aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/arm/Samsung-S3C24XX/Overview.txt42
-rw-r--r--Documentation/kernel-parameters.txt11
-rw-r--r--Documentation/power/swsusp.txt51
-rw-r--r--Documentation/power/userland-swsusp.txt149
-rw-r--r--Documentation/power/video.txt74
-rw-r--r--Documentation/powerpc/booting-without-of.txt72
-rw-r--r--Documentation/powerpc/eeh-pci-error-recovery.txt15
-rw-r--r--Documentation/powerpc/hvcs.txt4
-rw-r--r--MAINTAINERS4
-rw-r--r--arch/arm/Kconfig16
-rw-r--r--arch/arm/Makefile1
-rw-r--r--arch/arm/common/Makefile1
-rw-r--r--arch/arm/common/dmabounce.c2
-rw-r--r--arch/arm/common/locomo.c49
-rw-r--r--arch/arm/common/sa1111.c46
-rw-r--r--arch/arm/common/scoop.c6
-rw-r--r--arch/arm/common/uengine.c (renamed from arch/arm/mach-ixp2000/uengine.c)2
-rw-r--r--arch/arm/common/vic.c49
-rw-r--r--arch/arm/configs/ep93xx_defconfig (renamed from arch/arm/configs/enp2611_defconfig)553
-rw-r--r--arch/arm/configs/ixdp2401_defconfig976
-rw-r--r--arch/arm/configs/ixdp2800_defconfig975
-rw-r--r--arch/arm/configs/ixdp2801_defconfig976
-rw-r--r--arch/arm/configs/ixp2000_defconfig (renamed from arch/arm/configs/ixdp2400_defconfig)61
-rw-r--r--arch/arm/configs/s3c2410_defconfig147
-rw-r--r--arch/arm/kernel/apm.c4
-rw-r--r--arch/arm/kernel/bios32.c4
-rw-r--r--arch/arm/kernel/debug.S1
-rw-r--r--arch/arm/kernel/ecard.c4
-rw-r--r--arch/arm/kernel/entry-armv.S2
-rw-r--r--arch/arm/kernel/head.S7
-rw-r--r--arch/arm/kernel/irq.c11
-rw-r--r--arch/arm/lib/delay.S20
-rw-r--r--arch/arm/lib/io-acorn.S1
-rw-r--r--arch/arm/mach-at91rm9200/clock.c85
-rw-r--r--arch/arm/mach-at91rm9200/gpio.c4
-rw-r--r--arch/arm/mach-at91rm9200/time.c4
-rw-r--r--arch/arm/mach-ep93xx/Kconfig21
-rw-r--r--arch/arm/mach-ep93xx/Makefile10
-rw-r--r--arch/arm/mach-ep93xx/Makefile.boot2
-rw-r--r--arch/arm/mach-ep93xx/core.c374
-rw-r--r--arch/arm/mach-ep93xx/gesbc9312.c40
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c118
-rw-r--r--arch/arm/mach-footbridge/dc21285.c4
-rw-r--r--arch/arm/mach-integrator/impd1.c7
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c4
-rw-r--r--arch/arm/mach-iop3xx/iq31244-pci.c4
-rw-r--r--arch/arm/mach-iop3xx/iq80321-pci.c4
-rw-r--r--arch/arm/mach-iop3xx/iq80331-pci.c4
-rw-r--r--arch/arm/mach-iop3xx/iq80332-pci.c4
-rw-r--r--arch/arm/mach-ixp2000/Kconfig9
-rw-r--r--arch/arm/mach-ixp2000/Makefile2
-rw-r--r--arch/arm/mach-ixp2000/core.c13
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x01.c20
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c3
-rw-r--r--arch/arm/mach-ixp4xx/common.c5
-rw-r--r--arch/arm/mach-lh7a40x/common.h1
-rw-r--r--arch/arm/mach-lh7a40x/irq-kev7a400.c1
-rw-r--r--arch/arm/mach-lh7a40x/irq-lh7a400.c2
-rw-r--r--arch/arm/mach-lh7a40x/irq-lh7a404.c3
-rw-r--r--arch/arm/mach-lh7a40x/irq-lpd7a40x.c1
-rw-r--r--arch/arm/mach-pxa/Makefile2
-rw-r--r--arch/arm/mach-pxa/clock.c124
-rw-r--r--arch/arm/mach-pxa/corgi.c1
-rw-r--r--arch/arm/mach-pxa/poodle.c1
-rw-r--r--arch/arm/mach-pxa/spitz.c1
-rw-r--r--arch/arm/mach-pxa/tosa.c1
-rw-r--r--arch/arm/mach-s3c2410/Kconfig7
-rw-r--r--arch/arm/mach-s3c2410/Makefile1
-rw-r--r--arch/arm/mach-s3c2410/clock.c178
-rw-r--r--arch/arm/mach-s3c2410/clock.h8
-rw-r--r--arch/arm/mach-s3c2410/mach-osiris.c294
-rw-r--r--arch/arm/mach-s3c2410/s3c2440-clock.c89
-rw-r--r--arch/arm/mach-s3c2410/time.c8
-rw-r--r--arch/arm/mach-sa1100/Makefile2
-rw-r--r--arch/arm/mach-sa1100/clock.c132
-rw-r--r--arch/arm/mach-versatile/core.c2
-rw-r--r--arch/arm/mm/Kconfig2
-rw-r--r--arch/arm/mm/init.c1
-rw-r--r--arch/arm/mm/ioremap.c1
-rw-r--r--arch/arm/mm/proc-arm1020.S1
-rw-r--r--arch/arm/mm/proc-arm1020e.S1
-rw-r--r--arch/arm/mm/proc-arm720.S1
-rw-r--r--arch/arm/mm/proc-arm920.S1
-rw-r--r--arch/arm/mm/proc-arm922.S1
-rw-r--r--arch/arm/mm/proc-arm925.S1
-rw-r--r--arch/arm/mm/proc-arm926.S1
-rw-r--r--arch/arm/mm/proc-xscale.S1
-rw-r--r--arch/arm/oprofile/common.c34
-rw-r--r--arch/arm/oprofile/op_counter.h2
-rw-r--r--arch/arm/vfp/entry.S1
-rw-r--r--arch/cris/kernel/irq.c10
-rw-r--r--arch/frv/kernel/irq.c10
-rw-r--r--arch/i386/Kconfig24
-rw-r--r--arch/i386/Kconfig.debug9
-rw-r--r--arch/i386/kernel/Makefile2
-rw-r--r--arch/i386/kernel/alternative.c321
-rw-r--r--arch/i386/kernel/apic.c1
-rw-r--r--arch/i386/kernel/cpu/centaur.c1
-rw-r--r--arch/i386/kernel/cpu/common.c47
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c4
-rw-r--r--arch/i386/kernel/cpu/intel.c12
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c4
-rw-r--r--arch/i386/kernel/cpu/proc.c2
-rw-r--r--arch/i386/kernel/crash.c2
-rw-r--r--arch/i386/kernel/entry.S4
-rw-r--r--arch/i386/kernel/head.S5
-rw-r--r--arch/i386/kernel/io_apic.c25
-rw-r--r--arch/i386/kernel/kprobes.c4
-rw-r--r--arch/i386/kernel/module.c32
-rw-r--r--arch/i386/kernel/mpparse.c7
-rw-r--r--arch/i386/kernel/nmi.c6
-rw-r--r--arch/i386/kernel/process.c2
-rw-r--r--arch/i386/kernel/ptrace.c4
-rw-r--r--arch/i386/kernel/semaphore.c8
-rw-r--r--arch/i386/kernel/setup.c118
-rw-r--r--arch/i386/kernel/signal.c7
-rw-r--r--arch/i386/kernel/smpboot.c3
-rw-r--r--arch/i386/kernel/topology.c9
-rw-r--r--arch/i386/kernel/traps.c57
-rw-r--r--arch/i386/kernel/vmlinux.lds.S20
-rw-r--r--arch/i386/kernel/vsyscall-sysenter.S3
-rw-r--r--arch/i386/mach-es7000/es7000.h5
-rw-r--r--arch/i386/mach-es7000/es7000plat.c6
-rw-r--r--arch/i386/mm/fault.c210
-rw-r--r--arch/i386/mm/init.c45
-rw-r--r--arch/i386/oprofile/nmi_int.c7
-rw-r--r--arch/ia64/hp/sim/simserial.c7
-rw-r--r--arch/m32r/kernel/irq.c10
-rw-r--r--arch/m68k/bvme6000/rtc.c4
-rw-r--r--arch/mips/kernel/irq.c10
-rw-r--r--arch/mips/kernel/smp.c4
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c5
-rw-r--r--arch/parisc/kernel/smp.c25
-rw-r--r--arch/powerpc/Kconfig38
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/powerpc/boot/install.sh2
-rw-r--r--arch/powerpc/boot/main.c4
-rw-r--r--arch/powerpc/configs/mpc8540_ads_defconfig721
-rw-r--r--arch/powerpc/kernel/asm-offsets.c3
-rw-r--r--arch/powerpc/kernel/cputable.c12
-rw-r--r--arch/powerpc/kernel/entry_64.S11
-rw-r--r--arch/powerpc/kernel/firmware.c25
-rw-r--r--arch/powerpc/kernel/head_44x.S2
-rw-r--r--arch/powerpc/kernel/head_64.S11
-rw-r--r--arch/powerpc/kernel/head_8xx.S2
-rw-r--r--arch/powerpc/kernel/head_booke.h363
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S6
-rw-r--r--arch/powerpc/kernel/iomap.c2
-rw-r--r--arch/powerpc/kernel/iommu.c1
-rw-r--r--arch/powerpc/kernel/irq.c37
-rw-r--r--arch/powerpc/kernel/kprobes.c5
-rw-r--r--arch/powerpc/kernel/of_device.c5
-rw-r--r--arch/powerpc/kernel/pci_iommu.c1
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c1
-rw-r--r--arch/powerpc/kernel/process.c9
-rw-r--r--arch/powerpc/kernel/prom.c4
-rw-r--r--arch/powerpc/kernel/ptrace-common.h2
-rw-r--r--arch/powerpc/kernel/rtas-proc.c1
-rw-r--r--arch/powerpc/kernel/rtas_pci.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c5
-rw-r--r--arch/powerpc/kernel/setup_32.c5
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kernel/signal_64.c2
-rw-r--r--arch/powerpc/kernel/smp.c4
-rw-r--r--arch/powerpc/kernel/time.c241
-rw-r--r--arch/powerpc/kernel/vdso.c2
-rw-r--r--arch/powerpc/lib/copypage_64.S2
-rw-r--r--arch/powerpc/lib/copyuser_64.S2
-rw-r--r--arch/powerpc/lib/e2a.c14
-rw-r--r--arch/powerpc/lib/memcpy_64.S2
-rw-r--r--arch/powerpc/lib/rheap.c2
-rw-r--r--arch/powerpc/mm/fault.c2
-rw-r--r--arch/powerpc/mm/hash_low_32.S2
-rw-r--r--arch/powerpc/mm/hash_utils_64.c32
-rw-r--r--arch/powerpc/mm/init_64.c48
-rw-r--r--arch/powerpc/mm/lmb.c16
-rw-r--r--arch/powerpc/mm/mem.c3
-rw-r--r--arch/powerpc/mm/mmap.c2
-rw-r--r--arch/powerpc/mm/numa.c160
-rw-r--r--arch/powerpc/mm/slb_low.S2
-rw-r--r--arch/powerpc/mm/stab.c4
-rw-r--r--arch/powerpc/mm/tlb_64.c2
-rw-r--r--arch/powerpc/oprofile/op_model_power4.c3
-rw-r--r--arch/powerpc/platforms/83xx/Makefile4
-rw-r--r--arch/powerpc/platforms/83xx/misc.c55
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.c89
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.h2
-rw-r--r--arch/powerpc/platforms/83xx/mpc83xx.h5
-rw-r--r--arch/powerpc/platforms/83xx/pci.c21
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig74
-rw-r--r--arch/powerpc/platforms/85xx/Makefile6
-rw-r--r--arch/powerpc/platforms/85xx/misc.c31
-rw-r--r--arch/powerpc/platforms/85xx/mpc8540_ads.h36
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx.h18
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c244
-rw-r--r--arch/powerpc/platforms/85xx/pci.c96
-rw-r--r--arch/powerpc/platforms/Makefile2
-rw-r--r--arch/powerpc/platforms/chrp/pegasos_eth.c2
-rw-r--r--arch/powerpc/platforms/chrp/setup.c2
-rw-r--r--arch/powerpc/platforms/chrp/time.c2
-rw-r--r--arch/powerpc/platforms/iseries/mf.c112
-rw-r--r--arch/powerpc/platforms/iseries/setup.c72
-rw-r--r--arch/powerpc/platforms/maple/time.c2
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c2
-rw-r--r--arch/powerpc/platforms/powermac/feature.c2
-rw-r--r--arch/powerpc/platforms/powermac/nvram.c2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c8
-rw-r--r--arch/powerpc/platforms/powermac/smp.c4
-rw-r--r--arch/powerpc/platforms/pseries/Makefile3
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c103
-rw-r--r--arch/powerpc/platforms/pseries/firmware.h17
-rw-r--r--arch/powerpc/platforms/pseries/hvCall.S2
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c4
-rw-r--r--arch/powerpc/platforms/pseries/pci.c2
-rw-r--r--arch/powerpc/platforms/pseries/setup.c67
-rw-r--r--arch/powerpc/platforms/pseries/smp.c2
-rw-r--r--arch/powerpc/platforms/pseries/xics.c3
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c2
-rw-r--r--arch/powerpc/sysdev/dcr.S2
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c292
-rw-r--r--arch/powerpc/sysdev/ipic.h2
-rw-r--r--arch/powerpc/xmon/xmon.c30
-rw-r--r--arch/ppc/4xx_io/serial_sicc.c5
-rw-r--r--arch/ppc/8xx_io/commproc.c6
-rw-r--r--arch/ppc/Kconfig47
-rw-r--r--arch/ppc/Kconfig.debug2
-rw-r--r--arch/ppc/amiga/amiints.c2
-rw-r--r--arch/ppc/amiga/bootinfo.c2
-rw-r--r--arch/ppc/amiga/cia.c2
-rw-r--r--arch/ppc/amiga/config.c2
-rw-r--r--arch/ppc/amiga/ints.c2
-rw-r--r--arch/ppc/boot/Makefile3
-rw-r--r--arch/ppc/boot/common/Makefile3
-rw-r--r--arch/ppc/boot/common/bootinfo.c2
-rw-r--r--arch/ppc/boot/common/misc-common.c2
-rw-r--r--arch/ppc/boot/common/ns16550.c3
-rw-r--r--arch/ppc/boot/common/serial_stub.c2
-rw-r--r--arch/ppc/boot/common/util.S2
-rw-r--r--arch/ppc/boot/include/mpc10x.h2
-rw-r--r--arch/ppc/boot/simple/Makefile1
-rw-r--r--arch/ppc/boot/simple/cpc700_memory.c2
-rw-r--r--arch/ppc/boot/simple/embed_config.c7
-rw-r--r--arch/ppc/boot/simple/head.S9
-rw-r--r--arch/ppc/boot/simple/misc-chestnut.c2
-rw-r--r--arch/ppc/boot/simple/misc-cpci690.c2
-rw-r--r--arch/ppc/boot/simple/misc-ev64260.c2
-rw-r--r--arch/ppc/boot/simple/misc-ev64360.c1
-rw-r--r--arch/ppc/boot/simple/misc-katana.c2
-rw-r--r--arch/ppc/boot/simple/misc-mv64x60.c2
-rw-r--r--arch/ppc/boot/simple/misc-prep.c2
-rw-r--r--arch/ppc/boot/simple/misc-radstone_ppc7d.c2
-rw-r--r--arch/ppc/boot/simple/misc-spruce.c2
-rw-r--r--arch/ppc/boot/simple/misc.c2
-rw-r--r--arch/ppc/boot/simple/mpc10x_memory.c2
-rw-r--r--arch/ppc/boot/simple/mpc52xx_tty.c2
-rw-r--r--arch/ppc/boot/simple/mv64x60_tty.c2
-rw-r--r--arch/ppc/boot/simple/openbios.c2
-rw-r--r--arch/ppc/boot/simple/relocate.S2
-rw-r--r--arch/ppc/boot/utils/mkbugboot.c2
-rw-r--r--arch/ppc/configs/ml300_defconfig739
-rw-r--r--arch/ppc/configs/ml403_defconfig740
-rw-r--r--arch/ppc/kernel/head_44x.S2
-rw-r--r--arch/ppc/kernel/head_8xx.S2
-rw-r--r--arch/ppc/kernel/head_fsl_booke.S6
-rw-r--r--arch/ppc/kernel/setup.c10
-rw-r--r--arch/ppc/kernel/smp-tbsync.c3
-rw-r--r--arch/ppc/kernel/traps.c2
-rw-r--r--arch/ppc/lib/rheap.c2
-rw-r--r--arch/ppc/math-emu/math.c2
-rw-r--r--arch/ppc/mm/44x_mmu.c4
-rw-r--r--arch/ppc/mm/fault.c2
-rw-r--r--arch/ppc/mm/hashtable.S2
-rw-r--r--arch/ppc/platforms/4xx/Kconfig23
-rw-r--r--arch/ppc/platforms/4xx/Makefile4
-rw-r--r--arch/ppc/platforms/4xx/bamboo.c2
-rw-r--r--arch/ppc/platforms/4xx/bamboo.h2
-rw-r--r--arch/ppc/platforms/4xx/bubinga.h2
-rw-r--r--arch/ppc/platforms/4xx/cpci405.c2
-rw-r--r--arch/ppc/platforms/4xx/ebony.c2
-rw-r--r--arch/ppc/platforms/4xx/ebony.h2
-rw-r--r--arch/ppc/platforms/4xx/ep405.c2
-rw-r--r--arch/ppc/platforms/4xx/ep405.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm405ep.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm405ep.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm405gp.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm405gpr.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm405gpr.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440ep.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440ep.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gp.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gp.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gx.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gx.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440sp.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440sp.h2
-rw-r--r--arch/ppc/platforms/4xx/ibmnp405h.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmnp405h.h2
-rw-r--r--arch/ppc/platforms/4xx/ibmstb4.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmstb4.h2
-rw-r--r--arch/ppc/platforms/4xx/ibmstbx25.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmstbx25.h2
-rw-r--r--arch/ppc/platforms/4xx/luan.c2
-rw-r--r--arch/ppc/platforms/4xx/luan.h2
-rw-r--r--arch/ppc/platforms/4xx/ocotea.c2
-rw-r--r--arch/ppc/platforms/4xx/ocotea.h2
-rw-r--r--arch/ppc/platforms/4xx/ppc440spe.c2
-rw-r--r--arch/ppc/platforms/4xx/ppc440spe.h2
-rw-r--r--arch/ppc/platforms/4xx/redwood5.c2
-rw-r--r--arch/ppc/platforms/4xx/redwood5.h2
-rw-r--r--arch/ppc/platforms/4xx/redwood6.c2
-rw-r--r--arch/ppc/platforms/4xx/redwood6.h2
-rw-r--r--arch/ppc/platforms/4xx/sycamore.c2
-rw-r--r--arch/ppc/platforms/4xx/sycamore.h2
-rw-r--r--arch/ppc/platforms/4xx/virtex-ii_pro.c60
-rw-r--r--arch/ppc/platforms/4xx/virtex-ii_pro.h99
-rw-r--r--arch/ppc/platforms/4xx/virtex.c56
-rw-r--r--arch/ppc/platforms/4xx/virtex.h35
-rw-r--r--arch/ppc/platforms/4xx/walnut.c2
-rw-r--r--arch/ppc/platforms/4xx/walnut.h2
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml300.c76
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml300.h6
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml403.c177
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml403.h49
-rw-r--r--arch/ppc/platforms/4xx/xparameters/xparameters.h37
-rw-r--r--arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h243
-rw-r--r--arch/ppc/platforms/4xx/yucca.c2
-rw-r--r--arch/ppc/platforms/4xx/yucca.h2
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.c2
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.h4
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc8555_cds.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.h2
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.c2
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.h2
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.c2
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.h2
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.c2
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.h2
-rw-r--r--arch/ppc/platforms/85xx/tqm85xx.c2
-rw-r--r--arch/ppc/platforms/85xx/tqm85xx.h2
-rw-r--r--arch/ppc/platforms/Makefile3
-rw-r--r--arch/ppc/platforms/apus_setup.c2
-rw-r--r--arch/ppc/platforms/chestnut.c2
-rw-r--r--arch/ppc/platforms/chestnut.h2
-rw-r--r--arch/ppc/platforms/chrp_pegasos_eth.c2
-rw-r--r--arch/ppc/platforms/chrp_setup.c2
-rw-r--r--arch/ppc/platforms/chrp_time.c2
-rw-r--r--arch/ppc/platforms/cpci690.c4
-rw-r--r--arch/ppc/platforms/cpci690.h2
-rw-r--r--arch/ppc/platforms/ev64260.c4
-rw-r--r--arch/ppc/platforms/ev64260.h2
-rw-r--r--arch/ppc/platforms/ev64360.c4
-rw-r--r--arch/ppc/platforms/ev64360.h2
-rw-r--r--arch/ppc/platforms/fads.h2
-rw-r--r--arch/ppc/platforms/gemini.h3
-rw-r--r--arch/ppc/platforms/gemini_prom.S2
-rw-r--r--arch/ppc/platforms/gemini_setup.c2
-rw-r--r--arch/ppc/platforms/hdpu.c5
-rw-r--r--arch/ppc/platforms/hdpu.h2
-rw-r--r--arch/ppc/platforms/katana.c7
-rw-r--r--arch/ppc/platforms/katana.h2
-rw-r--r--arch/ppc/platforms/lite5200.c2
-rw-r--r--arch/ppc/platforms/lite5200.h2
-rw-r--r--arch/ppc/platforms/lopec.c2
-rw-r--r--arch/ppc/platforms/mpc8272ads_setup.c236
-rw-r--r--arch/ppc/platforms/mpc866ads_setup.c273
-rw-r--r--arch/ppc/platforms/mpc885ads_setup.c389
-rw-r--r--arch/ppc/platforms/mvme5100.c2
-rw-r--r--arch/ppc/platforms/pal4.h2
-rw-r--r--arch/ppc/platforms/pal4_pci.c2
-rw-r--r--arch/ppc/platforms/pal4_serial.h2
-rw-r--r--arch/ppc/platforms/pal4_setup.c2
-rw-r--r--arch/ppc/platforms/powerpmc250.c2
-rw-r--r--arch/ppc/platforms/pplus.c2
-rw-r--r--arch/ppc/platforms/pplus.h2
-rw-r--r--arch/ppc/platforms/pq2ads.c2
-rw-r--r--arch/ppc/platforms/pq2ads.h4
-rw-r--r--arch/ppc/platforms/pq2ads_pd.h114
-rw-r--r--arch/ppc/platforms/prep_setup.c2
-rw-r--r--arch/ppc/platforms/prpmc750.c2
-rw-r--r--arch/ppc/platforms/prpmc800.c2
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.c7
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.h2
-rw-r--r--arch/ppc/platforms/sandpoint.c2
-rw-r--r--arch/ppc/platforms/sandpoint.h2
-rw-r--r--arch/ppc/platforms/sbc82xx.c2
-rw-r--r--arch/ppc/platforms/spruce.c2
-rw-r--r--arch/ppc/platforms/tqm8260_setup.c2
-rw-r--r--arch/ppc/syslib/Makefile4
-rw-r--r--arch/ppc/syslib/cpc700.h2
-rw-r--r--arch/ppc/syslib/cpc700_pic.c2
-rw-r--r--arch/ppc/syslib/cpc710.h2
-rw-r--r--arch/ppc/syslib/gen550.h2
-rw-r--r--arch/ppc/syslib/gen550_dbg.c2
-rw-r--r--arch/ppc/syslib/gen550_kgdb.c2
-rw-r--r--arch/ppc/syslib/gt64260_pic.c2
-rw-r--r--arch/ppc/syslib/harrier.c2
-rw-r--r--arch/ppc/syslib/hawk_common.c2
-rw-r--r--arch/ppc/syslib/ibm440gp_common.c2
-rw-r--r--arch/ppc/syslib/ibm440gp_common.h2
-rw-r--r--arch/ppc/syslib/ibm440gx_common.c2
-rw-r--r--arch/ppc/syslib/ibm440gx_common.h2
-rw-r--r--arch/ppc/syslib/ibm440sp_common.c2
-rw-r--r--arch/ppc/syslib/ibm440sp_common.h2
-rw-r--r--arch/ppc/syslib/ibm44x_common.c2
-rw-r--r--arch/ppc/syslib/ibm44x_common.h2
-rw-r--r--arch/ppc/syslib/m8260_pci_erratum9.c2
-rw-r--r--arch/ppc/syslib/m8260_setup.c2
-rw-r--r--arch/ppc/syslib/m8xx_setup.c65
-rw-r--r--arch/ppc/syslib/m8xx_wdt.c3
-rw-r--r--arch/ppc/syslib/mpc10x_common.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_pci.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_pci.h2
-rw-r--r--arch/ppc/syslib/mpc52xx_pic.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_setup.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_sys.c2
-rw-r--r--arch/ppc/syslib/mpc83xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc83xx_sys.c2
-rw-r--r--arch/ppc/syslib/mpc85xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc85xx_sys.c2
-rw-r--r--arch/ppc/syslib/mpc8xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc8xx_sys.c2
-rw-r--r--arch/ppc/syslib/mv64360_pic.c2
-rw-r--r--arch/ppc/syslib/mv64x60.c2
-rw-r--r--arch/ppc/syslib/mv64x60_dbg.c2
-rw-r--r--arch/ppc/syslib/mv64x60_win.c2
-rw-r--r--arch/ppc/syslib/ocp.c3
-rw-r--r--arch/ppc/syslib/open_pic.c2
-rw-r--r--arch/ppc/syslib/open_pic2.c2
-rw-r--r--arch/ppc/syslib/open_pic_defs.h2
-rw-r--r--arch/ppc/syslib/pci_auto.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_dma.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_pic.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_pm.c47
-rw-r--r--arch/ppc/syslib/ppc4xx_sgdma.c2
-rw-r--r--arch/ppc/syslib/ppc83xx_setup.c2
-rw-r--r--arch/ppc/syslib/ppc83xx_setup.h2
-rw-r--r--arch/ppc/syslib/ppc85xx_common.c2
-rw-r--r--arch/ppc/syslib/ppc85xx_common.h2
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.c2
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.h2
-rw-r--r--arch/ppc/syslib/ppc_sys.c179
-rw-r--r--arch/ppc/syslib/pq2_devices.c2
-rw-r--r--arch/ppc/syslib/pq2_sys.c2
-rw-r--r--arch/ppc/syslib/prep_nvram.c2
-rw-r--r--arch/ppc/syslib/todc_time.c2
-rw-r--r--arch/ppc/syslib/xilinx_pic.c4
-rw-r--r--arch/s390/kernel/smp.c4
-rw-r--r--arch/sh/kernel/irq.c5
-rw-r--r--arch/sh/kernel/setup.c5
-rw-r--r--arch/sh64/kernel/irq.c5
-rw-r--r--arch/sparc/kernel/irq.c5
-rw-r--r--arch/sparc/kernel/smp.c24
-rw-r--r--arch/sparc/kernel/sun4d_irq.c8
-rw-r--r--arch/sparc/kernel/sun4d_smp.c8
-rw-r--r--arch/sparc/kernel/sun4m_smp.c6
-rw-r--r--arch/sparc64/kernel/irq.c4
-rw-r--r--arch/sparc64/kernel/smp.c30
-rw-r--r--arch/sparc64/mm/init.c4
-rw-r--r--arch/um/kernel/um_arch.c12
-rw-r--r--arch/x86_64/kernel/early_printk.c26
-rw-r--r--arch/x86_64/kernel/irq.c21
-rw-r--r--arch/x86_64/kernel/kprobes.c4
-rw-r--r--arch/x86_64/kernel/nmi.c4
-rw-r--r--arch/x86_64/kernel/signal.c4
-rw-r--r--arch/xtensa/kernel/irq.c15
-rw-r--r--arch/xtensa/platform-iss/console.c4
-rw-r--r--block/ioctl.c22
-rw-r--r--drivers/base/power/suspend.c5
-rw-r--r--drivers/block/cciss.c2
-rw-r--r--drivers/block/floppy.c17
-rw-r--r--drivers/block/loop.c18
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/pktcdvd.c27
-rw-r--r--drivers/block/rd.c4
-rw-r--r--drivers/cdrom/cdrom.c874
-rw-r--r--drivers/cdrom/cdu31a.c8
-rw-r--r--drivers/cdrom/cm206.c44
-rw-r--r--drivers/cdrom/sbpcd.c710
-rw-r--r--drivers/cdrom/viocd.c2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/amiserial.c18
-rw-r--r--drivers/char/generic_serial.c14
-rw-r--r--drivers/char/hvcs.c9
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/n_tty.c10
-rw-r--r--drivers/char/nwflash.c11
-rw-r--r--drivers/char/raw.c23
-rw-r--r--drivers/char/ser_a2232.c4
-rw-r--r--drivers/char/snsc.c8
-rw-r--r--drivers/char/snsc_event.c5
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/tty_io.c50
-rw-r--r--drivers/char/vme_scc.c2
-rw-r--r--drivers/char/vt.c22
-rw-r--r--drivers/char/watchdog/pcwd_usb.c7
-rw-r--r--drivers/connector/connector.c15
-rw-r--r--drivers/firmware/dcdbas.c23
-rw-r--r--drivers/ide/ide-cd.c110
-rw-r--r--drivers/ide/ide-disk.c11
-rw-r--r--drivers/ide/ide-floppy.c11
-rw-r--r--drivers/ide/ide-tape.c19
-rw-r--r--drivers/isdn/capi/kcapi.c17
-rw-r--r--drivers/isdn/hisax/config.c1
-rw-r--r--drivers/isdn/hisax/elsa.c1
-rw-r--r--drivers/macintosh/macio_asic.c5
-rw-r--r--drivers/macintosh/smu.c4
-rw-r--r--drivers/macintosh/therm_pm72.c2
-rw-r--r--drivers/macintosh/via-pmu.c5
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c1
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c1
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c1
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/Makefile4
-rw-r--r--drivers/net/au1000_eth.c18
-rw-r--r--drivers/net/depca.c2
-rw-r--r--drivers/net/ixp2000/enp2611.c2
-rw-r--r--drivers/net/ixp2000/ixpdev.c2
-rw-r--r--drivers/net/loopback.c4
-rw-r--r--drivers/net/ppp_generic.c25
-rw-r--r--drivers/net/sis900.c1
-rw-r--r--drivers/net/skge.c105
-rw-r--r--drivers/net/skge.h1
-rw-r--r--drivers/net/sky2.c33
-rw-r--r--drivers/net/sky2.h71
-rw-r--r--drivers/net/tulip/de2104x.c2
-rw-r--r--drivers/oprofile/cpu_buffer.c3
-rw-r--r--drivers/parport/parport_serial.c75
-rw-r--r--drivers/pnp/pnpbios/rsparser.c6
-rw-r--r--drivers/s390/block/dasd_ioctl.c8
-rw-r--r--drivers/s390/net/qeth_main.c57
-rw-r--r--drivers/s390/net/qeth_proc.c56
-rw-r--r--drivers/s390/net/qeth_sys.c2
-rw-r--r--drivers/scsi/Kconfig4
-rw-r--r--drivers/scsi/Makefile4
-rw-r--r--drivers/scsi/ahci.c135
-rw-r--r--drivers/scsi/ide-scsi.c11
-rw-r--r--drivers/scsi/libata-bmdma.c39
-rw-r--r--drivers/scsi/libata-core.c140
-rw-r--r--drivers/scsi/libata-scsi.c140
-rw-r--r--drivers/scsi/pdc_adma.c2
-rw-r--r--drivers/scsi/sata_mv.c5
-rw-r--r--drivers/scsi/sata_svw.c56
-rw-r--r--drivers/scsi/sata_vsc.c124
-rw-r--r--drivers/scsi/sr.c37
-rw-r--r--drivers/scsi/sr.h1
-rw-r--r--drivers/scsi/sr_ioctl.c19
-rw-r--r--drivers/serial/21285.c19
-rw-r--r--drivers/serial/68328serial.c9
-rw-r--r--drivers/serial/8250.c26
-rw-r--r--drivers/serial/8250_early.c9
-rw-r--r--drivers/serial/amba-pl010.c24
-rw-r--r--drivers/serial/amba-pl011.c20
-rw-r--r--drivers/serial/at91_serial.c24
-rw-r--r--drivers/serial/au1x00_uart.c37
-rw-r--r--drivers/serial/clps711x.c24
-rw-r--r--drivers/serial/crisv10.c68
-rw-r--r--drivers/serial/dz.c12
-rw-r--r--drivers/serial/imx.c26
-rw-r--r--drivers/serial/ip22zilog.c11
-rw-r--r--drivers/serial/m32r_sio.c41
-rw-r--r--drivers/serial/mpc52xx_uart.c11
-rw-r--r--drivers/serial/pmac_zilog.c23
-rw-r--r--drivers/serial/pxa.c26
-rw-r--r--drivers/serial/s3c2410.c26
-rw-r--r--drivers/serial/sa1100.c26
-rw-r--r--drivers/serial/serial_core.c21
-rw-r--r--drivers/serial/serial_lh7a40x.c17
-rw-r--r--drivers/serial/serial_txx9.c26
-rw-r--r--drivers/serial/sunsab.c10
-rw-r--r--drivers/serial/sunsu.c39
-rw-r--r--drivers/serial/sunzilog.c13
-rw-r--r--drivers/serial/vr41xx_siu.c16
-rw-r--r--drivers/tc/zs.c9
-rw-r--r--fs/9p/mux.c11
-rw-r--r--fs/adfs/file.c4
-rw-r--r--fs/autofs4/autofs_i.h3
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/autofs4/waitq.c16
-rw-r--r--fs/bio.c8
-rw-r--r--fs/block_dev.c28
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cifs/dir.c8
-rw-r--r--fs/cifs/fcntl.c4
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/cifs/inode.c16
-rw-r--r--fs/cifs/link.c16
-rw-r--r--fs/cifs/readdir.c4
-rw-r--r--fs/cifs/xattr.c16
-rw-r--r--fs/devpts/inode.c76
-rw-r--r--fs/dquot.c167
-rw-r--r--fs/eventpoll.c32
-rw-r--r--fs/ext2/namei.c54
-rw-r--r--fs/ext3/dir.c52
-rw-r--r--fs/ext3/file.c4
-rw-r--r--fs/ext3/inode.c16
-rw-r--r--fs/ext3/ioctl.c4
-rw-r--r--fs/ext3/super.c6
-rw-r--r--fs/fat/fatent.c6
-rw-r--r--fs/fcntl.c9
-rw-r--r--fs/file.c34
-rw-r--r--fs/file_table.c10
-rw-r--r--fs/hpfs/hpfs_fn.h5
-rw-r--r--fs/hpfs/inode.c10
-rw-r--r--fs/hpfs/namei.c60
-rw-r--r--fs/hpfs/super.c4
-rw-r--r--fs/inode.c18
-rw-r--r--fs/inotify.c116
-rw-r--r--fs/jbd/checkpoint.c4
-rw-r--r--fs/jbd/journal.c4
-rw-r--r--fs/jbd/transaction.c4
-rw-r--r--fs/jffs/inode-v23.c86
-rw-r--r--fs/jffs/intrep.c6
-rw-r--r--fs/jffs/jffs_fm.c2
-rw-r--r--fs/jffs/jffs_fm.h5
-rw-r--r--fs/libfs.c14
-rw-r--r--fs/minix/namei.c48
-rw-r--r--fs/namei.c12
-rw-r--r--fs/ncpfs/file.c4
-rw-r--r--fs/ncpfs/inode.c6
-rw-r--r--fs/ncpfs/ncplib_kernel.c4
-rw-r--r--fs/ncpfs/sock.c34
-rw-r--r--fs/open.c8
-rw-r--r--fs/proc/proc_misc.c2
-rw-r--r--fs/qnx4/file.c3
-rw-r--r--fs/quota.c6
-rw-r--r--fs/quota_v2.c2
-rw-r--r--fs/ramfs/file-mmu.c11
-rw-r--r--fs/seq_file.c10
-rw-r--r--fs/super.c10
-rw-r--r--fs/sysv/namei.c48
-rw-r--r--fs/udf/balloc.c36
-rw-r--r--fs/udf/ialloc.c8
-rw-r--r--fs/udf/super.c2
-rw-r--r--fs/ufs/file.c10
-rw-r--r--fs/ufs/namei.c48
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c7
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.c3
-rw-r--r--include/asm-alpha/mmu_context.h5
-rw-r--r--include/asm-alpha/topology.h4
-rw-r--r--include/asm-arm/arch-aaec2000/param.h15
-rw-r--r--include/asm-arm/arch-at91rm9200/param.h28
-rw-r--r--include/asm-arm/arch-cl7500/debug-macro.S14
-rw-r--r--include/asm-arm/arch-cl7500/param.h5
-rw-r--r--include/asm-arm/arch-clps711x/param.h19
-rw-r--r--include/asm-arm/arch-ebsa110/debug-macro.S19
-rw-r--r--include/asm-arm/arch-ebsa110/param.h4
-rw-r--r--include/asm-arm/arch-ebsa285/debug-macro.S18
-rw-r--r--include/asm-arm/arch-ebsa285/param.h3
-rw-r--r--include/asm-arm/arch-ep93xx/debug-macro.S22
-rw-r--r--include/asm-arm/arch-ep93xx/dma.h3
-rw-r--r--include/asm-arm/arch-ep93xx/entry-macro.S53
-rw-r--r--include/asm-arm/arch-ep93xx/ep93xx-regs.h125
-rw-r--r--include/asm-arm/arch-ep93xx/gesbc9312.h3
-rw-r--r--include/asm-arm/arch-ep93xx/gpio.h107
-rw-r--r--include/asm-arm/arch-ep93xx/hardware.h12
-rw-r--r--include/asm-arm/arch-ep93xx/io.h8
-rw-r--r--include/asm-arm/arch-ep93xx/irqs.h80
-rw-r--r--include/asm-arm/arch-ep93xx/memory.h14
-rw-r--r--include/asm-arm/arch-ep93xx/platform.h14
-rw-r--r--include/asm-arm/arch-ep93xx/system.h26
-rw-r--r--include/asm-arm/arch-ep93xx/timex.h5
-rw-r--r--include/asm-arm/arch-ep93xx/ts72xx.h90
-rw-r--r--include/asm-arm/arch-ep93xx/uncompress.h53
-rw-r--r--include/asm-arm/arch-ep93xx/vmalloc.h5
-rw-r--r--include/asm-arm/arch-h720x/irq.h14
-rw-r--r--include/asm-arm/arch-h720x/param.h10
-rw-r--r--include/asm-arm/arch-imx/irq.h20
-rw-r--r--include/asm-arm/arch-imx/param.h19
-rw-r--r--include/asm-arm/arch-integrator/debug-macro.S18
-rw-r--r--include/asm-arm/arch-integrator/param.h19
-rw-r--r--include/asm-arm/arch-iop3xx/debug-macro.S19
-rw-r--r--include/asm-arm/arch-iop3xx/param.h3
-rw-r--r--include/asm-arm/arch-ixp2000/debug-macro.S17
-rw-r--r--include/asm-arm/arch-ixp2000/irq.h13
-rw-r--r--include/asm-arm/arch-ixp2000/ixdp2x00.h5
-rw-r--r--include/asm-arm/arch-ixp2000/ixp2000-regs.h4
-rw-r--r--include/asm-arm/arch-ixp2000/param.h3
-rw-r--r--include/asm-arm/arch-ixp2000/system.h2
-rw-r--r--include/asm-arm/arch-ixp4xx/debug-macro.S15
-rw-r--r--include/asm-arm/arch-ixp4xx/irq.h13
-rw-r--r--include/asm-arm/arch-ixp4xx/param.h3
-rw-r--r--include/asm-arm/arch-ixp4xx/platform.h27
-rw-r--r--include/asm-arm/arch-l7200/param.h19
-rw-r--r--include/asm-arm/arch-lh7a40x/irq.h11
-rw-r--r--include/asm-arm/arch-lh7a40x/param.h9
-rw-r--r--include/asm-arm/arch-omap/param.h8
-rw-r--r--include/asm-arm/arch-pxa/debug-macro.S17
-rw-r--r--include/asm-arm/arch-pxa/irq.h14
-rw-r--r--include/asm-arm/arch-pxa/param.h3
-rw-r--r--include/asm-arm/arch-realview/debug-macro.S18
-rw-r--r--include/asm-arm/arch-realview/param.h19
-rw-r--r--include/asm-arm/arch-rpc/debug-macro.S19
-rw-r--r--include/asm-arm/arch-rpc/param.h3
-rw-r--r--include/asm-arm/arch-s3c2410/osiris-cpld.h25
-rw-r--r--include/asm-arm/arch-s3c2410/osiris-map.h41
-rw-r--r--include/asm-arm/arch-s3c2410/param.h27
-rw-r--r--include/asm-arm/arch-s3c2410/regs-gpio.h2
-rw-r--r--include/asm-arm/arch-sa1100/debug-macro.S1
-rw-r--r--include/asm-arm/arch-sa1100/param.h3
-rw-r--r--include/asm-arm/arch-shark/param.h5
-rw-r--r--include/asm-arm/arch-versatile/debug-macro.S18
-rw-r--r--include/asm-arm/arch-versatile/param.h19
-rw-r--r--include/asm-arm/delay.h12
-rw-r--r--include/asm-arm/hardware/debug-8250.S29
-rw-r--r--include/asm-arm/hardware/debug-pl01x.S29
-rw-r--r--include/asm-arm/hardware/uengine.h (renamed from include/asm-arm/arch-ixp2000/uengine.h)0
-rw-r--r--include/asm-arm/hardware/vic.h2
-rw-r--r--include/asm-arm/mach/arch.h5
-rw-r--r--include/asm-arm/mach/irq.h7
-rw-r--r--include/asm-arm/param.h7
-rw-r--r--include/asm-generic/bug.h4
-rw-r--r--include/asm-generic/percpu.h7
-rw-r--r--include/asm-i386/alternative.h129
-rw-r--r--include/asm-i386/arch_hooks.h3
-rw-r--r--include/asm-i386/atomic.h36
-rw-r--r--include/asm-i386/bitops.h7
-rw-r--r--include/asm-i386/cache.h2
-rw-r--r--include/asm-i386/cpufeature.h1
-rw-r--r--include/asm-i386/mach-default/do_timer.h2
-rw-r--r--include/asm-i386/mach-es7000/mach_mpparse.h10
-rw-r--r--include/asm-i386/mach-visws/do_timer.h2
-rw-r--r--include/asm-i386/mach-voyager/do_timer.h2
-rw-r--r--include/asm-i386/mpspec.h1
-rw-r--r--include/asm-i386/mtrr.h1
-rw-r--r--include/asm-i386/mutex.h6
-rw-r--r--include/asm-i386/pgtable-2level.h2
-rw-r--r--include/asm-i386/pgtable-3level.h2
-rw-r--r--include/asm-i386/rwlock.h56
-rw-r--r--include/asm-i386/semaphore.h8
-rw-r--r--include/asm-i386/spinlock.h34
-rw-r--r--include/asm-i386/system.h62
-rw-r--r--include/asm-i386/uaccess.h12
-rw-r--r--include/asm-i386/unistd.h36
-rw-r--r--include/asm-ia64/atomic.h8
-rw-r--r--include/asm-ia64/cache.h2
-rw-r--r--include/asm-m68k/atomic.h8
-rw-r--r--include/asm-parisc/cache.h2
-rw-r--r--include/asm-powerpc/atomic.h38
-rw-r--r--include/asm-powerpc/cputable.h38
-rw-r--r--include/asm-powerpc/cputime.h202
-rw-r--r--include/asm-powerpc/firmware.h16
-rw-r--r--include/asm-powerpc/irq.h6
-rw-r--r--include/asm-powerpc/iseries/mf.h7
-rw-r--r--include/asm-powerpc/lmb.h19
-rw-r--r--include/asm-powerpc/mmu.h1
-rw-r--r--include/asm-powerpc/paca.h7
-rw-r--r--include/asm-powerpc/percpu.h7
-rw-r--r--include/asm-powerpc/pgtable-4k.h11
-rw-r--r--include/asm-powerpc/pgtable.h9
-rw-r--r--include/asm-powerpc/ppc_asm.h42
-rw-r--r--include/asm-powerpc/processor.h1
-rw-r--r--include/asm-powerpc/prom.h6
-rw-r--r--include/asm-powerpc/rwsem.h2
-rw-r--r--include/asm-powerpc/synch.h2
-rw-r--r--include/asm-powerpc/system.h6
-rw-r--r--include/asm-powerpc/time.h15
-rw-r--r--include/asm-ppc/harrier.h2
-rw-r--r--include/asm-ppc/ibm44x.h2
-rw-r--r--include/asm-ppc/ibm4xx.h4
-rw-r--r--include/asm-ppc/io.h7
-rw-r--r--include/asm-ppc/mpc10x.h3
-rw-r--r--include/asm-ppc/mpc52xx.h1
-rw-r--r--include/asm-ppc/mpc8260.h1
-rw-r--r--include/asm-ppc/mpc83xx.h1
-rw-r--r--include/asm-ppc/mpc85xx.h1
-rw-r--r--include/asm-ppc/mpc8xx.h3
-rw-r--r--include/asm-ppc/pgtable.h6
-rw-r--r--include/asm-ppc/ppc_sys.h34
-rw-r--r--include/asm-ppc/time.h5
-rw-r--r--include/asm-ppc/todc.h2
-rw-r--r--include/asm-ppc/xparameters.h18
-rw-r--r--include/asm-s390/atomic.h18
-rw-r--r--include/asm-s390/percpu.h7
-rw-r--r--include/asm-sparc64/atomic.h10
-rw-r--r--include/asm-sparc64/cache.h2
-rw-r--r--include/asm-sparc64/percpu.h7
-rw-r--r--include/asm-um/alternative.h6
-rw-r--r--include/asm-x86_64/atomic.h8
-rw-r--r--include/asm-x86_64/cache.h2
-rw-r--r--include/asm-x86_64/percpu.h7
-rw-r--r--include/linux/ata.h7
-rw-r--r--include/linux/cache.h4
-rw-r--r--include/linux/cdrom.h5
-rw-r--r--include/linux/eventpoll.h8
-rw-r--r--include/linux/ext3_fs.h9
-rw-r--r--include/linux/ext3_fs_i.h7
-rw-r--r--include/linux/file.h28
-rw-r--r--include/linux/fs.h22
-rw-r--r--include/linux/generic_serial.h4
-rw-r--r--include/linux/genhd.h14
-rw-r--r--include/linux/init_task.h10
-rw-r--r--include/linux/jbd.h7
-rw-r--r--include/linux/kernel.h3
-rw-r--r--include/linux/kprobes.h3
-rw-r--r--include/linux/libata.h4
-rw-r--r--include/linux/loop.h3
-rw-r--r--include/linux/msdos_fs.h3
-rw-r--r--include/linux/nbd.h3
-rw-r--r--include/linux/ncp_fs_i.h2
-rw-r--r--include/linux/ncp_fs_sb.h5
-rw-r--r--include/linux/netfilter/x_tables.h64
-rw-r--r--include/linux/netfilter_arp/arp_tables.h37
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h70
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h69
-rw-r--r--include/linux/pm.h3
-rw-r--r--include/linux/profile.h2
-rw-r--r--include/linux/quota.h7
-rw-r--r--include/linux/raid/raid1.h2
-rw-r--r--include/linux/rcupdate.h2
-rw-r--r--include/linux/seq_file.h4
-rw-r--r--include/linux/serial_core.h3
-rw-r--r--include/linux/swap.h5
-rw-r--r--include/linux/tty.h8
-rw-r--r--include/linux/tty_flip.h12
-rw-r--r--include/linux/udf_fs_sb.h4
-rw-r--r--include/linux/vt_kern.h5
-rw-r--r--include/net/netfilter/nf_conntrack.h4
-rw-r--r--include/net/tc_act/tc_ipt.h4
-rw-r--r--init/do_mounts_initrd.c1
-rw-r--r--init/main.c26
-rw-r--r--kernel/auditsc.c2
-rw-r--r--kernel/cpuset.c212
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/fork.c8
-rw-r--r--kernel/kprobes.c14
-rw-r--r--kernel/kthread.c7
-rw-r--r--kernel/module.c53
-rw-r--r--kernel/panic.c97
-rw-r--r--kernel/posix-timers.c1
-rw-r--r--kernel/power/Makefile2
-rw-r--r--kernel/power/disk.c20
-rw-r--r--kernel/power/main.c2
-rw-r--r--kernel/power/pm.c21
-rw-r--r--kernel/power/power.h75
-rw-r--r--kernel/power/process.c61
-rw-r--r--kernel/power/snapshot.c335
-rw-r--r--kernel/power/swap.c544
-rw-r--r--kernel/power/swsusp.c887
-rw-r--r--kernel/power/user.c333
-rw-r--r--kernel/profile.c11
-rw-r--r--kernel/rcupdate.c14
-rw-r--r--kernel/sched.c13
-rw-r--r--kernel/signal.c11
-rw-r--r--kernel/spinlock.c9
-rw-r--r--kernel/sys.c46
-rw-r--r--lib/extable.c1
-rw-r--r--lib/reed_solomon/reed_solomon.c11
-rw-r--r--mm/readahead.c1
-rw-r--r--mm/swapfile.c57
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/netfilter/arp_tables.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c72
-rw-r--r--net/ipv4/netfilter/ip_tables.c15
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c1
-rw-r--r--net/ipv6/ipv6_sockglue.c4
-rw-r--r--net/ipv6/netfilter/ip6_tables.c15
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c1
-rw-r--r--net/netfilter/Kconfig6
-rw-r--r--net/netfilter/nf_conntrack_core.c35
-rw-r--r--net/netfilter/nf_conntrack_netlink.c84
-rw-r--r--net/netfilter/nf_conntrack_standalone.c2
-rw-r--r--net/netfilter/nfnetlink_queue.c19
-rw-r--r--net/netfilter/x_tables.c16
-rw-r--r--net/netfilter/xt_CLASSIFY.c12
-rw-r--r--net/netfilter/xt_CONNMARK.c12
-rw-r--r--net/netfilter/xt_MARK.c21
-rw-r--r--net/netfilter/xt_NFQUEUE.c19
-rw-r--r--net/netfilter/xt_NOTRACK.c12
-rw-r--r--net/netfilter/xt_comment.c12
-rw-r--r--net/netfilter/xt_connbytes.c12
-rw-r--r--net/netfilter/xt_connmark.c29
-rw-r--r--net/netfilter/xt_conntrack.c33
-rw-r--r--net/netfilter/xt_dccp.c12
-rw-r--r--net/netfilter/xt_helper.c29
-rw-r--r--net/netfilter/xt_length.c12
-rw-r--r--net/netfilter/xt_limit.c12
-rw-r--r--net/netfilter/xt_mac.c12
-rw-r--r--net/netfilter/xt_mark.c12
-rw-r--r--net/netfilter/xt_physdev.c12
-rw-r--r--net/netfilter/xt_pkttype.c12
-rw-r--r--net/netfilter/xt_policy.c18
-rw-r--r--net/netfilter/xt_realm.c5
-rw-r--r--net/netfilter/xt_sctp.c12
-rw-r--r--net/netfilter/xt_state.c41
-rw-r--r--net/netfilter/xt_string.c12
-rw-r--r--net/netfilter/xt_tcpmss.c12
-rw-r--r--net/netfilter/xt_tcpudp.c26
-rw-r--r--security/seclvl.c210
-rw-r--r--sound/oss/ac97_codec.c24
-rw-r--r--sound/oss/aci.c11
-rw-r--r--sound/oss/ad1889.c7
-rw-r--r--sound/oss/ad1889.h2
-rw-r--r--sound/oss/ali5455.c8
-rw-r--r--sound/oss/au1000.c44
-rw-r--r--sound/oss/au1550_ac97.c44
-rw-r--r--sound/oss/btaudio.c36
-rw-r--r--sound/oss/cmpci.c20
-rw-r--r--sound/oss/cs4281/cs4281m.c54
-rw-r--r--sound/oss/cs46xx.c75
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c10
-rw-r--r--sound/oss/emu10k1/hwaccess.h2
-rw-r--r--sound/oss/emu10k1/main.c2
-rw-r--r--sound/oss/emu10k1/midi.c14
-rw-r--r--sound/oss/es1370.c71
-rw-r--r--sound/oss/es1371.c71
-rw-r--r--sound/oss/esssolo1.c50
-rw-r--r--sound/oss/forte.c11
-rw-r--r--sound/oss/hal2.c22
-rw-r--r--sound/oss/i810_audio.c8
-rw-r--r--sound/oss/ite8172.c20
-rw-r--r--sound/oss/maestro.c26
-rw-r--r--sound/oss/maestro3.c20
-rw-r--r--sound/oss/nec_vrc5477.c20
-rw-r--r--sound/oss/rme96xx.c17
-rw-r--r--sound/oss/sonicvibes.c48
-rw-r--r--sound/oss/swarm_cs4297a.c39
-rw-r--r--sound/oss/trident.c62
-rw-r--r--sound/oss/via82cxxx_audio.c49
-rw-r--r--sound/oss/vwsnd.c61
-rw-r--r--sound/oss/ymfpci.c14
-rw-r--r--sound/oss/ymfpci.h3
932 files changed, 16795 insertions, 10761 deletions
diff --git a/Documentation/arm/Samsung-S3C24XX/Overview.txt b/Documentation/arm/Samsung-S3C24XX/Overview.txt
index 89aa89d526ac..8c6ee684174c 100644
--- a/Documentation/arm/Samsung-S3C24XX/Overview.txt
+++ b/Documentation/arm/Samsung-S3C24XX/Overview.txt
@@ -10,6 +10,8 @@ Introduction
10 by the 's3c2410' architecture of ARM Linux. Currently the S3C2410 and 10 by the 's3c2410' architecture of ARM Linux. Currently the S3C2410 and
11 the S3C2440 are supported CPUs. 11 the S3C2440 are supported CPUs.
12 12
13 Support for the S3C2400 series is in progress.
14
13 15
14Configuration 16Configuration
15------------- 17-------------
@@ -32,6 +34,11 @@ Machines
32 A general purpose development board, see EB2410ITX.txt for further 34 A general purpose development board, see EB2410ITX.txt for further
33 details 35 details
34 36
37 Simtec Electronics IM2440D20 (Osiris)
38
39 CPU Module from Simtec Electronics, with a S3C2440A CPU, nand flash
40 and a PCMCIA controller.
41
35 Samsung SMDK2410 42 Samsung SMDK2410
36 43
37 Samsung's own development board, geared for PDA work. 44 Samsung's own development board, geared for PDA work.
@@ -85,6 +92,26 @@ Adding New Machines
85 mailing list information. 92 mailing list information.
86 93
87 94
95I2C
96---
97
98 The hardware I2C core in the CPU is supported in single master
99 mode, and can be configured via platform data.
100
101
102RTC
103---
104
105 Support for the onboard RTC unit, including alarm function.
106
107
108Watchdog
109--------
110
111 The onchip watchdog is available via the standard watchdog
112 interface.
113
114
88NAND 115NAND
89---- 116----
90 117
@@ -121,6 +148,15 @@ Clock Management
121 various clock units 148 various clock units
122 149
123 150
151Suspend to RAM
152--------------
153
154 For boards that provide support for suspend to RAM, the
155 system can be placed into low power suspend.
156
157 See Suspend.txt for more information.
158
159
124Platform Data 160Platform Data
125------------- 161-------------
126 162
@@ -158,6 +194,7 @@ Platform Data
158 exported outside arch/arm/mach-s3c2410/, or exported to 194 exported outside arch/arm/mach-s3c2410/, or exported to
159 modules via EXPORT_SYMBOL() and related functions. 195 modules via EXPORT_SYMBOL() and related functions.
160 196
197
161Port Contributors 198Port Contributors
162----------------- 199-----------------
163 200
@@ -188,8 +225,11 @@ Document Changes
188 08 Mar 2005 - BJD - Added LCVR to list of people, updated introduction 225 08 Mar 2005 - BJD - Added LCVR to list of people, updated introduction
189 08 Mar 2005 - BJD - Added section on adding machines 226 08 Mar 2005 - BJD - Added section on adding machines
190 09 Sep 2005 - BJD - Added section on platform data 227 09 Sep 2005 - BJD - Added section on platform data
228 11 Feb 2006 - BJD - Added I2C, RTC and Watchdog sections
229 11 Feb 2006 - BJD - Added Osiris machine, and S3C2400 information
230
191 231
192Document Author 232Document Author
193--------------- 233---------------
194 234
195Ben Dooks, (c) 2004-2005 Simtec Electronics 235Ben Dooks, (c) 2004-2005,2006 Simtec Electronics
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index fc99075e0af4..7b7382d0f758 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1008,7 +1008,9 @@ running once the system is up.
1008 noexec=on: enable non-executable mappings (default) 1008 noexec=on: enable non-executable mappings (default)
1009 noexec=off: disable nn-executable mappings 1009 noexec=off: disable nn-executable mappings
1010 1010
1011 nofxsr [BUGS=IA-32] 1011 nofxsr [BUGS=IA-32] Disables x86 floating point extended
1012 register save and restore. The kernel will only save
1013 legacy floating-point registers on task switch.
1012 1014
1013 nohlt [BUGS=ARM] 1015 nohlt [BUGS=ARM]
1014 1016
@@ -1053,6 +1055,8 @@ running once the system is up.
1053 1055
1054 nosbagart [IA-64] 1056 nosbagart [IA-64]
1055 1057
1058 nosep [BUGS=IA-32] Disables x86 SYSENTER/SYSEXIT support.
1059
1056 nosmp [SMP] Tells an SMP kernel to act as a UP kernel. 1060 nosmp [SMP] Tells an SMP kernel to act as a UP kernel.
1057 1061
1058 nosync [HW,M68K] Disables sync negotiation for all devices. 1062 nosync [HW,M68K] Disables sync negotiation for all devices.
@@ -1122,6 +1126,11 @@ running once the system is up.
1122 pas16= [HW,SCSI] 1126 pas16= [HW,SCSI]
1123 See header of drivers/scsi/pas16.c. 1127 See header of drivers/scsi/pas16.c.
1124 1128
1129 pause_on_oops=
1130 Halt all CPUs after the first oops has been printed for
1131 the specified number of seconds. This is to be used if
1132 your oopses keep scrolling off the screen.
1133
1125 pcbit= [HW,ISDN] 1134 pcbit= [HW,ISDN]
1126 1135
1127 pcd. [PARIDE] 1136 pcd. [PARIDE]
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index b28b7f04abb8..d7814a113ee1 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -17,6 +17,11 @@ Some warnings, first.
17 * but it will probably only crash. 17 * but it will probably only crash.
18 * 18 *
19 * (*) suspend/resume support is needed to make it safe. 19 * (*) suspend/resume support is needed to make it safe.
20 *
21 * If you have any filesystems on USB devices mounted before suspend,
22 * they won't be accessible after resume and you may lose data, as though
23 * you have unplugged the USB devices with mounted filesystems on them
24 * (see the FAQ below for details).
20 25
21You need to append resume=/dev/your_swap_partition to kernel command 26You need to append resume=/dev/your_swap_partition to kernel command
22line. Then you suspend by 27line. Then you suspend by
@@ -27,19 +32,18 @@ echo shutdown > /sys/power/disk; echo disk > /sys/power/state
27 32
28echo platform > /sys/power/disk; echo disk > /sys/power/state 33echo platform > /sys/power/disk; echo disk > /sys/power/state
29 34
35. If you have SATA disks, you'll need recent kernels with SATA suspend
36support. For suspend and resume to work, make sure your disk drivers
37are built into kernel -- not modules. [There's way to make
38suspend/resume with modular disk drivers, see FAQ, but you probably
39should not do that.]
40
30If you want to limit the suspend image size to N bytes, do 41If you want to limit the suspend image size to N bytes, do
31 42
32echo N > /sys/power/image_size 43echo N > /sys/power/image_size
33 44
34before suspend (it is limited to 500 MB by default). 45before suspend (it is limited to 500 MB by default).
35 46
36Encrypted suspend image:
37------------------------
38If you want to store your suspend image encrypted with a temporary
39key to prevent data gathering after resume you must compile
40crypto and the aes algorithm into the kernel - modules won't work
41as they cannot be loaded at resume time.
42
43 47
44Article about goals and implementation of Software Suspend for Linux 48Article about goals and implementation of Software Suspend for Linux
45~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 49~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -333,4 +337,37 @@ init=/bin/bash, then swapon and starting suspend sequence manually
333usually does the trick. Then it is good idea to try with latest 337usually does the trick. Then it is good idea to try with latest
334vanilla kernel. 338vanilla kernel.
335 339
340Q: How can distributions ship a swsusp-supporting kernel with modular
341disk drivers (especially SATA)?
342
343A: Well, it can be done, load the drivers, then do echo into
344/sys/power/disk/resume file from initrd. Be sure not to mount
345anything, not even read-only mount, or you are going to lose your
346data.
347
348Q: How do I make suspend more verbose?
349
350A: If you want to see any non-error kernel messages on the virtual
351terminal the kernel switches to during suspend, you have to set the
352kernel console loglevel to at least 5, for example by doing
353
354 echo 5 > /proc/sys/kernel/printk
355
356Q: Is this true that if I have a mounted filesystem on a USB device and
357I suspend to disk, I can lose data unless the filesystem has been mounted
358with "sync"?
359
360A: That's right. It depends on your hardware, and it could be true even for
361suspend-to-RAM. In fact, even with "-o sync" you can lose data if your
362programs have information in buffers they haven't written out to disk.
363
364If you're lucky, your hardware will support low-power modes for USB
365controllers while the system is asleep. Lots of hardware doesn't,
366however. Shutting off the power to a USB controller is equivalent to
367unplugging all the attached devices.
368
369Remember that it's always a bad idea to unplug a disk drive containing a
370mounted filesystem. With USB that's true even when your system is asleep!
371The safest thing is to unmount all USB-based filesystems before suspending
372and remount them after resuming.
336 373
diff --git a/Documentation/power/userland-swsusp.txt b/Documentation/power/userland-swsusp.txt
new file mode 100644
index 000000000000..94058220aaf0
--- /dev/null
+++ b/Documentation/power/userland-swsusp.txt
@@ -0,0 +1,149 @@
1Documentation for userland software suspend interface
2 (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
3
4First, the warnings at the beginning of swsusp.txt still apply.
5
6Second, you should read the FAQ in swsusp.txt _now_ if you have not
7done it already.
8
9Now, to use the userland interface for software suspend you need special
10utilities that will read/write the system memory snapshot from/to the
11kernel. Such utilities are available, for example, from
12<http://www.sisk.pl/kernel/utilities/suspend>. You may want to have
13a look at them if you are going to develop your own suspend/resume
14utilities.
15
16The interface consists of a character device providing the open(),
17release(), read(), and write() operations as well as several ioctl()
18commands defined in kernel/power/power.h. The major and minor
19numbers of the device are, respectively, 10 and 231, and they can
20be read from /sys/class/misc/snapshot/dev.
21
22The device can be open either for reading or for writing. If open for
23reading, it is considered to be in the suspend mode. Otherwise it is
24assumed to be in the resume mode. The device cannot be open for reading
25and writing. It is also impossible to have the device open more than once
26at a time.
27
28The ioctl() commands recognized by the device are:
29
30SNAPSHOT_FREEZE - freeze user space processes (the current process is
31 not frozen); this is required for SNAPSHOT_ATOMIC_SNAPSHOT
32 and SNAPSHOT_ATOMIC_RESTORE to succeed
33
34SNAPSHOT_UNFREEZE - thaw user space processes frozen by SNAPSHOT_FREEZE
35
36SNAPSHOT_ATOMIC_SNAPSHOT - create a snapshot of the system memory; the
37 last argument of ioctl() should be a pointer to an int variable,
38 the value of which will indicate whether the call returned after
39 creating the snapshot (1) or after restoring the system memory state
40 from it (0) (after resume the system finds itself finishing the
41 SNAPSHOT_ATOMIC_SNAPSHOT ioctl() again); after the snapshot
42 has been created the read() operation can be used to transfer
43 it out of the kernel
44
45SNAPSHOT_ATOMIC_RESTORE - restore the system memory state from the
46 uploaded snapshot image; before calling it you should transfer
47 the system memory snapshot back to the kernel using the write()
48 operation; this call will not succeed if the snapshot
49 image is not available to the kernel
50
51SNAPSHOT_FREE - free memory allocated for the snapshot image
52
53SNAPSHOT_SET_IMAGE_SIZE - set the preferred maximum size of the image
54 (the kernel will do its best to ensure the image size will not exceed
55 this number, but if it turns out to be impossible, the kernel will
56 create the smallest image possible)
57
58SNAPSHOT_AVAIL_SWAP - return the amount of available swap in bytes (the last
59 argument should be a pointer to an unsigned int variable that will
60 contain the result if the call is successful).
61
62SNAPSHOT_GET_SWAP_PAGE - allocate a swap page from the resume partition
63 (the last argument should be a pointer to a loff_t variable that
64 will contain the swap page offset if the call is successful)
65
66SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with
67 SNAPSHOT_GET_SWAP_PAGE
68
69SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument
70 should specify the device's major and minor numbers in the old
71 two-byte format, as returned by the stat() function in the .st_rdev
72 member of the stat structure); it is recommended to always use this
73 call, because the code to set the resume partition could be removed from
74 future kernels
75
76The device's read() operation can be used to transfer the snapshot image from
77the kernel. It has the following limitations:
78- you cannot read() more than one virtual memory page at a time
79- read()s accross page boundaries are impossible (ie. if ypu read() 1/2 of
80 a page in the previous call, you will only be able to read()
81 _at_ _most_ 1/2 of the page in the next call)
82
83The device's write() operation is used for uploading the system memory snapshot
84into the kernel. It has the same limitations as the read() operation.
85
86The release() operation frees all memory allocated for the snapshot image
87and all swap pages allocated with SNAPSHOT_GET_SWAP_PAGE (if any).
88Thus it is not necessary to use either SNAPSHOT_FREE or
89SNAPSHOT_FREE_SWAP_PAGES before closing the device (in fact it will also
90unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
91still frozen when the device is being closed).
92
93Currently it is assumed that the userland utilities reading/writing the
94snapshot image from/to the kernel will use a swap parition, called the resume
95partition, as storage space. However, this is not really required, as they
96can use, for example, a special (blank) suspend partition or a file on a partition
97that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and mounted afterwards.
98
99These utilities SHOULD NOT make any assumptions regarding the ordering of
100data within the snapshot image, except for the image header that MAY be
101assumed to start with an swsusp_info structure, as specified in
102kernel/power/power.h. This structure MAY be used by the userland utilities
103to obtain some information about the snapshot image, such as the size
104of the snapshot image, including the metadata and the header itself,
105contained in the .size member of swsusp_info.
106
107The snapshot image MUST be written to the kernel unaltered (ie. all of the image
108data, metadata and header MUST be written in _exactly_ the same amount, form
109and order in which they have been read). Otherwise, the behavior of the
110resumed system may be totally unpredictable.
111
112While executing SNAPSHOT_ATOMIC_RESTORE the kernel checks if the
113structure of the snapshot image is consistent with the information stored
114in the image header. If any inconsistencies are detected,
115SNAPSHOT_ATOMIC_RESTORE will not succeed. Still, this is not a fool-proof
116mechanism and the userland utilities using the interface SHOULD use additional
117means, such as checksums, to ensure the integrity of the snapshot image.
118
119The suspending and resuming utilities MUST lock themselves in memory,
120preferrably using mlockall(), before calling SNAPSHOT_FREEZE.
121
122The suspending utility MUST check the value stored by SNAPSHOT_ATOMIC_SNAPSHOT
123in the memory location pointed to by the last argument of ioctl() and proceed
124in accordance with it:
1251. If the value is 1 (ie. the system memory snapshot has just been
126 created and the system is ready for saving it):
127 (a) The suspending utility MUST NOT close the snapshot device
128 _unless_ the whole suspend procedure is to be cancelled, in
129 which case, if the snapshot image has already been saved, the
130 suspending utility SHOULD destroy it, preferrably by zapping
131 its header. If the suspend is not to be cancelled, the
132 system MUST be powered off or rebooted after the snapshot
133 image has been saved.
134 (b) The suspending utility SHOULD NOT attempt to perform any
135 file system operations (including reads) on the file systems
136 that were mounted before SNAPSHOT_ATOMIC_SNAPSHOT has been
137 called. However, it MAY mount a file system that was not
138 mounted at that time and perform some operations on it (eg.
139 use it for saving the image).
1402. If the value is 0 (ie. the system state has just been restored from
141 the snapshot image), the suspending utility MUST close the snapshot
142 device. Afterwards it will be treated as a regular userland process,
143 so it need not exit.
144
145The resuming utility SHOULD NOT attempt to mount any file systems that could
146be mounted before suspend and SHOULD NOT attempt to perform any operations
147involving such file systems.
148
149For details, please refer to the source code.
diff --git a/Documentation/power/video.txt b/Documentation/power/video.txt
index 912bed87c758..d18a57d1a531 100644
--- a/Documentation/power/video.txt
+++ b/Documentation/power/video.txt
@@ -1,7 +1,7 @@
1 1
2 Video issues with S3 resume 2 Video issues with S3 resume
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 2003-2005, Pavel Machek 4 2003-2006, Pavel Machek
5 5
6During S3 resume, hardware needs to be reinitialized. For most 6During S3 resume, hardware needs to be reinitialized. For most
7devices, this is easy, and kernel driver knows how to do 7devices, this is easy, and kernel driver knows how to do
@@ -15,6 +15,27 @@ run normally so video card is normally initialized. It should not be
15problem for S1 standby, because hardware should retain its state over 15problem for S1 standby, because hardware should retain its state over
16that. 16that.
17 17
18We either have to run video BIOS during early resume, or interpret it
19using vbetool later, or maybe nothing is neccessary on particular
20system because video state is preserved. Unfortunately different
21methods work on different systems, and no known method suits all of
22them.
23
24Userland application called s2ram has been developed; it contains long
25whitelist of systems, and automatically selects working method for a
26given system. It can be downloaded from CVS at
27www.sf.net/projects/suspend . If you get a system that is not in the
28whitelist, please try to find a working solution, and submit whitelist
29entry so that work does not need to be repeated.
30
31Currently, VBE_SAVE method (6 below) works on most
32systems. Unfortunately, vbetool only runs after userland is resumed,
33so it makes debugging of early resume problems
34hard/impossible. Methods that do not rely on userland are preferable.
35
36Details
37~~~~~~~
38
18There are a few types of systems where video works after S3 resume: 39There are a few types of systems where video works after S3 resume:
19 40
20(1) systems where video state is preserved over S3. 41(1) systems where video state is preserved over S3.
@@ -104,6 +125,7 @@ HP NX7000 ??? (*)
104HP Pavilion ZD7000 vbetool post needed, need open-source nv driver for X 125HP Pavilion ZD7000 vbetool post needed, need open-source nv driver for X
105HP Omnibook XE3 athlon version none (1) 126HP Omnibook XE3 athlon version none (1)
106HP Omnibook XE3GC none (1), video is S3 Savage/IX-MV 127HP Omnibook XE3GC none (1), video is S3 Savage/IX-MV
128HP Omnibook 5150 none (1), (S1 also works OK)
107IBM TP T20, model 2647-44G none (1), video is S3 Inc. 86C270-294 Savage/IX-MV, vesafb gets "interesting" but X work. 129IBM TP T20, model 2647-44G none (1), video is S3 Inc. 86C270-294 Savage/IX-MV, vesafb gets "interesting" but X work.
108IBM TP A31 / Type 2652-M5G s3_mode (3) [works ok with BIOS 1.04 2002-08-23, but not at all with BIOS 1.11 2004-11-05 :-(] 130IBM TP A31 / Type 2652-M5G s3_mode (3) [works ok with BIOS 1.04 2002-08-23, but not at all with BIOS 1.11 2004-11-05 :-(]
109IBM TP R32 / Type 2658-MMG none (1) 131IBM TP R32 / Type 2658-MMG none (1)
@@ -120,18 +142,24 @@ IBM ThinkPad T42p (2373-GTG) s3_bios (2)
120IBM TP X20 ??? (*) 142IBM TP X20 ??? (*)
121IBM TP X30 s3_bios (2) 143IBM TP X30 s3_bios (2)
122IBM TP X31 / Type 2672-XXH none (1), use radeontool (http://fdd.com/software/radeon/) to turn off backlight. 144IBM TP X31 / Type 2672-XXH none (1), use radeontool (http://fdd.com/software/radeon/) to turn off backlight.
123IBM TP X32 none (1), but backlight is on and video is trashed after long suspend 145IBM TP X32 none (1), but backlight is on and video is trashed after long suspend. s3_bios,s3_mode (4) works too. Perhaps that gets better results?
124IBM Thinkpad X40 Type 2371-7JG s3_bios,s3_mode (4) 146IBM Thinkpad X40 Type 2371-7JG s3_bios,s3_mode (4)
147IBM TP 600e none(1), but a switch to console and back to X is needed
125Medion MD4220 ??? (*) 148Medion MD4220 ??? (*)
126Samsung P35 vbetool needed (6) 149Samsung P35 vbetool needed (6)
127Sharp PC-AR10 (ATI rage) none (1) 150Sharp PC-AR10 (ATI rage) none (1), backlight does not switch off
128Sony Vaio PCG-C1VRX/K s3_bios (2) 151Sony Vaio PCG-C1VRX/K s3_bios (2)
129Sony Vaio PCG-F403 ??? (*) 152Sony Vaio PCG-F403 ??? (*)
153Sony Vaio PCG-GRT995MP none (1), works with 'nv' X driver
154Sony Vaio PCG-GR7/K none (1), but needs radeonfb, use radeontool (http://fdd.com/software/radeon/) to turn off backlight.
130Sony Vaio PCG-N505SN ??? (*) 155Sony Vaio PCG-N505SN ??? (*)
131Sony Vaio vgn-s260 X or boot-radeon can init it (5) 156Sony Vaio vgn-s260 X or boot-radeon can init it (5)
157Sony Vaio vgn-S580BH vga=normal, but suspend from X. Console will be blank unless you return to X.
158Sony Vaio vgn-FS115B s3_bios (2),s3_mode (4)
132Toshiba Libretto L5 none (1) 159Toshiba Libretto L5 none (1)
133Toshiba Satellite 4030CDT s3_mode (3) 160Toshiba Portege 3020CT s3_mode (3)
134Toshiba Satellite 4080XCDT s3_mode (3) 161Toshiba Satellite 4030CDT s3_mode (3) (S1 also works OK)
162Toshiba Satellite 4080XCDT s3_mode (3) (S1 also works OK)
135Toshiba Satellite 4090XCDT ??? (*) 163Toshiba Satellite 4090XCDT ??? (*)
136Toshiba Satellite P10-554 s3_bios,s3_mode (4)(****) 164Toshiba Satellite P10-554 s3_bios,s3_mode (4)(****)
137Toshiba M30 (2) xor X with nvidia driver using internal AGP 165Toshiba M30 (2) xor X with nvidia driver using internal AGP
@@ -151,39 +179,3 @@ Asus A7V8X nVidia RIVA TNT2 model 64 s3_bios,s3_mode (4)
151(***) To be tested with a newer kernel. 179(***) To be tested with a newer kernel.
152 180
153(****) Not with SMP kernel, UP only. 181(****) Not with SMP kernel, UP only.
154
155VBEtool details
156~~~~~~~~~~~~~~~
157(with thanks to Carl-Daniel Hailfinger)
158
159First, boot into X and run the following script ONCE:
160#!/bin/bash
161statedir=/root/s3/state
162mkdir -p $statedir
163chvt 2
164sleep 1
165vbetool vbestate save >$statedir/vbe
166
167
168To suspend and resume properly, call the following script as root:
169#!/bin/bash
170statedir=/root/s3/state
171curcons=`fgconsole`
172fuser /dev/tty$curcons 2>/dev/null|xargs ps -o comm= -p|grep -q X && chvt 2
173cat /dev/vcsa >$statedir/vcsa
174sync
175echo 3 >/proc/acpi/sleep
176sync
177vbetool post
178vbetool vbestate restore <$statedir/vbe
179cat $statedir/vcsa >/dev/vcsa
180rckbd restart
181chvt $[curcons%6+1]
182chvt $curcons
183
184
185Unless you change your graphics card or other hardware configuration,
186the state once saved will be OK for every resume afterwards.
187NOTE: The "rckbd restart" command may be different for your
188distribution. Simply replace it with the command you would use to
189set the fonts on screen.
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index d02c64953dcd..ee551c6ea235 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1365,6 +1365,78 @@ platforms are moved over to use the flattened-device-tree model.
1365 }; 1365 };
1366 1366
1367 1367
1368 g) Freescale SOC SEC Security Engines
1369
1370 Required properties:
1371
1372 - device_type : Should be "crypto"
1373 - model : Model of the device. Should be "SEC1" or "SEC2"
1374 - compatible : Should be "talitos"
1375 - reg : Offset and length of the register set for the device
1376 - interrupts : <a b> where a is the interrupt number and b is a
1377 field that represents an encoding of the sense and level
1378 information for the interrupt. This should be encoded based on
1379 the information in section 2) depending on the type of interrupt
1380 controller you have.
1381 - interrupt-parent : the phandle for the interrupt controller that
1382 services interrupts for this device.
1383 - num-channels : An integer representing the number of channels
1384 available.
1385 - channel-fifo-len : An integer representing the number of
1386 descriptor pointers each channel fetch fifo can hold.
1387 - exec-units-mask : The bitmask representing what execution units
1388 (EUs) are available. It's a single 32 bit cell. EU information
1389 should be encoded following the SEC's Descriptor Header Dword
1390 EU_SEL0 field documentation, i.e. as follows:
1391
1392 bit 0 = reserved - should be 0
1393 bit 1 = set if SEC has the ARC4 EU (AFEU)
1394 bit 2 = set if SEC has the DES/3DES EU (DEU)
1395 bit 3 = set if SEC has the message digest EU (MDEU)
1396 bit 4 = set if SEC has the random number generator EU (RNG)
1397 bit 5 = set if SEC has the public key EU (PKEU)
1398 bit 6 = set if SEC has the AES EU (AESU)
1399 bit 7 = set if SEC has the Kasumi EU (KEU)
1400
1401 bits 8 through 31 are reserved for future SEC EUs.
1402
1403 - descriptor-types-mask : The bitmask representing what descriptors
1404 are available. It's a single 32 bit cell. Descriptor type
1405 information should be encoded following the SEC's Descriptor
1406 Header Dword DESC_TYPE field documentation, i.e. as follows:
1407
1408 bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
1409 bit 1 = set if SEC supports the ipsec_esp descriptor type
1410 bit 2 = set if SEC supports the common_nonsnoop desc. type
1411 bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
1412 bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
1413 bit 5 = set if SEC supports the srtp descriptor type
1414 bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
1415 bit 7 = set if SEC supports the pkeu_assemble descriptor type
1416 bit 8 = set if SEC supports the aesu_key_expand_output desc.type
1417 bit 9 = set if SEC supports the pkeu_ptmul descriptor type
1418 bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
1419 bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
1420
1421 ..and so on and so forth.
1422
1423 Example:
1424
1425 /* MPC8548E */
1426 crypto@30000 {
1427 device_type = "crypto";
1428 model = "SEC2";
1429 compatible = "talitos";
1430 reg = <30000 10000>;
1431 interrupts = <1d 3>;
1432 interrupt-parent = <40000>;
1433 num-channels = <4>;
1434 channel-fifo-len = <24>;
1435 exec-units-mask = <000000fe>;
1436 descriptor-types-mask = <073f1127>;
1437 };
1438
1439
1368 More devices will be defined as this spec matures. 1440 More devices will be defined as this spec matures.
1369 1441
1370 1442
diff --git a/Documentation/powerpc/eeh-pci-error-recovery.txt b/Documentation/powerpc/eeh-pci-error-recovery.txt
index 67a11a36270c..3764dd4b12cb 100644
--- a/Documentation/powerpc/eeh-pci-error-recovery.txt
+++ b/Documentation/powerpc/eeh-pci-error-recovery.txt
@@ -121,7 +121,7 @@ accomplished.
121 121
122EEH must be enabled in the PHB's very early during the boot process, 122EEH must be enabled in the PHB's very early during the boot process,
123and if a PCI slot is hot-plugged. The former is performed by 123and if a PCI slot is hot-plugged. The former is performed by
124eeh_init() in arch/ppc64/kernel/eeh.c, and the later by 124eeh_init() in arch/powerpc/platforms/pseries/eeh.c, and the later by
125drivers/pci/hotplug/pSeries_pci.c calling in to the eeh.c code. 125drivers/pci/hotplug/pSeries_pci.c calling in to the eeh.c code.
126EEH must be enabled before a PCI scan of the device can proceed. 126EEH must be enabled before a PCI scan of the device can proceed.
127Current Power5 hardware will not work unless EEH is enabled; 127Current Power5 hardware will not work unless EEH is enabled;
@@ -133,7 +133,7 @@ error. Given an arbitrary address, the routine
133pci_get_device_by_addr() will find the pci device associated 133pci_get_device_by_addr() will find the pci device associated
134with that address (if any). 134with that address (if any).
135 135
136The default include/asm-ppc64/io.h macros readb(), inb(), insb(), 136The default include/asm-powerpc/io.h macros readb(), inb(), insb(),
137etc. include a check to see if the i/o read returned all-0xff's. 137etc. include a check to see if the i/o read returned all-0xff's.
138If so, these make a call to eeh_dn_check_failure(), which in turn 138If so, these make a call to eeh_dn_check_failure(), which in turn
139asks the firmware if the all-ff's value is the sign of a true EEH 139asks the firmware if the all-ff's value is the sign of a true EEH
@@ -143,11 +143,12 @@ seen in /proc/ppc64/eeh (subject to change). Normally, almost
143all of these occur during boot, when the PCI bus is scanned, where 143all of these occur during boot, when the PCI bus is scanned, where
144a large number of 0xff reads are part of the bus scan procedure. 144a large number of 0xff reads are part of the bus scan procedure.
145 145
146If a frozen slot is detected, code in arch/ppc64/kernel/eeh.c will 146If a frozen slot is detected, code in
147print a stack trace to syslog (/var/log/messages). This stack trace 147arch/powerpc/platforms/pseries/eeh.c will print a stack trace to
148has proven to be very useful to device-driver authors for finding 148syslog (/var/log/messages). This stack trace has proven to be very
149out at what point the EEH error was detected, as the error itself 149useful to device-driver authors for finding out at what point the EEH
150usually occurs slightly beforehand. 150error was detected, as the error itself usually occurs slightly
151beforehand.
151 152
152Next, it uses the Linux kernel notifier chain/work queue mechanism to 153Next, it uses the Linux kernel notifier chain/work queue mechanism to
153allow any interested parties to find out about the failure. Device 154allow any interested parties to find out about the failure. Device
diff --git a/Documentation/powerpc/hvcs.txt b/Documentation/powerpc/hvcs.txt
index dca75cbda6f8..1e38166f4e54 100644
--- a/Documentation/powerpc/hvcs.txt
+++ b/Documentation/powerpc/hvcs.txt
@@ -558,9 +558,9 @@ partitions.
558 558
559The proper channel for reporting bugs is either through the Linux OS 559The proper channel for reporting bugs is either through the Linux OS
560distribution company that provided your OS or by posting issues to the 560distribution company that provided your OS or by posting issues to the
561ppc64 development mailing list at: 561PowerPC development mailing list at:
562 562
563linuxppc64-dev@lists.linuxppc.org 563linuxppc-dev@ozlabs.org
564 564
565This request is to provide a documented and searchable public exchange 565This request is to provide a documented and searchable public exchange
566of the problems and solutions surrounding this driver for the benefit of 566of the problems and solutions surrounding this driver for the benefit of
diff --git a/MAINTAINERS b/MAINTAINERS
index dd1351dc32b8..bfd7fbfe90ab 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -534,7 +534,7 @@ S: Supported
534BROADBAND PROCESSOR ARCHITECTURE 534BROADBAND PROCESSOR ARCHITECTURE
535P: Arnd Bergmann 535P: Arnd Bergmann
536M: arnd@arndb.de 536M: arnd@arndb.de
537L: linuxppc64-dev@ozlabs.org 537L: linuxppc-dev@ozlabs.org
538W: http://linuxppc64.org 538W: http://linuxppc64.org
539S: Supported 539S: Supported
540 540
@@ -1624,7 +1624,7 @@ P: Anton Blanchard
1624M: anton@samba.org 1624M: anton@samba.org
1625M: anton@au.ibm.com 1625M: anton@au.ibm.com
1626W: http://linuxppc64.org 1626W: http://linuxppc64.org
1627L: linuxppc64-dev@ozlabs.org 1627L: linuxppc-dev@ozlabs.org
1628S: Supported 1628S: Supported
1629 1629
1630LINUX SECURITY MODULE (LSM) FRAMEWORK 1630LINUX SECURITY MODULE (LSM) FRAMEWORK
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 32ba00bd0a2f..0dd24ebdf6ac 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -108,6 +108,13 @@ config ARCH_EBSA110
108 Ethernet interface, two PCMCIA sockets, two serial ports and a 108 Ethernet interface, two PCMCIA sockets, two serial ports and a
109 parallel port. 109 parallel port.
110 110
111config ARCH_EP93XX
112 bool "EP93xx-based"
113 select ARM_AMBA
114 select ARM_VIC
115 help
116 This enables support for the Cirrus EP93xx series of CPUs.
117
111config ARCH_FOOTBRIDGE 118config ARCH_FOOTBRIDGE
112 bool "FootBridge" 119 bool "FootBridge"
113 select FOOTBRIDGE 120 select FOOTBRIDGE
@@ -250,6 +257,8 @@ endchoice
250 257
251source "arch/arm/mach-clps711x/Kconfig" 258source "arch/arm/mach-clps711x/Kconfig"
252 259
260source "arch/arm/mach-ep93xx/Kconfig"
261
253source "arch/arm/mach-footbridge/Kconfig" 262source "arch/arm/mach-footbridge/Kconfig"
254 263
255source "arch/arm/mach-integrator/Kconfig" 264source "arch/arm/mach-integrator/Kconfig"
@@ -434,6 +443,13 @@ config NO_IDLE_HZ
434 Currently at least OMAP, PXA2xx and SA11x0 platforms are known 443 Currently at least OMAP, PXA2xx and SA11x0 platforms are known
435 to have accurate timekeeping with dynamic tick. 444 to have accurate timekeeping with dynamic tick.
436 445
446config HZ
447 int
448 default 128 if ARCH_L7200
449 default 200 if ARCH_EBSA110 || ARCH_S3C2410
450 default OMAP_32K_TIMER_HZ if ARCH_OMAP && OMAP_32K_TIMER
451 default 100
452
437config AEABI 453config AEABI
438 bool "Use the ARM EABI to compile the kernel" 454 bool "Use the ARM EABI to compile the kernel"
439 help 455 help
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index fbfc14a56b96..b5b1e4087516 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -105,6 +105,7 @@ endif
105 machine-$(CONFIG_ARCH_AAEC2000) := aaec2000 105 machine-$(CONFIG_ARCH_AAEC2000) := aaec2000
106 machine-$(CONFIG_ARCH_REALVIEW) := realview 106 machine-$(CONFIG_ARCH_REALVIEW) := realview
107 machine-$(CONFIG_ARCH_AT91RM9200) := at91rm9200 107 machine-$(CONFIG_ARCH_AT91RM9200) := at91rm9200
108 machine-$(CONFIG_ARCH_EP93XX) := ep93xx
108 109
109ifeq ($(CONFIG_ARCH_EBSA110),y) 110ifeq ($(CONFIG_ARCH_EBSA110),y)
110# This is what happens if you forget the IOCS16 line. 111# This is what happens if you forget the IOCS16 line.
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index c81a2ff6b5be..847e3e6356c6 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_SHARP_LOCOMO) += locomo.o
15obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o 15obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o
16obj-$(CONFIG_SHARPSL_PM) += sharpsl_pm.o 16obj-$(CONFIG_SHARPSL_PM) += sharpsl_pm.o
17obj-$(CONFIG_SHARP_SCOOP) += scoop.o 17obj-$(CONFIG_SHARP_SCOOP) += scoop.o
18obj-$(CONFIG_ARCH_IXP2000) += uengine.o
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index ad6c89a555bb..7971d0dc6892 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -5,7 +5,7 @@
5 * limited DMA windows. These functions utilize bounce buffers to 5 * limited DMA windows. These functions utilize bounce buffers to
6 * copy data to/from buffers located outside the DMA region. This 6 * copy data to/from buffers located outside the DMA region. This
7 * only works for systems in which DMA memory is at the bottom of 7 * only works for systems in which DMA memory is at the bottom of
8 * RAM and the remainder of memory is at the top an the DMA memory 8 * RAM, the remainder of memory is at the top and the DMA memory
9 * can be marked as ZONE_DMA. Anything beyond that such as discontigous 9 * can be marked as ZONE_DMA. Anything beyond that such as discontigous
10 * DMA windows will require custom implementations that reserve memory 10 * DMA windows will require custom implementations that reserve memory
11 * areas at early bootup. 11 * areas at early bootup.
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index 23609400a8e2..a7dc1370695b 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -60,7 +60,7 @@ struct locomo {
60 unsigned long phys; 60 unsigned long phys;
61 unsigned int irq; 61 unsigned int irq;
62 spinlock_t lock; 62 spinlock_t lock;
63 void *base; 63 void __iomem *base;
64}; 64};
65 65
66struct locomo_dev_info { 66struct locomo_dev_info {
@@ -162,7 +162,7 @@ static void locomo_handler(unsigned int irq, struct irqdesc *desc,
162{ 162{
163 int req, i; 163 int req, i;
164 struct irqdesc *d; 164 struct irqdesc *d;
165 void *mapbase = get_irq_chipdata(irq); 165 void __iomem *mapbase = get_irq_chipdata(irq);
166 166
167 /* Acknowledge the parent IRQ */ 167 /* Acknowledge the parent IRQ */
168 desc->chip->ack(irq); 168 desc->chip->ack(irq);
@@ -189,7 +189,7 @@ static void locomo_ack_irq(unsigned int irq)
189 189
190static void locomo_mask_irq(unsigned int irq) 190static void locomo_mask_irq(unsigned int irq)
191{ 191{
192 void *mapbase = get_irq_chipdata(irq); 192 void __iomem *mapbase = get_irq_chipdata(irq);
193 unsigned int r; 193 unsigned int r;
194 r = locomo_readl(mapbase + LOCOMO_ICR); 194 r = locomo_readl(mapbase + LOCOMO_ICR);
195 r &= ~(0x0010 << (irq - LOCOMO_IRQ_START)); 195 r &= ~(0x0010 << (irq - LOCOMO_IRQ_START));
@@ -198,7 +198,7 @@ static void locomo_mask_irq(unsigned int irq)
198 198
199static void locomo_unmask_irq(unsigned int irq) 199static void locomo_unmask_irq(unsigned int irq)
200{ 200{
201 void *mapbase = get_irq_chipdata(irq); 201 void __iomem *mapbase = get_irq_chipdata(irq);
202 unsigned int r; 202 unsigned int r;
203 r = locomo_readl(mapbase + LOCOMO_ICR); 203 r = locomo_readl(mapbase + LOCOMO_ICR);
204 r |= (0x0010 << (irq - LOCOMO_IRQ_START)); 204 r |= (0x0010 << (irq - LOCOMO_IRQ_START));
@@ -215,7 +215,7 @@ static void locomo_key_handler(unsigned int irq, struct irqdesc *desc,
215 struct pt_regs *regs) 215 struct pt_regs *regs)
216{ 216{
217 struct irqdesc *d; 217 struct irqdesc *d;
218 void *mapbase = get_irq_chipdata(irq); 218 void __iomem *mapbase = get_irq_chipdata(irq);
219 219
220 if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) { 220 if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) {
221 d = irq_desc + LOCOMO_IRQ_KEY_START; 221 d = irq_desc + LOCOMO_IRQ_KEY_START;
@@ -225,7 +225,7 @@ static void locomo_key_handler(unsigned int irq, struct irqdesc *desc,
225 225
226static void locomo_key_ack_irq(unsigned int irq) 226static void locomo_key_ack_irq(unsigned int irq)
227{ 227{
228 void *mapbase = get_irq_chipdata(irq); 228 void __iomem *mapbase = get_irq_chipdata(irq);
229 unsigned int r; 229 unsigned int r;
230 r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC); 230 r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
231 r &= ~(0x0100 << (irq - LOCOMO_IRQ_KEY_START)); 231 r &= ~(0x0100 << (irq - LOCOMO_IRQ_KEY_START));
@@ -234,7 +234,7 @@ static void locomo_key_ack_irq(unsigned int irq)
234 234
235static void locomo_key_mask_irq(unsigned int irq) 235static void locomo_key_mask_irq(unsigned int irq)
236{ 236{
237 void *mapbase = get_irq_chipdata(irq); 237 void __iomem *mapbase = get_irq_chipdata(irq);
238 unsigned int r; 238 unsigned int r;
239 r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC); 239 r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
240 r &= ~(0x0010 << (irq - LOCOMO_IRQ_KEY_START)); 240 r &= ~(0x0010 << (irq - LOCOMO_IRQ_KEY_START));
@@ -243,7 +243,7 @@ static void locomo_key_mask_irq(unsigned int irq)
243 243
244static void locomo_key_unmask_irq(unsigned int irq) 244static void locomo_key_unmask_irq(unsigned int irq)
245{ 245{
246 void *mapbase = get_irq_chipdata(irq); 246 void __iomem *mapbase = get_irq_chipdata(irq);
247 unsigned int r; 247 unsigned int r;
248 r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC); 248 r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
249 r |= (0x0010 << (irq - LOCOMO_IRQ_KEY_START)); 249 r |= (0x0010 << (irq - LOCOMO_IRQ_KEY_START));
@@ -261,7 +261,7 @@ static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc,
261{ 261{
262 int req, i; 262 int req, i;
263 struct irqdesc *d; 263 struct irqdesc *d;
264 void *mapbase = get_irq_chipdata(irq); 264 void __iomem *mapbase = get_irq_chipdata(irq);
265 265
266 req = locomo_readl(mapbase + LOCOMO_GIR) & 266 req = locomo_readl(mapbase + LOCOMO_GIR) &
267 locomo_readl(mapbase + LOCOMO_GPD) & 267 locomo_readl(mapbase + LOCOMO_GPD) &
@@ -280,7 +280,7 @@ static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc,
280 280
281static void locomo_gpio_ack_irq(unsigned int irq) 281static void locomo_gpio_ack_irq(unsigned int irq)
282{ 282{
283 void *mapbase = get_irq_chipdata(irq); 283 void __iomem *mapbase = get_irq_chipdata(irq);
284 unsigned int r; 284 unsigned int r;
285 r = locomo_readl(mapbase + LOCOMO_GWE); 285 r = locomo_readl(mapbase + LOCOMO_GWE);
286 r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START)); 286 r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -297,7 +297,7 @@ static void locomo_gpio_ack_irq(unsigned int irq)
297 297
298static void locomo_gpio_mask_irq(unsigned int irq) 298static void locomo_gpio_mask_irq(unsigned int irq)
299{ 299{
300 void *mapbase = get_irq_chipdata(irq); 300 void __iomem *mapbase = get_irq_chipdata(irq);
301 unsigned int r; 301 unsigned int r;
302 r = locomo_readl(mapbase + LOCOMO_GIE); 302 r = locomo_readl(mapbase + LOCOMO_GIE);
303 r &= ~(0x0001 << (irq - LOCOMO_IRQ_GPIO_START)); 303 r &= ~(0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -306,7 +306,7 @@ static void locomo_gpio_mask_irq(unsigned int irq)
306 306
307static void locomo_gpio_unmask_irq(unsigned int irq) 307static void locomo_gpio_unmask_irq(unsigned int irq)
308{ 308{
309 void *mapbase = get_irq_chipdata(irq); 309 void __iomem *mapbase = get_irq_chipdata(irq);
310 unsigned int r; 310 unsigned int r;
311 r = locomo_readl(mapbase + LOCOMO_GIE); 311 r = locomo_readl(mapbase + LOCOMO_GIE);
312 r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START)); 312 r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -323,7 +323,7 @@ static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc,
323 struct pt_regs *regs) 323 struct pt_regs *regs)
324{ 324{
325 struct irqdesc *d; 325 struct irqdesc *d;
326 void *mapbase = get_irq_chipdata(irq); 326 void __iomem *mapbase = get_irq_chipdata(irq);
327 327
328 if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) { 328 if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) {
329 d = irq_desc + LOCOMO_IRQ_LT_START; 329 d = irq_desc + LOCOMO_IRQ_LT_START;
@@ -333,7 +333,7 @@ static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc,
333 333
334static void locomo_lt_ack_irq(unsigned int irq) 334static void locomo_lt_ack_irq(unsigned int irq)
335{ 335{
336 void *mapbase = get_irq_chipdata(irq); 336 void __iomem *mapbase = get_irq_chipdata(irq);
337 unsigned int r; 337 unsigned int r;
338 r = locomo_readl(mapbase + LOCOMO_LTINT); 338 r = locomo_readl(mapbase + LOCOMO_LTINT);
339 r &= ~(0x0100 << (irq - LOCOMO_IRQ_LT_START)); 339 r &= ~(0x0100 << (irq - LOCOMO_IRQ_LT_START));
@@ -342,7 +342,7 @@ static void locomo_lt_ack_irq(unsigned int irq)
342 342
343static void locomo_lt_mask_irq(unsigned int irq) 343static void locomo_lt_mask_irq(unsigned int irq)
344{ 344{
345 void *mapbase = get_irq_chipdata(irq); 345 void __iomem *mapbase = get_irq_chipdata(irq);
346 unsigned int r; 346 unsigned int r;
347 r = locomo_readl(mapbase + LOCOMO_LTINT); 347 r = locomo_readl(mapbase + LOCOMO_LTINT);
348 r &= ~(0x0010 << (irq - LOCOMO_IRQ_LT_START)); 348 r &= ~(0x0010 << (irq - LOCOMO_IRQ_LT_START));
@@ -351,7 +351,7 @@ static void locomo_lt_mask_irq(unsigned int irq)
351 351
352static void locomo_lt_unmask_irq(unsigned int irq) 352static void locomo_lt_unmask_irq(unsigned int irq)
353{ 353{
354 void *mapbase = get_irq_chipdata(irq); 354 void __iomem *mapbase = get_irq_chipdata(irq);
355 unsigned int r; 355 unsigned int r;
356 r = locomo_readl(mapbase + LOCOMO_LTINT); 356 r = locomo_readl(mapbase + LOCOMO_LTINT);
357 r |= (0x0010 << (irq - LOCOMO_IRQ_LT_START)); 357 r |= (0x0010 << (irq - LOCOMO_IRQ_LT_START));
@@ -369,7 +369,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc,
369{ 369{
370 int req, i; 370 int req, i;
371 struct irqdesc *d; 371 struct irqdesc *d;
372 void *mapbase = get_irq_chipdata(irq); 372 void __iomem *mapbase = get_irq_chipdata(irq);
373 373
374 req = locomo_readl(mapbase + LOCOMO_SPIIR) & 0x000F; 374 req = locomo_readl(mapbase + LOCOMO_SPIIR) & 0x000F;
375 if (req) { 375 if (req) {
@@ -386,7 +386,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc,
386 386
387static void locomo_spi_ack_irq(unsigned int irq) 387static void locomo_spi_ack_irq(unsigned int irq)
388{ 388{
389 void *mapbase = get_irq_chipdata(irq); 389 void __iomem *mapbase = get_irq_chipdata(irq);
390 unsigned int r; 390 unsigned int r;
391 r = locomo_readl(mapbase + LOCOMO_SPIWE); 391 r = locomo_readl(mapbase + LOCOMO_SPIWE);
392 r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START)); 392 r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -403,7 +403,7 @@ static void locomo_spi_ack_irq(unsigned int irq)
403 403
404static void locomo_spi_mask_irq(unsigned int irq) 404static void locomo_spi_mask_irq(unsigned int irq)
405{ 405{
406 void *mapbase = get_irq_chipdata(irq); 406 void __iomem *mapbase = get_irq_chipdata(irq);
407 unsigned int r; 407 unsigned int r;
408 r = locomo_readl(mapbase + LOCOMO_SPIIE); 408 r = locomo_readl(mapbase + LOCOMO_SPIIE);
409 r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); 409 r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -412,7 +412,7 @@ static void locomo_spi_mask_irq(unsigned int irq)
412 412
413static void locomo_spi_unmask_irq(unsigned int irq) 413static void locomo_spi_unmask_irq(unsigned int irq)
414{ 414{
415 void *mapbase = get_irq_chipdata(irq); 415 void __iomem *mapbase = get_irq_chipdata(irq);
416 unsigned int r; 416 unsigned int r;
417 r = locomo_readl(mapbase + LOCOMO_SPIIE); 417 r = locomo_readl(mapbase + LOCOMO_SPIIE);
418 r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START)); 418 r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -428,7 +428,7 @@ static struct irqchip locomo_spi_chip = {
428static void locomo_setup_irq(struct locomo *lchip) 428static void locomo_setup_irq(struct locomo *lchip)
429{ 429{
430 int irq; 430 int irq;
431 void *irqbase = lchip->base; 431 void __iomem *irqbase = lchip->base;
432 432
433 /* 433 /*
434 * Install handler for IRQ_LOCOMO_HW. 434 * Install handler for IRQ_LOCOMO_HW.
@@ -501,12 +501,11 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
501 struct locomo_dev *dev; 501 struct locomo_dev *dev;
502 int ret; 502 int ret;
503 503
504 dev = kmalloc(sizeof(struct locomo_dev), GFP_KERNEL); 504 dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
505 if (!dev) { 505 if (!dev) {
506 ret = -ENOMEM; 506 ret = -ENOMEM;
507 goto out; 507 goto out;
508 } 508 }
509 memset(dev, 0, sizeof(struct locomo_dev));
510 509
511 strncpy(dev->dev.bus_id,info->name,sizeof(dev->dev.bus_id)); 510 strncpy(dev->dev.bus_id,info->name,sizeof(dev->dev.bus_id));
512 /* 511 /*
@@ -664,12 +663,10 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
664 unsigned long r; 663 unsigned long r;
665 int i, ret = -ENODEV; 664 int i, ret = -ENODEV;
666 665
667 lchip = kmalloc(sizeof(struct locomo), GFP_KERNEL); 666 lchip = kzalloc(sizeof(struct locomo), GFP_KERNEL);
668 if (!lchip) 667 if (!lchip)
669 return -ENOMEM; 668 return -ENOMEM;
670 669
671 memset(lchip, 0, sizeof(struct locomo));
672
673 spin_lock_init(&lchip->lock); 670 spin_lock_init(&lchip->lock);
674 671
675 lchip->dev = me; 672 lchip->dev = me;
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 93352f6097c1..3f68db84e5e6 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -26,6 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/clk.h>
29 30
30#include <asm/hardware.h> 31#include <asm/hardware.h>
31#include <asm/mach-types.h> 32#include <asm/mach-types.h>
@@ -36,10 +37,6 @@
36 37
37#include <asm/hardware/sa1111.h> 38#include <asm/hardware/sa1111.h>
38 39
39#ifdef CONFIG_ARCH_PXA
40#include <asm/arch/pxa-regs.h>
41#endif
42
43extern void __init sa1110_mb_enable(void); 40extern void __init sa1110_mb_enable(void);
44 41
45/* 42/*
@@ -51,6 +48,7 @@ extern void __init sa1110_mb_enable(void);
51 */ 48 */
52struct sa1111 { 49struct sa1111 {
53 struct device *dev; 50 struct device *dev;
51 struct clk *clk;
54 unsigned long phys; 52 unsigned long phys;
55 int irq; 53 int irq;
56 spinlock_t lock; 54 spinlock_t lock;
@@ -451,19 +449,7 @@ static void sa1111_wake(struct sa1111 *sachip)
451 449
452 spin_lock_irqsave(&sachip->lock, flags); 450 spin_lock_irqsave(&sachip->lock, flags);
453 451
454#ifdef CONFIG_ARCH_SA1100 452 clk_enable(sachip->clk);
455 /*
456 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
457 * (SA-1110 Developer's Manual, section 9.1.2.1)
458 */
459 GAFR |= GPIO_32_768kHz;
460 GPDR |= GPIO_32_768kHz;
461 TUCR = TUCR_3_6864MHz;
462#elif CONFIG_ARCH_PXA
463 pxa_gpio_mode(GPIO11_3_6MHz_MD);
464#else
465#error missing clock setup
466#endif
467 453
468 /* 454 /*
469 * Turn VCO on, and disable PLL Bypass. 455 * Turn VCO on, and disable PLL Bypass.
@@ -555,12 +541,11 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
555 struct sa1111_dev *dev; 541 struct sa1111_dev *dev;
556 int ret; 542 int ret;
557 543
558 dev = kmalloc(sizeof(struct sa1111_dev), GFP_KERNEL); 544 dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
559 if (!dev) { 545 if (!dev) {
560 ret = -ENOMEM; 546 ret = -ENOMEM;
561 goto out; 547 goto out;
562 } 548 }
563 memset(dev, 0, sizeof(struct sa1111_dev));
564 549
565 snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), 550 snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
566 "%4.4lx", info->offset); 551 "%4.4lx", info->offset);
@@ -635,11 +620,15 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
635 unsigned int has_devs, val; 620 unsigned int has_devs, val;
636 int i, ret = -ENODEV; 621 int i, ret = -ENODEV;
637 622
638 sachip = kmalloc(sizeof(struct sa1111), GFP_KERNEL); 623 sachip = kzalloc(sizeof(struct sa1111), GFP_KERNEL);
639 if (!sachip) 624 if (!sachip)
640 return -ENOMEM; 625 return -ENOMEM;
641 626
642 memset(sachip, 0, sizeof(struct sa1111)); 627 sachip->clk = clk_get(me, "GPIO27_CLK");
628 if (!sachip->clk) {
629 ret = PTR_ERR(sachip->clk);
630 goto err_free;
631 }
643 632
644 spin_lock_init(&sachip->lock); 633 spin_lock_init(&sachip->lock);
645 634
@@ -656,7 +645,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
656 sachip->base = ioremap(mem->start, PAGE_SIZE * 2); 645 sachip->base = ioremap(mem->start, PAGE_SIZE * 2);
657 if (!sachip->base) { 646 if (!sachip->base) {
658 ret = -ENOMEM; 647 ret = -ENOMEM;
659 goto out; 648 goto err_clkput;
660 } 649 }
661 650
662 /* 651 /*
@@ -666,7 +655,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
666 if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { 655 if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
667 printk(KERN_DEBUG "SA1111 not detected: ID = %08lx\n", id); 656 printk(KERN_DEBUG "SA1111 not detected: ID = %08lx\n", id);
668 ret = -ENODEV; 657 ret = -ENODEV;
669 goto unmap; 658 goto err_unmap;
670 } 659 }
671 660
672 printk(KERN_INFO "SA1111 Microprocessor Companion Chip: " 661 printk(KERN_INFO "SA1111 Microprocessor Companion Chip: "
@@ -726,9 +715,11 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
726 715
727 return 0; 716 return 0;
728 717
729 unmap: 718 err_unmap:
730 iounmap(sachip->base); 719 iounmap(sachip->base);
731 out: 720 err_clkput:
721 clk_put(sachip->clk);
722 err_free:
732 kfree(sachip); 723 kfree(sachip);
733 return ret; 724 return ret;
734} 725}
@@ -751,6 +742,8 @@ static void __sa1111_remove(struct sa1111 *sachip)
751 sa1111_writel(0, irqbase + SA1111_WAKEEN0); 742 sa1111_writel(0, irqbase + SA1111_WAKEEN0);
752 sa1111_writel(0, irqbase + SA1111_WAKEEN1); 743 sa1111_writel(0, irqbase + SA1111_WAKEEN1);
753 744
745 clk_disable(sachip->clk);
746
754 if (sachip->irq != NO_IRQ) { 747 if (sachip->irq != NO_IRQ) {
755 set_irq_chained_handler(sachip->irq, NULL); 748 set_irq_chained_handler(sachip->irq, NULL);
756 set_irq_data(sachip->irq, NULL); 749 set_irq_data(sachip->irq, NULL);
@@ -759,6 +752,7 @@ static void __sa1111_remove(struct sa1111 *sachip)
759 } 752 }
760 753
761 iounmap(sachip->base); 754 iounmap(sachip->base);
755 clk_put(sachip->clk);
762 kfree(sachip); 756 kfree(sachip);
763} 757}
764 758
@@ -857,6 +851,8 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
857 sa1111_writel(0, sachip->base + SA1111_SKPWM0); 851 sa1111_writel(0, sachip->base + SA1111_SKPWM0);
858 sa1111_writel(0, sachip->base + SA1111_SKPWM1); 852 sa1111_writel(0, sachip->base + SA1111_SKPWM1);
859 853
854 clk_disable(sachip->clk);
855
860 spin_unlock_irqrestore(&sachip->lock, flags); 856 spin_unlock_irqrestore(&sachip->lock, flags);
861 857
862 return 0; 858 return 0;
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index a2dfe0b0f1ec..5e830f444c6c 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -132,12 +132,10 @@ int __init scoop_probe(struct platform_device *pdev)
132 if (!mem) 132 if (!mem)
133 return -EINVAL; 133 return -EINVAL;
134 134
135 devptr = kmalloc(sizeof(struct scoop_dev), GFP_KERNEL); 135 devptr = kzalloc(sizeof(struct scoop_dev), GFP_KERNEL);
136
137 if (!devptr) 136 if (!devptr)
138 return -ENOMEM; 137 return -ENOMEM;
139 138
140 memset(devptr, 0, sizeof(struct scoop_dev));
141 spin_lock_init(&devptr->scoop_lock); 139 spin_lock_init(&devptr->scoop_lock);
142 140
143 inf = pdev->dev.platform_data; 141 inf = pdev->dev.platform_data;
diff --git a/arch/arm/mach-ixp2000/uengine.c b/arch/arm/common/uengine.c
index ec4e007a22ef..a1310b71004e 100644
--- a/arch/arm/mach-ixp2000/uengine.c
+++ b/arch/arm/common/uengine.c
@@ -19,7 +19,7 @@
19#include <linux/string.h> 19#include <linux/string.h>
20#include <asm/hardware.h> 20#include <asm/hardware.h>
21#include <asm/arch/ixp2000-regs.h> 21#include <asm/arch/ixp2000-regs.h>
22#include <asm/arch/uengine.h> 22#include <asm/hardware/uengine.h>
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25#define USTORE_ADDRESS 0x000 25#define USTORE_ADDRESS 0x000
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index a45ed1687a59..a19bc4a6196d 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -22,22 +22,21 @@
22#include <linux/list.h> 22#include <linux/list.h>
23 23
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/irq.h>
26#include <asm/mach/irq.h> 25#include <asm/mach/irq.h>
27#include <asm/hardware/vic.h> 26#include <asm/hardware/vic.h>
28 27
29static void __iomem *vic_base;
30
31static void vic_mask_irq(unsigned int irq) 28static void vic_mask_irq(unsigned int irq)
32{ 29{
33 irq -= IRQ_VIC_START; 30 void __iomem *base = get_irq_chipdata(irq);
34 writel(1 << irq, vic_base + VIC_INT_ENABLE_CLEAR); 31 irq &= 31;
32 writel(1 << irq, base + VIC_INT_ENABLE_CLEAR);
35} 33}
36 34
37static void vic_unmask_irq(unsigned int irq) 35static void vic_unmask_irq(unsigned int irq)
38{ 36{
39 irq -= IRQ_VIC_START; 37 void __iomem *base = get_irq_chipdata(irq);
40 writel(1 << irq, vic_base + VIC_INT_ENABLE); 38 irq &= 31;
39 writel(1 << irq, base + VIC_INT_ENABLE);
41} 40}
42 41
43static struct irqchip vic_chip = { 42static struct irqchip vic_chip = {
@@ -46,43 +45,49 @@ static struct irqchip vic_chip = {
46 .unmask = vic_unmask_irq, 45 .unmask = vic_unmask_irq,
47}; 46};
48 47
49void __init vic_init(void __iomem *base, u32 vic_sources) 48/**
49 * vic_init - initialise a vectored interrupt controller
50 * @base: iomem base address
51 * @irq_start: starting interrupt number, must be muliple of 32
52 * @vic_sources: bitmask of interrupt sources to allow
53 */
54void __init vic_init(void __iomem *base, unsigned int irq_start,
55 u32 vic_sources)
50{ 56{
51 unsigned int i; 57 unsigned int i;
52 58
53 vic_base = base;
54
55 /* Disable all interrupts initially. */ 59 /* Disable all interrupts initially. */
56 60
57 writel(0, vic_base + VIC_INT_SELECT); 61 writel(0, base + VIC_INT_SELECT);
58 writel(0, vic_base + VIC_INT_ENABLE); 62 writel(0, base + VIC_INT_ENABLE);
59 writel(~0, vic_base + VIC_INT_ENABLE_CLEAR); 63 writel(~0, base + VIC_INT_ENABLE_CLEAR);
60 writel(0, vic_base + VIC_IRQ_STATUS); 64 writel(0, base + VIC_IRQ_STATUS);
61 writel(0, vic_base + VIC_ITCR); 65 writel(0, base + VIC_ITCR);
62 writel(~0, vic_base + VIC_INT_SOFT_CLEAR); 66 writel(~0, base + VIC_INT_SOFT_CLEAR);
63 67
64 /* 68 /*
65 * Make sure we clear all existing interrupts 69 * Make sure we clear all existing interrupts
66 */ 70 */
67 writel(0, vic_base + VIC_VECT_ADDR); 71 writel(0, base + VIC_VECT_ADDR);
68 for (i = 0; i < 19; i++) { 72 for (i = 0; i < 19; i++) {
69 unsigned int value; 73 unsigned int value;
70 74
71 value = readl(vic_base + VIC_VECT_ADDR); 75 value = readl(base + VIC_VECT_ADDR);
72 writel(value, vic_base + VIC_VECT_ADDR); 76 writel(value, base + VIC_VECT_ADDR);
73 } 77 }
74 78
75 for (i = 0; i < 16; i++) { 79 for (i = 0; i < 16; i++) {
76 void __iomem *reg = vic_base + VIC_VECT_CNTL0 + (i * 4); 80 void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4);
77 writel(VIC_VECT_CNTL_ENABLE | i, reg); 81 writel(VIC_VECT_CNTL_ENABLE | i, reg);
78 } 82 }
79 83
80 writel(32, vic_base + VIC_DEF_VECT_ADDR); 84 writel(32, base + VIC_DEF_VECT_ADDR);
81 85
82 for (i = 0; i < 32; i++) { 86 for (i = 0; i < 32; i++) {
83 unsigned int irq = IRQ_VIC_START + i; 87 unsigned int irq = irq_start + i;
84 88
85 set_irq_chip(irq, &vic_chip); 89 set_irq_chip(irq, &vic_chip);
90 set_irq_chipdata(irq, base);
86 91
87 if (vic_sources & (1 << i)) { 92 if (vic_sources & (1 << i)) {
88 set_irq_handler(irq, do_level_IRQ); 93 set_irq_handler(irq, do_level_IRQ);
diff --git a/arch/arm/configs/enp2611_defconfig b/arch/arm/configs/ep93xx_defconfig
index 5fdaf3ce9d56..8dcc8e8ec813 100644
--- a/arch/arm/configs/enp2611_defconfig
+++ b/arch/arm/configs/ep93xx_defconfig
@@ -1,11 +1,10 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-git13 3# Linux kernel version: 2.6.16
4# Thu Nov 10 15:12:48 2005 4# Mon Mar 20 14:54:51 2006
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 8CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
11 10
@@ -13,7 +12,6 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
13# Code maturity level options 12# Code maturity level options
14# 13#
15CONFIG_EXPERIMENTAL=y 14CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 15CONFIG_BROKEN_ON_SMP=y
18CONFIG_INIT_ENV_ARG_LIMIT=32 16CONFIG_INIT_ENV_ARG_LIMIT=32
19 17
@@ -25,38 +23,42 @@ CONFIG_LOCALVERSION_AUTO=y
25CONFIG_SWAP=y 23CONFIG_SWAP=y
26CONFIG_SYSVIPC=y 24CONFIG_SYSVIPC=y
27# CONFIG_POSIX_MQUEUE is not set 25# CONFIG_POSIX_MQUEUE is not set
28CONFIG_BSD_PROCESS_ACCT=y 26# CONFIG_BSD_PROCESS_ACCT is not set
29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
30CONFIG_SYSCTL=y 27CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set 28# CONFIG_AUDIT is not set
32# CONFIG_HOTPLUG is not set 29CONFIG_IKCONFIG=y
33CONFIG_KOBJECT_UEVENT=y 30CONFIG_IKCONFIG_PROC=y
34# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE="" 31CONFIG_INITRAMFS_SOURCE=""
32CONFIG_UID16=y
33CONFIG_CC_OPTIMIZE_FOR_SIZE=y
36CONFIG_EMBEDDED=y 34CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y 35CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set 36# CONFIG_KALLSYMS_ALL is not set
39# CONFIG_KALLSYMS_EXTRA_PASS is not set 37# CONFIG_KALLSYMS_EXTRA_PASS is not set
38CONFIG_HOTPLUG=y
40CONFIG_PRINTK=y 39CONFIG_PRINTK=y
41CONFIG_BUG=y 40CONFIG_BUG=y
41CONFIG_ELF_CORE=y
42CONFIG_BASE_FULL=y 42CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y 43CONFIG_FUTEX=y
44CONFIG_EPOLL=y 44CONFIG_EPOLL=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SHMEM=y 45CONFIG_SHMEM=y
47CONFIG_CC_ALIGN_FUNCTIONS=0 46CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0 47CONFIG_CC_ALIGN_LABELS=0
49CONFIG_CC_ALIGN_LOOPS=0 48CONFIG_CC_ALIGN_LOOPS=0
50CONFIG_CC_ALIGN_JUMPS=0 49CONFIG_CC_ALIGN_JUMPS=0
50CONFIG_SLAB=y
51# CONFIG_TINY_SHMEM is not set 51# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0 52CONFIG_BASE_SMALL=0
53# CONFIG_SLOB is not set
54CONFIG_OBSOLETE_INTERMODULE=y
53 55
54# 56#
55# Loadable module support 57# Loadable module support
56# 58#
57CONFIG_MODULES=y 59CONFIG_MODULES=y
58CONFIG_MODULE_UNLOAD=y 60CONFIG_MODULE_UNLOAD=y
59# CONFIG_MODULE_FORCE_UNLOAD is not set 61CONFIG_MODULE_FORCE_UNLOAD=y
60CONFIG_OBSOLETE_MODPARM=y 62CONFIG_OBSOLETE_MODPARM=y
61# CONFIG_MODVERSIONS is not set 63# CONFIG_MODVERSIONS is not set
62# CONFIG_MODULE_SRCVERSION_ALL is not set 64# CONFIG_MODULE_SRCVERSION_ALL is not set
@@ -70,14 +72,14 @@ CONFIG_KMOD=y
70# IO Schedulers 72# IO Schedulers
71# 73#
72CONFIG_IOSCHED_NOOP=y 74CONFIG_IOSCHED_NOOP=y
73CONFIG_IOSCHED_AS=y 75# CONFIG_IOSCHED_AS is not set
74CONFIG_IOSCHED_DEADLINE=y 76CONFIG_IOSCHED_DEADLINE=y
75CONFIG_IOSCHED_CFQ=y 77# CONFIG_IOSCHED_CFQ is not set
76CONFIG_DEFAULT_AS=y 78# CONFIG_DEFAULT_AS is not set
77# CONFIG_DEFAULT_DEADLINE is not set 79CONFIG_DEFAULT_DEADLINE=y
78# CONFIG_DEFAULT_CFQ is not set 80# CONFIG_DEFAULT_CFQ is not set
79# CONFIG_DEFAULT_NOOP is not set 81# CONFIG_DEFAULT_NOOP is not set
80CONFIG_DEFAULT_IOSCHED="anticipatory" 82CONFIG_DEFAULT_IOSCHED="deadline"
81 83
82# 84#
83# System Type 85# System Type
@@ -86,11 +88,12 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
86# CONFIG_ARCH_CLPS711X is not set 88# CONFIG_ARCH_CLPS711X is not set
87# CONFIG_ARCH_CO285 is not set 89# CONFIG_ARCH_CO285 is not set
88# CONFIG_ARCH_EBSA110 is not set 90# CONFIG_ARCH_EBSA110 is not set
91CONFIG_ARCH_EP93XX=y
89# CONFIG_ARCH_FOOTBRIDGE is not set 92# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set 93# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set 94# CONFIG_ARCH_IOP3XX is not set
92# CONFIG_ARCH_IXP4XX is not set 95# CONFIG_ARCH_IXP4XX is not set
93CONFIG_ARCH_IXP2000=y 96# CONFIG_ARCH_IXP2000 is not set
94# CONFIG_ARCH_L7200 is not set 97# CONFIG_ARCH_L7200 is not set
95# CONFIG_ARCH_PXA is not set 98# CONFIG_ARCH_PXA is not set
96# CONFIG_ARCH_RPC is not set 99# CONFIG_ARCH_RPC is not set
@@ -104,46 +107,44 @@ CONFIG_ARCH_IXP2000=y
104# CONFIG_ARCH_IMX is not set 107# CONFIG_ARCH_IMX is not set
105# CONFIG_ARCH_H720X is not set 108# CONFIG_ARCH_H720X is not set
106# CONFIG_ARCH_AAEC2000 is not set 109# CONFIG_ARCH_AAEC2000 is not set
107CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y 110# CONFIG_ARCH_AT91RM9200 is not set
108 111
109# 112#
110# Intel IXP2400/2800 Implementation Options 113# Cirrus EP93xx Implementation Options
111# 114#
115CONFIG_CRUNCH=y
112 116
113# 117#
114# IXP2400/2800 Platforms 118# EP93xx Platforms
115# 119#
116CONFIG_ARCH_ENP2611=y 120CONFIG_MACH_GESBC9312=y
117# CONFIG_ARCH_IXDP2400 is not set 121CONFIG_MACH_TS72XX=y
118# CONFIG_ARCH_IXDP2800 is not set
119# CONFIG_ARCH_IXDP2401 is not set
120# CONFIG_ARCH_IXDP2801 is not set
121# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
122 122
123# 123#
124# Processor Type 124# Processor Type
125# 125#
126CONFIG_CPU_32=y 126CONFIG_CPU_32=y
127CONFIG_CPU_XSCALE=y 127CONFIG_CPU_ARM920T=y
128CONFIG_CPU_32v5=y 128CONFIG_CPU_32v4=y
129CONFIG_CPU_ABRT_EV5T=y 129CONFIG_CPU_ABRT_EV4T=y
130CONFIG_CPU_CACHE_V4WT=y
130CONFIG_CPU_CACHE_VIVT=y 131CONFIG_CPU_CACHE_VIVT=y
132CONFIG_CPU_COPY_V4WB=y
131CONFIG_CPU_TLB_V4WBI=y 133CONFIG_CPU_TLB_V4WBI=y
132 134
133# 135#
134# Processor Features 136# Processor Features
135# 137#
136# CONFIG_ARM_THUMB is not set 138CONFIG_ARM_THUMB=y
137CONFIG_CPU_BIG_ENDIAN=y 139# CONFIG_CPU_ICACHE_DISABLE is not set
138CONFIG_XSCALE_PMU=y 140# CONFIG_CPU_DCACHE_DISABLE is not set
141# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
142CONFIG_ARM_VIC=y
139 143
140# 144#
141# Bus support 145# Bus support
142# 146#
143CONFIG_ISA_DMA_API=y 147CONFIG_ARM_AMBA=y
144CONFIG_PCI=y
145CONFIG_PCI_LEGACY_PROC=y
146# CONFIG_PCI_DEBUG is not set
147 148
148# 149#
149# PCCARD (PCMCIA/CardBus) support 150# PCCARD (PCMCIA/CardBus) support
@@ -155,6 +156,8 @@ CONFIG_PCI_LEGACY_PROC=y
155# 156#
156# CONFIG_PREEMPT is not set 157# CONFIG_PREEMPT is not set
157# CONFIG_NO_IDLE_HZ is not set 158# CONFIG_NO_IDLE_HZ is not set
159CONFIG_HZ=100
160# CONFIG_AEABI is not set
158# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set 161# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
159CONFIG_SELECT_MEMORY_MODEL=y 162CONFIG_SELECT_MEMORY_MODEL=y
160CONFIG_FLATMEM_MANUAL=y 163CONFIG_FLATMEM_MANUAL=y
@@ -171,7 +174,7 @@ CONFIG_ALIGNMENT_TRAP=y
171# 174#
172CONFIG_ZBOOT_ROM_TEXT=0x0 175CONFIG_ZBOOT_ROM_TEXT=0x0
173CONFIG_ZBOOT_ROM_BSS=0x0 176CONFIG_ZBOOT_ROM_BSS=0x0
174CONFIG_CMDLINE="console=ttyS0,57600 root=/dev/nfs ip=bootp mem=64M@0x0" 177CONFIG_CMDLINE="console=ttyAM0,115200 root=/dev/nfs ip=bootp"
175# CONFIG_XIP_KERNEL is not set 178# CONFIG_XIP_KERNEL is not set
176 179
177# 180#
@@ -197,6 +200,7 @@ CONFIG_BINFMT_ELF=y
197# Power management options 200# Power management options
198# 201#
199# CONFIG_PM is not set 202# CONFIG_PM is not set
203# CONFIG_APM is not set
200 204
201# 205#
202# Networking 206# Networking
@@ -206,10 +210,13 @@ CONFIG_NET=y
206# 210#
207# Networking options 211# Networking options
208# 212#
213# CONFIG_NETDEBUG is not set
209CONFIG_PACKET=y 214CONFIG_PACKET=y
210CONFIG_PACKET_MMAP=y 215CONFIG_PACKET_MMAP=y
211CONFIG_UNIX=y 216CONFIG_UNIX=y
212# CONFIG_NET_KEY is not set 217CONFIG_XFRM=y
218# CONFIG_XFRM_USER is not set
219CONFIG_NET_KEY=y
213CONFIG_INET=y 220CONFIG_INET=y
214# CONFIG_IP_MULTICAST is not set 221# CONFIG_IP_MULTICAST is not set
215# CONFIG_IP_ADVANCED_ROUTER is not set 222# CONFIG_IP_ADVANCED_ROUTER is not set
@@ -242,6 +249,11 @@ CONFIG_TCP_CONG_BIC=y
242# SCTP Configuration (EXPERIMENTAL) 249# SCTP Configuration (EXPERIMENTAL)
243# 250#
244# CONFIG_IP_SCTP is not set 251# CONFIG_IP_SCTP is not set
252
253#
254# TIPC Configuration (EXPERIMENTAL)
255#
256# CONFIG_TIPC is not set
245# CONFIG_ATM is not set 257# CONFIG_ATM is not set
246# CONFIG_BRIDGE is not set 258# CONFIG_BRIDGE is not set
247# CONFIG_VLAN_8021Q is not set 259# CONFIG_VLAN_8021Q is not set
@@ -259,7 +271,6 @@ CONFIG_TCP_CONG_BIC=y
259# QoS and/or fair queueing 271# QoS and/or fair queueing
260# 272#
261# CONFIG_NET_SCHED is not set 273# CONFIG_NET_SCHED is not set
262# CONFIG_NET_CLS_ROUTE is not set
263 274
264# 275#
265# Network testing 276# Network testing
@@ -278,21 +289,26 @@ CONFIG_TCP_CONG_BIC=y
278# Generic Driver Options 289# Generic Driver Options
279# 290#
280CONFIG_STANDALONE=y 291CONFIG_STANDALONE=y
281# CONFIG_PREVENT_FIRMWARE_BUILD is not set 292CONFIG_PREVENT_FIRMWARE_BUILD=y
282# CONFIG_FW_LOADER is not set 293# CONFIG_FW_LOADER is not set
283# CONFIG_DEBUG_DRIVER is not set 294# CONFIG_DEBUG_DRIVER is not set
284 295
285# 296#
297# Connector - unified userspace <-> kernelspace linker
298#
299# CONFIG_CONNECTOR is not set
300
301#
286# Memory Technology Devices (MTD) 302# Memory Technology Devices (MTD)
287# 303#
288CONFIG_MTD=y 304CONFIG_MTD=y
289# CONFIG_MTD_DEBUG is not set 305# CONFIG_MTD_DEBUG is not set
290# CONFIG_MTD_CONCAT is not set 306CONFIG_MTD_CONCAT=y
291CONFIG_MTD_PARTITIONS=y 307CONFIG_MTD_PARTITIONS=y
292CONFIG_MTD_REDBOOT_PARTS=y 308CONFIG_MTD_REDBOOT_PARTS=y
293CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 309CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
294CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y 310# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
295CONFIG_MTD_REDBOOT_PARTS_READONLY=y 311# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
296# CONFIG_MTD_CMDLINE_PARTS is not set 312# CONFIG_MTD_CMDLINE_PARTS is not set
297# CONFIG_MTD_AFS_PARTS is not set 313# CONFIG_MTD_AFS_PARTS is not set
298 314
@@ -312,7 +328,11 @@ CONFIG_MTD_BLOCK=y
312CONFIG_MTD_CFI=y 328CONFIG_MTD_CFI=y
313# CONFIG_MTD_JEDECPROBE is not set 329# CONFIG_MTD_JEDECPROBE is not set
314CONFIG_MTD_GEN_PROBE=y 330CONFIG_MTD_GEN_PROBE=y
315# CONFIG_MTD_CFI_ADV_OPTIONS is not set 331CONFIG_MTD_CFI_ADV_OPTIONS=y
332CONFIG_MTD_CFI_NOSWAP=y
333# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
334# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
335# CONFIG_MTD_CFI_GEOMETRY is not set
316CONFIG_MTD_MAP_BANK_WIDTH_1=y 336CONFIG_MTD_MAP_BANK_WIDTH_1=y
317CONFIG_MTD_MAP_BANK_WIDTH_2=y 337CONFIG_MTD_MAP_BANK_WIDTH_2=y
318CONFIG_MTD_MAP_BANK_WIDTH_4=y 338CONFIG_MTD_MAP_BANK_WIDTH_4=y
@@ -323,29 +343,31 @@ CONFIG_MTD_CFI_I1=y
323CONFIG_MTD_CFI_I2=y 343CONFIG_MTD_CFI_I2=y
324# CONFIG_MTD_CFI_I4 is not set 344# CONFIG_MTD_CFI_I4 is not set
325# CONFIG_MTD_CFI_I8 is not set 345# CONFIG_MTD_CFI_I8 is not set
346# CONFIG_MTD_OTP is not set
326CONFIG_MTD_CFI_INTELEXT=y 347CONFIG_MTD_CFI_INTELEXT=y
327# CONFIG_MTD_CFI_AMDSTD is not set 348CONFIG_MTD_CFI_AMDSTD=y
328# CONFIG_MTD_CFI_STAA is not set 349CONFIG_MTD_CFI_AMDSTD_RETRY=0
350CONFIG_MTD_CFI_STAA=y
329CONFIG_MTD_CFI_UTIL=y 351CONFIG_MTD_CFI_UTIL=y
330# CONFIG_MTD_RAM is not set 352# CONFIG_MTD_RAM is not set
331# CONFIG_MTD_ROM is not set 353CONFIG_MTD_ROM=y
332# CONFIG_MTD_ABSENT is not set 354# CONFIG_MTD_ABSENT is not set
333# CONFIG_MTD_XIP is not set 355# CONFIG_MTD_OBSOLETE_CHIPS is not set
334 356
335# 357#
336# Mapping drivers for chip access 358# Mapping drivers for chip access
337# 359#
338CONFIG_MTD_COMPLEX_MAPPINGS=y 360# CONFIG_MTD_COMPLEX_MAPPINGS is not set
339# CONFIG_MTD_PHYSMAP is not set 361CONFIG_MTD_PHYSMAP=y
362CONFIG_MTD_PHYSMAP_START=0x0
363CONFIG_MTD_PHYSMAP_LEN=0x0
364CONFIG_MTD_PHYSMAP_BANKWIDTH=1
340# CONFIG_MTD_ARM_INTEGRATOR is not set 365# CONFIG_MTD_ARM_INTEGRATOR is not set
341CONFIG_MTD_IXP2000=y
342# CONFIG_MTD_PCI is not set
343# CONFIG_MTD_PLATRAM is not set 366# CONFIG_MTD_PLATRAM is not set
344 367
345# 368#
346# Self-contained MTD device drivers 369# Self-contained MTD device drivers
347# 370#
348# CONFIG_MTD_PMC551 is not set
349# CONFIG_MTD_SLRAM is not set 371# CONFIG_MTD_SLRAM is not set
350# CONFIG_MTD_PHRAM is not set 372# CONFIG_MTD_PHRAM is not set
351# CONFIG_MTD_MTDRAM is not set 373# CONFIG_MTD_MTDRAM is not set
@@ -362,7 +384,11 @@ CONFIG_MTD_IXP2000=y
362# 384#
363# NAND Flash Device Drivers 385# NAND Flash Device Drivers
364# 386#
365# CONFIG_MTD_NAND is not set 387CONFIG_MTD_NAND=y
388CONFIG_MTD_NAND_VERIFY_WRITE=y
389CONFIG_MTD_NAND_IDS=y
390# CONFIG_MTD_NAND_DISKONCHIP is not set
391# CONFIG_MTD_NAND_NANDSIM is not set
366 392
367# 393#
368# OneNAND Flash Device Drivers 394# OneNAND Flash Device Drivers
@@ -381,19 +407,12 @@ CONFIG_MTD_IXP2000=y
381# 407#
382# Block devices 408# Block devices
383# 409#
384# CONFIG_BLK_CPQ_DA is not set
385# CONFIG_BLK_CPQ_CISS_DA is not set
386# CONFIG_BLK_DEV_DAC960 is not set
387# CONFIG_BLK_DEV_UMEM is not set
388# CONFIG_BLK_DEV_COW_COMMON is not set 410# CONFIG_BLK_DEV_COW_COMMON is not set
389CONFIG_BLK_DEV_LOOP=y 411# CONFIG_BLK_DEV_LOOP is not set
390# CONFIG_BLK_DEV_CRYPTOLOOP is not set
391# CONFIG_BLK_DEV_NBD is not set 412# CONFIG_BLK_DEV_NBD is not set
392# CONFIG_BLK_DEV_SX8 is not set 413# CONFIG_BLK_DEV_UB is not set
393CONFIG_BLK_DEV_RAM=y 414# CONFIG_BLK_DEV_RAM is not set
394CONFIG_BLK_DEV_RAM_COUNT=16 415CONFIG_BLK_DEV_RAM_COUNT=16
395CONFIG_BLK_DEV_RAM_SIZE=8192
396CONFIG_BLK_DEV_INITRD=y
397# CONFIG_CDROM_PKTCDVD is not set 416# CONFIG_CDROM_PKTCDVD is not set
398# CONFIG_ATA_OVER_ETH is not set 417# CONFIG_ATA_OVER_ETH is not set
399 418
@@ -401,7 +420,40 @@ CONFIG_BLK_DEV_INITRD=y
401# SCSI device support 420# SCSI device support
402# 421#
403# CONFIG_RAID_ATTRS is not set 422# CONFIG_RAID_ATTRS is not set
404# CONFIG_SCSI is not set 423CONFIG_SCSI=y
424# CONFIG_SCSI_PROC_FS is not set
425
426#
427# SCSI support type (disk, tape, CD-ROM)
428#
429CONFIG_BLK_DEV_SD=y
430# CONFIG_CHR_DEV_ST is not set
431# CONFIG_CHR_DEV_OSST is not set
432# CONFIG_BLK_DEV_SR is not set
433# CONFIG_CHR_DEV_SG is not set
434# CONFIG_CHR_DEV_SCH is not set
435
436#
437# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
438#
439# CONFIG_SCSI_MULTI_LUN is not set
440# CONFIG_SCSI_CONSTANTS is not set
441# CONFIG_SCSI_LOGGING is not set
442
443#
444# SCSI Transport Attributes
445#
446# CONFIG_SCSI_SPI_ATTRS is not set
447# CONFIG_SCSI_FC_ATTRS is not set
448# CONFIG_SCSI_ISCSI_ATTRS is not set
449# CONFIG_SCSI_SAS_ATTRS is not set
450
451#
452# SCSI low-level drivers
453#
454# CONFIG_ISCSI_TCP is not set
455# CONFIG_SCSI_SATA is not set
456# CONFIG_SCSI_DEBUG is not set
405 457
406# 458#
407# Multi-device support (RAID and LVM) 459# Multi-device support (RAID and LVM)
@@ -416,28 +468,21 @@ CONFIG_BLK_DEV_INITRD=y
416# 468#
417# IEEE 1394 (FireWire) support 469# IEEE 1394 (FireWire) support
418# 470#
419# CONFIG_IEEE1394 is not set
420 471
421# 472#
422# I2O device support 473# I2O device support
423# 474#
424# CONFIG_I2O is not set
425 475
426# 476#
427# Network device support 477# Network device support
428# 478#
429CONFIG_NETDEVICES=y 479CONFIG_NETDEVICES=y
430CONFIG_DUMMY=y 480# CONFIG_DUMMY is not set
431# CONFIG_BONDING is not set 481# CONFIG_BONDING is not set
432# CONFIG_EQUALIZER is not set 482# CONFIG_EQUALIZER is not set
433# CONFIG_TUN is not set 483# CONFIG_TUN is not set
434 484
435# 485#
436# ARCnet devices
437#
438# CONFIG_ARCNET is not set
439
440#
441# PHY device support 486# PHY device support
442# 487#
443# CONFIG_PHYLIB is not set 488# CONFIG_PHYLIB is not set
@@ -447,66 +492,20 @@ CONFIG_DUMMY=y
447# 492#
448CONFIG_NET_ETHERNET=y 493CONFIG_NET_ETHERNET=y
449CONFIG_MII=y 494CONFIG_MII=y
450# CONFIG_HAPPYMEAL is not set
451# CONFIG_SUNGEM is not set
452# CONFIG_CASSINI is not set
453# CONFIG_NET_VENDOR_3COM is not set
454# CONFIG_SMC91X is not set 495# CONFIG_SMC91X is not set
455# CONFIG_DM9000 is not set 496# CONFIG_DM9000 is not set
456 497
457# 498#
458# Tulip family network device support
459#
460# CONFIG_NET_TULIP is not set
461# CONFIG_HP100 is not set
462CONFIG_NET_PCI=y
463# CONFIG_PCNET32 is not set
464# CONFIG_AMD8111_ETH is not set
465# CONFIG_ADAPTEC_STARFIRE is not set
466# CONFIG_B44 is not set
467# CONFIG_FORCEDETH is not set
468# CONFIG_DGRS is not set
469CONFIG_EEPRO100=y
470# CONFIG_E100 is not set
471# CONFIG_FEALNX is not set
472# CONFIG_NATSEMI is not set
473# CONFIG_NE2K_PCI is not set
474# CONFIG_8139CP is not set
475# CONFIG_8139TOO is not set
476# CONFIG_SIS900 is not set
477# CONFIG_EPIC100 is not set
478# CONFIG_SUNDANCE is not set
479# CONFIG_TLAN is not set
480# CONFIG_VIA_RHINE is not set
481
482#
483# Ethernet (1000 Mbit) 499# Ethernet (1000 Mbit)
484# 500#
485# CONFIG_ACENIC is not set
486# CONFIG_DL2K is not set
487# CONFIG_E1000 is not set
488# CONFIG_NS83820 is not set
489# CONFIG_HAMACHI is not set
490# CONFIG_YELLOWFIN is not set
491# CONFIG_R8169 is not set
492# CONFIG_SIS190 is not set
493# CONFIG_SKGE is not set
494# CONFIG_SK98LIN is not set
495# CONFIG_VIA_VELOCITY is not set
496# CONFIG_TIGON3 is not set
497# CONFIG_BNX2 is not set
498 501
499# 502#
500# Ethernet (10000 Mbit) 503# Ethernet (10000 Mbit)
501# 504#
502# CONFIG_CHELSIO_T1 is not set
503# CONFIG_IXGB is not set
504# CONFIG_S2IO is not set
505 505
506# 506#
507# Token Ring devices 507# Token Ring devices
508# 508#
509# CONFIG_TR is not set
510 509
511# 510#
512# Wireless LAN (non-hamradio) 511# Wireless LAN (non-hamradio)
@@ -516,29 +515,7 @@ CONFIG_EEPRO100=y
516# 515#
517# Wan interfaces 516# Wan interfaces
518# 517#
519CONFIG_WAN=y 518# CONFIG_WAN is not set
520# CONFIG_DSCC4 is not set
521# CONFIG_LANMEDIA is not set
522# CONFIG_SYNCLINK_SYNCPPP is not set
523CONFIG_HDLC=y
524CONFIG_HDLC_RAW=y
525# CONFIG_HDLC_RAW_ETH is not set
526CONFIG_HDLC_CISCO=y
527CONFIG_HDLC_FR=y
528CONFIG_HDLC_PPP=y
529
530#
531# X.25/LAPB support is disabled
532#
533# CONFIG_PCI200SYN is not set
534# CONFIG_WANXL is not set
535# CONFIG_PC300 is not set
536# CONFIG_FARSYNC is not set
537CONFIG_DLCI=y
538CONFIG_DLCI_COUNT=24
539CONFIG_DLCI_MAX=8
540# CONFIG_FDDI is not set
541# CONFIG_HIPPI is not set
542# CONFIG_PPP is not set 519# CONFIG_PPP is not set
543# CONFIG_SLIP is not set 520# CONFIG_SLIP is not set
544# CONFIG_SHAPER is not set 521# CONFIG_SHAPER is not set
@@ -554,28 +531,7 @@ CONFIG_DLCI_MAX=8
554# 531#
555# Input device support 532# Input device support
556# 533#
557CONFIG_INPUT=y 534# CONFIG_INPUT is not set
558
559#
560# Userland interfaces
561#
562CONFIG_INPUT_MOUSEDEV=y
563CONFIG_INPUT_MOUSEDEV_PSAUX=y
564CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
565CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
566# CONFIG_INPUT_JOYDEV is not set
567# CONFIG_INPUT_TSDEV is not set
568# CONFIG_INPUT_EVDEV is not set
569# CONFIG_INPUT_EVBUG is not set
570
571#
572# Input Device Drivers
573#
574# CONFIG_INPUT_KEYBOARD is not set
575# CONFIG_INPUT_MOUSE is not set
576# CONFIG_INPUT_JOYSTICK is not set
577# CONFIG_INPUT_TOUCHSCREEN is not set
578# CONFIG_INPUT_MISC is not set
579 535
580# 536#
581# Hardware I/O ports 537# Hardware I/O ports
@@ -592,20 +548,18 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
592# 548#
593# Serial drivers 549# Serial drivers
594# 550#
595CONFIG_SERIAL_8250=y 551# CONFIG_SERIAL_8250 is not set
596CONFIG_SERIAL_8250_CONSOLE=y
597CONFIG_SERIAL_8250_NR_UARTS=2
598# CONFIG_SERIAL_8250_EXTENDED is not set
599 552
600# 553#
601# Non-8250 serial port support 554# Non-8250 serial port support
602# 555#
556CONFIG_SERIAL_AMBA_PL010=y
557CONFIG_SERIAL_AMBA_PL010_CONSOLE=y
558# CONFIG_SERIAL_AMBA_PL011 is not set
603CONFIG_SERIAL_CORE=y 559CONFIG_SERIAL_CORE=y
604CONFIG_SERIAL_CORE_CONSOLE=y 560CONFIG_SERIAL_CORE_CONSOLE=y
605# CONFIG_SERIAL_JSM is not set
606CONFIG_UNIX98_PTYS=y 561CONFIG_UNIX98_PTYS=y
607CONFIG_LEGACY_PTYS=y 562# CONFIG_LEGACY_PTYS is not set
608CONFIG_LEGACY_PTY_COUNT=256
609 563
610# 564#
611# IPMI 565# IPMI
@@ -622,23 +576,19 @@ CONFIG_WATCHDOG=y
622# Watchdog Device Drivers 576# Watchdog Device Drivers
623# 577#
624# CONFIG_SOFT_WATCHDOG is not set 578# CONFIG_SOFT_WATCHDOG is not set
625CONFIG_IXP2000_WATCHDOG=y
626 579
627# 580#
628# PCI-based Watchdog Cards 581# USB-based Watchdog Cards
629# 582#
630# CONFIG_PCIPCWATCHDOG is not set 583# CONFIG_USBPCWATCHDOG is not set
631# CONFIG_WDTPCI is not set
632# CONFIG_NVRAM is not set 584# CONFIG_NVRAM is not set
633# CONFIG_RTC is not set 585# CONFIG_RTC is not set
634# CONFIG_DTLK is not set 586# CONFIG_DTLK is not set
635# CONFIG_R3964 is not set 587# CONFIG_R3964 is not set
636# CONFIG_APPLICOM is not set
637 588
638# 589#
639# Ftape, the floppy tape device driver 590# Ftape, the floppy tape device driver
640# 591#
641# CONFIG_DRM is not set
642# CONFIG_RAW_DRIVER is not set 592# CONFIG_RAW_DRIVER is not set
643 593
644# 594#
@@ -663,27 +613,8 @@ CONFIG_I2C_ALGOBIT=y
663# 613#
664# I2C Hardware Bus support 614# I2C Hardware Bus support
665# 615#
666# CONFIG_I2C_ALI1535 is not set
667# CONFIG_I2C_ALI1563 is not set
668# CONFIG_I2C_ALI15X3 is not set
669# CONFIG_I2C_AMD756 is not set
670# CONFIG_I2C_AMD8111 is not set
671# CONFIG_I2C_I801 is not set
672# CONFIG_I2C_I810 is not set
673# CONFIG_I2C_PIIX4 is not set
674CONFIG_I2C_IXP2000=y
675# CONFIG_I2C_NFORCE2 is not set
676# CONFIG_I2C_PARPORT_LIGHT is not set 616# CONFIG_I2C_PARPORT_LIGHT is not set
677# CONFIG_I2C_PROSAVAGE is not set
678# CONFIG_I2C_SAVAGE4 is not set
679# CONFIG_SCx200_ACB is not set
680# CONFIG_I2C_SIS5595 is not set
681# CONFIG_I2C_SIS630 is not set
682# CONFIG_I2C_SIS96X is not set
683# CONFIG_I2C_STUB is not set 617# CONFIG_I2C_STUB is not set
684# CONFIG_I2C_VIA is not set
685# CONFIG_I2C_VIAPRO is not set
686# CONFIG_I2C_VOODOO3 is not set
687# CONFIG_I2C_PCA_ISA is not set 618# CONFIG_I2C_PCA_ISA is not set
688 619
689# 620#
@@ -691,17 +622,28 @@ CONFIG_I2C_IXP2000=y
691# 622#
692# CONFIG_SENSORS_DS1337 is not set 623# CONFIG_SENSORS_DS1337 is not set
693# CONFIG_SENSORS_DS1374 is not set 624# CONFIG_SENSORS_DS1374 is not set
694CONFIG_SENSORS_EEPROM=y 625# CONFIG_SENSORS_EEPROM is not set
695# CONFIG_SENSORS_PCF8574 is not set 626# CONFIG_SENSORS_PCF8574 is not set
696# CONFIG_SENSORS_PCA9539 is not set 627# CONFIG_SENSORS_PCA9539 is not set
697# CONFIG_SENSORS_PCF8591 is not set 628# CONFIG_SENSORS_PCF8591 is not set
698# CONFIG_SENSORS_RTC8564 is not set 629# CONFIG_SENSORS_RTC8564 is not set
699# CONFIG_SENSORS_MAX6875 is not set 630# CONFIG_SENSORS_MAX6875 is not set
700# CONFIG_RTC_X1205_I2C is not set 631# CONFIG_RTC_X1205_I2C is not set
701# CONFIG_I2C_DEBUG_CORE is not set 632CONFIG_I2C_DEBUG_CORE=y
702# CONFIG_I2C_DEBUG_ALGO is not set 633CONFIG_I2C_DEBUG_ALGO=y
703# CONFIG_I2C_DEBUG_BUS is not set 634CONFIG_I2C_DEBUG_BUS=y
704# CONFIG_I2C_DEBUG_CHIP is not set 635CONFIG_I2C_DEBUG_CHIP=y
636
637#
638# SPI support
639#
640# CONFIG_SPI is not set
641# CONFIG_SPI_MASTER is not set
642
643#
644# Dallas's 1-wire bus
645#
646# CONFIG_W1 is not set
705 647
706# 648#
707# Hardware Monitoring support 649# Hardware Monitoring support
@@ -716,6 +658,7 @@ CONFIG_HWMON=y
716# CONFIG_SENSORS_ASB100 is not set 658# CONFIG_SENSORS_ASB100 is not set
717# CONFIG_SENSORS_ATXP1 is not set 659# CONFIG_SENSORS_ATXP1 is not set
718# CONFIG_SENSORS_DS1621 is not set 660# CONFIG_SENSORS_DS1621 is not set
661# CONFIG_SENSORS_F71805F is not set
719# CONFIG_SENSORS_FSCHER is not set 662# CONFIG_SENSORS_FSCHER is not set
720# CONFIG_SENSORS_FSCPOS is not set 663# CONFIG_SENSORS_FSCPOS is not set
721# CONFIG_SENSORS_GL518SM is not set 664# CONFIG_SENSORS_GL518SM is not set
@@ -733,10 +676,8 @@ CONFIG_HWMON=y
733# CONFIG_SENSORS_LM92 is not set 676# CONFIG_SENSORS_LM92 is not set
734# CONFIG_SENSORS_MAX1619 is not set 677# CONFIG_SENSORS_MAX1619 is not set
735# CONFIG_SENSORS_PC87360 is not set 678# CONFIG_SENSORS_PC87360 is not set
736# CONFIG_SENSORS_SIS5595 is not set
737# CONFIG_SENSORS_SMSC47M1 is not set 679# CONFIG_SENSORS_SMSC47M1 is not set
738# CONFIG_SENSORS_SMSC47B397 is not set 680# CONFIG_SENSORS_SMSC47B397 is not set
739# CONFIG_SENSORS_VIA686A is not set
740# CONFIG_SENSORS_W83781D is not set 681# CONFIG_SENSORS_W83781D is not set
741# CONFIG_SENSORS_W83792D is not set 682# CONFIG_SENSORS_W83792D is not set
742# CONFIG_SENSORS_W83L785TS is not set 683# CONFIG_SENSORS_W83L785TS is not set
@@ -776,14 +717,144 @@ CONFIG_HWMON=y
776# USB support 717# USB support
777# 718#
778CONFIG_USB_ARCH_HAS_HCD=y 719CONFIG_USB_ARCH_HAS_HCD=y
779CONFIG_USB_ARCH_HAS_OHCI=y 720# CONFIG_USB_ARCH_HAS_OHCI is not set
780# CONFIG_USB is not set 721CONFIG_USB=y
722CONFIG_USB_DEBUG=y
723
724#
725# Miscellaneous USB options
726#
727CONFIG_USB_DEVICEFS=y
728# CONFIG_USB_BANDWIDTH is not set
729CONFIG_USB_DYNAMIC_MINORS=y
730# CONFIG_USB_OTG is not set
731
732#
733# USB Host Controller Drivers
734#
735# CONFIG_USB_ISP116X_HCD is not set
736# CONFIG_USB_SL811_HCD is not set
737
738#
739# USB Device Class drivers
740#
741# CONFIG_USB_ACM is not set
742# CONFIG_USB_PRINTER is not set
781 743
782# 744#
783# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 745# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
784# 746#
785 747
786# 748#
749# may also be needed; see USB_STORAGE Help for more information
750#
751CONFIG_USB_STORAGE=y
752# CONFIG_USB_STORAGE_DEBUG is not set
753# CONFIG_USB_STORAGE_DATAFAB is not set
754# CONFIG_USB_STORAGE_FREECOM is not set
755# CONFIG_USB_STORAGE_DPCM is not set
756# CONFIG_USB_STORAGE_USBAT is not set
757# CONFIG_USB_STORAGE_SDDR09 is not set
758# CONFIG_USB_STORAGE_SDDR55 is not set
759# CONFIG_USB_STORAGE_JUMPSHOT is not set
760# CONFIG_USB_STORAGE_ALAUDA is not set
761# CONFIG_USB_LIBUSUAL is not set
762
763#
764# USB Input Devices
765#
766# CONFIG_USB_HID is not set
767
768#
769# USB HID Boot Protocol drivers
770#
771
772#
773# USB Imaging devices
774#
775# CONFIG_USB_MDC800 is not set
776# CONFIG_USB_MICROTEK is not set
777
778#
779# USB Multimedia devices
780#
781# CONFIG_USB_DABUSB is not set
782
783#
784# Video4Linux support is needed for USB Multimedia device support
785#
786
787#
788# USB Network Adapters
789#
790# CONFIG_USB_CATC is not set
791# CONFIG_USB_KAWETH is not set
792# CONFIG_USB_PEGASUS is not set
793CONFIG_USB_RTL8150=y
794# CONFIG_USB_USBNET is not set
795# CONFIG_USB_MON is not set
796
797#
798# USB port drivers
799#
800
801#
802# USB Serial Converter support
803#
804CONFIG_USB_SERIAL=y
805CONFIG_USB_SERIAL_CONSOLE=y
806# CONFIG_USB_SERIAL_GENERIC is not set
807# CONFIG_USB_SERIAL_AIRPRIME is not set
808# CONFIG_USB_SERIAL_ANYDATA is not set
809# CONFIG_USB_SERIAL_BELKIN is not set
810# CONFIG_USB_SERIAL_WHITEHEAT is not set
811# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
812# CONFIG_USB_SERIAL_CP2101 is not set
813# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
814# CONFIG_USB_SERIAL_EMPEG is not set
815# CONFIG_USB_SERIAL_FTDI_SIO is not set
816# CONFIG_USB_SERIAL_VISOR is not set
817# CONFIG_USB_SERIAL_IPAQ is not set
818# CONFIG_USB_SERIAL_IR is not set
819# CONFIG_USB_SERIAL_EDGEPORT is not set
820# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
821# CONFIG_USB_SERIAL_GARMIN is not set
822# CONFIG_USB_SERIAL_IPW is not set
823# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
824# CONFIG_USB_SERIAL_KEYSPAN is not set
825# CONFIG_USB_SERIAL_KLSI is not set
826# CONFIG_USB_SERIAL_KOBIL_SCT is not set
827# CONFIG_USB_SERIAL_MCT_U232 is not set
828CONFIG_USB_SERIAL_PL2303=y
829# CONFIG_USB_SERIAL_HP4X is not set
830# CONFIG_USB_SERIAL_SAFE is not set
831# CONFIG_USB_SERIAL_TI is not set
832# CONFIG_USB_SERIAL_CYBERJACK is not set
833# CONFIG_USB_SERIAL_XIRCOM is not set
834# CONFIG_USB_SERIAL_OMNINET is not set
835
836#
837# USB Miscellaneous drivers
838#
839# CONFIG_USB_EMI62 is not set
840# CONFIG_USB_EMI26 is not set
841# CONFIG_USB_AUERSWALD is not set
842# CONFIG_USB_RIO500 is not set
843# CONFIG_USB_LEGOTOWER is not set
844# CONFIG_USB_LCD is not set
845# CONFIG_USB_LED is not set
846# CONFIG_USB_CYTHERM is not set
847# CONFIG_USB_PHIDGETKIT is not set
848# CONFIG_USB_PHIDGETSERVO is not set
849# CONFIG_USB_IDMOUSE is not set
850# CONFIG_USB_LD is not set
851# CONFIG_USB_TEST is not set
852
853#
854# USB DSL modem support
855#
856
857#
787# USB Gadget Support 858# USB Gadget Support
788# 859#
789# CONFIG_USB_GADGET is not set 860# CONFIG_USB_GADGET is not set
@@ -797,21 +868,17 @@ CONFIG_USB_ARCH_HAS_OHCI=y
797# File systems 868# File systems
798# 869#
799CONFIG_EXT2_FS=y 870CONFIG_EXT2_FS=y
800CONFIG_EXT2_FS_XATTR=y 871# CONFIG_EXT2_FS_XATTR is not set
801CONFIG_EXT2_FS_POSIX_ACL=y
802# CONFIG_EXT2_FS_SECURITY is not set
803# CONFIG_EXT2_FS_XIP is not set 872# CONFIG_EXT2_FS_XIP is not set
804CONFIG_EXT3_FS=y 873CONFIG_EXT3_FS=y
805CONFIG_EXT3_FS_XATTR=y 874# CONFIG_EXT3_FS_XATTR is not set
806CONFIG_EXT3_FS_POSIX_ACL=y
807# CONFIG_EXT3_FS_SECURITY is not set
808CONFIG_JBD=y 875CONFIG_JBD=y
809# CONFIG_JBD_DEBUG is not set 876# CONFIG_JBD_DEBUG is not set
810CONFIG_FS_MBCACHE=y
811# CONFIG_REISERFS_FS is not set 877# CONFIG_REISERFS_FS is not set
812# CONFIG_JFS_FS is not set 878# CONFIG_JFS_FS is not set
813CONFIG_FS_POSIX_ACL=y 879# CONFIG_FS_POSIX_ACL is not set
814# CONFIG_XFS_FS is not set 880# CONFIG_XFS_FS is not set
881# CONFIG_OCFS2_FS is not set
815# CONFIG_MINIX_FS is not set 882# CONFIG_MINIX_FS is not set
816# CONFIG_ROMFS_FS is not set 883# CONFIG_ROMFS_FS is not set
817CONFIG_INOTIFY=y 884CONFIG_INOTIFY=y
@@ -830,8 +897,11 @@ CONFIG_DNOTIFY=y
830# 897#
831# DOS/FAT/NT Filesystems 898# DOS/FAT/NT Filesystems
832# 899#
900CONFIG_FAT_FS=y
833# CONFIG_MSDOS_FS is not set 901# CONFIG_MSDOS_FS is not set
834# CONFIG_VFAT_FS is not set 902CONFIG_VFAT_FS=y
903CONFIG_FAT_DEFAULT_CODEPAGE=437
904CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
835# CONFIG_NTFS_FS is not set 905# CONFIG_NTFS_FS is not set
836 906
837# 907#
@@ -843,6 +913,7 @@ CONFIG_TMPFS=y
843# CONFIG_HUGETLB_PAGE is not set 913# CONFIG_HUGETLB_PAGE is not set
844CONFIG_RAMFS=y 914CONFIG_RAMFS=y
845# CONFIG_RELAYFS_FS is not set 915# CONFIG_RELAYFS_FS is not set
916# CONFIG_CONFIGFS_FS is not set
846 917
847# 918#
848# Miscellaneous filesystems 919# Miscellaneous filesystems
@@ -911,12 +982,52 @@ CONFIG_MSDOS_PARTITION=y
911# CONFIG_SGI_PARTITION is not set 982# CONFIG_SGI_PARTITION is not set
912# CONFIG_ULTRIX_PARTITION is not set 983# CONFIG_ULTRIX_PARTITION is not set
913# CONFIG_SUN_PARTITION is not set 984# CONFIG_SUN_PARTITION is not set
985# CONFIG_KARMA_PARTITION is not set
914# CONFIG_EFI_PARTITION is not set 986# CONFIG_EFI_PARTITION is not set
915 987
916# 988#
917# Native Language Support 989# Native Language Support
918# 990#
919# CONFIG_NLS is not set 991CONFIG_NLS=y
992CONFIG_NLS_DEFAULT="iso8859-1"
993CONFIG_NLS_CODEPAGE_437=y
994# CONFIG_NLS_CODEPAGE_737 is not set
995# CONFIG_NLS_CODEPAGE_775 is not set
996# CONFIG_NLS_CODEPAGE_850 is not set
997# CONFIG_NLS_CODEPAGE_852 is not set
998# CONFIG_NLS_CODEPAGE_855 is not set
999# CONFIG_NLS_CODEPAGE_857 is not set
1000# CONFIG_NLS_CODEPAGE_860 is not set
1001# CONFIG_NLS_CODEPAGE_861 is not set
1002# CONFIG_NLS_CODEPAGE_862 is not set
1003# CONFIG_NLS_CODEPAGE_863 is not set
1004# CONFIG_NLS_CODEPAGE_864 is not set
1005# CONFIG_NLS_CODEPAGE_865 is not set
1006# CONFIG_NLS_CODEPAGE_866 is not set
1007# CONFIG_NLS_CODEPAGE_869 is not set
1008# CONFIG_NLS_CODEPAGE_936 is not set
1009# CONFIG_NLS_CODEPAGE_950 is not set
1010# CONFIG_NLS_CODEPAGE_932 is not set
1011# CONFIG_NLS_CODEPAGE_949 is not set
1012# CONFIG_NLS_CODEPAGE_874 is not set
1013# CONFIG_NLS_ISO8859_8 is not set
1014# CONFIG_NLS_CODEPAGE_1250 is not set
1015# CONFIG_NLS_CODEPAGE_1251 is not set
1016# CONFIG_NLS_ASCII is not set
1017CONFIG_NLS_ISO8859_1=y
1018# CONFIG_NLS_ISO8859_2 is not set
1019# CONFIG_NLS_ISO8859_3 is not set
1020# CONFIG_NLS_ISO8859_4 is not set
1021# CONFIG_NLS_ISO8859_5 is not set
1022# CONFIG_NLS_ISO8859_6 is not set
1023# CONFIG_NLS_ISO8859_7 is not set
1024# CONFIG_NLS_ISO8859_9 is not set
1025# CONFIG_NLS_ISO8859_13 is not set
1026# CONFIG_NLS_ISO8859_14 is not set
1027# CONFIG_NLS_ISO8859_15 is not set
1028# CONFIG_NLS_KOI8_R is not set
1029# CONFIG_NLS_KOI8_U is not set
1030# CONFIG_NLS_UTF8 is not set
920 1031
921# 1032#
922# Profiling support 1033# Profiling support
@@ -927,13 +1038,14 @@ CONFIG_MSDOS_PARTITION=y
927# Kernel hacking 1038# Kernel hacking
928# 1039#
929# CONFIG_PRINTK_TIME is not set 1040# CONFIG_PRINTK_TIME is not set
930CONFIG_DEBUG_KERNEL=y
931CONFIG_MAGIC_SYSRQ=y 1041CONFIG_MAGIC_SYSRQ=y
1042CONFIG_DEBUG_KERNEL=y
932CONFIG_LOG_BUF_SHIFT=14 1043CONFIG_LOG_BUF_SHIFT=14
933CONFIG_DETECT_SOFTLOCKUP=y 1044CONFIG_DETECT_SOFTLOCKUP=y
934# CONFIG_SCHEDSTATS is not set 1045# CONFIG_SCHEDSTATS is not set
935# CONFIG_DEBUG_SLAB is not set 1046CONFIG_DEBUG_SLAB=y
936# CONFIG_DEBUG_SPINLOCK is not set 1047CONFIG_DEBUG_MUTEXES=y
1048CONFIG_DEBUG_SPINLOCK=y
937# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1049# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
938# CONFIG_DEBUG_KOBJECT is not set 1050# CONFIG_DEBUG_KOBJECT is not set
939CONFIG_DEBUG_BUGVERBOSE=y 1051CONFIG_DEBUG_BUGVERBOSE=y
@@ -941,9 +1053,10 @@ CONFIG_DEBUG_BUGVERBOSE=y
941# CONFIG_DEBUG_FS is not set 1053# CONFIG_DEBUG_FS is not set
942# CONFIG_DEBUG_VM is not set 1054# CONFIG_DEBUG_VM is not set
943CONFIG_FRAME_POINTER=y 1055CONFIG_FRAME_POINTER=y
1056CONFIG_FORCED_INLINING=y
944# CONFIG_RCU_TORTURE_TEST is not set 1057# CONFIG_RCU_TORTURE_TEST is not set
945CONFIG_DEBUG_USER=y 1058CONFIG_DEBUG_USER=y
946# CONFIG_DEBUG_WAITQ is not set 1059CONFIG_DEBUG_WAITQ=y
947CONFIG_DEBUG_ERRORS=y 1060CONFIG_DEBUG_ERRORS=y
948CONFIG_DEBUG_LL=y 1061CONFIG_DEBUG_LL=y
949# CONFIG_DEBUG_ICEDCC is not set 1062# CONFIG_DEBUG_ICEDCC is not set
@@ -969,6 +1082,6 @@ CONFIG_DEBUG_LL=y
969# CONFIG_CRC_CCITT is not set 1082# CONFIG_CRC_CCITT is not set
970# CONFIG_CRC16 is not set 1083# CONFIG_CRC16 is not set
971CONFIG_CRC32=y 1084CONFIG_CRC32=y
972# CONFIG_LIBCRC32C is not set 1085CONFIG_LIBCRC32C=y
973CONFIG_ZLIB_INFLATE=y 1086CONFIG_ZLIB_INFLATE=y
974CONFIG_ZLIB_DEFLATE=y 1087CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2401_defconfig b/arch/arm/configs/ixdp2401_defconfig
deleted file mode 100644
index 60d66e82c51f..000000000000
--- a/arch/arm/configs/ixdp2401_defconfig
+++ /dev/null
@@ -1,976 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-git13
4# Thu Nov 10 15:14:50 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
19
20#
21# General setup
22#
23CONFIG_LOCALVERSION=""
24CONFIG_LOCALVERSION_AUTO=y
25CONFIG_SWAP=y
26CONFIG_SYSVIPC=y
27# CONFIG_POSIX_MQUEUE is not set
28CONFIG_BSD_PROCESS_ACCT=y
29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set
32# CONFIG_HOTPLUG is not set
33CONFIG_KOBJECT_UEVENT=y
34# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE=""
36CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set
39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_PRINTK=y
41CONFIG_BUG=y
42CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y
44CONFIG_EPOLL=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SHMEM=y
47CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0
49CONFIG_CC_ALIGN_LOOPS=0
50CONFIG_CC_ALIGN_JUMPS=0
51# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0
53
54#
55# Loadable module support
56#
57CONFIG_MODULES=y
58CONFIG_MODULE_UNLOAD=y
59# CONFIG_MODULE_FORCE_UNLOAD is not set
60CONFIG_OBSOLETE_MODPARM=y
61# CONFIG_MODVERSIONS is not set
62# CONFIG_MODULE_SRCVERSION_ALL is not set
63CONFIG_KMOD=y
64
65#
66# Block layer
67#
68
69#
70# IO Schedulers
71#
72CONFIG_IOSCHED_NOOP=y
73CONFIG_IOSCHED_AS=y
74CONFIG_IOSCHED_DEADLINE=y
75CONFIG_IOSCHED_CFQ=y
76CONFIG_DEFAULT_AS=y
77# CONFIG_DEFAULT_DEADLINE is not set
78# CONFIG_DEFAULT_CFQ is not set
79# CONFIG_DEFAULT_NOOP is not set
80CONFIG_DEFAULT_IOSCHED="anticipatory"
81
82#
83# System Type
84#
85# CONFIG_ARCH_CLPS7500 is not set
86# CONFIG_ARCH_CLPS711X is not set
87# CONFIG_ARCH_CO285 is not set
88# CONFIG_ARCH_EBSA110 is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set
92# CONFIG_ARCH_IXP4XX is not set
93CONFIG_ARCH_IXP2000=y
94# CONFIG_ARCH_L7200 is not set
95# CONFIG_ARCH_PXA is not set
96# CONFIG_ARCH_RPC is not set
97# CONFIG_ARCH_SA1100 is not set
98# CONFIG_ARCH_S3C2410 is not set
99# CONFIG_ARCH_SHARK is not set
100# CONFIG_ARCH_LH7A40X is not set
101# CONFIG_ARCH_OMAP is not set
102# CONFIG_ARCH_VERSATILE is not set
103# CONFIG_ARCH_REALVIEW is not set
104# CONFIG_ARCH_IMX is not set
105# CONFIG_ARCH_H720X is not set
106# CONFIG_ARCH_AAEC2000 is not set
107CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
108
109#
110# Intel IXP2400/2800 Implementation Options
111#
112
113#
114# IXP2400/2800 Platforms
115#
116# CONFIG_ARCH_ENP2611 is not set
117# CONFIG_ARCH_IXDP2400 is not set
118# CONFIG_ARCH_IXDP2800 is not set
119CONFIG_ARCH_IXDP2401=y
120# CONFIG_ARCH_IXDP2801 is not set
121CONFIG_ARCH_IXDP2X01=y
122# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
123
124#
125# Processor Type
126#
127CONFIG_CPU_32=y
128CONFIG_CPU_XSCALE=y
129CONFIG_CPU_32v5=y
130CONFIG_CPU_ABRT_EV5T=y
131CONFIG_CPU_CACHE_VIVT=y
132CONFIG_CPU_TLB_V4WBI=y
133
134#
135# Processor Features
136#
137# CONFIG_ARM_THUMB is not set
138CONFIG_CPU_BIG_ENDIAN=y
139CONFIG_XSCALE_PMU=y
140
141#
142# Bus support
143#
144CONFIG_ISA_DMA_API=y
145CONFIG_PCI=y
146CONFIG_PCI_LEGACY_PROC=y
147# CONFIG_PCI_DEBUG is not set
148
149#
150# PCCARD (PCMCIA/CardBus) support
151#
152# CONFIG_PCCARD is not set
153
154#
155# Kernel Features
156#
157# CONFIG_PREEMPT is not set
158# CONFIG_NO_IDLE_HZ is not set
159# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
160CONFIG_SELECT_MEMORY_MODEL=y
161CONFIG_FLATMEM_MANUAL=y
162# CONFIG_DISCONTIGMEM_MANUAL is not set
163# CONFIG_SPARSEMEM_MANUAL is not set
164CONFIG_FLATMEM=y
165CONFIG_FLAT_NODE_MEM_MAP=y
166# CONFIG_SPARSEMEM_STATIC is not set
167CONFIG_SPLIT_PTLOCK_CPUS=4096
168CONFIG_ALIGNMENT_TRAP=y
169
170#
171# Boot options
172#
173CONFIG_ZBOOT_ROM_TEXT=0x0
174CONFIG_ZBOOT_ROM_BSS=0x0
175CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs ip=bootp mem=64M@0x0"
176# CONFIG_XIP_KERNEL is not set
177
178#
179# Floating point emulation
180#
181
182#
183# At least one emulation must be selected
184#
185CONFIG_FPE_NWFPE=y
186CONFIG_FPE_NWFPE_XP=y
187# CONFIG_FPE_FASTFPE is not set
188
189#
190# Userspace binary formats
191#
192CONFIG_BINFMT_ELF=y
193# CONFIG_BINFMT_AOUT is not set
194# CONFIG_BINFMT_MISC is not set
195# CONFIG_ARTHUR is not set
196
197#
198# Power management options
199#
200# CONFIG_PM is not set
201
202#
203# Networking
204#
205CONFIG_NET=y
206
207#
208# Networking options
209#
210CONFIG_PACKET=y
211CONFIG_PACKET_MMAP=y
212CONFIG_UNIX=y
213# CONFIG_NET_KEY is not set
214CONFIG_INET=y
215# CONFIG_IP_MULTICAST is not set
216# CONFIG_IP_ADVANCED_ROUTER is not set
217CONFIG_IP_FIB_HASH=y
218CONFIG_IP_PNP=y
219CONFIG_IP_PNP_DHCP=y
220CONFIG_IP_PNP_BOOTP=y
221# CONFIG_IP_PNP_RARP is not set
222# CONFIG_NET_IPIP is not set
223# CONFIG_NET_IPGRE is not set
224# CONFIG_ARPD is not set
225CONFIG_SYN_COOKIES=y
226# CONFIG_INET_AH is not set
227# CONFIG_INET_ESP is not set
228# CONFIG_INET_IPCOMP is not set
229# CONFIG_INET_TUNNEL is not set
230CONFIG_INET_DIAG=y
231CONFIG_INET_TCP_DIAG=y
232# CONFIG_TCP_CONG_ADVANCED is not set
233CONFIG_TCP_CONG_BIC=y
234# CONFIG_IPV6 is not set
235# CONFIG_NETFILTER is not set
236
237#
238# DCCP Configuration (EXPERIMENTAL)
239#
240# CONFIG_IP_DCCP is not set
241
242#
243# SCTP Configuration (EXPERIMENTAL)
244#
245# CONFIG_IP_SCTP is not set
246# CONFIG_ATM is not set
247# CONFIG_BRIDGE is not set
248# CONFIG_VLAN_8021Q is not set
249# CONFIG_DECNET is not set
250# CONFIG_LLC2 is not set
251# CONFIG_IPX is not set
252# CONFIG_ATALK is not set
253# CONFIG_X25 is not set
254# CONFIG_LAPB is not set
255# CONFIG_NET_DIVERT is not set
256# CONFIG_ECONET is not set
257# CONFIG_WAN_ROUTER is not set
258
259#
260# QoS and/or fair queueing
261#
262# CONFIG_NET_SCHED is not set
263# CONFIG_NET_CLS_ROUTE is not set
264
265#
266# Network testing
267#
268# CONFIG_NET_PKTGEN is not set
269# CONFIG_HAMRADIO is not set
270# CONFIG_IRDA is not set
271# CONFIG_BT is not set
272# CONFIG_IEEE80211 is not set
273
274#
275# Device Drivers
276#
277
278#
279# Generic Driver Options
280#
281CONFIG_STANDALONE=y
282# CONFIG_PREVENT_FIRMWARE_BUILD is not set
283# CONFIG_FW_LOADER is not set
284# CONFIG_DEBUG_DRIVER is not set
285
286#
287# Memory Technology Devices (MTD)
288#
289CONFIG_MTD=y
290# CONFIG_MTD_DEBUG is not set
291# CONFIG_MTD_CONCAT is not set
292CONFIG_MTD_PARTITIONS=y
293CONFIG_MTD_REDBOOT_PARTS=y
294CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
295CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
296CONFIG_MTD_REDBOOT_PARTS_READONLY=y
297# CONFIG_MTD_CMDLINE_PARTS is not set
298# CONFIG_MTD_AFS_PARTS is not set
299
300#
301# User Modules And Translation Layers
302#
303CONFIG_MTD_CHAR=y
304CONFIG_MTD_BLOCK=y
305# CONFIG_FTL is not set
306# CONFIG_NFTL is not set
307# CONFIG_INFTL is not set
308# CONFIG_RFD_FTL is not set
309
310#
311# RAM/ROM/Flash chip drivers
312#
313CONFIG_MTD_CFI=y
314# CONFIG_MTD_JEDECPROBE is not set
315CONFIG_MTD_GEN_PROBE=y
316# CONFIG_MTD_CFI_ADV_OPTIONS is not set
317CONFIG_MTD_MAP_BANK_WIDTH_1=y
318CONFIG_MTD_MAP_BANK_WIDTH_2=y
319CONFIG_MTD_MAP_BANK_WIDTH_4=y
320# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
321# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
322# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
323CONFIG_MTD_CFI_I1=y
324CONFIG_MTD_CFI_I2=y
325# CONFIG_MTD_CFI_I4 is not set
326# CONFIG_MTD_CFI_I8 is not set
327CONFIG_MTD_CFI_INTELEXT=y
328# CONFIG_MTD_CFI_AMDSTD is not set
329# CONFIG_MTD_CFI_STAA is not set
330CONFIG_MTD_CFI_UTIL=y
331# CONFIG_MTD_RAM is not set
332# CONFIG_MTD_ROM is not set
333# CONFIG_MTD_ABSENT is not set
334# CONFIG_MTD_XIP is not set
335
336#
337# Mapping drivers for chip access
338#
339CONFIG_MTD_COMPLEX_MAPPINGS=y
340# CONFIG_MTD_PHYSMAP is not set
341# CONFIG_MTD_ARM_INTEGRATOR is not set
342CONFIG_MTD_IXP2000=y
343# CONFIG_MTD_PCI is not set
344# CONFIG_MTD_PLATRAM is not set
345
346#
347# Self-contained MTD device drivers
348#
349# CONFIG_MTD_PMC551 is not set
350# CONFIG_MTD_SLRAM is not set
351# CONFIG_MTD_PHRAM is not set
352# CONFIG_MTD_MTDRAM is not set
353# CONFIG_MTD_BLKMTD is not set
354# CONFIG_MTD_BLOCK2MTD is not set
355
356#
357# Disk-On-Chip Device Drivers
358#
359# CONFIG_MTD_DOC2000 is not set
360# CONFIG_MTD_DOC2001 is not set
361# CONFIG_MTD_DOC2001PLUS is not set
362
363#
364# NAND Flash Device Drivers
365#
366# CONFIG_MTD_NAND is not set
367
368#
369# OneNAND Flash Device Drivers
370#
371# CONFIG_MTD_ONENAND is not set
372
373#
374# Parallel port support
375#
376# CONFIG_PARPORT is not set
377
378#
379# Plug and Play support
380#
381
382#
383# Block devices
384#
385# CONFIG_BLK_CPQ_DA is not set
386# CONFIG_BLK_CPQ_CISS_DA is not set
387# CONFIG_BLK_DEV_DAC960 is not set
388# CONFIG_BLK_DEV_UMEM is not set
389# CONFIG_BLK_DEV_COW_COMMON is not set
390CONFIG_BLK_DEV_LOOP=y
391# CONFIG_BLK_DEV_CRYPTOLOOP is not set
392# CONFIG_BLK_DEV_NBD is not set
393# CONFIG_BLK_DEV_SX8 is not set
394CONFIG_BLK_DEV_RAM=y
395CONFIG_BLK_DEV_RAM_COUNT=16
396CONFIG_BLK_DEV_RAM_SIZE=8192
397CONFIG_BLK_DEV_INITRD=y
398# CONFIG_CDROM_PKTCDVD is not set
399# CONFIG_ATA_OVER_ETH is not set
400
401#
402# SCSI device support
403#
404# CONFIG_RAID_ATTRS is not set
405# CONFIG_SCSI is not set
406
407#
408# Multi-device support (RAID and LVM)
409#
410# CONFIG_MD is not set
411
412#
413# Fusion MPT device support
414#
415# CONFIG_FUSION is not set
416
417#
418# IEEE 1394 (FireWire) support
419#
420# CONFIG_IEEE1394 is not set
421
422#
423# I2O device support
424#
425# CONFIG_I2O is not set
426
427#
428# Network device support
429#
430CONFIG_NETDEVICES=y
431CONFIG_DUMMY=y
432# CONFIG_BONDING is not set
433# CONFIG_EQUALIZER is not set
434# CONFIG_TUN is not set
435
436#
437# ARCnet devices
438#
439# CONFIG_ARCNET is not set
440
441#
442# PHY device support
443#
444# CONFIG_PHYLIB is not set
445
446#
447# Ethernet (10 or 100Mbit)
448#
449CONFIG_NET_ETHERNET=y
450CONFIG_MII=y
451# CONFIG_HAPPYMEAL is not set
452# CONFIG_SUNGEM is not set
453# CONFIG_CASSINI is not set
454# CONFIG_NET_VENDOR_3COM is not set
455# CONFIG_SMC91X is not set
456# CONFIG_DM9000 is not set
457
458#
459# Tulip family network device support
460#
461# CONFIG_NET_TULIP is not set
462# CONFIG_HP100 is not set
463CONFIG_NET_PCI=y
464# CONFIG_PCNET32 is not set
465# CONFIG_AMD8111_ETH is not set
466# CONFIG_ADAPTEC_STARFIRE is not set
467# CONFIG_B44 is not set
468# CONFIG_FORCEDETH is not set
469CONFIG_CS89x0=y
470# CONFIG_DGRS is not set
471CONFIG_EEPRO100=y
472# CONFIG_E100 is not set
473# CONFIG_FEALNX is not set
474# CONFIG_NATSEMI is not set
475# CONFIG_NE2K_PCI is not set
476# CONFIG_8139CP is not set
477# CONFIG_8139TOO is not set
478# CONFIG_SIS900 is not set
479# CONFIG_EPIC100 is not set
480# CONFIG_SUNDANCE is not set
481# CONFIG_TLAN is not set
482# CONFIG_VIA_RHINE is not set
483
484#
485# Ethernet (1000 Mbit)
486#
487# CONFIG_ACENIC is not set
488# CONFIG_DL2K is not set
489# CONFIG_E1000 is not set
490# CONFIG_NS83820 is not set
491# CONFIG_HAMACHI is not set
492# CONFIG_YELLOWFIN is not set
493# CONFIG_R8169 is not set
494# CONFIG_SIS190 is not set
495# CONFIG_SKGE is not set
496# CONFIG_SK98LIN is not set
497# CONFIG_VIA_VELOCITY is not set
498# CONFIG_TIGON3 is not set
499# CONFIG_BNX2 is not set
500
501#
502# Ethernet (10000 Mbit)
503#
504# CONFIG_CHELSIO_T1 is not set
505# CONFIG_IXGB is not set
506# CONFIG_S2IO is not set
507
508#
509# Token Ring devices
510#
511# CONFIG_TR is not set
512
513#
514# Wireless LAN (non-hamradio)
515#
516# CONFIG_NET_RADIO is not set
517
518#
519# Wan interfaces
520#
521CONFIG_WAN=y
522# CONFIG_DSCC4 is not set
523# CONFIG_LANMEDIA is not set
524# CONFIG_SYNCLINK_SYNCPPP is not set
525CONFIG_HDLC=y
526CONFIG_HDLC_RAW=y
527# CONFIG_HDLC_RAW_ETH is not set
528CONFIG_HDLC_CISCO=y
529CONFIG_HDLC_FR=y
530CONFIG_HDLC_PPP=y
531
532#
533# X.25/LAPB support is disabled
534#
535# CONFIG_PCI200SYN is not set
536# CONFIG_WANXL is not set
537# CONFIG_PC300 is not set
538# CONFIG_FARSYNC is not set
539CONFIG_DLCI=y
540CONFIG_DLCI_COUNT=24
541CONFIG_DLCI_MAX=8
542# CONFIG_FDDI is not set
543# CONFIG_HIPPI is not set
544# CONFIG_PPP is not set
545# CONFIG_SLIP is not set
546# CONFIG_SHAPER is not set
547# CONFIG_NETCONSOLE is not set
548# CONFIG_NETPOLL is not set
549# CONFIG_NET_POLL_CONTROLLER is not set
550
551#
552# ISDN subsystem
553#
554# CONFIG_ISDN is not set
555
556#
557# Input device support
558#
559CONFIG_INPUT=y
560
561#
562# Userland interfaces
563#
564CONFIG_INPUT_MOUSEDEV=y
565CONFIG_INPUT_MOUSEDEV_PSAUX=y
566CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
567CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
568# CONFIG_INPUT_JOYDEV is not set
569# CONFIG_INPUT_TSDEV is not set
570# CONFIG_INPUT_EVDEV is not set
571# CONFIG_INPUT_EVBUG is not set
572
573#
574# Input Device Drivers
575#
576# CONFIG_INPUT_KEYBOARD is not set
577# CONFIG_INPUT_MOUSE is not set
578# CONFIG_INPUT_JOYSTICK is not set
579# CONFIG_INPUT_TOUCHSCREEN is not set
580# CONFIG_INPUT_MISC is not set
581
582#
583# Hardware I/O ports
584#
585# CONFIG_SERIO is not set
586# CONFIG_GAMEPORT is not set
587
588#
589# Character devices
590#
591# CONFIG_VT is not set
592# CONFIG_SERIAL_NONSTANDARD is not set
593
594#
595# Serial drivers
596#
597CONFIG_SERIAL_8250=y
598CONFIG_SERIAL_8250_CONSOLE=y
599CONFIG_SERIAL_8250_NR_UARTS=3
600# CONFIG_SERIAL_8250_EXTENDED is not set
601
602#
603# Non-8250 serial port support
604#
605CONFIG_SERIAL_CORE=y
606CONFIG_SERIAL_CORE_CONSOLE=y
607# CONFIG_SERIAL_JSM is not set
608CONFIG_UNIX98_PTYS=y
609CONFIG_LEGACY_PTYS=y
610CONFIG_LEGACY_PTY_COUNT=256
611
612#
613# IPMI
614#
615# CONFIG_IPMI_HANDLER is not set
616
617#
618# Watchdog Cards
619#
620CONFIG_WATCHDOG=y
621# CONFIG_WATCHDOG_NOWAYOUT is not set
622
623#
624# Watchdog Device Drivers
625#
626# CONFIG_SOFT_WATCHDOG is not set
627CONFIG_IXP2000_WATCHDOG=y
628
629#
630# PCI-based Watchdog Cards
631#
632# CONFIG_PCIPCWATCHDOG is not set
633# CONFIG_WDTPCI is not set
634# CONFIG_NVRAM is not set
635# CONFIG_RTC is not set
636# CONFIG_DTLK is not set
637# CONFIG_R3964 is not set
638# CONFIG_APPLICOM is not set
639
640#
641# Ftape, the floppy tape device driver
642#
643# CONFIG_DRM is not set
644# CONFIG_RAW_DRIVER is not set
645
646#
647# TPM devices
648#
649# CONFIG_TCG_TPM is not set
650# CONFIG_TELCLOCK is not set
651
652#
653# I2C support
654#
655CONFIG_I2C=y
656CONFIG_I2C_CHARDEV=y
657
658#
659# I2C Algorithms
660#
661CONFIG_I2C_ALGOBIT=y
662# CONFIG_I2C_ALGOPCF is not set
663# CONFIG_I2C_ALGOPCA is not set
664
665#
666# I2C Hardware Bus support
667#
668# CONFIG_I2C_ALI1535 is not set
669# CONFIG_I2C_ALI1563 is not set
670# CONFIG_I2C_ALI15X3 is not set
671# CONFIG_I2C_AMD756 is not set
672# CONFIG_I2C_AMD8111 is not set
673# CONFIG_I2C_I801 is not set
674# CONFIG_I2C_I810 is not set
675# CONFIG_I2C_PIIX4 is not set
676CONFIG_I2C_IXP2000=y
677# CONFIG_I2C_NFORCE2 is not set
678# CONFIG_I2C_PARPORT_LIGHT is not set
679# CONFIG_I2C_PROSAVAGE is not set
680# CONFIG_I2C_SAVAGE4 is not set
681# CONFIG_SCx200_ACB is not set
682# CONFIG_I2C_SIS5595 is not set
683# CONFIG_I2C_SIS630 is not set
684# CONFIG_I2C_SIS96X is not set
685# CONFIG_I2C_STUB is not set
686# CONFIG_I2C_VIA is not set
687# CONFIG_I2C_VIAPRO is not set
688# CONFIG_I2C_VOODOO3 is not set
689# CONFIG_I2C_PCA_ISA is not set
690
691#
692# Miscellaneous I2C Chip support
693#
694# CONFIG_SENSORS_DS1337 is not set
695# CONFIG_SENSORS_DS1374 is not set
696CONFIG_SENSORS_EEPROM=y
697# CONFIG_SENSORS_PCF8574 is not set
698# CONFIG_SENSORS_PCA9539 is not set
699# CONFIG_SENSORS_PCF8591 is not set
700# CONFIG_SENSORS_RTC8564 is not set
701# CONFIG_SENSORS_MAX6875 is not set
702# CONFIG_RTC_X1205_I2C is not set
703# CONFIG_I2C_DEBUG_CORE is not set
704# CONFIG_I2C_DEBUG_ALGO is not set
705# CONFIG_I2C_DEBUG_BUS is not set
706# CONFIG_I2C_DEBUG_CHIP is not set
707
708#
709# Hardware Monitoring support
710#
711CONFIG_HWMON=y
712# CONFIG_HWMON_VID is not set
713# CONFIG_SENSORS_ADM1021 is not set
714# CONFIG_SENSORS_ADM1025 is not set
715# CONFIG_SENSORS_ADM1026 is not set
716# CONFIG_SENSORS_ADM1031 is not set
717# CONFIG_SENSORS_ADM9240 is not set
718# CONFIG_SENSORS_ASB100 is not set
719# CONFIG_SENSORS_ATXP1 is not set
720# CONFIG_SENSORS_DS1621 is not set
721# CONFIG_SENSORS_FSCHER is not set
722# CONFIG_SENSORS_FSCPOS is not set
723# CONFIG_SENSORS_GL518SM is not set
724# CONFIG_SENSORS_GL520SM is not set
725# CONFIG_SENSORS_IT87 is not set
726# CONFIG_SENSORS_LM63 is not set
727# CONFIG_SENSORS_LM75 is not set
728# CONFIG_SENSORS_LM77 is not set
729# CONFIG_SENSORS_LM78 is not set
730# CONFIG_SENSORS_LM80 is not set
731# CONFIG_SENSORS_LM83 is not set
732# CONFIG_SENSORS_LM85 is not set
733# CONFIG_SENSORS_LM87 is not set
734# CONFIG_SENSORS_LM90 is not set
735# CONFIG_SENSORS_LM92 is not set
736# CONFIG_SENSORS_MAX1619 is not set
737# CONFIG_SENSORS_PC87360 is not set
738# CONFIG_SENSORS_SIS5595 is not set
739# CONFIG_SENSORS_SMSC47M1 is not set
740# CONFIG_SENSORS_SMSC47B397 is not set
741# CONFIG_SENSORS_VIA686A is not set
742# CONFIG_SENSORS_W83781D is not set
743# CONFIG_SENSORS_W83792D is not set
744# CONFIG_SENSORS_W83L785TS is not set
745# CONFIG_SENSORS_W83627HF is not set
746# CONFIG_SENSORS_W83627EHF is not set
747# CONFIG_HWMON_DEBUG_CHIP is not set
748
749#
750# Misc devices
751#
752
753#
754# Multimedia Capabilities Port drivers
755#
756
757#
758# Multimedia devices
759#
760# CONFIG_VIDEO_DEV is not set
761
762#
763# Digital Video Broadcasting Devices
764#
765# CONFIG_DVB is not set
766
767#
768# Graphics support
769#
770# CONFIG_FB is not set
771
772#
773# Sound
774#
775# CONFIG_SOUND is not set
776
777#
778# USB support
779#
780CONFIG_USB_ARCH_HAS_HCD=y
781CONFIG_USB_ARCH_HAS_OHCI=y
782# CONFIG_USB is not set
783
784#
785# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
786#
787
788#
789# USB Gadget Support
790#
791# CONFIG_USB_GADGET is not set
792
793#
794# MMC/SD Card support
795#
796# CONFIG_MMC is not set
797
798#
799# File systems
800#
801CONFIG_EXT2_FS=y
802CONFIG_EXT2_FS_XATTR=y
803CONFIG_EXT2_FS_POSIX_ACL=y
804# CONFIG_EXT2_FS_SECURITY is not set
805# CONFIG_EXT2_FS_XIP is not set
806CONFIG_EXT3_FS=y
807CONFIG_EXT3_FS_XATTR=y
808CONFIG_EXT3_FS_POSIX_ACL=y
809# CONFIG_EXT3_FS_SECURITY is not set
810CONFIG_JBD=y
811# CONFIG_JBD_DEBUG is not set
812CONFIG_FS_MBCACHE=y
813# CONFIG_REISERFS_FS is not set
814# CONFIG_JFS_FS is not set
815CONFIG_FS_POSIX_ACL=y
816# CONFIG_XFS_FS is not set
817# CONFIG_MINIX_FS is not set
818# CONFIG_ROMFS_FS is not set
819CONFIG_INOTIFY=y
820# CONFIG_QUOTA is not set
821CONFIG_DNOTIFY=y
822# CONFIG_AUTOFS_FS is not set
823# CONFIG_AUTOFS4_FS is not set
824# CONFIG_FUSE_FS is not set
825
826#
827# CD-ROM/DVD Filesystems
828#
829# CONFIG_ISO9660_FS is not set
830# CONFIG_UDF_FS is not set
831
832#
833# DOS/FAT/NT Filesystems
834#
835# CONFIG_MSDOS_FS is not set
836# CONFIG_VFAT_FS is not set
837# CONFIG_NTFS_FS is not set
838
839#
840# Pseudo filesystems
841#
842CONFIG_PROC_FS=y
843CONFIG_SYSFS=y
844CONFIG_TMPFS=y
845# CONFIG_HUGETLB_PAGE is not set
846CONFIG_RAMFS=y
847# CONFIG_RELAYFS_FS is not set
848
849#
850# Miscellaneous filesystems
851#
852# CONFIG_ADFS_FS is not set
853# CONFIG_AFFS_FS is not set
854# CONFIG_HFS_FS is not set
855# CONFIG_HFSPLUS_FS is not set
856# CONFIG_BEFS_FS is not set
857# CONFIG_BFS_FS is not set
858# CONFIG_EFS_FS is not set
859# CONFIG_JFFS_FS is not set
860CONFIG_JFFS2_FS=y
861CONFIG_JFFS2_FS_DEBUG=0
862CONFIG_JFFS2_FS_WRITEBUFFER=y
863# CONFIG_JFFS2_SUMMARY is not set
864# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
865CONFIG_JFFS2_ZLIB=y
866CONFIG_JFFS2_RTIME=y
867# CONFIG_JFFS2_RUBIN is not set
868# CONFIG_CRAMFS is not set
869# CONFIG_VXFS_FS is not set
870# CONFIG_HPFS_FS is not set
871# CONFIG_QNX4FS_FS is not set
872# CONFIG_SYSV_FS is not set
873# CONFIG_UFS_FS is not set
874
875#
876# Network File Systems
877#
878CONFIG_NFS_FS=y
879CONFIG_NFS_V3=y
880# CONFIG_NFS_V3_ACL is not set
881# CONFIG_NFS_V4 is not set
882# CONFIG_NFS_DIRECTIO is not set
883# CONFIG_NFSD is not set
884CONFIG_ROOT_NFS=y
885CONFIG_LOCKD=y
886CONFIG_LOCKD_V4=y
887CONFIG_NFS_COMMON=y
888CONFIG_SUNRPC=y
889# CONFIG_RPCSEC_GSS_KRB5 is not set
890# CONFIG_RPCSEC_GSS_SPKM3 is not set
891# CONFIG_SMB_FS is not set
892# CONFIG_CIFS is not set
893# CONFIG_NCP_FS is not set
894# CONFIG_CODA_FS is not set
895# CONFIG_AFS_FS is not set
896# CONFIG_9P_FS is not set
897
898#
899# Partition Types
900#
901CONFIG_PARTITION_ADVANCED=y
902# CONFIG_ACORN_PARTITION is not set
903# CONFIG_OSF_PARTITION is not set
904# CONFIG_AMIGA_PARTITION is not set
905# CONFIG_ATARI_PARTITION is not set
906# CONFIG_MAC_PARTITION is not set
907CONFIG_MSDOS_PARTITION=y
908# CONFIG_BSD_DISKLABEL is not set
909# CONFIG_MINIX_SUBPARTITION is not set
910# CONFIG_SOLARIS_X86_PARTITION is not set
911# CONFIG_UNIXWARE_DISKLABEL is not set
912# CONFIG_LDM_PARTITION is not set
913# CONFIG_SGI_PARTITION is not set
914# CONFIG_ULTRIX_PARTITION is not set
915# CONFIG_SUN_PARTITION is not set
916# CONFIG_EFI_PARTITION is not set
917
918#
919# Native Language Support
920#
921# CONFIG_NLS is not set
922
923#
924# Profiling support
925#
926# CONFIG_PROFILING is not set
927
928#
929# Kernel hacking
930#
931# CONFIG_PRINTK_TIME is not set
932CONFIG_DEBUG_KERNEL=y
933CONFIG_MAGIC_SYSRQ=y
934CONFIG_LOG_BUF_SHIFT=14
935CONFIG_DETECT_SOFTLOCKUP=y
936# CONFIG_SCHEDSTATS is not set
937# CONFIG_DEBUG_SLAB is not set
938# CONFIG_DEBUG_SPINLOCK is not set
939# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
940# CONFIG_DEBUG_KOBJECT is not set
941CONFIG_DEBUG_BUGVERBOSE=y
942# CONFIG_DEBUG_INFO is not set
943# CONFIG_DEBUG_FS is not set
944# CONFIG_DEBUG_VM is not set
945CONFIG_FRAME_POINTER=y
946# CONFIG_RCU_TORTURE_TEST is not set
947CONFIG_DEBUG_USER=y
948# CONFIG_DEBUG_WAITQ is not set
949CONFIG_DEBUG_ERRORS=y
950CONFIG_DEBUG_LL=y
951# CONFIG_DEBUG_ICEDCC is not set
952
953#
954# Security options
955#
956# CONFIG_KEYS is not set
957# CONFIG_SECURITY is not set
958
959#
960# Cryptographic options
961#
962# CONFIG_CRYPTO is not set
963
964#
965# Hardware crypto devices
966#
967
968#
969# Library routines
970#
971# CONFIG_CRC_CCITT is not set
972# CONFIG_CRC16 is not set
973CONFIG_CRC32=y
974# CONFIG_LIBCRC32C is not set
975CONFIG_ZLIB_INFLATE=y
976CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2800_defconfig b/arch/arm/configs/ixdp2800_defconfig
deleted file mode 100644
index 4248123815e9..000000000000
--- a/arch/arm/configs/ixdp2800_defconfig
+++ /dev/null
@@ -1,975 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-git13
4# Thu Nov 10 15:14:56 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
19
20#
21# General setup
22#
23CONFIG_LOCALVERSION=""
24CONFIG_LOCALVERSION_AUTO=y
25CONFIG_SWAP=y
26CONFIG_SYSVIPC=y
27# CONFIG_POSIX_MQUEUE is not set
28CONFIG_BSD_PROCESS_ACCT=y
29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set
32# CONFIG_HOTPLUG is not set
33CONFIG_KOBJECT_UEVENT=y
34# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE=""
36CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set
39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_PRINTK=y
41CONFIG_BUG=y
42CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y
44CONFIG_EPOLL=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SHMEM=y
47CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0
49CONFIG_CC_ALIGN_LOOPS=0
50CONFIG_CC_ALIGN_JUMPS=0
51# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0
53
54#
55# Loadable module support
56#
57CONFIG_MODULES=y
58CONFIG_MODULE_UNLOAD=y
59# CONFIG_MODULE_FORCE_UNLOAD is not set
60CONFIG_OBSOLETE_MODPARM=y
61# CONFIG_MODVERSIONS is not set
62# CONFIG_MODULE_SRCVERSION_ALL is not set
63CONFIG_KMOD=y
64
65#
66# Block layer
67#
68
69#
70# IO Schedulers
71#
72CONFIG_IOSCHED_NOOP=y
73CONFIG_IOSCHED_AS=y
74CONFIG_IOSCHED_DEADLINE=y
75CONFIG_IOSCHED_CFQ=y
76CONFIG_DEFAULT_AS=y
77# CONFIG_DEFAULT_DEADLINE is not set
78# CONFIG_DEFAULT_CFQ is not set
79# CONFIG_DEFAULT_NOOP is not set
80CONFIG_DEFAULT_IOSCHED="anticipatory"
81
82#
83# System Type
84#
85# CONFIG_ARCH_CLPS7500 is not set
86# CONFIG_ARCH_CLPS711X is not set
87# CONFIG_ARCH_CO285 is not set
88# CONFIG_ARCH_EBSA110 is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set
92# CONFIG_ARCH_IXP4XX is not set
93CONFIG_ARCH_IXP2000=y
94# CONFIG_ARCH_L7200 is not set
95# CONFIG_ARCH_PXA is not set
96# CONFIG_ARCH_RPC is not set
97# CONFIG_ARCH_SA1100 is not set
98# CONFIG_ARCH_S3C2410 is not set
99# CONFIG_ARCH_SHARK is not set
100# CONFIG_ARCH_LH7A40X is not set
101# CONFIG_ARCH_OMAP is not set
102# CONFIG_ARCH_VERSATILE is not set
103# CONFIG_ARCH_REALVIEW is not set
104# CONFIG_ARCH_IMX is not set
105# CONFIG_ARCH_H720X is not set
106# CONFIG_ARCH_AAEC2000 is not set
107CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
108
109#
110# Intel IXP2400/2800 Implementation Options
111#
112
113#
114# IXP2400/2800 Platforms
115#
116# CONFIG_ARCH_ENP2611 is not set
117# CONFIG_ARCH_IXDP2400 is not set
118CONFIG_ARCH_IXDP2800=y
119CONFIG_ARCH_IXDP2X00=y
120# CONFIG_ARCH_IXDP2401 is not set
121# CONFIG_ARCH_IXDP2801 is not set
122# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
123
124#
125# Processor Type
126#
127CONFIG_CPU_32=y
128CONFIG_CPU_XSCALE=y
129CONFIG_CPU_32v5=y
130CONFIG_CPU_ABRT_EV5T=y
131CONFIG_CPU_CACHE_VIVT=y
132CONFIG_CPU_TLB_V4WBI=y
133
134#
135# Processor Features
136#
137# CONFIG_ARM_THUMB is not set
138CONFIG_CPU_BIG_ENDIAN=y
139CONFIG_XSCALE_PMU=y
140
141#
142# Bus support
143#
144CONFIG_ISA_DMA_API=y
145CONFIG_PCI=y
146CONFIG_PCI_LEGACY_PROC=y
147# CONFIG_PCI_DEBUG is not set
148
149#
150# PCCARD (PCMCIA/CardBus) support
151#
152# CONFIG_PCCARD is not set
153
154#
155# Kernel Features
156#
157# CONFIG_PREEMPT is not set
158# CONFIG_NO_IDLE_HZ is not set
159# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
160CONFIG_SELECT_MEMORY_MODEL=y
161CONFIG_FLATMEM_MANUAL=y
162# CONFIG_DISCONTIGMEM_MANUAL is not set
163# CONFIG_SPARSEMEM_MANUAL is not set
164CONFIG_FLATMEM=y
165CONFIG_FLAT_NODE_MEM_MAP=y
166# CONFIG_SPARSEMEM_STATIC is not set
167CONFIG_SPLIT_PTLOCK_CPUS=4096
168CONFIG_ALIGNMENT_TRAP=y
169
170#
171# Boot options
172#
173CONFIG_ZBOOT_ROM_TEXT=0x0
174CONFIG_ZBOOT_ROM_BSS=0x0
175CONFIG_CMDLINE="console=ttyS0,9600 root=/dev/nfs ip=bootp mem=64M@0x0"
176# CONFIG_XIP_KERNEL is not set
177
178#
179# Floating point emulation
180#
181
182#
183# At least one emulation must be selected
184#
185CONFIG_FPE_NWFPE=y
186CONFIG_FPE_NWFPE_XP=y
187# CONFIG_FPE_FASTFPE is not set
188
189#
190# Userspace binary formats
191#
192CONFIG_BINFMT_ELF=y
193# CONFIG_BINFMT_AOUT is not set
194# CONFIG_BINFMT_MISC is not set
195# CONFIG_ARTHUR is not set
196
197#
198# Power management options
199#
200# CONFIG_PM is not set
201
202#
203# Networking
204#
205CONFIG_NET=y
206
207#
208# Networking options
209#
210CONFIG_PACKET=y
211CONFIG_PACKET_MMAP=y
212CONFIG_UNIX=y
213# CONFIG_NET_KEY is not set
214CONFIG_INET=y
215# CONFIG_IP_MULTICAST is not set
216# CONFIG_IP_ADVANCED_ROUTER is not set
217CONFIG_IP_FIB_HASH=y
218CONFIG_IP_PNP=y
219CONFIG_IP_PNP_DHCP=y
220CONFIG_IP_PNP_BOOTP=y
221# CONFIG_IP_PNP_RARP is not set
222# CONFIG_NET_IPIP is not set
223# CONFIG_NET_IPGRE is not set
224# CONFIG_ARPD is not set
225CONFIG_SYN_COOKIES=y
226# CONFIG_INET_AH is not set
227# CONFIG_INET_ESP is not set
228# CONFIG_INET_IPCOMP is not set
229# CONFIG_INET_TUNNEL is not set
230CONFIG_INET_DIAG=y
231CONFIG_INET_TCP_DIAG=y
232# CONFIG_TCP_CONG_ADVANCED is not set
233CONFIG_TCP_CONG_BIC=y
234# CONFIG_IPV6 is not set
235# CONFIG_NETFILTER is not set
236
237#
238# DCCP Configuration (EXPERIMENTAL)
239#
240# CONFIG_IP_DCCP is not set
241
242#
243# SCTP Configuration (EXPERIMENTAL)
244#
245# CONFIG_IP_SCTP is not set
246# CONFIG_ATM is not set
247# CONFIG_BRIDGE is not set
248# CONFIG_VLAN_8021Q is not set
249# CONFIG_DECNET is not set
250# CONFIG_LLC2 is not set
251# CONFIG_IPX is not set
252# CONFIG_ATALK is not set
253# CONFIG_X25 is not set
254# CONFIG_LAPB is not set
255# CONFIG_NET_DIVERT is not set
256# CONFIG_ECONET is not set
257# CONFIG_WAN_ROUTER is not set
258
259#
260# QoS and/or fair queueing
261#
262# CONFIG_NET_SCHED is not set
263# CONFIG_NET_CLS_ROUTE is not set
264
265#
266# Network testing
267#
268# CONFIG_NET_PKTGEN is not set
269# CONFIG_HAMRADIO is not set
270# CONFIG_IRDA is not set
271# CONFIG_BT is not set
272# CONFIG_IEEE80211 is not set
273
274#
275# Device Drivers
276#
277
278#
279# Generic Driver Options
280#
281CONFIG_STANDALONE=y
282# CONFIG_PREVENT_FIRMWARE_BUILD is not set
283# CONFIG_FW_LOADER is not set
284# CONFIG_DEBUG_DRIVER is not set
285
286#
287# Memory Technology Devices (MTD)
288#
289CONFIG_MTD=y
290# CONFIG_MTD_DEBUG is not set
291# CONFIG_MTD_CONCAT is not set
292CONFIG_MTD_PARTITIONS=y
293CONFIG_MTD_REDBOOT_PARTS=y
294CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
295CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
296CONFIG_MTD_REDBOOT_PARTS_READONLY=y
297# CONFIG_MTD_CMDLINE_PARTS is not set
298# CONFIG_MTD_AFS_PARTS is not set
299
300#
301# User Modules And Translation Layers
302#
303CONFIG_MTD_CHAR=y
304CONFIG_MTD_BLOCK=y
305# CONFIG_FTL is not set
306# CONFIG_NFTL is not set
307# CONFIG_INFTL is not set
308# CONFIG_RFD_FTL is not set
309
310#
311# RAM/ROM/Flash chip drivers
312#
313CONFIG_MTD_CFI=y
314# CONFIG_MTD_JEDECPROBE is not set
315CONFIG_MTD_GEN_PROBE=y
316# CONFIG_MTD_CFI_ADV_OPTIONS is not set
317CONFIG_MTD_MAP_BANK_WIDTH_1=y
318CONFIG_MTD_MAP_BANK_WIDTH_2=y
319CONFIG_MTD_MAP_BANK_WIDTH_4=y
320# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
321# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
322# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
323CONFIG_MTD_CFI_I1=y
324CONFIG_MTD_CFI_I2=y
325# CONFIG_MTD_CFI_I4 is not set
326# CONFIG_MTD_CFI_I8 is not set
327CONFIG_MTD_CFI_INTELEXT=y
328# CONFIG_MTD_CFI_AMDSTD is not set
329# CONFIG_MTD_CFI_STAA is not set
330CONFIG_MTD_CFI_UTIL=y
331# CONFIG_MTD_RAM is not set
332# CONFIG_MTD_ROM is not set
333# CONFIG_MTD_ABSENT is not set
334# CONFIG_MTD_XIP is not set
335
336#
337# Mapping drivers for chip access
338#
339CONFIG_MTD_COMPLEX_MAPPINGS=y
340# CONFIG_MTD_PHYSMAP is not set
341# CONFIG_MTD_ARM_INTEGRATOR is not set
342CONFIG_MTD_IXP2000=y
343# CONFIG_MTD_PCI is not set
344# CONFIG_MTD_PLATRAM is not set
345
346#
347# Self-contained MTD device drivers
348#
349# CONFIG_MTD_PMC551 is not set
350# CONFIG_MTD_SLRAM is not set
351# CONFIG_MTD_PHRAM is not set
352# CONFIG_MTD_MTDRAM is not set
353# CONFIG_MTD_BLKMTD is not set
354# CONFIG_MTD_BLOCK2MTD is not set
355
356#
357# Disk-On-Chip Device Drivers
358#
359# CONFIG_MTD_DOC2000 is not set
360# CONFIG_MTD_DOC2001 is not set
361# CONFIG_MTD_DOC2001PLUS is not set
362
363#
364# NAND Flash Device Drivers
365#
366# CONFIG_MTD_NAND is not set
367
368#
369# OneNAND Flash Device Drivers
370#
371# CONFIG_MTD_ONENAND is not set
372
373#
374# Parallel port support
375#
376# CONFIG_PARPORT is not set
377
378#
379# Plug and Play support
380#
381
382#
383# Block devices
384#
385# CONFIG_BLK_CPQ_DA is not set
386# CONFIG_BLK_CPQ_CISS_DA is not set
387# CONFIG_BLK_DEV_DAC960 is not set
388# CONFIG_BLK_DEV_UMEM is not set
389# CONFIG_BLK_DEV_COW_COMMON is not set
390CONFIG_BLK_DEV_LOOP=y
391# CONFIG_BLK_DEV_CRYPTOLOOP is not set
392# CONFIG_BLK_DEV_NBD is not set
393# CONFIG_BLK_DEV_SX8 is not set
394CONFIG_BLK_DEV_RAM=y
395CONFIG_BLK_DEV_RAM_COUNT=16
396CONFIG_BLK_DEV_RAM_SIZE=8192
397CONFIG_BLK_DEV_INITRD=y
398# CONFIG_CDROM_PKTCDVD is not set
399# CONFIG_ATA_OVER_ETH is not set
400
401#
402# SCSI device support
403#
404# CONFIG_RAID_ATTRS is not set
405# CONFIG_SCSI is not set
406
407#
408# Multi-device support (RAID and LVM)
409#
410# CONFIG_MD is not set
411
412#
413# Fusion MPT device support
414#
415# CONFIG_FUSION is not set
416
417#
418# IEEE 1394 (FireWire) support
419#
420# CONFIG_IEEE1394 is not set
421
422#
423# I2O device support
424#
425# CONFIG_I2O is not set
426
427#
428# Network device support
429#
430CONFIG_NETDEVICES=y
431CONFIG_DUMMY=y
432# CONFIG_BONDING is not set
433# CONFIG_EQUALIZER is not set
434# CONFIG_TUN is not set
435
436#
437# ARCnet devices
438#
439# CONFIG_ARCNET is not set
440
441#
442# PHY device support
443#
444# CONFIG_PHYLIB is not set
445
446#
447# Ethernet (10 or 100Mbit)
448#
449CONFIG_NET_ETHERNET=y
450CONFIG_MII=y
451# CONFIG_HAPPYMEAL is not set
452# CONFIG_SUNGEM is not set
453# CONFIG_CASSINI is not set
454# CONFIG_NET_VENDOR_3COM is not set
455# CONFIG_SMC91X is not set
456# CONFIG_DM9000 is not set
457
458#
459# Tulip family network device support
460#
461# CONFIG_NET_TULIP is not set
462# CONFIG_HP100 is not set
463CONFIG_NET_PCI=y
464# CONFIG_PCNET32 is not set
465# CONFIG_AMD8111_ETH is not set
466# CONFIG_ADAPTEC_STARFIRE is not set
467# CONFIG_B44 is not set
468# CONFIG_FORCEDETH is not set
469# CONFIG_DGRS is not set
470CONFIG_EEPRO100=y
471# CONFIG_E100 is not set
472# CONFIG_FEALNX is not set
473# CONFIG_NATSEMI is not set
474# CONFIG_NE2K_PCI is not set
475# CONFIG_8139CP is not set
476# CONFIG_8139TOO is not set
477# CONFIG_SIS900 is not set
478# CONFIG_EPIC100 is not set
479# CONFIG_SUNDANCE is not set
480# CONFIG_TLAN is not set
481# CONFIG_VIA_RHINE is not set
482
483#
484# Ethernet (1000 Mbit)
485#
486# CONFIG_ACENIC is not set
487# CONFIG_DL2K is not set
488# CONFIG_E1000 is not set
489# CONFIG_NS83820 is not set
490# CONFIG_HAMACHI is not set
491# CONFIG_YELLOWFIN is not set
492# CONFIG_R8169 is not set
493# CONFIG_SIS190 is not set
494# CONFIG_SKGE is not set
495# CONFIG_SK98LIN is not set
496# CONFIG_VIA_VELOCITY is not set
497# CONFIG_TIGON3 is not set
498# CONFIG_BNX2 is not set
499
500#
501# Ethernet (10000 Mbit)
502#
503# CONFIG_CHELSIO_T1 is not set
504# CONFIG_IXGB is not set
505# CONFIG_S2IO is not set
506
507#
508# Token Ring devices
509#
510# CONFIG_TR is not set
511
512#
513# Wireless LAN (non-hamradio)
514#
515# CONFIG_NET_RADIO is not set
516
517#
518# Wan interfaces
519#
520CONFIG_WAN=y
521# CONFIG_DSCC4 is not set
522# CONFIG_LANMEDIA is not set
523# CONFIG_SYNCLINK_SYNCPPP is not set
524CONFIG_HDLC=y
525CONFIG_HDLC_RAW=y
526# CONFIG_HDLC_RAW_ETH is not set
527CONFIG_HDLC_CISCO=y
528CONFIG_HDLC_FR=y
529CONFIG_HDLC_PPP=y
530
531#
532# X.25/LAPB support is disabled
533#
534# CONFIG_PCI200SYN is not set
535# CONFIG_WANXL is not set
536# CONFIG_PC300 is not set
537# CONFIG_FARSYNC is not set
538CONFIG_DLCI=y
539CONFIG_DLCI_COUNT=24
540CONFIG_DLCI_MAX=8
541# CONFIG_FDDI is not set
542# CONFIG_HIPPI is not set
543# CONFIG_PPP is not set
544# CONFIG_SLIP is not set
545# CONFIG_SHAPER is not set
546# CONFIG_NETCONSOLE is not set
547# CONFIG_NETPOLL is not set
548# CONFIG_NET_POLL_CONTROLLER is not set
549
550#
551# ISDN subsystem
552#
553# CONFIG_ISDN is not set
554
555#
556# Input device support
557#
558CONFIG_INPUT=y
559
560#
561# Userland interfaces
562#
563CONFIG_INPUT_MOUSEDEV=y
564CONFIG_INPUT_MOUSEDEV_PSAUX=y
565CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
566CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
567# CONFIG_INPUT_JOYDEV is not set
568# CONFIG_INPUT_TSDEV is not set
569# CONFIG_INPUT_EVDEV is not set
570# CONFIG_INPUT_EVBUG is not set
571
572#
573# Input Device Drivers
574#
575# CONFIG_INPUT_KEYBOARD is not set
576# CONFIG_INPUT_MOUSE is not set
577# CONFIG_INPUT_JOYSTICK is not set
578# CONFIG_INPUT_TOUCHSCREEN is not set
579# CONFIG_INPUT_MISC is not set
580
581#
582# Hardware I/O ports
583#
584# CONFIG_SERIO is not set
585# CONFIG_GAMEPORT is not set
586
587#
588# Character devices
589#
590# CONFIG_VT is not set
591# CONFIG_SERIAL_NONSTANDARD is not set
592
593#
594# Serial drivers
595#
596CONFIG_SERIAL_8250=y
597CONFIG_SERIAL_8250_CONSOLE=y
598CONFIG_SERIAL_8250_NR_UARTS=1
599# CONFIG_SERIAL_8250_EXTENDED is not set
600
601#
602# Non-8250 serial port support
603#
604CONFIG_SERIAL_CORE=y
605CONFIG_SERIAL_CORE_CONSOLE=y
606# CONFIG_SERIAL_JSM is not set
607CONFIG_UNIX98_PTYS=y
608CONFIG_LEGACY_PTYS=y
609CONFIG_LEGACY_PTY_COUNT=256
610
611#
612# IPMI
613#
614# CONFIG_IPMI_HANDLER is not set
615
616#
617# Watchdog Cards
618#
619CONFIG_WATCHDOG=y
620# CONFIG_WATCHDOG_NOWAYOUT is not set
621
622#
623# Watchdog Device Drivers
624#
625# CONFIG_SOFT_WATCHDOG is not set
626CONFIG_IXP2000_WATCHDOG=y
627
628#
629# PCI-based Watchdog Cards
630#
631# CONFIG_PCIPCWATCHDOG is not set
632# CONFIG_WDTPCI is not set
633# CONFIG_NVRAM is not set
634# CONFIG_RTC is not set
635# CONFIG_DTLK is not set
636# CONFIG_R3964 is not set
637# CONFIG_APPLICOM is not set
638
639#
640# Ftape, the floppy tape device driver
641#
642# CONFIG_DRM is not set
643# CONFIG_RAW_DRIVER is not set
644
645#
646# TPM devices
647#
648# CONFIG_TCG_TPM is not set
649# CONFIG_TELCLOCK is not set
650
651#
652# I2C support
653#
654CONFIG_I2C=y
655CONFIG_I2C_CHARDEV=y
656
657#
658# I2C Algorithms
659#
660CONFIG_I2C_ALGOBIT=y
661# CONFIG_I2C_ALGOPCF is not set
662# CONFIG_I2C_ALGOPCA is not set
663
664#
665# I2C Hardware Bus support
666#
667# CONFIG_I2C_ALI1535 is not set
668# CONFIG_I2C_ALI1563 is not set
669# CONFIG_I2C_ALI15X3 is not set
670# CONFIG_I2C_AMD756 is not set
671# CONFIG_I2C_AMD8111 is not set
672# CONFIG_I2C_I801 is not set
673# CONFIG_I2C_I810 is not set
674# CONFIG_I2C_PIIX4 is not set
675CONFIG_I2C_IXP2000=y
676# CONFIG_I2C_NFORCE2 is not set
677# CONFIG_I2C_PARPORT_LIGHT is not set
678# CONFIG_I2C_PROSAVAGE is not set
679# CONFIG_I2C_SAVAGE4 is not set
680# CONFIG_SCx200_ACB is not set
681# CONFIG_I2C_SIS5595 is not set
682# CONFIG_I2C_SIS630 is not set
683# CONFIG_I2C_SIS96X is not set
684# CONFIG_I2C_STUB is not set
685# CONFIG_I2C_VIA is not set
686# CONFIG_I2C_VIAPRO is not set
687# CONFIG_I2C_VOODOO3 is not set
688# CONFIG_I2C_PCA_ISA is not set
689
690#
691# Miscellaneous I2C Chip support
692#
693# CONFIG_SENSORS_DS1337 is not set
694# CONFIG_SENSORS_DS1374 is not set
695CONFIG_SENSORS_EEPROM=y
696# CONFIG_SENSORS_PCF8574 is not set
697# CONFIG_SENSORS_PCA9539 is not set
698# CONFIG_SENSORS_PCF8591 is not set
699# CONFIG_SENSORS_RTC8564 is not set
700# CONFIG_SENSORS_MAX6875 is not set
701# CONFIG_RTC_X1205_I2C is not set
702# CONFIG_I2C_DEBUG_CORE is not set
703# CONFIG_I2C_DEBUG_ALGO is not set
704# CONFIG_I2C_DEBUG_BUS is not set
705# CONFIG_I2C_DEBUG_CHIP is not set
706
707#
708# Hardware Monitoring support
709#
710CONFIG_HWMON=y
711# CONFIG_HWMON_VID is not set
712# CONFIG_SENSORS_ADM1021 is not set
713# CONFIG_SENSORS_ADM1025 is not set
714# CONFIG_SENSORS_ADM1026 is not set
715# CONFIG_SENSORS_ADM1031 is not set
716# CONFIG_SENSORS_ADM9240 is not set
717# CONFIG_SENSORS_ASB100 is not set
718# CONFIG_SENSORS_ATXP1 is not set
719# CONFIG_SENSORS_DS1621 is not set
720# CONFIG_SENSORS_FSCHER is not set
721# CONFIG_SENSORS_FSCPOS is not set
722# CONFIG_SENSORS_GL518SM is not set
723# CONFIG_SENSORS_GL520SM is not set
724# CONFIG_SENSORS_IT87 is not set
725# CONFIG_SENSORS_LM63 is not set
726# CONFIG_SENSORS_LM75 is not set
727# CONFIG_SENSORS_LM77 is not set
728# CONFIG_SENSORS_LM78 is not set
729# CONFIG_SENSORS_LM80 is not set
730# CONFIG_SENSORS_LM83 is not set
731# CONFIG_SENSORS_LM85 is not set
732# CONFIG_SENSORS_LM87 is not set
733# CONFIG_SENSORS_LM90 is not set
734# CONFIG_SENSORS_LM92 is not set
735# CONFIG_SENSORS_MAX1619 is not set
736# CONFIG_SENSORS_PC87360 is not set
737# CONFIG_SENSORS_SIS5595 is not set
738# CONFIG_SENSORS_SMSC47M1 is not set
739# CONFIG_SENSORS_SMSC47B397 is not set
740# CONFIG_SENSORS_VIA686A is not set
741# CONFIG_SENSORS_W83781D is not set
742# CONFIG_SENSORS_W83792D is not set
743# CONFIG_SENSORS_W83L785TS is not set
744# CONFIG_SENSORS_W83627HF is not set
745# CONFIG_SENSORS_W83627EHF is not set
746# CONFIG_HWMON_DEBUG_CHIP is not set
747
748#
749# Misc devices
750#
751
752#
753# Multimedia Capabilities Port drivers
754#
755
756#
757# Multimedia devices
758#
759# CONFIG_VIDEO_DEV is not set
760
761#
762# Digital Video Broadcasting Devices
763#
764# CONFIG_DVB is not set
765
766#
767# Graphics support
768#
769# CONFIG_FB is not set
770
771#
772# Sound
773#
774# CONFIG_SOUND is not set
775
776#
777# USB support
778#
779CONFIG_USB_ARCH_HAS_HCD=y
780CONFIG_USB_ARCH_HAS_OHCI=y
781# CONFIG_USB is not set
782
783#
784# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
785#
786
787#
788# USB Gadget Support
789#
790# CONFIG_USB_GADGET is not set
791
792#
793# MMC/SD Card support
794#
795# CONFIG_MMC is not set
796
797#
798# File systems
799#
800CONFIG_EXT2_FS=y
801CONFIG_EXT2_FS_XATTR=y
802CONFIG_EXT2_FS_POSIX_ACL=y
803# CONFIG_EXT2_FS_SECURITY is not set
804# CONFIG_EXT2_FS_XIP is not set
805CONFIG_EXT3_FS=y
806CONFIG_EXT3_FS_XATTR=y
807CONFIG_EXT3_FS_POSIX_ACL=y
808# CONFIG_EXT3_FS_SECURITY is not set
809CONFIG_JBD=y
810# CONFIG_JBD_DEBUG is not set
811CONFIG_FS_MBCACHE=y
812# CONFIG_REISERFS_FS is not set
813# CONFIG_JFS_FS is not set
814CONFIG_FS_POSIX_ACL=y
815# CONFIG_XFS_FS is not set
816# CONFIG_MINIX_FS is not set
817# CONFIG_ROMFS_FS is not set
818CONFIG_INOTIFY=y
819# CONFIG_QUOTA is not set
820CONFIG_DNOTIFY=y
821# CONFIG_AUTOFS_FS is not set
822# CONFIG_AUTOFS4_FS is not set
823# CONFIG_FUSE_FS is not set
824
825#
826# CD-ROM/DVD Filesystems
827#
828# CONFIG_ISO9660_FS is not set
829# CONFIG_UDF_FS is not set
830
831#
832# DOS/FAT/NT Filesystems
833#
834# CONFIG_MSDOS_FS is not set
835# CONFIG_VFAT_FS is not set
836# CONFIG_NTFS_FS is not set
837
838#
839# Pseudo filesystems
840#
841CONFIG_PROC_FS=y
842CONFIG_SYSFS=y
843CONFIG_TMPFS=y
844# CONFIG_HUGETLB_PAGE is not set
845CONFIG_RAMFS=y
846# CONFIG_RELAYFS_FS is not set
847
848#
849# Miscellaneous filesystems
850#
851# CONFIG_ADFS_FS is not set
852# CONFIG_AFFS_FS is not set
853# CONFIG_HFS_FS is not set
854# CONFIG_HFSPLUS_FS is not set
855# CONFIG_BEFS_FS is not set
856# CONFIG_BFS_FS is not set
857# CONFIG_EFS_FS is not set
858# CONFIG_JFFS_FS is not set
859CONFIG_JFFS2_FS=y
860CONFIG_JFFS2_FS_DEBUG=0
861CONFIG_JFFS2_FS_WRITEBUFFER=y
862# CONFIG_JFFS2_SUMMARY is not set
863# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
864CONFIG_JFFS2_ZLIB=y
865CONFIG_JFFS2_RTIME=y
866# CONFIG_JFFS2_RUBIN is not set
867# CONFIG_CRAMFS is not set
868# CONFIG_VXFS_FS is not set
869# CONFIG_HPFS_FS is not set
870# CONFIG_QNX4FS_FS is not set
871# CONFIG_SYSV_FS is not set
872# CONFIG_UFS_FS is not set
873
874#
875# Network File Systems
876#
877CONFIG_NFS_FS=y
878CONFIG_NFS_V3=y
879# CONFIG_NFS_V3_ACL is not set
880# CONFIG_NFS_V4 is not set
881# CONFIG_NFS_DIRECTIO is not set
882# CONFIG_NFSD is not set
883CONFIG_ROOT_NFS=y
884CONFIG_LOCKD=y
885CONFIG_LOCKD_V4=y
886CONFIG_NFS_COMMON=y
887CONFIG_SUNRPC=y
888# CONFIG_RPCSEC_GSS_KRB5 is not set
889# CONFIG_RPCSEC_GSS_SPKM3 is not set
890# CONFIG_SMB_FS is not set
891# CONFIG_CIFS is not set
892# CONFIG_NCP_FS is not set
893# CONFIG_CODA_FS is not set
894# CONFIG_AFS_FS is not set
895# CONFIG_9P_FS is not set
896
897#
898# Partition Types
899#
900CONFIG_PARTITION_ADVANCED=y
901# CONFIG_ACORN_PARTITION is not set
902# CONFIG_OSF_PARTITION is not set
903# CONFIG_AMIGA_PARTITION is not set
904# CONFIG_ATARI_PARTITION is not set
905# CONFIG_MAC_PARTITION is not set
906CONFIG_MSDOS_PARTITION=y
907# CONFIG_BSD_DISKLABEL is not set
908# CONFIG_MINIX_SUBPARTITION is not set
909# CONFIG_SOLARIS_X86_PARTITION is not set
910# CONFIG_UNIXWARE_DISKLABEL is not set
911# CONFIG_LDM_PARTITION is not set
912# CONFIG_SGI_PARTITION is not set
913# CONFIG_ULTRIX_PARTITION is not set
914# CONFIG_SUN_PARTITION is not set
915# CONFIG_EFI_PARTITION is not set
916
917#
918# Native Language Support
919#
920# CONFIG_NLS is not set
921
922#
923# Profiling support
924#
925# CONFIG_PROFILING is not set
926
927#
928# Kernel hacking
929#
930# CONFIG_PRINTK_TIME is not set
931CONFIG_DEBUG_KERNEL=y
932CONFIG_MAGIC_SYSRQ=y
933CONFIG_LOG_BUF_SHIFT=14
934CONFIG_DETECT_SOFTLOCKUP=y
935# CONFIG_SCHEDSTATS is not set
936# CONFIG_DEBUG_SLAB is not set
937# CONFIG_DEBUG_SPINLOCK is not set
938# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
939# CONFIG_DEBUG_KOBJECT is not set
940CONFIG_DEBUG_BUGVERBOSE=y
941# CONFIG_DEBUG_INFO is not set
942# CONFIG_DEBUG_FS is not set
943# CONFIG_DEBUG_VM is not set
944CONFIG_FRAME_POINTER=y
945# CONFIG_RCU_TORTURE_TEST is not set
946CONFIG_DEBUG_USER=y
947# CONFIG_DEBUG_WAITQ is not set
948CONFIG_DEBUG_ERRORS=y
949CONFIG_DEBUG_LL=y
950# CONFIG_DEBUG_ICEDCC is not set
951
952#
953# Security options
954#
955# CONFIG_KEYS is not set
956# CONFIG_SECURITY is not set
957
958#
959# Cryptographic options
960#
961# CONFIG_CRYPTO is not set
962
963#
964# Hardware crypto devices
965#
966
967#
968# Library routines
969#
970# CONFIG_CRC_CCITT is not set
971# CONFIG_CRC16 is not set
972CONFIG_CRC32=y
973# CONFIG_LIBCRC32C is not set
974CONFIG_ZLIB_INFLATE=y
975CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2801_defconfig b/arch/arm/configs/ixdp2801_defconfig
deleted file mode 100644
index f54f3dcc5b33..000000000000
--- a/arch/arm/configs/ixdp2801_defconfig
+++ /dev/null
@@ -1,976 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-git13
4# Thu Nov 10 15:15:03 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
19
20#
21# General setup
22#
23CONFIG_LOCALVERSION=""
24CONFIG_LOCALVERSION_AUTO=y
25CONFIG_SWAP=y
26CONFIG_SYSVIPC=y
27# CONFIG_POSIX_MQUEUE is not set
28CONFIG_BSD_PROCESS_ACCT=y
29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set
32# CONFIG_HOTPLUG is not set
33CONFIG_KOBJECT_UEVENT=y
34# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE=""
36CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set
39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_PRINTK=y
41CONFIG_BUG=y
42CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y
44CONFIG_EPOLL=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SHMEM=y
47CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0
49CONFIG_CC_ALIGN_LOOPS=0
50CONFIG_CC_ALIGN_JUMPS=0
51# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0
53
54#
55# Loadable module support
56#
57CONFIG_MODULES=y
58CONFIG_MODULE_UNLOAD=y
59# CONFIG_MODULE_FORCE_UNLOAD is not set
60CONFIG_OBSOLETE_MODPARM=y
61# CONFIG_MODVERSIONS is not set
62# CONFIG_MODULE_SRCVERSION_ALL is not set
63CONFIG_KMOD=y
64
65#
66# Block layer
67#
68
69#
70# IO Schedulers
71#
72CONFIG_IOSCHED_NOOP=y
73CONFIG_IOSCHED_AS=y
74CONFIG_IOSCHED_DEADLINE=y
75CONFIG_IOSCHED_CFQ=y
76CONFIG_DEFAULT_AS=y
77# CONFIG_DEFAULT_DEADLINE is not set
78# CONFIG_DEFAULT_CFQ is not set
79# CONFIG_DEFAULT_NOOP is not set
80CONFIG_DEFAULT_IOSCHED="anticipatory"
81
82#
83# System Type
84#
85# CONFIG_ARCH_CLPS7500 is not set
86# CONFIG_ARCH_CLPS711X is not set
87# CONFIG_ARCH_CO285 is not set
88# CONFIG_ARCH_EBSA110 is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set
92# CONFIG_ARCH_IXP4XX is not set
93CONFIG_ARCH_IXP2000=y
94# CONFIG_ARCH_L7200 is not set
95# CONFIG_ARCH_PXA is not set
96# CONFIG_ARCH_RPC is not set
97# CONFIG_ARCH_SA1100 is not set
98# CONFIG_ARCH_S3C2410 is not set
99# CONFIG_ARCH_SHARK is not set
100# CONFIG_ARCH_LH7A40X is not set
101# CONFIG_ARCH_OMAP is not set
102# CONFIG_ARCH_VERSATILE is not set
103# CONFIG_ARCH_REALVIEW is not set
104# CONFIG_ARCH_IMX is not set
105# CONFIG_ARCH_H720X is not set
106# CONFIG_ARCH_AAEC2000 is not set
107CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
108
109#
110# Intel IXP2400/2800 Implementation Options
111#
112
113#
114# IXP2400/2800 Platforms
115#
116# CONFIG_ARCH_ENP2611 is not set
117# CONFIG_ARCH_IXDP2400 is not set
118# CONFIG_ARCH_IXDP2800 is not set
119# CONFIG_ARCH_IXDP2401 is not set
120CONFIG_ARCH_IXDP2801=y
121CONFIG_ARCH_IXDP2X01=y
122# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
123
124#
125# Processor Type
126#
127CONFIG_CPU_32=y
128CONFIG_CPU_XSCALE=y
129CONFIG_CPU_32v5=y
130CONFIG_CPU_ABRT_EV5T=y
131CONFIG_CPU_CACHE_VIVT=y
132CONFIG_CPU_TLB_V4WBI=y
133
134#
135# Processor Features
136#
137# CONFIG_ARM_THUMB is not set
138CONFIG_CPU_BIG_ENDIAN=y
139CONFIG_XSCALE_PMU=y
140
141#
142# Bus support
143#
144CONFIG_ISA_DMA_API=y
145CONFIG_PCI=y
146CONFIG_PCI_LEGACY_PROC=y
147# CONFIG_PCI_DEBUG is not set
148
149#
150# PCCARD (PCMCIA/CardBus) support
151#
152# CONFIG_PCCARD is not set
153
154#
155# Kernel Features
156#
157# CONFIG_PREEMPT is not set
158# CONFIG_NO_IDLE_HZ is not set
159# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
160CONFIG_SELECT_MEMORY_MODEL=y
161CONFIG_FLATMEM_MANUAL=y
162# CONFIG_DISCONTIGMEM_MANUAL is not set
163# CONFIG_SPARSEMEM_MANUAL is not set
164CONFIG_FLATMEM=y
165CONFIG_FLAT_NODE_MEM_MAP=y
166# CONFIG_SPARSEMEM_STATIC is not set
167CONFIG_SPLIT_PTLOCK_CPUS=4096
168CONFIG_ALIGNMENT_TRAP=y
169
170#
171# Boot options
172#
173CONFIG_ZBOOT_ROM_TEXT=0x0
174CONFIG_ZBOOT_ROM_BSS=0x0
175CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs ip=bootp mem=64M@0x0"
176# CONFIG_XIP_KERNEL is not set
177
178#
179# Floating point emulation
180#
181
182#
183# At least one emulation must be selected
184#
185CONFIG_FPE_NWFPE=y
186CONFIG_FPE_NWFPE_XP=y
187# CONFIG_FPE_FASTFPE is not set
188
189#
190# Userspace binary formats
191#
192CONFIG_BINFMT_ELF=y
193# CONFIG_BINFMT_AOUT is not set
194# CONFIG_BINFMT_MISC is not set
195# CONFIG_ARTHUR is not set
196
197#
198# Power management options
199#
200# CONFIG_PM is not set
201
202#
203# Networking
204#
205CONFIG_NET=y
206
207#
208# Networking options
209#
210CONFIG_PACKET=y
211CONFIG_PACKET_MMAP=y
212CONFIG_UNIX=y
213# CONFIG_NET_KEY is not set
214CONFIG_INET=y
215# CONFIG_IP_MULTICAST is not set
216# CONFIG_IP_ADVANCED_ROUTER is not set
217CONFIG_IP_FIB_HASH=y
218CONFIG_IP_PNP=y
219CONFIG_IP_PNP_DHCP=y
220CONFIG_IP_PNP_BOOTP=y
221# CONFIG_IP_PNP_RARP is not set
222# CONFIG_NET_IPIP is not set
223# CONFIG_NET_IPGRE is not set
224# CONFIG_ARPD is not set
225CONFIG_SYN_COOKIES=y
226# CONFIG_INET_AH is not set
227# CONFIG_INET_ESP is not set
228# CONFIG_INET_IPCOMP is not set
229# CONFIG_INET_TUNNEL is not set
230CONFIG_INET_DIAG=y
231CONFIG_INET_TCP_DIAG=y
232# CONFIG_TCP_CONG_ADVANCED is not set
233CONFIG_TCP_CONG_BIC=y
234# CONFIG_IPV6 is not set
235# CONFIG_NETFILTER is not set
236
237#
238# DCCP Configuration (EXPERIMENTAL)
239#
240# CONFIG_IP_DCCP is not set
241
242#
243# SCTP Configuration (EXPERIMENTAL)
244#
245# CONFIG_IP_SCTP is not set
246# CONFIG_ATM is not set
247# CONFIG_BRIDGE is not set
248# CONFIG_VLAN_8021Q is not set
249# CONFIG_DECNET is not set
250# CONFIG_LLC2 is not set
251# CONFIG_IPX is not set
252# CONFIG_ATALK is not set
253# CONFIG_X25 is not set
254# CONFIG_LAPB is not set
255# CONFIG_NET_DIVERT is not set
256# CONFIG_ECONET is not set
257# CONFIG_WAN_ROUTER is not set
258
259#
260# QoS and/or fair queueing
261#
262# CONFIG_NET_SCHED is not set
263# CONFIG_NET_CLS_ROUTE is not set
264
265#
266# Network testing
267#
268# CONFIG_NET_PKTGEN is not set
269# CONFIG_HAMRADIO is not set
270# CONFIG_IRDA is not set
271# CONFIG_BT is not set
272# CONFIG_IEEE80211 is not set
273
274#
275# Device Drivers
276#
277
278#
279# Generic Driver Options
280#
281CONFIG_STANDALONE=y
282# CONFIG_PREVENT_FIRMWARE_BUILD is not set
283# CONFIG_FW_LOADER is not set
284# CONFIG_DEBUG_DRIVER is not set
285
286#
287# Memory Technology Devices (MTD)
288#
289CONFIG_MTD=y
290# CONFIG_MTD_DEBUG is not set
291# CONFIG_MTD_CONCAT is not set
292CONFIG_MTD_PARTITIONS=y
293CONFIG_MTD_REDBOOT_PARTS=y
294CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
295CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
296CONFIG_MTD_REDBOOT_PARTS_READONLY=y
297# CONFIG_MTD_CMDLINE_PARTS is not set
298# CONFIG_MTD_AFS_PARTS is not set
299
300#
301# User Modules And Translation Layers
302#
303CONFIG_MTD_CHAR=y
304CONFIG_MTD_BLOCK=y
305# CONFIG_FTL is not set
306# CONFIG_NFTL is not set
307# CONFIG_INFTL is not set
308# CONFIG_RFD_FTL is not set
309
310#
311# RAM/ROM/Flash chip drivers
312#
313CONFIG_MTD_CFI=y
314# CONFIG_MTD_JEDECPROBE is not set
315CONFIG_MTD_GEN_PROBE=y
316# CONFIG_MTD_CFI_ADV_OPTIONS is not set
317CONFIG_MTD_MAP_BANK_WIDTH_1=y
318CONFIG_MTD_MAP_BANK_WIDTH_2=y
319CONFIG_MTD_MAP_BANK_WIDTH_4=y
320# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
321# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
322# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
323CONFIG_MTD_CFI_I1=y
324CONFIG_MTD_CFI_I2=y
325# CONFIG_MTD_CFI_I4 is not set
326# CONFIG_MTD_CFI_I8 is not set
327CONFIG_MTD_CFI_INTELEXT=y
328# CONFIG_MTD_CFI_AMDSTD is not set
329# CONFIG_MTD_CFI_STAA is not set
330CONFIG_MTD_CFI_UTIL=y
331# CONFIG_MTD_RAM is not set
332# CONFIG_MTD_ROM is not set
333# CONFIG_MTD_ABSENT is not set
334# CONFIG_MTD_XIP is not set
335
336#
337# Mapping drivers for chip access
338#
339CONFIG_MTD_COMPLEX_MAPPINGS=y
340# CONFIG_MTD_PHYSMAP is not set
341# CONFIG_MTD_ARM_INTEGRATOR is not set
342CONFIG_MTD_IXP2000=y
343# CONFIG_MTD_PCI is not set
344# CONFIG_MTD_PLATRAM is not set
345
346#
347# Self-contained MTD device drivers
348#
349# CONFIG_MTD_PMC551 is not set
350# CONFIG_MTD_SLRAM is not set
351# CONFIG_MTD_PHRAM is not set
352# CONFIG_MTD_MTDRAM is not set
353# CONFIG_MTD_BLKMTD is not set
354# CONFIG_MTD_BLOCK2MTD is not set
355
356#
357# Disk-On-Chip Device Drivers
358#
359# CONFIG_MTD_DOC2000 is not set
360# CONFIG_MTD_DOC2001 is not set
361# CONFIG_MTD_DOC2001PLUS is not set
362
363#
364# NAND Flash Device Drivers
365#
366# CONFIG_MTD_NAND is not set
367
368#
369# OneNAND Flash Device Drivers
370#
371# CONFIG_MTD_ONENAND is not set
372
373#
374# Parallel port support
375#
376# CONFIG_PARPORT is not set
377
378#
379# Plug and Play support
380#
381
382#
383# Block devices
384#
385# CONFIG_BLK_CPQ_DA is not set
386# CONFIG_BLK_CPQ_CISS_DA is not set
387# CONFIG_BLK_DEV_DAC960 is not set
388# CONFIG_BLK_DEV_UMEM is not set
389# CONFIG_BLK_DEV_COW_COMMON is not set
390CONFIG_BLK_DEV_LOOP=y
391# CONFIG_BLK_DEV_CRYPTOLOOP is not set
392# CONFIG_BLK_DEV_NBD is not set
393# CONFIG_BLK_DEV_SX8 is not set
394CONFIG_BLK_DEV_RAM=y
395CONFIG_BLK_DEV_RAM_COUNT=16
396CONFIG_BLK_DEV_RAM_SIZE=8192
397CONFIG_BLK_DEV_INITRD=y
398# CONFIG_CDROM_PKTCDVD is not set
399# CONFIG_ATA_OVER_ETH is not set
400
401#
402# SCSI device support
403#
404# CONFIG_RAID_ATTRS is not set
405# CONFIG_SCSI is not set
406
407#
408# Multi-device support (RAID and LVM)
409#
410# CONFIG_MD is not set
411
412#
413# Fusion MPT device support
414#
415# CONFIG_FUSION is not set
416
417#
418# IEEE 1394 (FireWire) support
419#
420# CONFIG_IEEE1394 is not set
421
422#
423# I2O device support
424#
425# CONFIG_I2O is not set
426
427#
428# Network device support
429#
430CONFIG_NETDEVICES=y
431CONFIG_DUMMY=y
432# CONFIG_BONDING is not set
433# CONFIG_EQUALIZER is not set
434# CONFIG_TUN is not set
435
436#
437# ARCnet devices
438#
439# CONFIG_ARCNET is not set
440
441#
442# PHY device support
443#
444# CONFIG_PHYLIB is not set
445
446#
447# Ethernet (10 or 100Mbit)
448#
449CONFIG_NET_ETHERNET=y
450CONFIG_MII=y
451# CONFIG_HAPPYMEAL is not set
452# CONFIG_SUNGEM is not set
453# CONFIG_CASSINI is not set
454# CONFIG_NET_VENDOR_3COM is not set
455# CONFIG_SMC91X is not set
456# CONFIG_DM9000 is not set
457
458#
459# Tulip family network device support
460#
461# CONFIG_NET_TULIP is not set
462# CONFIG_HP100 is not set
463CONFIG_NET_PCI=y
464# CONFIG_PCNET32 is not set
465# CONFIG_AMD8111_ETH is not set
466# CONFIG_ADAPTEC_STARFIRE is not set
467# CONFIG_B44 is not set
468# CONFIG_FORCEDETH is not set
469CONFIG_CS89x0=y
470# CONFIG_DGRS is not set
471CONFIG_EEPRO100=y
472# CONFIG_E100 is not set
473# CONFIG_FEALNX is not set
474# CONFIG_NATSEMI is not set
475# CONFIG_NE2K_PCI is not set
476# CONFIG_8139CP is not set
477# CONFIG_8139TOO is not set
478# CONFIG_SIS900 is not set
479# CONFIG_EPIC100 is not set
480# CONFIG_SUNDANCE is not set
481# CONFIG_TLAN is not set
482# CONFIG_VIA_RHINE is not set
483
484#
485# Ethernet (1000 Mbit)
486#
487# CONFIG_ACENIC is not set
488# CONFIG_DL2K is not set
489# CONFIG_E1000 is not set
490# CONFIG_NS83820 is not set
491# CONFIG_HAMACHI is not set
492# CONFIG_YELLOWFIN is not set
493# CONFIG_R8169 is not set
494# CONFIG_SIS190 is not set
495# CONFIG_SKGE is not set
496# CONFIG_SK98LIN is not set
497# CONFIG_VIA_VELOCITY is not set
498# CONFIG_TIGON3 is not set
499# CONFIG_BNX2 is not set
500
501#
502# Ethernet (10000 Mbit)
503#
504# CONFIG_CHELSIO_T1 is not set
505# CONFIG_IXGB is not set
506# CONFIG_S2IO is not set
507
508#
509# Token Ring devices
510#
511# CONFIG_TR is not set
512
513#
514# Wireless LAN (non-hamradio)
515#
516# CONFIG_NET_RADIO is not set
517
518#
519# Wan interfaces
520#
521CONFIG_WAN=y
522# CONFIG_DSCC4 is not set
523# CONFIG_LANMEDIA is not set
524# CONFIG_SYNCLINK_SYNCPPP is not set
525CONFIG_HDLC=y
526CONFIG_HDLC_RAW=y
527# CONFIG_HDLC_RAW_ETH is not set
528CONFIG_HDLC_CISCO=y
529CONFIG_HDLC_FR=y
530CONFIG_HDLC_PPP=y
531
532#
533# X.25/LAPB support is disabled
534#
535# CONFIG_PCI200SYN is not set
536# CONFIG_WANXL is not set
537# CONFIG_PC300 is not set
538# CONFIG_FARSYNC is not set
539CONFIG_DLCI=y
540CONFIG_DLCI_COUNT=24
541CONFIG_DLCI_MAX=8
542# CONFIG_FDDI is not set
543# CONFIG_HIPPI is not set
544# CONFIG_PPP is not set
545# CONFIG_SLIP is not set
546# CONFIG_SHAPER is not set
547# CONFIG_NETCONSOLE is not set
548# CONFIG_NETPOLL is not set
549# CONFIG_NET_POLL_CONTROLLER is not set
550
551#
552# ISDN subsystem
553#
554# CONFIG_ISDN is not set
555
556#
557# Input device support
558#
559CONFIG_INPUT=y
560
561#
562# Userland interfaces
563#
564CONFIG_INPUT_MOUSEDEV=y
565CONFIG_INPUT_MOUSEDEV_PSAUX=y
566CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
567CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
568# CONFIG_INPUT_JOYDEV is not set
569# CONFIG_INPUT_TSDEV is not set
570# CONFIG_INPUT_EVDEV is not set
571# CONFIG_INPUT_EVBUG is not set
572
573#
574# Input Device Drivers
575#
576# CONFIG_INPUT_KEYBOARD is not set
577# CONFIG_INPUT_MOUSE is not set
578# CONFIG_INPUT_JOYSTICK is not set
579# CONFIG_INPUT_TOUCHSCREEN is not set
580# CONFIG_INPUT_MISC is not set
581
582#
583# Hardware I/O ports
584#
585# CONFIG_SERIO is not set
586# CONFIG_GAMEPORT is not set
587
588#
589# Character devices
590#
591# CONFIG_VT is not set
592# CONFIG_SERIAL_NONSTANDARD is not set
593
594#
595# Serial drivers
596#
597CONFIG_SERIAL_8250=y
598CONFIG_SERIAL_8250_CONSOLE=y
599CONFIG_SERIAL_8250_NR_UARTS=3
600# CONFIG_SERIAL_8250_EXTENDED is not set
601
602#
603# Non-8250 serial port support
604#
605CONFIG_SERIAL_CORE=y
606CONFIG_SERIAL_CORE_CONSOLE=y
607# CONFIG_SERIAL_JSM is not set
608CONFIG_UNIX98_PTYS=y
609CONFIG_LEGACY_PTYS=y
610CONFIG_LEGACY_PTY_COUNT=256
611
612#
613# IPMI
614#
615# CONFIG_IPMI_HANDLER is not set
616
617#
618# Watchdog Cards
619#
620CONFIG_WATCHDOG=y
621# CONFIG_WATCHDOG_NOWAYOUT is not set
622
623#
624# Watchdog Device Drivers
625#
626# CONFIG_SOFT_WATCHDOG is not set
627CONFIG_IXP2000_WATCHDOG=y
628
629#
630# PCI-based Watchdog Cards
631#
632# CONFIG_PCIPCWATCHDOG is not set
633# CONFIG_WDTPCI is not set
634# CONFIG_NVRAM is not set
635# CONFIG_RTC is not set
636# CONFIG_DTLK is not set
637# CONFIG_R3964 is not set
638# CONFIG_APPLICOM is not set
639
640#
641# Ftape, the floppy tape device driver
642#
643# CONFIG_DRM is not set
644# CONFIG_RAW_DRIVER is not set
645
646#
647# TPM devices
648#
649# CONFIG_TCG_TPM is not set
650# CONFIG_TELCLOCK is not set
651
652#
653# I2C support
654#
655CONFIG_I2C=y
656CONFIG_I2C_CHARDEV=y
657
658#
659# I2C Algorithms
660#
661CONFIG_I2C_ALGOBIT=y
662# CONFIG_I2C_ALGOPCF is not set
663# CONFIG_I2C_ALGOPCA is not set
664
665#
666# I2C Hardware Bus support
667#
668# CONFIG_I2C_ALI1535 is not set
669# CONFIG_I2C_ALI1563 is not set
670# CONFIG_I2C_ALI15X3 is not set
671# CONFIG_I2C_AMD756 is not set
672# CONFIG_I2C_AMD8111 is not set
673# CONFIG_I2C_I801 is not set
674# CONFIG_I2C_I810 is not set
675# CONFIG_I2C_PIIX4 is not set
676CONFIG_I2C_IXP2000=y
677# CONFIG_I2C_NFORCE2 is not set
678# CONFIG_I2C_PARPORT_LIGHT is not set
679# CONFIG_I2C_PROSAVAGE is not set
680# CONFIG_I2C_SAVAGE4 is not set
681# CONFIG_SCx200_ACB is not set
682# CONFIG_I2C_SIS5595 is not set
683# CONFIG_I2C_SIS630 is not set
684# CONFIG_I2C_SIS96X is not set
685# CONFIG_I2C_STUB is not set
686# CONFIG_I2C_VIA is not set
687# CONFIG_I2C_VIAPRO is not set
688# CONFIG_I2C_VOODOO3 is not set
689# CONFIG_I2C_PCA_ISA is not set
690
691#
692# Miscellaneous I2C Chip support
693#
694# CONFIG_SENSORS_DS1337 is not set
695# CONFIG_SENSORS_DS1374 is not set
696CONFIG_SENSORS_EEPROM=y
697# CONFIG_SENSORS_PCF8574 is not set
698# CONFIG_SENSORS_PCA9539 is not set
699# CONFIG_SENSORS_PCF8591 is not set
700# CONFIG_SENSORS_RTC8564 is not set
701# CONFIG_SENSORS_MAX6875 is not set
702# CONFIG_RTC_X1205_I2C is not set
703# CONFIG_I2C_DEBUG_CORE is not set
704# CONFIG_I2C_DEBUG_ALGO is not set
705# CONFIG_I2C_DEBUG_BUS is not set
706# CONFIG_I2C_DEBUG_CHIP is not set
707
708#
709# Hardware Monitoring support
710#
711CONFIG_HWMON=y
712# CONFIG_HWMON_VID is not set
713# CONFIG_SENSORS_ADM1021 is not set
714# CONFIG_SENSORS_ADM1025 is not set
715# CONFIG_SENSORS_ADM1026 is not set
716# CONFIG_SENSORS_ADM1031 is not set
717# CONFIG_SENSORS_ADM9240 is not set
718# CONFIG_SENSORS_ASB100 is not set
719# CONFIG_SENSORS_ATXP1 is not set
720# CONFIG_SENSORS_DS1621 is not set
721# CONFIG_SENSORS_FSCHER is not set
722# CONFIG_SENSORS_FSCPOS is not set
723# CONFIG_SENSORS_GL518SM is not set
724# CONFIG_SENSORS_GL520SM is not set
725# CONFIG_SENSORS_IT87 is not set
726# CONFIG_SENSORS_LM63 is not set
727# CONFIG_SENSORS_LM75 is not set
728# CONFIG_SENSORS_LM77 is not set
729# CONFIG_SENSORS_LM78 is not set
730# CONFIG_SENSORS_LM80 is not set
731# CONFIG_SENSORS_LM83 is not set
732# CONFIG_SENSORS_LM85 is not set
733# CONFIG_SENSORS_LM87 is not set
734# CONFIG_SENSORS_LM90 is not set
735# CONFIG_SENSORS_LM92 is not set
736# CONFIG_SENSORS_MAX1619 is not set
737# CONFIG_SENSORS_PC87360 is not set
738# CONFIG_SENSORS_SIS5595 is not set
739# CONFIG_SENSORS_SMSC47M1 is not set
740# CONFIG_SENSORS_SMSC47B397 is not set
741# CONFIG_SENSORS_VIA686A is not set
742# CONFIG_SENSORS_W83781D is not set
743# CONFIG_SENSORS_W83792D is not set
744# CONFIG_SENSORS_W83L785TS is not set
745# CONFIG_SENSORS_W83627HF is not set
746# CONFIG_SENSORS_W83627EHF is not set
747# CONFIG_HWMON_DEBUG_CHIP is not set
748
749#
750# Misc devices
751#
752
753#
754# Multimedia Capabilities Port drivers
755#
756
757#
758# Multimedia devices
759#
760# CONFIG_VIDEO_DEV is not set
761
762#
763# Digital Video Broadcasting Devices
764#
765# CONFIG_DVB is not set
766
767#
768# Graphics support
769#
770# CONFIG_FB is not set
771
772#
773# Sound
774#
775# CONFIG_SOUND is not set
776
777#
778# USB support
779#
780CONFIG_USB_ARCH_HAS_HCD=y
781CONFIG_USB_ARCH_HAS_OHCI=y
782# CONFIG_USB is not set
783
784#
785# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
786#
787
788#
789# USB Gadget Support
790#
791# CONFIG_USB_GADGET is not set
792
793#
794# MMC/SD Card support
795#
796# CONFIG_MMC is not set
797
798#
799# File systems
800#
801CONFIG_EXT2_FS=y
802CONFIG_EXT2_FS_XATTR=y
803CONFIG_EXT2_FS_POSIX_ACL=y
804# CONFIG_EXT2_FS_SECURITY is not set
805# CONFIG_EXT2_FS_XIP is not set
806CONFIG_EXT3_FS=y
807CONFIG_EXT3_FS_XATTR=y
808CONFIG_EXT3_FS_POSIX_ACL=y
809# CONFIG_EXT3_FS_SECURITY is not set
810CONFIG_JBD=y
811# CONFIG_JBD_DEBUG is not set
812CONFIG_FS_MBCACHE=y
813# CONFIG_REISERFS_FS is not set
814# CONFIG_JFS_FS is not set
815CONFIG_FS_POSIX_ACL=y
816# CONFIG_XFS_FS is not set
817# CONFIG_MINIX_FS is not set
818# CONFIG_ROMFS_FS is not set
819CONFIG_INOTIFY=y
820# CONFIG_QUOTA is not set
821CONFIG_DNOTIFY=y
822# CONFIG_AUTOFS_FS is not set
823# CONFIG_AUTOFS4_FS is not set
824# CONFIG_FUSE_FS is not set
825
826#
827# CD-ROM/DVD Filesystems
828#
829# CONFIG_ISO9660_FS is not set
830# CONFIG_UDF_FS is not set
831
832#
833# DOS/FAT/NT Filesystems
834#
835# CONFIG_MSDOS_FS is not set
836# CONFIG_VFAT_FS is not set
837# CONFIG_NTFS_FS is not set
838
839#
840# Pseudo filesystems
841#
842CONFIG_PROC_FS=y
843CONFIG_SYSFS=y
844CONFIG_TMPFS=y
845# CONFIG_HUGETLB_PAGE is not set
846CONFIG_RAMFS=y
847# CONFIG_RELAYFS_FS is not set
848
849#
850# Miscellaneous filesystems
851#
852# CONFIG_ADFS_FS is not set
853# CONFIG_AFFS_FS is not set
854# CONFIG_HFS_FS is not set
855# CONFIG_HFSPLUS_FS is not set
856# CONFIG_BEFS_FS is not set
857# CONFIG_BFS_FS is not set
858# CONFIG_EFS_FS is not set
859# CONFIG_JFFS_FS is not set
860CONFIG_JFFS2_FS=y
861CONFIG_JFFS2_FS_DEBUG=0
862CONFIG_JFFS2_FS_WRITEBUFFER=y
863# CONFIG_JFFS2_SUMMARY is not set
864# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
865CONFIG_JFFS2_ZLIB=y
866CONFIG_JFFS2_RTIME=y
867# CONFIG_JFFS2_RUBIN is not set
868# CONFIG_CRAMFS is not set
869# CONFIG_VXFS_FS is not set
870# CONFIG_HPFS_FS is not set
871# CONFIG_QNX4FS_FS is not set
872# CONFIG_SYSV_FS is not set
873# CONFIG_UFS_FS is not set
874
875#
876# Network File Systems
877#
878CONFIG_NFS_FS=y
879CONFIG_NFS_V3=y
880# CONFIG_NFS_V3_ACL is not set
881# CONFIG_NFS_V4 is not set
882# CONFIG_NFS_DIRECTIO is not set
883# CONFIG_NFSD is not set
884CONFIG_ROOT_NFS=y
885CONFIG_LOCKD=y
886CONFIG_LOCKD_V4=y
887CONFIG_NFS_COMMON=y
888CONFIG_SUNRPC=y
889# CONFIG_RPCSEC_GSS_KRB5 is not set
890# CONFIG_RPCSEC_GSS_SPKM3 is not set
891# CONFIG_SMB_FS is not set
892# CONFIG_CIFS is not set
893# CONFIG_NCP_FS is not set
894# CONFIG_CODA_FS is not set
895# CONFIG_AFS_FS is not set
896# CONFIG_9P_FS is not set
897
898#
899# Partition Types
900#
901CONFIG_PARTITION_ADVANCED=y
902# CONFIG_ACORN_PARTITION is not set
903# CONFIG_OSF_PARTITION is not set
904# CONFIG_AMIGA_PARTITION is not set
905# CONFIG_ATARI_PARTITION is not set
906# CONFIG_MAC_PARTITION is not set
907CONFIG_MSDOS_PARTITION=y
908# CONFIG_BSD_DISKLABEL is not set
909# CONFIG_MINIX_SUBPARTITION is not set
910# CONFIG_SOLARIS_X86_PARTITION is not set
911# CONFIG_UNIXWARE_DISKLABEL is not set
912# CONFIG_LDM_PARTITION is not set
913# CONFIG_SGI_PARTITION is not set
914# CONFIG_ULTRIX_PARTITION is not set
915# CONFIG_SUN_PARTITION is not set
916# CONFIG_EFI_PARTITION is not set
917
918#
919# Native Language Support
920#
921# CONFIG_NLS is not set
922
923#
924# Profiling support
925#
926# CONFIG_PROFILING is not set
927
928#
929# Kernel hacking
930#
931# CONFIG_PRINTK_TIME is not set
932CONFIG_DEBUG_KERNEL=y
933CONFIG_MAGIC_SYSRQ=y
934CONFIG_LOG_BUF_SHIFT=14
935CONFIG_DETECT_SOFTLOCKUP=y
936# CONFIG_SCHEDSTATS is not set
937# CONFIG_DEBUG_SLAB is not set
938# CONFIG_DEBUG_SPINLOCK is not set
939# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
940# CONFIG_DEBUG_KOBJECT is not set
941CONFIG_DEBUG_BUGVERBOSE=y
942# CONFIG_DEBUG_INFO is not set
943# CONFIG_DEBUG_FS is not set
944# CONFIG_DEBUG_VM is not set
945CONFIG_FRAME_POINTER=y
946# CONFIG_RCU_TORTURE_TEST is not set
947CONFIG_DEBUG_USER=y
948# CONFIG_DEBUG_WAITQ is not set
949CONFIG_DEBUG_ERRORS=y
950CONFIG_DEBUG_LL=y
951# CONFIG_DEBUG_ICEDCC is not set
952
953#
954# Security options
955#
956# CONFIG_KEYS is not set
957# CONFIG_SECURITY is not set
958
959#
960# Cryptographic options
961#
962# CONFIG_CRYPTO is not set
963
964#
965# Hardware crypto devices
966#
967
968#
969# Library routines
970#
971# CONFIG_CRC_CCITT is not set
972# CONFIG_CRC16 is not set
973CONFIG_CRC32=y
974# CONFIG_LIBCRC32C is not set
975CONFIG_ZLIB_INFLATE=y
976CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2400_defconfig b/arch/arm/configs/ixp2000_defconfig
index c67fc449a11f..7b02ca04c3ee 100644
--- a/arch/arm/configs/ixdp2400_defconfig
+++ b/arch/arm/configs/ixp2000_defconfig
@@ -1,11 +1,10 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-git13 3# Linux kernel version: 2.6.16-rc2
4# Thu Nov 10 15:14:13 2005 4# Wed Feb 8 04:49:11 2006
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 8CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
11 10
@@ -29,27 +28,31 @@ CONFIG_BSD_PROCESS_ACCT=y
29# CONFIG_BSD_PROCESS_ACCT_V3 is not set 28# CONFIG_BSD_PROCESS_ACCT_V3 is not set
30CONFIG_SYSCTL=y 29CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set 30# CONFIG_AUDIT is not set
32# CONFIG_HOTPLUG is not set
33CONFIG_KOBJECT_UEVENT=y
34# CONFIG_IKCONFIG is not set 31# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE="" 32CONFIG_INITRAMFS_SOURCE=""
33CONFIG_UID16=y
34CONFIG_CC_OPTIMIZE_FOR_SIZE=y
36CONFIG_EMBEDDED=y 35CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y 36CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set 37# CONFIG_KALLSYMS_ALL is not set
39# CONFIG_KALLSYMS_EXTRA_PASS is not set 38# CONFIG_KALLSYMS_EXTRA_PASS is not set
39# CONFIG_HOTPLUG is not set
40CONFIG_PRINTK=y 40CONFIG_PRINTK=y
41CONFIG_BUG=y 41CONFIG_BUG=y
42CONFIG_ELF_CORE=y
42CONFIG_BASE_FULL=y 43CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y 44CONFIG_FUTEX=y
44CONFIG_EPOLL=y 45CONFIG_EPOLL=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SHMEM=y 46CONFIG_SHMEM=y
47CONFIG_CC_ALIGN_FUNCTIONS=0 47CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0 48CONFIG_CC_ALIGN_LABELS=0
49CONFIG_CC_ALIGN_LOOPS=0 49CONFIG_CC_ALIGN_LOOPS=0
50CONFIG_CC_ALIGN_JUMPS=0 50CONFIG_CC_ALIGN_JUMPS=0
51CONFIG_SLAB=y
51# CONFIG_TINY_SHMEM is not set 52# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0 53CONFIG_BASE_SMALL=0
54# CONFIG_SLOB is not set
55CONFIG_OBSOLETE_INTERMODULE=y
53 56
54# 57#
55# Loadable module support 58# Loadable module support
@@ -104,6 +107,7 @@ CONFIG_ARCH_IXP2000=y
104# CONFIG_ARCH_IMX is not set 107# CONFIG_ARCH_IMX is not set
105# CONFIG_ARCH_H720X is not set 108# CONFIG_ARCH_H720X is not set
106# CONFIG_ARCH_AAEC2000 is not set 109# CONFIG_ARCH_AAEC2000 is not set
110# CONFIG_ARCH_AT91RM9200 is not set
107CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y 111CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
108 112
109# 113#
@@ -113,12 +117,13 @@ CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
113# 117#
114# IXP2400/2800 Platforms 118# IXP2400/2800 Platforms
115# 119#
116# CONFIG_ARCH_ENP2611 is not set 120CONFIG_ARCH_ENP2611=y
117CONFIG_ARCH_IXDP2400=y 121CONFIG_ARCH_IXDP2400=y
118# CONFIG_ARCH_IXDP2800 is not set 122CONFIG_ARCH_IXDP2800=y
119CONFIG_ARCH_IXDP2X00=y 123CONFIG_ARCH_IXDP2X00=y
120# CONFIG_ARCH_IXDP2401 is not set 124CONFIG_ARCH_IXDP2401=y
121# CONFIG_ARCH_IXDP2801 is not set 125CONFIG_ARCH_IXDP2801=y
126CONFIG_ARCH_IXDP2X01=y
122# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set 127# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
123 128
124# 129#
@@ -141,7 +146,6 @@ CONFIG_XSCALE_PMU=y
141# 146#
142# Bus support 147# Bus support
143# 148#
144CONFIG_ISA_DMA_API=y
145CONFIG_PCI=y 149CONFIG_PCI=y
146CONFIG_PCI_LEGACY_PROC=y 150CONFIG_PCI_LEGACY_PROC=y
147# CONFIG_PCI_DEBUG is not set 151# CONFIG_PCI_DEBUG is not set
@@ -156,6 +160,7 @@ CONFIG_PCI_LEGACY_PROC=y
156# 160#
157# CONFIG_PREEMPT is not set 161# CONFIG_PREEMPT is not set
158# CONFIG_NO_IDLE_HZ is not set 162# CONFIG_NO_IDLE_HZ is not set
163# CONFIG_AEABI is not set
159# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set 164# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
160CONFIG_SELECT_MEMORY_MODEL=y 165CONFIG_SELECT_MEMORY_MODEL=y
161CONFIG_FLATMEM_MANUAL=y 166CONFIG_FLATMEM_MANUAL=y
@@ -198,6 +203,7 @@ CONFIG_BINFMT_ELF=y
198# Power management options 203# Power management options
199# 204#
200# CONFIG_PM is not set 205# CONFIG_PM is not set
206# CONFIG_APM is not set
201 207
202# 208#
203# Networking 209# Networking
@@ -243,6 +249,11 @@ CONFIG_TCP_CONG_BIC=y
243# SCTP Configuration (EXPERIMENTAL) 249# SCTP Configuration (EXPERIMENTAL)
244# 250#
245# CONFIG_IP_SCTP is not set 251# CONFIG_IP_SCTP is not set
252
253#
254# TIPC Configuration (EXPERIMENTAL)
255#
256# CONFIG_TIPC is not set
246# CONFIG_ATM is not set 257# CONFIG_ATM is not set
247# CONFIG_BRIDGE is not set 258# CONFIG_BRIDGE is not set
248# CONFIG_VLAN_8021Q is not set 259# CONFIG_VLAN_8021Q is not set
@@ -260,7 +271,6 @@ CONFIG_TCP_CONG_BIC=y
260# QoS and/or fair queueing 271# QoS and/or fair queueing
261# 272#
262# CONFIG_NET_SCHED is not set 273# CONFIG_NET_SCHED is not set
263# CONFIG_NET_CLS_ROUTE is not set
264 274
265# 275#
266# Network testing 276# Network testing
@@ -284,6 +294,11 @@ CONFIG_STANDALONE=y
284# CONFIG_DEBUG_DRIVER is not set 294# CONFIG_DEBUG_DRIVER is not set
285 295
286# 296#
297# Connector - unified userspace <-> kernelspace linker
298#
299# CONFIG_CONNECTOR is not set
300
301#
287# Memory Technology Devices (MTD) 302# Memory Technology Devices (MTD)
288# 303#
289CONFIG_MTD=y 304CONFIG_MTD=y
@@ -331,6 +346,7 @@ CONFIG_MTD_CFI_UTIL=y
331# CONFIG_MTD_RAM is not set 346# CONFIG_MTD_RAM is not set
332# CONFIG_MTD_ROM is not set 347# CONFIG_MTD_ROM is not set
333# CONFIG_MTD_ABSENT is not set 348# CONFIG_MTD_ABSENT is not set
349# CONFIG_MTD_OBSOLETE_CHIPS is not set
334# CONFIG_MTD_XIP is not set 350# CONFIG_MTD_XIP is not set
335 351
336# 352#
@@ -466,6 +482,7 @@ CONFIG_NET_PCI=y
466# CONFIG_ADAPTEC_STARFIRE is not set 482# CONFIG_ADAPTEC_STARFIRE is not set
467# CONFIG_B44 is not set 483# CONFIG_B44 is not set
468# CONFIG_FORCEDETH is not set 484# CONFIG_FORCEDETH is not set
485CONFIG_CS89x0=y
469# CONFIG_DGRS is not set 486# CONFIG_DGRS is not set
470CONFIG_EEPRO100=y 487CONFIG_EEPRO100=y
471# CONFIG_E100 is not set 488# CONFIG_E100 is not set
@@ -486,12 +503,14 @@ CONFIG_EEPRO100=y
486# CONFIG_ACENIC is not set 503# CONFIG_ACENIC is not set
487# CONFIG_DL2K is not set 504# CONFIG_DL2K is not set
488# CONFIG_E1000 is not set 505# CONFIG_E1000 is not set
506CONFIG_ENP2611_MSF_NET=y
489# CONFIG_NS83820 is not set 507# CONFIG_NS83820 is not set
490# CONFIG_HAMACHI is not set 508# CONFIG_HAMACHI is not set
491# CONFIG_YELLOWFIN is not set 509# CONFIG_YELLOWFIN is not set
492# CONFIG_R8169 is not set 510# CONFIG_R8169 is not set
493# CONFIG_SIS190 is not set 511# CONFIG_SIS190 is not set
494# CONFIG_SKGE is not set 512# CONFIG_SKGE is not set
513# CONFIG_SKY2 is not set
495# CONFIG_SK98LIN is not set 514# CONFIG_SK98LIN is not set
496# CONFIG_VIA_VELOCITY is not set 515# CONFIG_VIA_VELOCITY is not set
497# CONFIG_TIGON3 is not set 516# CONFIG_TIGON3 is not set
@@ -595,7 +614,8 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
595# 614#
596CONFIG_SERIAL_8250=y 615CONFIG_SERIAL_8250=y
597CONFIG_SERIAL_8250_CONSOLE=y 616CONFIG_SERIAL_8250_CONSOLE=y
598CONFIG_SERIAL_8250_NR_UARTS=1 617CONFIG_SERIAL_8250_NR_UARTS=3
618CONFIG_SERIAL_8250_RUNTIME_UARTS=4
599# CONFIG_SERIAL_8250_EXTENDED is not set 619# CONFIG_SERIAL_8250_EXTENDED is not set
600 620
601# 621#
@@ -603,7 +623,6 @@ CONFIG_SERIAL_8250_NR_UARTS=1
603# 623#
604CONFIG_SERIAL_CORE=y 624CONFIG_SERIAL_CORE=y
605CONFIG_SERIAL_CORE_CONSOLE=y 625CONFIG_SERIAL_CORE_CONSOLE=y
606# CONFIG_SERIAL_JSM is not set
607CONFIG_UNIX98_PTYS=y 626CONFIG_UNIX98_PTYS=y
608CONFIG_LEGACY_PTYS=y 627CONFIG_LEGACY_PTYS=y
609CONFIG_LEGACY_PTY_COUNT=256 628CONFIG_LEGACY_PTY_COUNT=256
@@ -705,6 +724,12 @@ CONFIG_SENSORS_EEPROM=y
705# CONFIG_I2C_DEBUG_CHIP is not set 724# CONFIG_I2C_DEBUG_CHIP is not set
706 725
707# 726#
727# SPI support
728#
729# CONFIG_SPI is not set
730# CONFIG_SPI_MASTER is not set
731
732#
708# Hardware Monitoring support 733# Hardware Monitoring support
709# 734#
710CONFIG_HWMON=y 735CONFIG_HWMON=y
@@ -738,6 +763,7 @@ CONFIG_HWMON=y
738# CONFIG_SENSORS_SMSC47M1 is not set 763# CONFIG_SENSORS_SMSC47M1 is not set
739# CONFIG_SENSORS_SMSC47B397 is not set 764# CONFIG_SENSORS_SMSC47B397 is not set
740# CONFIG_SENSORS_VIA686A is not set 765# CONFIG_SENSORS_VIA686A is not set
766# CONFIG_SENSORS_VT8231 is not set
741# CONFIG_SENSORS_W83781D is not set 767# CONFIG_SENSORS_W83781D is not set
742# CONFIG_SENSORS_W83792D is not set 768# CONFIG_SENSORS_W83792D is not set
743# CONFIG_SENSORS_W83L785TS is not set 769# CONFIG_SENSORS_W83L785TS is not set
@@ -813,6 +839,7 @@ CONFIG_FS_MBCACHE=y
813# CONFIG_JFS_FS is not set 839# CONFIG_JFS_FS is not set
814CONFIG_FS_POSIX_ACL=y 840CONFIG_FS_POSIX_ACL=y
815# CONFIG_XFS_FS is not set 841# CONFIG_XFS_FS is not set
842# CONFIG_OCFS2_FS is not set
816# CONFIG_MINIX_FS is not set 843# CONFIG_MINIX_FS is not set
817# CONFIG_ROMFS_FS is not set 844# CONFIG_ROMFS_FS is not set
818CONFIG_INOTIFY=y 845CONFIG_INOTIFY=y
@@ -844,6 +871,7 @@ CONFIG_TMPFS=y
844# CONFIG_HUGETLB_PAGE is not set 871# CONFIG_HUGETLB_PAGE is not set
845CONFIG_RAMFS=y 872CONFIG_RAMFS=y
846# CONFIG_RELAYFS_FS is not set 873# CONFIG_RELAYFS_FS is not set
874# CONFIG_CONFIGFS_FS is not set
847 875
848# 876#
849# Miscellaneous filesystems 877# Miscellaneous filesystems
@@ -912,6 +940,7 @@ CONFIG_MSDOS_PARTITION=y
912# CONFIG_SGI_PARTITION is not set 940# CONFIG_SGI_PARTITION is not set
913# CONFIG_ULTRIX_PARTITION is not set 941# CONFIG_ULTRIX_PARTITION is not set
914# CONFIG_SUN_PARTITION is not set 942# CONFIG_SUN_PARTITION is not set
943# CONFIG_KARMA_PARTITION is not set
915# CONFIG_EFI_PARTITION is not set 944# CONFIG_EFI_PARTITION is not set
916 945
917# 946#
@@ -928,12 +957,13 @@ CONFIG_MSDOS_PARTITION=y
928# Kernel hacking 957# Kernel hacking
929# 958#
930# CONFIG_PRINTK_TIME is not set 959# CONFIG_PRINTK_TIME is not set
931CONFIG_DEBUG_KERNEL=y
932CONFIG_MAGIC_SYSRQ=y 960CONFIG_MAGIC_SYSRQ=y
961CONFIG_DEBUG_KERNEL=y
933CONFIG_LOG_BUF_SHIFT=14 962CONFIG_LOG_BUF_SHIFT=14
934CONFIG_DETECT_SOFTLOCKUP=y 963CONFIG_DETECT_SOFTLOCKUP=y
935# CONFIG_SCHEDSTATS is not set 964# CONFIG_SCHEDSTATS is not set
936# CONFIG_DEBUG_SLAB is not set 965# CONFIG_DEBUG_SLAB is not set
966CONFIG_DEBUG_MUTEXES=y
937# CONFIG_DEBUG_SPINLOCK is not set 967# CONFIG_DEBUG_SPINLOCK is not set
938# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 968# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
939# CONFIG_DEBUG_KOBJECT is not set 969# CONFIG_DEBUG_KOBJECT is not set
@@ -942,6 +972,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
942# CONFIG_DEBUG_FS is not set 972# CONFIG_DEBUG_FS is not set
943# CONFIG_DEBUG_VM is not set 973# CONFIG_DEBUG_VM is not set
944CONFIG_FRAME_POINTER=y 974CONFIG_FRAME_POINTER=y
975CONFIG_FORCED_INLINING=y
945# CONFIG_RCU_TORTURE_TEST is not set 976# CONFIG_RCU_TORTURE_TEST is not set
946CONFIG_DEBUG_USER=y 977CONFIG_DEBUG_USER=y
947# CONFIG_DEBUG_WAITQ is not set 978# CONFIG_DEBUG_WAITQ is not set
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 6695b07cf1ba..3cec29d56c8e 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16-rc2 3# Linux kernel version: 2.6.16
4# Mon Feb 6 11:17:23 2006 4# Mon Mar 20 20:36:02 2006
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -12,7 +12,6 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
12# Code maturity level options 12# Code maturity level options
13# 13#
14CONFIG_EXPERIMENTAL=y 14CONFIG_EXPERIMENTAL=y
15CONFIG_CLEAN_COMPILE=y
16CONFIG_BROKEN_ON_SMP=y 15CONFIG_BROKEN_ON_SMP=y
17CONFIG_INIT_ENV_ARG_LIMIT=32 16CONFIG_INIT_ENV_ARG_LIMIT=32
18 17
@@ -87,6 +86,7 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
87# CONFIG_ARCH_CLPS711X is not set 86# CONFIG_ARCH_CLPS711X is not set
88# CONFIG_ARCH_CO285 is not set 87# CONFIG_ARCH_CO285 is not set
89# CONFIG_ARCH_EBSA110 is not set 88# CONFIG_ARCH_EBSA110 is not set
89# CONFIG_ARCH_EP93XX is not set
90# CONFIG_ARCH_FOOTBRIDGE is not set 90# CONFIG_ARCH_FOOTBRIDGE is not set
91# CONFIG_ARCH_INTEGRATOR is not set 91# CONFIG_ARCH_INTEGRATOR is not set
92# CONFIG_ARCH_IOP3XX is not set 92# CONFIG_ARCH_IOP3XX is not set
@@ -111,6 +111,7 @@ CONFIG_ARCH_S3C2410=y
111# S3C24XX Implementations 111# S3C24XX Implementations
112# 112#
113CONFIG_MACH_ANUBIS=y 113CONFIG_MACH_ANUBIS=y
114CONFIG_MACH_OSIRIS=y
114CONFIG_ARCH_BAST=y 115CONFIG_ARCH_BAST=y
115CONFIG_BAST_PC104_IRQ=y 116CONFIG_BAST_PC104_IRQ=y
116CONFIG_ARCH_H1940=y 117CONFIG_ARCH_H1940=y
@@ -175,6 +176,7 @@ CONFIG_ISA=y
175# 176#
176# CONFIG_PREEMPT is not set 177# CONFIG_PREEMPT is not set
177# CONFIG_NO_IDLE_HZ is not set 178# CONFIG_NO_IDLE_HZ is not set
179CONFIG_HZ=200
178# CONFIG_AEABI is not set 180# CONFIG_AEABI is not set
179# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set 181# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
180CONFIG_SELECT_MEMORY_MODEL=y 182CONFIG_SELECT_MEMORY_MODEL=y
@@ -230,6 +232,7 @@ CONFIG_NET=y
230# 232#
231# Networking options 233# Networking options
232# 234#
235# CONFIG_NETDEBUG is not set
233# CONFIG_PACKET is not set 236# CONFIG_PACKET is not set
234CONFIG_UNIX=y 237CONFIG_UNIX=y
235# CONFIG_NET_KEY is not set 238# CONFIG_NET_KEY is not set
@@ -364,7 +367,6 @@ CONFIG_MTD_CFI_UTIL=y
364CONFIG_MTD_ROM=y 367CONFIG_MTD_ROM=y
365# CONFIG_MTD_ABSENT is not set 368# CONFIG_MTD_ABSENT is not set
366# CONFIG_MTD_OBSOLETE_CHIPS is not set 369# CONFIG_MTD_OBSOLETE_CHIPS is not set
367# CONFIG_MTD_XIP is not set
368 370
369# 371#
370# Mapping drivers for chip access 372# Mapping drivers for chip access
@@ -431,6 +433,7 @@ CONFIG_PARPORT_1284=y
431CONFIG_BLK_DEV_LOOP=y 433CONFIG_BLK_DEV_LOOP=y
432# CONFIG_BLK_DEV_CRYPTOLOOP is not set 434# CONFIG_BLK_DEV_CRYPTOLOOP is not set
433CONFIG_BLK_DEV_NBD=m 435CONFIG_BLK_DEV_NBD=m
436# CONFIG_BLK_DEV_UB is not set
434CONFIG_BLK_DEV_RAM=y 437CONFIG_BLK_DEV_RAM=y
435CONFIG_BLK_DEV_RAM_COUNT=16 438CONFIG_BLK_DEV_RAM_COUNT=16
436CONFIG_BLK_DEV_RAM_SIZE=4096 439CONFIG_BLK_DEV_RAM_SIZE=4096
@@ -623,7 +626,6 @@ CONFIG_SERIAL_NONSTANDARD=y
623# CONFIG_MOXA_SMARTIO is not set 626# CONFIG_MOXA_SMARTIO is not set
624# CONFIG_ISI is not set 627# CONFIG_ISI is not set
625# CONFIG_SYNCLINKMP is not set 628# CONFIG_SYNCLINKMP is not set
626# CONFIG_SYNCLINK_GT is not set
627# CONFIG_N_HDLC is not set 629# CONFIG_N_HDLC is not set
628# CONFIG_RISCOM8 is not set 630# CONFIG_RISCOM8 is not set
629# CONFIG_SPECIALIX is not set 631# CONFIG_SPECIALIX is not set
@@ -686,6 +688,11 @@ CONFIG_S3C2410_WATCHDOG=y
686# CONFIG_PCWATCHDOG is not set 688# CONFIG_PCWATCHDOG is not set
687# CONFIG_MIXCOMWD is not set 689# CONFIG_MIXCOMWD is not set
688# CONFIG_WDT is not set 690# CONFIG_WDT is not set
691
692#
693# USB-based Watchdog Cards
694#
695# CONFIG_USBPCWATCHDOG is not set
689# CONFIG_NVRAM is not set 696# CONFIG_NVRAM is not set
690# CONFIG_RTC is not set 697# CONFIG_RTC is not set
691CONFIG_S3C2410_RTC=y 698CONFIG_S3C2410_RTC=y
@@ -751,6 +758,11 @@ CONFIG_SENSORS_EEPROM=m
751# CONFIG_SPI_MASTER is not set 758# CONFIG_SPI_MASTER is not set
752 759
753# 760#
761# Dallas's 1-wire bus
762#
763# CONFIG_W1 is not set
764
765#
754# Hardware Monitoring support 766# Hardware Monitoring support
755# 767#
756CONFIG_HWMON=y 768CONFIG_HWMON=y
@@ -763,6 +775,7 @@ CONFIG_HWMON_VID=m
763# CONFIG_SENSORS_ASB100 is not set 775# CONFIG_SENSORS_ASB100 is not set
764# CONFIG_SENSORS_ATXP1 is not set 776# CONFIG_SENSORS_ATXP1 is not set
765# CONFIG_SENSORS_DS1621 is not set 777# CONFIG_SENSORS_DS1621 is not set
778# CONFIG_SENSORS_F71805F is not set
766# CONFIG_SENSORS_FSCHER is not set 779# CONFIG_SENSORS_FSCHER is not set
767# CONFIG_SENSORS_FSCPOS is not set 780# CONFIG_SENSORS_FSCPOS is not set
768# CONFIG_SENSORS_GL518SM is not set 781# CONFIG_SENSORS_GL518SM is not set
@@ -850,16 +863,138 @@ CONFIG_FONT_8x16=y
850# 863#
851CONFIG_USB_ARCH_HAS_HCD=y 864CONFIG_USB_ARCH_HAS_HCD=y
852CONFIG_USB_ARCH_HAS_OHCI=y 865CONFIG_USB_ARCH_HAS_OHCI=y
853# CONFIG_USB is not set 866CONFIG_USB=y
867# CONFIG_USB_DEBUG is not set
868
869#
870# Miscellaneous USB options
871#
872CONFIG_USB_DEVICEFS=y
873# CONFIG_USB_BANDWIDTH is not set
874# CONFIG_USB_DYNAMIC_MINORS is not set
875# CONFIG_USB_SUSPEND is not set
876# CONFIG_USB_OTG is not set
877
878#
879# USB Host Controller Drivers
880#
881# CONFIG_USB_ISP116X_HCD is not set
882CONFIG_USB_OHCI_HCD=y
883# CONFIG_USB_OHCI_BIG_ENDIAN is not set
884CONFIG_USB_OHCI_LITTLE_ENDIAN=y
885# CONFIG_USB_SL811_HCD is not set
886
887#
888# USB Device Class drivers
889#
890# CONFIG_USB_ACM is not set
891# CONFIG_USB_PRINTER is not set
854 892
855# 893#
856# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 894# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
857# 895#
858 896
859# 897#
898# may also be needed; see USB_STORAGE Help for more information
899#
900# CONFIG_USB_STORAGE is not set
901# CONFIG_USB_LIBUSUAL is not set
902
903#
904# USB Input Devices
905#
906# CONFIG_USB_HID is not set
907
908#
909# USB HID Boot Protocol drivers
910#
911# CONFIG_USB_KBD is not set
912# CONFIG_USB_MOUSE is not set
913# CONFIG_USB_AIPTEK is not set
914# CONFIG_USB_WACOM is not set
915# CONFIG_USB_ACECAD is not set
916# CONFIG_USB_KBTAB is not set
917# CONFIG_USB_POWERMATE is not set
918# CONFIG_USB_MTOUCH is not set
919# CONFIG_USB_ITMTOUCH is not set
920# CONFIG_USB_EGALAX is not set
921# CONFIG_USB_YEALINK is not set
922# CONFIG_USB_XPAD is not set
923# CONFIG_USB_ATI_REMOTE is not set
924# CONFIG_USB_ATI_REMOTE2 is not set
925# CONFIG_USB_KEYSPAN_REMOTE is not set
926# CONFIG_USB_APPLETOUCH is not set
927
928#
929# USB Imaging devices
930#
931# CONFIG_USB_MDC800 is not set
932
933#
934# USB Multimedia devices
935#
936# CONFIG_USB_DABUSB is not set
937
938#
939# Video4Linux support is needed for USB Multimedia device support
940#
941
942#
943# USB Network Adapters
944#
945# CONFIG_USB_CATC is not set
946# CONFIG_USB_KAWETH is not set
947# CONFIG_USB_PEGASUS is not set
948# CONFIG_USB_RTL8150 is not set
949# CONFIG_USB_USBNET is not set
950CONFIG_USB_MON=y
951
952#
953# USB port drivers
954#
955# CONFIG_USB_USS720 is not set
956
957#
958# USB Serial Converter support
959#
960# CONFIG_USB_SERIAL is not set
961
962#
963# USB Miscellaneous drivers
964#
965# CONFIG_USB_EMI62 is not set
966# CONFIG_USB_EMI26 is not set
967# CONFIG_USB_AUERSWALD is not set
968# CONFIG_USB_RIO500 is not set
969# CONFIG_USB_LEGOTOWER is not set
970# CONFIG_USB_LCD is not set
971# CONFIG_USB_LED is not set
972# CONFIG_USB_CYTHERM is not set
973# CONFIG_USB_PHIDGETKIT is not set
974# CONFIG_USB_PHIDGETSERVO is not set
975# CONFIG_USB_IDMOUSE is not set
976# CONFIG_USB_LD is not set
977# CONFIG_USB_TEST is not set
978
979#
980# USB DSL modem support
981#
982
983#
860# USB Gadget Support 984# USB Gadget Support
861# 985#
862# CONFIG_USB_GADGET is not set 986# CONFIG_USB_GADGET is not set
987# CONFIG_USB_GADGET_NET2280 is not set
988# CONFIG_USB_GADGET_PXA2XX is not set
989# CONFIG_USB_GADGET_GOKU is not set
990# CONFIG_USB_GADGET_LH7A40X is not set
991# CONFIG_USB_GADGET_OMAP is not set
992# CONFIG_USB_GADGET_DUMMY_HCD is not set
993# CONFIG_USB_ZERO is not set
994# CONFIG_USB_ETH is not set
995# CONFIG_USB_GADGETFS is not set
996# CONFIG_USB_FILE_STORAGE is not set
997# CONFIG_USB_G_SERIAL is not set
863 998
864# 999#
865# MMC/SD Card support 1000# MMC/SD Card support
diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
index 766b6c05c6db..2bed290fec76 100644
--- a/arch/arm/kernel/apm.c
+++ b/arch/arm/kernel/apm.c
@@ -357,10 +357,8 @@ static int apm_open(struct inode * inode, struct file * filp)
357{ 357{
358 struct apm_user *as; 358 struct apm_user *as;
359 359
360 as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); 360 as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL);
361 if (as) { 361 if (as) {
362 memset(as, 0, sizeof(*as));
363
364 /* 362 /*
365 * XXX - this is a tiny bit broken, when we consider BSD 363 * XXX - this is a tiny bit broken, when we consider BSD
366 * process accounting. If the device is opened by root, we 364 * process accounting. If the device is opened by root, we
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index c4923fac8dff..de606dfa8db9 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -540,12 +540,10 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
540 int nr, busnr; 540 int nr, busnr;
541 541
542 for (nr = busnr = 0; nr < hw->nr_controllers; nr++) { 542 for (nr = busnr = 0; nr < hw->nr_controllers; nr++) {
543 sys = kmalloc(sizeof(struct pci_sys_data), GFP_KERNEL); 543 sys = kzalloc(sizeof(struct pci_sys_data), GFP_KERNEL);
544 if (!sys) 544 if (!sys)
545 panic("PCI: unable to allocate sys data!"); 545 panic("PCI: unable to allocate sys data!");
546 546
547 memset(sys, 0, sizeof(struct pci_sys_data));
548
549 sys->hw = hw; 547 sys->hw = hw;
550 sys->busnr = busnr; 548 sys->busnr = busnr;
551 sys->swizzle = hw->swizzle; 549 sys->swizzle = hw->swizzle;
diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
index caaa919ab47a..da280bae3d07 100644
--- a/arch/arm/kernel/debug.S
+++ b/arch/arm/kernel/debug.S
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <linux/config.h> 12#include <linux/config.h>
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/hardware.h>
15 14
16 .text 15 .text
17 16
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index 74ea29c3205e..00aa225e8d95 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -807,14 +807,12 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
807 unsigned long base; 807 unsigned long base;
808 int i; 808 int i;
809 809
810 ec = kmalloc(sizeof(ecard_t), GFP_KERNEL); 810 ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
811 if (!ec) { 811 if (!ec) {
812 ec = ERR_PTR(-ENOMEM); 812 ec = ERR_PTR(-ENOMEM);
813 goto nomem; 813 goto nomem;
814 } 814 }
815 815
816 memset(ec, 0, sizeof(ecard_t));
817
818 ec->slot_no = slot; 816 ec->slot_no = slot;
819 ec->type = type; 817 ec->type = type;
820 ec->irq = NO_IRQ; 818 ec->irq = NO_IRQ;
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index ec48d70c6d8b..355914ffb192 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -484,7 +484,6 @@ call_fpe:
484 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1) 484 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
485 bcs iwmmxt_task_enable 485 bcs iwmmxt_task_enable
486#endif 486#endif
487 enable_irq
488 add pc, pc, r8, lsr #6 487 add pc, pc, r8, lsr #6
489 mov r0, r0 488 mov r0, r0
490 489
@@ -511,6 +510,7 @@ call_fpe:
511 mov pc, lr @ CP#15 (Control) 510 mov pc, lr @ CP#15 (Control)
512 511
513do_fpe: 512do_fpe:
513 enable_irq
514 ldr r4, .LCfp 514 ldr r4, .LCfp
515 add r10, r10, #TI_FPSTATE @ r10 = workspace 515 add r10, r10, #TI_FPSTATE @ r10 = workspace
516 ldr pc, [r4] @ Call FP module USR entry point 516 ldr pc, [r4] @ Call FP module USR entry point
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 1aca1775b28f..84277fe818a1 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -28,10 +28,9 @@
28#define PROCINFO_INITFUNC 12 28#define PROCINFO_INITFUNC 12
29 29
30#define MACHINFO_TYPE 0 30#define MACHINFO_TYPE 0
31#define MACHINFO_PHYSRAM 4 31#define MACHINFO_PHYSIO 4
32#define MACHINFO_PHYSIO 8 32#define MACHINFO_PGOFFIO 8
33#define MACHINFO_PGOFFIO 12 33#define MACHINFO_NAME 12
34#define MACHINFO_NAME 16
35 34
36#define KERNEL_RAM_ADDR (PAGE_OFFSET + TEXT_OFFSET) 35#define KERNEL_RAM_ADDR (PAGE_OFFSET + TEXT_OFFSET)
37 36
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 1d50d2b98f55..2d5896b36181 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -305,14 +305,19 @@ report_bad_irq(unsigned int irq, struct pt_regs *regs, struct irqdesc *desc, int
305 static int count = 100; 305 static int count = 100;
306 struct irqaction *action; 306 struct irqaction *action;
307 307
308 if (!count || noirqdebug) 308 if (noirqdebug)
309 return; 309 return;
310 310
311 count--;
312
313 if (ret != IRQ_HANDLED && ret != IRQ_NONE) { 311 if (ret != IRQ_HANDLED && ret != IRQ_NONE) {
312 if (!count)
313 return;
314 count--;
314 printk("irq%u: bogus retval mask %x\n", irq, ret); 315 printk("irq%u: bogus retval mask %x\n", irq, ret);
315 } else { 316 } else {
317 desc->irqs_unhandled++;
318 if (desc->irqs_unhandled <= 99900)
319 return;
320 desc->irqs_unhandled = 0;
316 printk("irq%u: nobody cared\n", irq); 321 printk("irq%u: nobody cared\n", irq);
317 } 322 }
318 show_regs(regs); 323 show_regs(regs);
diff --git a/arch/arm/lib/delay.S b/arch/arm/lib/delay.S
index b3fb475b4120..9183b06c0e2f 100644
--- a/arch/arm/lib/delay.S
+++ b/arch/arm/lib/delay.S
@@ -9,28 +9,32 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/param.h>
12 .text 13 .text
13 14
14.LC0: .word loops_per_jiffy 15.LC0: .word loops_per_jiffy
16.LC1: .word (2199023*HZ)>>11
15 17
16/* 18/*
17 * 0 <= r0 <= 2000 19 * r0 <= 2000
20 * lpj <= 0x01ffffff (max. 3355 bogomips)
21 * HZ <= 1000
18 */ 22 */
23
19ENTRY(__udelay) 24ENTRY(__udelay)
20 mov r2, #0x6800 25 ldr r2, .LC1
21 orr r2, r2, #0x00db
22 mul r0, r2, r0 26 mul r0, r2, r0
23ENTRY(__const_udelay) @ 0 <= r0 <= 0x01ffffff 27ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
24 ldr r2, .LC0 28 ldr r2, .LC0
25 ldr r2, [r2] @ max = 0x0fffffff 29 ldr r2, [r2] @ max = 0x01ffffff
26 mov r0, r0, lsr #11 @ max = 0x00003fff 30 mov r0, r0, lsr #14 @ max = 0x0001ffff
27 mov r2, r2, lsr #11 @ max = 0x0003ffff 31 mov r2, r2, lsr #10 @ max = 0x00007fff
28 mul r0, r2, r0 @ max = 2^32-1 32 mul r0, r2, r0 @ max = 2^32-1
29 movs r0, r0, lsr #6 33 movs r0, r0, lsr #6
30 RETINSTR(moveq,pc,lr) 34 RETINSTR(moveq,pc,lr)
31 35
32/* 36/*
33 * loops = (r0 * 0x10c6 * 100 * loops_per_jiffy) / 2^32 37 * loops = r0 * HZ * loops_per_jiffy / 1000000
34 * 38 *
35 * Oh, if only we had a cycle counter... 39 * Oh, if only we had a cycle counter...
36 */ 40 */
diff --git a/arch/arm/lib/io-acorn.S b/arch/arm/lib/io-acorn.S
index b153523631c3..1b197ea7aab3 100644
--- a/arch/arm/lib/io-acorn.S
+++ b/arch/arm/lib/io-acorn.S
@@ -12,7 +12,6 @@
12 */ 12 */
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/hardware.h>
16 15
17 .text 16 .text
18 .align 17 .align
diff --git a/arch/arm/mach-at91rm9200/clock.c b/arch/arm/mach-at91rm9200/clock.c
index ec8195a2a3cc..8b95467c6d61 100644
--- a/arch/arm/mach-at91rm9200/clock.c
+++ b/arch/arm/mach-at91rm9200/clock.c
@@ -201,6 +201,54 @@ static struct clk ohci_clk = {
201 .pmc_mask = 1 << AT91_ID_UHP, 201 .pmc_mask = 1 << AT91_ID_UHP,
202 .mode = pmc_periph_mode, 202 .mode = pmc_periph_mode,
203}; 203};
204static struct clk ether_clk = {
205 .name = "ether_clk",
206 .parent = &mck,
207 .pmc_mask = 1 << AT91_ID_EMAC,
208 .mode = pmc_periph_mode,
209};
210static struct clk mmc_clk = {
211 .name = "mci_clk",
212 .parent = &mck,
213 .pmc_mask = 1 << AT91_ID_MCI,
214 .mode = pmc_periph_mode,
215};
216static struct clk twi_clk = {
217 .name = "twi_clk",
218 .parent = &mck,
219 .pmc_mask = 1 << AT91_ID_TWI,
220 .mode = pmc_periph_mode,
221};
222static struct clk usart0_clk = {
223 .name = "usart0_clk",
224 .parent = &mck,
225 .pmc_mask = 1 << AT91_ID_US0,
226 .mode = pmc_periph_mode,
227};
228static struct clk usart1_clk = {
229 .name = "usart1_clk",
230 .parent = &mck,
231 .pmc_mask = 1 << AT91_ID_US1,
232 .mode = pmc_periph_mode,
233};
234static struct clk usart2_clk = {
235 .name = "usart2_clk",
236 .parent = &mck,
237 .pmc_mask = 1 << AT91_ID_US2,
238 .mode = pmc_periph_mode,
239};
240static struct clk usart3_clk = {
241 .name = "usart3_clk",
242 .parent = &mck,
243 .pmc_mask = 1 << AT91_ID_US3,
244 .mode = pmc_periph_mode,
245};
246static struct clk spi_clk = {
247 .name = "spi0_clk",
248 .parent = &mck,
249 .pmc_mask = 1 << AT91_ID_SPI,
250 .mode = pmc_periph_mode,
251};
204 252
205static struct clk *const clock_list[] = { 253static struct clk *const clock_list[] = {
206 /* four primary clocks -- MUST BE FIRST! */ 254 /* four primary clocks -- MUST BE FIRST! */
@@ -223,15 +271,18 @@ static struct clk *const clock_list[] = {
223 271
224 /* MCK and peripherals */ 272 /* MCK and peripherals */
225 &mck, 273 &mck,
226 // usart0..usart3 274 &usart0_clk,
227 // mmc 275 &usart1_clk,
276 &usart2_clk,
277 &usart3_clk,
278 &mmc_clk,
228 &udc_clk, 279 &udc_clk,
229 // i2c 280 &twi_clk,
230 // spi 281 &spi_clk,
231 // ssc0..ssc2 282 // ssc0..ssc2
232 // tc0..tc5 283 // tc0..tc5
233 &ohci_clk, 284 &ohci_clk,
234 // ether 285 &ether_clk,
235}; 286};
236 287
237 288
@@ -360,7 +411,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
360 u32 pckr; 411 u32 pckr;
361 412
362 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); 413 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
363 pckr &= 0x03; 414 pckr &= AT91_PMC_CSS_PLLB; /* clock selection */
364 pckr |= prescale << 2; 415 pckr |= prescale << 2;
365 at91_sys_write(AT91_PMC_PCKR(clk->id), pckr); 416 at91_sys_write(AT91_PMC_PCKR(clk->id), pckr);
366 clk->rate_hz = actual; 417 clk->rate_hz = actual;
@@ -440,7 +491,7 @@ static int at91_clk_show(struct seq_file *s, void *unused)
440 else 491 else
441 state = ""; 492 state = "";
442 493
443 seq_printf(s, "%-10s users=%d %-3s %9ld Hz %s\n", 494 seq_printf(s, "%-10s users=%2d %-3s %9ld Hz %s\n",
444 clk->name, clk->users, state, clk_get_rate(clk), 495 clk->name, clk->users, state, clk_get_rate(clk),
445 clk->parent ? clk->parent->name : ""); 496 clk->parent ? clk->parent->name : "");
446 } 497 }
@@ -483,11 +534,18 @@ static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg)
483 freq *= mul + 1; 534 freq *= mul + 1;
484 } else 535 } else
485 freq = 0; 536 freq = 0;
486 if (pll == &pllb && (reg & (1 << 28))) 537
487 freq /= 2;
488 return freq; 538 return freq;
489} 539}
490 540
541static u32 __init at91_usb_rate(struct clk *pll, u32 freq, u32 reg)
542{
543 if (pll == &pllb && (reg & AT91_PMC_USB96M))
544 return freq / 2;
545 else
546 return freq;
547}
548
491static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq) 549static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq)
492{ 550{
493 unsigned i, div = 0, mul = 0, diff = 1 << 30; 551 unsigned i, div = 0, mul = 0, diff = 1 << 30;
@@ -550,8 +608,8 @@ int __init at91_clock_init(unsigned long main_clock)
550 if (!main_clock) { 608 if (!main_clock) {
551 do { 609 do {
552 tmp = at91_sys_read(AT91_CKGR_MCFR); 610 tmp = at91_sys_read(AT91_CKGR_MCFR);
553 } while (!(tmp & 0x10000)); 611 } while (!(tmp & AT91_PMC_MAINRDY));
554 main_clock = (tmp & 0xffff) * (AT91_SLOW_CLOCK / 16); 612 main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
555 } 613 }
556 main_clk.rate_hz = main_clock; 614 main_clk.rate_hz = main_clock;
557 615
@@ -566,13 +624,16 @@ int __init at91_clock_init(unsigned long main_clock)
566 * 624 *
567 * REVISIT: assumes MCK doesn't derive from PLLB! 625 * REVISIT: assumes MCK doesn't derive from PLLB!
568 */ 626 */
569 at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | 0x10000000; 627 at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M;
570 pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init); 628 pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init);
571 at91_sys_write(AT91_PMC_PCDR, (1 << AT91_ID_UHP) | (1 << AT91_ID_UDP)); 629 at91_sys_write(AT91_PMC_PCDR, (1 << AT91_ID_UHP) | (1 << AT91_ID_UDP));
572 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_UHP | AT91_PMC_UDP); 630 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_UHP | AT91_PMC_UDP);
573 at91_sys_write(AT91_CKGR_PLLBR, 0); 631 at91_sys_write(AT91_CKGR_PLLBR, 0);
574 at91_sys_write(AT91_PMC_SCER, AT91_PMC_MCKUDP); 632 at91_sys_write(AT91_PMC_SCER, AT91_PMC_MCKUDP);
575 633
634 udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
635 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
636
576 /* 637 /*
577 * MCK and CPU derive from one of those primary clocks. 638 * MCK and CPU derive from one of those primary clocks.
578 * For now, assume this parentage won't change. 639 * For now, assume this parentage won't change.
diff --git a/arch/arm/mach-at91rm9200/gpio.c b/arch/arm/mach-at91rm9200/gpio.c
index 0e396feec468..5ab46274e1a3 100644
--- a/arch/arm/mach-at91rm9200/gpio.c
+++ b/arch/arm/mach-at91rm9200/gpio.c
@@ -261,7 +261,7 @@ static void gpio_irq_handler(unsigned irq, struct irqdesc *desc, struct pt_regs
261 void __iomem *pio; 261 void __iomem *pio;
262 u32 isr; 262 u32 isr;
263 263
264 pio = (void __force __iomem *) desc->chipdata; 264 pio = desc->base;
265 265
266 /* temporarily mask (level sensitive) parent IRQ */ 266 /* temporarily mask (level sensitive) parent IRQ */
267 desc->chip->ack(irq); 267 desc->chip->ack(irq);
@@ -312,7 +312,7 @@ void __init at91_gpio_irq_setup(unsigned banks)
312 __raw_writel(~0, controller + PIO_IDR); 312 __raw_writel(~0, controller + PIO_IDR);
313 313
314 set_irq_data(id, (void *) pin); 314 set_irq_data(id, (void *) pin);
315 set_irq_chipdata(id, (void __force *) controller); 315 set_irq_chipdata(id, controller);
316 316
317 for (i = 0; i < 32; i++, pin++) { 317 for (i = 0; i < 32; i++, pin++) {
318 set_irq_chip(pin, &gpio_irqchip); 318 set_irq_chip(pin, &gpio_irqchip);
diff --git a/arch/arm/mach-at91rm9200/time.c b/arch/arm/mach-at91rm9200/time.c
index 1b6dd2deeb22..7ffcf443b99f 100644
--- a/arch/arm/mach-at91rm9200/time.c
+++ b/arch/arm/mach-at91rm9200/time.c
@@ -71,11 +71,11 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id, struct pt_r
71 if (at91_sys_read(AT91_ST_SR) & AT91_ST_PITS) { /* This is a shared interrupt */ 71 if (at91_sys_read(AT91_ST_SR) & AT91_ST_PITS) { /* This is a shared interrupt */
72 write_seqlock(&xtime_lock); 72 write_seqlock(&xtime_lock);
73 73
74 do { 74 while (((read_CRTR() - at91_sys_read(AT91_ST_RTAR)) & AT91_ST_ALMV) >= LATCH) {
75 timer_tick(regs); 75 timer_tick(regs);
76 rtar = (at91_sys_read(AT91_ST_RTAR) + LATCH) & AT91_ST_ALMV; 76 rtar = (at91_sys_read(AT91_ST_RTAR) + LATCH) & AT91_ST_ALMV;
77 at91_sys_write(AT91_ST_RTAR, rtar); 77 at91_sys_write(AT91_ST_RTAR, rtar);
78 } while (((read_CRTR() - at91_sys_read(AT91_ST_RTAR)) & AT91_ST_ALMV) >= LATCH); 78 }
79 79
80 write_sequnlock(&xtime_lock); 80 write_sequnlock(&xtime_lock);
81 81
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
new file mode 100644
index 000000000000..cec5a21ca4e3
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -0,0 +1,21 @@
1if ARCH_EP93XX
2
3menu "Cirrus EP93xx Implementation Options"
4
5comment "EP93xx Platforms"
6
7config MACH_GESBC9312
8 bool "Support Glomation GESBC-9312-sx"
9 help
10 Say 'Y' here if you want your kernel to support the Glomation
11 GESBC-9312-sx board.
12
13config MACH_TS72XX
14 bool "Support Technologic Systems TS-72xx SBC"
15 help
16 Say 'Y' here if you want your kernel to support the
17 Technologic Systems TS-72xx board.
18
19endmenu
20
21endif
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
new file mode 100644
index 000000000000..5393af989e94
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -0,0 +1,10 @@
1#
2# Makefile for the linux kernel.
3#
4obj-y := core.o
5obj-m :=
6obj-n :=
7obj- :=
8
9obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o
10obj-$(CONFIG_MACH_TS72XX) += ts72xx.o
diff --git a/arch/arm/mach-ep93xx/Makefile.boot b/arch/arm/mach-ep93xx/Makefile.boot
new file mode 100644
index 000000000000..d5561ad15bad
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Makefile.boot
@@ -0,0 +1,2 @@
1 zreladdr-y := 0x00008000
2params_phys-y := 0x00000100
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
new file mode 100644
index 000000000000..865427bfad7e
--- /dev/null
+++ b/arch/arm/mach-ep93xx/core.c
@@ -0,0 +1,374 @@
1/*
2 * arch/arm/mach-ep93xx/core.c
3 * Core routines for Cirrus EP93xx chips.
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * Thanks go to Michael Burian and Ray Lehtiniemi for their key
8 * role in the ep93xx linux community.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
14 */
15
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/spinlock.h>
20#include <linux/sched.h>
21#include <linux/interrupt.h>
22#include <linux/serial.h>
23#include <linux/tty.h>
24#include <linux/bitops.h>
25#include <linux/serial.h>
26#include <linux/serial_8250.h>
27#include <linux/serial_core.h>
28#include <linux/device.h>
29#include <linux/mm.h>
30#include <linux/time.h>
31#include <linux/timex.h>
32#include <linux/delay.h>
33#include <linux/amba/bus.h>
34
35#include <asm/types.h>
36#include <asm/setup.h>
37#include <asm/memory.h>
38#include <asm/hardware.h>
39#include <asm/irq.h>
40#include <asm/system.h>
41#include <asm/tlbflush.h>
42#include <asm/pgtable.h>
43#include <asm/io.h>
44
45#include <asm/mach/map.h>
46#include <asm/mach/time.h>
47#include <asm/mach/irq.h>
48#include <asm/arch/gpio.h>
49
50#include <asm/hardware/vic.h>
51
52
53/*************************************************************************
54 * Static I/O mappings that are needed for all EP93xx platforms
55 *************************************************************************/
56static struct map_desc ep93xx_io_desc[] __initdata = {
57 {
58 .virtual = EP93XX_AHB_VIRT_BASE,
59 .pfn = __phys_to_pfn(EP93XX_AHB_PHYS_BASE),
60 .length = EP93XX_AHB_SIZE,
61 .type = MT_DEVICE,
62 }, {
63 .virtual = EP93XX_APB_VIRT_BASE,
64 .pfn = __phys_to_pfn(EP93XX_APB_PHYS_BASE),
65 .length = EP93XX_APB_SIZE,
66 .type = MT_DEVICE,
67 },
68};
69
70void __init ep93xx_map_io(void)
71{
72 iotable_init(ep93xx_io_desc, ARRAY_SIZE(ep93xx_io_desc));
73}
74
75
76/*************************************************************************
77 * Timer handling for EP93xx
78 *************************************************************************
79 * The ep93xx has four internal timers. Timers 1, 2 (both 16 bit) and
80 * 3 (32 bit) count down at 508 kHz, are self-reloading, and can generate
81 * an interrupt on underflow. Timer 4 (40 bit) counts down at 983.04 kHz,
82 * is free-running, and can't generate interrupts.
83 *
84 * The 508 kHz timers are ideal for use for the timer interrupt, as the
85 * most common values of HZ divide 508 kHz nicely. We pick one of the 16
86 * bit timers (timer 1) since we don't need more than 16 bits of reload
87 * value as long as HZ >= 8.
88 *
89 * The higher clock rate of timer 4 makes it a better choice than the
90 * other timers for use in gettimeoffset(), while the fact that it can't
91 * generate interrupts means we don't have to worry about not being able
92 * to use this timer for something else. We also use timer 4 for keeping
93 * track of lost jiffies.
94 */
95static unsigned int last_jiffy_time;
96
97#define TIMER4_TICKS_PER_JIFFY ((CLOCK_TICK_RATE + (HZ/2)) / HZ)
98
99static int ep93xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
100{
101 write_seqlock(&xtime_lock);
102
103 __raw_writel(1, EP93XX_TIMER1_CLEAR);
104 while (__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time
105 >= TIMER4_TICKS_PER_JIFFY) {
106 last_jiffy_time += TIMER4_TICKS_PER_JIFFY;
107 timer_tick(regs);
108 }
109
110 write_sequnlock(&xtime_lock);
111
112 return IRQ_HANDLED;
113}
114
115static struct irqaction ep93xx_timer_irq = {
116 .name = "ep93xx timer",
117 .flags = SA_INTERRUPT | SA_TIMER,
118 .handler = ep93xx_timer_interrupt,
119};
120
121static void __init ep93xx_timer_init(void)
122{
123 /* Enable periodic HZ timer. */
124 __raw_writel(0x48, EP93XX_TIMER1_CONTROL);
125 __raw_writel((508000 / HZ) - 1, EP93XX_TIMER1_LOAD);
126 __raw_writel(0xc8, EP93XX_TIMER1_CONTROL);
127
128 /* Enable lost jiffy timer. */
129 __raw_writel(0x100, EP93XX_TIMER4_VALUE_HIGH);
130
131 setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
132}
133
134static unsigned long ep93xx_gettimeoffset(void)
135{
136 int offset;
137
138 offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
139
140 /* Calculate (1000000 / 983040) * offset. */
141 return offset + (53 * offset / 3072);
142}
143
144struct sys_timer ep93xx_timer = {
145 .init = ep93xx_timer_init,
146 .offset = ep93xx_gettimeoffset,
147};
148
149
150/*************************************************************************
151 * GPIO handling for EP93xx
152 *************************************************************************/
153static unsigned char gpio_int_enable[2];
154static unsigned char gpio_int_type1[2];
155static unsigned char gpio_int_type2[2];
156
157static void update_gpio_ab_int_params(int port)
158{
159 if (port == 0) {
160 __raw_writeb(0, EP93XX_GPIO_A_INT_ENABLE);
161 __raw_writeb(gpio_int_type2[0], EP93XX_GPIO_A_INT_TYPE2);
162 __raw_writeb(gpio_int_type1[0], EP93XX_GPIO_A_INT_TYPE1);
163 __raw_writeb(gpio_int_enable[0], EP93XX_GPIO_A_INT_ENABLE);
164 } else if (port == 1) {
165 __raw_writeb(0, EP93XX_GPIO_B_INT_ENABLE);
166 __raw_writeb(gpio_int_type2[1], EP93XX_GPIO_B_INT_TYPE2);
167 __raw_writeb(gpio_int_type1[1], EP93XX_GPIO_B_INT_TYPE1);
168 __raw_writeb(gpio_int_enable[1], EP93XX_GPIO_B_INT_ENABLE);
169 }
170}
171
172
173static unsigned char data_register_offset[8] = {
174 0x00, 0x04, 0x08, 0x0c, 0x20, 0x30, 0x38, 0x40,
175};
176
177static unsigned char data_direction_register_offset[8] = {
178 0x10, 0x14, 0x18, 0x1c, 0x24, 0x34, 0x3c, 0x44,
179};
180
181void gpio_line_config(int line, int direction)
182{
183 unsigned int data_direction_register;
184 unsigned long flags;
185 unsigned char v;
186
187 data_direction_register =
188 EP93XX_GPIO_REG(data_direction_register_offset[line >> 3]);
189
190 local_irq_save(flags);
191 if (direction == GPIO_OUT) {
192 if (line >= 0 && line < 16) {
193 gpio_int_enable[line >> 3] &= ~(1 << (line & 7));
194 update_gpio_ab_int_params(line >> 3);
195 }
196
197 v = __raw_readb(data_direction_register);
198 v |= 1 << (line & 7);
199 __raw_writeb(v, data_direction_register);
200 } else if (direction == GPIO_IN) {
201 v = __raw_readb(data_direction_register);
202 v &= ~(1 << (line & 7));
203 __raw_writeb(v, data_direction_register);
204 }
205 local_irq_restore(flags);
206}
207EXPORT_SYMBOL(gpio_line_config);
208
209int gpio_line_get(int line)
210{
211 unsigned int data_register;
212
213 data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]);
214
215 return !!(__raw_readb(data_register) & (1 << (line & 7)));
216}
217EXPORT_SYMBOL(gpio_line_get);
218
219void gpio_line_set(int line, int value)
220{
221 unsigned int data_register;
222 unsigned long flags;
223 unsigned char v;
224
225 data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]);
226
227 local_irq_save(flags);
228 if (value == EP93XX_GPIO_HIGH) {
229 v = __raw_readb(data_register);
230 v |= 1 << (line & 7);
231 __raw_writeb(v, data_register);
232 } else if (value == EP93XX_GPIO_LOW) {
233 v = __raw_readb(data_register);
234 v &= ~(1 << (line & 7));
235 __raw_writeb(v, data_register);
236 }
237 local_irq_restore(flags);
238}
239EXPORT_SYMBOL(gpio_line_set);
240
241
242/*************************************************************************
243 * EP93xx IRQ handling
244 *************************************************************************/
245static void ep93xx_gpio_ab_irq_handler(unsigned int irq,
246 struct irqdesc *desc, struct pt_regs *regs)
247{
248 unsigned char status;
249 int i;
250
251 status = __raw_readb(EP93XX_GPIO_A_INT_STATUS);
252 for (i = 0; i < 8; i++) {
253 if (status & (1 << i)) {
254 desc = irq_desc + IRQ_EP93XX_GPIO(0) + i;
255 desc_handle_irq(IRQ_EP93XX_GPIO(0) + i, desc, regs);
256 }
257 }
258
259 status = __raw_readb(EP93XX_GPIO_B_INT_STATUS);
260 for (i = 0; i < 8; i++) {
261 if (status & (1 << i)) {
262 desc = irq_desc + IRQ_EP93XX_GPIO(8) + i;
263 desc_handle_irq(IRQ_EP93XX_GPIO(8) + i, desc, regs);
264 }
265 }
266}
267
268static void ep93xx_gpio_ab_irq_mask_ack(unsigned int irq)
269{
270 int line = irq - IRQ_EP93XX_GPIO(0);
271 int port = line >> 3;
272
273 gpio_int_enable[port] &= ~(1 << (line & 7));
274 update_gpio_ab_int_params(port);
275
276 if (line >> 3) {
277 __raw_writel(1 << (line & 7), EP93XX_GPIO_B_INT_ACK);
278 } else {
279 __raw_writel(1 << (line & 7), EP93XX_GPIO_A_INT_ACK);
280 }
281}
282
283static void ep93xx_gpio_ab_irq_mask(unsigned int irq)
284{
285 int line = irq - IRQ_EP93XX_GPIO(0);
286 int port = line >> 3;
287
288 gpio_int_enable[port] &= ~(1 << (line & 7));
289 update_gpio_ab_int_params(port);
290}
291
292static void ep93xx_gpio_ab_irq_unmask(unsigned int irq)
293{
294 int line = irq - IRQ_EP93XX_GPIO(0);
295 int port = line >> 3;
296
297 gpio_int_enable[port] |= 1 << (line & 7);
298 update_gpio_ab_int_params(port);
299}
300
301
302/*
303 * gpio_int_type1 controls whether the interrupt is level (0) or
304 * edge (1) triggered, while gpio_int_type2 controls whether it
305 * triggers on low/falling (0) or high/rising (1).
306 */
307static int ep93xx_gpio_ab_irq_type(unsigned int irq, unsigned int type)
308{
309 int port;
310 int line;
311
312 line = irq - IRQ_EP93XX_GPIO(0);
313 gpio_line_config(line, GPIO_IN);
314
315 port = line >> 3;
316 line &= 7;
317
318 if (type & IRQT_RISING) {
319 gpio_int_type1[port] |= 1 << line;
320 gpio_int_type2[port] |= 1 << line;
321 } else if (type & IRQT_FALLING) {
322 gpio_int_type1[port] |= 1 << line;
323 gpio_int_type2[port] &= ~(1 << line);
324 } else if (type & IRQT_HIGH) {
325 gpio_int_type1[port] &= ~(1 << line);
326 gpio_int_type2[port] |= 1 << line;
327 } else if (type & IRQT_LOW) {
328 gpio_int_type1[port] &= ~(1 << line);
329 gpio_int_type2[port] &= ~(1 << line);
330 }
331 update_gpio_ab_int_params(port);
332
333 return 0;
334}
335
336static struct irqchip ep93xx_gpio_ab_irq_chip = {
337 .ack = ep93xx_gpio_ab_irq_mask_ack,
338 .mask = ep93xx_gpio_ab_irq_mask,
339 .unmask = ep93xx_gpio_ab_irq_unmask,
340 .set_type = ep93xx_gpio_ab_irq_type,
341};
342
343
344void __init ep93xx_init_irq(void)
345{
346 int irq;
347
348 vic_init((void *)EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK);
349 vic_init((void *)EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK);
350
351 for (irq = IRQ_EP93XX_GPIO(0) ; irq <= IRQ_EP93XX_GPIO(15); irq++) {
352 set_irq_chip(irq, &ep93xx_gpio_ab_irq_chip);
353 set_irq_handler(irq, do_level_IRQ);
354 set_irq_flags(irq, IRQF_VALID);
355 }
356 set_irq_chained_handler(IRQ_EP93XX_GPIO_AB, ep93xx_gpio_ab_irq_handler);
357}
358
359
360/*************************************************************************
361 * EP93xx peripheral handling
362 *************************************************************************/
363void __init ep93xx_init_devices(void)
364{
365 unsigned int v;
366
367 /*
368 * Disallow access to MaverickCrunch initially.
369 */
370 v = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
371 v &= ~EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE;
372 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
373 __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG);
374}
diff --git a/arch/arm/mach-ep93xx/gesbc9312.c b/arch/arm/mach-ep93xx/gesbc9312.c
new file mode 100644
index 000000000000..d18fcb1a2f1b
--- /dev/null
+++ b/arch/arm/mach-ep93xx/gesbc9312.c
@@ -0,0 +1,40 @@
1/*
2 * arch/arm/mach-ep93xx/gesbc9312.c
3 * Glomation GESBC-9312-sx support.
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/mm.h>
17#include <linux/sched.h>
18#include <linux/interrupt.h>
19#include <linux/mtd/physmap.h>
20#include <asm/io.h>
21#include <asm/hardware.h>
22#include <asm/mach-types.h>
23#include <asm/mach/arch.h>
24
25static void __init gesbc9312_init_machine(void)
26{
27 ep93xx_init_devices();
28 physmap_configure(0x60000000, 0x00800000, 4, NULL);
29}
30
31MACHINE_START(GESBC9312, "Glomation GESBC-9312-sx")
32 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
33 .phys_io = EP93XX_APB_PHYS_BASE,
34 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
35 .boot_params = 0x00000100,
36 .map_io = ep93xx_map_io,
37 .init_irq = ep93xx_init_irq,
38 .timer = &ep93xx_timer,
39 .init_machine = gesbc9312_init_machine,
40MACHINE_END
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
new file mode 100644
index 000000000000..777e75daa8a5
--- /dev/null
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -0,0 +1,118 @@
1/*
2 * arch/arm/mach-ep93xx/ts72xx.c
3 * Technologic Systems TS72xx SBC support.
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/mm.h>
17#include <linux/sched.h>
18#include <linux/interrupt.h>
19#include <linux/mtd/physmap.h>
20#include <asm/io.h>
21#include <asm/hardware.h>
22#include <asm/mach-types.h>
23#include <asm/mach/arch.h>
24#include <asm/mach/map.h>
25
26static struct map_desc ts72xx_io_desc[] __initdata = {
27 {
28 .virtual = TS72XX_MODEL_VIRT_BASE,
29 .pfn = __phys_to_pfn(TS72XX_MODEL_PHYS_BASE),
30 .length = TS72XX_MODEL_SIZE,
31 .type = MT_DEVICE,
32 }, {
33 .virtual = TS72XX_OPTIONS_VIRT_BASE,
34 .pfn = __phys_to_pfn(TS72XX_OPTIONS_PHYS_BASE),
35 .length = TS72XX_OPTIONS_SIZE,
36 .type = MT_DEVICE,
37 }, {
38 .virtual = TS72XX_OPTIONS2_VIRT_BASE,
39 .pfn = __phys_to_pfn(TS72XX_OPTIONS2_PHYS_BASE),
40 .length = TS72XX_OPTIONS2_SIZE,
41 .type = MT_DEVICE,
42 }
43};
44
45static struct map_desc ts72xx_nand_io_desc[] __initdata = {
46 {
47 .virtual = TS72XX_NAND_DATA_VIRT_BASE,
48 .pfn = __phys_to_pfn(TS72XX_NAND1_DATA_PHYS_BASE),
49 .length = TS72XX_NAND_DATA_SIZE,
50 .type = MT_DEVICE,
51 }, {
52 .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
53 .pfn = __phys_to_pfn(TS72XX_NAND1_CONTROL_PHYS_BASE),
54 .length = TS72XX_NAND_CONTROL_SIZE,
55 .type = MT_DEVICE,
56 }, {
57 .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
58 .pfn = __phys_to_pfn(TS72XX_NAND1_BUSY_PHYS_BASE),
59 .length = TS72XX_NAND_BUSY_SIZE,
60 .type = MT_DEVICE,
61 }
62};
63
64static struct map_desc ts72xx_alternate_nand_io_desc[] __initdata = {
65 {
66 .virtual = TS72XX_NAND_DATA_VIRT_BASE,
67 .pfn = __phys_to_pfn(TS72XX_NAND2_DATA_PHYS_BASE),
68 .length = TS72XX_NAND_DATA_SIZE,
69 .type = MT_DEVICE,
70 }, {
71 .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
72 .pfn = __phys_to_pfn(TS72XX_NAND2_CONTROL_PHYS_BASE),
73 .length = TS72XX_NAND_CONTROL_SIZE,
74 .type = MT_DEVICE,
75 }, {
76 .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
77 .pfn = __phys_to_pfn(TS72XX_NAND2_BUSY_PHYS_BASE),
78 .length = TS72XX_NAND_BUSY_SIZE,
79 .type = MT_DEVICE,
80 }
81};
82
83static void __init ts72xx_map_io(void)
84{
85 ep93xx_map_io();
86 iotable_init(ts72xx_io_desc, ARRAY_SIZE(ts72xx_io_desc));
87
88 /*
89 * The TS-7200 has NOR flash, the other models have NAND flash.
90 */
91 if (!board_is_ts7200()) {
92 if (is_ts9420_installed()) {
93 iotable_init(ts72xx_alternate_nand_io_desc,
94 ARRAY_SIZE(ts72xx_alternate_nand_io_desc));
95 } else {
96 iotable_init(ts72xx_nand_io_desc,
97 ARRAY_SIZE(ts72xx_nand_io_desc));
98 }
99 }
100}
101
102static void __init ts72xx_init_machine(void)
103{
104 ep93xx_init_devices();
105 if (board_is_ts7200())
106 physmap_configure(TS72XX_NOR_PHYS_BASE, 0x01000000, 1, NULL);
107}
108
109MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
110 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
111 .phys_io = EP93XX_APB_PHYS_BASE,
112 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
113 .boot_params = 0x00000100,
114 .map_io = ts72xx_map_io,
115 .init_irq = ep93xx_init_irq,
116 .timer = &ep93xx_timer,
117 .init_machine = ts72xx_init_machine,
118MACHINE_END
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index e79884eea1f7..5dace2597838 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -255,14 +255,12 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
255 if (nr || !footbridge_cfn_mode()) 255 if (nr || !footbridge_cfn_mode())
256 return 0; 256 return 0;
257 257
258 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); 258 res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
259 if (!res) { 259 if (!res) {
260 printk("out of memory for root bus resources"); 260 printk("out of memory for root bus resources");
261 return 0; 261 return 0;
262 } 262 }
263 263
264 memset(res, 0, sizeof(struct resource) * 2);
265
266 res[0].flags = IORESOURCE_MEM; 264 res[0].flags = IORESOURCE_MEM;
267 res[0].name = "Footbridge non-prefetch"; 265 res[0].name = "Footbridge non-prefetch";
268 res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; 266 res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index a85d471c5bfa..92d79fb39311 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -355,12 +355,11 @@ static int impd1_probe(struct lm_device *dev)
355 if (!request_mem_region(dev->resource.start, SZ_4K, "LM registers")) 355 if (!request_mem_region(dev->resource.start, SZ_4K, "LM registers"))
356 return -EBUSY; 356 return -EBUSY;
357 357
358 impd1 = kmalloc(sizeof(struct impd1_module), GFP_KERNEL); 358 impd1 = kzalloc(sizeof(struct impd1_module), GFP_KERNEL);
359 if (!impd1) { 359 if (!impd1) {
360 ret = -ENOMEM; 360 ret = -ENOMEM;
361 goto release_lm; 361 goto release_lm;
362 } 362 }
363 memset(impd1, 0, sizeof(struct impd1_module));
364 363
365 impd1->base = ioremap(dev->resource.start, SZ_4K); 364 impd1->base = ioremap(dev->resource.start, SZ_4K);
366 if (!impd1->base) { 365 if (!impd1->base) {
@@ -389,12 +388,10 @@ static int impd1_probe(struct lm_device *dev)
389 388
390 pc_base = dev->resource.start + idev->offset; 389 pc_base = dev->resource.start + idev->offset;
391 390
392 d = kmalloc(sizeof(struct amba_device), GFP_KERNEL); 391 d = kzalloc(sizeof(struct amba_device), GFP_KERNEL);
393 if (!d) 392 if (!d)
394 continue; 393 continue;
395 394
396 memset(d, 0, sizeof(struct amba_device));
397
398 snprintf(d->dev.bus_id, sizeof(d->dev.bus_id), 395 snprintf(d->dev.bus_id, sizeof(d->dev.bus_id),
399 "lm%x:%5.5lx", dev->id, idev->offset >> 12); 396 "lm%x:%5.5lx", dev->id, idev->offset >> 12);
400 397
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index d8d3c2a5a97e..6d65c96ebfd2 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -319,12 +319,10 @@ static void __init ap_init(void)
319 if ((sc_dec & (16 << i)) == 0) 319 if ((sc_dec & (16 << i)) == 0)
320 continue; 320 continue;
321 321
322 lmdev = kmalloc(sizeof(struct lm_device), GFP_KERNEL); 322 lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
323 if (!lmdev) 323 if (!lmdev)
324 continue; 324 continue;
325 325
326 memset(lmdev, 0, sizeof(struct lm_device));
327
328 lmdev->resource.start = 0xc0000000 + 0x10000000 * i; 326 lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
329 lmdev->resource.end = lmdev->resource.start + 0x0fffffff; 327 lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
330 lmdev->resource.flags = IORESOURCE_MEM; 328 lmdev->resource.flags = IORESOURCE_MEM;
diff --git a/arch/arm/mach-iop3xx/iq31244-pci.c b/arch/arm/mach-iop3xx/iq31244-pci.c
index c6a973ba8fc6..f3c6413fa5bd 100644
--- a/arch/arm/mach-iop3xx/iq31244-pci.c
+++ b/arch/arm/mach-iop3xx/iq31244-pci.c
@@ -74,12 +74,10 @@ static int iq31244_setup(int nr, struct pci_sys_data *sys)
74 if(nr != 0) 74 if(nr != 0)
75 return 0; 75 return 0;
76 76
77 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); 77 res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
78 if (!res) 78 if (!res)
79 panic("PCI: unable to alloc resources"); 79 panic("PCI: unable to alloc resources");
80 80
81 memset(res, 0, sizeof(struct resource) * 2);
82
83 res[0].start = IOP321_PCI_LOWER_IO_VA; 81 res[0].start = IOP321_PCI_LOWER_IO_VA;
84 res[0].end = IOP321_PCI_UPPER_IO_VA; 82 res[0].end = IOP321_PCI_UPPER_IO_VA;
85 res[0].name = "IQ31244 PCI I/O Space"; 83 res[0].name = "IQ31244 PCI I/O Space";
diff --git a/arch/arm/mach-iop3xx/iq80321-pci.c b/arch/arm/mach-iop3xx/iq80321-pci.c
index 802f6d091b75..d9758d3f6e7f 100644
--- a/arch/arm/mach-iop3xx/iq80321-pci.c
+++ b/arch/arm/mach-iop3xx/iq80321-pci.c
@@ -68,12 +68,10 @@ static int iq80321_setup(int nr, struct pci_sys_data *sys)
68 if(nr != 0) 68 if(nr != 0)
69 return 0; 69 return 0;
70 70
71 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); 71 res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
72 if (!res) 72 if (!res)
73 panic("PCI: unable to alloc resources"); 73 panic("PCI: unable to alloc resources");
74 74
75 memset(res, 0, sizeof(struct resource) * 2);
76
77 res[0].start = IOP321_PCI_LOWER_IO_VA; 75 res[0].start = IOP321_PCI_LOWER_IO_VA;
78 res[0].end = IOP321_PCI_UPPER_IO_VA; 76 res[0].end = IOP321_PCI_UPPER_IO_VA;
79 res[0].name = "IQ80321 PCI I/O Space"; 77 res[0].name = "IQ80321 PCI I/O Space";
diff --git a/arch/arm/mach-iop3xx/iq80331-pci.c b/arch/arm/mach-iop3xx/iq80331-pci.c
index 654e450a1311..40d861002492 100644
--- a/arch/arm/mach-iop3xx/iq80331-pci.c
+++ b/arch/arm/mach-iop3xx/iq80331-pci.c
@@ -64,12 +64,10 @@ static int iq80331_setup(int nr, struct pci_sys_data *sys)
64 if(nr != 0) 64 if(nr != 0)
65 return 0; 65 return 0;
66 66
67 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); 67 res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
68 if (!res) 68 if (!res)
69 panic("PCI: unable to alloc resources"); 69 panic("PCI: unable to alloc resources");
70 70
71 memset(res, 0, sizeof(struct resource) * 2);
72
73 res[0].start = IOP331_PCI_LOWER_IO_VA; 71 res[0].start = IOP331_PCI_LOWER_IO_VA;
74 res[0].end = IOP331_PCI_UPPER_IO_VA; 72 res[0].end = IOP331_PCI_UPPER_IO_VA;
75 res[0].name = "IQ80331 PCI I/O Space"; 73 res[0].name = "IQ80331 PCI I/O Space";
diff --git a/arch/arm/mach-iop3xx/iq80332-pci.c b/arch/arm/mach-iop3xx/iq80332-pci.c
index 65951ffe4631..afc0676318e4 100644
--- a/arch/arm/mach-iop3xx/iq80332-pci.c
+++ b/arch/arm/mach-iop3xx/iq80332-pci.c
@@ -70,12 +70,10 @@ static int iq80332_setup(int nr, struct pci_sys_data *sys)
70 if(nr != 0) 70 if(nr != 0)
71 return 0; 71 return 0;
72 72
73 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); 73 res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
74 if (!res) 74 if (!res)
75 panic("PCI: unable to alloc resources"); 75 panic("PCI: unable to alloc resources");
76 76
77 memset(res, 0, sizeof(struct resource) * 2);
78
79 res[0].start = IOP331_PCI_LOWER_IO_VA; 77 res[0].start = IOP331_PCI_LOWER_IO_VA;
80 res[0].end = IOP331_PCI_UPPER_IO_VA; 78 res[0].end = IOP331_PCI_UPPER_IO_VA;
81 res[0].name = "IQ80332 PCI I/O Space"; 79 res[0].name = "IQ80332 PCI I/O Space";
diff --git a/arch/arm/mach-ixp2000/Kconfig b/arch/arm/mach-ixp2000/Kconfig
index ecb58d83478e..86f53f8ccbf5 100644
--- a/arch/arm/mach-ixp2000/Kconfig
+++ b/arch/arm/mach-ixp2000/Kconfig
@@ -43,12 +43,17 @@ config ARCH_IXDP2401
43 this platform, see <file:Documentation/arm/IXP2000>. 43 this platform, see <file:Documentation/arm/IXP2000>.
44 44
45config ARCH_IXDP2801 45config ARCH_IXDP2801
46 bool "Support Intel IXDP2801" 46 bool "Support Intel IXDP2801 and IXDP28x5"
47 help 47 help
48 Say 'Y' here if you want your kernel to support the Intel 48 Say 'Y' here if you want your kernel to support the Intel
49 IXDP2801 reference platform. For more information on 49 IXDP2801/2805/2855 reference platforms. For more information on
50 this platform, see <file:Documentation/arm/IXP2000>. 50 this platform, see <file:Documentation/arm/IXP2000>.
51 51
52config MACH_IXDP28X5
53 bool
54 depends on ARCH_IXDP2801
55 default y
56
52config ARCH_IXDP2X01 57config ARCH_IXDP2X01
53 bool 58 bool
54 depends on ARCH_IXDP2401 || ARCH_IXDP2801 59 depends on ARCH_IXDP2401 || ARCH_IXDP2801
diff --git a/arch/arm/mach-ixp2000/Makefile b/arch/arm/mach-ixp2000/Makefile
index 9621aeb61f46..1e6139d42a92 100644
--- a/arch/arm/mach-ixp2000/Makefile
+++ b/arch/arm/mach-ixp2000/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4obj-y := core.o pci.o uengine.o 4obj-y := core.o pci.o
5obj-m := 5obj-m :=
6obj-n := 6obj-n :=
7obj- := 7obj- :=
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index cfd5bef3190b..6e8d504aca55 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -288,8 +288,6 @@ void gpio_line_config(int line, int direction)
288 288
289 local_irq_save(flags); 289 local_irq_save(flags);
290 if (direction == GPIO_OUT) { 290 if (direction == GPIO_OUT) {
291 irq_desc[line + IRQ_IXP2000_GPIO0].valid = 0;
292
293 /* if it's an output, it ain't an interrupt anymore */ 291 /* if it's an output, it ain't an interrupt anymore */
294 GPIO_IRQ_falling_edge &= ~(1 << line); 292 GPIO_IRQ_falling_edge &= ~(1 << line);
295 GPIO_IRQ_rising_edge &= ~(1 << line); 293 GPIO_IRQ_rising_edge &= ~(1 << line);
@@ -351,11 +349,6 @@ static int ixp2000_GPIO_irq_type(unsigned int irq, unsigned int type)
351 GPIO_IRQ_level_high &= ~(1 << line); 349 GPIO_IRQ_level_high &= ~(1 << line);
352 update_gpio_int_csrs(); 350 update_gpio_int_csrs();
353 351
354 /*
355 * Finally, mark the corresponding IRQ as valid.
356 */
357 irq_desc[irq].valid = 1;
358
359 return 0; 352 return 0;
360} 353}
361 354
@@ -506,14 +499,10 @@ void __init ixp2000_init_irq(void)
506 } 499 }
507 set_irq_chained_handler(IRQ_IXP2000_ERRSUM, ixp2000_err_irq_handler); 500 set_irq_chained_handler(IRQ_IXP2000_ERRSUM, ixp2000_err_irq_handler);
508 501
509 /*
510 * GPIO IRQs are invalid until someone sets the interrupt mode
511 * by calling set_irq_type().
512 */
513 for (irq = IRQ_IXP2000_GPIO0; irq <= IRQ_IXP2000_GPIO7; irq++) { 502 for (irq = IRQ_IXP2000_GPIO0; irq <= IRQ_IXP2000_GPIO7; irq++) {
514 set_irq_chip(irq, &ixp2000_GPIO_irq_chip); 503 set_irq_chip(irq, &ixp2000_GPIO_irq_chip);
515 set_irq_handler(irq, do_level_IRQ); 504 set_irq_handler(irq, do_level_IRQ);
516 set_irq_flags(irq, 0); 505 set_irq_flags(irq, IRQF_VALID);
517 } 506 }
518 set_irq_chained_handler(IRQ_IXP2000_GPIO, ixp2000_GPIO_irq_handler); 507 set_irq_chained_handler(IRQ_IXP2000_GPIO, ixp2000_GPIO_irq_handler);
519 508
diff --git a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c
index 150519fb38ec..f9d4968c1d66 100644
--- a/arch/arm/mach-ixp2000/ixdp2x01.c
+++ b/arch/arm/mach-ixp2000/ixdp2x01.c
@@ -284,7 +284,7 @@ static int ixdp2x01_pci_setup(int nr, struct pci_sys_data *sys)
284{ 284{
285 sys->mem_offset = 0xe0000000; 285 sys->mem_offset = 0xe0000000;
286 286
287 if (machine_is_ixdp2801()) 287 if (machine_is_ixdp2801() || machine_is_ixdp28x5())
288 sys->mem_offset -= ((*IXP2000_PCI_ADDR_EXT & 0xE000) << 16); 288 sys->mem_offset -= ((*IXP2000_PCI_ADDR_EXT & 0xE000) << 16);
289 289
290 return ixp2000_pci_setup(nr, sys); 290 return ixp2000_pci_setup(nr, sys);
@@ -300,7 +300,8 @@ struct hw_pci ixdp2x01_pci __initdata = {
300 300
301int __init ixdp2x01_pci_init(void) 301int __init ixdp2x01_pci_init(void)
302{ 302{
303 if (machine_is_ixdp2401() || machine_is_ixdp2801()) 303 if (machine_is_ixdp2401() || machine_is_ixdp2801() ||\
304 machine_is_ixdp28x5())
304 pci_common_init(&ixdp2x01_pci); 305 pci_common_init(&ixdp2x01_pci);
305 306
306 return 0; 307 return 0;
@@ -400,6 +401,21 @@ MACHINE_START(IXDP2801, "Intel IXDP2801 Development Platform")
400 .timer = &ixdp2x01_timer, 401 .timer = &ixdp2x01_timer,
401 .init_machine = ixdp2x01_init_machine, 402 .init_machine = ixdp2x01_init_machine,
402MACHINE_END 403MACHINE_END
404
405/*
406 * IXDP28x5 is basically an IXDP2801 with a different CPU but Intel
407 * changed the machine ID in the bootloader
408 */
409MACHINE_START(IXDP28X5, "Intel IXDP2805/2855 Development Platform")
410 /* Maintainer: MontaVista Software, Inc. */
411 .phys_io = IXP2000_UART_PHYS_BASE,
412 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
413 .boot_params = 0x00000100,
414 .map_io = ixdp2x01_map_io,
415 .init_irq = ixdp2x01_init_irq,
416 .timer = &ixdp2x01_timer,
417 .init_machine = ixdp2x01_init_machine,
418MACHINE_END
403#endif 419#endif
404 420
405 421
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 6e3462ed5306..2d40fe1145f0 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -463,7 +463,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
463 if (nr >= 1) 463 if (nr >= 1)
464 return 0; 464 return 0;
465 465
466 res = kmalloc(sizeof(*res) * 2, GFP_KERNEL); 466 res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
467 if (res == NULL) { 467 if (res == NULL) {
468 /* 468 /*
469 * If we're out of memory this early, something is wrong, 469 * If we're out of memory this early, something is wrong,
@@ -471,7 +471,6 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
471 */ 471 */
472 panic("PCI: unable to allocate resources?\n"); 472 panic("PCI: unable to allocate resources?\n");
473 } 473 }
474 memset(res, 0, sizeof(*res) * 2);
475 474
476 local_write_config(PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); 475 local_write_config(PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
477 476
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index fbadf3021b9e..a0888e160e3b 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -91,7 +91,7 @@ static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type);
91/* 91/*
92 * IRQ -> GPIO mapping table 92 * IRQ -> GPIO mapping table
93 */ 93 */
94static int irq2gpio[32] = { 94static char irq2gpio[32] = {
95 -1, -1, -1, -1, -1, -1, 0, 1, 95 -1, -1, -1, -1, -1, -1, 0, 1,
96 -1, -1, -1, -1, -1, -1, -1, -1, 96 -1, -1, -1, -1, -1, -1, -1, -1,
97 -1, -1, -1, 2, 3, 4, 5, 6, 97 -1, -1, -1, 2, 3, 4, 5, 6,
@@ -153,6 +153,9 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
153 /* Set the new style */ 153 /* Set the new style */
154 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE)); 154 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
155 155
156 /* Configure the line as an input */
157 gpio_line_config(line, IXP4XX_GPIO_IN);
158
156 return 0; 159 return 0;
157} 160}
158 161
diff --git a/arch/arm/mach-lh7a40x/common.h b/arch/arm/mach-lh7a40x/common.h
index 578a52461fdb..ea8de7e3ab1b 100644
--- a/arch/arm/mach-lh7a40x/common.h
+++ b/arch/arm/mach-lh7a40x/common.h
@@ -12,5 +12,6 @@ extern struct sys_timer lh7a40x_timer;
12 12
13extern void lh7a400_init_irq (void); 13extern void lh7a400_init_irq (void);
14extern void lh7a404_init_irq (void); 14extern void lh7a404_init_irq (void);
15extern void lh7a40x_init_board_irq (void);
15 16
16#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq), regs) 17#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq), regs)
diff --git a/arch/arm/mach-lh7a40x/irq-kev7a400.c b/arch/arm/mach-lh7a40x/irq-kev7a400.c
index 691bb09232a5..8535764d89ca 100644
--- a/arch/arm/mach-lh7a40x/irq-kev7a400.c
+++ b/arch/arm/mach-lh7a40x/irq-kev7a400.c
@@ -16,6 +16,7 @@
16#include <asm/mach/hardware.h> 16#include <asm/mach/hardware.h>
17#include <asm/mach/irqs.h> 17#include <asm/mach/irqs.h>
18 18
19#include "common.h"
19 20
20 /* KEV7a400 CPLD IRQ handling */ 21 /* KEV7a400 CPLD IRQ handling */
21 22
diff --git a/arch/arm/mach-lh7a40x/irq-lh7a400.c b/arch/arm/mach-lh7a40x/irq-lh7a400.c
index f334d81c2cd8..f9fdefef6d6f 100644
--- a/arch/arm/mach-lh7a40x/irq-lh7a400.c
+++ b/arch/arm/mach-lh7a40x/irq-lh7a400.c
@@ -16,9 +16,9 @@
16#include <asm/hardware.h> 16#include <asm/hardware.h>
17#include <asm/irq.h> 17#include <asm/irq.h>
18#include <asm/mach/irq.h> 18#include <asm/mach/irq.h>
19#include <asm/arch/irq.h>
20#include <asm/arch/irqs.h> 19#include <asm/arch/irqs.h>
21 20
21#include "common.h"
22 22
23 /* CPU IRQ handling */ 23 /* CPU IRQ handling */
24 24
diff --git a/arch/arm/mach-lh7a40x/irq-lh7a404.c b/arch/arm/mach-lh7a40x/irq-lh7a404.c
index 122fadabc97d..e902e3d87da4 100644
--- a/arch/arm/mach-lh7a40x/irq-lh7a404.c
+++ b/arch/arm/mach-lh7a40x/irq-lh7a404.c
@@ -16,9 +16,10 @@
16#include <asm/hardware.h> 16#include <asm/hardware.h>
17#include <asm/irq.h> 17#include <asm/irq.h>
18#include <asm/mach/irq.h> 18#include <asm/mach/irq.h>
19#include <asm/arch/irq.h>
20#include <asm/arch/irqs.h> 19#include <asm/arch/irqs.h>
21 20
21#include "common.h"
22
22#define USE_PRIORITIES 23#define USE_PRIORITIES
23 24
24/* See Documentation/arm/Sharp-LH/VectoredInterruptController for more 25/* See Documentation/arm/Sharp-LH/VectoredInterruptController for more
diff --git a/arch/arm/mach-lh7a40x/irq-lpd7a40x.c b/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
index 6262d449120c..dcb4e17b9419 100644
--- a/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
+++ b/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
@@ -19,6 +19,7 @@
19#include <asm/mach/irq.h> 19#include <asm/mach/irq.h>
20#include <asm/arch/irqs.h> 20#include <asm/arch/irqs.h>
21 21
22#include "common.h"
22 23
23static void lh7a40x_ack_cpld_irq (u32 irq) 24static void lh7a40x_ack_cpld_irq (u32 irq)
24{ 25{
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 32526a0a6f86..382644401a4d 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Common support (must be linked before board specific support) 5# Common support (must be linked before board specific support)
6obj-y += generic.o irq.o dma.o time.o 6obj-y += clock.o generic.o irq.o dma.o time.o
7obj-$(CONFIG_PXA25x) += pxa25x.o 7obj-$(CONFIG_PXA25x) += pxa25x.o
8obj-$(CONFIG_PXA27x) += pxa27x.o 8obj-$(CONFIG_PXA27x) += pxa27x.o
9 9
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
new file mode 100644
index 000000000000..8f7c90a0593b
--- /dev/null
+++ b/arch/arm/mach-pxa/clock.c
@@ -0,0 +1,124 @@
1/*
2 * linux/arch/arm/mach-sa1100/clock.c
3 */
4#include <linux/module.h>
5#include <linux/kernel.h>
6#include <linux/list.h>
7#include <linux/errno.h>
8#include <linux/err.h>
9#include <linux/string.h>
10#include <linux/clk.h>
11#include <linux/spinlock.h>
12
13#include <asm/arch/pxa-regs.h>
14#include <asm/hardware.h>
15#include <asm/semaphore.h>
16
17struct clk {
18 struct list_head node;
19 unsigned long rate;
20 struct module *owner;
21 const char *name;
22 unsigned int enabled;
23 void (*enable)(void);
24 void (*disable)(void);
25};
26
27static LIST_HEAD(clocks);
28static DECLARE_MUTEX(clocks_sem);
29static DEFINE_SPINLOCK(clocks_lock);
30
31struct clk *clk_get(struct device *dev, const char *id)
32{
33 struct clk *p, *clk = ERR_PTR(-ENOENT);
34
35 down(&clocks_sem);
36 list_for_each_entry(p, &clocks, node) {
37 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
38 clk = p;
39 break;
40 }
41 }
42 up(&clocks_sem);
43
44 return clk;
45}
46EXPORT_SYMBOL(clk_get);
47
48void clk_put(struct clk *clk)
49{
50 module_put(clk->owner);
51}
52EXPORT_SYMBOL(clk_put);
53
54int clk_enable(struct clk *clk)
55{
56 unsigned long flags;
57
58 spin_lock_irqsave(&clocks_lock, flags);
59 if (clk->enabled++ == 0)
60 clk->enable();
61 spin_unlock_irqrestore(&clocks_lock, flags);
62 return 0;
63}
64EXPORT_SYMBOL(clk_enable);
65
66void clk_disable(struct clk *clk)
67{
68 unsigned long flags;
69
70 WARN_ON(clk->enabled == 0);
71
72 spin_lock_irqsave(&clocks_lock, flags);
73 if (--clk->enabled == 0)
74 clk->disable();
75 spin_unlock_irqrestore(&clocks_lock, flags);
76}
77EXPORT_SYMBOL(clk_disable);
78
79unsigned long clk_get_rate(struct clk *clk)
80{
81 return clk->rate;
82}
83EXPORT_SYMBOL(clk_get_rate);
84
85
86static void clk_gpio27_enable(void)
87{
88 pxa_gpio_mode(GPIO11_3_6MHz_MD);
89}
90
91static void clk_gpio27_disable(void)
92{
93}
94
95static struct clk clk_gpio27 = {
96 .name = "GPIO27_CLK",
97 .rate = 3686400,
98 .enable = clk_gpio27_enable,
99 .disable = clk_gpio27_disable,
100};
101
102int clk_register(struct clk *clk)
103{
104 down(&clocks_sem);
105 list_add(&clk->node, &clocks);
106 up(&clocks_sem);
107 return 0;
108}
109EXPORT_SYMBOL(clk_register);
110
111void clk_unregister(struct clk *clk)
112{
113 down(&clocks_sem);
114 list_del(&clk->node);
115 up(&clocks_sem);
116}
117EXPORT_SYMBOL(clk_unregister);
118
119static int __init clk_init(void)
120{
121 clk_register(&clk_gpio27);
122 return 0;
123}
124arch_initcall(clk_init);
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 7ffd2de8f2f3..68923b1d2b62 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -32,7 +32,6 @@
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
34#include <asm/arch/pxa-regs.h> 34#include <asm/arch/pxa-regs.h>
35#include <asm/arch/irq.h>
36#include <asm/arch/irda.h> 35#include <asm/arch/irda.h>
37#include <asm/arch/mmc.h> 36#include <asm/arch/mmc.h>
38#include <asm/arch/udc.h> 37#include <asm/arch/udc.h>
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 911e6ff5a9bd..b45560a8f6c4 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -29,7 +29,6 @@
29#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
30 30
31#include <asm/arch/pxa-regs.h> 31#include <asm/arch/pxa-regs.h>
32#include <asm/arch/irq.h>
33#include <asm/arch/mmc.h> 32#include <asm/arch/mmc.h>
34#include <asm/arch/udc.h> 33#include <asm/arch/udc.h>
35#include <asm/arch/irda.h> 34#include <asm/arch/irda.h>
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index c094d99ebf56..30ec317bbb97 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -33,7 +33,6 @@
33#include <asm/mach/irq.h> 33#include <asm/mach/irq.h>
34 34
35#include <asm/arch/pxa-regs.h> 35#include <asm/arch/pxa-regs.h>
36#include <asm/arch/irq.h>
37#include <asm/arch/irda.h> 36#include <asm/arch/irda.h>
38#include <asm/arch/mmc.h> 37#include <asm/arch/mmc.h>
39#include <asm/arch/ohci.h> 38#include <asm/arch/ohci.h>
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index d168286ed470..66ec71756d0f 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -34,7 +34,6 @@
34#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
35 35
36#include <asm/arch/pxa-regs.h> 36#include <asm/arch/pxa-regs.h>
37#include <asm/arch/irq.h>
38#include <asm/arch/tosa.h> 37#include <asm/arch/tosa.h>
39 38
40#include <asm/hardware/scoop.h> 39#include <asm/hardware/scoop.h>
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index 0b9d7ca49ec1..ed07c4149d82 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -9,6 +9,13 @@ config MACH_ANUBIS
9 Say Y gere if you are using the Simtec Electronics ANUBIS 9 Say Y gere if you are using the Simtec Electronics ANUBIS
10 development system 10 development system
11 11
12config MACH_OSIRIS
13 bool "Simtec IM2440D20 (OSIRIS) module"
14 select CPU_S3C2440
15 help
16 Say Y here if you are using the Simtec IM2440D20 module, also
17 known as the Osiris.
18
12config ARCH_BAST 19config ARCH_BAST
13 bool "Simtec Electronics BAST (EB2410ITX)" 20 bool "Simtec Electronics BAST (EB2410ITX)"
14 select CPU_S3C2410 21 select CPU_S3C2410
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index 1217bf00309c..1b3b476e5637 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_BAST_PC104_IRQ) += bast-irq.o
38# machine specific support 38# machine specific support
39 39
40obj-$(CONFIG_MACH_ANUBIS) += mach-anubis.o 40obj-$(CONFIG_MACH_ANUBIS) += mach-anubis.o
41obj-$(CONFIG_MACH_OSIRIS) += mach-osiris.o
41obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o 42obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o
42obj-$(CONFIG_ARCH_H1940) += mach-h1940.o 43obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
43obj-$(CONFIG_MACH_N30) += mach-n30.o 44obj-$(CONFIG_MACH_N30) += mach-n30.o
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index 08489efdaf06..fec02c92f95f 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -38,12 +38,14 @@
38#include <linux/ioport.h> 38#include <linux/ioport.h>
39#include <linux/clk.h> 39#include <linux/clk.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/delay.h>
41 42
42#include <asm/hardware.h> 43#include <asm/hardware.h>
43#include <asm/irq.h> 44#include <asm/irq.h>
44#include <asm/io.h> 45#include <asm/io.h>
45 46
46#include <asm/arch/regs-clock.h> 47#include <asm/arch/regs-clock.h>
48#include <asm/arch/regs-gpio.h>
47 49
48#include "clock.h" 50#include "clock.h"
49#include "cpu.h" 51#include "cpu.h"
@@ -51,7 +53,8 @@
51/* clock information */ 53/* clock information */
52 54
53static LIST_HEAD(clocks); 55static LIST_HEAD(clocks);
54static DEFINE_MUTEX(clocks_mutex); 56
57DEFINE_MUTEX(clocks_mutex);
55 58
56/* old functions */ 59/* old functions */
57 60
@@ -178,12 +181,24 @@ unsigned long clk_get_rate(struct clk *clk)
178 181
179long clk_round_rate(struct clk *clk, unsigned long rate) 182long clk_round_rate(struct clk *clk, unsigned long rate)
180{ 183{
184 if (!IS_ERR(clk) && clk->round_rate)
185 return (clk->round_rate)(clk, rate);
186
181 return rate; 187 return rate;
182} 188}
183 189
184int clk_set_rate(struct clk *clk, unsigned long rate) 190int clk_set_rate(struct clk *clk, unsigned long rate)
185{ 191{
186 return -EINVAL; 192 int ret;
193
194 if (IS_ERR(clk))
195 return -EINVAL;
196
197 mutex_lock(&clocks_mutex);
198 ret = (clk->set_rate)(clk, rate);
199 mutex_unlock(&clocks_mutex);
200
201 return ret;
187} 202}
188 203
189struct clk *clk_get_parent(struct clk *clk) 204struct clk *clk_get_parent(struct clk *clk)
@@ -191,6 +206,23 @@ struct clk *clk_get_parent(struct clk *clk)
191 return clk->parent; 206 return clk->parent;
192} 207}
193 208
209int clk_set_parent(struct clk *clk, struct clk *parent)
210{
211 int ret = 0;
212
213 if (IS_ERR(clk))
214 return -EINVAL;
215
216 mutex_lock(&clocks_mutex);
217
218 if (clk->set_parent)
219 ret = (clk->set_parent)(clk, parent);
220
221 mutex_unlock(&clocks_mutex);
222
223 return ret;
224}
225
194EXPORT_SYMBOL(clk_get); 226EXPORT_SYMBOL(clk_get);
195EXPORT_SYMBOL(clk_put); 227EXPORT_SYMBOL(clk_put);
196EXPORT_SYMBOL(clk_enable); 228EXPORT_SYMBOL(clk_enable);
@@ -199,6 +231,29 @@ EXPORT_SYMBOL(clk_get_rate);
199EXPORT_SYMBOL(clk_round_rate); 231EXPORT_SYMBOL(clk_round_rate);
200EXPORT_SYMBOL(clk_set_rate); 232EXPORT_SYMBOL(clk_set_rate);
201EXPORT_SYMBOL(clk_get_parent); 233EXPORT_SYMBOL(clk_get_parent);
234EXPORT_SYMBOL(clk_set_parent);
235
236/* base clock enable */
237
238static int s3c24xx_upll_enable(struct clk *clk, int enable)
239{
240 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
241 unsigned long orig = clkslow;
242
243 if (enable)
244 clkslow &= ~S3C2410_CLKSLOW_UCLK_OFF;
245 else
246 clkslow |= S3C2410_CLKSLOW_UCLK_OFF;
247
248 __raw_writel(clkslow, S3C2410_CLKSLOW);
249
250 /* if we started the UPLL, then allow to settle */
251
252 if (enable && !(orig & S3C2410_CLKSLOW_UCLK_OFF))
253 udelay(200);
254
255 return 0;
256}
202 257
203/* base clocks */ 258/* base clocks */
204 259
@@ -210,6 +265,14 @@ static struct clk clk_xtal = {
210 .ctrlbit = 0, 265 .ctrlbit = 0,
211}; 266};
212 267
268static struct clk clk_upll = {
269 .name = "upll",
270 .id = -1,
271 .parent = NULL,
272 .enable = s3c24xx_upll_enable,
273 .ctrlbit = 0,
274};
275
213static struct clk clk_f = { 276static struct clk clk_f = {
214 .name = "fclk", 277 .name = "fclk",
215 .id = -1, 278 .id = -1,
@@ -234,26 +297,124 @@ static struct clk clk_p = {
234 .ctrlbit = 0, 297 .ctrlbit = 0,
235}; 298};
236 299
300struct clk clk_usb_bus = {
301 .name = "usb-bus",
302 .id = -1,
303 .rate = 0,
304 .parent = &clk_upll,
305};
306
237/* clocks that could be registered by external code */ 307/* clocks that could be registered by external code */
238 308
309static int s3c24xx_dclk_enable(struct clk *clk, int enable)
310{
311 unsigned long dclkcon = __raw_readl(S3C2410_DCLKCON);
312
313 if (enable)
314 dclkcon |= clk->ctrlbit;
315 else
316 dclkcon &= ~clk->ctrlbit;
317
318 __raw_writel(dclkcon, S3C2410_DCLKCON);
319
320 return 0;
321}
322
323static int s3c24xx_dclk_setparent(struct clk *clk, struct clk *parent)
324{
325 unsigned long dclkcon;
326 unsigned int uclk;
327
328 if (parent == &clk_upll)
329 uclk = 1;
330 else if (parent == &clk_p)
331 uclk = 0;
332 else
333 return -EINVAL;
334
335 clk->parent = parent;
336
337 dclkcon = __raw_readl(S3C2410_DCLKCON);
338
339 if (clk->ctrlbit == S3C2410_DCLKCON_DCLK0EN) {
340 if (uclk)
341 dclkcon |= S3C2410_DCLKCON_DCLK0_UCLK;
342 else
343 dclkcon &= ~S3C2410_DCLKCON_DCLK0_UCLK;
344 } else {
345 if (uclk)
346 dclkcon |= S3C2410_DCLKCON_DCLK1_UCLK;
347 else
348 dclkcon &= ~S3C2410_DCLKCON_DCLK1_UCLK;
349 }
350
351 __raw_writel(dclkcon, S3C2410_DCLKCON);
352
353 return 0;
354}
355
356
357static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
358{
359 unsigned long mask;
360 unsigned long source;
361
362 /* calculate the MISCCR setting for the clock */
363
364 if (parent == &clk_xtal)
365 source = S3C2410_MISCCR_CLK0_MPLL;
366 else if (parent == &clk_upll)
367 source = S3C2410_MISCCR_CLK0_UPLL;
368 else if (parent == &clk_f)
369 source = S3C2410_MISCCR_CLK0_FCLK;
370 else if (parent == &clk_p)
371 source = S3C2410_MISCCR_CLK0_PCLK;
372 else if (clk == &s3c24xx_clkout0 && parent == &s3c24xx_dclk0)
373 source = S3C2410_MISCCR_CLK0_DCLK0;
374 else if (clk == &s3c24xx_clkout1 && parent == &s3c24xx_dclk1)
375 source = S3C2410_MISCCR_CLK0_DCLK0;
376 else
377 return -EINVAL;
378
379 if (clk == &s3c24xx_dclk0)
380 mask = S3C2410_MISCCR_CLK0_MASK;
381 else {
382 source <<= 4;
383 mask = S3C2410_MISCCR_CLK1_MASK;
384 }
385
386 s3c2410_modify_misccr(mask, source);
387 return 0;
388}
389
390/* external clock definitions */
391
239struct clk s3c24xx_dclk0 = { 392struct clk s3c24xx_dclk0 = {
240 .name = "dclk0", 393 .name = "dclk0",
241 .id = -1, 394 .id = -1,
395 .ctrlbit = S3C2410_DCLKCON_DCLK0EN,
396 .enable = s3c24xx_dclk_enable,
397 .set_parent = s3c24xx_dclk_setparent,
242}; 398};
243 399
244struct clk s3c24xx_dclk1 = { 400struct clk s3c24xx_dclk1 = {
245 .name = "dclk1", 401 .name = "dclk1",
246 .id = -1, 402 .id = -1,
403 .ctrlbit = S3C2410_DCLKCON_DCLK0EN,
404 .enable = s3c24xx_dclk_enable,
405 .set_parent = s3c24xx_dclk_setparent,
247}; 406};
248 407
249struct clk s3c24xx_clkout0 = { 408struct clk s3c24xx_clkout0 = {
250 .name = "clkout0", 409 .name = "clkout0",
251 .id = -1, 410 .id = -1,
411 .set_parent = s3c24xx_clkout_setparent,
252}; 412};
253 413
254struct clk s3c24xx_clkout1 = { 414struct clk s3c24xx_clkout1 = {
255 .name = "clkout1", 415 .name = "clkout1",
256 .id = -1, 416 .id = -1,
417 .set_parent = s3c24xx_clkout_setparent,
257}; 418};
258 419
259struct clk s3c24xx_uclk = { 420struct clk s3c24xx_uclk = {
@@ -262,7 +423,7 @@ struct clk s3c24xx_uclk = {
262}; 423};
263 424
264 425
265/* clock definitions */ 426/* standard clock definitions */
266 427
267static struct clk init_clocks[] = { 428static struct clk init_clocks[] = {
268 { 429 {
@@ -374,7 +535,7 @@ int s3c24xx_register_clock(struct clk *clk)
374 535
375 /* if this is a standard clock, set the usage state */ 536 /* if this is a standard clock, set the usage state */
376 537
377 if (clk->ctrlbit) { 538 if (clk->ctrlbit && clk->enable == s3c24xx_clkcon_enable) {
378 unsigned long clkcon = __raw_readl(S3C2410_CLKCON); 539 unsigned long clkcon = __raw_readl(S3C2410_CLKCON);
379 540
380 clk->usage = (clkcon & clk->ctrlbit) ? 1 : 0; 541 clk->usage = (clkcon & clk->ctrlbit) ? 1 : 0;
@@ -396,6 +557,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
396 unsigned long hclk, 557 unsigned long hclk,
397 unsigned long pclk) 558 unsigned long pclk)
398{ 559{
560 unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
399 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW); 561 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
400 struct clk *clkp = init_clocks; 562 struct clk *clkp = init_clocks;
401 int ptr; 563 int ptr;
@@ -406,6 +568,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
406 /* initialise the main system clocks */ 568 /* initialise the main system clocks */
407 569
408 clk_xtal.rate = xtal; 570 clk_xtal.rate = xtal;
571 clk_upll.rate = s3c2410_get_pll(upllcon, xtal);
409 572
410 clk_h.rate = hclk; 573 clk_h.rate = hclk;
411 clk_p.rate = pclk; 574 clk_p.rate = pclk;
@@ -439,6 +602,9 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
439 if (s3c24xx_register_clock(&clk_xtal) < 0) 602 if (s3c24xx_register_clock(&clk_xtal) < 0)
440 printk(KERN_ERR "failed to register master xtal\n"); 603 printk(KERN_ERR "failed to register master xtal\n");
441 604
605 if (s3c24xx_register_clock(&clk_upll) < 0)
606 printk(KERN_ERR "failed to register upll clock\n");
607
442 if (s3c24xx_register_clock(&clk_f) < 0) 608 if (s3c24xx_register_clock(&clk_f) < 0)
443 printk(KERN_ERR "failed to register cpu fclk\n"); 609 printk(KERN_ERR "failed to register cpu fclk\n");
444 610
@@ -448,6 +614,10 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
448 if (s3c24xx_register_clock(&clk_p) < 0) 614 if (s3c24xx_register_clock(&clk_p) < 0)
449 printk(KERN_ERR "failed to register cpu pclk\n"); 615 printk(KERN_ERR "failed to register cpu pclk\n");
450 616
617
618 if (s3c24xx_register_clock(&clk_usb_bus) < 0)
619 printk(KERN_ERR "failed to register usb bus clock\n");
620
451 /* register clocks from clock array */ 621 /* register clocks from clock array */
452 622
453 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) { 623 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) {
diff --git a/arch/arm/mach-s3c2410/clock.h b/arch/arm/mach-s3c2410/clock.h
index eb5c95d1e7f2..01bb458bf8eb 100644
--- a/arch/arm/mach-s3c2410/clock.h
+++ b/arch/arm/mach-s3c2410/clock.h
@@ -19,7 +19,11 @@ struct clk {
19 int usage; 19 int usage;
20 unsigned long rate; 20 unsigned long rate;
21 unsigned long ctrlbit; 21 unsigned long ctrlbit;
22
22 int (*enable)(struct clk *, int enable); 23 int (*enable)(struct clk *, int enable);
24 int (*set_rate)(struct clk *c, unsigned long rate);
25 unsigned long (*round_rate)(struct clk *c, unsigned long rate);
26 int (*set_parent)(struct clk *c, struct clk *parent);
23}; 27};
24 28
25/* other clocks which may be registered by board support */ 29/* other clocks which may be registered by board support */
@@ -30,11 +34,15 @@ extern struct clk s3c24xx_clkout0;
30extern struct clk s3c24xx_clkout1; 34extern struct clk s3c24xx_clkout1;
31extern struct clk s3c24xx_uclk; 35extern struct clk s3c24xx_uclk;
32 36
37extern struct clk clk_usb_bus;
38
33/* exports for arch/arm/mach-s3c2410 39/* exports for arch/arm/mach-s3c2410
34 * 40 *
35 * Please DO NOT use these outside of arch/arm/mach-s3c2410 41 * Please DO NOT use these outside of arch/arm/mach-s3c2410
36*/ 42*/
37 43
44extern struct mutex clocks_mutex;
45
38extern int s3c24xx_clkcon_enable(struct clk *clk, int enable); 46extern int s3c24xx_clkcon_enable(struct clk *clk, int enable);
39extern int s3c24xx_register_clock(struct clk *clk); 47extern int s3c24xx_register_clock(struct clk *clk);
40 48
diff --git a/arch/arm/mach-s3c2410/mach-osiris.c b/arch/arm/mach-s3c2410/mach-osiris.c
new file mode 100644
index 000000000000..ae0787557751
--- /dev/null
+++ b/arch/arm/mach-s3c2410/mach-osiris.c
@@ -0,0 +1,294 @@
1/* linux/arch/arm/mach-s3c2410/mach-osiris.c
2 *
3 * Copyright (c) 2005 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/list.h>
16#include <linux/timer.h>
17#include <linux/init.h>
18#include <linux/device.h>
19
20#include <asm/mach/arch.h>
21#include <asm/mach/map.h>
22#include <asm/mach/irq.h>
23
24#include <asm/arch/osiris-map.h>
25#include <asm/arch/osiris-cpld.h>
26
27#include <asm/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h>
30#include <asm/mach-types.h>
31
32#include <asm/arch/regs-serial.h>
33#include <asm/arch/regs-gpio.h>
34#include <asm/arch/regs-mem.h>
35#include <asm/arch/regs-lcd.h>
36#include <asm/arch/nand.h>
37
38#include <linux/mtd/mtd.h>
39#include <linux/mtd/nand.h>
40#include <linux/mtd/nand_ecc.h>
41#include <linux/mtd/partitions.h>
42
43#include "clock.h"
44#include "devs.h"
45#include "cpu.h"
46
47/* onboard perihpheral map */
48
49static struct map_desc osiris_iodesc[] __initdata = {
50 /* ISA IO areas (may be over-written later) */
51
52 {
53 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
54 .pfn = __phys_to_pfn(S3C2410_CS5),
55 .length = SZ_16M,
56 .type = MT_DEVICE,
57 }, {
58 .virtual = (u32)S3C24XX_VA_ISA_WORD,
59 .pfn = __phys_to_pfn(S3C2410_CS5),
60 .length = SZ_16M,
61 .type = MT_DEVICE,
62 },
63
64 /* CPLD control registers */
65
66 {
67 .virtual = (u32)OSIRIS_VA_CTRL1,
68 .pfn = __phys_to_pfn(OSIRIS_PA_CTRL1),
69 .length = SZ_16K,
70 .type = MT_DEVICE
71 }, {
72 .virtual = (u32)OSIRIS_VA_CTRL2,
73 .pfn = __phys_to_pfn(OSIRIS_PA_CTRL2),
74 .length = SZ_16K,
75 .type = MT_DEVICE
76 },
77};
78
79#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
80#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
81#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
82
83static struct s3c24xx_uart_clksrc osiris_serial_clocks[] = {
84 [0] = {
85 .name = "uclk",
86 .divisor = 1,
87 .min_baud = 0,
88 .max_baud = 0,
89 },
90 [1] = {
91 .name = "pclk",
92 .divisor = 1,
93 .min_baud = 0,
94 .max_baud = 0.
95 }
96};
97
98
99static struct s3c2410_uartcfg osiris_uartcfgs[] = {
100 [0] = {
101 .hwport = 0,
102 .flags = 0,
103 .ucon = UCON,
104 .ulcon = ULCON,
105 .ufcon = UFCON,
106 .clocks = osiris_serial_clocks,
107 .clocks_size = ARRAY_SIZE(osiris_serial_clocks)
108 },
109 [1] = {
110 .hwport = 2,
111 .flags = 0,
112 .ucon = UCON,
113 .ulcon = ULCON,
114 .ufcon = UFCON,
115 .clocks = osiris_serial_clocks,
116 .clocks_size = ARRAY_SIZE(osiris_serial_clocks)
117 },
118};
119
120/* NAND Flash on Osiris board */
121
122static int external_map[] = { 2 };
123static int chip0_map[] = { 0 };
124static int chip1_map[] = { 1 };
125
126static struct mtd_partition osiris_default_nand_part[] = {
127 [0] = {
128 .name = "Boot Agent",
129 .size = SZ_16K,
130 .offset = 0
131 },
132 [1] = {
133 .name = "/boot",
134 .size = SZ_4M - SZ_16K,
135 .offset = SZ_16K,
136 },
137 [2] = {
138 .name = "user1",
139 .offset = SZ_4M,
140 .size = SZ_32M - SZ_4M,
141 },
142 [3] = {
143 .name = "user2",
144 .offset = SZ_32M,
145 .size = MTDPART_SIZ_FULL,
146 }
147};
148
149/* the Osiris has 3 selectable slots for nand-flash, the two
150 * on-board chip areas, as well as the external slot.
151 *
152 * Note, there is no current hot-plug support for the External
153 * socket.
154*/
155
156static struct s3c2410_nand_set osiris_nand_sets[] = {
157 [1] = {
158 .name = "External",
159 .nr_chips = 1,
160 .nr_map = external_map,
161 .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
162 .partitions = osiris_default_nand_part
163 },
164 [0] = {
165 .name = "chip0",
166 .nr_chips = 1,
167 .nr_map = chip0_map,
168 .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
169 .partitions = osiris_default_nand_part
170 },
171 [2] = {
172 .name = "chip1",
173 .nr_chips = 1,
174 .nr_map = chip1_map,
175 .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
176 .partitions = osiris_default_nand_part
177 },
178};
179
180static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
181{
182 unsigned int tmp;
183
184 slot = set->nr_map[slot] & 3;
185
186 pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
187 slot, set, set->nr_map);
188
189 tmp = __raw_readb(OSIRIS_VA_CTRL1);
190 tmp &= ~OSIRIS_CTRL1_NANDSEL;
191 tmp |= slot;
192
193 pr_debug("osiris_nand: ctrl1 now %02x\n", tmp);
194
195 __raw_writeb(tmp, OSIRIS_VA_CTRL1);
196}
197
198static struct s3c2410_platform_nand osiris_nand_info = {
199 .tacls = 25,
200 .twrph0 = 60,
201 .twrph1 = 60,
202 .nr_sets = ARRAY_SIZE(osiris_nand_sets),
203 .sets = osiris_nand_sets,
204 .select_chip = osiris_nand_select,
205};
206
207/* PCMCIA control and configuration */
208
209static struct resource osiris_pcmcia_resource[] = {
210 [0] = {
211 .start = 0x0f000000,
212 .end = 0x0f100000,
213 .flags = IORESOURCE_MEM,
214 },
215 [1] = {
216 .start = 0x0c000000,
217 .end = 0x0c100000,
218 .flags = IORESOURCE_MEM,
219 }
220};
221
222static struct platform_device osiris_pcmcia = {
223 .name = "osiris-pcmcia",
224 .id = -1,
225 .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
226 .resource = osiris_pcmcia_resource,
227};
228
229/* Standard Osiris devices */
230
231static struct platform_device *osiris_devices[] __initdata = {
232 &s3c_device_i2c,
233 &s3c_device_nand,
234 &osiris_pcmcia,
235};
236
237static struct clk *osiris_clocks[] = {
238 &s3c24xx_dclk0,
239 &s3c24xx_dclk1,
240 &s3c24xx_clkout0,
241 &s3c24xx_clkout1,
242 &s3c24xx_uclk,
243};
244
245static struct s3c24xx_board osiris_board __initdata = {
246 .devices = osiris_devices,
247 .devices_count = ARRAY_SIZE(osiris_devices),
248 .clocks = osiris_clocks,
249 .clocks_count = ARRAY_SIZE(osiris_clocks)
250};
251
252static void __init osiris_map_io(void)
253{
254 unsigned long flags;
255
256 /* initialise the clocks */
257
258 s3c24xx_dclk0.parent = NULL;
259 s3c24xx_dclk0.rate = 12*1000*1000;
260
261 s3c24xx_dclk1.parent = NULL;
262 s3c24xx_dclk1.rate = 24*1000*1000;
263
264 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
265 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
266
267 s3c24xx_uclk.parent = &s3c24xx_clkout1;
268
269 s3c_device_nand.dev.platform_data = &osiris_nand_info;
270
271 s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
272 s3c24xx_init_clocks(0);
273 s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
274 s3c24xx_set_board(&osiris_board);
275
276 /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
277
278 local_irq_save(flags);
279 __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
280 local_irq_restore(flags);
281
282 /* write-protect line to the NAND */
283 s3c2410_gpio_setpin(S3C2410_GPA0, 1);
284}
285
286MACHINE_START(OSIRIS, "Simtec-OSIRIS")
287 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
288 .phys_io = S3C2410_PA_UART,
289 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
290 .boot_params = S3C2410_SDRAM_PA + 0x100,
291 .map_io = osiris_map_io,
292 .init_irq = s3c24xx_init_irq,
293 .timer = &s3c24xx_timer,
294MACHINE_END
diff --git a/arch/arm/mach-s3c2410/s3c2440-clock.c b/arch/arm/mach-s3c2410/s3c2440-clock.c
index b557a2be8a01..57a15974d4b5 100644
--- a/arch/arm/mach-s3c2410/s3c2440-clock.c
+++ b/arch/arm/mach-s3c2410/s3c2440-clock.c
@@ -31,6 +31,7 @@
31#include <linux/sysdev.h> 31#include <linux/sysdev.h>
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/mutex.h>
34#include <linux/clk.h> 35#include <linux/clk.h>
35 36
36#include <asm/hardware.h> 37#include <asm/hardware.h>
@@ -45,10 +46,47 @@
45 46
46/* S3C2440 extended clock support */ 47/* S3C2440 extended clock support */
47 48
48static struct clk s3c2440_clk_upll = { 49static unsigned long s3c2440_camif_upll_round(struct clk *clk,
49 .name = "upll", 50 unsigned long rate)
50 .id = -1, 51{
51}; 52 unsigned long parent_rate = clk_get_rate(clk->parent);
53 int div;
54
55 if (rate > parent_rate)
56 return parent_rate;
57
58 /* note, we remove the +/- 1 calculations for the divisor */
59
60 div = (parent_rate / rate) / 2;
61
62 if (div < 1)
63 div = 1;
64 else if (div > 16)
65 div = 16;
66
67 return parent_rate / (div * 2);
68}
69
70static int s3c2440_camif_upll_setrate(struct clk *clk, unsigned long rate)
71{
72 unsigned long parent_rate = clk_get_rate(clk->parent);
73 unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);
74
75 rate = s3c2440_camif_upll_round(clk, rate);
76
77 camdivn &= ~(S3C2440_CAMDIVN_CAMCLK_SEL | S3C2440_CAMDIVN_CAMCLK_MASK);
78
79 if (rate != parent_rate) {
80 camdivn |= S3C2440_CAMDIVN_CAMCLK_SEL;
81 camdivn |= (((parent_rate / rate) / 2) - 1);
82 }
83
84 __raw_writel(camdivn, S3C2440_CAMDIVN);
85
86 return 0;
87}
88
89/* Extra S3C2440 clocks */
52 90
53static struct clk s3c2440_clk_cam = { 91static struct clk s3c2440_clk_cam = {
54 .name = "camif", 92 .name = "camif",
@@ -57,6 +95,13 @@ static struct clk s3c2440_clk_cam = {
57 .ctrlbit = S3C2440_CLKCON_CAMERA, 95 .ctrlbit = S3C2440_CLKCON_CAMERA,
58}; 96};
59 97
98static struct clk s3c2440_clk_cam_upll = {
99 .name = "camif-upll",
100 .id = -1,
101 .set_rate = s3c2440_camif_upll_setrate,
102 .round_rate = s3c2440_camif_upll_round,
103};
104
60static struct clk s3c2440_clk_ac97 = { 105static struct clk s3c2440_clk_ac97 = {
61 .name = "ac97", 106 .name = "ac97",
62 .id = -1, 107 .id = -1,
@@ -66,38 +111,46 @@ static struct clk s3c2440_clk_ac97 = {
66 111
67static int s3c2440_clk_add(struct sys_device *sysdev) 112static int s3c2440_clk_add(struct sys_device *sysdev)
68{ 113{
69 unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
70 unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN); 114 unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);
115 unsigned long clkdivn;
71 struct clk *clk_h; 116 struct clk *clk_h;
72 struct clk *clk_p; 117 struct clk *clk_p;
73 struct clk *clk_xtal; 118 struct clk *clk_upll;
74
75 clk_xtal = clk_get(NULL, "xtal");
76 if (IS_ERR(clk_xtal)) {
77 printk(KERN_ERR "S3C2440: Failed to get clk_xtal\n");
78 return -EINVAL;
79 }
80
81 s3c2440_clk_upll.rate = s3c2410_get_pll(upllcon, clk_xtal->rate);
82 119
83 printk("S3C2440: Clock Support, UPLL %ld.%03ld MHz, DVS %s\n", 120 printk("S3C2440: Clock Support, DVS %s\n",
84 print_mhz(s3c2440_clk_upll.rate),
85 (camdivn & S3C2440_CAMDIVN_DVSEN) ? "on" : "off"); 121 (camdivn & S3C2440_CAMDIVN_DVSEN) ? "on" : "off");
86 122
87 clk_p = clk_get(NULL, "pclk"); 123 clk_p = clk_get(NULL, "pclk");
88 clk_h = clk_get(NULL, "hclk"); 124 clk_h = clk_get(NULL, "hclk");
125 clk_upll = clk_get(NULL, "upll");
89 126
90 if (IS_ERR(clk_p) || IS_ERR(clk_h)) { 127 if (IS_ERR(clk_p) || IS_ERR(clk_h) || IS_ERR(clk_upll)) {
91 printk(KERN_ERR "S3C2440: Failed to get parent clocks\n"); 128 printk(KERN_ERR "S3C2440: Failed to get parent clocks\n");
92 return -EINVAL; 129 return -EINVAL;
93 } 130 }
94 131
132 /* check rate of UPLL, and if it is near 96MHz, then change
133 * to using half the UPLL rate for the system */
134
135 if (clk_get_rate(clk_upll) > (94 * MHZ)) {
136 clk_usb_bus.rate = clk_get_rate(clk_upll) / 2;
137
138 mutex_lock(&clocks_mutex);
139
140 clkdivn = __raw_readl(S3C2410_CLKDIVN);
141 clkdivn |= S3C2440_CLKDIVN_UCLK;
142 __raw_writel(camdivn, S3C2410_CLKDIVN);
143
144 mutex_unlock(&clocks_mutex);
145 }
146
95 s3c2440_clk_cam.parent = clk_h; 147 s3c2440_clk_cam.parent = clk_h;
96 s3c2440_clk_ac97.parent = clk_p; 148 s3c2440_clk_ac97.parent = clk_p;
149 s3c2440_clk_cam_upll.parent = clk_upll;
97 150
98 s3c24xx_register_clock(&s3c2440_clk_ac97); 151 s3c24xx_register_clock(&s3c2440_clk_ac97);
99 s3c24xx_register_clock(&s3c2440_clk_cam); 152 s3c24xx_register_clock(&s3c2440_clk_cam);
100 s3c24xx_register_clock(&s3c2440_clk_upll); 153 s3c24xx_register_clock(&s3c2440_clk_cam_upll);
101 154
102 clk_disable(&s3c2440_clk_ac97); 155 clk_disable(&s3c2440_clk_ac97);
103 clk_disable(&s3c2440_clk_cam); 156 clk_disable(&s3c2440_clk_cam);
diff --git a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c
index 10a2976aefdd..9d7b799ea4a4 100644
--- a/arch/arm/mach-s3c2410/time.c
+++ b/arch/arm/mach-s3c2410/time.c
@@ -142,6 +142,12 @@ static struct irqaction s3c2410_timer_irq = {
142 .handler = s3c2410_timer_interrupt, 142 .handler = s3c2410_timer_interrupt,
143}; 143};
144 144
145#define use_tclk1_12() ( \
146 machine_is_bast() || \
147 machine_is_vr1000() || \
148 machine_is_anubis() || \
149 machine_is_osiris() )
150
145/* 151/*
146 * Set up timer interrupt, and return the current time in seconds. 152 * Set up timer interrupt, and return the current time in seconds.
147 * 153 *
@@ -165,7 +171,7 @@ static void s3c2410_timer_setup (void)
165 171
166 /* configure the system for whichever machine is in use */ 172 /* configure the system for whichever machine is in use */
167 173
168 if (machine_is_bast() || machine_is_vr1000() || machine_is_anubis()) { 174 if (use_tclk1_12()) {
169 /* timer is at 12MHz, scaler is 1 */ 175 /* timer is at 12MHz, scaler is 1 */
170 timer_usec_ticks = timer_mask_usec_ticks(1, 12000000); 176 timer_usec_ticks = timer_mask_usec_ticks(1, 12000000);
171 tcnt = 12000000 / HZ; 177 tcnt = 12000000 / HZ;
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
index e4a4a3e8aa8f..e27f15042a22 100644
--- a/arch/arm/mach-sa1100/Makefile
+++ b/arch/arm/mach-sa1100/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := generic.o irq.o dma.o time.o 6obj-y := clock.o generic.o irq.o dma.o time.o #nmi-oopser.o
7obj-m := 7obj-m :=
8obj-n := 8obj-n :=
9obj- := 9obj- :=
diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
new file mode 100644
index 000000000000..b1e8fd766c1a
--- /dev/null
+++ b/arch/arm/mach-sa1100/clock.c
@@ -0,0 +1,132 @@
1/*
2 * linux/arch/arm/mach-sa1100/clock.c
3 */
4#include <linux/module.h>
5#include <linux/kernel.h>
6#include <linux/list.h>
7#include <linux/errno.h>
8#include <linux/err.h>
9#include <linux/string.h>
10#include <linux/clk.h>
11#include <linux/spinlock.h>
12
13#include <asm/hardware.h>
14#include <asm/semaphore.h>
15
16struct clk {
17 struct list_head node;
18 unsigned long rate;
19 struct module *owner;
20 const char *name;
21 unsigned int enabled;
22 void (*enable)(void);
23 void (*disable)(void);
24};
25
26static LIST_HEAD(clocks);
27static DECLARE_MUTEX(clocks_sem);
28static DEFINE_SPINLOCK(clocks_lock);
29
30struct clk *clk_get(struct device *dev, const char *id)
31{
32 struct clk *p, *clk = ERR_PTR(-ENOENT);
33
34 down(&clocks_sem);
35 list_for_each_entry(p, &clocks, node) {
36 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
37 clk = p;
38 break;
39 }
40 }
41 up(&clocks_sem);
42
43 return clk;
44}
45EXPORT_SYMBOL(clk_get);
46
47void clk_put(struct clk *clk)
48{
49 module_put(clk->owner);
50}
51EXPORT_SYMBOL(clk_put);
52
53int clk_enable(struct clk *clk)
54{
55 unsigned long flags;
56
57 spin_lock_irqsave(&clocks_lock, flags);
58 if (clk->enabled++ == 0)
59 clk->enable();
60 spin_unlock_irqrestore(&clocks_lock, flags);
61 return 0;
62}
63EXPORT_SYMBOL(clk_enable);
64
65void clk_disable(struct clk *clk)
66{
67 unsigned long flags;
68
69 WARN_ON(clk->enabled == 0);
70
71 spin_lock_irqsave(&clocks_lock, flags);
72 if (--clk->enabled == 0)
73 clk->disable();
74 spin_unlock_irqrestore(&clocks_lock, flags);
75}
76EXPORT_SYMBOL(clk_disable);
77
78unsigned long clk_get_rate(struct clk *clk)
79{
80 return clk->rate;
81}
82EXPORT_SYMBOL(clk_get_rate);
83
84
85static void clk_gpio27_enable(void)
86{
87 /*
88 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
89 * (SA-1110 Developer's Manual, section 9.1.2.1)
90 */
91 GAFR |= GPIO_32_768kHz;
92 GPDR |= GPIO_32_768kHz;
93 TUCR = TUCR_3_6864MHz;
94}
95
96static void clk_gpio27_disable(void)
97{
98 TUCR = 0;
99 GPDR &= ~GPIO_32_768kHz;
100 GAFR &= ~GPIO_32_768kHz;
101}
102
103static struct clk clk_gpio27 = {
104 .name = "GPIO27_CLK",
105 .rate = 3686400,
106 .enable = clk_gpio27_enable,
107 .disable = clk_gpio27_disable,
108};
109
110int clk_register(struct clk *clk)
111{
112 down(&clocks_sem);
113 list_add(&clk->node, &clocks);
114 up(&clocks_sem);
115 return 0;
116}
117EXPORT_SYMBOL(clk_register);
118
119void clk_unregister(struct clk *clk)
120{
121 down(&clocks_sem);
122 list_del(&clk->node);
123 up(&clocks_sem);
124}
125EXPORT_SYMBOL(clk_unregister);
126
127static int __init clk_init(void)
128{
129 clk_register(&clk_gpio27);
130 return 0;
131}
132arch_initcall(clk_init);
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 9ebbe808b41d..799697d32dec 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -112,7 +112,7 @@ void __init versatile_init_irq(void)
112{ 112{
113 unsigned int i; 113 unsigned int i;
114 114
115 vic_init(VA_VIC_BASE, ~(1 << 31)); 115 vic_init(VA_VIC_BASE, IRQ_VIC_START, ~(1 << 31));
116 116
117 set_irq_handler(IRQ_VICSOURCE31, sic_handle_irq); 117 set_irq_handler(IRQ_VICSOURCE31, sic_handle_irq);
118 enable_irq(IRQ_VICSOURCE31); 118 enable_irq(IRQ_VICSOURCE31);
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 3b79d0e23455..eaaec90db972 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -62,7 +62,7 @@ config CPU_ARM720T
62# ARM920T 62# ARM920T
63config CPU_ARM920T 63config CPU_ARM920T
64 bool "Support ARM920T processor" if !ARCH_S3C2410 64 bool "Support ARM920T processor" if !ARCH_S3C2410
65 depends on ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX || ARCH_AAEC2000 || ARCH_AT91RM9200 65 depends on ARCH_EP93XX || ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX || ARCH_AAEC2000 || ARCH_AT91RM9200
66 default y if ARCH_S3C2410 || ARCH_AT91RM9200 66 default y if ARCH_S3C2410 || ARCH_AT91RM9200
67 select CPU_32v4 67 select CPU_32v4
68 select CPU_ABRT_EV4T 68 select CPU_ABRT_EV4T
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index b0321e943b76..88279124317a 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -19,7 +19,6 @@
19#include <linux/initrd.h> 19#include <linux/initrd.h>
20 20
21#include <asm/mach-types.h> 21#include <asm/mach-types.h>
22#include <asm/hardware.h>
23#include <asm/setup.h> 22#include <asm/setup.h>
24#include <asm/tlb.h> 23#include <asm/tlb.h>
25 24
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index da9b35974118..25e0ca3e598c 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -26,7 +26,6 @@
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27 27
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/hardware.h>
30#include <asm/io.h> 29#include <asm/io.h>
31#include <asm/tlbflush.h> 30#include <asm/tlbflush.h>
32 31
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 82ec954e45b6..3aa80094012c 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -32,7 +32,6 @@
32#include <asm/pgtable.h> 32#include <asm/pgtable.h>
33#include <asm/procinfo.h> 33#include <asm/procinfo.h>
34#include <asm/ptrace.h> 34#include <asm/ptrace.h>
35#include <asm/hardware.h>
36 35
37/* 36/*
38 * This is the maximum size of an area which will be invalidated 37 * This is the maximum size of an area which will be invalidated
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index 7375fe930f72..767d158f211a 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -32,7 +32,6 @@
32#include <asm/pgtable.h> 32#include <asm/pgtable.h>
33#include <asm/procinfo.h> 33#include <asm/procinfo.h>
34#include <asm/ptrace.h> 34#include <asm/ptrace.h>
35#include <asm/hardware.h>
36 35
37/* 36/*
38 * This is the maximum size of an area which will be invalidated 37 * This is the maximum size of an area which will be invalidated
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index a13e0184d343..471286fdf78f 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -37,7 +37,6 @@
37#include <asm/pgtable.h> 37#include <asm/pgtable.h>
38#include <asm/procinfo.h> 38#include <asm/procinfo.h>
39#include <asm/ptrace.h> 39#include <asm/ptrace.h>
40#include <asm/hardware.h>
41 40
42/* 41/*
43 * Function: arm720_proc_init (void) 42 * Function: arm720_proc_init (void)
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index d16513899999..950d3b664c1e 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -30,7 +30,6 @@
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/procinfo.h> 32#include <asm/procinfo.h>
33#include <asm/hardware.h>
34#include <asm/page.h> 33#include <asm/page.h>
35#include <asm/ptrace.h> 34#include <asm/ptrace.h>
36#include "proc-macros.S" 35#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index 23b8ed97f4e3..410b032faa3b 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -31,7 +31,6 @@
31#include <asm/assembler.h> 31#include <asm/assembler.h>
32#include <asm/pgtable.h> 32#include <asm/pgtable.h>
33#include <asm/procinfo.h> 33#include <asm/procinfo.h>
34#include <asm/hardware.h>
35#include <asm/page.h> 34#include <asm/page.h>
36#include <asm/ptrace.h> 35#include <asm/ptrace.h>
37#include "proc-macros.S" 36#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index ee95c52db513..6dd2be7cd050 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -53,7 +53,6 @@
53#include <asm/assembler.h> 53#include <asm/assembler.h>
54#include <asm/pgtable.h> 54#include <asm/pgtable.h>
55#include <asm/procinfo.h> 55#include <asm/procinfo.h>
56#include <asm/hardware.h>
57#include <asm/page.h> 56#include <asm/page.h>
58#include <asm/ptrace.h> 57#include <asm/ptrace.h>
59#include "proc-macros.S" 58#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 7d042dc20c47..022e86842041 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -30,7 +30,6 @@
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/procinfo.h> 32#include <asm/procinfo.h>
33#include <asm/hardware.h>
34#include <asm/page.h> 33#include <asm/page.h>
35#include <asm/ptrace.h> 34#include <asm/ptrace.h>
36#include "proc-macros.S" 35#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 2d3823ec3153..b50f87a0ee76 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -24,7 +24,6 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <asm/assembler.h> 25#include <asm/assembler.h>
26#include <asm/procinfo.h> 26#include <asm/procinfo.h>
27#include <asm/hardware.h>
28#include <asm/pgtable.h> 27#include <asm/pgtable.h>
29#include <asm/page.h> 28#include <asm/page.h>
30#include <asm/ptrace.h> 29#include <asm/ptrace.h>
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 6f8bc1f0e6a1..6f833358cd06 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -10,17 +10,18 @@
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/oprofile.h> 11#include <linux/oprofile.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/slab.h>
13#include <linux/sysdev.h> 14#include <linux/sysdev.h>
14#include <asm/semaphore.h> 15#include <linux/mutex.h>
15 16
16#include "op_counter.h" 17#include "op_counter.h"
17#include "op_arm_model.h" 18#include "op_arm_model.h"
18 19
19static struct op_arm_model_spec *op_arm_model; 20static struct op_arm_model_spec *op_arm_model;
20static int op_arm_enabled; 21static int op_arm_enabled;
21static struct semaphore op_arm_sem; 22static DEFINE_MUTEX(op_arm_mutex);
22 23
23struct op_counter_config counter_config[OP_MAX_COUNTER]; 24struct op_counter_config *counter_config;
24 25
25static int op_arm_create_files(struct super_block *sb, struct dentry *root) 26static int op_arm_create_files(struct super_block *sb, struct dentry *root)
26{ 27{
@@ -28,7 +29,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root)
28 29
29 for (i = 0; i < op_arm_model->num_counters; i++) { 30 for (i = 0; i < op_arm_model->num_counters; i++) {
30 struct dentry *dir; 31 struct dentry *dir;
31 char buf[2]; 32 char buf[4];
32 33
33 snprintf(buf, sizeof buf, "%d", i); 34 snprintf(buf, sizeof buf, "%d", i);
34 dir = oprofilefs_mkdir(sb, root, buf); 35 dir = oprofilefs_mkdir(sb, root, buf);
@@ -57,40 +58,40 @@ static int op_arm_start(void)
57{ 58{
58 int ret = -EBUSY; 59 int ret = -EBUSY;
59 60
60 down(&op_arm_sem); 61 mutex_lock(&op_arm_mutex);
61 if (!op_arm_enabled) { 62 if (!op_arm_enabled) {
62 ret = op_arm_model->start(); 63 ret = op_arm_model->start();
63 op_arm_enabled = !ret; 64 op_arm_enabled = !ret;
64 } 65 }
65 up(&op_arm_sem); 66 mutex_unlock(&op_arm_mutex);
66 return ret; 67 return ret;
67} 68}
68 69
69static void op_arm_stop(void) 70static void op_arm_stop(void)
70{ 71{
71 down(&op_arm_sem); 72 mutex_lock(&op_arm_mutex);
72 if (op_arm_enabled) 73 if (op_arm_enabled)
73 op_arm_model->stop(); 74 op_arm_model->stop();
74 op_arm_enabled = 0; 75 op_arm_enabled = 0;
75 up(&op_arm_sem); 76 mutex_unlock(&op_arm_mutex);
76} 77}
77 78
78#ifdef CONFIG_PM 79#ifdef CONFIG_PM
79static int op_arm_suspend(struct sys_device *dev, pm_message_t state) 80static int op_arm_suspend(struct sys_device *dev, pm_message_t state)
80{ 81{
81 down(&op_arm_sem); 82 mutex_lock(&op_arm_mutex);
82 if (op_arm_enabled) 83 if (op_arm_enabled)
83 op_arm_model->stop(); 84 op_arm_model->stop();
84 up(&op_arm_sem); 85 mutex_unlock(&op_arm_mutex);
85 return 0; 86 return 0;
86} 87}
87 88
88static int op_arm_resume(struct sys_device *dev) 89static int op_arm_resume(struct sys_device *dev)
89{ 90{
90 down(&op_arm_sem); 91 mutex_lock(&op_arm_mutex);
91 if (op_arm_enabled && op_arm_model->start()) 92 if (op_arm_enabled && op_arm_model->start())
92 op_arm_enabled = 0; 93 op_arm_enabled = 0;
93 up(&op_arm_sem); 94 mutex_unlock(&op_arm_mutex);
94 return 0; 95 return 0;
95} 96}
96 97
@@ -135,12 +136,15 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
135#endif 136#endif
136 137
137 if (spec) { 138 if (spec) {
138 init_MUTEX(&op_arm_sem);
139
140 ret = spec->init(); 139 ret = spec->init();
141 if (ret < 0) 140 if (ret < 0)
142 return ret; 141 return ret;
143 142
143 counter_config = kcalloc(spec->num_counters, sizeof(struct op_counter_config),
144 GFP_KERNEL);
145 if (!counter_config)
146 return -ENOMEM;
147
144 op_arm_model = spec; 148 op_arm_model = spec;
145 init_driverfs(); 149 init_driverfs();
146 ops->create_files = op_arm_create_files; 150 ops->create_files = op_arm_create_files;
@@ -162,5 +166,5 @@ void oprofile_arch_exit(void)
162 exit_driverfs(); 166 exit_driverfs();
163 op_arm_model = NULL; 167 op_arm_model = NULL;
164 } 168 }
169 kfree(counter_config);
165} 170}
166
diff --git a/arch/arm/oprofile/op_counter.h b/arch/arm/oprofile/op_counter.h
index 153c1d467f24..8c5351d751cf 100644
--- a/arch/arm/oprofile/op_counter.h
+++ b/arch/arm/oprofile/op_counter.h
@@ -24,6 +24,6 @@ struct op_counter_config {
24 unsigned long user; 24 unsigned long user;
25}; 25};
26 26
27extern struct op_counter_config counter_config[]; 27extern struct op_counter_config *counter_config;
28 28
29#endif /* OP_COUNTER_H */ 29#endif /* OP_COUNTER_H */
diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
index 6f17187ab32a..9ab1abfbe7ad 100644
--- a/arch/arm/vfp/entry.S
+++ b/arch/arm/vfp/entry.S
@@ -22,6 +22,7 @@
22 22
23 .globl do_vfp 23 .globl do_vfp
24do_vfp: 24do_vfp:
25 enable_irq
25 ldr r4, .LCvfp 26 ldr r4, .LCvfp
26 add r10, r10, #TI_VFPSTATE @ r10 = workspace 27 add r10, r10, #TI_VFPSTATE @ r10 = workspace
27 ldr pc, [r4] @ call VFP entry point 28 ldr pc, [r4] @ call VFP entry point
diff --git a/arch/cris/kernel/irq.c b/arch/cris/kernel/irq.c
index 30deaf1b728a..b504def3e346 100644
--- a/arch/cris/kernel/irq.c
+++ b/arch/cris/kernel/irq.c
@@ -52,9 +52,8 @@ int show_interrupts(struct seq_file *p, void *v)
52 52
53 if (i == 0) { 53 if (i == 0) {
54 seq_printf(p, " "); 54 seq_printf(p, " ");
55 for (j=0; j<NR_CPUS; j++) 55 for_each_online_cpu(j)
56 if (cpu_online(j)) 56 seq_printf(p, "CPU%d ",j);
57 seq_printf(p, "CPU%d ",j);
58 seq_putc(p, '\n'); 57 seq_putc(p, '\n');
59 } 58 }
60 59
@@ -67,9 +66,8 @@ int show_interrupts(struct seq_file *p, void *v)
67#ifndef CONFIG_SMP 66#ifndef CONFIG_SMP
68 seq_printf(p, "%10u ", kstat_irqs(i)); 67 seq_printf(p, "%10u ", kstat_irqs(i));
69#else 68#else
70 for (j = 0; j < NR_CPUS; j++) 69 for_each_online_cpu(j)
71 if (cpu_online(j)) 70 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
72 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
73#endif 71#endif
74 seq_printf(p, " %14s", irq_desc[i].handler->typename); 72 seq_printf(p, " %14s", irq_desc[i].handler->typename);
75 seq_printf(p, " %s", action->name); 73 seq_printf(p, " %s", action->name);
diff --git a/arch/frv/kernel/irq.c b/arch/frv/kernel/irq.c
index 27ab4c30aac6..11fa326a8f62 100644
--- a/arch/frv/kernel/irq.c
+++ b/arch/frv/kernel/irq.c
@@ -75,9 +75,8 @@ int show_interrupts(struct seq_file *p, void *v)
75 switch (i) { 75 switch (i) {
76 case 0: 76 case 0:
77 seq_printf(p, " "); 77 seq_printf(p, " ");
78 for (j = 0; j < NR_CPUS; j++) 78 for_each_online_cpu(j)
79 if (cpu_online(j)) 79 seq_printf(p, "CPU%d ",j);
80 seq_printf(p, "CPU%d ",j);
81 80
82 seq_putc(p, '\n'); 81 seq_putc(p, '\n');
83 break; 82 break;
@@ -100,9 +99,8 @@ int show_interrupts(struct seq_file *p, void *v)
100#ifndef CONFIG_SMP 99#ifndef CONFIG_SMP
101 seq_printf(p, "%10u ", kstat_irqs(i)); 100 seq_printf(p, "%10u ", kstat_irqs(i));
102#else 101#else
103 for (j = 0; j < NR_CPUS; j++) 102 for_each_online_cpu(j)
104 if (cpu_online(j)) 103 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i - 1]);
105 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i - 1]);
106#endif 104#endif
107 105
108 level = group->sources[ix]->level - frv_irq_levels; 106 level = group->sources[ix]->level - frv_irq_levels;
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 5b1a7d46d1d9..bfea1bedcbf2 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -80,6 +80,7 @@ config X86_VOYAGER
80 80
81config X86_NUMAQ 81config X86_NUMAQ
82 bool "NUMAQ (IBM/Sequent)" 82 bool "NUMAQ (IBM/Sequent)"
83 select SMP
83 select NUMA 84 select NUMA
84 help 85 help
85 This option is used for getting Linux to run on a (IBM/Sequent) NUMA 86 This option is used for getting Linux to run on a (IBM/Sequent) NUMA
@@ -400,6 +401,7 @@ choice
400 401
401config NOHIGHMEM 402config NOHIGHMEM
402 bool "off" 403 bool "off"
404 depends on !X86_NUMAQ
403 ---help--- 405 ---help---
404 Linux can use up to 64 Gigabytes of physical memory on x86 systems. 406 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
405 However, the address space of 32-bit x86 processors is only 4 407 However, the address space of 32-bit x86 processors is only 4
@@ -436,6 +438,7 @@ config NOHIGHMEM
436 438
437config HIGHMEM4G 439config HIGHMEM4G
438 bool "4GB" 440 bool "4GB"
441 depends on !X86_NUMAQ
439 help 442 help
440 Select this if you have a 32-bit processor and between 1 and 4 443 Select this if you have a 32-bit processor and between 1 and 4
441 gigabytes of physical RAM. 444 gigabytes of physical RAM.
@@ -503,10 +506,6 @@ config NUMA
503 default n if X86_PC 506 default n if X86_PC
504 default y if (X86_NUMAQ || X86_SUMMIT) 507 default y if (X86_NUMAQ || X86_SUMMIT)
505 508
506# Need comments to help the hapless user trying to turn on NUMA support
507comment "NUMA (NUMA-Q) requires SMP, 64GB highmem support"
508 depends on X86_NUMAQ && (!HIGHMEM64G || !SMP)
509
510comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI" 509comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
511 depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI) 510 depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI)
512 511
@@ -660,13 +659,18 @@ config BOOT_IOREMAP
660 default y 659 default y
661 660
662config REGPARM 661config REGPARM
663 bool "Use register arguments (EXPERIMENTAL)" 662 bool "Use register arguments"
664 depends on EXPERIMENTAL 663 default y
665 default n
666 help 664 help
667 Compile the kernel with -mregparm=3. This uses a different ABI 665 Compile the kernel with -mregparm=3. This instructs gcc to use
668 and passes the first three arguments of a function call in registers. 666 a more efficient function call ABI which passes the first three
669 This will probably break binary only modules. 667 arguments of a function call via registers, which results in denser
668 and faster code.
669
670 If this option is disabled, then the default ABI of passing
671 arguments via the stack is used.
672
673 If unsure, say Y.
670 674
671config SECCOMP 675config SECCOMP
672 bool "Enable seccomp to safely compute untrusted bytecode" 676 bool "Enable seccomp to safely compute untrusted bytecode"
diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug
index bf32ecc9ad04..00108ba9a78d 100644
--- a/arch/i386/Kconfig.debug
+++ b/arch/i386/Kconfig.debug
@@ -31,6 +31,15 @@ config DEBUG_STACK_USAGE
31 31
32 This option will slow down process creation somewhat. 32 This option will slow down process creation somewhat.
33 33
34config STACK_BACKTRACE_COLS
35 int "Stack backtraces per line" if DEBUG_KERNEL
36 range 1 3
37 default 2
38 help
39 Selects how many stack backtrace entries per line to display.
40
41 This can save screen space when displaying traces.
42
34comment "Page alloc debug is incompatible with Software Suspend on i386" 43comment "Page alloc debug is incompatible with Software Suspend on i386"
35 depends on DEBUG_KERNEL && SOFTWARE_SUSPEND 44 depends on DEBUG_KERNEL && SOFTWARE_SUSPEND
36 45
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 65656c033d70..5b9ed21216cf 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds
7obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \
8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
9 pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ 9 pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
10 quirks.o i8237.o topology.o 10 quirks.o i8237.o topology.o alternative.o
11 11
12obj-y += cpu/ 12obj-y += cpu/
13obj-y += timers/ 13obj-y += timers/
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
new file mode 100644
index 000000000000..5cbd6f99fb2a
--- /dev/null
+++ b/arch/i386/kernel/alternative.c
@@ -0,0 +1,321 @@
1#include <linux/module.h>
2#include <linux/spinlock.h>
3#include <linux/list.h>
4#include <asm/alternative.h>
5#include <asm/sections.h>
6
7#define DEBUG 0
8#if DEBUG
9# define DPRINTK(fmt, args...) printk(fmt, args)
10#else
11# define DPRINTK(fmt, args...)
12#endif
13
14/* Use inline assembly to define this because the nops are defined
15 as inline assembly strings in the include files and we cannot
16 get them easily into strings. */
17asm("\t.data\nintelnops: "
18 GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
19 GENERIC_NOP7 GENERIC_NOP8);
20asm("\t.data\nk8nops: "
21 K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
22 K8_NOP7 K8_NOP8);
23asm("\t.data\nk7nops: "
24 K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
25 K7_NOP7 K7_NOP8);
26
27extern unsigned char intelnops[], k8nops[], k7nops[];
28static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
29 NULL,
30 intelnops,
31 intelnops + 1,
32 intelnops + 1 + 2,
33 intelnops + 1 + 2 + 3,
34 intelnops + 1 + 2 + 3 + 4,
35 intelnops + 1 + 2 + 3 + 4 + 5,
36 intelnops + 1 + 2 + 3 + 4 + 5 + 6,
37 intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
38};
39static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
40 NULL,
41 k8nops,
42 k8nops + 1,
43 k8nops + 1 + 2,
44 k8nops + 1 + 2 + 3,
45 k8nops + 1 + 2 + 3 + 4,
46 k8nops + 1 + 2 + 3 + 4 + 5,
47 k8nops + 1 + 2 + 3 + 4 + 5 + 6,
48 k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
49};
50static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
51 NULL,
52 k7nops,
53 k7nops + 1,
54 k7nops + 1 + 2,
55 k7nops + 1 + 2 + 3,
56 k7nops + 1 + 2 + 3 + 4,
57 k7nops + 1 + 2 + 3 + 4 + 5,
58 k7nops + 1 + 2 + 3 + 4 + 5 + 6,
59 k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
60};
61static struct nop {
62 int cpuid;
63 unsigned char **noptable;
64} noptypes[] = {
65 { X86_FEATURE_K8, k8_nops },
66 { X86_FEATURE_K7, k7_nops },
67 { -1, NULL }
68};
69
70
71extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
72extern struct alt_instr __smp_alt_instructions[], __smp_alt_instructions_end[];
73extern u8 *__smp_locks[], *__smp_locks_end[];
74
75extern u8 __smp_alt_begin[], __smp_alt_end[];
76
77
78static unsigned char** find_nop_table(void)
79{
80 unsigned char **noptable = intel_nops;
81 int i;
82
83 for (i = 0; noptypes[i].cpuid >= 0; i++) {
84 if (boot_cpu_has(noptypes[i].cpuid)) {
85 noptable = noptypes[i].noptable;
86 break;
87 }
88 }
89 return noptable;
90}
91
92/* Replace instructions with better alternatives for this CPU type.
93 This runs before SMP is initialized to avoid SMP problems with
94 self modifying code. This implies that assymetric systems where
95 APs have less capabilities than the boot processor are not handled.
96 Tough. Make sure you disable such features by hand. */
97
98void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
99{
100 unsigned char **noptable = find_nop_table();
101 struct alt_instr *a;
102 int diff, i, k;
103
104 DPRINTK("%s: alt table %p -> %p\n", __FUNCTION__, start, end);
105 for (a = start; a < end; a++) {
106 BUG_ON(a->replacementlen > a->instrlen);
107 if (!boot_cpu_has(a->cpuid))
108 continue;
109 memcpy(a->instr, a->replacement, a->replacementlen);
110 diff = a->instrlen - a->replacementlen;
111 /* Pad the rest with nops */
112 for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
113 k = diff;
114 if (k > ASM_NOP_MAX)
115 k = ASM_NOP_MAX;
116 memcpy(a->instr + i, noptable[k], k);
117 }
118 }
119}
120
121static void alternatives_smp_save(struct alt_instr *start, struct alt_instr *end)
122{
123 struct alt_instr *a;
124
125 DPRINTK("%s: alt table %p-%p\n", __FUNCTION__, start, end);
126 for (a = start; a < end; a++) {
127 memcpy(a->replacement + a->replacementlen,
128 a->instr,
129 a->instrlen);
130 }
131}
132
133static void alternatives_smp_apply(struct alt_instr *start, struct alt_instr *end)
134{
135 struct alt_instr *a;
136
137 for (a = start; a < end; a++) {
138 memcpy(a->instr,
139 a->replacement + a->replacementlen,
140 a->instrlen);
141 }
142}
143
144static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
145{
146 u8 **ptr;
147
148 for (ptr = start; ptr < end; ptr++) {
149 if (*ptr < text)
150 continue;
151 if (*ptr > text_end)
152 continue;
153 **ptr = 0xf0; /* lock prefix */
154 };
155}
156
157static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end)
158{
159 unsigned char **noptable = find_nop_table();
160 u8 **ptr;
161
162 for (ptr = start; ptr < end; ptr++) {
163 if (*ptr < text)
164 continue;
165 if (*ptr > text_end)
166 continue;
167 **ptr = noptable[1][0];
168 };
169}
170
171struct smp_alt_module {
172 /* what is this ??? */
173 struct module *mod;
174 char *name;
175
176 /* ptrs to lock prefixes */
177 u8 **locks;
178 u8 **locks_end;
179
180 /* .text segment, needed to avoid patching init code ;) */
181 u8 *text;
182 u8 *text_end;
183
184 struct list_head next;
185};
186static LIST_HEAD(smp_alt_modules);
187static DEFINE_SPINLOCK(smp_alt);
188
189static int smp_alt_once = 0;
190static int __init bootonly(char *str)
191{
192 smp_alt_once = 1;
193 return 1;
194}
195__setup("smp-alt-boot", bootonly);
196
197void alternatives_smp_module_add(struct module *mod, char *name,
198 void *locks, void *locks_end,
199 void *text, void *text_end)
200{
201 struct smp_alt_module *smp;
202 unsigned long flags;
203
204 if (smp_alt_once) {
205 if (boot_cpu_has(X86_FEATURE_UP))
206 alternatives_smp_unlock(locks, locks_end,
207 text, text_end);
208 return;
209 }
210
211 smp = kzalloc(sizeof(*smp), GFP_KERNEL);
212 if (NULL == smp)
213 return; /* we'll run the (safe but slow) SMP code then ... */
214
215 smp->mod = mod;
216 smp->name = name;
217 smp->locks = locks;
218 smp->locks_end = locks_end;
219 smp->text = text;
220 smp->text_end = text_end;
221 DPRINTK("%s: locks %p -> %p, text %p -> %p, name %s\n",
222 __FUNCTION__, smp->locks, smp->locks_end,
223 smp->text, smp->text_end, smp->name);
224
225 spin_lock_irqsave(&smp_alt, flags);
226 list_add_tail(&smp->next, &smp_alt_modules);
227 if (boot_cpu_has(X86_FEATURE_UP))
228 alternatives_smp_unlock(smp->locks, smp->locks_end,
229 smp->text, smp->text_end);
230 spin_unlock_irqrestore(&smp_alt, flags);
231}
232
233void alternatives_smp_module_del(struct module *mod)
234{
235 struct smp_alt_module *item;
236 unsigned long flags;
237
238 if (smp_alt_once)
239 return;
240
241 spin_lock_irqsave(&smp_alt, flags);
242 list_for_each_entry(item, &smp_alt_modules, next) {
243 if (mod != item->mod)
244 continue;
245 list_del(&item->next);
246 spin_unlock_irqrestore(&smp_alt, flags);
247 DPRINTK("%s: %s\n", __FUNCTION__, item->name);
248 kfree(item);
249 return;
250 }
251 spin_unlock_irqrestore(&smp_alt, flags);
252}
253
254void alternatives_smp_switch(int smp)
255{
256 struct smp_alt_module *mod;
257 unsigned long flags;
258
259 if (smp_alt_once)
260 return;
261 BUG_ON(!smp && (num_online_cpus() > 1));
262
263 spin_lock_irqsave(&smp_alt, flags);
264 if (smp) {
265 printk(KERN_INFO "SMP alternatives: switching to SMP code\n");
266 clear_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
267 clear_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
268 alternatives_smp_apply(__smp_alt_instructions,
269 __smp_alt_instructions_end);
270 list_for_each_entry(mod, &smp_alt_modules, next)
271 alternatives_smp_lock(mod->locks, mod->locks_end,
272 mod->text, mod->text_end);
273 } else {
274 printk(KERN_INFO "SMP alternatives: switching to UP code\n");
275 set_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
276 set_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
277 apply_alternatives(__smp_alt_instructions,
278 __smp_alt_instructions_end);
279 list_for_each_entry(mod, &smp_alt_modules, next)
280 alternatives_smp_unlock(mod->locks, mod->locks_end,
281 mod->text, mod->text_end);
282 }
283 spin_unlock_irqrestore(&smp_alt, flags);
284}
285
286void __init alternative_instructions(void)
287{
288 apply_alternatives(__alt_instructions, __alt_instructions_end);
289
290 /* switch to patch-once-at-boottime-only mode and free the
291 * tables in case we know the number of CPUs will never ever
292 * change */
293#ifdef CONFIG_HOTPLUG_CPU
294 if (num_possible_cpus() < 2)
295 smp_alt_once = 1;
296#else
297 smp_alt_once = 1;
298#endif
299
300 if (smp_alt_once) {
301 if (1 == num_possible_cpus()) {
302 printk(KERN_INFO "SMP alternatives: switching to UP code\n");
303 set_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
304 set_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
305 apply_alternatives(__smp_alt_instructions,
306 __smp_alt_instructions_end);
307 alternatives_smp_unlock(__smp_locks, __smp_locks_end,
308 _text, _etext);
309 }
310 free_init_pages("SMP alternatives",
311 (unsigned long)__smp_alt_begin,
312 (unsigned long)__smp_alt_end);
313 } else {
314 alternatives_smp_save(__smp_alt_instructions,
315 __smp_alt_instructions_end);
316 alternatives_smp_module_add(NULL, "core kernel",
317 __smp_locks, __smp_locks_end,
318 _text, _etext);
319 alternatives_smp_switch(0);
320 }
321}
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 776c90989e06..eb5279d23b7f 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -38,6 +38,7 @@
38#include <asm/i8253.h> 38#include <asm/i8253.h>
39 39
40#include <mach_apic.h> 40#include <mach_apic.h>
41#include <mach_apicdef.h>
41#include <mach_ipi.h> 42#include <mach_ipi.h>
42 43
43#include "io_ports.h" 44#include "io_ports.h"
diff --git a/arch/i386/kernel/cpu/centaur.c b/arch/i386/kernel/cpu/centaur.c
index f52669ecb93f..bd75629dd262 100644
--- a/arch/i386/kernel/cpu/centaur.c
+++ b/arch/i386/kernel/cpu/centaur.c
@@ -4,6 +4,7 @@
4#include <asm/processor.h> 4#include <asm/processor.h>
5#include <asm/msr.h> 5#include <asm/msr.h>
6#include <asm/e820.h> 6#include <asm/e820.h>
7#include <asm/mtrr.h>
7#include "cpu.h" 8#include "cpu.h"
8 9
9#ifdef CONFIG_X86_OOSTORE 10#ifdef CONFIG_X86_OOSTORE
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index e6bd095ae108..7e3d6b6a4e96 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -25,9 +25,10 @@ EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr);
25DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); 25DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);
26EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack); 26EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack);
27 27
28static int cachesize_override __devinitdata = -1; 28static int cachesize_override __cpuinitdata = -1;
29static int disable_x86_fxsr __devinitdata = 0; 29static int disable_x86_fxsr __cpuinitdata;
30static int disable_x86_serial_nr __devinitdata = 1; 30static int disable_x86_serial_nr __cpuinitdata = 1;
31static int disable_x86_sep __cpuinitdata;
31 32
32struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {}; 33struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
33 34
@@ -59,7 +60,7 @@ static int __init cachesize_setup(char *str)
59} 60}
60__setup("cachesize=", cachesize_setup); 61__setup("cachesize=", cachesize_setup);
61 62
62int __devinit get_model_name(struct cpuinfo_x86 *c) 63int __cpuinit get_model_name(struct cpuinfo_x86 *c)
63{ 64{
64 unsigned int *v; 65 unsigned int *v;
65 char *p, *q; 66 char *p, *q;
@@ -89,7 +90,7 @@ int __devinit get_model_name(struct cpuinfo_x86 *c)
89} 90}
90 91
91 92
92void __devinit display_cacheinfo(struct cpuinfo_x86 *c) 93void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
93{ 94{
94 unsigned int n, dummy, ecx, edx, l2size; 95 unsigned int n, dummy, ecx, edx, l2size;
95 96
@@ -130,7 +131,7 @@ void __devinit display_cacheinfo(struct cpuinfo_x86 *c)
130/* in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */ 131/* in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */
131 132
132/* Look up CPU names by table lookup. */ 133/* Look up CPU names by table lookup. */
133static char __devinit *table_lookup_model(struct cpuinfo_x86 *c) 134static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
134{ 135{
135 struct cpu_model_info *info; 136 struct cpu_model_info *info;
136 137
@@ -151,7 +152,7 @@ static char __devinit *table_lookup_model(struct cpuinfo_x86 *c)
151} 152}
152 153
153 154
154static void __devinit get_cpu_vendor(struct cpuinfo_x86 *c, int early) 155static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
155{ 156{
156 char *v = c->x86_vendor_id; 157 char *v = c->x86_vendor_id;
157 int i; 158 int i;
@@ -187,6 +188,14 @@ static int __init x86_fxsr_setup(char * s)
187__setup("nofxsr", x86_fxsr_setup); 188__setup("nofxsr", x86_fxsr_setup);
188 189
189 190
191static int __init x86_sep_setup(char * s)
192{
193 disable_x86_sep = 1;
194 return 1;
195}
196__setup("nosep", x86_sep_setup);
197
198
190/* Standard macro to see if a specific flag is changeable */ 199/* Standard macro to see if a specific flag is changeable */
191static inline int flag_is_changeable_p(u32 flag) 200static inline int flag_is_changeable_p(u32 flag)
192{ 201{
@@ -210,7 +219,7 @@ static inline int flag_is_changeable_p(u32 flag)
210 219
211 220
212/* Probe for the CPUID instruction */ 221/* Probe for the CPUID instruction */
213static int __devinit have_cpuid_p(void) 222static int __cpuinit have_cpuid_p(void)
214{ 223{
215 return flag_is_changeable_p(X86_EFLAGS_ID); 224 return flag_is_changeable_p(X86_EFLAGS_ID);
216} 225}
@@ -254,7 +263,7 @@ static void __init early_cpu_detect(void)
254 } 263 }
255} 264}
256 265
257void __devinit generic_identify(struct cpuinfo_x86 * c) 266void __cpuinit generic_identify(struct cpuinfo_x86 * c)
258{ 267{
259 u32 tfms, xlvl; 268 u32 tfms, xlvl;
260 int junk; 269 int junk;
@@ -307,7 +316,7 @@ void __devinit generic_identify(struct cpuinfo_x86 * c)
307#endif 316#endif
308} 317}
309 318
310static void __devinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) 319static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
311{ 320{
312 if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) { 321 if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) {
313 /* Disable processor serial number */ 322 /* Disable processor serial number */
@@ -335,7 +344,7 @@ __setup("serialnumber", x86_serial_nr_setup);
335/* 344/*
336 * This does the hard work of actually picking apart the CPU stuff... 345 * This does the hard work of actually picking apart the CPU stuff...
337 */ 346 */
338void __devinit identify_cpu(struct cpuinfo_x86 *c) 347void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
339{ 348{
340 int i; 349 int i;
341 350
@@ -405,6 +414,10 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
405 clear_bit(X86_FEATURE_XMM, c->x86_capability); 414 clear_bit(X86_FEATURE_XMM, c->x86_capability);
406 } 415 }
407 416
417 /* SEP disabled? */
418 if (disable_x86_sep)
419 clear_bit(X86_FEATURE_SEP, c->x86_capability);
420
408 if (disable_pse) 421 if (disable_pse)
409 clear_bit(X86_FEATURE_PSE, c->x86_capability); 422 clear_bit(X86_FEATURE_PSE, c->x86_capability);
410 423
@@ -417,7 +430,7 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
417 else 430 else
418 /* Last resort... */ 431 /* Last resort... */
419 sprintf(c->x86_model_id, "%02x/%02x", 432 sprintf(c->x86_model_id, "%02x/%02x",
420 c->x86_vendor, c->x86_model); 433 c->x86, c->x86_model);
421 } 434 }
422 435
423 /* Now the feature flags better reflect actual CPU features! */ 436 /* Now the feature flags better reflect actual CPU features! */
@@ -453,7 +466,7 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
453} 466}
454 467
455#ifdef CONFIG_X86_HT 468#ifdef CONFIG_X86_HT
456void __devinit detect_ht(struct cpuinfo_x86 *c) 469void __cpuinit detect_ht(struct cpuinfo_x86 *c)
457{ 470{
458 u32 eax, ebx, ecx, edx; 471 u32 eax, ebx, ecx, edx;
459 int index_msb, core_bits; 472 int index_msb, core_bits;
@@ -500,7 +513,7 @@ void __devinit detect_ht(struct cpuinfo_x86 *c)
500} 513}
501#endif 514#endif
502 515
503void __devinit print_cpu_info(struct cpuinfo_x86 *c) 516void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
504{ 517{
505 char *vendor = NULL; 518 char *vendor = NULL;
506 519
@@ -523,7 +536,7 @@ void __devinit print_cpu_info(struct cpuinfo_x86 *c)
523 printk("\n"); 536 printk("\n");
524} 537}
525 538
526cpumask_t cpu_initialized __devinitdata = CPU_MASK_NONE; 539cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
527 540
528/* This is hacky. :) 541/* This is hacky. :)
529 * We're emulating future behavior. 542 * We're emulating future behavior.
@@ -570,7 +583,7 @@ void __init early_cpu_init(void)
570 * and IDT. We reload them nevertheless, this function acts as a 583 * and IDT. We reload them nevertheless, this function acts as a
571 * 'CPU state barrier', nothing should get across. 584 * 'CPU state barrier', nothing should get across.
572 */ 585 */
573void __devinit cpu_init(void) 586void __cpuinit cpu_init(void)
574{ 587{
575 int cpu = smp_processor_id(); 588 int cpu = smp_processor_id();
576 struct tss_struct * t = &per_cpu(init_tss, cpu); 589 struct tss_struct * t = &per_cpu(init_tss, cpu);
@@ -670,7 +683,7 @@ void __devinit cpu_init(void)
670} 683}
671 684
672#ifdef CONFIG_HOTPLUG_CPU 685#ifdef CONFIG_HOTPLUG_CPU
673void __devinit cpu_uninit(void) 686void __cpuinit cpu_uninit(void)
674{ 687{
675 int cpu = raw_smp_processor_id(); 688 int cpu = raw_smp_processor_id();
676 cpu_clear(cpu, cpu_initialized); 689 cpu_clear(cpu, cpu_initialized);
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index e11a09207ec8..3d5110b65cc3 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -1145,9 +1145,7 @@ static int __cpuinit powernowk8_init(void)
1145{ 1145{
1146 unsigned int i, supported_cpus = 0; 1146 unsigned int i, supported_cpus = 0;
1147 1147
1148 for (i=0; i<NR_CPUS; i++) { 1148 for_each_cpu(i) {
1149 if (!cpu_online(i))
1150 continue;
1151 if (check_supported_cpu(i)) 1149 if (check_supported_cpu(i))
1152 supported_cpus++; 1150 supported_cpus++;
1153 } 1151 }
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 8c0120186b9f..5386b29bb5a5 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -29,7 +29,7 @@ extern int trap_init_f00f_bug(void);
29struct movsl_mask movsl_mask __read_mostly; 29struct movsl_mask movsl_mask __read_mostly;
30#endif 30#endif
31 31
32void __devinit early_intel_workaround(struct cpuinfo_x86 *c) 32void __cpuinit early_intel_workaround(struct cpuinfo_x86 *c)
33{ 33{
34 if (c->x86_vendor != X86_VENDOR_INTEL) 34 if (c->x86_vendor != X86_VENDOR_INTEL)
35 return; 35 return;
@@ -44,7 +44,7 @@ void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
44 * This is called before we do cpu ident work 44 * This is called before we do cpu ident work
45 */ 45 */
46 46
47int __devinit ppro_with_ram_bug(void) 47int __cpuinit ppro_with_ram_bug(void)
48{ 48{
49 /* Uses data from early_cpu_detect now */ 49 /* Uses data from early_cpu_detect now */
50 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && 50 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
@@ -62,7 +62,7 @@ int __devinit ppro_with_ram_bug(void)
62 * P4 Xeon errata 037 workaround. 62 * P4 Xeon errata 037 workaround.
63 * Hardware prefetcher may cause stale data to be loaded into the cache. 63 * Hardware prefetcher may cause stale data to be loaded into the cache.
64 */ 64 */
65static void __devinit Intel_errata_workarounds(struct cpuinfo_x86 *c) 65static void __cpuinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
66{ 66{
67 unsigned long lo, hi; 67 unsigned long lo, hi;
68 68
@@ -81,7 +81,7 @@ static void __devinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
81/* 81/*
82 * find out the number of processor cores on the die 82 * find out the number of processor cores on the die
83 */ 83 */
84static int __devinit num_cpu_cores(struct cpuinfo_x86 *c) 84static int __cpuinit num_cpu_cores(struct cpuinfo_x86 *c)
85{ 85{
86 unsigned int eax, ebx, ecx, edx; 86 unsigned int eax, ebx, ecx, edx;
87 87
@@ -96,7 +96,7 @@ static int __devinit num_cpu_cores(struct cpuinfo_x86 *c)
96 return 1; 96 return 1;
97} 97}
98 98
99static void __devinit init_intel(struct cpuinfo_x86 *c) 99static void __cpuinit init_intel(struct cpuinfo_x86 *c)
100{ 100{
101 unsigned int l2 = 0; 101 unsigned int l2 = 0;
102 char *p = NULL; 102 char *p = NULL;
@@ -205,7 +205,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
205 return size; 205 return size;
206} 206}
207 207
208static struct cpu_dev intel_cpu_dev __devinitdata = { 208static struct cpu_dev intel_cpu_dev __cpuinitdata = {
209 .c_vendor = "Intel", 209 .c_vendor = "Intel",
210 .c_ident = { "GenuineIntel" }, 210 .c_ident = { "GenuineIntel" },
211 .c_models = { 211 .c_models = {
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index ffe58cee0c48..ce61921369e5 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -174,7 +174,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
174 unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */ 174 unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
175 unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */ 175 unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
176 176
177 if (c->cpuid_level > 4) { 177 if (c->cpuid_level > 3) {
178 static int is_initialized; 178 static int is_initialized;
179 179
180 if (is_initialized == 0) { 180 if (is_initialized == 0) {
@@ -330,7 +330,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
330 } 330 }
331 } 331 }
332} 332}
333static void __devinit cache_remove_shared_cpu_map(unsigned int cpu, int index) 333static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
334{ 334{
335 struct _cpuid4_info *this_leaf, *sibling_leaf; 335 struct _cpuid4_info *this_leaf, *sibling_leaf;
336 int sibling; 336 int sibling;
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 89a85af33d28..5cfbd8011698 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -40,7 +40,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
40 /* Other (Linux-defined) */ 40 /* Other (Linux-defined) */
41 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr", 41 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
42 NULL, NULL, NULL, NULL, 42 NULL, NULL, NULL, NULL,
43 "constant_tsc", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 43 "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
44 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 44 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
46 46
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index d49dbe8dc96b..e3c5fca0aa8a 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -105,7 +105,7 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu)
105 return 1; 105 return 1;
106 local_irq_disable(); 106 local_irq_disable();
107 107
108 if (!user_mode(regs)) { 108 if (!user_mode_vm(regs)) {
109 crash_fixup_ss_esp(&fixed_regs, regs); 109 crash_fixup_ss_esp(&fixed_regs, regs);
110 regs = &fixed_regs; 110 regs = &fixed_regs;
111 } 111 }
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 4d704724b2f5..cfc683f153b9 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -226,6 +226,10 @@ ENTRY(system_call)
226 pushl %eax # save orig_eax 226 pushl %eax # save orig_eax
227 SAVE_ALL 227 SAVE_ALL
228 GET_THREAD_INFO(%ebp) 228 GET_THREAD_INFO(%ebp)
229 testl $TF_MASK,EFLAGS(%esp)
230 jz no_singlestep
231 orl $_TIF_SINGLESTEP,TI_flags(%ebp)
232no_singlestep:
229 # system call tracing in operation / emulation 233 # system call tracing in operation / emulation
230 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */ 234 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
231 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp) 235 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index e0b7c632efbc..3debc2e26542 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -450,7 +450,6 @@ int_msg:
450 450
451.globl boot_gdt_descr 451.globl boot_gdt_descr
452.globl idt_descr 452.globl idt_descr
453.globl cpu_gdt_descr
454 453
455 ALIGN 454 ALIGN
456# early boot GDT descriptor (must use 1:1 address mapping) 455# early boot GDT descriptor (must use 1:1 address mapping)
@@ -470,8 +469,6 @@ cpu_gdt_descr:
470 .word GDT_ENTRIES*8-1 469 .word GDT_ENTRIES*8-1
471 .long cpu_gdt_table 470 .long cpu_gdt_table
472 471
473 .fill NR_CPUS-1,8,0 # space for the other GDT descriptors
474
475/* 472/*
476 * The boot_gdt_table must mirror the equivalent in setup.S and is 473 * The boot_gdt_table must mirror the equivalent in setup.S and is
477 * used only for booting. 474 * used only for booting.
@@ -485,7 +482,7 @@ ENTRY(boot_gdt_table)
485/* 482/*
486 * The Global Descriptor Table contains 28 quadwords, per-CPU. 483 * The Global Descriptor Table contains 28 quadwords, per-CPU.
487 */ 484 */
488 .align PAGE_SIZE_asm 485 .align L1_CACHE_BYTES
489ENTRY(cpu_gdt_table) 486ENTRY(cpu_gdt_table)
490 .quad 0x0000000000000000 /* NULL descriptor */ 487 .quad 0x0000000000000000 /* NULL descriptor */
491 .quad 0x0000000000000000 /* 0x0b reserved */ 488 .quad 0x0000000000000000 /* 0x0b reserved */
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 39d9a5fa907e..311b4e7266f1 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -351,8 +351,8 @@ static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold)
351{ 351{
352 int i, j; 352 int i, j;
353 Dprintk("Rotating IRQs among CPUs.\n"); 353 Dprintk("Rotating IRQs among CPUs.\n");
354 for (i = 0; i < NR_CPUS; i++) { 354 for_each_online_cpu(i) {
355 for (j = 0; cpu_online(i) && (j < NR_IRQS); j++) { 355 for (j = 0; j < NR_IRQS; j++) {
356 if (!irq_desc[j].action) 356 if (!irq_desc[j].action)
357 continue; 357 continue;
358 /* Is it a significant load ? */ 358 /* Is it a significant load ? */
@@ -381,7 +381,7 @@ static void do_irq_balance(void)
381 unsigned long imbalance = 0; 381 unsigned long imbalance = 0;
382 cpumask_t allowed_mask, target_cpu_mask, tmp; 382 cpumask_t allowed_mask, target_cpu_mask, tmp;
383 383
384 for (i = 0; i < NR_CPUS; i++) { 384 for_each_cpu(i) {
385 int package_index; 385 int package_index;
386 CPU_IRQ(i) = 0; 386 CPU_IRQ(i) = 0;
387 if (!cpu_online(i)) 387 if (!cpu_online(i))
@@ -422,9 +422,7 @@ static void do_irq_balance(void)
422 } 422 }
423 } 423 }
424 /* Find the least loaded processor package */ 424 /* Find the least loaded processor package */
425 for (i = 0; i < NR_CPUS; i++) { 425 for_each_online_cpu(i) {
426 if (!cpu_online(i))
427 continue;
428 if (i != CPU_TO_PACKAGEINDEX(i)) 426 if (i != CPU_TO_PACKAGEINDEX(i))
429 continue; 427 continue;
430 if (min_cpu_irq > CPU_IRQ(i)) { 428 if (min_cpu_irq > CPU_IRQ(i)) {
@@ -441,9 +439,7 @@ tryanothercpu:
441 */ 439 */
442 tmp_cpu_irq = 0; 440 tmp_cpu_irq = 0;
443 tmp_loaded = -1; 441 tmp_loaded = -1;
444 for (i = 0; i < NR_CPUS; i++) { 442 for_each_online_cpu(i) {
445 if (!cpu_online(i))
446 continue;
447 if (i != CPU_TO_PACKAGEINDEX(i)) 443 if (i != CPU_TO_PACKAGEINDEX(i))
448 continue; 444 continue;
449 if (max_cpu_irq <= CPU_IRQ(i)) 445 if (max_cpu_irq <= CPU_IRQ(i))
@@ -619,9 +615,7 @@ static int __init balanced_irq_init(void)
619 if (smp_num_siblings > 1 && !cpus_empty(tmp)) 615 if (smp_num_siblings > 1 && !cpus_empty(tmp))
620 physical_balance = 1; 616 physical_balance = 1;
621 617
622 for (i = 0; i < NR_CPUS; i++) { 618 for_each_online_cpu(i) {
623 if (!cpu_online(i))
624 continue;
625 irq_cpu_data[i].irq_delta = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL); 619 irq_cpu_data[i].irq_delta = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL);
626 irq_cpu_data[i].last_irq = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL); 620 irq_cpu_data[i].last_irq = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL);
627 if (irq_cpu_data[i].irq_delta == NULL || irq_cpu_data[i].last_irq == NULL) { 621 if (irq_cpu_data[i].irq_delta == NULL || irq_cpu_data[i].last_irq == NULL) {
@@ -638,9 +632,11 @@ static int __init balanced_irq_init(void)
638 else 632 else
639 printk(KERN_ERR "balanced_irq_init: failed to spawn balanced_irq"); 633 printk(KERN_ERR "balanced_irq_init: failed to spawn balanced_irq");
640failed: 634failed:
641 for (i = 0; i < NR_CPUS; i++) { 635 for_each_cpu(i) {
642 kfree(irq_cpu_data[i].irq_delta); 636 kfree(irq_cpu_data[i].irq_delta);
637 irq_cpu_data[i].irq_delta = NULL;
643 kfree(irq_cpu_data[i].last_irq); 638 kfree(irq_cpu_data[i].last_irq);
639 irq_cpu_data[i].last_irq = NULL;
644 } 640 }
645 return 0; 641 return 0;
646} 642}
@@ -1761,7 +1757,8 @@ static void __init setup_ioapic_ids_from_mpc(void)
1761 * Don't check I/O APIC IDs for xAPIC systems. They have 1757 * Don't check I/O APIC IDs for xAPIC systems. They have
1762 * no meaning without the serial APIC bus. 1758 * no meaning without the serial APIC bus.
1763 */ 1759 */
1764 if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && boot_cpu_data.x86 < 15)) 1760 if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
1761 || APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
1765 return; 1762 return;
1766 /* 1763 /*
1767 * This is broken; anything with a real cpu count has to 1764 * This is broken; anything with a real cpu count has to
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 694a13997637..7a59050242a7 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -84,9 +84,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
84 84
85void __kprobes arch_remove_kprobe(struct kprobe *p) 85void __kprobes arch_remove_kprobe(struct kprobe *p)
86{ 86{
87 down(&kprobe_mutex); 87 mutex_lock(&kprobe_mutex);
88 free_insn_slot(p->ainsn.insn); 88 free_insn_slot(p->ainsn.insn);
89 up(&kprobe_mutex); 89 mutex_unlock(&kprobe_mutex);
90} 90}
91 91
92static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) 92static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
diff --git a/arch/i386/kernel/module.c b/arch/i386/kernel/module.c
index 5149c8a621f0..470cf97e7cd3 100644
--- a/arch/i386/kernel/module.c
+++ b/arch/i386/kernel/module.c
@@ -104,26 +104,38 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
104 return -ENOEXEC; 104 return -ENOEXEC;
105} 105}
106 106
107extern void apply_alternatives(void *start, void *end);
108
109int module_finalize(const Elf_Ehdr *hdr, 107int module_finalize(const Elf_Ehdr *hdr,
110 const Elf_Shdr *sechdrs, 108 const Elf_Shdr *sechdrs,
111 struct module *me) 109 struct module *me)
112{ 110{
113 const Elf_Shdr *s; 111 const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL;
114 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 112 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
115 113
116 /* look for .altinstructions to patch */
117 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { 114 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
118 void *seg; 115 if (!strcmp(".text", secstrings + s->sh_name))
119 if (strcmp(".altinstructions", secstrings + s->sh_name)) 116 text = s;
120 continue; 117 if (!strcmp(".altinstructions", secstrings + s->sh_name))
121 seg = (void *)s->sh_addr; 118 alt = s;
122 apply_alternatives(seg, seg + s->sh_size); 119 if (!strcmp(".smp_locks", secstrings + s->sh_name))
123 } 120 locks= s;
121 }
122
123 if (alt) {
124 /* patch .altinstructions */
125 void *aseg = (void *)alt->sh_addr;
126 apply_alternatives(aseg, aseg + alt->sh_size);
127 }
128 if (locks && text) {
129 void *lseg = (void *)locks->sh_addr;
130 void *tseg = (void *)text->sh_addr;
131 alternatives_smp_module_add(me, me->name,
132 lseg, lseg + locks->sh_size,
133 tseg, tseg + text->sh_size);
134 }
124 return 0; 135 return 0;
125} 136}
126 137
127void module_arch_cleanup(struct module *mod) 138void module_arch_cleanup(struct module *mod)
128{ 139{
140 alternatives_smp_module_del(mod);
129} 141}
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index e6e2f43db85e..8d8aa9d1796d 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -828,6 +828,8 @@ void __init find_smp_config (void)
828 smp_scan_config(address, 0x400); 828 smp_scan_config(address, 0x400);
829} 829}
830 830
831int es7000_plat;
832
831/* -------------------------------------------------------------------------- 833/* --------------------------------------------------------------------------
832 ACPI-based MP Configuration 834 ACPI-based MP Configuration
833 -------------------------------------------------------------------------- */ 835 -------------------------------------------------------------------------- */
@@ -935,7 +937,8 @@ void __init mp_register_ioapic (
935 mp_ioapics[idx].mpc_apicaddr = address; 937 mp_ioapics[idx].mpc_apicaddr = address;
936 938
937 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); 939 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
938 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 < 15)) 940 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
941 && !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
939 tmpid = io_apic_get_unique_id(idx, id); 942 tmpid = io_apic_get_unique_id(idx, id);
940 else 943 else
941 tmpid = id; 944 tmpid = id;
@@ -1011,8 +1014,6 @@ void __init mp_override_legacy_irq (
1011 return; 1014 return;
1012} 1015}
1013 1016
1014int es7000_plat;
1015
1016void __init mp_config_acpi_legacy_irqs (void) 1017void __init mp_config_acpi_legacy_irqs (void)
1017{ 1018{
1018 struct mpc_config_intsrc intsrc; 1019 struct mpc_config_intsrc intsrc;
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index be87c5e2ee95..9074818b9473 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -143,7 +143,7 @@ static int __init check_nmi_watchdog(void)
143 local_irq_enable(); 143 local_irq_enable();
144 mdelay((10*1000)/nmi_hz); // wait 10 ticks 144 mdelay((10*1000)/nmi_hz); // wait 10 ticks
145 145
146 for (cpu = 0; cpu < NR_CPUS; cpu++) { 146 for_each_cpu(cpu) {
147#ifdef CONFIG_SMP 147#ifdef CONFIG_SMP
148 /* Check cpu_callin_map here because that is set 148 /* Check cpu_callin_map here because that is set
149 after the timer is started. */ 149 after the timer is started. */
@@ -510,7 +510,7 @@ void touch_nmi_watchdog (void)
510 * Just reset the alert counters, (other CPUs might be 510 * Just reset the alert counters, (other CPUs might be
511 * spinning on locks we hold): 511 * spinning on locks we hold):
512 */ 512 */
513 for (i = 0; i < NR_CPUS; i++) 513 for_each_cpu(i)
514 alert_counter[i] = 0; 514 alert_counter[i] = 0;
515 515
516 /* 516 /*
@@ -543,7 +543,7 @@ void nmi_watchdog_tick (struct pt_regs * regs)
543 /* 543 /*
544 * die_nmi will return ONLY if NOTIFY_STOP happens.. 544 * die_nmi will return ONLY if NOTIFY_STOP happens..
545 */ 545 */
546 die_nmi(regs, "NMI Watchdog detected LOCKUP"); 546 die_nmi(regs, "BUG: NMI Watchdog detected LOCKUP");
547 } else { 547 } else {
548 last_irq_sums[cpu] = sum; 548 last_irq_sums[cpu] = sum;
549 alert_counter[cpu] = 0; 549 alert_counter[cpu] = 0;
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 0480454ebffa..299e61674084 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -295,7 +295,7 @@ void show_regs(struct pt_regs * regs)
295 printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id()); 295 printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
296 print_symbol("EIP is at %s\n", regs->eip); 296 print_symbol("EIP is at %s\n", regs->eip);
297 297
298 if (user_mode(regs)) 298 if (user_mode_vm(regs))
299 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp); 299 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
300 printk(" EFLAGS: %08lx %s (%s %.*s)\n", 300 printk(" EFLAGS: %08lx %s (%s %.*s)\n",
301 regs->eflags, print_tainted(), system_utsname.release, 301 regs->eflags, print_tainted(), system_utsname.release,
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index 5c1fb6aada5b..506462ef36a0 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -34,10 +34,10 @@
34 34
35/* 35/*
36 * Determines which flags the user has access to [1 = access, 0 = no access]. 36 * Determines which flags the user has access to [1 = access, 0 = no access].
37 * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9). 37 * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), NT(14), IOPL(12-13), IF(9).
38 * Also masks reserved bits (31-22, 15, 5, 3, 1). 38 * Also masks reserved bits (31-22, 15, 5, 3, 1).
39 */ 39 */
40#define FLAG_MASK 0x00054dd5 40#define FLAG_MASK 0x00050dd5
41 41
42/* set's the trap flag. */ 42/* set's the trap flag. */
43#define TRAP_FLAG 0x100 43#define TRAP_FLAG 0x100
diff --git a/arch/i386/kernel/semaphore.c b/arch/i386/kernel/semaphore.c
index 7455ab643943..967dc74df9ee 100644
--- a/arch/i386/kernel/semaphore.c
+++ b/arch/i386/kernel/semaphore.c
@@ -110,11 +110,11 @@ asm(
110".align 4\n" 110".align 4\n"
111".globl __write_lock_failed\n" 111".globl __write_lock_failed\n"
112"__write_lock_failed:\n\t" 112"__write_lock_failed:\n\t"
113 LOCK "addl $" RW_LOCK_BIAS_STR ",(%eax)\n" 113 LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
114"1: rep; nop\n\t" 114"1: rep; nop\n\t"
115 "cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n\t" 115 "cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
116 "jne 1b\n\t" 116 "jne 1b\n\t"
117 LOCK "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t" 117 LOCK_PREFIX "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
118 "jnz __write_lock_failed\n\t" 118 "jnz __write_lock_failed\n\t"
119 "ret" 119 "ret"
120); 120);
@@ -124,11 +124,11 @@ asm(
124".align 4\n" 124".align 4\n"
125".globl __read_lock_failed\n" 125".globl __read_lock_failed\n"
126"__read_lock_failed:\n\t" 126"__read_lock_failed:\n\t"
127 LOCK "incl (%eax)\n" 127 LOCK_PREFIX "incl (%eax)\n"
128"1: rep; nop\n\t" 128"1: rep; nop\n\t"
129 "cmpl $1,(%eax)\n\t" 129 "cmpl $1,(%eax)\n\t"
130 "js 1b\n\t" 130 "js 1b\n\t"
131 LOCK "decl (%eax)\n\t" 131 LOCK_PREFIX "decl (%eax)\n\t"
132 "js __read_lock_failed\n\t" 132 "js __read_lock_failed\n\t"
133 "ret" 133 "ret"
134); 134);
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index ab62a9f4701e..2d8782960f41 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -1377,101 +1377,6 @@ static void __init register_memory(void)
1377 pci_mem_start, gapstart, gapsize); 1377 pci_mem_start, gapstart, gapsize);
1378} 1378}
1379 1379
1380/* Use inline assembly to define this because the nops are defined
1381 as inline assembly strings in the include files and we cannot
1382 get them easily into strings. */
1383asm("\t.data\nintelnops: "
1384 GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
1385 GENERIC_NOP7 GENERIC_NOP8);
1386asm("\t.data\nk8nops: "
1387 K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
1388 K8_NOP7 K8_NOP8);
1389asm("\t.data\nk7nops: "
1390 K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
1391 K7_NOP7 K7_NOP8);
1392
1393extern unsigned char intelnops[], k8nops[], k7nops[];
1394static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
1395 NULL,
1396 intelnops,
1397 intelnops + 1,
1398 intelnops + 1 + 2,
1399 intelnops + 1 + 2 + 3,
1400 intelnops + 1 + 2 + 3 + 4,
1401 intelnops + 1 + 2 + 3 + 4 + 5,
1402 intelnops + 1 + 2 + 3 + 4 + 5 + 6,
1403 intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1404};
1405static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
1406 NULL,
1407 k8nops,
1408 k8nops + 1,
1409 k8nops + 1 + 2,
1410 k8nops + 1 + 2 + 3,
1411 k8nops + 1 + 2 + 3 + 4,
1412 k8nops + 1 + 2 + 3 + 4 + 5,
1413 k8nops + 1 + 2 + 3 + 4 + 5 + 6,
1414 k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1415};
1416static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
1417 NULL,
1418 k7nops,
1419 k7nops + 1,
1420 k7nops + 1 + 2,
1421 k7nops + 1 + 2 + 3,
1422 k7nops + 1 + 2 + 3 + 4,
1423 k7nops + 1 + 2 + 3 + 4 + 5,
1424 k7nops + 1 + 2 + 3 + 4 + 5 + 6,
1425 k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1426};
1427static struct nop {
1428 int cpuid;
1429 unsigned char **noptable;
1430} noptypes[] = {
1431 { X86_FEATURE_K8, k8_nops },
1432 { X86_FEATURE_K7, k7_nops },
1433 { -1, NULL }
1434};
1435
1436/* Replace instructions with better alternatives for this CPU type.
1437
1438 This runs before SMP is initialized to avoid SMP problems with
1439 self modifying code. This implies that assymetric systems where
1440 APs have less capabilities than the boot processor are not handled.
1441 Tough. Make sure you disable such features by hand. */
1442void apply_alternatives(void *start, void *end)
1443{
1444 struct alt_instr *a;
1445 int diff, i, k;
1446 unsigned char **noptable = intel_nops;
1447 for (i = 0; noptypes[i].cpuid >= 0; i++) {
1448 if (boot_cpu_has(noptypes[i].cpuid)) {
1449 noptable = noptypes[i].noptable;
1450 break;
1451 }
1452 }
1453 for (a = start; (void *)a < end; a++) {
1454 if (!boot_cpu_has(a->cpuid))
1455 continue;
1456 BUG_ON(a->replacementlen > a->instrlen);
1457 memcpy(a->instr, a->replacement, a->replacementlen);
1458 diff = a->instrlen - a->replacementlen;
1459 /* Pad the rest with nops */
1460 for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
1461 k = diff;
1462 if (k > ASM_NOP_MAX)
1463 k = ASM_NOP_MAX;
1464 memcpy(a->instr + i, noptable[k], k);
1465 }
1466 }
1467}
1468
1469void __init alternative_instructions(void)
1470{
1471 extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
1472 apply_alternatives(__alt_instructions, __alt_instructions_end);
1473}
1474
1475static char * __init machine_specific_memory_setup(void); 1380static char * __init machine_specific_memory_setup(void);
1476 1381
1477#ifdef CONFIG_MCA 1382#ifdef CONFIG_MCA
@@ -1554,6 +1459,16 @@ void __init setup_arch(char **cmdline_p)
1554 1459
1555 parse_cmdline_early(cmdline_p); 1460 parse_cmdline_early(cmdline_p);
1556 1461
1462#ifdef CONFIG_EARLY_PRINTK
1463 {
1464 char *s = strstr(*cmdline_p, "earlyprintk=");
1465 if (s) {
1466 setup_early_printk(strchr(s, '=') + 1);
1467 printk("early console enabled\n");
1468 }
1469 }
1470#endif
1471
1557 max_low_pfn = setup_memory(); 1472 max_low_pfn = setup_memory();
1558 1473
1559 /* 1474 /*
@@ -1578,19 +1493,6 @@ void __init setup_arch(char **cmdline_p)
1578 * NOTE: at this point the bootmem allocator is fully available. 1493 * NOTE: at this point the bootmem allocator is fully available.
1579 */ 1494 */
1580 1495
1581#ifdef CONFIG_EARLY_PRINTK
1582 {
1583 char *s = strstr(*cmdline_p, "earlyprintk=");
1584 if (s) {
1585 extern void setup_early_printk(char *);
1586
1587 setup_early_printk(strchr(s, '=') + 1);
1588 printk("early console enabled\n");
1589 }
1590 }
1591#endif
1592
1593
1594 dmi_scan_machine(); 1496 dmi_scan_machine();
1595 1497
1596#ifdef CONFIG_X86_GENERICARCH 1498#ifdef CONFIG_X86_GENERICARCH
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index 963616d364ec..5c352c3a9e7f 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -123,7 +123,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax
123 err |= __get_user(tmp, &sc->seg); \ 123 err |= __get_user(tmp, &sc->seg); \
124 loadsegment(seg,tmp); } 124 loadsegment(seg,tmp); }
125 125
126#define FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_OF | X86_EFLAGS_DF | \ 126#define FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_RF | \
127 X86_EFLAGS_OF | X86_EFLAGS_DF | \
127 X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \ 128 X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
128 X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF) 129 X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF)
129 130
@@ -582,9 +583,6 @@ static void fastcall do_signal(struct pt_regs *regs)
582 if (!user_mode(regs)) 583 if (!user_mode(regs))
583 return; 584 return;
584 585
585 if (try_to_freeze())
586 goto no_signal;
587
588 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 586 if (test_thread_flag(TIF_RESTORE_SIGMASK))
589 oldset = &current->saved_sigmask; 587 oldset = &current->saved_sigmask;
590 else 588 else
@@ -613,7 +611,6 @@ static void fastcall do_signal(struct pt_regs *regs)
613 return; 611 return;
614 } 612 }
615 613
616no_signal:
617 /* Did we come from a system call? */ 614 /* Did we come from a system call? */
618 if (regs->orig_eax >= 0) { 615 if (regs->orig_eax >= 0) {
619 /* Restart the system call - no handlers present */ 616 /* Restart the system call - no handlers present */
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 7007e1783797..4c470e99a742 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -899,6 +899,7 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
899 unsigned short nmi_high = 0, nmi_low = 0; 899 unsigned short nmi_high = 0, nmi_low = 0;
900 900
901 ++cpucount; 901 ++cpucount;
902 alternatives_smp_switch(1);
902 903
903 /* 904 /*
904 * We can't use kernel_thread since we must avoid to 905 * We can't use kernel_thread since we must avoid to
@@ -1368,6 +1369,8 @@ void __cpu_die(unsigned int cpu)
1368 /* They ack this in play_dead by setting CPU_DEAD */ 1369 /* They ack this in play_dead by setting CPU_DEAD */
1369 if (per_cpu(cpu_state, cpu) == CPU_DEAD) { 1370 if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
1370 printk ("CPU %d is now offline\n", cpu); 1371 printk ("CPU %d is now offline\n", cpu);
1372 if (1 == num_online_cpus())
1373 alternatives_smp_switch(0);
1371 return; 1374 return;
1372 } 1375 }
1373 msleep(100); 1376 msleep(100);
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c
index 67a0e1baa28b..296355292c7c 100644
--- a/arch/i386/kernel/topology.c
+++ b/arch/i386/kernel/topology.c
@@ -41,6 +41,15 @@ int arch_register_cpu(int num){
41 parent = &node_devices[node].node; 41 parent = &node_devices[node].node;
42#endif /* CONFIG_NUMA */ 42#endif /* CONFIG_NUMA */
43 43
44 /*
45 * CPU0 cannot be offlined due to several
46 * restrictions and assumptions in kernel. This basically
47 * doesnt add a control file, one cannot attempt to offline
48 * BSP.
49 */
50 if (!num)
51 cpu_devices[num].cpu.no_control = 1;
52
44 return register_cpu(&cpu_devices[num].cpu, num, parent); 53 return register_cpu(&cpu_devices[num].cpu, num, parent);
45} 54}
46 55
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index b814dbdcc91e..de5386b01d38 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -99,6 +99,8 @@ int register_die_notifier(struct notifier_block *nb)
99{ 99{
100 int err = 0; 100 int err = 0;
101 unsigned long flags; 101 unsigned long flags;
102
103 vmalloc_sync_all();
102 spin_lock_irqsave(&die_notifier_lock, flags); 104 spin_lock_irqsave(&die_notifier_lock, flags);
103 err = notifier_chain_register(&i386die_chain, nb); 105 err = notifier_chain_register(&i386die_chain, nb);
104 spin_unlock_irqrestore(&die_notifier_lock, flags); 106 spin_unlock_irqrestore(&die_notifier_lock, flags);
@@ -112,12 +114,30 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
112 p < (void *)tinfo + THREAD_SIZE - 3; 114 p < (void *)tinfo + THREAD_SIZE - 3;
113} 115}
114 116
115static void print_addr_and_symbol(unsigned long addr, char *log_lvl) 117/*
118 * Print CONFIG_STACK_BACKTRACE_COLS address/symbol entries per line.
119 */
120static inline int print_addr_and_symbol(unsigned long addr, char *log_lvl,
121 int printed)
116{ 122{
117 printk(log_lvl); 123 if (!printed)
124 printk(log_lvl);
125
126#if CONFIG_STACK_BACKTRACE_COLS == 1
118 printk(" [<%08lx>] ", addr); 127 printk(" [<%08lx>] ", addr);
128#else
129 printk(" <%08lx> ", addr);
130#endif
119 print_symbol("%s", addr); 131 print_symbol("%s", addr);
120 printk("\n"); 132
133 printed = (printed + 1) % CONFIG_STACK_BACKTRACE_COLS;
134
135 if (printed)
136 printk(" ");
137 else
138 printk("\n");
139
140 return printed;
121} 141}
122 142
123static inline unsigned long print_context_stack(struct thread_info *tinfo, 143static inline unsigned long print_context_stack(struct thread_info *tinfo,
@@ -125,20 +145,24 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
125 char *log_lvl) 145 char *log_lvl)
126{ 146{
127 unsigned long addr; 147 unsigned long addr;
148 int printed = 0; /* nr of entries already printed on current line */
128 149
129#ifdef CONFIG_FRAME_POINTER 150#ifdef CONFIG_FRAME_POINTER
130 while (valid_stack_ptr(tinfo, (void *)ebp)) { 151 while (valid_stack_ptr(tinfo, (void *)ebp)) {
131 addr = *(unsigned long *)(ebp + 4); 152 addr = *(unsigned long *)(ebp + 4);
132 print_addr_and_symbol(addr, log_lvl); 153 printed = print_addr_and_symbol(addr, log_lvl, printed);
133 ebp = *(unsigned long *)ebp; 154 ebp = *(unsigned long *)ebp;
134 } 155 }
135#else 156#else
136 while (valid_stack_ptr(tinfo, stack)) { 157 while (valid_stack_ptr(tinfo, stack)) {
137 addr = *stack++; 158 addr = *stack++;
138 if (__kernel_text_address(addr)) 159 if (__kernel_text_address(addr))
139 print_addr_and_symbol(addr, log_lvl); 160 printed = print_addr_and_symbol(addr, log_lvl, printed);
140 } 161 }
141#endif 162#endif
163 if (printed)
164 printk("\n");
165
142 return ebp; 166 return ebp;
143} 167}
144 168
@@ -166,8 +190,7 @@ static void show_trace_log_lvl(struct task_struct *task,
166 stack = (unsigned long*)context->previous_esp; 190 stack = (unsigned long*)context->previous_esp;
167 if (!stack) 191 if (!stack)
168 break; 192 break;
169 printk(log_lvl); 193 printk("%s =======================\n", log_lvl);
170 printk(" =======================\n");
171 } 194 }
172} 195}
173 196
@@ -194,21 +217,17 @@ static void show_stack_log_lvl(struct task_struct *task, unsigned long *esp,
194 for(i = 0; i < kstack_depth_to_print; i++) { 217 for(i = 0; i < kstack_depth_to_print; i++) {
195 if (kstack_end(stack)) 218 if (kstack_end(stack))
196 break; 219 break;
197 if (i && ((i % 8) == 0)) { 220 if (i && ((i % 8) == 0))
198 printk("\n"); 221 printk("\n%s ", log_lvl);
199 printk(log_lvl);
200 printk(" ");
201 }
202 printk("%08lx ", *stack++); 222 printk("%08lx ", *stack++);
203 } 223 }
204 printk("\n"); 224 printk("\n%sCall Trace:\n", log_lvl);
205 printk(log_lvl);
206 printk("Call Trace:\n");
207 show_trace_log_lvl(task, esp, log_lvl); 225 show_trace_log_lvl(task, esp, log_lvl);
208} 226}
209 227
210void show_stack(struct task_struct *task, unsigned long *esp) 228void show_stack(struct task_struct *task, unsigned long *esp)
211{ 229{
230 printk(" ");
212 show_stack_log_lvl(task, esp, ""); 231 show_stack_log_lvl(task, esp, "");
213} 232}
214 233
@@ -233,7 +252,7 @@ void show_registers(struct pt_regs *regs)
233 252
234 esp = (unsigned long) (&regs->esp); 253 esp = (unsigned long) (&regs->esp);
235 savesegment(ss, ss); 254 savesegment(ss, ss);
236 if (user_mode(regs)) { 255 if (user_mode_vm(regs)) {
237 in_kernel = 0; 256 in_kernel = 0;
238 esp = regs->esp; 257 esp = regs->esp;
239 ss = regs->xss & 0xffff; 258 ss = regs->xss & 0xffff;
@@ -333,6 +352,8 @@ void die(const char * str, struct pt_regs * regs, long err)
333 static int die_counter; 352 static int die_counter;
334 unsigned long flags; 353 unsigned long flags;
335 354
355 oops_enter();
356
336 if (die.lock_owner != raw_smp_processor_id()) { 357 if (die.lock_owner != raw_smp_processor_id()) {
337 console_verbose(); 358 console_verbose();
338 spin_lock_irqsave(&die.lock, flags); 359 spin_lock_irqsave(&die.lock, flags);
@@ -385,6 +406,7 @@ void die(const char * str, struct pt_regs * regs, long err)
385 ssleep(5); 406 ssleep(5);
386 panic("Fatal exception"); 407 panic("Fatal exception");
387 } 408 }
409 oops_exit();
388 do_exit(SIGSEGV); 410 do_exit(SIGSEGV);
389} 411}
390 412
@@ -623,7 +645,7 @@ void die_nmi (struct pt_regs *regs, const char *msg)
623 /* If we are in kernel we are probably nested up pretty bad 645 /* If we are in kernel we are probably nested up pretty bad
624 * and might aswell get out now while we still can. 646 * and might aswell get out now while we still can.
625 */ 647 */
626 if (!user_mode(regs)) { 648 if (!user_mode_vm(regs)) {
627 current->thread.trap_no = 2; 649 current->thread.trap_no = 2;
628 crash_kexec(regs); 650 crash_kexec(regs);
629 } 651 }
@@ -694,6 +716,7 @@ fastcall void do_nmi(struct pt_regs * regs, long error_code)
694 716
695void set_nmi_callback(nmi_callback_t callback) 717void set_nmi_callback(nmi_callback_t callback)
696{ 718{
719 vmalloc_sync_all();
697 rcu_assign_pointer(nmi_callback, callback); 720 rcu_assign_pointer(nmi_callback, callback);
698} 721}
699EXPORT_SYMBOL_GPL(set_nmi_callback); 722EXPORT_SYMBOL_GPL(set_nmi_callback);
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index 4710195b6b74..3f21c6f6466d 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -68,6 +68,26 @@ SECTIONS
68 *(.data.init_task) 68 *(.data.init_task)
69 } 69 }
70 70
71 /* might get freed after init */
72 . = ALIGN(4096);
73 __smp_alt_begin = .;
74 __smp_alt_instructions = .;
75 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
76 *(.smp_altinstructions)
77 }
78 __smp_alt_instructions_end = .;
79 . = ALIGN(4);
80 __smp_locks = .;
81 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
82 *(.smp_locks)
83 }
84 __smp_locks_end = .;
85 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
86 *(.smp_altinstr_replacement)
87 }
88 . = ALIGN(4096);
89 __smp_alt_end = .;
90
71 /* will be freed after init */ 91 /* will be freed after init */
72 . = ALIGN(4096); /* Init code and data */ 92 . = ALIGN(4096); /* Init code and data */
73 __init_begin = .; 93 __init_begin = .;
diff --git a/arch/i386/kernel/vsyscall-sysenter.S b/arch/i386/kernel/vsyscall-sysenter.S
index 76b728159403..3b62baa6a371 100644
--- a/arch/i386/kernel/vsyscall-sysenter.S
+++ b/arch/i386/kernel/vsyscall-sysenter.S
@@ -21,6 +21,9 @@
21 * instruction clobbers %esp, the user's %esp won't even survive entry 21 * instruction clobbers %esp, the user's %esp won't even survive entry
22 * into the kernel. We store %esp in %ebp. Code in entry.S must fetch 22 * into the kernel. We store %esp in %ebp. Code in entry.S must fetch
23 * arg6 from the stack. 23 * arg6 from the stack.
24 *
25 * You can not use this vsyscall for the clone() syscall because the
26 * three dwords on the parent stack do not get copied to the child.
24 */ 27 */
25 .text 28 .text
26 .globl __kernel_vsyscall 29 .globl __kernel_vsyscall
diff --git a/arch/i386/mach-es7000/es7000.h b/arch/i386/mach-es7000/es7000.h
index f1e3204f5dec..80566ca4a80a 100644
--- a/arch/i386/mach-es7000/es7000.h
+++ b/arch/i386/mach-es7000/es7000.h
@@ -83,6 +83,7 @@ struct es7000_oem_table {
83 struct psai psai; 83 struct psai psai;
84}; 84};
85 85
86#ifdef CONFIG_ACPI
86struct acpi_table_sdt { 87struct acpi_table_sdt {
87 unsigned long pa; 88 unsigned long pa;
88 unsigned long count; 89 unsigned long count;
@@ -99,6 +100,9 @@ struct oem_table {
99 u32 OEMTableSize; 100 u32 OEMTableSize;
100}; 101};
101 102
103extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
104#endif
105
102struct mip_reg { 106struct mip_reg {
103 unsigned long long off_0; 107 unsigned long long off_0;
104 unsigned long long off_8; 108 unsigned long long off_8;
@@ -114,7 +118,6 @@ struct mip_reg {
114#define MIP_FUNC(VALUE) (VALUE & 0xff) 118#define MIP_FUNC(VALUE) (VALUE & 0xff)
115 119
116extern int parse_unisys_oem (char *oemptr); 120extern int parse_unisys_oem (char *oemptr);
117extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
118extern void setup_unisys(void); 121extern void setup_unisys(void);
119extern int es7000_start_cpu(int cpu, unsigned long eip); 122extern int es7000_start_cpu(int cpu, unsigned long eip);
120extern void es7000_sw_apic(void); 123extern void es7000_sw_apic(void);
diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c
index a9ab0644f403..3d0fc853516d 100644
--- a/arch/i386/mach-es7000/es7000plat.c
+++ b/arch/i386/mach-es7000/es7000plat.c
@@ -51,8 +51,6 @@ struct mip_reg *host_reg;
51int mip_port; 51int mip_port;
52unsigned long mip_addr, host_addr; 52unsigned long mip_addr, host_addr;
53 53
54#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
55
56/* 54/*
57 * GSI override for ES7000 platforms. 55 * GSI override for ES7000 platforms.
58 */ 56 */
@@ -76,8 +74,6 @@ es7000_rename_gsi(int ioapic, int gsi)
76 return gsi; 74 return gsi;
77} 75}
78 76
79#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
80
81void __init 77void __init
82setup_unisys(void) 78setup_unisys(void)
83{ 79{
@@ -160,6 +156,7 @@ parse_unisys_oem (char *oemptr)
160 return es7000_plat; 156 return es7000_plat;
161} 157}
162 158
159#ifdef CONFIG_ACPI
163int __init 160int __init
164find_unisys_acpi_oem_table(unsigned long *oem_addr) 161find_unisys_acpi_oem_table(unsigned long *oem_addr)
165{ 162{
@@ -212,6 +209,7 @@ find_unisys_acpi_oem_table(unsigned long *oem_addr)
212 } 209 }
213 return -1; 210 return -1;
214} 211}
212#endif
215 213
216static void 214static void
217es7000_spin(int n) 215es7000_spin(int n)
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
index cf572d9a3b6e..7f0fcf219a26 100644
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -214,6 +214,68 @@ static noinline void force_sig_info_fault(int si_signo, int si_code,
214 214
215fastcall void do_invalid_op(struct pt_regs *, unsigned long); 215fastcall void do_invalid_op(struct pt_regs *, unsigned long);
216 216
217static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
218{
219 unsigned index = pgd_index(address);
220 pgd_t *pgd_k;
221 pud_t *pud, *pud_k;
222 pmd_t *pmd, *pmd_k;
223
224 pgd += index;
225 pgd_k = init_mm.pgd + index;
226
227 if (!pgd_present(*pgd_k))
228 return NULL;
229
230 /*
231 * set_pgd(pgd, *pgd_k); here would be useless on PAE
232 * and redundant with the set_pmd() on non-PAE. As would
233 * set_pud.
234 */
235
236 pud = pud_offset(pgd, address);
237 pud_k = pud_offset(pgd_k, address);
238 if (!pud_present(*pud_k))
239 return NULL;
240
241 pmd = pmd_offset(pud, address);
242 pmd_k = pmd_offset(pud_k, address);
243 if (!pmd_present(*pmd_k))
244 return NULL;
245 if (!pmd_present(*pmd))
246 set_pmd(pmd, *pmd_k);
247 else
248 BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
249 return pmd_k;
250}
251
252/*
253 * Handle a fault on the vmalloc or module mapping area
254 *
255 * This assumes no large pages in there.
256 */
257static inline int vmalloc_fault(unsigned long address)
258{
259 unsigned long pgd_paddr;
260 pmd_t *pmd_k;
261 pte_t *pte_k;
262 /*
263 * Synchronize this task's top level page-table
264 * with the 'reference' page table.
265 *
266 * Do _not_ use "current" here. We might be inside
267 * an interrupt in the middle of a task switch..
268 */
269 pgd_paddr = read_cr3();
270 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
271 if (!pmd_k)
272 return -1;
273 pte_k = pte_offset_kernel(pmd_k, address);
274 if (!pte_present(*pte_k))
275 return -1;
276 return 0;
277}
278
217/* 279/*
218 * This routine handles page faults. It determines the address, 280 * This routine handles page faults. It determines the address,
219 * and the problem, and then passes it off to one of the appropriate 281 * and the problem, and then passes it off to one of the appropriate
@@ -223,6 +285,8 @@ fastcall void do_invalid_op(struct pt_regs *, unsigned long);
223 * bit 0 == 0 means no page found, 1 means protection fault 285 * bit 0 == 0 means no page found, 1 means protection fault
224 * bit 1 == 0 means read, 1 means write 286 * bit 1 == 0 means read, 1 means write
225 * bit 2 == 0 means kernel, 1 means user-mode 287 * bit 2 == 0 means kernel, 1 means user-mode
288 * bit 3 == 1 means use of reserved bit detected
289 * bit 4 == 1 means fault was an instruction fetch
226 */ 290 */
227fastcall void __kprobes do_page_fault(struct pt_regs *regs, 291fastcall void __kprobes do_page_fault(struct pt_regs *regs,
228 unsigned long error_code) 292 unsigned long error_code)
@@ -237,13 +301,6 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs,
237 /* get the address */ 301 /* get the address */
238 address = read_cr2(); 302 address = read_cr2();
239 303
240 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
241 SIGSEGV) == NOTIFY_STOP)
242 return;
243 /* It's safe to allow irq's after cr2 has been saved */
244 if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
245 local_irq_enable();
246
247 tsk = current; 304 tsk = current;
248 305
249 si_code = SEGV_MAPERR; 306 si_code = SEGV_MAPERR;
@@ -259,17 +316,29 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs,
259 * 316 *
260 * This verifies that the fault happens in kernel space 317 * This verifies that the fault happens in kernel space
261 * (error_code & 4) == 0, and that the fault was not a 318 * (error_code & 4) == 0, and that the fault was not a
262 * protection error (error_code & 1) == 0. 319 * protection error (error_code & 9) == 0.
263 */ 320 */
264 if (unlikely(address >= TASK_SIZE)) { 321 if (unlikely(address >= TASK_SIZE)) {
265 if (!(error_code & 5)) 322 if (!(error_code & 0x0000000d) && vmalloc_fault(address) >= 0)
266 goto vmalloc_fault; 323 return;
267 /* 324 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
325 SIGSEGV) == NOTIFY_STOP)
326 return;
327 /*
268 * Don't take the mm semaphore here. If we fixup a prefetch 328 * Don't take the mm semaphore here. If we fixup a prefetch
269 * fault we could otherwise deadlock. 329 * fault we could otherwise deadlock.
270 */ 330 */
271 goto bad_area_nosemaphore; 331 goto bad_area_nosemaphore;
272 } 332 }
333
334 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
335 SIGSEGV) == NOTIFY_STOP)
336 return;
337
338 /* It's safe to allow irq's after cr2 has been saved and the vmalloc
339 fault has been handled. */
340 if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
341 local_irq_enable();
273 342
274 mm = tsk->mm; 343 mm = tsk->mm;
275 344
@@ -440,24 +509,31 @@ no_context:
440 509
441 bust_spinlocks(1); 510 bust_spinlocks(1);
442 511
443#ifdef CONFIG_X86_PAE 512 if (oops_may_print()) {
444 if (error_code & 16) { 513 #ifdef CONFIG_X86_PAE
445 pte_t *pte = lookup_address(address); 514 if (error_code & 16) {
515 pte_t *pte = lookup_address(address);
446 516
447 if (pte && pte_present(*pte) && !pte_exec_kernel(*pte)) 517 if (pte && pte_present(*pte) && !pte_exec_kernel(*pte))
448 printk(KERN_CRIT "kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n", current->uid); 518 printk(KERN_CRIT "kernel tried to execute "
519 "NX-protected page - exploit attempt? "
520 "(uid: %d)\n", current->uid);
521 }
522 #endif
523 if (address < PAGE_SIZE)
524 printk(KERN_ALERT "BUG: unable to handle kernel NULL "
525 "pointer dereference");
526 else
527 printk(KERN_ALERT "BUG: unable to handle kernel paging"
528 " request");
529 printk(" at virtual address %08lx\n",address);
530 printk(KERN_ALERT " printing eip:\n");
531 printk("%08lx\n", regs->eip);
449 } 532 }
450#endif
451 if (address < PAGE_SIZE)
452 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
453 else
454 printk(KERN_ALERT "Unable to handle kernel paging request");
455 printk(" at virtual address %08lx\n",address);
456 printk(KERN_ALERT " printing eip:\n");
457 printk("%08lx\n", regs->eip);
458 page = read_cr3(); 533 page = read_cr3();
459 page = ((unsigned long *) __va(page))[address >> 22]; 534 page = ((unsigned long *) __va(page))[address >> 22];
460 printk(KERN_ALERT "*pde = %08lx\n", page); 535 if (oops_may_print())
536 printk(KERN_ALERT "*pde = %08lx\n", page);
461 /* 537 /*
462 * We must not directly access the pte in the highpte 538 * We must not directly access the pte in the highpte
463 * case, the page table might be allocated in highmem. 539 * case, the page table might be allocated in highmem.
@@ -465,7 +541,7 @@ no_context:
465 * it's allocated already. 541 * it's allocated already.
466 */ 542 */
467#ifndef CONFIG_HIGHPTE 543#ifndef CONFIG_HIGHPTE
468 if (page & 1) { 544 if ((page & 1) && oops_may_print()) {
469 page &= PAGE_MASK; 545 page &= PAGE_MASK;
470 address &= 0x003ff000; 546 address &= 0x003ff000;
471 page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT]; 547 page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT];
@@ -510,51 +586,41 @@ do_sigbus:
510 tsk->thread.error_code = error_code; 586 tsk->thread.error_code = error_code;
511 tsk->thread.trap_no = 14; 587 tsk->thread.trap_no = 14;
512 force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk); 588 force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
513 return; 589}
514
515vmalloc_fault:
516 {
517 /*
518 * Synchronize this task's top level page-table
519 * with the 'reference' page table.
520 *
521 * Do _not_ use "tsk" here. We might be inside
522 * an interrupt in the middle of a task switch..
523 */
524 int index = pgd_index(address);
525 unsigned long pgd_paddr;
526 pgd_t *pgd, *pgd_k;
527 pud_t *pud, *pud_k;
528 pmd_t *pmd, *pmd_k;
529 pte_t *pte_k;
530
531 pgd_paddr = read_cr3();
532 pgd = index + (pgd_t *)__va(pgd_paddr);
533 pgd_k = init_mm.pgd + index;
534
535 if (!pgd_present(*pgd_k))
536 goto no_context;
537
538 /*
539 * set_pgd(pgd, *pgd_k); here would be useless on PAE
540 * and redundant with the set_pmd() on non-PAE. As would
541 * set_pud.
542 */
543 590
544 pud = pud_offset(pgd, address); 591#ifndef CONFIG_X86_PAE
545 pud_k = pud_offset(pgd_k, address); 592void vmalloc_sync_all(void)
546 if (!pud_present(*pud_k)) 593{
547 goto no_context; 594 /*
548 595 * Note that races in the updates of insync and start aren't
549 pmd = pmd_offset(pud, address); 596 * problematic: insync can only get set bits added, and updates to
550 pmd_k = pmd_offset(pud_k, address); 597 * start are only improving performance (without affecting correctness
551 if (!pmd_present(*pmd_k)) 598 * if undone).
552 goto no_context; 599 */
553 set_pmd(pmd, *pmd_k); 600 static DECLARE_BITMAP(insync, PTRS_PER_PGD);
601 static unsigned long start = TASK_SIZE;
602 unsigned long address;
554 603
555 pte_k = pte_offset_kernel(pmd_k, address); 604 BUILD_BUG_ON(TASK_SIZE & ~PGDIR_MASK);
556 if (!pte_present(*pte_k)) 605 for (address = start; address >= TASK_SIZE; address += PGDIR_SIZE) {
557 goto no_context; 606 if (!test_bit(pgd_index(address), insync)) {
558 return; 607 unsigned long flags;
608 struct page *page;
609
610 spin_lock_irqsave(&pgd_lock, flags);
611 for (page = pgd_list; page; page =
612 (struct page *)page->index)
613 if (!vmalloc_sync_one(page_address(page),
614 address)) {
615 BUG_ON(page != pgd_list);
616 break;
617 }
618 spin_unlock_irqrestore(&pgd_lock, flags);
619 if (!page)
620 set_bit(pgd_index(address), insync);
621 }
622 if (address == start && test_bit(pgd_index(address), insync))
623 start = address + PGDIR_SIZE;
559 } 624 }
560} 625}
626#endif
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 7ba55a6e2dbc..9f66ac582a8b 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -720,21 +720,6 @@ static int noinline do_test_wp_bit(void)
720 return flag; 720 return flag;
721} 721}
722 722
723void free_initmem(void)
724{
725 unsigned long addr;
726
727 addr = (unsigned long)(&__init_begin);
728 for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
729 ClearPageReserved(virt_to_page(addr));
730 init_page_count(virt_to_page(addr));
731 memset((void *)addr, 0xcc, PAGE_SIZE);
732 free_page(addr);
733 totalram_pages++;
734 }
735 printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", (__init_end - __init_begin) >> 10);
736}
737
738#ifdef CONFIG_DEBUG_RODATA 723#ifdef CONFIG_DEBUG_RODATA
739 724
740extern char __start_rodata, __end_rodata; 725extern char __start_rodata, __end_rodata;
@@ -758,17 +743,31 @@ void mark_rodata_ro(void)
758} 743}
759#endif 744#endif
760 745
746void free_init_pages(char *what, unsigned long begin, unsigned long end)
747{
748 unsigned long addr;
749
750 for (addr = begin; addr < end; addr += PAGE_SIZE) {
751 ClearPageReserved(virt_to_page(addr));
752 init_page_count(virt_to_page(addr));
753 memset((void *)addr, 0xcc, PAGE_SIZE);
754 free_page(addr);
755 totalram_pages++;
756 }
757 printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
758}
759
760void free_initmem(void)
761{
762 free_init_pages("unused kernel memory",
763 (unsigned long)(&__init_begin),
764 (unsigned long)(&__init_end));
765}
761 766
762#ifdef CONFIG_BLK_DEV_INITRD 767#ifdef CONFIG_BLK_DEV_INITRD
763void free_initrd_mem(unsigned long start, unsigned long end) 768void free_initrd_mem(unsigned long start, unsigned long end)
764{ 769{
765 if (start < end) 770 free_init_pages("initrd memory", start, end);
766 printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
767 for (; start < end; start += PAGE_SIZE) {
768 ClearPageReserved(virt_to_page(start));
769 init_page_count(virt_to_page(start));
770 free_page(start);
771 totalram_pages++;
772 }
773} 771}
774#endif 772#endif
773
diff --git a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
index 0493e8b8ec49..1accce50c2c7 100644
--- a/arch/i386/oprofile/nmi_int.c
+++ b/arch/i386/oprofile/nmi_int.c
@@ -122,7 +122,7 @@ static void nmi_save_registers(void * dummy)
122static void free_msrs(void) 122static void free_msrs(void)
123{ 123{
124 int i; 124 int i;
125 for (i = 0; i < NR_CPUS; ++i) { 125 for_each_cpu(i) {
126 kfree(cpu_msrs[i].counters); 126 kfree(cpu_msrs[i].counters);
127 cpu_msrs[i].counters = NULL; 127 cpu_msrs[i].counters = NULL;
128 kfree(cpu_msrs[i].controls); 128 kfree(cpu_msrs[i].controls);
@@ -138,10 +138,7 @@ static int allocate_msrs(void)
138 size_t counters_size = sizeof(struct op_msr) * model->num_counters; 138 size_t counters_size = sizeof(struct op_msr) * model->num_counters;
139 139
140 int i; 140 int i;
141 for (i = 0; i < NR_CPUS; ++i) { 141 for_each_online_cpu(i) {
142 if (!cpu_online(i))
143 continue;
144
145 cpu_msrs[i].counters = kmalloc(counters_size, GFP_KERNEL); 142 cpu_msrs[i].counters = kmalloc(counters_size, GFP_KERNEL);
146 if (!cpu_msrs[i].counters) { 143 if (!cpu_msrs[i].counters) {
147 success = 0; 144 success = 0;
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 626cdc83668b..0e5c6ae50228 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -46,11 +46,6 @@
46#define KEYBOARD_INTR 3 /* must match with simulator! */ 46#define KEYBOARD_INTR 3 /* must match with simulator! */
47 47
48#define NR_PORTS 1 /* only one port for now */ 48#define NR_PORTS 1 /* only one port for now */
49#define SERIAL_INLINE 1
50
51#ifdef SERIAL_INLINE
52#define _INLINE_ inline
53#endif
54 49
55#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT) 50#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
56 51
@@ -237,7 +232,7 @@ static void rs_put_char(struct tty_struct *tty, unsigned char ch)
237 local_irq_restore(flags); 232 local_irq_restore(flags);
238} 233}
239 234
240static _INLINE_ void transmit_chars(struct async_struct *info, int *intr_done) 235static void transmit_chars(struct async_struct *info, int *intr_done)
241{ 236{
242 int count; 237 int count;
243 unsigned long flags; 238 unsigned long flags;
diff --git a/arch/m32r/kernel/irq.c b/arch/m32r/kernel/irq.c
index 1ce63926a3c0..a4634b06f675 100644
--- a/arch/m32r/kernel/irq.c
+++ b/arch/m32r/kernel/irq.c
@@ -37,9 +37,8 @@ int show_interrupts(struct seq_file *p, void *v)
37 37
38 if (i == 0) { 38 if (i == 0) {
39 seq_printf(p, " "); 39 seq_printf(p, " ");
40 for (j=0; j<NR_CPUS; j++) 40 for_each_online_cpu(j)
41 if (cpu_online(j)) 41 seq_printf(p, "CPU%d ",j);
42 seq_printf(p, "CPU%d ",j);
43 seq_putc(p, '\n'); 42 seq_putc(p, '\n');
44 } 43 }
45 44
@@ -52,9 +51,8 @@ int show_interrupts(struct seq_file *p, void *v)
52#ifndef CONFIG_SMP 51#ifndef CONFIG_SMP
53 seq_printf(p, "%10u ", kstat_irqs(i)); 52 seq_printf(p, "%10u ", kstat_irqs(i));
54#else 53#else
55 for (j = 0; j < NR_CPUS; j++) 54 for_each_online_cpu(j)
56 if (cpu_online(j)) 55 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
57 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
58#endif 56#endif
59 seq_printf(p, " %14s", irq_desc[i].handler->typename); 57 seq_printf(p, " %14s", irq_desc[i].handler->typename);
60 seq_printf(p, " %s", action->name); 58 seq_printf(p, " %s", action->name);
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index 703cbc6dc9cc..15c16b62dff5 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ 19#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
20#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
21#include <linux/bcd.h>
21#include <asm/bvme6000hw.h> 22#include <asm/bvme6000hw.h>
22 23
23#include <asm/io.h> 24#include <asm/io.h>
@@ -32,9 +33,6 @@
32 * ioctls. 33 * ioctls.
33 */ 34 */
34 35
35#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
36#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
37
38static unsigned char days_in_mo[] = 36static unsigned char days_in_mo[] =
39{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 37{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
40 38
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 7d93992e462c..3dd76b3d2967 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -68,9 +68,8 @@ int show_interrupts(struct seq_file *p, void *v)
68 68
69 if (i == 0) { 69 if (i == 0) {
70 seq_printf(p, " "); 70 seq_printf(p, " ");
71 for (j=0; j<NR_CPUS; j++) 71 for_each_online_cpu(j)
72 if (cpu_online(j)) 72 seq_printf(p, "CPU%d ",j);
73 seq_printf(p, "CPU%d ",j);
74 seq_putc(p, '\n'); 73 seq_putc(p, '\n');
75 } 74 }
76 75
@@ -83,9 +82,8 @@ int show_interrupts(struct seq_file *p, void *v)
83#ifndef CONFIG_SMP 82#ifndef CONFIG_SMP
84 seq_printf(p, "%10u ", kstat_irqs(i)); 83 seq_printf(p, "%10u ", kstat_irqs(i));
85#else 84#else
86 for (j = 0; j < NR_CPUS; j++) 85 for_each_online_cpu(j)
87 if (cpu_online(j)) 86 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
88 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
89#endif 87#endif
90 seq_printf(p, " %14s", irq_desc[i].handler->typename); 88 seq_printf(p, " %14s", irq_desc[i].handler->typename);
91 seq_printf(p, " %s", action->name); 89 seq_printf(p, " %s", action->name);
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 06ed90752424..78d171bfa331 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -167,8 +167,8 @@ int smp_call_function (void (*func) (void *info), void *info, int retry,
167 mb(); 167 mb();
168 168
169 /* Send a message to all other CPUs and wait for them to respond */ 169 /* Send a message to all other CPUs and wait for them to respond */
170 for (i = 0; i < NR_CPUS; i++) 170 for_each_online_cpu(i)
171 if (cpu_online(i) && i != cpu) 171 if (i != cpu)
172 core_send_ipi(i, SMP_CALL_FUNCTION); 172 core_send_ipi(i, SMP_CALL_FUNCTION);
173 173
174 /* Wait for response */ 174 /* Wait for response */
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 73e5e52781d8..2854ac4c9be1 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -88,12 +88,9 @@ static inline int find_level(cpuid_t *cpunum, int irq)
88{ 88{
89 int cpu, i; 89 int cpu, i;
90 90
91 for (cpu = 0; cpu <= NR_CPUS; cpu++) { 91 for_each_online_cpu(cpu) {
92 struct slice_data *si = cpu_data[cpu].data; 92 struct slice_data *si = cpu_data[cpu].data;
93 93
94 if (!cpu_online(cpu))
95 continue;
96
97 for (i = BASE_PCI_IRQ; i < LEVELS_PER_SLICE; i++) 94 for (i = BASE_PCI_IRQ; i < LEVELS_PER_SLICE; i++)
98 if (si->level_to_irq[i] == irq) { 95 if (si->level_to_irq[i] == irq) {
99 *cpunum = cpu; 96 *cpunum = cpu;
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 25564b7ca6bb..d6ac1c60a471 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -298,8 +298,8 @@ send_IPI_allbutself(enum ipi_message_type op)
298{ 298{
299 int i; 299 int i;
300 300
301 for (i = 0; i < NR_CPUS; i++) { 301 for_each_online_cpu(i) {
302 if (cpu_online(i) && i != smp_processor_id()) 302 if (i != smp_processor_id())
303 send_IPI_single(i, op); 303 send_IPI_single(i, op);
304 } 304 }
305} 305}
@@ -643,14 +643,13 @@ int sys_cpus(int argc, char **argv)
643 if ( argc == 1 ){ 643 if ( argc == 1 ){
644 644
645#ifdef DUMP_MORE_STATE 645#ifdef DUMP_MORE_STATE
646 for(i=0; i<NR_CPUS; i++) { 646 for_each_online_cpu(i) {
647 int cpus_per_line = 4; 647 int cpus_per_line = 4;
648 if(cpu_online(i)) { 648
649 if (j++ % cpus_per_line) 649 if (j++ % cpus_per_line)
650 printk(" %3d",i); 650 printk(" %3d",i);
651 else 651 else
652 printk("\n %3d",i); 652 printk("\n %3d",i);
653 }
654 } 653 }
655 printk("\n"); 654 printk("\n");
656#else 655#else
@@ -659,9 +658,7 @@ int sys_cpus(int argc, char **argv)
659 } else if((argc==2) && !(strcmp(argv[1],"-l"))) { 658 } else if((argc==2) && !(strcmp(argv[1],"-l"))) {
660 printk("\nCPUSTATE TASK CPUNUM CPUID HARDCPU(HPA)\n"); 659 printk("\nCPUSTATE TASK CPUNUM CPUID HARDCPU(HPA)\n");
661#ifdef DUMP_MORE_STATE 660#ifdef DUMP_MORE_STATE
662 for(i=0;i<NR_CPUS;i++) { 661 for_each_online_cpu(i) {
663 if (!cpu_online(i))
664 continue;
665 if (cpu_data[i].cpuid != NO_PROC_ID) { 662 if (cpu_data[i].cpuid != NO_PROC_ID) {
666 switch(cpu_data[i].state) { 663 switch(cpu_data[i].state) {
667 case STATE_RENDEZVOUS: 664 case STATE_RENDEZVOUS:
@@ -695,9 +692,7 @@ int sys_cpus(int argc, char **argv)
695 } else if ((argc==2) && !(strcmp(argv[1],"-s"))) { 692 } else if ((argc==2) && !(strcmp(argv[1],"-s"))) {
696#ifdef DUMP_MORE_STATE 693#ifdef DUMP_MORE_STATE
697 printk("\nCPUSTATE CPUID\n"); 694 printk("\nCPUSTATE CPUID\n");
698 for (i=0;i<NR_CPUS;i++) { 695 for_each_online_cpu(i) {
699 if (!cpu_online(i))
700 continue;
701 if (cpu_data[i].cpuid != NO_PROC_ID) { 696 if (cpu_data[i].cpuid != NO_PROC_ID) {
702 switch(cpu_data[i].state) { 697 switch(cpu_data[i].state) {
703 case STATE_RENDEZVOUS: 698 case STATE_RENDEZVOUS:
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index dfba81719dec..fae42da7468d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -127,6 +127,12 @@ config PPC_83xx
127 select 83xx 127 select 83xx
128 select PPC_FPU 128 select PPC_FPU
129 129
130config PPC_85xx
131 bool "Freescale 85xx"
132 select E500
133 select FSL_SOC
134 select 85xx
135
130config 40x 136config 40x
131 bool "AMCC 40x" 137 bool "AMCC 40x"
132 138
@@ -139,8 +145,6 @@ config 8xx
139config E200 145config E200
140 bool "Freescale e200" 146 bool "Freescale e200"
141 147
142config E500
143 bool "Freescale e500"
144endchoice 148endchoice
145 149
146config POWER4_ONLY 150config POWER4_ONLY
@@ -168,6 +172,13 @@ config 6xx
168config 83xx 172config 83xx
169 bool 173 bool
170 174
175# this is temp to handle compat with arch=ppc
176config 85xx
177 bool
178
179config E500
180 bool
181
171config PPC_FPU 182config PPC_FPU
172 bool 183 bool
173 default y if PPC64 184 default y if PPC64
@@ -217,6 +228,7 @@ config ALTIVEC
217config SPE 228config SPE
218 bool "SPE Support" 229 bool "SPE Support"
219 depends on E200 || E500 230 depends on E200 || E500
231 default y
220 ---help--- 232 ---help---
221 This option enables kernel support for the Signal Processing 233 This option enables kernel support for the Signal Processing
222 Extensions (SPE) to the PowerPC processor. The kernel currently 234 Extensions (SPE) to the PowerPC processor. The kernel currently
@@ -238,6 +250,21 @@ config PPC_STD_MMU_32
238 def_bool y 250 def_bool y
239 depends on PPC_STD_MMU && PPC32 251 depends on PPC_STD_MMU && PPC32
240 252
253config VIRT_CPU_ACCOUNTING
254 bool "Deterministic task and CPU time accounting"
255 depends on PPC64
256 default y
257 help
258 Select this option to enable more accurate task and CPU time
259 accounting. This is done by reading a CPU counter on each
260 kernel entry and exit and on transitions within the kernel
261 between system, softirq and hardirq state, so there is a
262 small performance impact. This also enables accounting of
263 stolen time on logically-partitioned systems running on
264 IBM POWER5-based machines.
265
266 If in doubt, say Y here.
267
241config SMP 268config SMP
242 depends on PPC_STD_MMU 269 depends on PPC_STD_MMU
243 bool "Symmetric multi-processing support" 270 bool "Symmetric multi-processing support"
@@ -734,13 +761,12 @@ config GENERIC_ISA_DMA
734 761
735config PPC_I8259 762config PPC_I8259
736 bool 763 bool
737 default y if 85xx
738 default n 764 default n
739 765
740config PPC_INDIRECT_PCI 766config PPC_INDIRECT_PCI
741 bool 767 bool
742 depends on PCI 768 depends on PCI
743 default y if 40x || 44x || 85xx 769 default y if 40x || 44x
744 default n 770 default n
745 771
746config EISA 772config EISA
@@ -757,8 +783,8 @@ config MCA
757 bool 783 bool
758 784
759config PCI 785config PCI
760 bool "PCI support" if 40x || CPM2 || PPC_83xx || 85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) 786 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES)
761 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !85xx 787 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !PPC_85xx
762 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS 788 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
763 default PCI_QSPAN if !4xx && !CPM2 && 8xx 789 default PCI_QSPAN if !4xx && !CPM2 && 8xx
764 help 790 help
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 5500ab55d042..a3fc7a23158f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -148,7 +148,7 @@ all: $(KBUILD_IMAGE)
148 148
149CPPFLAGS_vmlinux.lds := -Upowerpc 149CPPFLAGS_vmlinux.lds := -Upowerpc
150 150
151BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage 151BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin
152 152
153.PHONY: $(BOOT_TARGETS) 153.PHONY: $(BOOT_TARGETS)
154 154
diff --git a/arch/powerpc/boot/install.sh b/arch/powerpc/boot/install.sh
index eacce9590816..b002bfd56786 100644
--- a/arch/powerpc/boot/install.sh
+++ b/arch/powerpc/boot/install.sh
@@ -1,7 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# arch/ppc64/boot/install.sh
4#
5# This file is subject to the terms and conditions of the GNU General Public 3# This file is subject to the terms and conditions of the GNU General Public
6# License. See the file "COPYING" in the main directory of this archive 4# License. See the file "COPYING" in the main directory of this archive
7# for more details. 5# for more details.
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 55ec59867250..816446f0e497 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -152,7 +152,7 @@ static int is_elf64(void *hdr)
152 elf64ph = (Elf64_Phdr *)((unsigned long)elf64 + 152 elf64ph = (Elf64_Phdr *)((unsigned long)elf64 +
153 (unsigned long)elf64->e_phoff); 153 (unsigned long)elf64->e_phoff);
154 for (i = 0; i < (unsigned int)elf64->e_phnum; i++, elf64ph++) 154 for (i = 0; i < (unsigned int)elf64->e_phnum; i++, elf64ph++)
155 if (elf64ph->p_type == PT_LOAD && elf64ph->p_offset != 0) 155 if (elf64ph->p_type == PT_LOAD)
156 break; 156 break;
157 if (i >= (unsigned int)elf64->e_phnum) 157 if (i >= (unsigned int)elf64->e_phnum)
158 return 0; 158 return 0;
@@ -193,7 +193,7 @@ static int is_elf32(void *hdr)
193 elf32 = (Elf32_Ehdr *)elfheader; 193 elf32 = (Elf32_Ehdr *)elfheader;
194 elf32ph = (Elf32_Phdr *) ((unsigned long)elf32 + elf32->e_phoff); 194 elf32ph = (Elf32_Phdr *) ((unsigned long)elf32 + elf32->e_phoff);
195 for (i = 0; i < elf32->e_phnum; i++, elf32ph++) 195 for (i = 0; i < elf32->e_phnum; i++, elf32ph++)
196 if (elf32ph->p_type == PT_LOAD && elf32ph->p_offset != 0) 196 if (elf32ph->p_type == PT_LOAD)
197 break; 197 break;
198 if (i >= elf32->e_phnum) 198 if (i >= elf32->e_phnum)
199 return 0; 199 return 0;
diff --git a/arch/powerpc/configs/mpc8540_ads_defconfig b/arch/powerpc/configs/mpc8540_ads_defconfig
new file mode 100644
index 000000000000..2a8290ee15c6
--- /dev/null
+++ b/arch/powerpc/configs/mpc8540_ads_defconfig
@@ -0,0 +1,721 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version:
4# Sat Jan 14 15:57:54 2006
5#
6# CONFIG_PPC64 is not set
7CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_RWSEM_XCHGADD_ALGORITHM=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13CONFIG_PPC=y
14CONFIG_EARLY_PRINTK=y
15CONFIG_GENERIC_NVRAM=y
16CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
17CONFIG_ARCH_MAY_HAVE_PC_FDC=y
18CONFIG_PPC_OF=y
19CONFIG_PPC_UDBG_16550=y
20# CONFIG_GENERIC_TBSYNC is not set
21
22#
23# Processor support
24#
25# CONFIG_CLASSIC32 is not set
26# CONFIG_PPC_52xx is not set
27# CONFIG_PPC_82xx is not set
28# CONFIG_PPC_83xx is not set
29CONFIG_PPC_85xx=y
30# CONFIG_40x is not set
31# CONFIG_44x is not set
32# CONFIG_8xx is not set
33# CONFIG_E200 is not set
34CONFIG_85xx=y
35CONFIG_E500=y
36CONFIG_BOOKE=y
37CONFIG_FSL_BOOKE=y
38# CONFIG_PHYS_64BIT is not set
39CONFIG_SPE=y
40
41#
42# Code maturity level options
43#
44CONFIG_EXPERIMENTAL=y
45CONFIG_CLEAN_COMPILE=y
46CONFIG_BROKEN_ON_SMP=y
47CONFIG_INIT_ENV_ARG_LIMIT=32
48
49#
50# General setup
51#
52CONFIG_LOCALVERSION=""
53CONFIG_LOCALVERSION_AUTO=y
54CONFIG_SWAP=y
55CONFIG_SYSVIPC=y
56# CONFIG_POSIX_MQUEUE is not set
57# CONFIG_BSD_PROCESS_ACCT is not set
58CONFIG_SYSCTL=y
59# CONFIG_AUDIT is not set
60# CONFIG_IKCONFIG is not set
61CONFIG_INITRAMFS_SOURCE=""
62# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
63CONFIG_EMBEDDED=y
64CONFIG_KALLSYMS=y
65# CONFIG_KALLSYMS_ALL is not set
66# CONFIG_KALLSYMS_EXTRA_PASS is not set
67CONFIG_HOTPLUG=y
68CONFIG_PRINTK=y
69CONFIG_BUG=y
70CONFIG_ELF_CORE=y
71CONFIG_BASE_FULL=y
72CONFIG_FUTEX=y
73CONFIG_EPOLL=y
74CONFIG_SHMEM=y
75CONFIG_CC_ALIGN_FUNCTIONS=0
76CONFIG_CC_ALIGN_LABELS=0
77CONFIG_CC_ALIGN_LOOPS=0
78CONFIG_CC_ALIGN_JUMPS=0
79CONFIG_SLAB=y
80# CONFIG_TINY_SHMEM is not set
81CONFIG_BASE_SMALL=0
82# CONFIG_SLOB is not set
83
84#
85# Loadable module support
86#
87# CONFIG_MODULES is not set
88
89#
90# Block layer
91#
92# CONFIG_LBD is not set
93
94#
95# IO Schedulers
96#
97CONFIG_IOSCHED_NOOP=y
98CONFIG_IOSCHED_AS=y
99CONFIG_IOSCHED_DEADLINE=y
100CONFIG_IOSCHED_CFQ=y
101CONFIG_DEFAULT_AS=y
102# CONFIG_DEFAULT_DEADLINE is not set
103# CONFIG_DEFAULT_CFQ is not set
104# CONFIG_DEFAULT_NOOP is not set
105CONFIG_DEFAULT_IOSCHED="anticipatory"
106CONFIG_MPIC=y
107# CONFIG_WANT_EARLY_SERIAL is not set
108
109#
110# Platform support
111#
112CONFIG_MPC8540_ADS=y
113CONFIG_MPC8540=y
114CONFIG_PPC_INDIRECT_PCI_BE=y
115
116#
117# Kernel options
118#
119# CONFIG_HIGHMEM is not set
120# CONFIG_HZ_100 is not set
121CONFIG_HZ_250=y
122# CONFIG_HZ_1000 is not set
123CONFIG_HZ=250
124CONFIG_PREEMPT_NONE=y
125# CONFIG_PREEMPT_VOLUNTARY is not set
126# CONFIG_PREEMPT is not set
127CONFIG_BINFMT_ELF=y
128CONFIG_BINFMT_MISC=y
129CONFIG_MATH_EMULATION=y
130CONFIG_ARCH_FLATMEM_ENABLE=y
131CONFIG_SELECT_MEMORY_MODEL=y
132CONFIG_FLATMEM_MANUAL=y
133# CONFIG_DISCONTIGMEM_MANUAL is not set
134# CONFIG_SPARSEMEM_MANUAL is not set
135CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4
139CONFIG_PROC_DEVICETREE=y
140# CONFIG_CMDLINE_BOOL is not set
141# CONFIG_PM is not set
142# CONFIG_SOFTWARE_SUSPEND is not set
143# CONFIG_SECCOMP is not set
144CONFIG_ISA_DMA_API=y
145
146#
147# Bus options
148#
149# CONFIG_PPC_I8259 is not set
150CONFIG_PPC_INDIRECT_PCI=y
151CONFIG_FSL_SOC=y
152# CONFIG_PCI is not set
153# CONFIG_PCI_DOMAINS is not set
154
155#
156# PCCARD (PCMCIA/CardBus) support
157#
158# CONFIG_PCCARD is not set
159
160#
161# PCI Hotplug Support
162#
163
164#
165# Advanced setup
166#
167# CONFIG_ADVANCED_OPTIONS is not set
168
169#
170# Default settings for advanced configuration options are used
171#
172CONFIG_HIGHMEM_START=0xfe000000
173CONFIG_LOWMEM_SIZE=0x30000000
174CONFIG_KERNEL_START=0xc0000000
175CONFIG_TASK_SIZE=0x80000000
176CONFIG_BOOT_LOAD=0x00800000
177
178#
179# Networking
180#
181CONFIG_NET=y
182
183#
184# Networking options
185#
186CONFIG_PACKET=y
187# CONFIG_PACKET_MMAP is not set
188CONFIG_UNIX=y
189# CONFIG_NET_KEY is not set
190CONFIG_INET=y
191CONFIG_IP_MULTICAST=y
192# CONFIG_IP_ADVANCED_ROUTER is not set
193CONFIG_IP_FIB_HASH=y
194CONFIG_IP_PNP=y
195CONFIG_IP_PNP_DHCP=y
196CONFIG_IP_PNP_BOOTP=y
197# CONFIG_IP_PNP_RARP is not set
198# CONFIG_NET_IPIP is not set
199# CONFIG_NET_IPGRE is not set
200# CONFIG_IP_MROUTE is not set
201# CONFIG_ARPD is not set
202CONFIG_SYN_COOKIES=y
203# CONFIG_INET_AH is not set
204# CONFIG_INET_ESP is not set
205# CONFIG_INET_IPCOMP is not set
206# CONFIG_INET_TUNNEL is not set
207CONFIG_INET_DIAG=y
208CONFIG_INET_TCP_DIAG=y
209# CONFIG_TCP_CONG_ADVANCED is not set
210CONFIG_TCP_CONG_BIC=y
211# CONFIG_IPV6 is not set
212# CONFIG_NETFILTER is not set
213
214#
215# DCCP Configuration (EXPERIMENTAL)
216#
217# CONFIG_IP_DCCP is not set
218
219#
220# SCTP Configuration (EXPERIMENTAL)
221#
222# CONFIG_IP_SCTP is not set
223# CONFIG_ATM is not set
224# CONFIG_BRIDGE is not set
225# CONFIG_VLAN_8021Q is not set
226# CONFIG_DECNET is not set
227# CONFIG_LLC2 is not set
228# CONFIG_IPX is not set
229# CONFIG_ATALK is not set
230# CONFIG_X25 is not set
231# CONFIG_LAPB is not set
232
233#
234# TIPC Configuration (EXPERIMENTAL)
235#
236# CONFIG_TIPC is not set
237# CONFIG_NET_DIVERT is not set
238# CONFIG_ECONET is not set
239# CONFIG_WAN_ROUTER is not set
240
241#
242# QoS and/or fair queueing
243#
244# CONFIG_NET_SCHED is not set
245
246#
247# Network testing
248#
249# CONFIG_NET_PKTGEN is not set
250# CONFIG_HAMRADIO is not set
251# CONFIG_IRDA is not set
252# CONFIG_BT is not set
253# CONFIG_IEEE80211 is not set
254
255#
256# Device Drivers
257#
258
259#
260# Generic Driver Options
261#
262CONFIG_STANDALONE=y
263CONFIG_PREVENT_FIRMWARE_BUILD=y
264# CONFIG_FW_LOADER is not set
265# CONFIG_DEBUG_DRIVER is not set
266
267#
268# Connector - unified userspace <-> kernelspace linker
269#
270# CONFIG_CONNECTOR is not set
271
272#
273# Memory Technology Devices (MTD)
274#
275# CONFIG_MTD is not set
276
277#
278# Parallel port support
279#
280# CONFIG_PARPORT is not set
281
282#
283# Plug and Play support
284#
285
286#
287# Block devices
288#
289# CONFIG_BLK_DEV_FD is not set
290# CONFIG_BLK_DEV_COW_COMMON is not set
291CONFIG_BLK_DEV_LOOP=y
292# CONFIG_BLK_DEV_CRYPTOLOOP is not set
293# CONFIG_BLK_DEV_NBD is not set
294CONFIG_BLK_DEV_RAM=y
295CONFIG_BLK_DEV_RAM_COUNT=16
296CONFIG_BLK_DEV_RAM_SIZE=32768
297CONFIG_BLK_DEV_INITRD=y
298# CONFIG_CDROM_PKTCDVD is not set
299# CONFIG_ATA_OVER_ETH is not set
300
301#
302# ATA/ATAPI/MFM/RLL support
303#
304# CONFIG_IDE is not set
305
306#
307# SCSI device support
308#
309# CONFIG_RAID_ATTRS is not set
310# CONFIG_SCSI is not set
311
312#
313# Multi-device support (RAID and LVM)
314#
315# CONFIG_MD is not set
316
317#
318# Fusion MPT device support
319#
320# CONFIG_FUSION is not set
321
322#
323# IEEE 1394 (FireWire) support
324#
325
326#
327# I2O device support
328#
329
330#
331# Macintosh device drivers
332#
333# CONFIG_WINDFARM is not set
334
335#
336# Network device support
337#
338CONFIG_NETDEVICES=y
339# CONFIG_DUMMY is not set
340# CONFIG_BONDING is not set
341# CONFIG_EQUALIZER is not set
342# CONFIG_TUN is not set
343
344#
345# PHY device support
346#
347CONFIG_PHYLIB=y
348
349#
350# MII PHY device drivers
351#
352# CONFIG_MARVELL_PHY is not set
353# CONFIG_DAVICOM_PHY is not set
354# CONFIG_QSEMI_PHY is not set
355# CONFIG_LXT_PHY is not set
356# CONFIG_CICADA_PHY is not set
357
358#
359# Ethernet (10 or 100Mbit)
360#
361CONFIG_NET_ETHERNET=y
362CONFIG_MII=y
363
364#
365# Ethernet (1000 Mbit)
366#
367CONFIG_GIANFAR=y
368CONFIG_GFAR_NAPI=y
369
370#
371# Ethernet (10000 Mbit)
372#
373
374#
375# Token Ring devices
376#
377
378#
379# Wireless LAN (non-hamradio)
380#
381# CONFIG_NET_RADIO is not set
382
383#
384# Wan interfaces
385#
386# CONFIG_WAN is not set
387# CONFIG_PPP is not set
388# CONFIG_SLIP is not set
389# CONFIG_SHAPER is not set
390# CONFIG_NETCONSOLE is not set
391# CONFIG_NETPOLL is not set
392# CONFIG_NET_POLL_CONTROLLER is not set
393
394#
395# ISDN subsystem
396#
397# CONFIG_ISDN is not set
398
399#
400# Telephony Support
401#
402# CONFIG_PHONE is not set
403
404#
405# Input device support
406#
407CONFIG_INPUT=y
408
409#
410# Userland interfaces
411#
412# CONFIG_INPUT_MOUSEDEV is not set
413# CONFIG_INPUT_JOYDEV is not set
414# CONFIG_INPUT_TSDEV is not set
415# CONFIG_INPUT_EVDEV is not set
416# CONFIG_INPUT_EVBUG is not set
417
418#
419# Input Device Drivers
420#
421# CONFIG_INPUT_KEYBOARD is not set
422# CONFIG_INPUT_MOUSE is not set
423# CONFIG_INPUT_JOYSTICK is not set
424# CONFIG_INPUT_TOUCHSCREEN is not set
425# CONFIG_INPUT_MISC is not set
426
427#
428# Hardware I/O ports
429#
430# CONFIG_SERIO is not set
431# CONFIG_GAMEPORT is not set
432
433#
434# Character devices
435#
436# CONFIG_VT is not set
437# CONFIG_SERIAL_NONSTANDARD is not set
438
439#
440# Serial drivers
441#
442CONFIG_SERIAL_8250=y
443CONFIG_SERIAL_8250_CONSOLE=y
444CONFIG_SERIAL_8250_NR_UARTS=4
445CONFIG_SERIAL_8250_RUNTIME_UARTS=4
446# CONFIG_SERIAL_8250_EXTENDED is not set
447
448#
449# Non-8250 serial port support
450#
451CONFIG_SERIAL_CORE=y
452CONFIG_SERIAL_CORE_CONSOLE=y
453CONFIG_UNIX98_PTYS=y
454CONFIG_LEGACY_PTYS=y
455CONFIG_LEGACY_PTY_COUNT=256
456
457#
458# IPMI
459#
460# CONFIG_IPMI_HANDLER is not set
461
462#
463# Watchdog Cards
464#
465# CONFIG_WATCHDOG is not set
466# CONFIG_NVRAM is not set
467CONFIG_GEN_RTC=y
468# CONFIG_GEN_RTC_X is not set
469# CONFIG_DTLK is not set
470# CONFIG_R3964 is not set
471
472#
473# Ftape, the floppy tape device driver
474#
475# CONFIG_AGP is not set
476# CONFIG_RAW_DRIVER is not set
477
478#
479# TPM devices
480#
481# CONFIG_TCG_TPM is not set
482# CONFIG_TELCLOCK is not set
483
484#
485# I2C support
486#
487# CONFIG_I2C is not set
488
489#
490# Dallas's 1-wire bus
491#
492# CONFIG_W1 is not set
493
494#
495# Hardware Monitoring support
496#
497CONFIG_HWMON=y
498# CONFIG_HWMON_VID is not set
499# CONFIG_HWMON_DEBUG_CHIP is not set
500
501#
502# Misc devices
503#
504
505#
506# Multimedia Capabilities Port drivers
507#
508
509#
510# Multimedia devices
511#
512# CONFIG_VIDEO_DEV is not set
513
514#
515# Digital Video Broadcasting Devices
516#
517# CONFIG_DVB is not set
518
519#
520# Graphics support
521#
522# CONFIG_FB is not set
523
524#
525# Sound
526#
527# CONFIG_SOUND is not set
528
529#
530# USB support
531#
532# CONFIG_USB_ARCH_HAS_HCD is not set
533# CONFIG_USB_ARCH_HAS_OHCI is not set
534
535#
536# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
537#
538
539#
540# USB Gadget Support
541#
542# CONFIG_USB_GADGET is not set
543
544#
545# MMC/SD Card support
546#
547# CONFIG_MMC is not set
548
549#
550# InfiniBand support
551#
552
553#
554# SN Devices
555#
556
557#
558# File systems
559#
560CONFIG_EXT2_FS=y
561# CONFIG_EXT2_FS_XATTR is not set
562# CONFIG_EXT2_FS_XIP is not set
563CONFIG_EXT3_FS=y
564CONFIG_EXT3_FS_XATTR=y
565# CONFIG_EXT3_FS_POSIX_ACL is not set
566# CONFIG_EXT3_FS_SECURITY is not set
567CONFIG_JBD=y
568# CONFIG_JBD_DEBUG is not set
569CONFIG_FS_MBCACHE=y
570# CONFIG_REISERFS_FS is not set
571# CONFIG_JFS_FS is not set
572# CONFIG_FS_POSIX_ACL is not set
573# CONFIG_XFS_FS is not set
574# CONFIG_OCFS2_FS is not set
575# CONFIG_MINIX_FS is not set
576# CONFIG_ROMFS_FS is not set
577CONFIG_INOTIFY=y
578# CONFIG_QUOTA is not set
579CONFIG_DNOTIFY=y
580# CONFIG_AUTOFS_FS is not set
581# CONFIG_AUTOFS4_FS is not set
582# CONFIG_FUSE_FS is not set
583
584#
585# CD-ROM/DVD Filesystems
586#
587# CONFIG_ISO9660_FS is not set
588# CONFIG_UDF_FS is not set
589
590#
591# DOS/FAT/NT Filesystems
592#
593# CONFIG_MSDOS_FS is not set
594# CONFIG_VFAT_FS is not set
595# CONFIG_NTFS_FS is not set
596
597#
598# Pseudo filesystems
599#
600CONFIG_PROC_FS=y
601CONFIG_PROC_KCORE=y
602CONFIG_SYSFS=y
603CONFIG_TMPFS=y
604# CONFIG_HUGETLB_PAGE is not set
605CONFIG_RAMFS=y
606# CONFIG_RELAYFS_FS is not set
607# CONFIG_CONFIGFS_FS is not set
608
609#
610# Miscellaneous filesystems
611#
612# CONFIG_ADFS_FS is not set
613# CONFIG_AFFS_FS is not set
614# CONFIG_HFS_FS is not set
615# CONFIG_HFSPLUS_FS is not set
616# CONFIG_BEFS_FS is not set
617# CONFIG_BFS_FS is not set
618# CONFIG_EFS_FS is not set
619# CONFIG_CRAMFS is not set
620# CONFIG_VXFS_FS is not set
621# CONFIG_HPFS_FS is not set
622# CONFIG_QNX4FS_FS is not set
623# CONFIG_SYSV_FS is not set
624# CONFIG_UFS_FS is not set
625
626#
627# Network File Systems
628#
629CONFIG_NFS_FS=y
630# CONFIG_NFS_V3 is not set
631# CONFIG_NFS_V4 is not set
632# CONFIG_NFS_DIRECTIO is not set
633# CONFIG_NFSD is not set
634CONFIG_ROOT_NFS=y
635CONFIG_LOCKD=y
636CONFIG_NFS_COMMON=y
637CONFIG_SUNRPC=y
638# CONFIG_RPCSEC_GSS_KRB5 is not set
639# CONFIG_RPCSEC_GSS_SPKM3 is not set
640# CONFIG_SMB_FS is not set
641# CONFIG_CIFS is not set
642# CONFIG_NCP_FS is not set
643# CONFIG_CODA_FS is not set
644# CONFIG_AFS_FS is not set
645# CONFIG_9P_FS is not set
646
647#
648# Partition Types
649#
650CONFIG_PARTITION_ADVANCED=y
651# CONFIG_ACORN_PARTITION is not set
652# CONFIG_OSF_PARTITION is not set
653# CONFIG_AMIGA_PARTITION is not set
654# CONFIG_ATARI_PARTITION is not set
655# CONFIG_MAC_PARTITION is not set
656# CONFIG_MSDOS_PARTITION is not set
657# CONFIG_LDM_PARTITION is not set
658# CONFIG_SGI_PARTITION is not set
659# CONFIG_ULTRIX_PARTITION is not set
660# CONFIG_SUN_PARTITION is not set
661# CONFIG_EFI_PARTITION is not set
662
663#
664# Native Language Support
665#
666# CONFIG_NLS is not set
667
668#
669# Library routines
670#
671# CONFIG_CRC_CCITT is not set
672# CONFIG_CRC16 is not set
673CONFIG_CRC32=y
674# CONFIG_LIBCRC32C is not set
675
676#
677# Instrumentation Support
678#
679# CONFIG_PROFILING is not set
680
681#
682# Kernel hacking
683#
684# CONFIG_PRINTK_TIME is not set
685# CONFIG_MAGIC_SYSRQ is not set
686CONFIG_DEBUG_KERNEL=y
687CONFIG_LOG_BUF_SHIFT=14
688CONFIG_DETECT_SOFTLOCKUP=y
689# CONFIG_SCHEDSTATS is not set
690# CONFIG_DEBUG_SLAB is not set
691CONFIG_DEBUG_MUTEXES=y
692# CONFIG_DEBUG_SPINLOCK is not set
693# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
694# CONFIG_DEBUG_KOBJECT is not set
695# CONFIG_DEBUG_INFO is not set
696# CONFIG_DEBUG_FS is not set
697# CONFIG_DEBUG_VM is not set
698# CONFIG_RCU_TORTURE_TEST is not set
699# CONFIG_DEBUGGER is not set
700# CONFIG_BDI_SWITCH is not set
701# CONFIG_BOOTX_TEXT is not set
702# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
703# CONFIG_PPC_EARLY_DEBUG_G5 is not set
704# CONFIG_PPC_EARLY_DEBUG_RTAS is not set
705# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set
706# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
707
708#
709# Security options
710#
711# CONFIG_KEYS is not set
712# CONFIG_SECURITY is not set
713
714#
715# Cryptographic options
716#
717# CONFIG_CRYPTO is not set
718
719#
720# Hardware crypto devices
721#
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index c9a660e4c2db..882889b15926 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -136,6 +136,9 @@ int main(void)
136 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp)); 136 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp));
137 DEFINE(PACALPPACAPTR, offsetof(struct paca_struct, lppaca_ptr)); 137 DEFINE(PACALPPACAPTR, offsetof(struct paca_struct, lppaca_ptr));
138 DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id)); 138 DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id));
139 DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr));
140 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
141 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
139 142
140 DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0)); 143 DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0));
141 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1)); 144 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1));
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index e4e81374cb9a..39e348a3ade2 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -894,7 +894,7 @@ struct cpu_spec cpu_specs[] = {
894 .platform = "ppc405", 894 .platform = "ppc405",
895 }, 895 },
896 { /* Xilinx Virtex-II Pro */ 896 { /* Xilinx Virtex-II Pro */
897 .pvr_mask = 0xffff0000, 897 .pvr_mask = 0xfffff000,
898 .pvr_value = 0x20010000, 898 .pvr_value = 0x20010000,
899 .cpu_name = "Virtex-II Pro", 899 .cpu_name = "Virtex-II Pro",
900 .cpu_features = CPU_FTRS_40X, 900 .cpu_features = CPU_FTRS_40X,
@@ -904,6 +904,16 @@ struct cpu_spec cpu_specs[] = {
904 .dcache_bsize = 32, 904 .dcache_bsize = 32,
905 .platform = "ppc405", 905 .platform = "ppc405",
906 }, 906 },
907 { /* Xilinx Virtex-4 FX */
908 .pvr_mask = 0xfffff000,
909 .pvr_value = 0x20011000,
910 .cpu_name = "Virtex-4 FX",
911 .cpu_features = CPU_FTRS_40X,
912 .cpu_user_features = PPC_FEATURE_32 |
913 PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
914 .icache_bsize = 32,
915 .dcache_bsize = 32,
916 },
907 { /* 405EP */ 917 { /* 405EP */
908 .pvr_mask = 0xffff0000, 918 .pvr_mask = 0xffff0000,
909 .pvr_value = 0x51210000, 919 .pvr_value = 0x51210000,
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 24be0cf86d7f..1060155d84c3 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/entry.S
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 4 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
@@ -63,6 +61,7 @@ system_call_common:
63 std r12,_MSR(r1) 61 std r12,_MSR(r1)
64 std r0,GPR0(r1) 62 std r0,GPR0(r1)
65 std r10,GPR1(r1) 63 std r10,GPR1(r1)
64 ACCOUNT_CPU_USER_ENTRY(r10, r11)
66 std r2,GPR2(r1) 65 std r2,GPR2(r1)
67 std r3,GPR3(r1) 66 std r3,GPR3(r1)
68 std r4,GPR4(r1) 67 std r4,GPR4(r1)
@@ -170,8 +169,9 @@ syscall_error_cont:
170 stdcx. r0,0,r1 /* to clear the reservation */ 169 stdcx. r0,0,r1 /* to clear the reservation */
171 andi. r6,r8,MSR_PR 170 andi. r6,r8,MSR_PR
172 ld r4,_LINK(r1) 171 ld r4,_LINK(r1)
173 beq- 1f /* only restore r13 if */ 172 beq- 1f
174 ld r13,GPR13(r1) /* returning to usermode */ 173 ACCOUNT_CPU_USER_EXIT(r11, r12)
174 ld r13,GPR13(r1) /* only restore r13 if returning to usermode */
1751: ld r2,GPR2(r1) 1751: ld r2,GPR2(r1)
176 li r12,MSR_RI 176 li r12,MSR_RI
177 andc r11,r10,r12 177 andc r11,r10,r12
@@ -322,7 +322,7 @@ _GLOBAL(ret_from_fork)
322 * the fork code also. 322 * the fork code also.
323 * 323 *
324 * The code which creates the new task context is in 'copy_thread' 324 * The code which creates the new task context is in 'copy_thread'
325 * in arch/ppc64/kernel/process.c 325 * in arch/powerpc/kernel/process.c
326 */ 326 */
327 .align 7 327 .align 7
328_GLOBAL(_switch) 328_GLOBAL(_switch)
@@ -486,6 +486,7 @@ restore:
486 * userspace 486 * userspace
487 */ 487 */
488 beq 1f 488 beq 1f
489 ACCOUNT_CPU_USER_EXIT(r3, r4)
489 REST_GPR(13, r1) 490 REST_GPR(13, r1)
4901: 4911:
491 ld r3,_CTR(r1) 492 ld r3,_CTR(r1)
diff --git a/arch/powerpc/kernel/firmware.c b/arch/powerpc/kernel/firmware.c
index 65eae752a527..4d37a3cb80f6 100644
--- a/arch/powerpc/kernel/firmware.c
+++ b/arch/powerpc/kernel/firmware.c
@@ -18,28 +18,3 @@
18#include <asm/firmware.h> 18#include <asm/firmware.h>
19 19
20unsigned long ppc64_firmware_features; 20unsigned long ppc64_firmware_features;
21
22#ifdef CONFIG_PPC_PSERIES
23firmware_feature_t firmware_features_table[FIRMWARE_MAX_FEATURES] = {
24 {FW_FEATURE_PFT, "hcall-pft"},
25 {FW_FEATURE_TCE, "hcall-tce"},
26 {FW_FEATURE_SPRG0, "hcall-sprg0"},
27 {FW_FEATURE_DABR, "hcall-dabr"},
28 {FW_FEATURE_COPY, "hcall-copy"},
29 {FW_FEATURE_ASR, "hcall-asr"},
30 {FW_FEATURE_DEBUG, "hcall-debug"},
31 {FW_FEATURE_PERF, "hcall-perf"},
32 {FW_FEATURE_DUMP, "hcall-dump"},
33 {FW_FEATURE_INTERRUPT, "hcall-interrupt"},
34 {FW_FEATURE_MIGRATE, "hcall-migrate"},
35 {FW_FEATURE_PERFMON, "hcall-perfmon"},
36 {FW_FEATURE_CRQ, "hcall-crq"},
37 {FW_FEATURE_VIO, "hcall-vio"},
38 {FW_FEATURE_RDMA, "hcall-rdma"},
39 {FW_FEATURE_LLAN, "hcall-lLAN"},
40 {FW_FEATURE_BULK, "hcall-bulk"},
41 {FW_FEATURE_XDABR, "hcall-xdabr"},
42 {FW_FEATURE_MULTITCE, "hcall-multi-tce"},
43 {FW_FEATURE_SPLPAR, "hcall-splpar"},
44};
45#endif
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 8b49679fad54..47c7fa148c9a 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/head_44x.S
3 *
4 * Kernel execution entry point code. 2 * Kernel execution entry point code.
5 * 3 *
6 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org> 4 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 9b65029dd2a3..35084f3a841b 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/head.S
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * 4 *
@@ -279,6 +277,7 @@ exception_marker:
279 std r10,0(r1); /* make stack chain pointer */ \ 277 std r10,0(r1); /* make stack chain pointer */ \
280 std r0,GPR0(r1); /* save r0 in stackframe */ \ 278 std r0,GPR0(r1); /* save r0 in stackframe */ \
281 std r10,GPR1(r1); /* save r1 in stackframe */ \ 279 std r10,GPR1(r1); /* save r1 in stackframe */ \
280 ACCOUNT_CPU_USER_ENTRY(r9, r10); \
282 std r2,GPR2(r1); /* save r2 in stackframe */ \ 281 std r2,GPR2(r1); /* save r2 in stackframe */ \
283 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ 282 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \
284 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ 283 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
@@ -846,6 +845,14 @@ fast_exception_return:
846 ld r11,_NIP(r1) 845 ld r11,_NIP(r1)
847 andi. r3,r12,MSR_RI /* check if RI is set */ 846 andi. r3,r12,MSR_RI /* check if RI is set */
848 beq- unrecov_fer 847 beq- unrecov_fer
848
849#ifdef CONFIG_VIRT_CPU_ACCOUNTING
850 andi. r3,r12,MSR_PR
851 beq 2f
852 ACCOUNT_CPU_USER_EXIT(r3, r4)
8532:
854#endif
855
849 ld r3,_CCR(r1) 856 ld r3,_CCR(r1)
850 ld r4,_LINK(r1) 857 ld r4,_LINK(r1)
851 ld r5,_CTR(r1) 858 ld r5,_CTR(r1)
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index bc6d1ac55235..28941f5ce673 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/except_8xx.S
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 4 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
new file mode 100644
index 000000000000..8536e7676160
--- /dev/null
+++ b/arch/powerpc/kernel/head_booke.h
@@ -0,0 +1,363 @@
1#ifndef __HEAD_BOOKE_H__
2#define __HEAD_BOOKE_H__
3
4/*
5 * Macros used for common Book-e exception handling
6 */
7
8#define SET_IVOR(vector_number, vector_label) \
9 li r26,vector_label@l; \
10 mtspr SPRN_IVOR##vector_number,r26; \
11 sync
12
13#define NORMAL_EXCEPTION_PROLOG \
14 mtspr SPRN_SPRG0,r10; /* save two registers to work with */\
15 mtspr SPRN_SPRG1,r11; \
16 mtspr SPRN_SPRG4W,r1; \
17 mfcr r10; /* save CR in r10 for now */\
18 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
19 andi. r11,r11,MSR_PR; \
20 beq 1f; \
21 mfspr r1,SPRN_SPRG3; /* if from user, start at top of */\
22 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\
23 addi r1,r1,THREAD_SIZE; \
241: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\
25 mr r11,r1; \
26 stw r10,_CCR(r11); /* save various registers */\
27 stw r12,GPR12(r11); \
28 stw r9,GPR9(r11); \
29 mfspr r10,SPRN_SPRG0; \
30 stw r10,GPR10(r11); \
31 mfspr r12,SPRN_SPRG1; \
32 stw r12,GPR11(r11); \
33 mflr r10; \
34 stw r10,_LINK(r11); \
35 mfspr r10,SPRN_SPRG4R; \
36 mfspr r12,SPRN_SRR0; \
37 stw r10,GPR1(r11); \
38 mfspr r9,SPRN_SRR1; \
39 stw r10,0(r11); \
40 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
41 stw r0,GPR0(r11); \
42 SAVE_4GPRS(3, r11); \
43 SAVE_2GPRS(7, r11)
44
45/* To handle the additional exception priority levels on 40x and Book-E
46 * processors we allocate a 4k stack per additional priority level. The various
47 * head_xxx.S files allocate space (exception_stack_top) for each priority's
48 * stack times the number of CPUs
49 *
50 * On 40x critical is the only additional level
51 * On 44x/e500 we have critical and machine check
52 * On e200 we have critical and debug (machine check occurs via critical)
53 *
54 * Additionally we reserve a SPRG for each priority level so we can free up a
55 * GPR to use as the base for indirect access to the exception stacks. This
56 * is necessary since the MMU is always on, for Book-E parts, and the stacks
57 * are offset from KERNELBASE.
58 *
59 */
60#define BOOKE_EXCEPTION_STACK_SIZE (8192)
61
62/* CRIT_SPRG only used in critical exception handling */
63#define CRIT_SPRG SPRN_SPRG2
64/* MCHECK_SPRG only used in machine check exception handling */
65#define MCHECK_SPRG SPRN_SPRG6W
66
67#define MCHECK_STACK_TOP (exception_stack_top - 4096)
68#define CRIT_STACK_TOP (exception_stack_top)
69
70/* only on e200 for now */
71#define DEBUG_STACK_TOP (exception_stack_top - 4096)
72#define DEBUG_SPRG SPRN_SPRG6W
73
74#ifdef CONFIG_SMP
75#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
76 mfspr r8,SPRN_PIR; \
77 mulli r8,r8,BOOKE_EXCEPTION_STACK_SIZE; \
78 neg r8,r8; \
79 addis r8,r8,level##_STACK_TOP@ha; \
80 addi r8,r8,level##_STACK_TOP@l
81#else
82#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
83 lis r8,level##_STACK_TOP@h; \
84 ori r8,r8,level##_STACK_TOP@l
85#endif
86
87/*
88 * Exception prolog for critical/machine check exceptions. This is a
89 * little different from the normal exception prolog above since a
90 * critical/machine check exception can potentially occur at any point
91 * during normal exception processing. Thus we cannot use the same SPRG
92 * registers as the normal prolog above. Instead we use a portion of the
93 * critical/machine check exception stack at low physical addresses.
94 */
95#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
96 mtspr exc_level##_SPRG,r8; \
97 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
98 stw r10,GPR10-INT_FRAME_SIZE(r8); \
99 stw r11,GPR11-INT_FRAME_SIZE(r8); \
100 mfcr r10; /* save CR in r10 for now */\
101 mfspr r11,exc_level_srr1; /* check whether user or kernel */\
102 andi. r11,r11,MSR_PR; \
103 mr r11,r8; \
104 mfspr r8,exc_level##_SPRG; \
105 beq 1f; \
106 /* COMING FROM USER MODE */ \
107 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\
108 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
109 addi r11,r11,THREAD_SIZE; \
1101: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */\
111 stw r10,_CCR(r11); /* save various registers */\
112 stw r12,GPR12(r11); \
113 stw r9,GPR9(r11); \
114 mflr r10; \
115 stw r10,_LINK(r11); \
116 mfspr r12,SPRN_DEAR; /* save DEAR and ESR in the frame */\
117 stw r12,_DEAR(r11); /* since they may have had stuff */\
118 mfspr r9,SPRN_ESR; /* in them at the point where the */\
119 stw r9,_ESR(r11); /* exception was taken */\
120 mfspr r12,exc_level_srr0; \
121 stw r1,GPR1(r11); \
122 mfspr r9,exc_level_srr1; \
123 stw r1,0(r11); \
124 mr r1,r11; \
125 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
126 stw r0,GPR0(r11); \
127 SAVE_4GPRS(3, r11); \
128 SAVE_2GPRS(7, r11)
129
130#define CRITICAL_EXCEPTION_PROLOG \
131 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1)
132#define DEBUG_EXCEPTION_PROLOG \
133 EXC_LEVEL_EXCEPTION_PROLOG(DEBUG, SPRN_DSRR0, SPRN_DSRR1)
134#define MCHECK_EXCEPTION_PROLOG \
135 EXC_LEVEL_EXCEPTION_PROLOG(MCHECK, SPRN_MCSRR0, SPRN_MCSRR1)
136
137/*
138 * Exception vectors.
139 */
140#define START_EXCEPTION(label) \
141 .align 5; \
142label:
143
144#define FINISH_EXCEPTION(func) \
145 bl transfer_to_handler_full; \
146 .long func; \
147 .long ret_from_except_full
148
149#define EXCEPTION(n, label, hdlr, xfer) \
150 START_EXCEPTION(label); \
151 NORMAL_EXCEPTION_PROLOG; \
152 addi r3,r1,STACK_FRAME_OVERHEAD; \
153 xfer(n, hdlr)
154
155#define CRITICAL_EXCEPTION(n, label, hdlr) \
156 START_EXCEPTION(label); \
157 CRITICAL_EXCEPTION_PROLOG; \
158 addi r3,r1,STACK_FRAME_OVERHEAD; \
159 EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
160 NOCOPY, crit_transfer_to_handler, \
161 ret_from_crit_exc)
162
163#define MCHECK_EXCEPTION(n, label, hdlr) \
164 START_EXCEPTION(label); \
165 MCHECK_EXCEPTION_PROLOG; \
166 mfspr r5,SPRN_ESR; \
167 stw r5,_ESR(r11); \
168 addi r3,r1,STACK_FRAME_OVERHEAD; \
169 EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
170 NOCOPY, mcheck_transfer_to_handler, \
171 ret_from_mcheck_exc)
172
173#define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret) \
174 li r10,trap; \
175 stw r10,_TRAP(r11); \
176 lis r10,msr@h; \
177 ori r10,r10,msr@l; \
178 copyee(r10, r9); \
179 bl tfer; \
180 .long hdlr; \
181 .long ret
182
183#define COPY_EE(d, s) rlwimi d,s,0,16,16
184#define NOCOPY(d, s)
185
186#define EXC_XFER_STD(n, hdlr) \
187 EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, NOCOPY, transfer_to_handler_full, \
188 ret_from_except_full)
189
190#define EXC_XFER_LITE(n, hdlr) \
191 EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, NOCOPY, transfer_to_handler, \
192 ret_from_except)
193
194#define EXC_XFER_EE(n, hdlr) \
195 EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, COPY_EE, transfer_to_handler_full, \
196 ret_from_except_full)
197
198#define EXC_XFER_EE_LITE(n, hdlr) \
199 EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \
200 ret_from_except)
201
202/* Check for a single step debug exception while in an exception
203 * handler before state has been saved. This is to catch the case
204 * where an instruction that we are trying to single step causes
205 * an exception (eg ITLB/DTLB miss) and thus the first instruction of
206 * the exception handler generates a single step debug exception.
207 *
208 * If we get a debug trap on the first instruction of an exception handler,
209 * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
210 * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
211 * The exception handler was handling a non-critical interrupt, so it will
212 * save (and later restore) the MSR via SPRN_CSRR1, which will still have
213 * the MSR_DE bit set.
214 */
215#ifdef CONFIG_E200
216#define DEBUG_EXCEPTION \
217 START_EXCEPTION(Debug); \
218 DEBUG_EXCEPTION_PROLOG; \
219 \
220 /* \
221 * If there is a single step or branch-taken exception in an \
222 * exception entry sequence, it was probably meant to apply to \
223 * the code where the exception occurred (since exception entry \
224 * doesn't turn off DE automatically). We simulate the effect \
225 * of turning off DE on entry to an exception handler by turning \
226 * off DE in the CSRR1 value and clearing the debug status. \
227 */ \
228 mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
229 andis. r10,r10,DBSR_IC@h; \
230 beq+ 2f; \
231 \
232 lis r10,KERNELBASE@h; /* check if exception in vectors */ \
233 ori r10,r10,KERNELBASE@l; \
234 cmplw r12,r10; \
235 blt+ 2f; /* addr below exception vectors */ \
236 \
237 lis r10,Debug@h; \
238 ori r10,r10,Debug@l; \
239 cmplw r12,r10; \
240 bgt+ 2f; /* addr above exception vectors */ \
241 \
242 /* here it looks like we got an inappropriate debug exception. */ \
2431: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CDRR1 value */ \
244 lis r10,DBSR_IC@h; /* clear the IC event */ \
245 mtspr SPRN_DBSR,r10; \
246 /* restore state and get out */ \
247 lwz r10,_CCR(r11); \
248 lwz r0,GPR0(r11); \
249 lwz r1,GPR1(r11); \
250 mtcrf 0x80,r10; \
251 mtspr SPRN_DSRR0,r12; \
252 mtspr SPRN_DSRR1,r9; \
253 lwz r9,GPR9(r11); \
254 lwz r12,GPR12(r11); \
255 mtspr DEBUG_SPRG,r8; \
256 BOOKE_LOAD_EXC_LEVEL_STACK(DEBUG); /* r8 points to the debug stack */ \
257 lwz r10,GPR10-INT_FRAME_SIZE(r8); \
258 lwz r11,GPR11-INT_FRAME_SIZE(r8); \
259 mfspr r8,DEBUG_SPRG; \
260 \
261 RFDI; \
262 b .; \
263 \
264 /* continue normal handling for a critical exception... */ \
2652: mfspr r4,SPRN_DBSR; \
266 addi r3,r1,STACK_FRAME_OVERHEAD; \
267 EXC_XFER_TEMPLATE(DebugException, 0x2002, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, debug_transfer_to_handler, ret_from_debug_exc)
268#else
269#define DEBUG_EXCEPTION \
270 START_EXCEPTION(Debug); \
271 CRITICAL_EXCEPTION_PROLOG; \
272 \
273 /* \
274 * If there is a single step or branch-taken exception in an \
275 * exception entry sequence, it was probably meant to apply to \
276 * the code where the exception occurred (since exception entry \
277 * doesn't turn off DE automatically). We simulate the effect \
278 * of turning off DE on entry to an exception handler by turning \
279 * off DE in the CSRR1 value and clearing the debug status. \
280 */ \
281 mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
282 andis. r10,r10,DBSR_IC@h; \
283 beq+ 2f; \
284 \
285 lis r10,KERNELBASE@h; /* check if exception in vectors */ \
286 ori r10,r10,KERNELBASE@l; \
287 cmplw r12,r10; \
288 blt+ 2f; /* addr below exception vectors */ \
289 \
290 lis r10,Debug@h; \
291 ori r10,r10,Debug@l; \
292 cmplw r12,r10; \
293 bgt+ 2f; /* addr above exception vectors */ \
294 \
295 /* here it looks like we got an inappropriate debug exception. */ \
2961: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CSRR1 value */ \
297 lis r10,DBSR_IC@h; /* clear the IC event */ \
298 mtspr SPRN_DBSR,r10; \
299 /* restore state and get out */ \
300 lwz r10,_CCR(r11); \
301 lwz r0,GPR0(r11); \
302 lwz r1,GPR1(r11); \
303 mtcrf 0x80,r10; \
304 mtspr SPRN_CSRR0,r12; \
305 mtspr SPRN_CSRR1,r9; \
306 lwz r9,GPR9(r11); \
307 lwz r12,GPR12(r11); \
308 mtspr CRIT_SPRG,r8; \
309 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
310 lwz r10,GPR10-INT_FRAME_SIZE(r8); \
311 lwz r11,GPR11-INT_FRAME_SIZE(r8); \
312 mfspr r8,CRIT_SPRG; \
313 \
314 rfci; \
315 b .; \
316 \
317 /* continue normal handling for a critical exception... */ \
3182: mfspr r4,SPRN_DBSR; \
319 addi r3,r1,STACK_FRAME_OVERHEAD; \
320 EXC_XFER_TEMPLATE(DebugException, 0x2002, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
321#endif
322
323#define INSTRUCTION_STORAGE_EXCEPTION \
324 START_EXCEPTION(InstructionStorage) \
325 NORMAL_EXCEPTION_PROLOG; \
326 mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \
327 stw r5,_ESR(r11); \
328 mr r4,r12; /* Pass SRR0 as arg2 */ \
329 li r5,0; /* Pass zero as arg3 */ \
330 EXC_XFER_EE_LITE(0x0400, handle_page_fault)
331
332#define ALIGNMENT_EXCEPTION \
333 START_EXCEPTION(Alignment) \
334 NORMAL_EXCEPTION_PROLOG; \
335 mfspr r4,SPRN_DEAR; /* Grab the DEAR and save it */ \
336 stw r4,_DEAR(r11); \
337 addi r3,r1,STACK_FRAME_OVERHEAD; \
338 EXC_XFER_EE(0x0600, alignment_exception)
339
340#define PROGRAM_EXCEPTION \
341 START_EXCEPTION(Program) \
342 NORMAL_EXCEPTION_PROLOG; \
343 mfspr r4,SPRN_ESR; /* Grab the ESR and save it */ \
344 stw r4,_ESR(r11); \
345 addi r3,r1,STACK_FRAME_OVERHEAD; \
346 EXC_XFER_STD(0x0700, program_check_exception)
347
348#define DECREMENTER_EXCEPTION \
349 START_EXCEPTION(Decrementer) \
350 NORMAL_EXCEPTION_PROLOG; \
351 lis r0,TSR_DIS@h; /* Setup the DEC interrupt mask */ \
352 mtspr SPRN_TSR,r0; /* Clear the DEC interrupt */ \
353 addi r3,r1,STACK_FRAME_OVERHEAD; \
354 EXC_XFER_LITE(0x0900, timer_interrupt)
355
356#define FP_UNAVAILABLE_EXCEPTION \
357 START_EXCEPTION(FloatingPointUnavailable) \
358 NORMAL_EXCEPTION_PROLOG; \
359 bne load_up_fpu; /* if from user, just load it up */ \
360 addi r3,r1,STACK_FRAME_OVERHEAD; \
361 EXC_XFER_EE_LITE(0x800, kernel_fp_unavailable_exception)
362
363#endif /* __HEAD_BOOKE_H__ */
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 8d60fa99fc4b..dd86bbed7627 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/head_fsl_booke.S
3 *
4 * Kernel execution entry point code. 2 * Kernel execution entry point code.
5 * 3 *
6 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org> 4 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
@@ -316,6 +314,7 @@ skpinv: addi r6,r6,1 /* Increment */
316 */ 314 */
317 lis r2,DBCR0_IDM@h 315 lis r2,DBCR0_IDM@h
318 mtspr SPRN_DBCR0,r2 316 mtspr SPRN_DBCR0,r2
317 isync
319 /* clear any residual debug events */ 318 /* clear any residual debug events */
320 li r2,-1 319 li r2,-1
321 mtspr SPRN_DBSR,r2 320 mtspr SPRN_DBSR,r2
@@ -1002,12 +1001,15 @@ _GLOBAL(giveup_fpu)
1002_GLOBAL(abort) 1001_GLOBAL(abort)
1003 li r13,0 1002 li r13,0
1004 mtspr SPRN_DBCR0,r13 /* disable all debug events */ 1003 mtspr SPRN_DBCR0,r13 /* disable all debug events */
1004 isync
1005 mfmsr r13 1005 mfmsr r13
1006 ori r13,r13,MSR_DE@l /* Enable Debug Events */ 1006 ori r13,r13,MSR_DE@l /* Enable Debug Events */
1007 mtmsr r13 1007 mtmsr r13
1008 isync
1008 mfspr r13,SPRN_DBCR0 1009 mfspr r13,SPRN_DBCR0
1009 lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h 1010 lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h
1010 mtspr SPRN_DBCR0,r13 1011 mtspr SPRN_DBCR0,r13
1012 isync
1011 1013
1012_GLOBAL(set_context) 1014_GLOBAL(set_context)
1013 1015
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index 6160c8dbb7c5..fd8214caedee 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/iomap.c
3 *
4 * ppc64 "iomap" interface implementation. 2 * ppc64 "iomap" interface implementation.
5 * 3 *
6 * (C) Copyright 2004 Linus Torvalds 4 * (C) Copyright 2004 Linus Torvalds
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 946f3219fd29..d9a7fdef59b9 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/iommu.c
3 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation 2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
4 * 3 *
5 * Rewrite, cleanup, new allocation schemes, virtual merging: 4 * Rewrite, cleanup, new allocation schemes, virtual merging:
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index d1fffce86df9..771a59cbd213 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/irq.c
3 *
4 * Derived from arch/i386/kernel/irq.c 2 * Derived from arch/i386/kernel/irq.c
5 * Copyright (C) 1992 Linus Torvalds 3 * Copyright (C) 1992 Linus Torvalds
6 * Adapted from arch/i386 by Gary Thomas 4 * Adapted from arch/i386 by Gary Thomas
@@ -137,9 +135,8 @@ skip:
137#ifdef CONFIG_TAU_INT 135#ifdef CONFIG_TAU_INT
138 if (tau_initialized){ 136 if (tau_initialized){
139 seq_puts(p, "TAU: "); 137 seq_puts(p, "TAU: ");
140 for (j = 0; j < NR_CPUS; j++) 138 for_each_online_cpu(j)
141 if (cpu_online(j)) 139 seq_printf(p, "%10u ", tau_interrupts(j));
142 seq_printf(p, "%10u ", tau_interrupts(j));
143 seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n"); 140 seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n");
144 } 141 }
145#endif 142#endif
@@ -371,6 +368,7 @@ unsigned int real_irq_to_virt_slowpath(unsigned int real_irq)
371 return NO_IRQ; 368 return NO_IRQ;
372 369
373} 370}
371#endif /* CONFIG_PPC64 */
374 372
375#ifdef CONFIG_IRQSTACKS 373#ifdef CONFIG_IRQSTACKS
376struct thread_info *softirq_ctx[NR_CPUS]; 374struct thread_info *softirq_ctx[NR_CPUS];
@@ -394,10 +392,24 @@ void irq_ctx_init(void)
394 } 392 }
395} 393}
396 394
395static inline void do_softirq_onstack(void)
396{
397 struct thread_info *curtp, *irqtp;
398
399 curtp = current_thread_info();
400 irqtp = softirq_ctx[smp_processor_id()];
401 irqtp->task = curtp->task;
402 call_do_softirq(irqtp);
403 irqtp->task = NULL;
404}
405
406#else
407#define do_softirq_onstack() __do_softirq()
408#endif /* CONFIG_IRQSTACKS */
409
397void do_softirq(void) 410void do_softirq(void)
398{ 411{
399 unsigned long flags; 412 unsigned long flags;
400 struct thread_info *curtp, *irqtp;
401 413
402 if (in_interrupt()) 414 if (in_interrupt())
403 return; 415 return;
@@ -405,19 +417,18 @@ void do_softirq(void)
405 local_irq_save(flags); 417 local_irq_save(flags);
406 418
407 if (local_softirq_pending()) { 419 if (local_softirq_pending()) {
408 curtp = current_thread_info(); 420 account_system_vtime(current);
409 irqtp = softirq_ctx[smp_processor_id()]; 421 local_bh_disable();
410 irqtp->task = curtp->task; 422 do_softirq_onstack();
411 call_do_softirq(irqtp); 423 account_system_vtime(current);
412 irqtp->task = NULL; 424 __local_bh_enable();
413 } 425 }
414 426
415 local_irq_restore(flags); 427 local_irq_restore(flags);
416} 428}
417EXPORT_SYMBOL(do_softirq); 429EXPORT_SYMBOL(do_softirq);
418 430
419#endif /* CONFIG_IRQSTACKS */ 431#ifdef CONFIG_PPC64
420
421static int __init setup_noirqdistrib(char *str) 432static int __init setup_noirqdistrib(char *str)
422{ 433{
423 distribute_irqs = 0; 434 distribute_irqs = 0;
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index cfab48566db1..cb1fe5878e8b 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * Kernel Probes (KProbes) 2 * Kernel Probes (KProbes)
3 * arch/ppc64/kernel/kprobes.c
4 * 3 *
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -82,9 +81,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
82 81
83void __kprobes arch_remove_kprobe(struct kprobe *p) 82void __kprobes arch_remove_kprobe(struct kprobe *p)
84{ 83{
85 down(&kprobe_mutex); 84 mutex_lock(&kprobe_mutex);
86 free_insn_slot(p->ainsn.insn); 85 free_insn_slot(p->ainsn.insn);
87 up(&kprobe_mutex); 86 mutex_unlock(&kprobe_mutex);
88} 87}
89 88
90static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 89static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index 22d83d4d1af5..9feeeef5a875 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -147,15 +147,12 @@ postcore_initcall(of_bus_driver_init);
147 147
148int of_register_driver(struct of_platform_driver *drv) 148int of_register_driver(struct of_platform_driver *drv)
149{ 149{
150 int count = 0;
151
152 /* initialize common driver fields */ 150 /* initialize common driver fields */
153 drv->driver.name = drv->name; 151 drv->driver.name = drv->name;
154 drv->driver.bus = &of_platform_bus_type; 152 drv->driver.bus = &of_platform_bus_type;
155 153
156 /* register with core */ 154 /* register with core */
157 count = driver_register(&drv->driver); 155 return driver_register(&drv->driver);
158 return count ? count : 1;
159} 156}
160 157
161void of_unregister_driver(struct of_platform_driver *drv) 158void of_unregister_driver(struct of_platform_driver *drv)
diff --git a/arch/powerpc/kernel/pci_iommu.c b/arch/powerpc/kernel/pci_iommu.c
index bdf15dbbf4f0..c336f3e31cff 100644
--- a/arch/powerpc/kernel/pci_iommu.c
+++ b/arch/powerpc/kernel/pci_iommu.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/pci_iommu.c
3 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation 2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
4 * 3 *
5 * Rewrite, cleanup, new allocation schemes: 4 * Rewrite, cleanup, new allocation schemes:
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 63ecbec05202..dfa5398ab3c8 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -57,7 +57,6 @@ extern void machine_check_exception(struct pt_regs *regs);
57extern void alignment_exception(struct pt_regs *regs); 57extern void alignment_exception(struct pt_regs *regs);
58extern void program_check_exception(struct pt_regs *regs); 58extern void program_check_exception(struct pt_regs *regs);
59extern void single_step_exception(struct pt_regs *regs); 59extern void single_step_exception(struct pt_regs *regs);
60extern int pmac_newworld;
61extern int sys_sigreturn(struct pt_regs *regs); 60extern int sys_sigreturn(struct pt_regs *regs);
62 61
63EXPORT_SYMBOL(clear_pages); 62EXPORT_SYMBOL(clear_pages);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index c225cf154bfe..1770a066c217 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/process.c
3 *
4 * Derived from "arch/i386/kernel/process.c" 2 * Derived from "arch/i386/kernel/process.c"
5 * Copyright (C) 1995 Linus Torvalds 3 * Copyright (C) 1995 Linus Torvalds
6 * 4 *
@@ -47,9 +45,9 @@
47#include <asm/mmu.h> 45#include <asm/mmu.h>
48#include <asm/prom.h> 46#include <asm/prom.h>
49#include <asm/machdep.h> 47#include <asm/machdep.h>
48#include <asm/time.h>
50#ifdef CONFIG_PPC64 49#ifdef CONFIG_PPC64
51#include <asm/firmware.h> 50#include <asm/firmware.h>
52#include <asm/time.h>
53#endif 51#endif
54 52
55extern unsigned long _get_SP(void); 53extern unsigned long _get_SP(void);
@@ -330,6 +328,11 @@ struct task_struct *__switch_to(struct task_struct *prev,
330#endif 328#endif
331 329
332 local_irq_save(flags); 330 local_irq_save(flags);
331
332 account_system_vtime(current);
333 account_process_vtime(current);
334 calculate_steal_time();
335
333 last = _switch(old_thread, new_thread); 336 last = _switch(old_thread, new_thread);
334 337
335 local_irq_restore(flags); 338 local_irq_restore(flags);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 6dbd21726770..d63cd562d9d5 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -829,10 +829,6 @@ void __init unflatten_device_tree(void)
829 829
830 /* Allocate memory for the expanded device tree */ 830 /* Allocate memory for the expanded device tree */
831 mem = lmb_alloc(size + 4, __alignof__(struct device_node)); 831 mem = lmb_alloc(size + 4, __alignof__(struct device_node));
832 if (!mem) {
833 DBG("Couldn't allocate memory with lmb_alloc()!\n");
834 panic("Couldn't allocate memory with lmb_alloc()!\n");
835 }
836 mem = (unsigned long) __va(mem); 832 mem = (unsigned long) __va(mem);
837 833
838 ((u32 *)mem)[size / 4] = 0xdeadbeef; 834 ((u32 *)mem)[size / 4] = 0xdeadbeef;
diff --git a/arch/powerpc/kernel/ptrace-common.h b/arch/powerpc/kernel/ptrace-common.h
index 5ccbdbe0d5c9..c42a860c8d25 100644
--- a/arch/powerpc/kernel/ptrace-common.h
+++ b/arch/powerpc/kernel/ptrace-common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/ppc64/kernel/ptrace-common.h
3 *
4 * Copyright (c) 2002 Stephen Rothwell, IBM Coproration 2 * Copyright (c) 2002 Stephen Rothwell, IBM Coproration
5 * Extracted from ptrace.c and ptrace32.c 3 * Extracted from ptrace.c and ptrace32.c
6 * 4 *
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 7a95b8a28354..1f03fb28cc0a 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/rtas-proc.c
3 * Copyright (C) 2000 Tilmann Bitterberg 2 * Copyright (C) 2000 Tilmann Bitterberg
4 * (tilmann@bitterberg.de) 3 * (tilmann@bitterberg.de)
5 * 4 *
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 7442775ef2a1..57b539a03fa9 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/rtas_pci.c
3 *
4 * Copyright (C) 2001 Dave Engebretsen, IBM Corporation 2 * Copyright (C) 2001 Dave Engebretsen, IBM Corporation
5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM 3 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
6 * 4 *
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index be12041c0fc5..c1d62bf11f29 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -162,9 +162,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
162#if defined(CONFIG_SMP) && defined(CONFIG_PPC32) 162#if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
163 unsigned long bogosum = 0; 163 unsigned long bogosum = 0;
164 int i; 164 int i;
165 for (i = 0; i < NR_CPUS; ++i) 165 for_each_online_cpu(i)
166 if (cpu_online(i)) 166 bogosum += loops_per_jiffy;
167 bogosum += loops_per_jiffy;
168 seq_printf(m, "total bogomips\t: %lu.%02lu\n", 167 seq_printf(m, "total bogomips\t: %lu.%02lu\n",
169 bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); 168 bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
170#endif /* CONFIG_SMP && CONFIG_PPC32 */ 169#endif /* CONFIG_SMP && CONFIG_PPC32 */
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index db72a92943bf..dc2770df25b3 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -272,9 +272,8 @@ int __init ppc_init(void)
272 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); 272 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
273 273
274 /* register CPU devices */ 274 /* register CPU devices */
275 for (i = 0; i < NR_CPUS; i++) 275 for_each_cpu(i)
276 if (cpu_possible(i)) 276 register_cpu(&cpu_devices[i], i, NULL);
277 register_cpu(&cpu_devices[i], i, NULL);
278 277
279 /* call platform init */ 278 /* call platform init */
280 if (ppc_md.init != NULL) { 279 if (ppc_md.init != NULL) {
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index f96c49b03ba0..2f3fdad35594 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -497,8 +497,6 @@ void __init setup_system(void)
497#endif 497#endif
498 printk("-----------------------------------------------------\n"); 498 printk("-----------------------------------------------------\n");
499 499
500 mm_init_ppc64();
501
502 DBG(" <- setup_system()\n"); 500 DBG(" <- setup_system()\n");
503} 501}
504 502
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 4324f8a8ba24..47f910380a6a 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/ppc64/kernel/signal.c
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * 4 *
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 13595a64f013..805eaedbc308 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -541,7 +541,7 @@ int __devinit start_secondary(void *unused)
541 smp_ops->take_timebase(); 541 smp_ops->take_timebase();
542 542
543 if (system_state > SYSTEM_BOOTING) 543 if (system_state > SYSTEM_BOOTING)
544 per_cpu(last_jiffy, cpu) = get_tb(); 544 snapshot_timebase();
545 545
546 spin_lock(&call_lock); 546 spin_lock(&call_lock);
547 cpu_set(cpu, cpu_online_map); 547 cpu_set(cpu, cpu_online_map);
@@ -573,6 +573,8 @@ void __init smp_cpus_done(unsigned int max_cpus)
573 573
574 set_cpus_allowed(current, old_mask); 574 set_cpus_allowed(current, old_mask);
575 575
576 snapshot_timebases();
577
576 dump_numa_cpu_topology(); 578 dump_numa_cpu_topology();
577} 579}
578 580
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 86f7e3d154d8..4a27218a086c 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -51,6 +51,7 @@
51#include <linux/percpu.h> 51#include <linux/percpu.h>
52#include <linux/rtc.h> 52#include <linux/rtc.h>
53#include <linux/jiffies.h> 53#include <linux/jiffies.h>
54#include <linux/posix-timers.h>
54 55
55#include <asm/io.h> 56#include <asm/io.h>
56#include <asm/processor.h> 57#include <asm/processor.h>
@@ -98,6 +99,7 @@ unsigned long tb_ticks_per_jiffy;
98unsigned long tb_ticks_per_usec = 100; /* sane default */ 99unsigned long tb_ticks_per_usec = 100; /* sane default */
99EXPORT_SYMBOL(tb_ticks_per_usec); 100EXPORT_SYMBOL(tb_ticks_per_usec);
100unsigned long tb_ticks_per_sec; 101unsigned long tb_ticks_per_sec;
102EXPORT_SYMBOL(tb_ticks_per_sec); /* for cputime_t conversions */
101u64 tb_to_xs; 103u64 tb_to_xs;
102unsigned tb_to_us; 104unsigned tb_to_us;
103 105
@@ -135,6 +137,224 @@ unsigned long tb_last_stamp;
135 */ 137 */
136DEFINE_PER_CPU(unsigned long, last_jiffy); 138DEFINE_PER_CPU(unsigned long, last_jiffy);
137 139
140#ifdef CONFIG_VIRT_CPU_ACCOUNTING
141/*
142 * Factors for converting from cputime_t (timebase ticks) to
143 * jiffies, milliseconds, seconds, and clock_t (1/USER_HZ seconds).
144 * These are all stored as 0.64 fixed-point binary fractions.
145 */
146u64 __cputime_jiffies_factor;
147EXPORT_SYMBOL(__cputime_jiffies_factor);
148u64 __cputime_msec_factor;
149EXPORT_SYMBOL(__cputime_msec_factor);
150u64 __cputime_sec_factor;
151EXPORT_SYMBOL(__cputime_sec_factor);
152u64 __cputime_clockt_factor;
153EXPORT_SYMBOL(__cputime_clockt_factor);
154
155static void calc_cputime_factors(void)
156{
157 struct div_result res;
158
159 div128_by_32(HZ, 0, tb_ticks_per_sec, &res);
160 __cputime_jiffies_factor = res.result_low;
161 div128_by_32(1000, 0, tb_ticks_per_sec, &res);
162 __cputime_msec_factor = res.result_low;
163 div128_by_32(1, 0, tb_ticks_per_sec, &res);
164 __cputime_sec_factor = res.result_low;
165 div128_by_32(USER_HZ, 0, tb_ticks_per_sec, &res);
166 __cputime_clockt_factor = res.result_low;
167}
168
169/*
170 * Read the PURR on systems that have it, otherwise the timebase.
171 */
172static u64 read_purr(void)
173{
174 if (cpu_has_feature(CPU_FTR_PURR))
175 return mfspr(SPRN_PURR);
176 return mftb();
177}
178
179/*
180 * Account time for a transition between system, hard irq
181 * or soft irq state.
182 */
183void account_system_vtime(struct task_struct *tsk)
184{
185 u64 now, delta;
186 unsigned long flags;
187
188 local_irq_save(flags);
189 now = read_purr();
190 delta = now - get_paca()->startpurr;
191 get_paca()->startpurr = now;
192 if (!in_interrupt()) {
193 delta += get_paca()->system_time;
194 get_paca()->system_time = 0;
195 }
196 account_system_time(tsk, 0, delta);
197 local_irq_restore(flags);
198}
199
200/*
201 * Transfer the user and system times accumulated in the paca
202 * by the exception entry and exit code to the generic process
203 * user and system time records.
204 * Must be called with interrupts disabled.
205 */
206void account_process_vtime(struct task_struct *tsk)
207{
208 cputime_t utime;
209
210 utime = get_paca()->user_time;
211 get_paca()->user_time = 0;
212 account_user_time(tsk, utime);
213}
214
215static void account_process_time(struct pt_regs *regs)
216{
217 int cpu = smp_processor_id();
218
219 account_process_vtime(current);
220 run_local_timers();
221 if (rcu_pending(cpu))
222 rcu_check_callbacks(cpu, user_mode(regs));
223 scheduler_tick();
224 run_posix_cpu_timers(current);
225}
226
227#ifdef CONFIG_PPC_SPLPAR
228/*
229 * Stuff for accounting stolen time.
230 */
231struct cpu_purr_data {
232 int initialized; /* thread is running */
233 u64 tb0; /* timebase at origin time */
234 u64 purr0; /* PURR at origin time */
235 u64 tb; /* last TB value read */
236 u64 purr; /* last PURR value read */
237 u64 stolen; /* stolen time so far */
238 spinlock_t lock;
239};
240
241static DEFINE_PER_CPU(struct cpu_purr_data, cpu_purr_data);
242
243static void snapshot_tb_and_purr(void *data)
244{
245 struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data);
246
247 p->tb0 = mftb();
248 p->purr0 = mfspr(SPRN_PURR);
249 p->tb = p->tb0;
250 p->purr = 0;
251 wmb();
252 p->initialized = 1;
253}
254
255/*
256 * Called during boot when all cpus have come up.
257 */
258void snapshot_timebases(void)
259{
260 int cpu;
261
262 if (!cpu_has_feature(CPU_FTR_PURR))
263 return;
264 for_each_cpu(cpu)
265 spin_lock_init(&per_cpu(cpu_purr_data, cpu).lock);
266 on_each_cpu(snapshot_tb_and_purr, NULL, 0, 1);
267}
268
269void calculate_steal_time(void)
270{
271 u64 tb, purr, t0;
272 s64 stolen;
273 struct cpu_purr_data *p0, *pme, *phim;
274 int cpu;
275
276 if (!cpu_has_feature(CPU_FTR_PURR))
277 return;
278 cpu = smp_processor_id();
279 pme = &per_cpu(cpu_purr_data, cpu);
280 if (!pme->initialized)
281 return; /* this can happen in early boot */
282 p0 = &per_cpu(cpu_purr_data, cpu & ~1);
283 phim = &per_cpu(cpu_purr_data, cpu ^ 1);
284 spin_lock(&p0->lock);
285 tb = mftb();
286 purr = mfspr(SPRN_PURR) - pme->purr0;
287 if (!phim->initialized || !cpu_online(cpu ^ 1)) {
288 stolen = (tb - pme->tb) - (purr - pme->purr);
289 } else {
290 t0 = pme->tb0;
291 if (phim->tb0 < t0)
292 t0 = phim->tb0;
293 stolen = phim->tb - t0 - phim->purr - purr - p0->stolen;
294 }
295 if (stolen > 0) {
296 account_steal_time(current, stolen);
297 p0->stolen += stolen;
298 }
299 pme->tb = tb;
300 pme->purr = purr;
301 spin_unlock(&p0->lock);
302}
303
304/*
305 * Must be called before the cpu is added to the online map when
306 * a cpu is being brought up at runtime.
307 */
308static void snapshot_purr(void)
309{
310 int cpu;
311 u64 purr;
312 struct cpu_purr_data *p0, *pme, *phim;
313 unsigned long flags;
314
315 if (!cpu_has_feature(CPU_FTR_PURR))
316 return;
317 cpu = smp_processor_id();
318 pme = &per_cpu(cpu_purr_data, cpu);
319 p0 = &per_cpu(cpu_purr_data, cpu & ~1);
320 phim = &per_cpu(cpu_purr_data, cpu ^ 1);
321 spin_lock_irqsave(&p0->lock, flags);
322 pme->tb = pme->tb0 = mftb();
323 purr = mfspr(SPRN_PURR);
324 if (!phim->initialized) {
325 pme->purr = 0;
326 pme->purr0 = purr;
327 } else {
328 /* set p->purr and p->purr0 for no change in p0->stolen */
329 pme->purr = phim->tb - phim->tb0 - phim->purr - p0->stolen;
330 pme->purr0 = purr - pme->purr;
331 }
332 pme->initialized = 1;
333 spin_unlock_irqrestore(&p0->lock, flags);
334}
335
336#endif /* CONFIG_PPC_SPLPAR */
337
338#else /* ! CONFIG_VIRT_CPU_ACCOUNTING */
339#define calc_cputime_factors()
340#define account_process_time(regs) update_process_times(user_mode(regs))
341#define calculate_steal_time() do { } while (0)
342#endif
343
344#if !(defined(CONFIG_VIRT_CPU_ACCOUNTING) && defined(CONFIG_PPC_SPLPAR))
345#define snapshot_purr() do { } while (0)
346#endif
347
348/*
349 * Called when a cpu comes up after the system has finished booting,
350 * i.e. as a result of a hotplug cpu action.
351 */
352void snapshot_timebase(void)
353{
354 __get_cpu_var(last_jiffy) = get_tb();
355 snapshot_purr();
356}
357
138void __delay(unsigned long loops) 358void __delay(unsigned long loops)
139{ 359{
140 unsigned long start; 360 unsigned long start;
@@ -392,6 +612,7 @@ static void iSeries_tb_recal(void)
392 new_tb_ticks_per_jiffy, sign, tick_diff ); 612 new_tb_ticks_per_jiffy, sign, tick_diff );
393 tb_ticks_per_jiffy = new_tb_ticks_per_jiffy; 613 tb_ticks_per_jiffy = new_tb_ticks_per_jiffy;
394 tb_ticks_per_sec = new_tb_ticks_per_sec; 614 tb_ticks_per_sec = new_tb_ticks_per_sec;
615 calc_cputime_factors();
395 div128_by_32( XSEC_PER_SEC, 0, tb_ticks_per_sec, &divres ); 616 div128_by_32( XSEC_PER_SEC, 0, tb_ticks_per_sec, &divres );
396 do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; 617 do_gtod.tb_ticks_per_sec = tb_ticks_per_sec;
397 tb_to_xs = divres.result_low; 618 tb_to_xs = divres.result_low;
@@ -440,6 +661,7 @@ void timer_interrupt(struct pt_regs * regs)
440 irq_enter(); 661 irq_enter();
441 662
442 profile_tick(CPU_PROFILING, regs); 663 profile_tick(CPU_PROFILING, regs);
664 calculate_steal_time();
443 665
444#ifdef CONFIG_PPC_ISERIES 666#ifdef CONFIG_PPC_ISERIES
445 get_lppaca()->int_dword.fields.decr_int = 0; 667 get_lppaca()->int_dword.fields.decr_int = 0;
@@ -461,7 +683,7 @@ void timer_interrupt(struct pt_regs * regs)
461 * is the case. 683 * is the case.
462 */ 684 */
463 if (!cpu_is_offline(cpu)) 685 if (!cpu_is_offline(cpu))
464 update_process_times(user_mode(regs)); 686 account_process_time(regs);
465 687
466 /* 688 /*
467 * No need to check whether cpu is offline here; boot_cpuid 689 * No need to check whether cpu is offline here; boot_cpuid
@@ -518,13 +740,27 @@ void wakeup_decrementer(void)
518void __init smp_space_timers(unsigned int max_cpus) 740void __init smp_space_timers(unsigned int max_cpus)
519{ 741{
520 int i; 742 int i;
743 unsigned long half = tb_ticks_per_jiffy / 2;
521 unsigned long offset = tb_ticks_per_jiffy / max_cpus; 744 unsigned long offset = tb_ticks_per_jiffy / max_cpus;
522 unsigned long previous_tb = per_cpu(last_jiffy, boot_cpuid); 745 unsigned long previous_tb = per_cpu(last_jiffy, boot_cpuid);
523 746
524 /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */ 747 /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */
525 previous_tb -= tb_ticks_per_jiffy; 748 previous_tb -= tb_ticks_per_jiffy;
749 /*
750 * The stolen time calculation for POWER5 shared-processor LPAR
751 * systems works better if the two threads' timebase interrupts
752 * are staggered by half a jiffy with respect to each other.
753 */
526 for_each_cpu(i) { 754 for_each_cpu(i) {
527 if (i != boot_cpuid) { 755 if (i == boot_cpuid)
756 continue;
757 if (i == (boot_cpuid ^ 1))
758 per_cpu(last_jiffy, i) =
759 per_cpu(last_jiffy, boot_cpuid) - half;
760 else if (i & 1)
761 per_cpu(last_jiffy, i) =
762 per_cpu(last_jiffy, i ^ 1) + half;
763 else {
528 previous_tb += offset; 764 previous_tb += offset;
529 per_cpu(last_jiffy, i) = previous_tb; 765 per_cpu(last_jiffy, i) = previous_tb;
530 } 766 }
@@ -720,6 +956,7 @@ void __init time_init(void)
720 tb_ticks_per_sec = ppc_tb_freq; 956 tb_ticks_per_sec = ppc_tb_freq;
721 tb_ticks_per_usec = ppc_tb_freq / 1000000; 957 tb_ticks_per_usec = ppc_tb_freq / 1000000;
722 tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); 958 tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
959 calc_cputime_factors();
723 960
724 /* 961 /*
725 * Calculate the length of each tick in ns. It will not be 962 * Calculate the length of each tick in ns. It will not be
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 04f7df39ffbb..ec8370368423 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/ppc64/kernel/vdso.c
3 *
4 * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp. 2 * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org> 3 * <benh@kernel.crashing.org>
6 * 4 *
diff --git a/arch/powerpc/lib/copypage_64.S b/arch/powerpc/lib/copypage_64.S
index 40523b140109..f9837f44ac0b 100644
--- a/arch/powerpc/lib/copypage_64.S
+++ b/arch/powerpc/lib/copypage_64.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/lib/copypage.S
3 *
4 * Copyright (C) 2002 Paul Mackerras, IBM Corp. 2 * Copyright (C) 2002 Paul Mackerras, IBM Corp.
5 * 3 *
6 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/lib/copyuser_64.S b/arch/powerpc/lib/copyuser_64.S
index 6d69ef39b7df..a6b54cb97c49 100644
--- a/arch/powerpc/lib/copyuser_64.S
+++ b/arch/powerpc/lib/copyuser_64.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/lib/copyuser.S
3 *
4 * Copyright (C) 2002 Paul Mackerras, IBM Corp. 2 * Copyright (C) 2002 Paul Mackerras, IBM Corp.
5 * 3 *
6 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/lib/e2a.c b/arch/powerpc/lib/e2a.c
index d2b834887920..4b72ed8fd50e 100644
--- a/arch/powerpc/lib/e2a.c
+++ b/arch/powerpc/lib/e2a.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * arch/ppc64/lib/e2a.c
3 *
4 * EBCDIC to ASCII conversion 2 * EBCDIC to ASCII conversion
5 * 3 *
6 * This function moved here from arch/ppc64/kernel/viopath.c 4 * This function moved here from arch/powerpc/platforms/iseries/viopath.c
7 * 5 *
8 * (C) Copyright 2000-2004 IBM Corporation 6 * (C) Copyright 2000-2004 IBM Corporation
9 * 7 *
@@ -105,4 +103,14 @@ unsigned char e2a(unsigned char x)
105} 103}
106EXPORT_SYMBOL(e2a); 104EXPORT_SYMBOL(e2a);
107 105
106unsigned char* strne2a(unsigned char *dest, const unsigned char *src, size_t n)
107{
108 int i;
109
110 n = strnlen(src, n);
108 111
112 for (i = 0; i < n; i++)
113 dest[i] = e2a(src[i]);
114
115 return dest;
116}
diff --git a/arch/powerpc/lib/memcpy_64.S b/arch/powerpc/lib/memcpy_64.S
index 9ccacdf5bcb9..fd66acfd3e3e 100644
--- a/arch/powerpc/lib/memcpy_64.S
+++ b/arch/powerpc/lib/memcpy_64.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/lib/memcpy.S
3 *
4 * Copyright (C) 2002 Paul Mackerras, IBM Corp. 2 * Copyright (C) 2002 Paul Mackerras, IBM Corp.
5 * 3 *
6 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index 42c5de2c898f..31e511856dc5 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/rheap.c
3 *
4 * A Remote Heap. Remote means that we don't touch the memory that the 2 * A Remote Heap. Remote means that we don't touch the memory that the
5 * heap points to. Normal heap implementations use the memory they manage 3 * heap points to. Normal heap implementations use the memory they manage
6 * to place their list. We cannot do that because the memory we manage may 4 * to place their list. We cannot do that because the memory we manage may
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index a4815d316722..ec4adcb4bc28 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/mm/fault.c
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * 4 *
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index 12ccd7155bac..ea469eefa146 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/hashtable.S
3 *
4 * $Id: hashtable.S,v 1.6 1999/10/08 01:56:15 paulus Exp $ 2 * $Id: hashtable.S,v 1.6 1999/10/08 01:56:15 paulus Exp $
5 * 3 *
6 * PowerPC version 4 * PowerPC version
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index e9d589eefc14..89b35c181314 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -169,7 +169,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
169#ifdef CONFIG_PPC_ISERIES 169#ifdef CONFIG_PPC_ISERIES
170 if (_machine == PLATFORM_ISERIES_LPAR) 170 if (_machine == PLATFORM_ISERIES_LPAR)
171 ret = iSeries_hpte_insert(hpteg, va, 171 ret = iSeries_hpte_insert(hpteg, va,
172 __pa(vaddr), 172 paddr,
173 tmp_mode, 173 tmp_mode,
174 HPTE_V_BOLTED, 174 HPTE_V_BOLTED,
175 psize); 175 psize);
@@ -178,7 +178,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
178#ifdef CONFIG_PPC_PSERIES 178#ifdef CONFIG_PPC_PSERIES
179 if (_machine & PLATFORM_LPAR) 179 if (_machine & PLATFORM_LPAR)
180 ret = pSeries_lpar_hpte_insert(hpteg, va, 180 ret = pSeries_lpar_hpte_insert(hpteg, va,
181 virt_to_abs(paddr), 181 paddr,
182 tmp_mode, 182 tmp_mode,
183 HPTE_V_BOLTED, 183 HPTE_V_BOLTED,
184 psize); 184 psize);
@@ -186,7 +186,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
186#endif 186#endif
187#ifdef CONFIG_PPC_MULTIPLATFORM 187#ifdef CONFIG_PPC_MULTIPLATFORM
188 ret = native_hpte_insert(hpteg, va, 188 ret = native_hpte_insert(hpteg, va,
189 virt_to_abs(paddr), 189 paddr,
190 tmp_mode, HPTE_V_BOLTED, 190 tmp_mode, HPTE_V_BOLTED,
191 psize); 191 psize);
192#endif 192#endif
@@ -392,7 +392,7 @@ static unsigned long __init htab_get_table_size(void)
392#ifdef CONFIG_MEMORY_HOTPLUG 392#ifdef CONFIG_MEMORY_HOTPLUG
393void create_section_mapping(unsigned long start, unsigned long end) 393void create_section_mapping(unsigned long start, unsigned long end)
394{ 394{
395 BUG_ON(htab_bolt_mapping(start, end, start, 395 BUG_ON(htab_bolt_mapping(start, end, __pa(start),
396 _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX, 396 _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX,
397 mmu_linear_psize)); 397 mmu_linear_psize));
398} 398}
@@ -422,7 +422,7 @@ void __init htab_initialize(void)
422 422
423 htab_hash_mask = pteg_count - 1; 423 htab_hash_mask = pteg_count - 1;
424 424
425 if (platform_is_lpar()) { 425 if (firmware_has_feature(FW_FEATURE_LPAR)) {
426 /* Using a hypervisor which owns the htab */ 426 /* Using a hypervisor which owns the htab */
427 htab_address = NULL; 427 htab_address = NULL;
428 _SDR1 = 0; 428 _SDR1 = 0;
@@ -431,7 +431,6 @@ void __init htab_initialize(void)
431 * the absolute address space. 431 * the absolute address space.
432 */ 432 */
433 table = lmb_alloc(htab_size_bytes, htab_size_bytes); 433 table = lmb_alloc(htab_size_bytes, htab_size_bytes);
434 BUG_ON(table == 0);
435 434
436 DBG("Hash table allocated at %lx, size: %lx\n", table, 435 DBG("Hash table allocated at %lx, size: %lx\n", table,
437 htab_size_bytes); 436 htab_size_bytes);
@@ -474,21 +473,22 @@ void __init htab_initialize(void)
474 473
475 if (dart_tablebase != 0 && dart_tablebase >= base 474 if (dart_tablebase != 0 && dart_tablebase >= base
476 && dart_tablebase < (base + size)) { 475 && dart_tablebase < (base + size)) {
476 unsigned long dart_table_end = dart_tablebase + 16 * MB;
477 if (base != dart_tablebase) 477 if (base != dart_tablebase)
478 BUG_ON(htab_bolt_mapping(base, dart_tablebase, 478 BUG_ON(htab_bolt_mapping(base, dart_tablebase,
479 base, mode_rw, 479 __pa(base), mode_rw,
480 mmu_linear_psize)); 480 mmu_linear_psize));
481 if ((base + size) > (dart_tablebase + 16*MB)) 481 if ((base + size) > dart_table_end)
482 BUG_ON(htab_bolt_mapping(dart_tablebase+16*MB, 482 BUG_ON(htab_bolt_mapping(dart_tablebase+16*MB,
483 base + size, 483 base + size,
484 dart_tablebase+16*MB, 484 __pa(dart_table_end),
485 mode_rw, 485 mode_rw,
486 mmu_linear_psize)); 486 mmu_linear_psize));
487 continue; 487 continue;
488 } 488 }
489#endif /* CONFIG_U3_DART */ 489#endif /* CONFIG_U3_DART */
490 BUG_ON(htab_bolt_mapping(base, base + size, base, 490 BUG_ON(htab_bolt_mapping(base, base + size, __pa(base),
491 mode_rw, mmu_linear_psize)); 491 mode_rw, mmu_linear_psize));
492 } 492 }
493 493
494 /* 494 /*
@@ -505,8 +505,8 @@ void __init htab_initialize(void)
505 if (base + size >= tce_alloc_start) 505 if (base + size >= tce_alloc_start)
506 tce_alloc_start = base + size + 1; 506 tce_alloc_start = base + size + 1;
507 507
508 BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end, 508 BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end,
509 tce_alloc_start, mode_rw, 509 __pa(tce_alloc_start), mode_rw,
510 mmu_linear_psize)); 510 mmu_linear_psize));
511 } 511 }
512 512
@@ -517,7 +517,7 @@ void __init htab_initialize(void)
517 517
518void htab_initialize_secondary(void) 518void htab_initialize_secondary(void)
519{ 519{
520 if (!platform_is_lpar()) 520 if (!firmware_has_feature(FW_FEATURE_LPAR))
521 mtspr(SPRN_SDR1, _SDR1); 521 mtspr(SPRN_SDR1, _SDR1);
522} 522}
523 523
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index bacb71c89811..babebd15bdc4 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -84,54 +84,6 @@
84/* max amount of RAM to use */ 84/* max amount of RAM to use */
85unsigned long __max_memory; 85unsigned long __max_memory;
86 86
87/* info on what we think the IO hole is */
88unsigned long io_hole_start;
89unsigned long io_hole_size;
90
91/*
92 * Do very early mm setup.
93 */
94void __init mm_init_ppc64(void)
95{
96#ifndef CONFIG_PPC_ISERIES
97 unsigned long i;
98#endif
99
100 ppc64_boot_msg(0x100, "MM Init");
101
102 /* This is the story of the IO hole... please, keep seated,
103 * unfortunately, we are out of oxygen masks at the moment.
104 * So we need some rough way to tell where your big IO hole
105 * is. On pmac, it's between 2G and 4G, on POWER3, it's around
106 * that area as well, on POWER4 we don't have one, etc...
107 * We need that as a "hint" when sizing the TCE table on POWER3
108 * So far, the simplest way that seem work well enough for us it
109 * to just assume that the first discontinuity in our physical
110 * RAM layout is the IO hole. That may not be correct in the future
111 * (and isn't on iSeries but then we don't care ;)
112 */
113
114#ifndef CONFIG_PPC_ISERIES
115 for (i = 1; i < lmb.memory.cnt; i++) {
116 unsigned long base, prevbase, prevsize;
117
118 prevbase = lmb.memory.region[i-1].base;
119 prevsize = lmb.memory.region[i-1].size;
120 base = lmb.memory.region[i].base;
121 if (base > (prevbase + prevsize)) {
122 io_hole_start = prevbase + prevsize;
123 io_hole_size = base - (prevbase + prevsize);
124 break;
125 }
126 }
127#endif /* CONFIG_PPC_ISERIES */
128 if (io_hole_start)
129 printk("IO Hole assumed to be %lx -> %lx\n",
130 io_hole_start, io_hole_start + io_hole_size - 1);
131
132 ppc64_boot_msg(0x100, "MM Init Done");
133}
134
135void free_initmem(void) 87void free_initmem(void)
136{ 88{
137 unsigned long addr; 89 unsigned long addr;
diff --git a/arch/powerpc/mm/lmb.c b/arch/powerpc/mm/lmb.c
index bbe3eac918e8..417d58518558 100644
--- a/arch/powerpc/mm/lmb.c
+++ b/arch/powerpc/mm/lmb.c
@@ -31,6 +31,8 @@
31#define DBG(fmt...) 31#define DBG(fmt...)
32#endif 32#endif
33 33
34#define LMB_ALLOC_ANYWHERE 0
35
34struct lmb lmb; 36struct lmb lmb;
35 37
36void lmb_dump_all(void) 38void lmb_dump_all(void)
@@ -226,6 +228,20 @@ unsigned long __init lmb_alloc(unsigned long size, unsigned long align)
226unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align, 228unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align,
227 unsigned long max_addr) 229 unsigned long max_addr)
228{ 230{
231 unsigned long alloc;
232
233 alloc = __lmb_alloc_base(size, align, max_addr);
234
235 if (alloc == 0)
236 panic("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
237 size, max_addr);
238
239 return alloc;
240}
241
242unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
243 unsigned long max_addr)
244{
229 long i, j; 245 long i, j;
230 unsigned long base = 0; 246 unsigned long base = 0;
231 247
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 454cac01d8cc..badac10d700c 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -125,7 +125,7 @@ int __devinit add_memory(u64 start, u64 size)
125 nid = hot_add_scn_to_nid(start); 125 nid = hot_add_scn_to_nid(start);
126 pgdata = NODE_DATA(nid); 126 pgdata = NODE_DATA(nid);
127 127
128 start = __va(start); 128 start = (unsigned long)__va(start);
129 create_section_mapping(start, start + size); 129 create_section_mapping(start, start + size);
130 130
131 /* this should work for most non-highmem platforms */ 131 /* this should work for most non-highmem platforms */
@@ -249,7 +249,6 @@ void __init do_init_bootmem(void)
249 bootmap_pages = bootmem_bootmap_pages(total_pages); 249 bootmap_pages = bootmem_bootmap_pages(total_pages);
250 250
251 start = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE); 251 start = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
252 BUG_ON(!start);
253 252
254 boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages); 253 boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages);
255 254
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
index fe65f522aff3..972a8e884b9a 100644
--- a/arch/powerpc/mm/mmap.c
+++ b/arch/powerpc/mm/mmap.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/ppc64/mm/mmap.c
3 *
4 * flexible mmap layout support 2 * flexible mmap layout support
5 * 3 *
6 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. 4 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 2863a912bcd0..e89b22aa539e 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -129,10 +129,12 @@ void __init get_region(unsigned int nid, unsigned long *start_pfn,
129 *start_pfn = 0; 129 *start_pfn = 0;
130} 130}
131 131
132static inline void map_cpu_to_node(int cpu, int node) 132static void __cpuinit map_cpu_to_node(int cpu, int node)
133{ 133{
134 numa_cpu_lookup_table[cpu] = node; 134 numa_cpu_lookup_table[cpu] = node;
135 135
136 dbg("adding cpu %d to node %d\n", cpu, node);
137
136 if (!(cpu_isset(cpu, numa_cpumask_lookup_table[node]))) 138 if (!(cpu_isset(cpu, numa_cpumask_lookup_table[node])))
137 cpu_set(cpu, numa_cpumask_lookup_table[node]); 139 cpu_set(cpu, numa_cpumask_lookup_table[node]);
138} 140}
@@ -153,7 +155,7 @@ static void unmap_cpu_from_node(unsigned long cpu)
153} 155}
154#endif /* CONFIG_HOTPLUG_CPU */ 156#endif /* CONFIG_HOTPLUG_CPU */
155 157
156static struct device_node *find_cpu_node(unsigned int cpu) 158static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
157{ 159{
158 unsigned int hw_cpuid = get_hard_smp_processor_id(cpu); 160 unsigned int hw_cpuid = get_hard_smp_processor_id(cpu);
159 struct device_node *cpu_node = NULL; 161 struct device_node *cpu_node = NULL;
@@ -189,23 +191,29 @@ static int *of_get_associativity(struct device_node *dev)
189 return (unsigned int *)get_property(dev, "ibm,associativity", NULL); 191 return (unsigned int *)get_property(dev, "ibm,associativity", NULL);
190} 192}
191 193
192static int of_node_numa_domain(struct device_node *device) 194/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
195 * info is found.
196 */
197static int of_node_to_nid(struct device_node *device)
193{ 198{
194 int numa_domain; 199 int nid = -1;
195 unsigned int *tmp; 200 unsigned int *tmp;
196 201
197 if (min_common_depth == -1) 202 if (min_common_depth == -1)
198 return 0; 203 goto out;
199 204
200 tmp = of_get_associativity(device); 205 tmp = of_get_associativity(device);
201 if (tmp && (tmp[0] >= min_common_depth)) { 206 if (!tmp)
202 numa_domain = tmp[min_common_depth]; 207 goto out;
203 } else { 208
204 dbg("WARNING: no NUMA information for %s\n", 209 if (tmp[0] >= min_common_depth)
205 device->full_name); 210 nid = tmp[min_common_depth];
206 numa_domain = 0; 211
207 } 212 /* POWER4 LPAR uses 0xffff as invalid node */
208 return numa_domain; 213 if (nid == 0xffff || nid >= MAX_NUMNODES)
214 nid = -1;
215out:
216 return nid;
209} 217}
210 218
211/* 219/*
@@ -246,8 +254,7 @@ static int __init find_min_common_depth(void)
246 if ((len >= 1) && ref_points) { 254 if ((len >= 1) && ref_points) {
247 depth = ref_points[1]; 255 depth = ref_points[1];
248 } else { 256 } else {
249 dbg("WARNING: could not find NUMA " 257 dbg("NUMA: ibm,associativity-reference-points not found.\n");
250 "associativity reference point\n");
251 depth = -1; 258 depth = -1;
252 } 259 }
253 of_node_put(rtas_root); 260 of_node_put(rtas_root);
@@ -283,9 +290,9 @@ static unsigned long __devinit read_n_cells(int n, unsigned int **buf)
283 * Figure out to which domain a cpu belongs and stick it there. 290 * Figure out to which domain a cpu belongs and stick it there.
284 * Return the id of the domain used. 291 * Return the id of the domain used.
285 */ 292 */
286static int numa_setup_cpu(unsigned long lcpu) 293static int __cpuinit numa_setup_cpu(unsigned long lcpu)
287{ 294{
288 int numa_domain = 0; 295 int nid = 0;
289 struct device_node *cpu = find_cpu_node(lcpu); 296 struct device_node *cpu = find_cpu_node(lcpu);
290 297
291 if (!cpu) { 298 if (!cpu) {
@@ -293,27 +300,16 @@ static int numa_setup_cpu(unsigned long lcpu)
293 goto out; 300 goto out;
294 } 301 }
295 302
296 numa_domain = of_node_numa_domain(cpu); 303 nid = of_node_to_nid(cpu);
297 304
298 if (numa_domain >= num_online_nodes()) { 305 if (nid < 0 || !node_online(nid))
299 /* 306 nid = any_online_node(NODE_MASK_ALL);
300 * POWER4 LPAR uses 0xffff as invalid node,
301 * dont warn in this case.
302 */
303 if (numa_domain != 0xffff)
304 printk(KERN_ERR "WARNING: cpu %ld "
305 "maps to invalid NUMA node %d\n",
306 lcpu, numa_domain);
307 numa_domain = 0;
308 }
309out: 307out:
310 node_set_online(numa_domain); 308 map_cpu_to_node(lcpu, nid);
311
312 map_cpu_to_node(lcpu, numa_domain);
313 309
314 of_node_put(cpu); 310 of_node_put(cpu);
315 311
316 return numa_domain; 312 return nid;
317} 313}
318 314
319static int cpu_numa_callback(struct notifier_block *nfb, 315static int cpu_numa_callback(struct notifier_block *nfb,
@@ -325,10 +321,7 @@ static int cpu_numa_callback(struct notifier_block *nfb,
325 321
326 switch (action) { 322 switch (action) {
327 case CPU_UP_PREPARE: 323 case CPU_UP_PREPARE:
328 if (min_common_depth == -1 || !numa_enabled) 324 numa_setup_cpu(lcpu);
329 map_cpu_to_node(lcpu, 0);
330 else
331 numa_setup_cpu(lcpu);
332 ret = NOTIFY_OK; 325 ret = NOTIFY_OK;
333 break; 326 break;
334#ifdef CONFIG_HOTPLUG_CPU 327#ifdef CONFIG_HOTPLUG_CPU
@@ -375,7 +368,7 @@ static int __init parse_numa_properties(void)
375{ 368{
376 struct device_node *cpu = NULL; 369 struct device_node *cpu = NULL;
377 struct device_node *memory = NULL; 370 struct device_node *memory = NULL;
378 int max_domain; 371 int default_nid = 0;
379 unsigned long i; 372 unsigned long i;
380 373
381 if (numa_enabled == 0) { 374 if (numa_enabled == 0) {
@@ -385,32 +378,32 @@ static int __init parse_numa_properties(void)
385 378
386 min_common_depth = find_min_common_depth(); 379 min_common_depth = find_min_common_depth();
387 380
388 dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
389 if (min_common_depth < 0) 381 if (min_common_depth < 0)
390 return min_common_depth; 382 return min_common_depth;
391 383
392 max_domain = numa_setup_cpu(boot_cpuid); 384 dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
393 385
394 /* 386 /*
395 * Even though we connect cpus to numa domains later in SMP init, 387 * Even though we connect cpus to numa domains later in SMP
396 * we need to know the maximum node id now. This is because each 388 * init, we need to know the node ids now. This is because
397 * node id must have NODE_DATA etc backing it. 389 * each node to be onlined must have NODE_DATA etc backing it.
398 * As a result of hotplug we could still have cpus appear later on
399 * with larger node ids. In that case we force the cpu into node 0.
400 */ 390 */
401 for_each_cpu(i) { 391 for_each_present_cpu(i) {
402 int numa_domain; 392 int nid;
403 393
404 cpu = find_cpu_node(i); 394 cpu = find_cpu_node(i);
395 BUG_ON(!cpu);
396 nid = of_node_to_nid(cpu);
397 of_node_put(cpu);
405 398
406 if (cpu) { 399 /*
407 numa_domain = of_node_numa_domain(cpu); 400 * Don't fall back to default_nid yet -- we will plug
408 of_node_put(cpu); 401 * cpus into nodes once the memory scan has discovered
409 402 * the topology.
410 if (numa_domain < MAX_NUMNODES && 403 */
411 max_domain < numa_domain) 404 if (nid < 0)
412 max_domain = numa_domain; 405 continue;
413 } 406 node_set_online(nid);
414 } 407 }
415 408
416 get_n_mem_cells(&n_mem_addr_cells, &n_mem_size_cells); 409 get_n_mem_cells(&n_mem_addr_cells, &n_mem_size_cells);
@@ -418,7 +411,7 @@ static int __init parse_numa_properties(void)
418 while ((memory = of_find_node_by_type(memory, "memory")) != NULL) { 411 while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
419 unsigned long start; 412 unsigned long start;
420 unsigned long size; 413 unsigned long size;
421 int numa_domain; 414 int nid;
422 int ranges; 415 int ranges;
423 unsigned int *memcell_buf; 416 unsigned int *memcell_buf;
424 unsigned int len; 417 unsigned int len;
@@ -439,18 +432,15 @@ new_range:
439 start = read_n_cells(n_mem_addr_cells, &memcell_buf); 432 start = read_n_cells(n_mem_addr_cells, &memcell_buf);
440 size = read_n_cells(n_mem_size_cells, &memcell_buf); 433 size = read_n_cells(n_mem_size_cells, &memcell_buf);
441 434
442 numa_domain = of_node_numa_domain(memory); 435 /*
443 436 * Assumption: either all memory nodes or none will
444 if (numa_domain >= MAX_NUMNODES) { 437 * have associativity properties. If none, then
445 if (numa_domain != 0xffff) 438 * everything goes to default_nid.
446 printk(KERN_ERR "WARNING: memory at %lx maps " 439 */
447 "to invalid NUMA node %d\n", start, 440 nid = of_node_to_nid(memory);
448 numa_domain); 441 if (nid < 0)
449 numa_domain = 0; 442 nid = default_nid;
450 } 443 node_set_online(nid);
451
452 if (max_domain < numa_domain)
453 max_domain = numa_domain;
454 444
455 if (!(size = numa_enforce_memory_limit(start, size))) { 445 if (!(size = numa_enforce_memory_limit(start, size))) {
456 if (--ranges) 446 if (--ranges)
@@ -459,16 +449,13 @@ new_range:
459 continue; 449 continue;
460 } 450 }
461 451
462 add_region(numa_domain, start >> PAGE_SHIFT, 452 add_region(nid, start >> PAGE_SHIFT,
463 size >> PAGE_SHIFT); 453 size >> PAGE_SHIFT);
464 454
465 if (--ranges) 455 if (--ranges)
466 goto new_range; 456 goto new_range;
467 } 457 }
468 458
469 for (i = 0; i <= max_domain; i++)
470 node_set_online(i);
471
472 return 0; 459 return 0;
473} 460}
474 461
@@ -483,7 +470,6 @@ static void __init setup_nonnuma(void)
483 printk(KERN_INFO "Memory hole size: %ldMB\n", 470 printk(KERN_INFO "Memory hole size: %ldMB\n",
484 (top_of_ram - total_ram) >> 20); 471 (top_of_ram - total_ram) >> 20);
485 472
486 map_cpu_to_node(boot_cpuid, 0);
487 for (i = 0; i < lmb.memory.cnt; ++i) 473 for (i = 0; i < lmb.memory.cnt; ++i)
488 add_region(0, lmb.memory.region[i].base >> PAGE_SHIFT, 474 add_region(0, lmb.memory.region[i].base >> PAGE_SHIFT,
489 lmb_size_pages(&lmb.memory, i)); 475 lmb_size_pages(&lmb.memory, i));
@@ -570,11 +556,11 @@ static void __init *careful_allocation(int nid, unsigned long size,
570 unsigned long end_pfn) 556 unsigned long end_pfn)
571{ 557{
572 int new_nid; 558 int new_nid;
573 unsigned long ret = lmb_alloc_base(size, align, end_pfn << PAGE_SHIFT); 559 unsigned long ret = __lmb_alloc_base(size, align, end_pfn << PAGE_SHIFT);
574 560
575 /* retry over all memory */ 561 /* retry over all memory */
576 if (!ret) 562 if (!ret)
577 ret = lmb_alloc_base(size, align, lmb_end_of_DRAM()); 563 ret = __lmb_alloc_base(size, align, lmb_end_of_DRAM());
578 564
579 if (!ret) 565 if (!ret)
580 panic("numa.c: cannot allocate %lu bytes on node %d", 566 panic("numa.c: cannot allocate %lu bytes on node %d",
@@ -620,6 +606,8 @@ void __init do_init_bootmem(void)
620 dump_numa_memory_topology(); 606 dump_numa_memory_topology();
621 607
622 register_cpu_notifier(&ppc64_numa_nb); 608 register_cpu_notifier(&ppc64_numa_nb);
609 cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
610 (void *)(unsigned long)boot_cpuid);
623 611
624 for_each_online_node(nid) { 612 for_each_online_node(nid) {
625 unsigned long start_pfn, end_pfn, pages_present; 613 unsigned long start_pfn, end_pfn, pages_present;
@@ -767,10 +755,10 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
767{ 755{
768 struct device_node *memory = NULL; 756 struct device_node *memory = NULL;
769 nodemask_t nodes; 757 nodemask_t nodes;
770 int numa_domain = 0; 758 int default_nid = any_online_node(NODE_MASK_ALL);
771 759
772 if (!numa_enabled || (min_common_depth < 0)) 760 if (!numa_enabled || (min_common_depth < 0))
773 return numa_domain; 761 return default_nid;
774 762
775 while ((memory = of_find_node_by_type(memory, "memory")) != NULL) { 763 while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
776 unsigned long start, size; 764 unsigned long start, size;
@@ -787,15 +775,15 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
787ha_new_range: 775ha_new_range:
788 start = read_n_cells(n_mem_addr_cells, &memcell_buf); 776 start = read_n_cells(n_mem_addr_cells, &memcell_buf);
789 size = read_n_cells(n_mem_size_cells, &memcell_buf); 777 size = read_n_cells(n_mem_size_cells, &memcell_buf);
790 numa_domain = of_node_numa_domain(memory); 778 nid = of_node_to_nid(memory);
791 779
792 /* Domains not present at boot default to 0 */ 780 /* Domains not present at boot default to 0 */
793 if (!node_online(numa_domain)) 781 if (nid < 0 || !node_online(nid))
794 numa_domain = any_online_node(NODE_MASK_ALL); 782 nid = default_nid;
795 783
796 if ((scn_addr >= start) && (scn_addr < (start + size))) { 784 if ((scn_addr >= start) && (scn_addr < (start + size))) {
797 of_node_put(memory); 785 of_node_put(memory);
798 goto got_numa_domain; 786 goto got_nid;
799 } 787 }
800 788
801 if (--ranges) /* process all ranges in cell */ 789 if (--ranges) /* process all ranges in cell */
@@ -804,12 +792,12 @@ ha_new_range:
804 BUG(); /* section address should be found above */ 792 BUG(); /* section address should be found above */
805 793
806 /* Temporary code to ensure that returned node is not empty */ 794 /* Temporary code to ensure that returned node is not empty */
807got_numa_domain: 795got_nid:
808 nodes_setall(nodes); 796 nodes_setall(nodes);
809 while (NODE_DATA(numa_domain)->node_spanned_pages == 0) { 797 while (NODE_DATA(nid)->node_spanned_pages == 0) {
810 node_clear(numa_domain, nodes); 798 node_clear(nid, nodes);
811 numa_domain = any_online_node(nodes); 799 nid = any_online_node(nodes);
812 } 800 }
813 return numa_domain; 801 return nid;
814} 802}
815#endif /* CONFIG_MEMORY_HOTPLUG */ 803#endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S
index d1acee38f163..abfaabf667bf 100644
--- a/arch/powerpc/mm/slb_low.S
+++ b/arch/powerpc/mm/slb_low.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/mm/slb_low.S
3 *
4 * Low-level SLB routines 2 * Low-level SLB routines
5 * 3 *
6 * Copyright (C) 2004 David Gibson <dwg@au.ibm.com>, IBM 4 * Copyright (C) 2004 David Gibson <dwg@au.ibm.com>, IBM
diff --git a/arch/powerpc/mm/stab.c b/arch/powerpc/mm/stab.c
index 82e4951826bc..91d25fb27f89 100644
--- a/arch/powerpc/mm/stab.c
+++ b/arch/powerpc/mm/stab.c
@@ -247,10 +247,6 @@ void stabs_alloc(void)
247 247
248 newstab = lmb_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE, 248 newstab = lmb_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE,
249 1<<SID_SHIFT); 249 1<<SID_SHIFT);
250 if (! newstab)
251 panic("Unable to allocate segment table for CPU %d.\n",
252 cpu);
253
254 newstab = (unsigned long)__va(newstab); 250 newstab = (unsigned long)__va(newstab);
255 251
256 memset((void *)newstab, 0, HW_PAGE_SIZE); 252 memset((void *)newstab, 0, HW_PAGE_SIZE);
diff --git a/arch/powerpc/mm/tlb_64.c b/arch/powerpc/mm/tlb_64.c
index bb3afb6e6317..f734b11566c2 100644
--- a/arch/powerpc/mm/tlb_64.c
+++ b/arch/powerpc/mm/tlb_64.c
@@ -36,7 +36,7 @@
36DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); 36DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
37 37
38/* This is declared as we are using the more or less generic 38/* This is declared as we are using the more or less generic
39 * include/asm-ppc64/tlb.h file -- tgall 39 * include/asm-powerpc/tlb.h file -- tgall
40 */ 40 */
41DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 41DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
42DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur); 42DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
diff --git a/arch/powerpc/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c
index 659a021da0c7..4b06e53eb9b4 100644
--- a/arch/powerpc/oprofile/op_model_power4.c
+++ b/arch/powerpc/oprofile/op_model_power4.c
@@ -10,6 +10,7 @@
10#include <linux/oprofile.h> 10#include <linux/oprofile.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/smp.h> 12#include <linux/smp.h>
13#include <asm/firmware.h>
13#include <asm/ptrace.h> 14#include <asm/ptrace.h>
14#include <asm/system.h> 15#include <asm/system.h>
15#include <asm/processor.h> 16#include <asm/processor.h>
@@ -232,7 +233,7 @@ static unsigned long get_pc(struct pt_regs *regs)
232 mmcra = mfspr(SPRN_MMCRA); 233 mmcra = mfspr(SPRN_MMCRA);
233 234
234 /* Were we in the hypervisor? */ 235 /* Were we in the hypervisor? */
235 if (platform_is_lpar() && (mmcra & MMCRA_SIHV)) 236 if (firmware_has_feature(FW_FEATURE_LPAR) && (mmcra & MMCRA_SIHV))
236 /* function descriptor madness */ 237 /* function descriptor madness */
237 return *((unsigned long *)hypervisor_bucket); 238 return *((unsigned long *)hypervisor_bucket);
238 239
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
index 9d8b28ef3343..5c72367441a8 100644
--- a/arch/powerpc/platforms/83xx/Makefile
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -1,4 +1,6 @@
1# 1#
2# Makefile for the PowerPC 83xx linux kernel. 2# Makefile for the PowerPC 83xx linux kernel.
3# 3#
4obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o pci.o 4obj-y := misc.o
5obj-$(CONFIG_PCI) += pci.o
6obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o
diff --git a/arch/powerpc/platforms/83xx/misc.c b/arch/powerpc/platforms/83xx/misc.c
new file mode 100644
index 000000000000..1455bcef4892
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/misc.c
@@ -0,0 +1,55 @@
1/*
2 * misc setup functions for MPC83xx
3 *
4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/stddef.h>
14#include <linux/kernel.h>
15
16#include <asm/io.h>
17#include <asm/hw_irq.h>
18#include <sysdev/fsl_soc.h>
19
20#include "mpc83xx.h"
21
22void mpc83xx_restart(char *cmd)
23{
24#define RST_OFFSET 0x00000900
25#define RST_PROT_REG 0x00000018
26#define RST_CTRL_REG 0x0000001c
27 __be32 __iomem *reg;
28
29 /* map reset register space */
30 reg = ioremap(get_immrbase() + 0x900, 0xff);
31
32 local_irq_disable();
33
34 /* enable software reset "RSTE" */
35 out_be32(reg + (RST_PROT_REG >> 2), 0x52535445);
36
37 /* set software hard reset */
38 out_be32(reg + (RST_CTRL_REG >> 2), 0x2);
39 for (;;) ;
40}
41
42long __init mpc83xx_time_init(void)
43{
44#define SPCR_OFFSET 0x00000110
45#define SPCR_TBEN 0x00400000
46 __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
47 __be32 tmp;
48
49 tmp = in_be32(spcr);
50 out_be32(spcr, tmp | SPCR_TBEN);
51
52 iounmap(spcr);
53
54 return 0;
55}
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/powerpc/platforms/83xx/mpc834x_sys.c
index 2098dd05a773..7c18b4cd5db4 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c
@@ -24,22 +24,15 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/seq_file.h> 25#include <linux/seq_file.h>
26#include <linux/root_dev.h> 26#include <linux/root_dev.h>
27#include <linux/module.h>
28#include <linux/fsl_devices.h>
29 27
30#include <asm/system.h> 28#include <asm/system.h>
31#include <asm/pgtable.h>
32#include <asm/page.h>
33#include <asm/atomic.h> 29#include <asm/atomic.h>
34#include <asm/time.h> 30#include <asm/time.h>
35#include <asm/io.h> 31#include <asm/io.h>
36#include <asm/machdep.h> 32#include <asm/machdep.h>
37#include <asm/ipic.h> 33#include <asm/ipic.h>
38#include <asm/bootinfo.h> 34#include <asm/bootinfo.h>
39#include <asm/pci-bridge.h>
40#include <asm/mpc83xx.h>
41#include <asm/irq.h> 35#include <asm/irq.h>
42#include <mm/mmu_decl.h>
43#include <asm/prom.h> 36#include <asm/prom.h>
44#include <asm/udbg.h> 37#include <asm/udbg.h>
45#include <sysdev/fsl_soc.h> 38#include <sysdev/fsl_soc.h>
@@ -52,8 +45,6 @@ unsigned long isa_mem_base = 0;
52#endif 45#endif
53 46
54#ifdef CONFIG_PCI 47#ifdef CONFIG_PCI
55extern int mpc83xx_pci2_busno;
56
57static int 48static int
58mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin) 49mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
59{ 50{
@@ -78,26 +69,14 @@ mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
78 const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4; 69 const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4;
79 return PCI_IRQ_TABLE_LOOKUP; 70 return PCI_IRQ_TABLE_LOOKUP;
80} 71}
81 72#endif /* CONFIG_PCI */
82static int
83mpc83xx_exclude_device(u_char bus, u_char devfn)
84{
85 if (bus == 0 && PCI_SLOT(devfn) == 0)
86 return PCIBIOS_DEVICE_NOT_FOUND;
87 if (mpc83xx_pci2_busno)
88 if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0)
89 return PCIBIOS_DEVICE_NOT_FOUND;
90 return PCIBIOS_SUCCESSFUL;
91}
92#endif /* CONFIG_PCI */
93 73
94/* ************************************************************************ 74/* ************************************************************************
95 * 75 *
96 * Setup the architecture 76 * Setup the architecture
97 * 77 *
98 */ 78 */
99static void __init 79static void __init mpc834x_sys_setup_arch(void)
100mpc834x_sys_setup_arch(void)
101{ 80{
102 struct device_node *np; 81 struct device_node *np;
103 82
@@ -106,14 +85,14 @@ mpc834x_sys_setup_arch(void)
106 85
107 np = of_find_node_by_type(NULL, "cpu"); 86 np = of_find_node_by_type(NULL, "cpu");
108 if (np != 0) { 87 if (np != 0) {
109 unsigned int *fp = (int *) get_property(np, "clock-frequency", NULL); 88 unsigned int *fp =
89 (int *)get_property(np, "clock-frequency", NULL);
110 if (fp != 0) 90 if (fp != 0)
111 loops_per_jiffy = *fp / HZ; 91 loops_per_jiffy = *fp / HZ;
112 else 92 else
113 loops_per_jiffy = 50000000 / HZ; 93 loops_per_jiffy = 50000000 / HZ;
114 of_node_put(np); 94 of_node_put(np);
115 } 95 }
116
117#ifdef CONFIG_PCI 96#ifdef CONFIG_PCI
118 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 97 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
119 add_bridge(np); 98 add_bridge(np);
@@ -124,14 +103,13 @@ mpc834x_sys_setup_arch(void)
124#endif 103#endif
125 104
126#ifdef CONFIG_ROOT_NFS 105#ifdef CONFIG_ROOT_NFS
127 ROOT_DEV = Root_NFS; 106 ROOT_DEV = Root_NFS;
128#else 107#else
129 ROOT_DEV = Root_HDA1; 108 ROOT_DEV = Root_HDA1;
130#endif 109#endif
131} 110}
132 111
133void __init 112void __init mpc834x_sys_init_IRQ(void)
134mpc834x_sys_init_IRQ(void)
135{ 113{
136 u8 senses[8] = { 114 u8 senses[8] = {
137 0, /* EXT 0 */ 115 0, /* EXT 0 */
@@ -160,64 +138,27 @@ mpc834x_sys_init_IRQ(void)
160} 138}
161 139
162#if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374) 140#if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
163extern ulong ds1374_get_rtc_time(void); 141extern ulong ds1374_get_rtc_time(void);
164extern int ds1374_set_rtc_time(ulong); 142extern int ds1374_set_rtc_time(ulong);
165 143
166static int __init 144static int __init mpc834x_rtc_hookup(void)
167mpc834x_rtc_hookup(void)
168{ 145{
169 struct timespec tv; 146 struct timespec tv;
170 147
171 ppc_md.get_rtc_time = ds1374_get_rtc_time; 148 ppc_md.get_rtc_time = ds1374_get_rtc_time;
172 ppc_md.set_rtc_time = ds1374_set_rtc_time; 149 ppc_md.set_rtc_time = ds1374_set_rtc_time;
173 150
174 tv.tv_nsec = 0; 151 tv.tv_nsec = 0;
175 tv.tv_sec = (ppc_md.get_rtc_time)(); 152 tv.tv_sec = (ppc_md.get_rtc_time) ();
176 do_settimeofday(&tv); 153 do_settimeofday(&tv);
177 154
178 return 0; 155 return 0;
179} 156}
157
180late_initcall(mpc834x_rtc_hookup); 158late_initcall(mpc834x_rtc_hookup);
181#endif 159#endif
182 160
183static void 161void __init platform_init(void)
184mpc83xx_restart(char *cmd)
185{
186#define RST_OFFSET 0x00000900
187#define RST_PROT_REG 0x00000018
188#define RST_CTRL_REG 0x0000001c
189 __be32 __iomem *reg;
190
191 // map reset register space
192 reg = ioremap(get_immrbase() + 0x900, 0xff);
193
194 local_irq_disable();
195
196 /* enable software reset "RSTE" */
197 out_be32(reg + (RST_PROT_REG >> 2), 0x52535445);
198
199 /* set software hard reset */
200 out_be32(reg + (RST_CTRL_REG >> 2), 0x52535445);
201 for(;;);
202}
203
204static long __init
205mpc83xx_time_init(void)
206{
207#define SPCR_OFFSET 0x00000110
208#define SPCR_TBEN 0x00400000
209 __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
210 __be32 tmp;
211
212 tmp = in_be32(spcr);
213 out_be32(spcr, tmp|SPCR_TBEN);
214
215 iounmap(spcr);
216
217 return 0;
218}
219void __init
220platform_init(void)
221{ 162{
222 /* setup the PowerPC module struct */ 163 /* setup the PowerPC module struct */
223 ppc_md.setup_arch = mpc834x_sys_setup_arch; 164 ppc_md.setup_arch = mpc834x_sys_setup_arch;
@@ -239,5 +180,3 @@ platform_init(void)
239 180
240 return; 181 return;
241} 182}
242
243
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.h b/arch/powerpc/platforms/83xx/mpc834x_sys.h
index e4ca39f6a862..fedecb73f7ff 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.h
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.h
@@ -20,4 +20,4 @@
20#define PIRQC MPC83xx_IRQ_EXT6 20#define PIRQC MPC83xx_IRQ_EXT6
21#define PIRQD MPC83xx_IRQ_EXT7 21#define PIRQD MPC83xx_IRQ_EXT7
22 22
23#endif /* __MACH_MPC83XX_SYS_H__ */ 23#endif /* __MACH_MPC83XX_SYS_H__ */
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index ce9e66abef24..01cae106912b 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -10,5 +10,8 @@
10 */ 10 */
11 11
12extern int add_bridge(struct device_node *dev); 12extern int add_bridge(struct device_node *dev);
13extern int mpc83xx_exclude_device(u_char bus, u_char devfn);
14extern void mpc83xx_restart(char *cmd);
15extern long mpc83xx_time_init(void);
13 16
14#endif /* __MPC83XX_H__ */ 17#endif /* __MPC83XX_H__ */
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 469cdacc5bd4..16f7d3b30e1d 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -36,7 +36,16 @@
36 36
37int mpc83xx_pci2_busno; 37int mpc83xx_pci2_busno;
38 38
39#ifdef CONFIG_PCI 39int mpc83xx_exclude_device(u_char bus, u_char devfn)
40{
41 if (bus == 0 && PCI_SLOT(devfn) == 0)
42 return PCIBIOS_DEVICE_NOT_FOUND;
43 if (mpc83xx_pci2_busno)
44 if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0)
45 return PCIBIOS_DEVICE_NOT_FOUND;
46 return PCIBIOS_SUCCESSFUL;
47}
48
40int __init add_bridge(struct device_node *dev) 49int __init add_bridge(struct device_node *dev)
41{ 50{
42 int len; 51 int len;
@@ -52,7 +61,7 @@ int __init add_bridge(struct device_node *dev)
52 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 61 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
53 62
54 /* Get bus range if any */ 63 /* Get bus range if any */
55 bus_range = (int *) get_property(dev, "bus-range", &len); 64 bus_range = (int *)get_property(dev, "bus-range", &len);
56 if (bus_range == NULL || len < 2 * sizeof(int)) { 65 if (bus_range == NULL || len < 2 * sizeof(int)) {
57 printk(KERN_WARNING "Can't get bus-range for %s, assume" 66 printk(KERN_WARNING "Can't get bus-range for %s, assume"
58 " bus 0\n", dev->full_name); 67 " bus 0\n", dev->full_name);
@@ -74,7 +83,7 @@ int __init add_bridge(struct device_node *dev)
74 if ((rsrc.start & 0xfffff) == 0x8500) { 83 if ((rsrc.start & 0xfffff) == 0x8500) {
75 setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304); 84 setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304);
76 } 85 }
77 /* PCI 2*/ 86 /* PCI 2 */
78 if ((rsrc.start & 0xfffff) == 0x8600) { 87 if ((rsrc.start & 0xfffff) == 0x8600) {
79 setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384); 88 setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384);
80 primary = 0; 89 primary = 0;
@@ -84,10 +93,10 @@ int __init add_bridge(struct device_node *dev)
84 93
85 printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%08lx. " 94 printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%08lx. "
86 "Firmware bus number: %d->%d\n", 95 "Firmware bus number: %d->%d\n",
87 rsrc.start, hose->first_busno, hose->last_busno); 96 rsrc.start, hose->first_busno, hose->last_busno);
88 97
89 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n", 98 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
90 hose, hose->cfg_addr, hose->cfg_data); 99 hose, hose->cfg_addr, hose->cfg_data);
91 100
92 /* Interpret the "ranges" property */ 101 /* Interpret the "ranges" property */
93 /* This also maps the I/O region and sets isa_io/mem_base */ 102 /* This also maps the I/O region and sets isa_io/mem_base */
@@ -95,5 +104,3 @@ int __init add_bridge(struct device_node *dev)
95 104
96 return 0; 105 return 0;
97} 106}
98
99#endif
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index c5bc2821d991..d3d0ff745e84 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -1,86 +1,30 @@
1config 85xx 1menu "Platform support"
2 bool 2 depends on PPC_85xx
3 depends on E500
4 default y
5
6config PPC_INDIRECT_PCI_BE
7 bool
8 depends on 85xx
9 default y
10
11menu "Freescale 85xx options"
12 depends on E500
13 3
14choice 4choice
15 prompt "Machine Type" 5 prompt "Machine Type"
16 depends on 85xx
17 default MPC8540_ADS 6 default MPC8540_ADS
18 7
19config MPC8540_ADS 8config MPC8540_ADS
20 bool "Freescale MPC8540 ADS" 9 bool "Freescale MPC8540 ADS"
21 help 10 help
22 This option enables support for the MPC 8540 ADS evaluation board. 11 This option enables support for the MPC 8540 ADS board
23
24config MPC8548_CDS
25 bool "Freescale MPC8548 CDS"
26 help
27 This option enablese support for the MPC8548 CDS evaluation board.
28
29config MPC8555_CDS
30 bool "Freescale MPC8555 CDS"
31 help
32 This option enablese support for the MPC8555 CDS evaluation board.
33
34config MPC8560_ADS
35 bool "Freescale MPC8560 ADS"
36 help
37 This option enables support for the MPC 8560 ADS evaluation board.
38
39config SBC8560
40 bool "WindRiver PowerQUICC III SBC8560"
41 help
42 This option enables support for the WindRiver PowerQUICC III
43 SBC8560 board.
44
45config STX_GP3
46 bool "Silicon Turnkey Express GP3"
47 help
48 This option enables support for the Silicon Turnkey Express GP3
49 board.
50 12
51endchoice 13endchoice
52 14
53# It's often necessary to know the specific 85xx processor type.
54# Fortunately, it is implied (so far) from the board type, so we
55# don't need to ask more redundant questions.
56config MPC8540 15config MPC8540
57 bool 16 bool
58 depends on MPC8540_ADS 17 select PPC_UDBG_16550
59 default y 18 select PPC_INDIRECT_PCI
60 19 default y if MPC8540_ADS
61config MPC8548
62 bool
63 depends on MPC8548_CDS
64 default y
65 20
66config MPC8555 21config PPC_INDIRECT_PCI_BE
67 bool
68 depends on MPC8555_CDS
69 default y
70
71config MPC8560
72 bool 22 bool
73 depends on SBC8560 || MPC8560_ADS || STX_GP3 23 depends on PPC_85xx
74 default y
75
76config 85xx_PCI2
77 bool "Supprt for 2nd PCI host controller"
78 depends on MPC8555_CDS
79 default y 24 default y
80 25
81config PPC_GEN550 26config MPIC
82 bool 27 bool
83 depends on MPC8540 || SBC8560 || MPC8555
84 default y 28 default y
85 29
86endmenu 30endmenu
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 6407197ffd89..ffc4139cb214 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -1 +1,5 @@
1# empty makefile so make clean works 1#
2# Makefile for the PowerPC 85xx linux kernel.
3#
4obj-$(CONFIG_PPC_85xx) += misc.o pci.o
5obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
diff --git a/arch/powerpc/platforms/85xx/misc.c b/arch/powerpc/platforms/85xx/misc.c
new file mode 100644
index 000000000000..26c5e822c7c8
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/misc.c
@@ -0,0 +1,31 @@
1/*
2 * MPC85xx generic code.
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2005 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/irq.h>
14#include <linux/module.h>
15#include <asm/irq.h>
16
17extern void abort(void);
18
19void mpc85xx_restart(char *cmd)
20{
21 local_irq_disable();
22 abort();
23}
24
25/* For now this is a pass through */
26phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size)
27{
28 return addr;
29};
30
31EXPORT_SYMBOL(fixup_bigphys_addr);
diff --git a/arch/powerpc/platforms/85xx/mpc8540_ads.h b/arch/powerpc/platforms/85xx/mpc8540_ads.h
new file mode 100644
index 000000000000..f770cadb2080
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc8540_ads.h
@@ -0,0 +1,36 @@
1/*
2 * arch/ppc/platforms/85xx/mpc8540_ads.h
3 *
4 * MPC8540ADS board definitions
5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7 *
8 * Copyright 2004 Freescale Semiconductor Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#ifndef __MACH_MPC8540ADS_H__
18#define __MACH_MPC8540ADS_H__
19
20#include <linux/config.h>
21#include <linux/initrd.h>
22
23#define BOARD_CCSRBAR ((uint)0xe0000000)
24#define BCSR_ADDR ((uint)0xf8000000)
25#define BCSR_SIZE ((uint)(32 * 1024))
26
27/* PCI interrupt controller */
28#define PIRQA MPC85xx_IRQ_EXT1
29#define PIRQB MPC85xx_IRQ_EXT2
30#define PIRQC MPC85xx_IRQ_EXT3
31#define PIRQD MPC85xx_IRQ_EXT4
32
33/* Offset of CPM register space */
34#define CPM_MAP_ADDR (CCSRBAR + MPC85xx_CPM_OFFSET)
35
36#endif /* __MACH_MPC8540ADS_H__ */
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
new file mode 100644
index 000000000000..b44db6268f3d
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -0,0 +1,18 @@
1/*
2 * arch/ppc/platforms/85xx/mpc85xx.h
3 *
4 * MPC85xx soc definitions/function decls
5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7 *
8 * Copyright 2005 Freescale Semiconductor Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17extern void mpc85xx_restart(char *);
18extern int add_bridge(struct device_node *dev);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
new file mode 100644
index 000000000000..b7821dbae00d
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -0,0 +1,244 @@
1/*
2 * MPC85xx setup and early boot code plus other random bits.
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2005 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/config.h>
15#include <linux/stddef.h>
16#include <linux/kernel.h>
17#include <linux/pci.h>
18#include <linux/kdev_t.h>
19#include <linux/delay.h>
20#include <linux/seq_file.h>
21#include <linux/root_dev.h>
22
23#include <asm/system.h>
24#include <asm/time.h>
25#include <asm/machdep.h>
26#include <asm/pci-bridge.h>
27#include <asm/mpc85xx.h>
28#include <asm/prom.h>
29#include <asm/mpic.h>
30#include <mm/mmu_decl.h>
31#include <asm/udbg.h>
32
33#include <sysdev/fsl_soc.h>
34#include "mpc85xx.h"
35
36#ifndef CONFIG_PCI
37unsigned long isa_io_base = 0;
38unsigned long isa_mem_base = 0;
39#endif
40
41/*
42 * Internal interrupts are all Level Sensitive, and Positive Polarity
43 *
44 * Note: Likely, this table and the following function should be
45 * obtained and derived from the OF Device Tree.
46 */
47static u_char mpc85xx_ads_openpic_initsenses[] __initdata = {
48 MPC85XX_INTERNAL_IRQ_SENSES,
49 0x0, /* External 0: */
50#if defined(CONFIG_PCI)
51 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 1: PCI slot 0 */
52 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 2: PCI slot 1 */
53 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 3: PCI slot 2 */
54 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 4: PCI slot 3 */
55#else
56 0x0, /* External 1: */
57 0x0, /* External 2: */
58 0x0, /* External 3: */
59 0x0, /* External 4: */
60#endif
61 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 5: PHY */
62 0x0, /* External 6: */
63 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 7: PHY */
64 0x0, /* External 8: */
65 0x0, /* External 9: */
66 0x0, /* External 10: */
67 0x0, /* External 11: */
68};
69
70#ifdef CONFIG_PCI
71/*
72 * interrupt routing
73 */
74
75int
76mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
77{
78 static char pci_irq_table[][4] =
79 /*
80 * This is little evil, but works around the fact
81 * that revA boards have IDSEL starting at 18
82 * and others boards (older) start at 12
83 *
84 * PCI IDSEL/INTPIN->INTLINE
85 * A B C D
86 */
87 {
88 {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 2 */
89 {PIRQD, PIRQA, PIRQB, PIRQC},
90 {PIRQC, PIRQD, PIRQA, PIRQB},
91 {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 5 */
92 {0, 0, 0, 0}, /* -- */
93 {0, 0, 0, 0}, /* -- */
94 {0, 0, 0, 0}, /* -- */
95 {0, 0, 0, 0}, /* -- */
96 {0, 0, 0, 0}, /* -- */
97 {0, 0, 0, 0}, /* -- */
98 {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 12 */
99 {PIRQD, PIRQA, PIRQB, PIRQC},
100 {PIRQC, PIRQD, PIRQA, PIRQB},
101 {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 15 */
102 {0, 0, 0, 0}, /* -- */
103 {0, 0, 0, 0}, /* -- */
104 {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 18 */
105 {PIRQD, PIRQA, PIRQB, PIRQC},
106 {PIRQC, PIRQD, PIRQA, PIRQB},
107 {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 21 */
108 };
109
110 const long min_idsel = 2, max_idsel = 21, irqs_per_slot = 4;
111 return PCI_IRQ_TABLE_LOOKUP;
112}
113
114int
115mpc85xx_exclude_device(u_char bus, u_char devfn)
116{
117 if (bus == 0 && PCI_SLOT(devfn) == 0)
118 return PCIBIOS_DEVICE_NOT_FOUND;
119 else
120 return PCIBIOS_SUCCESSFUL;
121}
122
123#endif /* CONFIG_PCI */
124
125
126void __init mpc85xx_ads_pic_init(void)
127{
128 struct mpic *mpic1;
129 phys_addr_t OpenPIC_PAddr;
130
131 /* Determine the Physical Address of the OpenPIC regs */
132 OpenPIC_PAddr = get_immrbase() + MPC85xx_OPENPIC_OFFSET;
133
134 mpic1 = mpic_alloc(OpenPIC_PAddr,
135 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
136 4, MPC85xx_OPENPIC_IRQ_OFFSET, 0, 250,
137 mpc85xx_ads_openpic_initsenses,
138 sizeof(mpc85xx_ads_openpic_initsenses),
139 " OpenPIC ");
140 BUG_ON(mpic1 == NULL);
141 mpic_assign_isu(mpic1, 0, OpenPIC_PAddr + 0x10200);
142 mpic_assign_isu(mpic1, 1, OpenPIC_PAddr + 0x10280);
143 mpic_assign_isu(mpic1, 2, OpenPIC_PAddr + 0x10300);
144 mpic_assign_isu(mpic1, 3, OpenPIC_PAddr + 0x10380);
145 mpic_assign_isu(mpic1, 4, OpenPIC_PAddr + 0x10400);
146 mpic_assign_isu(mpic1, 5, OpenPIC_PAddr + 0x10480);
147 mpic_assign_isu(mpic1, 6, OpenPIC_PAddr + 0x10500);
148 mpic_assign_isu(mpic1, 7, OpenPIC_PAddr + 0x10580);
149
150 /* dummy mappings to get to 48 */
151 mpic_assign_isu(mpic1, 8, OpenPIC_PAddr + 0x10600);
152 mpic_assign_isu(mpic1, 9, OpenPIC_PAddr + 0x10680);
153 mpic_assign_isu(mpic1, 10, OpenPIC_PAddr + 0x10700);
154 mpic_assign_isu(mpic1, 11, OpenPIC_PAddr + 0x10780);
155
156 /* External ints */
157 mpic_assign_isu(mpic1, 12, OpenPIC_PAddr + 0x10000);
158 mpic_assign_isu(mpic1, 13, OpenPIC_PAddr + 0x10080);
159 mpic_assign_isu(mpic1, 14, OpenPIC_PAddr + 0x10100);
160 mpic_init(mpic1);
161}
162
163/*
164 * Setup the architecture
165 */
166static void __init mpc85xx_ads_setup_arch(void)
167{
168 struct device_node *cpu;
169 struct device_node *np;
170
171 if (ppc_md.progress)
172 ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
173
174 cpu = of_find_node_by_type(NULL, "cpu");
175 if (cpu != 0) {
176 unsigned int *fp;
177
178 fp = (int *)get_property(cpu, "clock-frequency", NULL);
179 if (fp != 0)
180 loops_per_jiffy = *fp / HZ;
181 else
182 loops_per_jiffy = 50000000 / HZ;
183 of_node_put(cpu);
184 }
185
186#ifdef CONFIG_PCI
187 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
188 add_bridge(np);
189
190 ppc_md.pci_swizzle = common_swizzle;
191 ppc_md.pci_map_irq = mpc85xx_map_irq;
192 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
193#endif
194
195#ifdef CONFIG_ROOT_NFS
196 ROOT_DEV = Root_NFS;
197#else
198 ROOT_DEV = Root_HDA1;
199#endif
200}
201
202void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
203{
204 uint pvid, svid, phid1;
205 uint memsize = total_memory;
206
207 pvid = mfspr(SPRN_PVR);
208 svid = mfspr(SPRN_SVR);
209
210 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
211 seq_printf(m, "Machine\t\t: mpc85xx\n");
212 seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
213 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
214
215 /* Display cpu Pll setting */
216 phid1 = mfspr(SPRN_HID1);
217 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
218
219 /* Display the amount of memory */
220 seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
221}
222
223void __init platform_init(void)
224{
225 ppc_md.setup_arch = mpc85xx_ads_setup_arch;
226 ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
227
228 ppc_md.init_IRQ = mpc85xx_ads_pic_init;
229 ppc_md.get_irq = mpic_get_irq;
230
231 ppc_md.restart = mpc85xx_restart;
232 ppc_md.power_off = NULL;
233 ppc_md.halt = NULL;
234
235 ppc_md.time_init = NULL;
236 ppc_md.set_rtc_time = NULL;
237 ppc_md.get_rtc_time = NULL;
238 ppc_md.calibrate_decr = generic_calibrate_decr;
239
240 ppc_md.progress = udbg_progress;
241
242 if (ppc_md.progress)
243 ppc_md.progress("mpc85xx_ads platform_init(): exit", 0);
244}
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
new file mode 100644
index 000000000000..bad290110ed1
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/pci.c
@@ -0,0 +1,96 @@
1/*
2 * FSL SoC setup code
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/stddef.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/errno.h>
17#include <linux/pci.h>
18#include <linux/delay.h>
19#include <linux/irq.h>
20#include <linux/module.h>
21
22#include <asm/system.h>
23#include <asm/atomic.h>
24#include <asm/io.h>
25#include <asm/pci-bridge.h>
26#include <asm/prom.h>
27#include <sysdev/fsl_soc.h>
28
29#undef DEBUG
30
31#ifdef DEBUG
32#define DBG(x...) printk(x)
33#else
34#define DBG(x...)
35#endif
36
37int mpc85xx_pci2_busno = 0;
38
39#ifdef CONFIG_PCI
40int __init add_bridge(struct device_node *dev)
41{
42 int len;
43 struct pci_controller *hose;
44 struct resource rsrc;
45 int *bus_range;
46 int primary = 1, has_address = 0;
47 phys_addr_t immr = get_immrbase();
48
49 DBG("Adding PCI host bridge %s\n", dev->full_name);
50
51 /* Fetch host bridge registers address */
52 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
53
54 /* Get bus range if any */
55 bus_range = (int *) get_property(dev, "bus-range", &len);
56 if (bus_range == NULL || len < 2 * sizeof(int)) {
57 printk(KERN_WARNING "Can't get bus-range for %s, assume"
58 " bus 0\n", dev->full_name);
59 }
60
61 hose = pcibios_alloc_controller();
62 if (!hose)
63 return -ENOMEM;
64 hose->arch_data = dev;
65 hose->set_cfg_type = 1;
66
67 hose->first_busno = bus_range ? bus_range[0] : 0;
68 hose->last_busno = bus_range ? bus_range[1] : 0xff;
69
70 /* PCI 1 */
71 if ((rsrc.start & 0xfffff) == 0x8000) {
72 setup_indirect_pci(hose, immr + 0x8000, immr + 0x8004);
73 }
74 /* PCI 2 */
75 if ((rsrc.start & 0xfffff) == 0x9000) {
76 setup_indirect_pci(hose, immr + 0x9000, immr + 0x9004);
77 primary = 0;
78 hose->bus_offset = hose->first_busno;
79 mpc85xx_pci2_busno = hose->first_busno;
80 }
81
82 printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%08lx. "
83 "Firmware bus number: %d->%d\n",
84 rsrc.start, hose->first_busno, hose->last_busno);
85
86 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
87 hose, hose->cfg_addr, hose->cfg_data);
88
89 /* Interpret the "ranges" property */
90 /* This also maps the I/O region and sets isa_io/mem_base */
91 pci_process_bridge_OF_ranges(hose, dev, primary);
92
93 return 0;
94}
95
96#endif
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 04073fd987ec..c4f6b0d2d140 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -8,7 +8,7 @@ endif
8obj-$(CONFIG_PPC_CHRP) += chrp/ 8obj-$(CONFIG_PPC_CHRP) += chrp/
9obj-$(CONFIG_4xx) += 4xx/ 9obj-$(CONFIG_4xx) += 4xx/
10obj-$(CONFIG_PPC_83xx) += 83xx/ 10obj-$(CONFIG_PPC_83xx) += 83xx/
11obj-$(CONFIG_85xx) += 85xx/ 11obj-$(CONFIG_PPC_85xx) += 85xx/
12obj-$(CONFIG_PPC_PSERIES) += pseries/ 12obj-$(CONFIG_PPC_PSERIES) += pseries/
13obj-$(CONFIG_PPC_ISERIES) += iseries/ 13obj-$(CONFIG_PPC_ISERIES) += iseries/
14obj-$(CONFIG_PPC_MAPLE) += maple/ 14obj-$(CONFIG_PPC_MAPLE) += maple/
diff --git a/arch/powerpc/platforms/chrp/pegasos_eth.c b/arch/powerpc/platforms/chrp/pegasos_eth.c
index 29c86781c493..6ad4b1a72c96 100644
--- a/arch/powerpc/platforms/chrp/pegasos_eth.c
+++ b/arch/powerpc/platforms/chrp/pegasos_eth.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/chrp_pegasos_eth.c
3 *
4 * Copyright (C) 2005 Sven Luther <sl@bplan-gmbh.de> 2 * Copyright (C) 2005 Sven Luther <sl@bplan-gmbh.de>
5 * Thanks to : 3 * Thanks to :
6 * Dale Farnsworth <dale@farnsworth.org> 4 * Dale Farnsworth <dale@farnsworth.org>
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index e1fadbf49150..8bf4307e323d 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas 3 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu) 4 * Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c
index 78df2e7ca88a..12c6f689b1aa 100644
--- a/arch/powerpc/platforms/chrp/time.c
+++ b/arch/powerpc/platforms/chrp/time.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/chrp_time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 2 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * 3 *
6 * Adapted for PowerPC (PReP) by Gary Thomas 4 * Adapted for PowerPC (PReP) by Gary Thomas
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index a41d8b78c0cd..d771b8ee857d 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -46,6 +46,7 @@
46#include "setup.h" 46#include "setup.h"
47 47
48extern int piranha_simulator; 48extern int piranha_simulator;
49static int mf_initialized;
49 50
50/* 51/*
51 * This is the structure layout for the Machine Facilites LPAR event 52 * This is the structure layout for the Machine Facilites LPAR event
@@ -143,7 +144,8 @@ static spinlock_t pending_event_spinlock;
143static struct pending_event *pending_event_head; 144static struct pending_event *pending_event_head;
144static struct pending_event *pending_event_tail; 145static struct pending_event *pending_event_tail;
145static struct pending_event *pending_event_avail; 146static struct pending_event *pending_event_avail;
146static struct pending_event pending_event_prealloc[16]; 147#define PENDING_EVENT_PREALLOC_LEN 16
148static struct pending_event pending_event_prealloc[PENDING_EVENT_PREALLOC_LEN];
147 149
148/* 150/*
149 * Put a pending event onto the available queue, so it can get reused. 151 * Put a pending event onto the available queue, so it can get reused.
@@ -597,7 +599,7 @@ void mf_power_off(void)
597 * Global kernel interface to tell the VSP object in the primary 599 * Global kernel interface to tell the VSP object in the primary
598 * partition to reboot this partition. 600 * partition to reboot this partition.
599 */ 601 */
600void mf_reboot(void) 602void mf_reboot(char *cmd)
601{ 603{
602 printk(KERN_INFO "mf.c: Preparing to bounce...\n"); 604 printk(KERN_INFO "mf.c: Preparing to bounce...\n");
603 signal_ce_msg_simple(0x4e, NULL); 605 signal_ce_msg_simple(0x4e, NULL);
@@ -625,7 +627,7 @@ void mf_display_src(u32 word)
625/* 627/*
626 * Display a single word SRC of the form "PROGXXXX" on the VSP control panel. 628 * Display a single word SRC of the form "PROGXXXX" on the VSP control panel.
627 */ 629 */
628void mf_display_progress(u16 value) 630static __init void mf_display_progress_src(u16 value)
629{ 631{
630 u8 ce[12]; 632 u8 ce[12];
631 u8 src[72]; 633 u8 src[72];
@@ -649,30 +651,42 @@ void mf_display_progress(u16 value)
649 * Clear the VSP control panel. Used to "erase" an SRC that was 651 * Clear the VSP control panel. Used to "erase" an SRC that was
650 * previously displayed. 652 * previously displayed.
651 */ 653 */
652void mf_clear_src(void) 654static void mf_clear_src(void)
653{ 655{
654 signal_ce_msg_simple(0x4b, NULL); 656 signal_ce_msg_simple(0x4b, NULL);
655} 657}
656 658
659void __init mf_display_progress(u16 value)
660{
661 if (piranha_simulator || !mf_initialized)
662 return;
663
664 if (0xFFFF == value)
665 mf_clear_src();
666 else
667 mf_display_progress_src(value);
668}
669
657/* 670/*
658 * Initialization code here. 671 * Initialization code here.
659 */ 672 */
660void mf_init(void) 673void __init mf_init(void)
661{ 674{
662 int i; 675 int i;
663 676
664 /* initialize */
665 spin_lock_init(&pending_event_spinlock); 677 spin_lock_init(&pending_event_spinlock);
666 for (i = 0; 678
667 i < sizeof(pending_event_prealloc) / sizeof(*pending_event_prealloc); 679 for (i = 0; i < PENDING_EVENT_PREALLOC_LEN; i++)
668 ++i)
669 free_pending_event(&pending_event_prealloc[i]); 680 free_pending_event(&pending_event_prealloc[i]);
681
670 HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hv_handler); 682 HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hv_handler);
671 683
672 /* virtual continue ack */ 684 /* virtual continue ack */
673 signal_ce_msg_simple(0x57, NULL); 685 signal_ce_msg_simple(0x57, NULL);
674 686
675 /* initialization complete */ 687 mf_initialized = 1;
688 mb();
689
676 printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities " 690 printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities "
677 "initialized\n"); 691 "initialized\n");
678} 692}
@@ -692,6 +706,43 @@ static void get_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
692 complete(&rtc->com); 706 complete(&rtc->com);
693} 707}
694 708
709static int mf_set_rtc(struct rtc_time *tm)
710{
711 char ce_time[12];
712 u8 day, mon, hour, min, sec, y1, y2;
713 unsigned year;
714
715 year = 1900 + tm->tm_year;
716 y1 = year / 100;
717 y2 = year % 100;
718
719 sec = tm->tm_sec;
720 min = tm->tm_min;
721 hour = tm->tm_hour;
722 day = tm->tm_mday;
723 mon = tm->tm_mon + 1;
724
725 BIN_TO_BCD(sec);
726 BIN_TO_BCD(min);
727 BIN_TO_BCD(hour);
728 BIN_TO_BCD(mon);
729 BIN_TO_BCD(day);
730 BIN_TO_BCD(y1);
731 BIN_TO_BCD(y2);
732
733 memset(ce_time, 0, sizeof(ce_time));
734 ce_time[3] = 0x41;
735 ce_time[4] = y1;
736 ce_time[5] = y2;
737 ce_time[6] = sec;
738 ce_time[7] = min;
739 ce_time[8] = hour;
740 ce_time[10] = day;
741 ce_time[11] = mon;
742
743 return signal_ce_msg(ce_time, NULL);
744}
745
695static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm) 746static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm)
696{ 747{
697 tm->tm_wday = 0; 748 tm->tm_wday = 0;
@@ -747,7 +798,7 @@ static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm)
747 return 0; 798 return 0;
748} 799}
749 800
750int mf_get_rtc(struct rtc_time *tm) 801static int mf_get_rtc(struct rtc_time *tm)
751{ 802{
752 struct ce_msg_comp_data ce_complete; 803 struct ce_msg_comp_data ce_complete;
753 struct rtc_time_data rtc_data; 804 struct rtc_time_data rtc_data;
@@ -780,7 +831,7 @@ static void get_boot_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
780 rtc->busy = 0; 831 rtc->busy = 0;
781} 832}
782 833
783int mf_get_boot_rtc(struct rtc_time *tm) 834static int mf_get_boot_rtc(struct rtc_time *tm)
784{ 835{
785 struct ce_msg_comp_data ce_complete; 836 struct ce_msg_comp_data ce_complete;
786 struct boot_rtc_time_data rtc_data; 837 struct boot_rtc_time_data rtc_data;
@@ -802,43 +853,6 @@ int mf_get_boot_rtc(struct rtc_time *tm)
802 return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm); 853 return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
803} 854}
804 855
805int mf_set_rtc(struct rtc_time *tm)
806{
807 char ce_time[12];
808 u8 day, mon, hour, min, sec, y1, y2;
809 unsigned year;
810
811 year = 1900 + tm->tm_year;
812 y1 = year / 100;
813 y2 = year % 100;
814
815 sec = tm->tm_sec;
816 min = tm->tm_min;
817 hour = tm->tm_hour;
818 day = tm->tm_mday;
819 mon = tm->tm_mon + 1;
820
821 BIN_TO_BCD(sec);
822 BIN_TO_BCD(min);
823 BIN_TO_BCD(hour);
824 BIN_TO_BCD(mon);
825 BIN_TO_BCD(day);
826 BIN_TO_BCD(y1);
827 BIN_TO_BCD(y2);
828
829 memset(ce_time, 0, sizeof(ce_time));
830 ce_time[3] = 0x41;
831 ce_time[4] = y1;
832 ce_time[5] = y2;
833 ce_time[6] = sec;
834 ce_time[7] = min;
835 ce_time[8] = hour;
836 ce_time[10] = day;
837 ce_time[11] = mon;
838
839 return signal_ce_msg(ce_time, NULL);
840}
841
842#ifdef CONFIG_PROC_FS 856#ifdef CONFIG_PROC_FS
843 857
844static int proc_mf_dump_cmdline(char *page, char **start, off_t off, 858static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index 3ecc4a652d82..fa4550611c11 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -50,6 +50,7 @@
50#include <asm/iseries/hv_call_xm.h> 50#include <asm/iseries/hv_call_xm.h>
51#include <asm/iseries/it_lp_queue.h> 51#include <asm/iseries/it_lp_queue.h>
52#include <asm/iseries/mf.h> 52#include <asm/iseries/mf.h>
53#include <asm/iseries/it_exp_vpd_panel.h>
53#include <asm/iseries/hv_lp_event.h> 54#include <asm/iseries/hv_lp_event.h>
54#include <asm/iseries/lpar_map.h> 55#include <asm/iseries/lpar_map.h>
55#include <asm/udbg.h> 56#include <asm/udbg.h>
@@ -89,8 +90,6 @@ extern unsigned long embedded_sysmap_end;
89extern unsigned long iSeries_recal_tb; 90extern unsigned long iSeries_recal_tb;
90extern unsigned long iSeries_recal_titan; 91extern unsigned long iSeries_recal_titan;
91 92
92static int mf_initialized;
93
94static unsigned long cmd_mem_limit; 93static unsigned long cmd_mem_limit;
95 94
96struct MemoryBlock { 95struct MemoryBlock {
@@ -303,8 +302,6 @@ static void __init iSeries_init_early(void)
303{ 302{
304 DBG(" -> iSeries_init_early()\n"); 303 DBG(" -> iSeries_init_early()\n");
305 304
306 ppc64_firmware_features = FW_FEATURE_ISERIES;
307
308 ppc64_interrupt_controller = IC_ISERIES; 305 ppc64_interrupt_controller = IC_ISERIES;
309 306
310#if defined(CONFIG_BLK_DEV_INITRD) 307#if defined(CONFIG_BLK_DEV_INITRD)
@@ -349,8 +346,6 @@ static void __init iSeries_init_early(void)
349 HvCallEvent_setLpEventQueueInterruptProc(0, 0); 346 HvCallEvent_setLpEventQueueInterruptProc(0, 0);
350 347
351 mf_init(); 348 mf_init();
352 mf_initialized = 1;
353 mb();
354 349
355 /* If we were passed an initrd, set the ROOT_DEV properly if the values 350 /* If we were passed an initrd, set the ROOT_DEV properly if the values
356 * look sensible. If not, clear initrd reference. 351 * look sensible. If not, clear initrd reference.
@@ -560,39 +555,10 @@ static void iSeries_show_cpuinfo(struct seq_file *m)
560 seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n"); 555 seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n");
561} 556}
562 557
563/*
564 * Document me.
565 */
566static void iSeries_restart(char *cmd)
567{
568 mf_reboot();
569}
570
571/*
572 * Document me.
573 */
574static void iSeries_power_off(void)
575{
576 mf_power_off();
577}
578
579/*
580 * Document me.
581 */
582static void iSeries_halt(void)
583{
584 mf_power_off();
585}
586
587static void __init iSeries_progress(char * st, unsigned short code) 558static void __init iSeries_progress(char * st, unsigned short code)
588{ 559{
589 printk("Progress: [%04x] - %s\n", (unsigned)code, st); 560 printk("Progress: [%04x] - %s\n", (unsigned)code, st);
590 if (!piranha_simulator && mf_initialized) { 561 mf_display_progress(code);
591 if (code != 0xffff)
592 mf_display_progress(code);
593 else
594 mf_clear_src();
595 }
596} 562}
597 563
598static void __init iSeries_fixup_klimit(void) 564static void __init iSeries_fixup_klimit(void)
@@ -711,7 +677,13 @@ void __init iSeries_init_IRQ(void) { }
711 677
712static int __init iseries_probe(int platform) 678static int __init iseries_probe(int platform)
713{ 679{
714 return PLATFORM_ISERIES_LPAR == platform; 680 if (PLATFORM_ISERIES_LPAR != platform)
681 return 0;
682
683 ppc64_firmware_features |= FW_FEATURE_ISERIES;
684 ppc64_firmware_features |= FW_FEATURE_LPAR;
685
686 return 1;
715} 687}
716 688
717struct machdep_calls __initdata iseries_md = { 689struct machdep_calls __initdata iseries_md = {
@@ -721,9 +693,9 @@ struct machdep_calls __initdata iseries_md = {
721 .get_irq = iSeries_get_irq, 693 .get_irq = iSeries_get_irq,
722 .init_early = iSeries_init_early, 694 .init_early = iSeries_init_early,
723 .pcibios_fixup = iSeries_pci_final_fixup, 695 .pcibios_fixup = iSeries_pci_final_fixup,
724 .restart = iSeries_restart, 696 .restart = mf_reboot,
725 .power_off = iSeries_power_off, 697 .power_off = mf_power_off,
726 .halt = iSeries_halt, 698 .halt = mf_power_off,
727 .get_boot_time = iSeries_get_boot_time, 699 .get_boot_time = iSeries_get_boot_time,
728 .set_rtc_time = iSeries_set_rtc_time, 700 .set_rtc_time = iSeries_set_rtc_time,
729 .get_rtc_time = iSeries_get_rtc_time, 701 .get_rtc_time = iSeries_get_rtc_time,
@@ -917,6 +889,24 @@ void dt_cpus(struct iseries_flat_dt *dt)
917 dt_end_node(dt); 889 dt_end_node(dt);
918} 890}
919 891
892void dt_model(struct iseries_flat_dt *dt)
893{
894 char buf[16] = "IBM,";
895
896 /* "IBM," + mfgId[2:3] + systemSerial[1:5] */
897 strne2a(buf + 4, xItExtVpdPanel.mfgID + 2, 2);
898 strne2a(buf + 6, xItExtVpdPanel.systemSerial + 1, 5);
899 buf[11] = '\0';
900 dt_prop_str(dt, "system-id", buf);
901
902 /* "IBM," + machineType[0:4] */
903 strne2a(buf + 4, xItExtVpdPanel.machineType, 4);
904 buf[8] = '\0';
905 dt_prop_str(dt, "model", buf);
906
907 dt_prop_str(dt, "compatible", "IBM,iSeries");
908}
909
920void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) 910void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
921{ 911{
922 u64 tmp[2]; 912 u64 tmp[2];
@@ -927,6 +917,7 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
927 917
928 dt_prop_u32(dt, "#address-cells", 2); 918 dt_prop_u32(dt, "#address-cells", 2);
929 dt_prop_u32(dt, "#size-cells", 2); 919 dt_prop_u32(dt, "#size-cells", 2);
920 dt_model(dt);
930 921
931 /* /memory */ 922 /* /memory */
932 dt_start_node(dt, "memory@0"); 923 dt_start_node(dt, "memory@0");
@@ -940,6 +931,7 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
940 /* /chosen */ 931 /* /chosen */
941 dt_start_node(dt, "chosen"); 932 dt_start_node(dt, "chosen");
942 dt_prop_u32(dt, "linux,platform", PLATFORM_ISERIES_LPAR); 933 dt_prop_u32(dt, "linux,platform", PLATFORM_ISERIES_LPAR);
934 dt_prop_str(dt, "bootargs", cmd_line);
943 if (cmd_mem_limit) 935 if (cmd_mem_limit)
944 dt_prop_u64(dt, "linux,memory-limit", cmd_mem_limit); 936 dt_prop_u64(dt, "linux,memory-limit", cmd_mem_limit);
945 dt_end_node(dt); 937 dt_end_node(dt);
diff --git a/arch/powerpc/platforms/maple/time.c b/arch/powerpc/platforms/maple/time.c
index 50bc4eb85353..5e6981d17379 100644
--- a/arch/powerpc/platforms/maple/time.c
+++ b/arch/powerpc/platforms/maple/time.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/maple_time.c
3 *
4 * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org), 2 * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
5 * IBM Corp. 3 * IBM Corp.
6 * 4 *
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 56fd4e05fede..cfd6527a0d7e 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pmac_cpufreq.c
3 *
4 * Copyright (C) 2002 - 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org> 2 * Copyright (C) 2002 - 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 * Copyright (C) 2004 John Steele Scott <toojays@toojays.net> 3 * Copyright (C) 2004 John Steele Scott <toojays@toojays.net>
6 * 4 *
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index bbe794891a20..e49eddd5042d 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pmac_feature.c
3 *
4 * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au) 2 * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
5 * Ben. Herrenschmidt (benh@kernel.crashing.org) 3 * Ben. Herrenschmidt (benh@kernel.crashing.org)
6 * 4 *
diff --git a/arch/powerpc/platforms/powermac/nvram.c b/arch/powerpc/platforms/powermac/nvram.c
index 3ebd045a3350..5fd28995c74c 100644
--- a/arch/powerpc/platforms/powermac/nvram.c
+++ b/arch/powerpc/platforms/powermac/nvram.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pmac_nvram.c
3 *
4 * Copyright (C) 2002 Benjamin Herrenschmidt (benh@kernel.crashing.org) 2 * Copyright (C) 2002 Benjamin Herrenschmidt (benh@kernel.crashing.org)
5 * 3 *
6 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 29c2946f1c77..385aab90c4d2 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -86,11 +86,10 @@ int ppc_override_l2cr = 0;
86int ppc_override_l2cr_value; 86int ppc_override_l2cr_value;
87int has_l2cache = 0; 87int has_l2cache = 0;
88 88
89int pmac_newworld = 1; 89int pmac_newworld;
90 90
91static int current_root_goodness = -1; 91static int current_root_goodness = -1;
92 92
93extern int pmac_newworld;
94extern struct machdep_calls pmac_md; 93extern struct machdep_calls pmac_md;
95 94
96#define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */ 95#define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
@@ -308,9 +307,10 @@ static void __init pmac_setup_arch(void)
308 for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; ) 307 for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; )
309 if (get_property(ic, "interrupt-controller", NULL)) 308 if (get_property(ic, "interrupt-controller", NULL))
310 break; 309 break;
311 pmac_newworld = (ic != NULL); 310 if (ic) {
312 if (ic) 311 pmac_newworld = 1;
313 of_node_put(ic); 312 of_node_put(ic);
313 }
314 314
315 /* Lookup PCI hosts */ 315 /* Lookup PCI hosts */
316 pmac_pci_init(); 316 pmac_pci_init();
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 6d64a9bf3474..1065d87fc279 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -191,9 +191,7 @@ static void smp_psurge_message_pass(int target, int msg)
191 if (num_online_cpus() < 2) 191 if (num_online_cpus() < 2)
192 return; 192 return;
193 193
194 for (i = 0; i < NR_CPUS; i++) { 194 for_each_online_cpu(i) {
195 if (!cpu_online(i))
196 continue;
197 if (target == MSG_ALL 195 if (target == MSG_ALL
198 || (target == MSG_ALL_BUT_SELF && i != smp_processor_id()) 196 || (target == MSG_ALL_BUT_SELF && i != smp_processor_id())
199 || target == i) { 197 || target == i) {
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 61616d144072..930898635c9f 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -1,5 +1,6 @@
1obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \ 1obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \
2 setup.o iommu.o ras.o rtasd.o pci_dlpar.o 2 setup.o iommu.o ras.o rtasd.o pci_dlpar.o \
3 firmware.o
3obj-$(CONFIG_SMP) += smp.o 4obj-$(CONFIG_SMP) += smp.o
4obj-$(CONFIG_IBMVIO) += vio.o 5obj-$(CONFIG_IBMVIO) += vio.o
5obj-$(CONFIG_XICS) += xics.o 6obj-$(CONFIG_XICS) += xics.o
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
new file mode 100644
index 000000000000..989f4bc136cb
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -0,0 +1,103 @@
1/*
2 * pSeries firmware setup code.
3 *
4 * Portions from arch/powerpc/platforms/pseries/setup.c:
5 * Copyright (C) 1995 Linus Torvalds
6 * Adapted from 'alpha' version by Gary Thomas
7 * Modified by Cort Dougan (cort@cs.nmt.edu)
8 * Modified by PPC64 Team, IBM Corp
9 *
10 * Portions from arch/powerpc/kernel/firmware.c
11 * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
12 * Modifications for ppc64:
13 * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
14 * Copyright (C) 2005 Stephen Rothwell, IBM Corporation
15 *
16 * Copyright 2006 IBM Corporation.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 */
23
24#undef DEBUG
25
26#include <asm/firmware.h>
27#include <asm/prom.h>
28
29#ifdef DEBUG
30#define DBG(fmt...) udbg_printf(fmt)
31#else
32#define DBG(fmt...)
33#endif
34
35typedef struct {
36 unsigned long val;
37 char * name;
38} firmware_feature_t;
39
40static __initdata firmware_feature_t
41firmware_features_table[FIRMWARE_MAX_FEATURES] = {
42 {FW_FEATURE_PFT, "hcall-pft"},
43 {FW_FEATURE_TCE, "hcall-tce"},
44 {FW_FEATURE_SPRG0, "hcall-sprg0"},
45 {FW_FEATURE_DABR, "hcall-dabr"},
46 {FW_FEATURE_COPY, "hcall-copy"},
47 {FW_FEATURE_ASR, "hcall-asr"},
48 {FW_FEATURE_DEBUG, "hcall-debug"},
49 {FW_FEATURE_PERF, "hcall-perf"},
50 {FW_FEATURE_DUMP, "hcall-dump"},
51 {FW_FEATURE_INTERRUPT, "hcall-interrupt"},
52 {FW_FEATURE_MIGRATE, "hcall-migrate"},
53 {FW_FEATURE_PERFMON, "hcall-perfmon"},
54 {FW_FEATURE_CRQ, "hcall-crq"},
55 {FW_FEATURE_VIO, "hcall-vio"},
56 {FW_FEATURE_RDMA, "hcall-rdma"},
57 {FW_FEATURE_LLAN, "hcall-lLAN"},
58 {FW_FEATURE_BULK, "hcall-bulk"},
59 {FW_FEATURE_XDABR, "hcall-xdabr"},
60 {FW_FEATURE_MULTITCE, "hcall-multi-tce"},
61 {FW_FEATURE_SPLPAR, "hcall-splpar"},
62};
63
64/* Build up the firmware features bitmask using the contents of
65 * device-tree/ibm,hypertas-functions. Ultimately this functionality may
66 * be moved into prom.c prom_init().
67 */
68void __init fw_feature_init(void)
69{
70 struct device_node *dn;
71 char *hypertas, *s;
72 int len, i;
73
74 DBG(" -> fw_feature_init()\n");
75
76 dn = of_find_node_by_path("/rtas");
77 if (dn == NULL) {
78 printk(KERN_ERR "WARNING! Cannot find RTAS in device-tree!\n");
79 goto out;
80 }
81
82 hypertas = get_property(dn, "ibm,hypertas-functions", &len);
83 if (hypertas == NULL)
84 goto out;
85
86 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
87 for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) {
88 /* check value against table of strings */
89 if (!firmware_features_table[i].name ||
90 strcmp(firmware_features_table[i].name, s))
91 continue;
92
93 /* we have a match */
94 ppc64_firmware_features |=
95 firmware_features_table[i].val;
96 break;
97 }
98 }
99
100out:
101 of_node_put(dn);
102 DBG(" <- fw_feature_init()\n");
103}
diff --git a/arch/powerpc/platforms/pseries/firmware.h b/arch/powerpc/platforms/pseries/firmware.h
new file mode 100644
index 000000000000..714f56f55362
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/firmware.h
@@ -0,0 +1,17 @@
1/*
2 * Copyright 2006 IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#ifndef _PSERIES_FIRMWARE_H
11#define _PSERIES_FIRMWARE_H
12
13#include <asm/firmware.h>
14
15extern void __init fw_feature_init(void);
16
17#endif /* _PSERIES_FIRMWARE_H */
diff --git a/arch/powerpc/platforms/pseries/hvCall.S b/arch/powerpc/platforms/pseries/hvCall.S
index 176e8da76466..db7c19fe9297 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/pSeries_hvCall.S
3 *
4 * This file contains the generic code to perform a call to the 2 * This file contains the generic code to perform a call to the
5 * pSeries LPAR hypervisor. 3 * pSeries LPAR hypervisor.
6 * NOTE: this file will go away when we move to inline this work. 4 * NOTE: this file will go away when we move to inline this work.
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 48cfbfc43f99..2643078433f0 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/pSeries_iommu.c
3 *
4 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation 2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
5 * 3 *
6 * Rewrite, cleanup: 4 * Rewrite, cleanup:
@@ -582,7 +580,7 @@ void iommu_init_early_pSeries(void)
582 return; 580 return;
583 } 581 }
584 582
585 if (platform_is_lpar()) { 583 if (firmware_has_feature(FW_FEATURE_LPAR)) {
586 if (firmware_has_feature(FW_FEATURE_MULTITCE)) { 584 if (firmware_has_feature(FW_FEATURE_MULTITCE)) {
587 ppc_md.tce_build = tce_buildmulti_pSeriesLP; 585 ppc_md.tce_build = tce_buildmulti_pSeriesLP;
588 ppc_md.tce_free = tce_freemulti_pSeriesLP; 586 ppc_md.tce_free = tce_freemulti_pSeriesLP;
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 999a9620b5ce..946ad59e3352 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc64/kernel/pSeries_pci.c
3 *
4 * Copyright (C) 2001 Dave Engebretsen, IBM Corporation 2 * Copyright (C) 2001 Dave Engebretsen, IBM Corporation
5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM 3 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
6 * 4 *
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 9edeca83f434..44d5c7fdcd97 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -60,7 +60,6 @@
60#include <asm/time.h> 60#include <asm/time.h>
61#include <asm/nvram.h> 61#include <asm/nvram.h>
62#include "xics.h" 62#include "xics.h"
63#include <asm/firmware.h>
64#include <asm/pmc.h> 63#include <asm/pmc.h>
65#include <asm/mpic.h> 64#include <asm/mpic.h>
66#include <asm/ppc-pci.h> 65#include <asm/ppc-pci.h>
@@ -70,6 +69,7 @@
70 69
71#include "plpar_wrappers.h" 70#include "plpar_wrappers.h"
72#include "ras.h" 71#include "ras.h"
72#include "firmware.h"
73 73
74#ifdef DEBUG 74#ifdef DEBUG
75#define DBG(fmt...) udbg_printf(fmt) 75#define DBG(fmt...) udbg_printf(fmt)
@@ -246,7 +246,7 @@ static void __init pSeries_setup_arch(void)
246 ppc_md.idle_loop = default_idle; 246 ppc_md.idle_loop = default_idle;
247 } 247 }
248 248
249 if (platform_is_lpar()) 249 if (firmware_has_feature(FW_FEATURE_LPAR))
250 ppc_md.enable_pmcs = pseries_lpar_enable_pmcs; 250 ppc_md.enable_pmcs = pseries_lpar_enable_pmcs;
251 else 251 else
252 ppc_md.enable_pmcs = power4_enable_pmcs; 252 ppc_md.enable_pmcs = power4_enable_pmcs;
@@ -262,53 +262,6 @@ static int __init pSeries_init_panel(void)
262} 262}
263arch_initcall(pSeries_init_panel); 263arch_initcall(pSeries_init_panel);
264 264
265
266/* Build up the ppc64_firmware_features bitmask field
267 * using contents of device-tree/ibm,hypertas-functions.
268 * Ultimately this functionality may be moved into prom.c prom_init().
269 */
270static void __init fw_feature_init(void)
271{
272 struct device_node * dn;
273 char * hypertas;
274 unsigned int len;
275
276 DBG(" -> fw_feature_init()\n");
277
278 ppc64_firmware_features = 0;
279 dn = of_find_node_by_path("/rtas");
280 if (dn == NULL) {
281 printk(KERN_ERR "WARNING ! Cannot find RTAS in device-tree !\n");
282 goto no_rtas;
283 }
284
285 hypertas = get_property(dn, "ibm,hypertas-functions", &len);
286 if (hypertas) {
287 while (len > 0){
288 int i, hypertas_len;
289 /* check value against table of strings */
290 for(i=0; i < FIRMWARE_MAX_FEATURES ;i++) {
291 if ((firmware_features_table[i].name) &&
292 (strcmp(firmware_features_table[i].name,hypertas))==0) {
293 /* we have a match */
294 ppc64_firmware_features |=
295 (firmware_features_table[i].val);
296 break;
297 }
298 }
299 hypertas_len = strlen(hypertas);
300 len -= hypertas_len +1;
301 hypertas+= hypertas_len +1;
302 }
303 }
304
305 of_node_put(dn);
306no_rtas:
307
308 DBG(" <- fw_feature_init()\n");
309}
310
311
312static void __init pSeries_discover_pic(void) 265static void __init pSeries_discover_pic(void)
313{ 266{
314 struct device_node *np; 267 struct device_node *np;
@@ -367,21 +320,16 @@ static int pseries_set_xdabr(unsigned long dabr)
367 */ 320 */
368static void __init pSeries_init_early(void) 321static void __init pSeries_init_early(void)
369{ 322{
370 int iommu_off = 0;
371
372 DBG(" -> pSeries_init_early()\n"); 323 DBG(" -> pSeries_init_early()\n");
373 324
374 fw_feature_init(); 325 fw_feature_init();
375 326
376 if (platform_is_lpar()) 327 if (firmware_has_feature(FW_FEATURE_LPAR))
377 hpte_init_lpar(); 328 hpte_init_lpar();
378 else { 329 else
379 hpte_init_native(); 330 hpte_init_native();
380 iommu_off = (of_chosen &&
381 get_property(of_chosen, "linux,iommu-off", NULL));
382 }
383 331
384 if (platform_is_lpar()) 332 if (firmware_has_feature(FW_FEATURE_LPAR))
385 find_udbg_vterm(); 333 find_udbg_vterm();
386 334
387 if (firmware_has_feature(FW_FEATURE_DABR)) 335 if (firmware_has_feature(FW_FEATURE_DABR))
@@ -437,6 +385,9 @@ static int __init pSeries_probe(int platform)
437 * it here ... 385 * it here ...
438 */ 386 */
439 387
388 if (platform == PLATFORM_PSERIES_LPAR)
389 ppc64_firmware_features |= FW_FEATURE_LPAR;
390
440 return 1; 391 return 1;
441} 392}
442 393
@@ -576,7 +527,7 @@ static void pseries_shared_idle(void)
576 527
577static int pSeries_pci_probe_mode(struct pci_bus *bus) 528static int pSeries_pci_probe_mode(struct pci_bus *bus)
578{ 529{
579 if (platform_is_lpar()) 530 if (firmware_has_feature(FW_FEATURE_LPAR))
580 return PCI_PROBE_DEVTREE; 531 return PCI_PROBE_DEVTREE;
581 return PCI_PROBE_NORMAL; 532 return PCI_PROBE_NORMAL;
582} 533}
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 8d710af50756..3cf78a6cd27c 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -443,7 +443,7 @@ void __init smp_init_pSeries(void)
443 smp_ops->cpu_die = pSeries_cpu_die; 443 smp_ops->cpu_die = pSeries_cpu_die;
444 444
445 /* Processors can be added/removed only on LPAR */ 445 /* Processors can be added/removed only on LPAR */
446 if (platform_is_lpar()) 446 if (firmware_has_feature(FW_FEATURE_LPAR))
447 pSeries_reconfig_notifier_register(&pSeries_smp_nb); 447 pSeries_reconfig_notifier_register(&pSeries_smp_nb);
448#endif 448#endif
449 449
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index fd823c7c9ac8..eb86cdb9b802 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -20,6 +20,7 @@
20#include <linux/gfp.h> 20#include <linux/gfp.h>
21#include <linux/radix-tree.h> 21#include <linux/radix-tree.h>
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <asm/firmware.h>
23#include <asm/prom.h> 24#include <asm/prom.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/pgtable.h> 26#include <asm/pgtable.h>
@@ -536,7 +537,7 @@ nextnode:
536 of_node_put(np); 537 of_node_put(np);
537 } 538 }
538 539
539 if (platform_is_lpar()) 540 if (firmware_has_feature(FW_FEATURE_LPAR))
540 ops = &pSeriesLP_ops; 541 ops = &pSeriesLP_ops;
541 else { 542 else {
542#ifdef CONFIG_SMP 543#ifdef CONFIG_SMP
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 6298264efe36..61d317428610 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -194,8 +194,6 @@ static int dart_init(struct device_node *dart_node)
194 * prefetching into invalid pages and corrupting data 194 * prefetching into invalid pages and corrupting data
195 */ 195 */
196 tmp = lmb_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE); 196 tmp = lmb_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE);
197 if (!tmp)
198 panic("DART: Cannot allocate spare page!");
199 dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) & 197 dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) &
200 DARTMAP_RPNMASK); 198 DARTMAP_RPNMASK);
201 199
diff --git a/arch/powerpc/sysdev/dcr.S b/arch/powerpc/sysdev/dcr.S
index 895f10243a43..2078f39e2f17 100644
--- a/arch/powerpc/sysdev/dcr.S
+++ b/arch/powerpc/sysdev/dcr.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/dcr.S
3 *
4 * "Indirect" DCR access 2 * "Indirect" DCR access
5 * 3 *
6 * Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net> 4 * Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net>
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 064c9de47732..ceb584682fa3 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -40,7 +40,7 @@ phys_addr_t get_immrbase(void)
40 return immrbase; 40 return immrbase;
41 41
42 soc = of_find_node_by_type(NULL, "soc"); 42 soc = of_find_node_by_type(NULL, "soc");
43 if (soc != 0) { 43 if (soc) {
44 unsigned int size; 44 unsigned int size;
45 void *prop = get_property(soc, "reg", &size); 45 void *prop = get_property(soc, "reg", &size);
46 immrbase = of_translate_address(soc, prop); 46 immrbase = of_translate_address(soc, prop);
@@ -49,21 +49,20 @@ phys_addr_t get_immrbase(void)
49 49
50 return immrbase; 50 return immrbase;
51} 51}
52EXPORT_SYMBOL(get_immrbase);
53 52
54static const char * gfar_tx_intr = "tx"; 53EXPORT_SYMBOL(get_immrbase);
55static const char * gfar_rx_intr = "rx";
56static const char * gfar_err_intr = "error";
57 54
58static int __init gfar_of_init(void) 55static int __init gfar_mdio_of_init(void)
59{ 56{
60 struct device_node *np; 57 struct device_node *np;
61 unsigned int i; 58 unsigned int i;
62 struct platform_device *mdio_dev, *gfar_dev; 59 struct platform_device *mdio_dev;
63 struct resource res; 60 struct resource res;
64 int ret; 61 int ret;
65 62
66 for (np = NULL, i = 0; (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL; i++) { 63 for (np = NULL, i = 0;
64 (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL;
65 i++) {
67 int k; 66 int k;
68 struct device_node *child = NULL; 67 struct device_node *child = NULL;
69 struct gianfar_mdio_data mdio_data; 68 struct gianfar_mdio_data mdio_data;
@@ -73,12 +72,14 @@ static int __init gfar_of_init(void)
73 72
74 ret = of_address_to_resource(np, 0, &res); 73 ret = of_address_to_resource(np, 0, &res);
75 if (ret) 74 if (ret)
76 goto mdio_err; 75 goto err;
77 76
78 mdio_dev = platform_device_register_simple("fsl-gianfar_mdio", res.start, &res, 1); 77 mdio_dev =
78 platform_device_register_simple("fsl-gianfar_mdio",
79 res.start, &res, 1);
79 if (IS_ERR(mdio_dev)) { 80 if (IS_ERR(mdio_dev)) {
80 ret = PTR_ERR(mdio_dev); 81 ret = PTR_ERR(mdio_dev);
81 goto mdio_err; 82 goto err;
82 } 83 }
83 84
84 for (k = 0; k < 32; k++) 85 for (k = 0; k < 32; k++)
@@ -86,17 +87,44 @@ static int __init gfar_of_init(void)
86 87
87 while ((child = of_get_next_child(np, child)) != NULL) { 88 while ((child = of_get_next_child(np, child)) != NULL) {
88 if (child->n_intrs) { 89 if (child->n_intrs) {
89 u32 *id = (u32 *) get_property(child, "reg", NULL); 90 u32 *id =
91 (u32 *) get_property(child, "reg", NULL);
90 mdio_data.irq[*id] = child->intrs[0].line; 92 mdio_data.irq[*id] = child->intrs[0].line;
91 } 93 }
92 } 94 }
93 95
94 ret = platform_device_add_data(mdio_dev, &mdio_data, sizeof(struct gianfar_mdio_data)); 96 ret =
97 platform_device_add_data(mdio_dev, &mdio_data,
98 sizeof(struct gianfar_mdio_data));
95 if (ret) 99 if (ret)
96 goto mdio_unreg; 100 goto unreg;
97 } 101 }
98 102
99 for (np = NULL, i = 0; (np = of_find_compatible_node(np, "network", "gianfar")) != NULL; i++) { 103 return 0;
104
105unreg:
106 platform_device_unregister(mdio_dev);
107err:
108 return ret;
109}
110
111arch_initcall(gfar_mdio_of_init);
112
113static const char *gfar_tx_intr = "tx";
114static const char *gfar_rx_intr = "rx";
115static const char *gfar_err_intr = "error";
116
117static int __init gfar_of_init(void)
118{
119 struct device_node *np;
120 unsigned int i;
121 struct platform_device *gfar_dev;
122 struct resource res;
123 int ret;
124
125 for (np = NULL, i = 0;
126 (np = of_find_compatible_node(np, "network", "gianfar")) != NULL;
127 i++) {
100 struct resource r[4]; 128 struct resource r[4];
101 struct device_node *phy, *mdio; 129 struct device_node *phy, *mdio;
102 struct gianfar_platform_data gfar_data; 130 struct gianfar_platform_data gfar_data;
@@ -110,7 +138,7 @@ static int __init gfar_of_init(void)
110 138
111 ret = of_address_to_resource(np, 0, &r[0]); 139 ret = of_address_to_resource(np, 0, &r[0]);
112 if (ret) 140 if (ret)
113 goto gfar_err; 141 goto err;
114 142
115 r[1].start = np->intrs[0].line; 143 r[1].start = np->intrs[0].line;
116 r[1].end = np->intrs[0].line; 144 r[1].end = np->intrs[0].line;
@@ -133,11 +161,13 @@ static int __init gfar_of_init(void)
133 r[3].flags = IORESOURCE_IRQ; 161 r[3].flags = IORESOURCE_IRQ;
134 } 162 }
135 163
136 gfar_dev = platform_device_register_simple("fsl-gianfar", i, &r[0], np->n_intrs + 1); 164 gfar_dev =
165 platform_device_register_simple("fsl-gianfar", i, &r[0],
166 np->n_intrs + 1);
137 167
138 if (IS_ERR(gfar_dev)) { 168 if (IS_ERR(gfar_dev)) {
139 ret = PTR_ERR(gfar_dev); 169 ret = PTR_ERR(gfar_dev);
140 goto gfar_err; 170 goto err;
141 } 171 }
142 172
143 mac_addr = get_property(np, "address", NULL); 173 mac_addr = get_property(np, "address", NULL);
@@ -145,26 +175,26 @@ static int __init gfar_of_init(void)
145 175
146 if (model && !strcasecmp(model, "TSEC")) 176 if (model && !strcasecmp(model, "TSEC"))
147 gfar_data.device_flags = 177 gfar_data.device_flags =
148 FSL_GIANFAR_DEV_HAS_GIGABIT | 178 FSL_GIANFAR_DEV_HAS_GIGABIT |
149 FSL_GIANFAR_DEV_HAS_COALESCE | 179 FSL_GIANFAR_DEV_HAS_COALESCE |
150 FSL_GIANFAR_DEV_HAS_RMON | 180 FSL_GIANFAR_DEV_HAS_RMON |
151 FSL_GIANFAR_DEV_HAS_MULTI_INTR; 181 FSL_GIANFAR_DEV_HAS_MULTI_INTR;
152 if (model && !strcasecmp(model, "eTSEC")) 182 if (model && !strcasecmp(model, "eTSEC"))
153 gfar_data.device_flags = 183 gfar_data.device_flags =
154 FSL_GIANFAR_DEV_HAS_GIGABIT | 184 FSL_GIANFAR_DEV_HAS_GIGABIT |
155 FSL_GIANFAR_DEV_HAS_COALESCE | 185 FSL_GIANFAR_DEV_HAS_COALESCE |
156 FSL_GIANFAR_DEV_HAS_RMON | 186 FSL_GIANFAR_DEV_HAS_RMON |
157 FSL_GIANFAR_DEV_HAS_MULTI_INTR | 187 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
158 FSL_GIANFAR_DEV_HAS_CSUM | 188 FSL_GIANFAR_DEV_HAS_CSUM |
159 FSL_GIANFAR_DEV_HAS_VLAN | 189 FSL_GIANFAR_DEV_HAS_VLAN |
160 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; 190 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
161 191
162 ph = (phandle *) get_property(np, "phy-handle", NULL); 192 ph = (phandle *) get_property(np, "phy-handle", NULL);
163 phy = of_find_node_by_phandle(*ph); 193 phy = of_find_node_by_phandle(*ph);
164 194
165 if (phy == NULL) { 195 if (phy == NULL) {
166 ret = -ENODEV; 196 ret = -ENODEV;
167 goto gfar_unreg; 197 goto unreg;
168 } 198 }
169 199
170 mdio = of_get_parent(phy); 200 mdio = of_get_parent(phy);
@@ -174,7 +204,7 @@ static int __init gfar_of_init(void)
174 if (ret) { 204 if (ret) {
175 of_node_put(phy); 205 of_node_put(phy);
176 of_node_put(mdio); 206 of_node_put(mdio);
177 goto gfar_unreg; 207 goto unreg;
178 } 208 }
179 209
180 gfar_data.phy_id = *id; 210 gfar_data.phy_id = *id;
@@ -183,23 +213,22 @@ static int __init gfar_of_init(void)
183 of_node_put(phy); 213 of_node_put(phy);
184 of_node_put(mdio); 214 of_node_put(mdio);
185 215
186 ret = platform_device_add_data(gfar_dev, &gfar_data, sizeof(struct gianfar_platform_data)); 216 ret =
217 platform_device_add_data(gfar_dev, &gfar_data,
218 sizeof(struct
219 gianfar_platform_data));
187 if (ret) 220 if (ret)
188 goto gfar_unreg; 221 goto unreg;
189 } 222 }
190 223
191 return 0; 224 return 0;
192 225
193mdio_unreg: 226unreg:
194 platform_device_unregister(mdio_dev);
195mdio_err:
196 return ret;
197
198gfar_unreg:
199 platform_device_unregister(gfar_dev); 227 platform_device_unregister(gfar_dev);
200gfar_err: 228err:
201 return ret; 229 return ret;
202} 230}
231
203arch_initcall(gfar_of_init); 232arch_initcall(gfar_of_init);
204 233
205static int __init fsl_i2c_of_init(void) 234static int __init fsl_i2c_of_init(void)
@@ -209,17 +238,19 @@ static int __init fsl_i2c_of_init(void)
209 struct platform_device *i2c_dev; 238 struct platform_device *i2c_dev;
210 int ret; 239 int ret;
211 240
212 for (np = NULL, i = 0; (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL; i++) { 241 for (np = NULL, i = 0;
242 (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
243 i++) {
213 struct resource r[2]; 244 struct resource r[2];
214 struct fsl_i2c_platform_data i2c_data; 245 struct fsl_i2c_platform_data i2c_data;
215 unsigned char * flags = NULL; 246 unsigned char *flags = NULL;
216 247
217 memset(&r, 0, sizeof(r)); 248 memset(&r, 0, sizeof(r));
218 memset(&i2c_data, 0, sizeof(i2c_data)); 249 memset(&i2c_data, 0, sizeof(i2c_data));
219 250
220 ret = of_address_to_resource(np, 0, &r[0]); 251 ret = of_address_to_resource(np, 0, &r[0]);
221 if (ret) 252 if (ret)
222 goto i2c_err; 253 goto err;
223 254
224 r[1].start = np->intrs[0].line; 255 r[1].start = np->intrs[0].line;
225 r[1].end = np->intrs[0].line; 256 r[1].end = np->intrs[0].line;
@@ -228,7 +259,7 @@ static int __init fsl_i2c_of_init(void)
228 i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); 259 i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
229 if (IS_ERR(i2c_dev)) { 260 if (IS_ERR(i2c_dev)) {
230 ret = PTR_ERR(i2c_dev); 261 ret = PTR_ERR(i2c_dev);
231 goto i2c_err; 262 goto err;
232 } 263 }
233 264
234 i2c_data.device_flags = 0; 265 i2c_data.device_flags = 0;
@@ -240,18 +271,22 @@ static int __init fsl_i2c_of_init(void)
240 if (flags) 271 if (flags)
241 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; 272 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
242 273
243 ret = platform_device_add_data(i2c_dev, &i2c_data, sizeof(struct fsl_i2c_platform_data)); 274 ret =
275 platform_device_add_data(i2c_dev, &i2c_data,
276 sizeof(struct
277 fsl_i2c_platform_data));
244 if (ret) 278 if (ret)
245 goto i2c_unreg; 279 goto unreg;
246 } 280 }
247 281
248 return 0; 282 return 0;
249 283
250i2c_unreg: 284unreg:
251 platform_device_unregister(i2c_dev); 285 platform_device_unregister(i2c_dev);
252i2c_err: 286err:
253 return ret; 287 return ret;
254} 288}
289
255arch_initcall(fsl_i2c_of_init); 290arch_initcall(fsl_i2c_of_init);
256 291
257#ifdef CONFIG_PPC_83xx 292#ifdef CONFIG_PPC_83xx
@@ -267,51 +302,192 @@ static int __init mpc83xx_wdt_init(void)
267 302
268 if (!np) { 303 if (!np) {
269 ret = -ENODEV; 304 ret = -ENODEV;
270 goto mpc83xx_wdt_nodev; 305 goto nodev;
271 } 306 }
272 307
273 soc = of_find_node_by_type(NULL, "soc"); 308 soc = of_find_node_by_type(NULL, "soc");
274 309
275 if (!soc) { 310 if (!soc) {
276 ret = -ENODEV; 311 ret = -ENODEV;
277 goto mpc83xx_wdt_nosoc; 312 goto nosoc;
278 } 313 }
279 314
280 freq = (unsigned int *)get_property(soc, "bus-frequency", NULL); 315 freq = (unsigned int *)get_property(soc, "bus-frequency", NULL);
281 if (!freq) { 316 if (!freq) {
282 ret = -ENODEV; 317 ret = -ENODEV;
283 goto mpc83xx_wdt_err; 318 goto err;
284 } 319 }
285 320
286 memset(&r, 0, sizeof(r)); 321 memset(&r, 0, sizeof(r));
287 322
288 ret = of_address_to_resource(np, 0, &r); 323 ret = of_address_to_resource(np, 0, &r);
289 if (ret) 324 if (ret)
290 goto mpc83xx_wdt_err; 325 goto err;
291 326
292 dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1); 327 dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1);
293 if (IS_ERR(dev)) { 328 if (IS_ERR(dev)) {
294 ret = PTR_ERR(dev); 329 ret = PTR_ERR(dev);
295 goto mpc83xx_wdt_err; 330 goto err;
296 } 331 }
297 332
298 ret = platform_device_add_data(dev, freq, sizeof(int)); 333 ret = platform_device_add_data(dev, freq, sizeof(int));
299 if (ret) 334 if (ret)
300 goto mpc83xx_wdt_unreg; 335 goto unreg;
301 336
302 of_node_put(soc); 337 of_node_put(soc);
303 of_node_put(np); 338 of_node_put(np);
304 339
305 return 0; 340 return 0;
306 341
307mpc83xx_wdt_unreg: 342unreg:
308 platform_device_unregister(dev); 343 platform_device_unregister(dev);
309mpc83xx_wdt_err: 344err:
310 of_node_put(soc); 345 of_node_put(soc);
311mpc83xx_wdt_nosoc: 346nosoc:
312 of_node_put(np); 347 of_node_put(np);
313mpc83xx_wdt_nodev: 348nodev:
314 return ret; 349 return ret;
315} 350}
351
316arch_initcall(mpc83xx_wdt_init); 352arch_initcall(mpc83xx_wdt_init);
317#endif 353#endif
354
355static enum fsl_usb2_phy_modes determine_usb_phy(char * phy_type)
356{
357 if (!phy_type)
358 return FSL_USB2_PHY_NONE;
359 if (!strcasecmp(phy_type, "ulpi"))
360 return FSL_USB2_PHY_ULPI;
361 if (!strcasecmp(phy_type, "utmi"))
362 return FSL_USB2_PHY_UTMI;
363 if (!strcasecmp(phy_type, "utmi_wide"))
364 return FSL_USB2_PHY_UTMI_WIDE;
365 if (!strcasecmp(phy_type, "serial"))
366 return FSL_USB2_PHY_SERIAL;
367
368 return FSL_USB2_PHY_NONE;
369}
370
371static int __init fsl_usb_of_init(void)
372{
373 struct device_node *np;
374 unsigned int i;
375 struct platform_device *usb_dev;
376 int ret;
377
378 for (np = NULL, i = 0;
379 (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL;
380 i++) {
381 struct resource r[2];
382 struct fsl_usb2_platform_data usb_data;
383 unsigned char *prop = NULL;
384
385 memset(&r, 0, sizeof(r));
386 memset(&usb_data, 0, sizeof(usb_data));
387
388 ret = of_address_to_resource(np, 0, &r[0]);
389 if (ret)
390 goto err;
391
392 r[1].start = np->intrs[0].line;
393 r[1].end = np->intrs[0].line;
394 r[1].flags = IORESOURCE_IRQ;
395
396 usb_dev =
397 platform_device_register_simple("fsl-usb2-mph", i, r, 2);
398 if (IS_ERR(usb_dev)) {
399 ret = PTR_ERR(usb_dev);
400 goto err;
401 }
402
403 usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
404 usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
405
406 usb_data.operating_mode = FSL_USB2_MPH_HOST;
407
408 prop = get_property(np, "port0", NULL);
409 if (prop)
410 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
411
412 prop = get_property(np, "port1", NULL);
413 if (prop)
414 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
415
416 prop = get_property(np, "phy_type", NULL);
417 usb_data.phy_mode = determine_usb_phy(prop);
418
419 ret =
420 platform_device_add_data(usb_dev, &usb_data,
421 sizeof(struct
422 fsl_usb2_platform_data));
423 if (ret)
424 goto unreg;
425 }
426
427 return 0;
428
429unreg:
430 platform_device_unregister(usb_dev);
431err:
432 return ret;
433}
434
435arch_initcall(fsl_usb_of_init);
436
437static int __init fsl_usb_dr_of_init(void)
438{
439 struct device_node *np;
440 unsigned int i;
441 struct platform_device *usb_dev;
442 int ret;
443
444 for (np = NULL, i = 0;
445 (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
446 i++) {
447 struct resource r[2];
448 struct fsl_usb2_platform_data usb_data;
449 unsigned char *prop = NULL;
450
451 memset(&r, 0, sizeof(r));
452 memset(&usb_data, 0, sizeof(usb_data));
453
454 ret = of_address_to_resource(np, 0, &r[0]);
455 if (ret)
456 goto err;
457
458 r[1].start = np->intrs[0].line;
459 r[1].end = np->intrs[0].line;
460 r[1].flags = IORESOURCE_IRQ;
461
462 usb_dev =
463 platform_device_register_simple("fsl-usb2-dr", i, r, 2);
464 if (IS_ERR(usb_dev)) {
465 ret = PTR_ERR(usb_dev);
466 goto err;
467 }
468
469 usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
470 usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
471
472 usb_data.operating_mode = FSL_USB2_DR_HOST;
473
474 prop = get_property(np, "phy_type", NULL);
475 usb_data.phy_mode = determine_usb_phy(prop);
476
477 ret =
478 platform_device_add_data(usb_dev, &usb_data,
479 sizeof(struct
480 fsl_usb2_platform_data));
481 if (ret)
482 goto unreg;
483 }
484
485 return 0;
486
487unreg:
488 platform_device_unregister(usb_dev);
489err:
490 return ret;
491}
492
493arch_initcall(fsl_usb_dr_of_init);
diff --git a/arch/powerpc/sysdev/ipic.h b/arch/powerpc/sysdev/ipic.h
index a7ce7da8785c..a60c9d18bb7f 100644
--- a/arch/powerpc/sysdev/ipic.h
+++ b/arch/powerpc/sysdev/ipic.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ipic.h
3 *
4 * IPIC private definitions and structure. 2 * IPIC private definitions and structure.
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 7d02fa2a8990..4735b41c113c 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -191,6 +191,7 @@ Commands:\n\
191 di dump instructions\n\ 191 di dump instructions\n\
192 df dump float values\n\ 192 df dump float values\n\
193 dd dump double values\n\ 193 dd dump double values\n\
194 dr dump stream of raw bytes\n\
194 e print exception information\n\ 195 e print exception information\n\
195 f flush cache\n\ 196 f flush cache\n\
196 la lookup symbol+offset of specified address\n\ 197 la lookup symbol+offset of specified address\n\
@@ -1938,6 +1939,28 @@ bsesc(void)
1938 return c; 1939 return c;
1939} 1940}
1940 1941
1942static void xmon_rawdump (unsigned long adrs, long ndump)
1943{
1944 long n, m, r, nr;
1945 unsigned char temp[16];
1946
1947 for (n = ndump; n > 0;) {
1948 r = n < 16? n: 16;
1949 nr = mread(adrs, temp, r);
1950 adrs += nr;
1951 for (m = 0; m < r; ++m) {
1952 if (m < nr)
1953 printf("%.2x", temp[m]);
1954 else
1955 printf("%s", fault_chars[fault_type]);
1956 }
1957 n -= r;
1958 if (nr < r)
1959 break;
1960 }
1961 printf("\n");
1962}
1963
1941#define isxdigit(c) (('0' <= (c) && (c) <= '9') \ 1964#define isxdigit(c) (('0' <= (c) && (c) <= '9') \
1942 || ('a' <= (c) && (c) <= 'f') \ 1965 || ('a' <= (c) && (c) <= 'f') \
1943 || ('A' <= (c) && (c) <= 'F')) 1966 || ('A' <= (c) && (c) <= 'F'))
@@ -1960,6 +1983,13 @@ dump(void)
1960 nidump = MAX_DUMP; 1983 nidump = MAX_DUMP;
1961 adrs += ppc_inst_dump(adrs, nidump, 1); 1984 adrs += ppc_inst_dump(adrs, nidump, 1);
1962 last_cmd = "di\n"; 1985 last_cmd = "di\n";
1986 } else if (c == 'r') {
1987 scanhex(&ndump);
1988 if (ndump == 0)
1989 ndump = 64;
1990 xmon_rawdump(adrs, ndump);
1991 adrs += ndump;
1992 last_cmd = "dr\n";
1963 } else { 1993 } else {
1964 scanhex(&ndump); 1994 scanhex(&ndump);
1965 if (ndump == 0) 1995 if (ndump == 0)
diff --git a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
index 8ace2a1f3b48..98b25fa0049a 100644
--- a/arch/ppc/4xx_io/serial_sicc.c
+++ b/arch/ppc/4xx_io/serial_sicc.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/4xx_io/serial_sicc.c
3 *
4 * Driver for IBM STB3xxx SICC serial port 2 * Driver for IBM STB3xxx SICC serial port
5 * 3 *
6 * Based on drivers/char/serial_amba.c, by ARM Ltd. 4 * Based on drivers/char/serial_amba.c, by ARM Ltd.
@@ -1639,9 +1637,8 @@ static struct SICC_info *siccuart_get(int line)
1639 state->count++; 1637 state->count++;
1640 if (state->info) 1638 if (state->info)
1641 return state->info; 1639 return state->info;
1642 info = kmalloc(sizeof(struct SICC_info), GFP_KERNEL); 1640 info = kzalloc(sizeof(struct SICC_info), GFP_KERNEL);
1643 if (info) { 1641 if (info) {
1644 memset(info, 0, sizeof(struct SICC_info));
1645 init_waitqueue_head(&info->open_wait); 1642 init_waitqueue_head(&info->open_wait);
1646 init_waitqueue_head(&info->close_wait); 1643 init_waitqueue_head(&info->close_wait);
1647 init_waitqueue_head(&info->delta_msr_wait); 1644 init_waitqueue_head(&info->delta_msr_wait);
diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index 579cd40258b9..12b84ca51327 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -73,7 +73,7 @@ cpm_mask_irq(unsigned int irq)
73{ 73{
74 int cpm_vec = irq - CPM_IRQ_OFFSET; 74 int cpm_vec = irq - CPM_IRQ_OFFSET;
75 75
76 out_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, in_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr) & ~(1 << cpm_vec)); 76 clrbits32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, (1 << cpm_vec));
77} 77}
78 78
79static void 79static void
@@ -81,7 +81,7 @@ cpm_unmask_irq(unsigned int irq)
81{ 81{
82 int cpm_vec = irq - CPM_IRQ_OFFSET; 82 int cpm_vec = irq - CPM_IRQ_OFFSET;
83 83
84 out_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, in_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr) | (1 << cpm_vec)); 84 setbits32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, (1 << cpm_vec));
85} 85}
86 86
87static void 87static void
@@ -198,7 +198,7 @@ cpm_interrupt_init(void)
198 if (setup_irq(CPM_IRQ_OFFSET + CPMVEC_ERROR, &cpm_error_irqaction)) 198 if (setup_irq(CPM_IRQ_OFFSET + CPMVEC_ERROR, &cpm_error_irqaction))
199 panic("Could not allocate CPM error IRQ!"); 199 panic("Could not allocate CPM error IRQ!");
200 200
201 out_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr, in_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr) | CICR_IEN); 201 setbits32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr, CICR_IEN);
202} 202}
203 203
204/* 204/*
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 11899f06bf06..54a0a9bb12dd 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -481,6 +481,53 @@ config WINCEPT
481 481
482endchoice 482endchoice
483 483
484menu "Freescale Ethernet driver platform-specific options"
485 depends on FS_ENET
486
487 config MPC8xx_SECOND_ETH
488 bool "Second Ethernet channel"
489 depends on (MPC885ADS || MPC86XADS)
490 default y
491 help
492 This enables support for second Ethernet on MPC885ADS and MPC86xADS boards.
493 The latter will use SCC1, for 885ADS you can select it below.
494
495 choice
496 prompt "Second Ethernet channel"
497 depends on MPC8xx_SECOND_ETH
498 default MPC8xx_SECOND_ETH_FEC2
499
500 config MPC8xx_SECOND_ETH_FEC2
501 bool "FEC2"
502 depends on MPC885ADS
503 help
504 Enable FEC2 to serve as 2-nd Ethernet channel. Note that SMC2
505 (often 2-nd UART) will not work if this is enabled.
506
507 config MPC8xx_SECOND_ETH_SCC1
508 bool "SCC1"
509 depends on MPC86XADS
510 select MPC8xx_SCC_ENET_FIXED
511 help
512 Enable SCC1 to serve as 2-nd Ethernet channel. Note that SMC1
513 (often 1-nd UART) will not work if this is enabled.
514
515 config MPC8xx_SECOND_ETH_SCC3
516 bool "SCC3"
517 depends on MPC885ADS
518 help
519 Enable SCC3 to serve as 2-nd Ethernet channel. Note that SMC1
520 (often 1-nd UART) will not work if this is enabled.
521
522 endchoice
523
524 config MPC8xx_SCC_ENET_FIXED
525 depends on MPC8xx_SECOND_ETH_SCC
526 default n
527 bool "Use fixed MII-less mode for SCC Ethernet"
528
529endmenu
530
484choice 531choice
485 prompt "Machine Type" 532 prompt "Machine Type"
486 depends on 6xx || POWER3 533 depends on 6xx || POWER3
diff --git a/arch/ppc/Kconfig.debug b/arch/ppc/Kconfig.debug
index 61653cb60c4e..8cc75abf3d83 100644
--- a/arch/ppc/Kconfig.debug
+++ b/arch/ppc/Kconfig.debug
@@ -67,7 +67,7 @@ config SERIAL_TEXT_DEBUG
67 67
68config PPC_OCP 68config PPC_OCP
69 bool 69 bool
70 depends on IBM_OCP || XILINX_OCP 70 depends on IBM_OCP
71 default y 71 default y
72 72
73endmenu 73endmenu
diff --git a/arch/ppc/amiga/amiints.c b/arch/ppc/amiga/amiints.c
index 5f35cf3986f7..b2bba052ab93 100644
--- a/arch/ppc/amiga/amiints.c
+++ b/arch/ppc/amiga/amiints.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * arch/ppc/amiga/amiints.c -- Amiga Linux interrupt handling code 2 * Amiga Linux interrupt handling code
3 * 3 *
4 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive 5 * License. See the file COPYING in the main directory of this archive
diff --git a/arch/ppc/amiga/bootinfo.c b/arch/ppc/amiga/bootinfo.c
index e2e965661d03..efd869a3ed9b 100644
--- a/arch/ppc/amiga/bootinfo.c
+++ b/arch/ppc/amiga/bootinfo.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/amiga/bootinfo.c
3 *
4 * Extracted from arch/m68k/kernel/setup.c. 2 * Extracted from arch/m68k/kernel/setup.c.
5 * Should be properly generalized and put somewhere else. 3 * Should be properly generalized and put somewhere else.
6 * Jesper 4 * Jesper
diff --git a/arch/ppc/amiga/cia.c b/arch/ppc/amiga/cia.c
index 4431c58f611a..9558f2f40e64 100644
--- a/arch/ppc/amiga/cia.c
+++ b/arch/ppc/amiga/cia.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/amiga/cia.c - CIA support
3 *
4 * Copyright (C) 1996 Roman Zippel 2 * Copyright (C) 1996 Roman Zippel
5 * 3 *
6 * The concept of some functions bases on the original Amiga OS function 4 * The concept of some functions bases on the original Amiga OS function
diff --git a/arch/ppc/amiga/config.c b/arch/ppc/amiga/config.c
index 60e2da1c92c0..bbe47c9bd707 100644
--- a/arch/ppc/amiga/config.c
+++ b/arch/ppc/amiga/config.c
@@ -1,8 +1,6 @@
1#define m68k_debug_device debug_device 1#define m68k_debug_device debug_device
2 2
3/* 3/*
4 * arch/ppc/amiga/config.c
5 *
6 * Copyright (C) 1993 Hamish Macdonald 4 * Copyright (C) 1993 Hamish Macdonald
7 * 5 *
8 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
diff --git a/arch/ppc/amiga/ints.c b/arch/ppc/amiga/ints.c
index 5d318e498f06..083a17462190 100644
--- a/arch/ppc/amiga/ints.c
+++ b/arch/ppc/amiga/ints.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/amiga/ints.c
3 *
4 * Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c 2 * Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c
5 * Needed to drive the m68k emulating IRQ hardware on the PowerUp boards. 3 * Needed to drive the m68k emulating IRQ hardware on the PowerUp boards.
6 */ 4 */
diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile
index efd8ce515d5f..f565699a9fe0 100644
--- a/arch/ppc/boot/Makefile
+++ b/arch/ppc/boot/Makefile
@@ -1,6 +1,3 @@
1#
2# arch/ppc/boot/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public 1# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 2# License. See the file "COPYING" in the main directory of this archive
6# for more details. 3# for more details.
diff --git a/arch/ppc/boot/common/Makefile b/arch/ppc/boot/common/Makefile
index f88d647d5dd4..a2e85e3beb88 100644
--- a/arch/ppc/boot/common/Makefile
+++ b/arch/ppc/boot/common/Makefile
@@ -1,6 +1,3 @@
1#
2# arch/ppc/boot/common/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public 1# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 2# License. See the file "COPYING" in the main directory of this archive
6# for more details. 3# for more details.
diff --git a/arch/ppc/boot/common/bootinfo.c b/arch/ppc/boot/common/bootinfo.c
index 9c6e528940e9..f4dc9b9fab9c 100644
--- a/arch/ppc/boot/common/bootinfo.c
+++ b/arch/ppc/boot/common/bootinfo.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/common/bootinfo.c
3 *
4 * General bootinfo record utilities 2 * General bootinfo record utilities
5 * Author: Randy Vinson <rvinson@mvista.com> 3 * Author: Randy Vinson <rvinson@mvista.com>
6 * 4 *
diff --git a/arch/ppc/boot/common/misc-common.c b/arch/ppc/boot/common/misc-common.c
index e79e6b3f276e..073830a8559a 100644
--- a/arch/ppc/boot/common/misc-common.c
+++ b/arch/ppc/boot/common/misc-common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/common/misc-common.c
3 *
4 * Misc. bootloader code (almost) all platforms can use 2 * Misc. bootloader code (almost) all platforms can use
5 * 3 *
6 * Author: Johnnie Peters <jpeters@mvista.com> 4 * Author: Johnnie Peters <jpeters@mvista.com>
diff --git a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c
index 26818bbb6cff..4f00c93ac870 100644
--- a/arch/ppc/boot/common/ns16550.c
+++ b/arch/ppc/boot/common/ns16550.c
@@ -8,6 +8,9 @@
8#include <linux/serial_reg.h> 8#include <linux/serial_reg.h>
9#include <asm/serial.h> 9#include <asm/serial.h>
10 10
11#if defined(CONFIG_XILINX_VIRTEX)
12#include <platforms/4xx/xparameters/xparameters.h>
13#endif
11#include "nonstdio.h" 14#include "nonstdio.h"
12#include "serial.h" 15#include "serial.h"
13 16
diff --git a/arch/ppc/boot/common/serial_stub.c b/arch/ppc/boot/common/serial_stub.c
index 03dfaa01fa63..5cc9ae66a8ba 100644
--- a/arch/ppc/boot/common/serial_stub.c
+++ b/arch/ppc/boot/common/serial_stub.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/common/serial_stub.c
3 *
4 * This is a few stub routines to make the boot code cleaner looking when 2 * This is a few stub routines to make the boot code cleaner looking when
5 * there is no serial port support doesn't need to be closed, for example. 3 * there is no serial port support doesn't need to be closed, for example.
6 * 4 *
diff --git a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S
index 368ec035e6cd..0c5e43c4ae06 100644
--- a/arch/ppc/boot/common/util.S
+++ b/arch/ppc/boot/common/util.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/common/util.S
3 *
4 * Useful bootup functions, which are more easily done in asm than C. 2 * Useful bootup functions, which are more easily done in asm than C.
5 * 3 *
6 * NOTE: Be very very careful about the registers you use here. 4 * NOTE: Be very very careful about the registers you use here.
diff --git a/arch/ppc/boot/include/mpc10x.h b/arch/ppc/boot/include/mpc10x.h
index 6cd40ecabc74..6e5d540d8d3e 100644
--- a/arch/ppc/boot/include/mpc10x.h
+++ b/arch/ppc/boot/include/mpc10x.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/include/mpc10.h
3 *
4 * Common defines for the Motorola SPS MPC106/8240/107 Host bridge/Mem 2 * Common defines for the Motorola SPS MPC106/8240/107 Host bridge/Mem
5 * ctrl/EPIC/etc. 3 * ctrl/EPIC/etc.
6 * 4 *
diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
index 9533f8de238f..28be01b99c44 100644
--- a/arch/ppc/boot/simple/Makefile
+++ b/arch/ppc/boot/simple/Makefile
@@ -192,6 +192,7 @@ boot-$(CONFIG_8xx) += embed_config.o
192boot-$(CONFIG_8260) += embed_config.o 192boot-$(CONFIG_8260) += embed_config.o
193boot-$(CONFIG_EP405) += embed_config.o 193boot-$(CONFIG_EP405) += embed_config.o
194boot-$(CONFIG_XILINX_ML300) += embed_config.o 194boot-$(CONFIG_XILINX_ML300) += embed_config.o
195boot-$(CONFIG_XILINX_ML403) += embed_config.o
195boot-$(CONFIG_BSEIP) += iic.o 196boot-$(CONFIG_BSEIP) += iic.o
196boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o 197boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o
197boot-$(CONFIG_MV64X60) += misc-mv64x60.o 198boot-$(CONFIG_MV64X60) += misc-mv64x60.o
diff --git a/arch/ppc/boot/simple/cpc700_memory.c b/arch/ppc/boot/simple/cpc700_memory.c
index 8c75cf6c2383..d75420a45a59 100644
--- a/arch/ppc/boot/simple/cpc700_memory.c
+++ b/arch/ppc/boot/simple/cpc700_memory.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/common/cpc700_memory.c
3 *
4 * Find memory based upon settings in the CPC700 bridge 2 * Find memory based upon settings in the CPC700 bridge
5 * 3 *
6 * Author: Dan Cox 4 * Author: Dan Cox
diff --git a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c
index 491a691d10cc..3a51b1062940 100644
--- a/arch/ppc/boot/simple/embed_config.c
+++ b/arch/ppc/boot/simple/embed_config.c
@@ -21,6 +21,9 @@
21#ifdef CONFIG_40x 21#ifdef CONFIG_40x
22#include <asm/io.h> 22#include <asm/io.h>
23#endif 23#endif
24#ifdef CONFIG_XILINX_VIRTEX
25#include <platforms/4xx/xparameters/xparameters.h>
26#endif
24extern unsigned long timebase_period_ns; 27extern unsigned long timebase_period_ns;
25 28
26/* For those boards that don't provide one. 29/* For those boards that don't provide one.
@@ -742,7 +745,7 @@ embed_config(bd_t **bdp)
742} 745}
743#endif /* WILLOW */ 746#endif /* WILLOW */
744 747
745#ifdef CONFIG_XILINX_ML300 748#if defined(CONFIG_XILINX_ML300) || defined(CONFIG_XILINX_ML403)
746void 749void
747embed_config(bd_t ** bdp) 750embed_config(bd_t ** bdp)
748{ 751{
@@ -779,7 +782,7 @@ embed_config(bd_t ** bdp)
779 timebase_period_ns = 1000000000 / bd->bi_tbfreq; 782 timebase_period_ns = 1000000000 / bd->bi_tbfreq;
780 /* see bi_tbfreq definition in arch/ppc/platforms/4xx/xilinx_ml300.h */ 783 /* see bi_tbfreq definition in arch/ppc/platforms/4xx/xilinx_ml300.h */
781} 784}
782#endif /* CONFIG_XILINX_ML300 */ 785#endif /* CONFIG_XILINX_ML300 || CONFIG_XILINX_ML403 */
783 786
784#ifdef CONFIG_IBM_OPENBIOS 787#ifdef CONFIG_IBM_OPENBIOS
785/* This could possibly work for all treeboot roms. 788/* This could possibly work for all treeboot roms.
diff --git a/arch/ppc/boot/simple/head.S b/arch/ppc/boot/simple/head.S
index 5e4adc298bf9..160da1006ff8 100644
--- a/arch/ppc/boot/simple/head.S
+++ b/arch/ppc/boot/simple/head.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/head.S
3 *
4 * Initial board bringup code for many different boards. 2 * Initial board bringup code for many different boards.
5 * 3 *
6 * Author: Tom Rini 4 * Author: Tom Rini
@@ -65,6 +63,13 @@ start_:
65 */ 63 */
66#endif 64#endif
67 65
66#if defined(CONFIG_XILINX_VIRTEX_4_FX)
67 /* PPC errata 213: only for Virtex-4 FX */
68 mfccr0 0
69 oris 0,0,0x50000000@h
70 mtccr0 0
71#endif
72
68 mflr r3 /* Save our actual starting address. */ 73 mflr r3 /* Save our actual starting address. */
69 74
70 /* The following functions we call must not modify r3 or r4..... 75 /* The following functions we call must not modify r3 or r4.....
diff --git a/arch/ppc/boot/simple/misc-chestnut.c b/arch/ppc/boot/simple/misc-chestnut.c
index 0dce7f3557e4..b94e142ad892 100644
--- a/arch/ppc/boot/simple/misc-chestnut.c
+++ b/arch/ppc/boot/simple/misc-chestnut.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-chestnut.c
3 *
4 * Setup for the IBM Chestnut (ibm-750fxgx_eval) 2 * Setup for the IBM Chestnut (ibm-750fxgx_eval)
5 * 3 *
6 * Author: Mark A. Greer <mgreer@mvista.com> 4 * Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-cpci690.c b/arch/ppc/boot/simple/misc-cpci690.c
index 26860300fa09..8a8614d11a32 100644
--- a/arch/ppc/boot/simple/misc-cpci690.c
+++ b/arch/ppc/boot/simple/misc-cpci690.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-cpci690.c
3 *
4 * Add birec data for Force CPCI690 board. 2 * Add birec data for Force CPCI690 board.
5 * 3 *
6 * Author: Mark A. Greer <source@mvista.com> 4 * Author: Mark A. Greer <source@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-ev64260.c b/arch/ppc/boot/simple/misc-ev64260.c
index 52ece6937a7a..2678c224af22 100644
--- a/arch/ppc/boot/simple/misc-ev64260.c
+++ b/arch/ppc/boot/simple/misc-ev64260.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-ev64260.c
3 *
4 * Host bridge init code for the Marvell/Galileo EV-64260-BP evaluation board 2 * Host bridge init code for the Marvell/Galileo EV-64260-BP evaluation board
5 * with a GT64260 onboard. 3 * with a GT64260 onboard.
6 * 4 *
diff --git a/arch/ppc/boot/simple/misc-ev64360.c b/arch/ppc/boot/simple/misc-ev64360.c
index cd1ccf2a1582..a212b5b988cb 100644
--- a/arch/ppc/boot/simple/misc-ev64360.c
+++ b/arch/ppc/boot/simple/misc-ev64360.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-ev64360.c
3 * Copyright (C) 2005 Lee Nicks <allinux@gmail.com> 2 * Copyright (C) 2005 Lee Nicks <allinux@gmail.com>
4 * 3 *
5 * Based on arch/ppc/boot/simple/misc-katana.c from: 4 * Based on arch/ppc/boot/simple/misc-katana.c from:
diff --git a/arch/ppc/boot/simple/misc-katana.c b/arch/ppc/boot/simple/misc-katana.c
index ec94a11bacac..d97f2ee6f04e 100644
--- a/arch/ppc/boot/simple/misc-katana.c
+++ b/arch/ppc/boot/simple/misc-katana.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-katana.c
3 *
4 * Set up MPSC values to bootwrapper can prompt user. 2 * Set up MPSC values to bootwrapper can prompt user.
5 * 3 *
6 * Author: Mark A. Greer <source@mvista.com> 4 * Author: Mark A. Greer <source@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-mv64x60.c b/arch/ppc/boot/simple/misc-mv64x60.c
index 258d4599fadc..71ff20fd494a 100644
--- a/arch/ppc/boot/simple/misc-mv64x60.c
+++ b/arch/ppc/boot/simple/misc-mv64x60.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-mv64x60.c
3 *
4 * Relocate bridge's register base and call board specific routine. 2 * Relocate bridge's register base and call board specific routine.
5 * 3 *
6 * Author: Mark A. Greer <source@mvista.com> 4 * Author: Mark A. Greer <source@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-prep.c b/arch/ppc/boot/simple/misc-prep.c
index 75380ac41669..63def9d13d70 100644
--- a/arch/ppc/boot/simple/misc-prep.c
+++ b/arch/ppc/boot/simple/misc-prep.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-prep.c
3 *
4 * Maintainer: Tom Rini <trini@kernel.crashing.org> 2 * Maintainer: Tom Rini <trini@kernel.crashing.org>
5 * 3 *
6 * In the past: Gary Thomas, Cort Dougan <cort@cs.nmt.edu> 4 * In the past: Gary Thomas, Cort Dougan <cort@cs.nmt.edu>
diff --git a/arch/ppc/boot/simple/misc-radstone_ppc7d.c b/arch/ppc/boot/simple/misc-radstone_ppc7d.c
index 569e0d4feeaf..0f302ea9c3d1 100644
--- a/arch/ppc/boot/simple/misc-radstone_ppc7d.c
+++ b/arch/ppc/boot/simple/misc-radstone_ppc7d.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/misc-radstone_ppc7d.c
3 *
4 * Misc data for Radstone PPC7D board. 2 * Misc data for Radstone PPC7D board.
5 * 3 *
6 * Author: James Chapman <jchapman@katalix.com> 4 * Author: James Chapman <jchapman@katalix.com>
diff --git a/arch/ppc/boot/simple/misc-spruce.c b/arch/ppc/boot/simple/misc-spruce.c
index d012c39278fd..0cad2f557a1e 100644
--- a/arch/ppc/boot/simple/misc-spruce.c
+++ b/arch/ppc/boot/simple/misc-spruce.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/spruce/misc.c
3 *
4 * Misc. bootloader code for IBM Spruce reference platform 2 * Misc. bootloader code for IBM Spruce reference platform
5 * 3 *
6 * Authors: Johnnie Peters <jpeters@mvista.com> 4 * Authors: Johnnie Peters <jpeters@mvista.com>
diff --git a/arch/ppc/boot/simple/misc.c b/arch/ppc/boot/simple/misc.c
index f415d6c62362..3d78571ad945 100644
--- a/arch/ppc/boot/simple/misc.c
+++ b/arch/ppc/boot/simple/misc.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/simple/misc.c
3 *
4 * Misc. bootloader code for many machines. This assumes you have are using 2 * Misc. bootloader code for many machines. This assumes you have are using
5 * a 6xx/7xx/74xx CPU in your machine. This assumes the chunk of memory 3 * a 6xx/7xx/74xx CPU in your machine. This assumes the chunk of memory
6 * below 8MB is free. Finally, it assumes you have a NS16550-style uart for 4 * below 8MB is free. Finally, it assumes you have a NS16550-style uart for
diff --git a/arch/ppc/boot/simple/mpc10x_memory.c b/arch/ppc/boot/simple/mpc10x_memory.c
index 20d92a34ceb8..c24290823f7f 100644
--- a/arch/ppc/boot/simple/mpc10x_memory.c
+++ b/arch/ppc/boot/simple/mpc10x_memory.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/common/mpc10x_common.c
3 *
4 * A routine to find out how much memory the machine has. 2 * A routine to find out how much memory the machine has.
5 * 3 *
6 * Based on: 4 * Based on:
diff --git a/arch/ppc/boot/simple/mpc52xx_tty.c b/arch/ppc/boot/simple/mpc52xx_tty.c
index 3acc6b7c0727..1964493cf3bd 100644
--- a/arch/ppc/boot/simple/mpc52xx_tty.c
+++ b/arch/ppc/boot/simple/mpc52xx_tty.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/mpc52xx_tty.c
3 *
4 * Minimal serial functions needed to send messages out a MPC52xx 2 * Minimal serial functions needed to send messages out a MPC52xx
5 * Programmable Serial Controller (PSC). 3 * Programmable Serial Controller (PSC).
6 * 4 *
diff --git a/arch/ppc/boot/simple/mv64x60_tty.c b/arch/ppc/boot/simple/mv64x60_tty.c
index b9c24d4c738b..0c52f5c784a2 100644
--- a/arch/ppc/boot/simple/mv64x60_tty.c
+++ b/arch/ppc/boot/simple/mv64x60_tty.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/mv64x60_tty.c
3 *
4 * Bootloader version of the embedded MPSC/UART driver for the Marvell 64x60. 2 * Bootloader version of the embedded MPSC/UART driver for the Marvell 64x60.
5 * Note: Due to a GT64260A erratum, DMA will be used for UART input (via SDMA). 3 * Note: Due to a GT64260A erratum, DMA will be used for UART input (via SDMA).
6 * 4 *
diff --git a/arch/ppc/boot/simple/openbios.c b/arch/ppc/boot/simple/openbios.c
index 81f11d8b30a7..3f2ed53f793a 100644
--- a/arch/ppc/boot/simple/openbios.c
+++ b/arch/ppc/boot/simple/openbios.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/openbios.c
3 *
4 * Copyright (c) 2005 DENX Software Engineering 2 * Copyright (c) 2005 DENX Software Engineering
5 * Stefan Roese <sr@denx.de> 3 * Stefan Roese <sr@denx.de>
6 * 4 *
diff --git a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S
index 555a216ccc49..7efddc507564 100644
--- a/arch/ppc/boot/simple/relocate.S
+++ b/arch/ppc/boot/simple/relocate.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/simple/relocate.S
3 *
4 * This is the common part of the loader relocation and initialization 2 * This is the common part of the loader relocation and initialization
5 * process. All of the board/processor specific initialization is 3 * process. All of the board/processor specific initialization is
6 * done before we get here. 4 * done before we get here.
diff --git a/arch/ppc/boot/utils/mkbugboot.c b/arch/ppc/boot/utils/mkbugboot.c
index 886122283f39..29115e01f60a 100644
--- a/arch/ppc/boot/utils/mkbugboot.c
+++ b/arch/ppc/boot/utils/mkbugboot.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/boot/utils/mkbugboot.c
3 *
4 * Makes a Motorola PPCBUG ROM bootable image which can be flashed 2 * Makes a Motorola PPCBUG ROM bootable image which can be flashed
5 * into one of the FLASH banks on a Motorola PowerPlus board. 3 * into one of the FLASH banks on a Motorola PowerPlus board.
6 * 4 *
diff --git a/arch/ppc/configs/ml300_defconfig b/arch/ppc/configs/ml300_defconfig
new file mode 100644
index 000000000000..4a33aca948cc
--- /dev/null
+++ b/arch/ppc/configs/ml300_defconfig
@@ -0,0 +1,739 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16-rc1
4# Wed Jan 18 00:49:20 2006
5#
6CONFIG_MMU=y
7CONFIG_GENERIC_HARDIRQS=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_PPC=y
11CONFIG_PPC32=y
12CONFIG_GENERIC_NVRAM=y
13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15
16#
17# Code maturity level options
18#
19CONFIG_EXPERIMENTAL=y
20CONFIG_CLEAN_COMPILE=y
21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
23
24#
25# General setup
26#
27CONFIG_LOCALVERSION=""
28CONFIG_LOCALVERSION_AUTO=y
29# CONFIG_SWAP is not set
30CONFIG_SYSVIPC=y
31# CONFIG_POSIX_MQUEUE is not set
32CONFIG_BSD_PROCESS_ACCT=y
33CONFIG_BSD_PROCESS_ACCT_V3=y
34CONFIG_SYSCTL=y
35# CONFIG_AUDIT is not set
36# CONFIG_IKCONFIG is not set
37CONFIG_INITRAMFS_SOURCE=""
38CONFIG_CC_OPTIMIZE_FOR_SIZE=y
39# CONFIG_EMBEDDED is not set
40CONFIG_KALLSYMS=y
41# CONFIG_KALLSYMS_ALL is not set
42# CONFIG_KALLSYMS_EXTRA_PASS is not set
43CONFIG_HOTPLUG=y
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_ELF_CORE=y
47CONFIG_BASE_FULL=y
48CONFIG_FUTEX=y
49CONFIG_EPOLL=y
50CONFIG_SHMEM=y
51CONFIG_CC_ALIGN_FUNCTIONS=0
52CONFIG_CC_ALIGN_LABELS=0
53CONFIG_CC_ALIGN_LOOPS=0
54CONFIG_CC_ALIGN_JUMPS=0
55CONFIG_SLAB=y
56# CONFIG_TINY_SHMEM is not set
57CONFIG_BASE_SMALL=0
58# CONFIG_SLOB is not set
59
60#
61# Loadable module support
62#
63CONFIG_MODULES=y
64CONFIG_MODULE_UNLOAD=y
65CONFIG_MODULE_FORCE_UNLOAD=y
66CONFIG_OBSOLETE_MODPARM=y
67CONFIG_MODVERSIONS=y
68CONFIG_MODULE_SRCVERSION_ALL=y
69CONFIG_KMOD=y
70
71#
72# Block layer
73#
74CONFIG_LBD=y
75
76#
77# IO Schedulers
78#
79CONFIG_IOSCHED_NOOP=y
80CONFIG_IOSCHED_AS=y
81CONFIG_IOSCHED_DEADLINE=y
82CONFIG_IOSCHED_CFQ=y
83CONFIG_DEFAULT_AS=y
84# CONFIG_DEFAULT_DEADLINE is not set
85# CONFIG_DEFAULT_CFQ is not set
86# CONFIG_DEFAULT_NOOP is not set
87CONFIG_DEFAULT_IOSCHED="anticipatory"
88
89#
90# Processor
91#
92# CONFIG_6xx is not set
93CONFIG_40x=y
94# CONFIG_44x is not set
95# CONFIG_POWER3 is not set
96# CONFIG_8xx is not set
97# CONFIG_E200 is not set
98# CONFIG_E500 is not set
99# CONFIG_MATH_EMULATION is not set
100# CONFIG_KEXEC is not set
101# CONFIG_CPU_FREQ is not set
102CONFIG_4xx=y
103# CONFIG_WANT_EARLY_SERIAL is not set
104
105#
106# IBM 4xx options
107#
108# CONFIG_BUBINGA is not set
109# CONFIG_CPCI405 is not set
110# CONFIG_EP405 is not set
111# CONFIG_REDWOOD_5 is not set
112# CONFIG_REDWOOD_6 is not set
113# CONFIG_SYCAMORE is not set
114# CONFIG_WALNUT is not set
115CONFIG_XILINX_ML300=y
116CONFIG_IBM405_ERR77=y
117CONFIG_IBM405_ERR51=y
118CONFIG_XILINX_VIRTEX=y
119CONFIG_EMBEDDEDBOOT=y
120# CONFIG_PPC4xx_DMA is not set
121CONFIG_PPC_GEN550=y
122CONFIG_UART0_TTYS0=y
123# CONFIG_UART0_TTYS1 is not set
124CONFIG_NOT_COHERENT_CACHE=y
125
126#
127# Platform options
128#
129# CONFIG_PC_KEYBOARD is not set
130# CONFIG_HIGHMEM is not set
131# CONFIG_HZ_100 is not set
132CONFIG_HZ_250=y
133# CONFIG_HZ_1000 is not set
134CONFIG_HZ=250
135CONFIG_PREEMPT_NONE=y
136# CONFIG_PREEMPT_VOLUNTARY is not set
137# CONFIG_PREEMPT is not set
138CONFIG_SELECT_MEMORY_MODEL=y
139CONFIG_FLATMEM_MANUAL=y
140# CONFIG_DISCONTIGMEM_MANUAL is not set
141# CONFIG_SPARSEMEM_MANUAL is not set
142CONFIG_FLATMEM=y
143CONFIG_FLAT_NODE_MEM_MAP=y
144# CONFIG_SPARSEMEM_STATIC is not set
145CONFIG_SPLIT_PTLOCK_CPUS=4
146CONFIG_BINFMT_ELF=y
147# CONFIG_BINFMT_MISC is not set
148CONFIG_CMDLINE_BOOL=y
149CONFIG_CMDLINE="console=ttyS0,9600"
150# CONFIG_PM is not set
151# CONFIG_SOFTWARE_SUSPEND is not set
152CONFIG_SECCOMP=y
153CONFIG_ISA_DMA_API=y
154
155#
156# Bus options
157#
158# CONFIG_PPC_I8259 is not set
159# CONFIG_PCI is not set
160# CONFIG_PCI_DOMAINS is not set
161
162#
163# PCCARD (PCMCIA/CardBus) support
164#
165# CONFIG_PCCARD is not set
166
167#
168# Advanced setup
169#
170# CONFIG_ADVANCED_OPTIONS is not set
171
172#
173# Default settings for advanced configuration options are used
174#
175CONFIG_HIGHMEM_START=0xfe000000
176CONFIG_LOWMEM_SIZE=0x30000000
177CONFIG_KERNEL_START=0xc0000000
178CONFIG_TASK_SIZE=0x80000000
179CONFIG_CONSISTENT_START=0xff100000
180CONFIG_CONSISTENT_SIZE=0x00200000
181CONFIG_BOOT_LOAD=0x00400000
182
183#
184# Networking
185#
186CONFIG_NET=y
187
188#
189# Networking options
190#
191CONFIG_PACKET=y
192CONFIG_PACKET_MMAP=y
193CONFIG_UNIX=y
194# CONFIG_NET_KEY is not set
195CONFIG_INET=y
196# CONFIG_IP_MULTICAST is not set
197# CONFIG_IP_ADVANCED_ROUTER is not set
198CONFIG_IP_FIB_HASH=y
199CONFIG_IP_PNP=y
200CONFIG_IP_PNP_DHCP=y
201# CONFIG_IP_PNP_BOOTP is not set
202# CONFIG_IP_PNP_RARP is not set
203# CONFIG_NET_IPIP is not set
204# CONFIG_NET_IPGRE is not set
205# CONFIG_ARPD is not set
206# CONFIG_SYN_COOKIES is not set
207# CONFIG_INET_AH is not set
208# CONFIG_INET_ESP is not set
209# CONFIG_INET_IPCOMP is not set
210# CONFIG_INET_TUNNEL is not set
211CONFIG_INET_DIAG=y
212CONFIG_INET_TCP_DIAG=y
213# CONFIG_TCP_CONG_ADVANCED is not set
214CONFIG_TCP_CONG_BIC=y
215# CONFIG_IPV6 is not set
216# CONFIG_NETFILTER is not set
217
218#
219# DCCP Configuration (EXPERIMENTAL)
220#
221# CONFIG_IP_DCCP is not set
222
223#
224# SCTP Configuration (EXPERIMENTAL)
225#
226# CONFIG_IP_SCTP is not set
227# CONFIG_ATM is not set
228# CONFIG_BRIDGE is not set
229# CONFIG_VLAN_8021Q is not set
230# CONFIG_DECNET is not set
231# CONFIG_LLC2 is not set
232# CONFIG_IPX is not set
233# CONFIG_ATALK is not set
234# CONFIG_X25 is not set
235# CONFIG_LAPB is not set
236
237#
238# TIPC Configuration (EXPERIMENTAL)
239#
240# CONFIG_TIPC is not set
241# CONFIG_NET_DIVERT is not set
242# CONFIG_ECONET is not set
243# CONFIG_WAN_ROUTER is not set
244
245#
246# QoS and/or fair queueing
247#
248# CONFIG_NET_SCHED is not set
249
250#
251# Network testing
252#
253# CONFIG_NET_PKTGEN is not set
254# CONFIG_HAMRADIO is not set
255# CONFIG_IRDA is not set
256# CONFIG_BT is not set
257# CONFIG_IEEE80211 is not set
258
259#
260# Device Drivers
261#
262
263#
264# Generic Driver Options
265#
266CONFIG_STANDALONE=y
267CONFIG_PREVENT_FIRMWARE_BUILD=y
268# CONFIG_FW_LOADER is not set
269# CONFIG_DEBUG_DRIVER is not set
270
271#
272# Connector - unified userspace <-> kernelspace linker
273#
274# CONFIG_CONNECTOR is not set
275
276#
277# Memory Technology Devices (MTD)
278#
279# CONFIG_MTD is not set
280
281#
282# Parallel port support
283#
284# CONFIG_PARPORT is not set
285
286#
287# Plug and Play support
288#
289
290#
291# Block devices
292#
293# CONFIG_BLK_DEV_FD is not set
294# CONFIG_BLK_DEV_COW_COMMON is not set
295# CONFIG_BLK_DEV_LOOP is not set
296# CONFIG_BLK_DEV_NBD is not set
297CONFIG_BLK_DEV_RAM=y
298CONFIG_BLK_DEV_RAM_COUNT=16
299CONFIG_BLK_DEV_RAM_SIZE=65536
300CONFIG_BLK_DEV_INITRD=y
301# CONFIG_CDROM_PKTCDVD is not set
302# CONFIG_ATA_OVER_ETH is not set
303
304#
305# ATA/ATAPI/MFM/RLL support
306#
307# CONFIG_IDE is not set
308
309#
310# SCSI device support
311#
312# CONFIG_RAID_ATTRS is not set
313# CONFIG_SCSI is not set
314
315#
316# Multi-device support (RAID and LVM)
317#
318# CONFIG_MD is not set
319
320#
321# Fusion MPT device support
322#
323# CONFIG_FUSION is not set
324
325#
326# IEEE 1394 (FireWire) support
327#
328
329#
330# I2O device support
331#
332
333#
334# Macintosh device drivers
335#
336# CONFIG_WINDFARM is not set
337
338#
339# Network device support
340#
341CONFIG_NETDEVICES=y
342# CONFIG_DUMMY is not set
343# CONFIG_BONDING is not set
344# CONFIG_EQUALIZER is not set
345CONFIG_TUN=y
346
347#
348# PHY device support
349#
350
351#
352# Ethernet (10 or 100Mbit)
353#
354# CONFIG_NET_ETHERNET is not set
355# CONFIG_IBM_EMAC is not set
356
357#
358# Ethernet (1000 Mbit)
359#
360
361#
362# Ethernet (10000 Mbit)
363#
364
365#
366# Token Ring devices
367#
368
369#
370# Wireless LAN (non-hamradio)
371#
372# CONFIG_NET_RADIO is not set
373
374#
375# Wan interfaces
376#
377# CONFIG_WAN is not set
378# CONFIG_PPP is not set
379# CONFIG_SLIP is not set
380# CONFIG_SHAPER is not set
381# CONFIG_NETCONSOLE is not set
382# CONFIG_NETPOLL is not set
383# CONFIG_NET_POLL_CONTROLLER is not set
384
385#
386# ISDN subsystem
387#
388# CONFIG_ISDN is not set
389
390#
391# Telephony Support
392#
393# CONFIG_PHONE is not set
394
395#
396# Input device support
397#
398CONFIG_INPUT=y
399
400#
401# Userland interfaces
402#
403CONFIG_INPUT_MOUSEDEV=y
404# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
405CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
406CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
407# CONFIG_INPUT_JOYDEV is not set
408# CONFIG_INPUT_TSDEV is not set
409# CONFIG_INPUT_EVDEV is not set
410# CONFIG_INPUT_EVBUG is not set
411
412#
413# Input Device Drivers
414#
415# CONFIG_INPUT_KEYBOARD is not set
416# CONFIG_INPUT_MOUSE is not set
417# CONFIG_INPUT_JOYSTICK is not set
418# CONFIG_INPUT_TOUCHSCREEN is not set
419# CONFIG_INPUT_MISC is not set
420
421#
422# Hardware I/O ports
423#
424# CONFIG_SERIO is not set
425# CONFIG_GAMEPORT is not set
426
427#
428# Character devices
429#
430CONFIG_VT=y
431CONFIG_VT_CONSOLE=y
432CONFIG_HW_CONSOLE=y
433# CONFIG_SERIAL_NONSTANDARD is not set
434
435#
436# Serial drivers
437#
438CONFIG_SERIAL_8250=y
439CONFIG_SERIAL_8250_CONSOLE=y
440CONFIG_SERIAL_8250_NR_UARTS=4
441CONFIG_SERIAL_8250_RUNTIME_UARTS=4
442# CONFIG_SERIAL_8250_EXTENDED is not set
443
444#
445# Non-8250 serial port support
446#
447CONFIG_SERIAL_CORE=y
448CONFIG_SERIAL_CORE_CONSOLE=y
449CONFIG_UNIX98_PTYS=y
450# CONFIG_LEGACY_PTYS is not set
451
452#
453# IPMI
454#
455# CONFIG_IPMI_HANDLER is not set
456
457#
458# Watchdog Cards
459#
460# CONFIG_WATCHDOG is not set
461# CONFIG_NVRAM is not set
462# CONFIG_GEN_RTC is not set
463# CONFIG_DTLK is not set
464# CONFIG_R3964 is not set
465
466#
467# Ftape, the floppy tape device driver
468#
469# CONFIG_AGP is not set
470# CONFIG_RAW_DRIVER is not set
471
472#
473# TPM devices
474#
475# CONFIG_TCG_TPM is not set
476# CONFIG_TELCLOCK is not set
477
478#
479# I2C support
480#
481# CONFIG_I2C is not set
482
483#
484# SPI support
485#
486# CONFIG_SPI is not set
487# CONFIG_SPI_MASTER is not set
488
489#
490# Dallas's 1-wire bus
491#
492# CONFIG_W1 is not set
493
494#
495# Hardware Monitoring support
496#
497# CONFIG_HWMON is not set
498# CONFIG_HWMON_VID is not set
499
500#
501# Misc devices
502#
503
504#
505# Multimedia Capabilities Port drivers
506#
507
508#
509# Multimedia devices
510#
511# CONFIG_VIDEO_DEV is not set
512
513#
514# Digital Video Broadcasting Devices
515#
516# CONFIG_DVB is not set
517
518#
519# Graphics support
520#
521# CONFIG_FB is not set
522
523#
524# Console display driver support
525#
526CONFIG_DUMMY_CONSOLE=y
527
528#
529# Sound
530#
531# CONFIG_SOUND is not set
532
533#
534# USB support
535#
536# CONFIG_USB_ARCH_HAS_HCD is not set
537# CONFIG_USB_ARCH_HAS_OHCI is not set
538
539#
540# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
541#
542
543#
544# USB Gadget Support
545#
546# CONFIG_USB_GADGET is not set
547
548#
549# MMC/SD Card support
550#
551# CONFIG_MMC is not set
552
553#
554# InfiniBand support
555#
556
557#
558# SN Devices
559#
560
561#
562# File systems
563#
564CONFIG_EXT2_FS=y
565# CONFIG_EXT2_FS_XATTR is not set
566# CONFIG_EXT2_FS_XIP is not set
567# CONFIG_EXT3_FS is not set
568# CONFIG_REISERFS_FS is not set
569# CONFIG_JFS_FS is not set
570# CONFIG_FS_POSIX_ACL is not set
571# CONFIG_XFS_FS is not set
572# CONFIG_OCFS2_FS is not set
573# CONFIG_MINIX_FS is not set
574# CONFIG_ROMFS_FS is not set
575CONFIG_INOTIFY=y
576# CONFIG_QUOTA is not set
577CONFIG_DNOTIFY=y
578# CONFIG_AUTOFS_FS is not set
579# CONFIG_AUTOFS4_FS is not set
580# CONFIG_FUSE_FS is not set
581
582#
583# CD-ROM/DVD Filesystems
584#
585# CONFIG_ISO9660_FS is not set
586# CONFIG_UDF_FS is not set
587
588#
589# DOS/FAT/NT Filesystems
590#
591CONFIG_FAT_FS=y
592CONFIG_MSDOS_FS=y
593CONFIG_VFAT_FS=y
594CONFIG_FAT_DEFAULT_CODEPAGE=437
595CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
596# CONFIG_NTFS_FS is not set
597
598#
599# Pseudo filesystems
600#
601CONFIG_PROC_FS=y
602CONFIG_PROC_KCORE=y
603CONFIG_SYSFS=y
604CONFIG_TMPFS=y
605# CONFIG_HUGETLB_PAGE is not set
606CONFIG_RAMFS=y
607# CONFIG_RELAYFS_FS is not set
608# CONFIG_CONFIGFS_FS is not set
609
610#
611# Miscellaneous filesystems
612#
613# CONFIG_ADFS_FS is not set
614# CONFIG_AFFS_FS is not set
615# CONFIG_HFS_FS is not set
616# CONFIG_HFSPLUS_FS is not set
617# CONFIG_BEFS_FS is not set
618# CONFIG_BFS_FS is not set
619# CONFIG_EFS_FS is not set
620# CONFIG_CRAMFS is not set
621# CONFIG_VXFS_FS is not set
622# CONFIG_HPFS_FS is not set
623# CONFIG_QNX4FS_FS is not set
624# CONFIG_SYSV_FS is not set
625# CONFIG_UFS_FS is not set
626
627#
628# Network File Systems
629#
630# CONFIG_NFS_FS is not set
631# CONFIG_NFSD is not set
632# CONFIG_SMB_FS is not set
633# CONFIG_CIFS is not set
634# CONFIG_NCP_FS is not set
635# CONFIG_CODA_FS is not set
636# CONFIG_AFS_FS is not set
637# CONFIG_9P_FS is not set
638
639#
640# Partition Types
641#
642# CONFIG_PARTITION_ADVANCED is not set
643CONFIG_MSDOS_PARTITION=y
644
645#
646# Native Language Support
647#
648CONFIG_NLS=y
649CONFIG_NLS_DEFAULT="iso8859-1"
650CONFIG_NLS_CODEPAGE_437=y
651# CONFIG_NLS_CODEPAGE_737 is not set
652# CONFIG_NLS_CODEPAGE_775 is not set
653# CONFIG_NLS_CODEPAGE_850 is not set
654# CONFIG_NLS_CODEPAGE_852 is not set
655# CONFIG_NLS_CODEPAGE_855 is not set
656# CONFIG_NLS_CODEPAGE_857 is not set
657# CONFIG_NLS_CODEPAGE_860 is not set
658# CONFIG_NLS_CODEPAGE_861 is not set
659# CONFIG_NLS_CODEPAGE_862 is not set
660# CONFIG_NLS_CODEPAGE_863 is not set
661# CONFIG_NLS_CODEPAGE_864 is not set
662# CONFIG_NLS_CODEPAGE_865 is not set
663# CONFIG_NLS_CODEPAGE_866 is not set
664# CONFIG_NLS_CODEPAGE_869 is not set
665# CONFIG_NLS_CODEPAGE_936 is not set
666# CONFIG_NLS_CODEPAGE_950 is not set
667# CONFIG_NLS_CODEPAGE_932 is not set
668# CONFIG_NLS_CODEPAGE_949 is not set
669# CONFIG_NLS_CODEPAGE_874 is not set
670# CONFIG_NLS_ISO8859_8 is not set
671# CONFIG_NLS_CODEPAGE_1250 is not set
672# CONFIG_NLS_CODEPAGE_1251 is not set
673CONFIG_NLS_ASCII=y
674CONFIG_NLS_ISO8859_1=y
675# CONFIG_NLS_ISO8859_2 is not set
676# CONFIG_NLS_ISO8859_3 is not set
677# CONFIG_NLS_ISO8859_4 is not set
678# CONFIG_NLS_ISO8859_5 is not set
679# CONFIG_NLS_ISO8859_6 is not set
680# CONFIG_NLS_ISO8859_7 is not set
681# CONFIG_NLS_ISO8859_9 is not set
682# CONFIG_NLS_ISO8859_13 is not set
683# CONFIG_NLS_ISO8859_14 is not set
684# CONFIG_NLS_ISO8859_15 is not set
685# CONFIG_NLS_KOI8_R is not set
686# CONFIG_NLS_KOI8_U is not set
687CONFIG_NLS_UTF8=y
688
689#
690# IBM 40x options
691#
692
693#
694# Library routines
695#
696# CONFIG_CRC_CCITT is not set
697# CONFIG_CRC16 is not set
698CONFIG_CRC32=y
699# CONFIG_LIBCRC32C is not set
700# CONFIG_PROFILING is not set
701
702#
703# Kernel hacking
704#
705CONFIG_PRINTK_TIME=y
706CONFIG_MAGIC_SYSRQ=y
707CONFIG_DEBUG_KERNEL=y
708CONFIG_LOG_BUF_SHIFT=14
709CONFIG_DETECT_SOFTLOCKUP=y
710# CONFIG_SCHEDSTATS is not set
711# CONFIG_DEBUG_SLAB is not set
712CONFIG_DEBUG_MUTEXES=y
713# CONFIG_DEBUG_SPINLOCK is not set
714# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
715# CONFIG_DEBUG_KOBJECT is not set
716CONFIG_DEBUG_INFO=y
717# CONFIG_DEBUG_FS is not set
718# CONFIG_DEBUG_VM is not set
719CONFIG_FORCED_INLINING=y
720# CONFIG_RCU_TORTURE_TEST is not set
721# CONFIG_KGDB is not set
722CONFIG_XMON=y
723# CONFIG_BDI_SWITCH is not set
724# CONFIG_SERIAL_TEXT_DEBUG is not set
725
726#
727# Security options
728#
729# CONFIG_KEYS is not set
730# CONFIG_SECURITY is not set
731
732#
733# Cryptographic options
734#
735# CONFIG_CRYPTO is not set
736
737#
738# Hardware crypto devices
739#
diff --git a/arch/ppc/configs/ml403_defconfig b/arch/ppc/configs/ml403_defconfig
new file mode 100644
index 000000000000..fafd2516fa51
--- /dev/null
+++ b/arch/ppc/configs/ml403_defconfig
@@ -0,0 +1,740 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16-rc1
4# Wed Jan 18 01:11:41 2006
5#
6CONFIG_MMU=y
7CONFIG_GENERIC_HARDIRQS=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_PPC=y
11CONFIG_PPC32=y
12CONFIG_GENERIC_NVRAM=y
13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15
16#
17# Code maturity level options
18#
19CONFIG_EXPERIMENTAL=y
20CONFIG_CLEAN_COMPILE=y
21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
23
24#
25# General setup
26#
27CONFIG_LOCALVERSION=""
28CONFIG_LOCALVERSION_AUTO=y
29# CONFIG_SWAP is not set
30CONFIG_SYSVIPC=y
31# CONFIG_POSIX_MQUEUE is not set
32CONFIG_BSD_PROCESS_ACCT=y
33CONFIG_BSD_PROCESS_ACCT_V3=y
34CONFIG_SYSCTL=y
35# CONFIG_AUDIT is not set
36# CONFIG_IKCONFIG is not set
37CONFIG_INITRAMFS_SOURCE=""
38CONFIG_CC_OPTIMIZE_FOR_SIZE=y
39# CONFIG_EMBEDDED is not set
40CONFIG_KALLSYMS=y
41# CONFIG_KALLSYMS_ALL is not set
42# CONFIG_KALLSYMS_EXTRA_PASS is not set
43CONFIG_HOTPLUG=y
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_ELF_CORE=y
47CONFIG_BASE_FULL=y
48CONFIG_FUTEX=y
49CONFIG_EPOLL=y
50CONFIG_SHMEM=y
51CONFIG_CC_ALIGN_FUNCTIONS=0
52CONFIG_CC_ALIGN_LABELS=0
53CONFIG_CC_ALIGN_LOOPS=0
54CONFIG_CC_ALIGN_JUMPS=0
55CONFIG_SLAB=y
56# CONFIG_TINY_SHMEM is not set
57CONFIG_BASE_SMALL=0
58# CONFIG_SLOB is not set
59
60#
61# Loadable module support
62#
63CONFIG_MODULES=y
64CONFIG_MODULE_UNLOAD=y
65CONFIG_MODULE_FORCE_UNLOAD=y
66CONFIG_OBSOLETE_MODPARM=y
67CONFIG_MODVERSIONS=y
68CONFIG_MODULE_SRCVERSION_ALL=y
69CONFIG_KMOD=y
70
71#
72# Block layer
73#
74CONFIG_LBD=y
75
76#
77# IO Schedulers
78#
79CONFIG_IOSCHED_NOOP=y
80CONFIG_IOSCHED_AS=y
81CONFIG_IOSCHED_DEADLINE=y
82CONFIG_IOSCHED_CFQ=y
83CONFIG_DEFAULT_AS=y
84# CONFIG_DEFAULT_DEADLINE is not set
85# CONFIG_DEFAULT_CFQ is not set
86# CONFIG_DEFAULT_NOOP is not set
87CONFIG_DEFAULT_IOSCHED="anticipatory"
88
89#
90# Processor
91#
92# CONFIG_6xx is not set
93CONFIG_40x=y
94# CONFIG_44x is not set
95# CONFIG_POWER3 is not set
96# CONFIG_8xx is not set
97# CONFIG_E200 is not set
98# CONFIG_E500 is not set
99# CONFIG_MATH_EMULATION is not set
100# CONFIG_KEXEC is not set
101# CONFIG_CPU_FREQ is not set
102CONFIG_4xx=y
103# CONFIG_WANT_EARLY_SERIAL is not set
104
105#
106# IBM 4xx options
107#
108# CONFIG_BUBINGA is not set
109# CONFIG_CPCI405 is not set
110# CONFIG_EP405 is not set
111# CONFIG_REDWOOD_5 is not set
112# CONFIG_REDWOOD_6 is not set
113# CONFIG_SYCAMORE is not set
114# CONFIG_WALNUT is not set
115# CONFIG_XILINX_ML300 is not set
116CONFIG_XILINX_ML403=y
117CONFIG_IBM405_ERR77=y
118CONFIG_IBM405_ERR51=y
119CONFIG_XILINX_VIRTEX=y
120CONFIG_EMBEDDEDBOOT=y
121# CONFIG_PPC4xx_DMA is not set
122CONFIG_PPC_GEN550=y
123CONFIG_UART0_TTYS0=y
124# CONFIG_UART0_TTYS1 is not set
125CONFIG_NOT_COHERENT_CACHE=y
126
127#
128# Platform options
129#
130# CONFIG_PC_KEYBOARD is not set
131# CONFIG_HIGHMEM is not set
132# CONFIG_HZ_100 is not set
133CONFIG_HZ_250=y
134# CONFIG_HZ_1000 is not set
135CONFIG_HZ=250
136CONFIG_PREEMPT_NONE=y
137# CONFIG_PREEMPT_VOLUNTARY is not set
138# CONFIG_PREEMPT is not set
139CONFIG_SELECT_MEMORY_MODEL=y
140CONFIG_FLATMEM_MANUAL=y
141# CONFIG_DISCONTIGMEM_MANUAL is not set
142# CONFIG_SPARSEMEM_MANUAL is not set
143CONFIG_FLATMEM=y
144CONFIG_FLAT_NODE_MEM_MAP=y
145# CONFIG_SPARSEMEM_STATIC is not set
146CONFIG_SPLIT_PTLOCK_CPUS=4
147CONFIG_BINFMT_ELF=y
148# CONFIG_BINFMT_MISC is not set
149CONFIG_CMDLINE_BOOL=y
150CONFIG_CMDLINE="console=ttyS0,9600"
151# CONFIG_PM is not set
152# CONFIG_SOFTWARE_SUSPEND is not set
153CONFIG_SECCOMP=y
154CONFIG_ISA_DMA_API=y
155
156#
157# Bus options
158#
159# CONFIG_PPC_I8259 is not set
160# CONFIG_PCI is not set
161# CONFIG_PCI_DOMAINS is not set
162
163#
164# PCCARD (PCMCIA/CardBus) support
165#
166# CONFIG_PCCARD is not set
167
168#
169# Advanced setup
170#
171# CONFIG_ADVANCED_OPTIONS is not set
172
173#
174# Default settings for advanced configuration options are used
175#
176CONFIG_HIGHMEM_START=0xfe000000
177CONFIG_LOWMEM_SIZE=0x30000000
178CONFIG_KERNEL_START=0xc0000000
179CONFIG_TASK_SIZE=0x80000000
180CONFIG_CONSISTENT_START=0xff100000
181CONFIG_CONSISTENT_SIZE=0x00200000
182CONFIG_BOOT_LOAD=0x00400000
183
184#
185# Networking
186#
187CONFIG_NET=y
188
189#
190# Networking options
191#
192CONFIG_PACKET=y
193CONFIG_PACKET_MMAP=y
194CONFIG_UNIX=y
195# CONFIG_NET_KEY is not set
196CONFIG_INET=y
197# CONFIG_IP_MULTICAST is not set
198# CONFIG_IP_ADVANCED_ROUTER is not set
199CONFIG_IP_FIB_HASH=y
200CONFIG_IP_PNP=y
201CONFIG_IP_PNP_DHCP=y
202# CONFIG_IP_PNP_BOOTP is not set
203# CONFIG_IP_PNP_RARP is not set
204# CONFIG_NET_IPIP is not set
205# CONFIG_NET_IPGRE is not set
206# CONFIG_ARPD is not set
207# CONFIG_SYN_COOKIES is not set
208# CONFIG_INET_AH is not set
209# CONFIG_INET_ESP is not set
210# CONFIG_INET_IPCOMP is not set
211# CONFIG_INET_TUNNEL is not set
212CONFIG_INET_DIAG=y
213CONFIG_INET_TCP_DIAG=y
214# CONFIG_TCP_CONG_ADVANCED is not set
215CONFIG_TCP_CONG_BIC=y
216# CONFIG_IPV6 is not set
217# CONFIG_NETFILTER is not set
218
219#
220# DCCP Configuration (EXPERIMENTAL)
221#
222# CONFIG_IP_DCCP is not set
223
224#
225# SCTP Configuration (EXPERIMENTAL)
226#
227# CONFIG_IP_SCTP is not set
228# CONFIG_ATM is not set
229# CONFIG_BRIDGE is not set
230# CONFIG_VLAN_8021Q is not set
231# CONFIG_DECNET is not set
232# CONFIG_LLC2 is not set
233# CONFIG_IPX is not set
234# CONFIG_ATALK is not set
235# CONFIG_X25 is not set
236# CONFIG_LAPB is not set
237
238#
239# TIPC Configuration (EXPERIMENTAL)
240#
241# CONFIG_TIPC is not set
242# CONFIG_NET_DIVERT is not set
243# CONFIG_ECONET is not set
244# CONFIG_WAN_ROUTER is not set
245
246#
247# QoS and/or fair queueing
248#
249# CONFIG_NET_SCHED is not set
250
251#
252# Network testing
253#
254# CONFIG_NET_PKTGEN is not set
255# CONFIG_HAMRADIO is not set
256# CONFIG_IRDA is not set
257# CONFIG_BT is not set
258# CONFIG_IEEE80211 is not set
259
260#
261# Device Drivers
262#
263
264#
265# Generic Driver Options
266#
267CONFIG_STANDALONE=y
268CONFIG_PREVENT_FIRMWARE_BUILD=y
269# CONFIG_FW_LOADER is not set
270# CONFIG_DEBUG_DRIVER is not set
271
272#
273# Connector - unified userspace <-> kernelspace linker
274#
275# CONFIG_CONNECTOR is not set
276
277#
278# Memory Technology Devices (MTD)
279#
280# CONFIG_MTD is not set
281
282#
283# Parallel port support
284#
285# CONFIG_PARPORT is not set
286
287#
288# Plug and Play support
289#
290
291#
292# Block devices
293#
294# CONFIG_BLK_DEV_FD is not set
295# CONFIG_BLK_DEV_COW_COMMON is not set
296# CONFIG_BLK_DEV_LOOP is not set
297# CONFIG_BLK_DEV_NBD is not set
298CONFIG_BLK_DEV_RAM=y
299CONFIG_BLK_DEV_RAM_COUNT=16
300CONFIG_BLK_DEV_RAM_SIZE=65536
301CONFIG_BLK_DEV_INITRD=y
302# CONFIG_CDROM_PKTCDVD is not set
303# CONFIG_ATA_OVER_ETH is not set
304
305#
306# ATA/ATAPI/MFM/RLL support
307#
308# CONFIG_IDE is not set
309
310#
311# SCSI device support
312#
313# CONFIG_RAID_ATTRS is not set
314# CONFIG_SCSI is not set
315
316#
317# Multi-device support (RAID and LVM)
318#
319# CONFIG_MD is not set
320
321#
322# Fusion MPT device support
323#
324# CONFIG_FUSION is not set
325
326#
327# IEEE 1394 (FireWire) support
328#
329
330#
331# I2O device support
332#
333
334#
335# Macintosh device drivers
336#
337# CONFIG_WINDFARM is not set
338
339#
340# Network device support
341#
342CONFIG_NETDEVICES=y
343# CONFIG_DUMMY is not set
344# CONFIG_BONDING is not set
345# CONFIG_EQUALIZER is not set
346CONFIG_TUN=y
347
348#
349# PHY device support
350#
351
352#
353# Ethernet (10 or 100Mbit)
354#
355# CONFIG_NET_ETHERNET is not set
356# CONFIG_IBM_EMAC is not set
357
358#
359# Ethernet (1000 Mbit)
360#
361
362#
363# Ethernet (10000 Mbit)
364#
365
366#
367# Token Ring devices
368#
369
370#
371# Wireless LAN (non-hamradio)
372#
373# CONFIG_NET_RADIO is not set
374
375#
376# Wan interfaces
377#
378# CONFIG_WAN is not set
379# CONFIG_PPP is not set
380# CONFIG_SLIP is not set
381# CONFIG_SHAPER is not set
382# CONFIG_NETCONSOLE is not set
383# CONFIG_NETPOLL is not set
384# CONFIG_NET_POLL_CONTROLLER is not set
385
386#
387# ISDN subsystem
388#
389# CONFIG_ISDN is not set
390
391#
392# Telephony Support
393#
394# CONFIG_PHONE is not set
395
396#
397# Input device support
398#
399CONFIG_INPUT=y
400
401#
402# Userland interfaces
403#
404CONFIG_INPUT_MOUSEDEV=y
405# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
406CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
407CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
408# CONFIG_INPUT_JOYDEV is not set
409# CONFIG_INPUT_TSDEV is not set
410# CONFIG_INPUT_EVDEV is not set
411# CONFIG_INPUT_EVBUG is not set
412
413#
414# Input Device Drivers
415#
416# CONFIG_INPUT_KEYBOARD is not set
417# CONFIG_INPUT_MOUSE is not set
418# CONFIG_INPUT_JOYSTICK is not set
419# CONFIG_INPUT_TOUCHSCREEN is not set
420# CONFIG_INPUT_MISC is not set
421
422#
423# Hardware I/O ports
424#
425# CONFIG_SERIO is not set
426# CONFIG_GAMEPORT is not set
427
428#
429# Character devices
430#
431CONFIG_VT=y
432CONFIG_VT_CONSOLE=y
433CONFIG_HW_CONSOLE=y
434# CONFIG_SERIAL_NONSTANDARD is not set
435
436#
437# Serial drivers
438#
439CONFIG_SERIAL_8250=y
440CONFIG_SERIAL_8250_CONSOLE=y
441CONFIG_SERIAL_8250_NR_UARTS=4
442CONFIG_SERIAL_8250_RUNTIME_UARTS=4
443# CONFIG_SERIAL_8250_EXTENDED is not set
444
445#
446# Non-8250 serial port support
447#
448CONFIG_SERIAL_CORE=y
449CONFIG_SERIAL_CORE_CONSOLE=y
450CONFIG_UNIX98_PTYS=y
451# CONFIG_LEGACY_PTYS is not set
452
453#
454# IPMI
455#
456# CONFIG_IPMI_HANDLER is not set
457
458#
459# Watchdog Cards
460#
461# CONFIG_WATCHDOG is not set
462# CONFIG_NVRAM is not set
463# CONFIG_GEN_RTC is not set
464# CONFIG_DTLK is not set
465# CONFIG_R3964 is not set
466
467#
468# Ftape, the floppy tape device driver
469#
470# CONFIG_AGP is not set
471# CONFIG_RAW_DRIVER is not set
472
473#
474# TPM devices
475#
476# CONFIG_TCG_TPM is not set
477# CONFIG_TELCLOCK is not set
478
479#
480# I2C support
481#
482# CONFIG_I2C is not set
483
484#
485# SPI support
486#
487# CONFIG_SPI is not set
488# CONFIG_SPI_MASTER is not set
489
490#
491# Dallas's 1-wire bus
492#
493# CONFIG_W1 is not set
494
495#
496# Hardware Monitoring support
497#
498# CONFIG_HWMON is not set
499# CONFIG_HWMON_VID is not set
500
501#
502# Misc devices
503#
504
505#
506# Multimedia Capabilities Port drivers
507#
508
509#
510# Multimedia devices
511#
512# CONFIG_VIDEO_DEV is not set
513
514#
515# Digital Video Broadcasting Devices
516#
517# CONFIG_DVB is not set
518
519#
520# Graphics support
521#
522# CONFIG_FB is not set
523
524#
525# Console display driver support
526#
527CONFIG_DUMMY_CONSOLE=y
528
529#
530# Sound
531#
532# CONFIG_SOUND is not set
533
534#
535# USB support
536#
537# CONFIG_USB_ARCH_HAS_HCD is not set
538# CONFIG_USB_ARCH_HAS_OHCI is not set
539
540#
541# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
542#
543
544#
545# USB Gadget Support
546#
547# CONFIG_USB_GADGET is not set
548
549#
550# MMC/SD Card support
551#
552# CONFIG_MMC is not set
553
554#
555# InfiniBand support
556#
557
558#
559# SN Devices
560#
561
562#
563# File systems
564#
565CONFIG_EXT2_FS=y
566# CONFIG_EXT2_FS_XATTR is not set
567# CONFIG_EXT2_FS_XIP is not set
568# CONFIG_EXT3_FS is not set
569# CONFIG_REISERFS_FS is not set
570# CONFIG_JFS_FS is not set
571# CONFIG_FS_POSIX_ACL is not set
572# CONFIG_XFS_FS is not set
573# CONFIG_OCFS2_FS is not set
574# CONFIG_MINIX_FS is not set
575# CONFIG_ROMFS_FS is not set
576CONFIG_INOTIFY=y
577# CONFIG_QUOTA is not set
578CONFIG_DNOTIFY=y
579# CONFIG_AUTOFS_FS is not set
580# CONFIG_AUTOFS4_FS is not set
581# CONFIG_FUSE_FS is not set
582
583#
584# CD-ROM/DVD Filesystems
585#
586# CONFIG_ISO9660_FS is not set
587# CONFIG_UDF_FS is not set
588
589#
590# DOS/FAT/NT Filesystems
591#
592CONFIG_FAT_FS=y
593CONFIG_MSDOS_FS=y
594CONFIG_VFAT_FS=y
595CONFIG_FAT_DEFAULT_CODEPAGE=437
596CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
597# CONFIG_NTFS_FS is not set
598
599#
600# Pseudo filesystems
601#
602CONFIG_PROC_FS=y
603CONFIG_PROC_KCORE=y
604CONFIG_SYSFS=y
605CONFIG_TMPFS=y
606# CONFIG_HUGETLB_PAGE is not set
607CONFIG_RAMFS=y
608# CONFIG_RELAYFS_FS is not set
609# CONFIG_CONFIGFS_FS is not set
610
611#
612# Miscellaneous filesystems
613#
614# CONFIG_ADFS_FS is not set
615# CONFIG_AFFS_FS is not set
616# CONFIG_HFS_FS is not set
617# CONFIG_HFSPLUS_FS is not set
618# CONFIG_BEFS_FS is not set
619# CONFIG_BFS_FS is not set
620# CONFIG_EFS_FS is not set
621# CONFIG_CRAMFS is not set
622# CONFIG_VXFS_FS is not set
623# CONFIG_HPFS_FS is not set
624# CONFIG_QNX4FS_FS is not set
625# CONFIG_SYSV_FS is not set
626# CONFIG_UFS_FS is not set
627
628#
629# Network File Systems
630#
631# CONFIG_NFS_FS is not set
632# CONFIG_NFSD is not set
633# CONFIG_SMB_FS is not set
634# CONFIG_CIFS is not set
635# CONFIG_NCP_FS is not set
636# CONFIG_CODA_FS is not set
637# CONFIG_AFS_FS is not set
638# CONFIG_9P_FS is not set
639
640#
641# Partition Types
642#
643# CONFIG_PARTITION_ADVANCED is not set
644CONFIG_MSDOS_PARTITION=y
645
646#
647# Native Language Support
648#
649CONFIG_NLS=y
650CONFIG_NLS_DEFAULT="iso8859-1"
651CONFIG_NLS_CODEPAGE_437=y
652# CONFIG_NLS_CODEPAGE_737 is not set
653# CONFIG_NLS_CODEPAGE_775 is not set
654# CONFIG_NLS_CODEPAGE_850 is not set
655# CONFIG_NLS_CODEPAGE_852 is not set
656# CONFIG_NLS_CODEPAGE_855 is not set
657# CONFIG_NLS_CODEPAGE_857 is not set
658# CONFIG_NLS_CODEPAGE_860 is not set
659# CONFIG_NLS_CODEPAGE_861 is not set
660# CONFIG_NLS_CODEPAGE_862 is not set
661# CONFIG_NLS_CODEPAGE_863 is not set
662# CONFIG_NLS_CODEPAGE_864 is not set
663# CONFIG_NLS_CODEPAGE_865 is not set
664# CONFIG_NLS_CODEPAGE_866 is not set
665# CONFIG_NLS_CODEPAGE_869 is not set
666# CONFIG_NLS_CODEPAGE_936 is not set
667# CONFIG_NLS_CODEPAGE_950 is not set
668# CONFIG_NLS_CODEPAGE_932 is not set
669# CONFIG_NLS_CODEPAGE_949 is not set
670# CONFIG_NLS_CODEPAGE_874 is not set
671# CONFIG_NLS_ISO8859_8 is not set
672# CONFIG_NLS_CODEPAGE_1250 is not set
673# CONFIG_NLS_CODEPAGE_1251 is not set
674CONFIG_NLS_ASCII=y
675CONFIG_NLS_ISO8859_1=y
676# CONFIG_NLS_ISO8859_2 is not set
677# CONFIG_NLS_ISO8859_3 is not set
678# CONFIG_NLS_ISO8859_4 is not set
679# CONFIG_NLS_ISO8859_5 is not set
680# CONFIG_NLS_ISO8859_6 is not set
681# CONFIG_NLS_ISO8859_7 is not set
682# CONFIG_NLS_ISO8859_9 is not set
683# CONFIG_NLS_ISO8859_13 is not set
684# CONFIG_NLS_ISO8859_14 is not set
685# CONFIG_NLS_ISO8859_15 is not set
686# CONFIG_NLS_KOI8_R is not set
687# CONFIG_NLS_KOI8_U is not set
688CONFIG_NLS_UTF8=y
689
690#
691# IBM 40x options
692#
693
694#
695# Library routines
696#
697# CONFIG_CRC_CCITT is not set
698# CONFIG_CRC16 is not set
699CONFIG_CRC32=y
700# CONFIG_LIBCRC32C is not set
701# CONFIG_PROFILING is not set
702
703#
704# Kernel hacking
705#
706CONFIG_PRINTK_TIME=y
707CONFIG_MAGIC_SYSRQ=y
708CONFIG_DEBUG_KERNEL=y
709CONFIG_LOG_BUF_SHIFT=14
710CONFIG_DETECT_SOFTLOCKUP=y
711# CONFIG_SCHEDSTATS is not set
712# CONFIG_DEBUG_SLAB is not set
713CONFIG_DEBUG_MUTEXES=y
714# CONFIG_DEBUG_SPINLOCK is not set
715# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
716# CONFIG_DEBUG_KOBJECT is not set
717CONFIG_DEBUG_INFO=y
718# CONFIG_DEBUG_FS is not set
719# CONFIG_DEBUG_VM is not set
720CONFIG_FORCED_INLINING=y
721# CONFIG_RCU_TORTURE_TEST is not set
722# CONFIG_KGDB is not set
723CONFIG_XMON=y
724# CONFIG_BDI_SWITCH is not set
725# CONFIG_SERIAL_TEXT_DEBUG is not set
726
727#
728# Security options
729#
730# CONFIG_KEYS is not set
731# CONFIG_SECURITY is not set
732
733#
734# Cryptographic options
735#
736# CONFIG_CRYPTO is not set
737
738#
739# Hardware crypto devices
740#
diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
index 677c571aa276..0d8b88219d38 100644
--- a/arch/ppc/kernel/head_44x.S
+++ b/arch/ppc/kernel/head_44x.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/head_44x.S
3 *
4 * Kernel execution entry point code. 2 * Kernel execution entry point code.
5 * 3 *
6 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org> 4 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
diff --git a/arch/ppc/kernel/head_8xx.S b/arch/ppc/kernel/head_8xx.S
index c1e89ad0684d..ec53c7d65f2b 100644
--- a/arch/ppc/kernel/head_8xx.S
+++ b/arch/ppc/kernel/head_8xx.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/except_8xx.S
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 4 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
diff --git a/arch/ppc/kernel/head_fsl_booke.S b/arch/ppc/kernel/head_fsl_booke.S
index 8d60fa99fc4b..dd86bbed7627 100644
--- a/arch/ppc/kernel/head_fsl_booke.S
+++ b/arch/ppc/kernel/head_fsl_booke.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/head_fsl_booke.S
3 *
4 * Kernel execution entry point code. 2 * Kernel execution entry point code.
5 * 3 *
6 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org> 4 * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
@@ -316,6 +314,7 @@ skpinv: addi r6,r6,1 /* Increment */
316 */ 314 */
317 lis r2,DBCR0_IDM@h 315 lis r2,DBCR0_IDM@h
318 mtspr SPRN_DBCR0,r2 316 mtspr SPRN_DBCR0,r2
317 isync
319 /* clear any residual debug events */ 318 /* clear any residual debug events */
320 li r2,-1 319 li r2,-1
321 mtspr SPRN_DBSR,r2 320 mtspr SPRN_DBSR,r2
@@ -1002,12 +1001,15 @@ _GLOBAL(giveup_fpu)
1002_GLOBAL(abort) 1001_GLOBAL(abort)
1003 li r13,0 1002 li r13,0
1004 mtspr SPRN_DBCR0,r13 /* disable all debug events */ 1003 mtspr SPRN_DBCR0,r13 /* disable all debug events */
1004 isync
1005 mfmsr r13 1005 mfmsr r13
1006 ori r13,r13,MSR_DE@l /* Enable Debug Events */ 1006 ori r13,r13,MSR_DE@l /* Enable Debug Events */
1007 mtmsr r13 1007 mtmsr r13
1008 isync
1008 mfspr r13,SPRN_DBCR0 1009 mfspr r13,SPRN_DBCR0
1009 lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h 1010 lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h
1010 mtspr SPRN_DBCR0,r13 1011 mtspr SPRN_DBCR0,r13
1012 isync
1011 1013
1012_GLOBAL(set_context) 1014_GLOBAL(set_context)
1013 1015
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index c08ab432e958..53e9deacee82 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -168,9 +168,8 @@ int show_cpuinfo(struct seq_file *m, void *v)
168 /* Show summary information */ 168 /* Show summary information */
169#ifdef CONFIG_SMP 169#ifdef CONFIG_SMP
170 unsigned long bogosum = 0; 170 unsigned long bogosum = 0;
171 for (i = 0; i < NR_CPUS; ++i) 171 for_each_online_cpu(i)
172 if (cpu_online(i)) 172 bogosum += cpu_data[i].loops_per_jiffy;
173 bogosum += cpu_data[i].loops_per_jiffy;
174 seq_printf(m, "total bogomips\t: %lu.%02lu\n", 173 seq_printf(m, "total bogomips\t: %lu.%02lu\n",
175 bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); 174 bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
176#endif /* CONFIG_SMP */ 175#endif /* CONFIG_SMP */
@@ -712,9 +711,8 @@ int __init ppc_init(void)
712 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); 711 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
713 712
714 /* register CPU devices */ 713 /* register CPU devices */
715 for (i = 0; i < NR_CPUS; i++) 714 for_each_cpu(i)
716 if (cpu_possible(i)) 715 register_cpu(&cpu_devices[i], i, NULL);
717 register_cpu(&cpu_devices[i], i, NULL);
718 716
719 /* call platform init */ 717 /* call platform init */
720 if (ppc_md.init != NULL) { 718 if (ppc_md.init != NULL) {
diff --git a/arch/ppc/kernel/smp-tbsync.c b/arch/ppc/kernel/smp-tbsync.c
index 2c9cd95bcea6..6a5694fcc711 100644
--- a/arch/ppc/kernel/smp-tbsync.c
+++ b/arch/ppc/kernel/smp-tbsync.c
@@ -126,8 +126,7 @@ smp_generic_give_timebase( void )
126 printk("Synchronizing timebase\n"); 126 printk("Synchronizing timebase\n");
127 127
128 /* if this fails then this kernel won't work anyway... */ 128 /* if this fails then this kernel won't work anyway... */
129 tbsync = kmalloc( sizeof(*tbsync), GFP_KERNEL ); 129 tbsync = kzalloc( sizeof(*tbsync), GFP_KERNEL );
130 memset( tbsync, 0, sizeof(*tbsync) );
131 mb(); 130 mb();
132 running = 1; 131 running = 1;
133 132
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index 6d0a1838d94c..1c0d68026abd 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/traps.c
3 *
4 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 2 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
5 * 3 *
6 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
diff --git a/arch/ppc/lib/rheap.c b/arch/ppc/lib/rheap.c
index 42c5de2c898f..31e511856dc5 100644
--- a/arch/ppc/lib/rheap.c
+++ b/arch/ppc/lib/rheap.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/rheap.c
3 *
4 * A Remote Heap. Remote means that we don't touch the memory that the 2 * A Remote Heap. Remote means that we don't touch the memory that the
5 * heap points to. Normal heap implementations use the memory they manage 3 * heap points to. Normal heap implementations use the memory they manage
6 * to place their list. We cannot do that because the memory we manage may 4 * to place their list. We cannot do that because the memory we manage may
diff --git a/arch/ppc/math-emu/math.c b/arch/ppc/math-emu/math.c
index b7dff53a7103..589153472761 100644
--- a/arch/ppc/math-emu/math.c
+++ b/arch/ppc/math-emu/math.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/math-emu/math.c
3 *
4 * Copyright (C) 1999 Eddie C. Dost (ecd@atecom.com) 2 * Copyright (C) 1999 Eddie C. Dost (ecd@atecom.com)
5 */ 3 */
6 4
diff --git a/arch/ppc/mm/44x_mmu.c b/arch/ppc/mm/44x_mmu.c
index 3d79ce281b67..e0152a9b26e6 100644
--- a/arch/ppc/mm/44x_mmu.c
+++ b/arch/ppc/mm/44x_mmu.c
@@ -104,7 +104,7 @@ unsigned long __init mmu_mapin_ram(void)
104 104
105 /* Determine number of entries necessary to cover lowmem */ 105 /* Determine number of entries necessary to cover lowmem */
106 pinned_tlbs = (unsigned int) 106 pinned_tlbs = (unsigned int)
107 (_ALIGN(total_lowmem, PPC44x_PIN_SIZE) >> PPC44x_PIN_SHIFT); 107 (_ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT);
108 108
109 /* Write upper watermark to save location */ 109 /* Write upper watermark to save location */
110 tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs; 110 tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
@@ -112,7 +112,7 @@ unsigned long __init mmu_mapin_ram(void)
112 /* If necessary, set additional pinned TLBs */ 112 /* If necessary, set additional pinned TLBs */
113 if (pinned_tlbs > 1) 113 if (pinned_tlbs > 1)
114 for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) { 114 for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) {
115 unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC44x_PIN_SIZE; 115 unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC_PIN_SIZE;
116 ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr); 116 ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr);
117 } 117 }
118 118
diff --git a/arch/ppc/mm/fault.c b/arch/ppc/mm/fault.c
index ee5e9f25baf9..0217188ef465 100644
--- a/arch/ppc/mm/fault.c
+++ b/arch/ppc/mm/fault.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/mm/fault.c
3 *
4 * PowerPC version 2 * PowerPC version
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * 4 *
diff --git a/arch/ppc/mm/hashtable.S b/arch/ppc/mm/hashtable.S
index 3ec87c91343e..f09fa88db35a 100644
--- a/arch/ppc/mm/hashtable.S
+++ b/arch/ppc/mm/hashtable.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/hashtable.S
3 *
4 * $Id: hashtable.S,v 1.6 1999/10/08 01:56:15 paulus Exp $ 2 * $Id: hashtable.S,v 1.6 1999/10/08 01:56:15 paulus Exp $
5 * 3 *
6 * PowerPC version 4 * PowerPC version
diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
index d8837911bbc6..174ddbc9758b 100644
--- a/arch/ppc/platforms/4xx/Kconfig
+++ b/arch/ppc/platforms/4xx/Kconfig
@@ -57,6 +57,10 @@ config XILINX_ML300
57 help 57 help
58 This option enables support for the Xilinx ML300 evaluation board. 58 This option enables support for the Xilinx ML300 evaluation board.
59 59
60config XILINX_ML403
61 bool "Xilinx-ML403"
62 help
63 This option enables support for the Xilinx ML403 evaluation board.
60endchoice 64endchoice
61 65
62choice 66choice
@@ -172,11 +176,6 @@ config IBM_OCP
172 depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || YUCCA || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT 176 depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || YUCCA || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
173 default y 177 default y
174 178
175config XILINX_OCP
176 bool
177 depends on XILINX_ML300
178 default y
179
180config IBM_EMAC4 179config IBM_EMAC4
181 bool 180 bool
182 depends on 440GX || 440SP || 440SPE 181 depends on 440GX || 440SP || 440SPE
@@ -208,11 +207,21 @@ config 405GPR
208 depends on SYCAMORE 207 depends on SYCAMORE
209 default y 208 default y
210 209
211config VIRTEX_II_PRO 210config XILINX_VIRTEX_II_PRO
212 bool 211 bool
213 depends on XILINX_ML300 212 depends on XILINX_ML300
214 default y 213 default y
215 214
215config XILINX_VIRTEX_4_FX
216 bool
217 depends on XILINX_ML403
218 default y
219
220config XILINX_VIRTEX
221 bool
222 depends on XILINX_VIRTEX_II_PRO || XILINX_VIRTEX_4_FX
223 default y
224
216config STB03xxx 225config STB03xxx
217 bool 226 bool
218 depends on REDWOOD_5 || REDWOOD_6 227 depends on REDWOOD_5 || REDWOOD_6
@@ -220,7 +229,7 @@ config STB03xxx
220 229
221config EMBEDDEDBOOT 230config EMBEDDEDBOOT
222 bool 231 bool
223 depends on EP405 || XILINX_ML300 232 depends on EP405 || XILINX_ML300 || XILINX_ML403
224 default y 233 default y
225 234
226config IBM_OPENBIOS 235config IBM_OPENBIOS
diff --git a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
index c9bb61170954..a04a0d0a0f5c 100644
--- a/arch/ppc/platforms/4xx/Makefile
+++ b/arch/ppc/platforms/4xx/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_REDWOOD_6) += redwood6.o
14obj-$(CONFIG_SYCAMORE) += sycamore.o 14obj-$(CONFIG_SYCAMORE) += sycamore.o
15obj-$(CONFIG_WALNUT) += walnut.o 15obj-$(CONFIG_WALNUT) += walnut.o
16obj-$(CONFIG_XILINX_ML300) += xilinx_ml300.o 16obj-$(CONFIG_XILINX_ML300) += xilinx_ml300.o
17obj-$(CONFIG_XILINX_ML403) += xilinx_ml403.o
17 18
18obj-$(CONFIG_405GP) += ibm405gp.o 19obj-$(CONFIG_405GP) += ibm405gp.o
19obj-$(CONFIG_REDWOOD_5) += ibmstb4.o 20obj-$(CONFIG_REDWOOD_5) += ibmstb4.o
@@ -26,4 +27,5 @@ obj-$(CONFIG_440SP) += ibm440sp.o
26obj-$(CONFIG_440SPE) += ppc440spe.o 27obj-$(CONFIG_440SPE) += ppc440spe.o
27obj-$(CONFIG_405EP) += ibm405ep.o 28obj-$(CONFIG_405EP) += ibm405ep.o
28obj-$(CONFIG_405GPR) += ibm405gpr.o 29obj-$(CONFIG_405GPR) += ibm405gpr.o
29obj-$(CONFIG_VIRTEX_II_PRO) += virtex-ii_pro.o 30obj-$(CONFIG_XILINX_VIRTEX) += virtex.o
31
diff --git a/arch/ppc/platforms/4xx/bamboo.c b/arch/ppc/platforms/4xx/bamboo.c
index 0ec53f049338..b940cfd646c2 100644
--- a/arch/ppc/platforms/4xx/bamboo.c
+++ b/arch/ppc/platforms/4xx/bamboo.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/bamboo.c
3 *
4 * Bamboo board specific routines 2 * Bamboo board specific routines
5 * 3 *
6 * Wade Farnsworth <wfarnsworth@mvista.com> 4 * Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/bamboo.h b/arch/ppc/platforms/4xx/bamboo.h
index 5c0192826494..31c0dd6a26cb 100644
--- a/arch/ppc/platforms/4xx/bamboo.h
+++ b/arch/ppc/platforms/4xx/bamboo.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/bamboo.h
3 *
4 * Bamboo board definitions 2 * Bamboo board definitions
5 * 3 *
6 * Wade Farnsworth <wfarnsworth@mvista.com> 4 * Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/bubinga.h b/arch/ppc/platforms/4xx/bubinga.h
index b5380cfaf5c0..606aa9fa5caa 100644
--- a/arch/ppc/platforms/4xx/bubinga.h
+++ b/arch/ppc/platforms/4xx/bubinga.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/bubinga.h
3 *
4 * Bubinga board definitions 2 * Bubinga board definitions
5 * 3 *
6 * Copyright (c) 2005 DENX Software Engineering 4 * Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/4xx/cpci405.c b/arch/ppc/platforms/4xx/cpci405.c
index ff966773a0bf..6571e39fbe48 100644
--- a/arch/ppc/platforms/4xx/cpci405.c
+++ b/arch/ppc/platforms/4xx/cpci405.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/cpci405.c
3 *
4 * Board setup routines for the esd CPCI-405 cPCI Board. 2 * Board setup routines for the esd CPCI-405 cPCI Board.
5 * 3 *
6 * Author: Stefan Roese 4 * Author: Stefan Roese
diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
index 9a828b623417..b4ecb9c79854 100644
--- a/arch/ppc/platforms/4xx/ebony.c
+++ b/arch/ppc/platforms/4xx/ebony.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ebony.c
3 *
4 * Ebony board specific routines 2 * Ebony board specific routines
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ebony.h b/arch/ppc/platforms/4xx/ebony.h
index b91ad4272dfe..27b2e77c7c83 100644
--- a/arch/ppc/platforms/4xx/ebony.h
+++ b/arch/ppc/platforms/4xx/ebony.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ebony.h
3 *
4 * Ebony board definitions 2 * Ebony board definitions
5 * 3 *
6 * Matt Porter <mporter@mvista.com> 4 * Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ep405.c b/arch/ppc/platforms/4xx/ep405.c
index 26a07cdb30ec..6efa91ff9c07 100644
--- a/arch/ppc/platforms/4xx/ep405.c
+++ b/arch/ppc/platforms/4xx/ep405.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ep405.c
3 *
4 * Embedded Planet 405GP board 2 * Embedded Planet 405GP board
5 * http://www.embeddedplanet.com 3 * http://www.embeddedplanet.com
6 * 4 *
diff --git a/arch/ppc/platforms/4xx/ep405.h b/arch/ppc/platforms/4xx/ep405.h
index ea3eb21338fb..9814fc431725 100644
--- a/arch/ppc/platforms/4xx/ep405.h
+++ b/arch/ppc/platforms/4xx/ep405.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ep405.h
3 *
4 * Embedded Planet 405GP board 2 * Embedded Planet 405GP board
5 * http://www.embeddedplanet.com 3 * http://www.embeddedplanet.com
6 * 4 *
diff --git a/arch/ppc/platforms/4xx/ibm405ep.c b/arch/ppc/platforms/4xx/ibm405ep.c
index 093b28d27a41..55af769a6e70 100644
--- a/arch/ppc/platforms/4xx/ibm405ep.c
+++ b/arch/ppc/platforms/4xx/ibm405ep.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ibm405ep.c
3 *
4 * Support for IBM PPC 405EP processors. 2 * Support for IBM PPC 405EP processors.
5 * 3 *
6 * Author: SAW (IBM), derived from ibmnp405l.c. 4 * Author: SAW (IBM), derived from ibmnp405l.c.
diff --git a/arch/ppc/platforms/4xx/ibm405ep.h b/arch/ppc/platforms/4xx/ibm405ep.h
index e051e3fe8c63..fe46640de152 100644
--- a/arch/ppc/platforms/4xx/ibm405ep.h
+++ b/arch/ppc/platforms/4xx/ibm405ep.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm405ep.h
3 *
4 * IBM PPC 405EP processor defines. 2 * IBM PPC 405EP processor defines.
5 * 3 *
6 * Author: SAW (IBM), derived from ibm405gp.h. 4 * Author: SAW (IBM), derived from ibm405gp.h.
diff --git a/arch/ppc/platforms/4xx/ibm405gp.h b/arch/ppc/platforms/4xx/ibm405gp.h
index b2b642e81af7..eaf0ef57028d 100644
--- a/arch/ppc/platforms/4xx/ibm405gp.h
+++ b/arch/ppc/platforms/4xx/ibm405gp.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm405gp.h
3 *
4 * Author: Armin Kuster akuster@mvista.com 2 * Author: Armin Kuster akuster@mvista.com
5 * 3 *
6 * 2001 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibm405gpr.c b/arch/ppc/platforms/4xx/ibm405gpr.c
index cd0d00d8e8ee..49da61f6854a 100644
--- a/arch/ppc/platforms/4xx/ibm405gpr.c
+++ b/arch/ppc/platforms/4xx/ibm405gpr.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm405gpr.c
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibm405gpr.h b/arch/ppc/platforms/4xx/ibm405gpr.h
index 45412fb4368f..e90c5dde01d3 100644
--- a/arch/ppc/platforms/4xx/ibm405gpr.h
+++ b/arch/ppc/platforms/4xx/ibm405gpr.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm405gpr.h
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibm440ep.c b/arch/ppc/platforms/4xx/ibm440ep.c
index 65ac0b9c2d05..1fed6638c81f 100644
--- a/arch/ppc/platforms/4xx/ibm440ep.c
+++ b/arch/ppc/platforms/4xx/ibm440ep.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440ep.c
3 *
4 * PPC440EP I/O descriptions 2 * PPC440EP I/O descriptions
5 * 3 *
6 * Wade Farnsworth <wfarnsworth@mvista.com> 4 * Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440ep.h b/arch/ppc/platforms/4xx/ibm440ep.h
index 97c80b8e3e10..61717e8a799e 100644
--- a/arch/ppc/platforms/4xx/ibm440ep.h
+++ b/arch/ppc/platforms/4xx/ibm440ep.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440ep.h
3 *
4 * PPC440EP definitions 2 * PPC440EP definitions
5 * 3 *
6 * Wade Farnsworth <wfarnsworth@mvista.com> 4 * Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440gp.c b/arch/ppc/platforms/4xx/ibm440gp.c
index d926245e8b3e..b67a72e5c6fe 100644
--- a/arch/ppc/platforms/4xx/ibm440gp.c
+++ b/arch/ppc/platforms/4xx/ibm440gp.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440gp.c
3 *
4 * PPC440GP I/O descriptions 2 * PPC440GP I/O descriptions
5 * 3 *
6 * Matt Porter <mporter@mvista.com> 4 * Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440gp.h b/arch/ppc/platforms/4xx/ibm440gp.h
index ae1efc03b295..7b2763b6024f 100644
--- a/arch/ppc/platforms/4xx/ibm440gp.h
+++ b/arch/ppc/platforms/4xx/ibm440gp.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440gp.h
3 *
4 * PPC440GP definitions 2 * PPC440GP definitions
5 * 3 *
6 * Roland Dreier <roland@digitalvampire.org> 4 * Roland Dreier <roland@digitalvampire.org>
diff --git a/arch/ppc/platforms/4xx/ibm440gx.c b/arch/ppc/platforms/4xx/ibm440gx.c
index d24c09ee7b18..685abffcb6ce 100644
--- a/arch/ppc/platforms/4xx/ibm440gx.c
+++ b/arch/ppc/platforms/4xx/ibm440gx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440gx.c
3 *
4 * PPC440GX I/O descriptions 2 * PPC440GX I/O descriptions
5 * 3 *
6 * Matt Porter <mporter@mvista.com> 4 * Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440gx.h b/arch/ppc/platforms/4xx/ibm440gx.h
index 0b59d8dcd03c..070a34efe1c7 100644
--- a/arch/ppc/platforms/4xx/ibm440gx.h
+++ b/arch/ppc/platforms/4xx/ibm440gx.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ibm440gx.h
3 *
4 * PPC440GX definitions 2 * PPC440GX definitions
5 * 3 *
6 * Matt Porter <mporter@mvista.com> 4 * Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440sp.c b/arch/ppc/platforms/4xx/ibm440sp.c
index 71a0117d3597..de8f7ac5623c 100644
--- a/arch/ppc/platforms/4xx/ibm440sp.c
+++ b/arch/ppc/platforms/4xx/ibm440sp.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440sp.c
3 *
4 * PPC440SP I/O descriptions 2 * PPC440SP I/O descriptions
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ibm440sp.h b/arch/ppc/platforms/4xx/ibm440sp.h
index c71e46a18b9e..77e8bb22c527 100644
--- a/arch/ppc/platforms/4xx/ibm440sp.h
+++ b/arch/ppc/platforms/4xx/ibm440sp.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440sp.h
3 *
4 * PPC440SP definitions 2 * PPC440SP definitions
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ibmnp405h.c b/arch/ppc/platforms/4xx/ibmnp405h.c
index a477a78f4902..f1dcb0ac15b7 100644
--- a/arch/ppc/platforms/4xx/ibmnp405h.c
+++ b/arch/ppc/platforms/4xx/ibmnp405h.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibmnp405h.c
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2000-2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2000-2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmnp405h.h b/arch/ppc/platforms/4xx/ibmnp405h.h
index e2c2b06128c8..2c683f6aaa66 100644
--- a/arch/ppc/platforms/4xx/ibmnp405h.h
+++ b/arch/ppc/platforms/4xx/ibmnp405h.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibmnp405h.h
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstb4.c b/arch/ppc/platforms/4xx/ibmstb4.c
index 7e33bb635443..799a2eccccc3 100644
--- a/arch/ppc/platforms/4xx/ibmstb4.c
+++ b/arch/ppc/platforms/4xx/ibmstb4.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibmstb4.c
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2000-2001 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2000-2001 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstb4.h b/arch/ppc/platforms/4xx/ibmstb4.h
index 9f21d4c88a3d..9de426597351 100644
--- a/arch/ppc/platforms/4xx/ibmstb4.h
+++ b/arch/ppc/platforms/4xx/ibmstb4.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibmstb4.h
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2001 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstbx25.c b/arch/ppc/platforms/4xx/ibmstbx25.c
index b895b9cca57d..090ddcbecc5e 100644
--- a/arch/ppc/platforms/4xx/ibmstbx25.c
+++ b/arch/ppc/platforms/4xx/ibmstbx25.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibmstbx25.c
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2000-2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2000-2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstbx25.h b/arch/ppc/platforms/4xx/ibmstbx25.h
index 9a2efc366e9c..6884a49d3482 100644
--- a/arch/ppc/platforms/4xx/ibmstbx25.h
+++ b/arch/ppc/platforms/4xx/ibmstbx25.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibmstbx25.h
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/luan.c b/arch/ppc/platforms/4xx/luan.c
index 21d29132aebd..5c37de28e135 100644
--- a/arch/ppc/platforms/4xx/luan.c
+++ b/arch/ppc/platforms/4xx/luan.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/luan.c
3 *
4 * Luan board specific routines 2 * Luan board specific routines
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/luan.h b/arch/ppc/platforms/4xx/luan.h
index bbe7d0766db8..e0db6a810feb 100644
--- a/arch/ppc/platforms/4xx/luan.h
+++ b/arch/ppc/platforms/4xx/luan.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/luan.h
3 *
4 * Luan board definitions 2 * Luan board definitions
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
index 4f355b6acab2..f841972f1fa9 100644
--- a/arch/ppc/platforms/4xx/ocotea.c
+++ b/arch/ppc/platforms/4xx/ocotea.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ocotea.c
3 *
4 * Ocotea board specific routines 2 * Ocotea board specific routines
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ocotea.h b/arch/ppc/platforms/4xx/ocotea.h
index 33251153ac5f..7c799a9ff82b 100644
--- a/arch/ppc/platforms/4xx/ocotea.h
+++ b/arch/ppc/platforms/4xx/ocotea.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ocotea.h
3 *
4 * Ocotea board definitions 2 * Ocotea board definitions
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ppc440spe.c b/arch/ppc/platforms/4xx/ppc440spe.c
index 6139a0b3393e..1be5d1c8e266 100644
--- a/arch/ppc/platforms/4xx/ppc440spe.c
+++ b/arch/ppc/platforms/4xx/ppc440spe.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ppc440spe.c
3 *
4 * PPC440SPe I/O descriptions 2 * PPC440SPe I/O descriptions
5 * 3 *
6 * Roland Dreier <rolandd@cisco.com> 4 * Roland Dreier <rolandd@cisco.com>
diff --git a/arch/ppc/platforms/4xx/ppc440spe.h b/arch/ppc/platforms/4xx/ppc440spe.h
index 2216846973b8..d3a620ddcdee 100644
--- a/arch/ppc/platforms/4xx/ppc440spe.h
+++ b/arch/ppc/platforms/4xx/ppc440spe.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/ibm440spe.h
3 *
4 * PPC440SPe definitions 2 * PPC440SPe definitions
5 * 3 *
6 * Roland Dreier <rolandd@cisco.com> 4 * Roland Dreier <rolandd@cisco.com>
diff --git a/arch/ppc/platforms/4xx/redwood5.c b/arch/ppc/platforms/4xx/redwood5.c
index 611ac861804d..53da2b4f7c24 100644
--- a/arch/ppc/platforms/4xx/redwood5.c
+++ b/arch/ppc/platforms/4xx/redwood5.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/redwood5.c
3 *
4 * Support for the IBM redwood5 eval board file 2 * Support for the IBM redwood5 eval board file
5 * 3 *
6 * Author: Armin Kuster <akuster@mvista.com> 4 * Author: Armin Kuster <akuster@mvista.com>
diff --git a/arch/ppc/platforms/4xx/redwood5.h b/arch/ppc/platforms/4xx/redwood5.h
index 264e34fb3fbd..49edd4818970 100644
--- a/arch/ppc/platforms/4xx/redwood5.h
+++ b/arch/ppc/platforms/4xx/redwood5.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/redwood5.h
3 *
4 * Macros, definitions, and data structures specific to the IBM PowerPC 2 * Macros, definitions, and data structures specific to the IBM PowerPC
5 * STB03xxx "Redwood" evaluation board. 3 * STB03xxx "Redwood" evaluation board.
6 * 4 *
diff --git a/arch/ppc/platforms/4xx/redwood6.c b/arch/ppc/platforms/4xx/redwood6.c
index b13116691289..41b27d106fa3 100644
--- a/arch/ppc/platforms/4xx/redwood6.c
+++ b/arch/ppc/platforms/4xx/redwood6.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/redwood6.c
3 *
4 * Author: Armin Kuster <akuster@mvista.com> 2 * Author: Armin Kuster <akuster@mvista.com>
5 * 3 *
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/redwood6.h b/arch/ppc/platforms/4xx/redwood6.h
index 1814b9f5fc3a..1edcbe5c51c7 100644
--- a/arch/ppc/platforms/4xx/redwood6.h
+++ b/arch/ppc/platforms/4xx/redwood6.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/redwood6.h
3 *
4 * Macros, definitions, and data structures specific to the IBM PowerPC 2 * Macros, definitions, and data structures specific to the IBM PowerPC
5 * STBx25xx "Redwood6" evaluation board. 3 * STBx25xx "Redwood6" evaluation board.
6 * 4 *
diff --git a/arch/ppc/platforms/4xx/sycamore.c b/arch/ppc/platforms/4xx/sycamore.c
index 281b4a2ffb96..bab31eb30687 100644
--- a/arch/ppc/platforms/4xx/sycamore.c
+++ b/arch/ppc/platforms/4xx/sycamore.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/sycamore.c
3 *
4 * Architecture- / platform-specific boot-time initialization code for 2 * Architecture- / platform-specific boot-time initialization code for
5 * IBM PowerPC 4xx based boards. 3 * IBM PowerPC 4xx based boards.
6 * 4 *
diff --git a/arch/ppc/platforms/4xx/sycamore.h b/arch/ppc/platforms/4xx/sycamore.h
index 1cd6c824fd62..dae01620227d 100644
--- a/arch/ppc/platforms/4xx/sycamore.h
+++ b/arch/ppc/platforms/4xx/sycamore.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/sycamore.h
3 *
4 * Sycamore board definitions 2 * Sycamore board definitions
5 * 3 *
6 * Copyright (c) 2005 DENX Software Engineering 4 * Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/4xx/virtex-ii_pro.c b/arch/ppc/platforms/4xx/virtex-ii_pro.c
deleted file mode 100644
index 097cc9d5aca0..000000000000
--- a/arch/ppc/platforms/4xx/virtex-ii_pro.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * arch/ppc/platforms/4xx/virtex-ii_pro.c
3 *
4 * Author: MontaVista Software, Inc.
5 * source@mvista.com
6 *
7 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is licensed
9 * "as is" without any warranty of any kind, whether express or implied.
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14#include <asm/ocp.h>
15#include "virtex-ii_pro.h"
16
17/* Have OCP take care of the serial ports. */
18struct ocp_def core_ocp[] = {
19#ifdef XPAR_UARTNS550_0_BASEADDR
20 { .vendor = OCP_VENDOR_XILINX,
21 .function = OCP_FUNC_16550,
22 .index = 0,
23 .paddr = XPAR_UARTNS550_0_BASEADDR,
24 .irq = XPAR_INTC_0_UARTNS550_0_VEC_ID,
25 .pm = OCP_CPM_NA
26 },
27#ifdef XPAR_UARTNS550_1_BASEADDR
28 { .vendor = OCP_VENDOR_XILINX,
29 .function = OCP_FUNC_16550,
30 .index = 1,
31 .paddr = XPAR_UARTNS550_1_BASEADDR,
32 .irq = XPAR_INTC_0_UARTNS550_1_VEC_ID,
33 .pm = OCP_CPM_NA
34 },
35#ifdef XPAR_UARTNS550_2_BASEADDR
36 { .vendor = OCP_VENDOR_XILINX,
37 .function = OCP_FUNC_16550,
38 .index = 2,
39 .paddr = XPAR_UARTNS550_2_BASEADDR,
40 .irq = XPAR_INTC_0_UARTNS550_2_VEC_ID,
41 .pm = OCP_CPM_NA
42 },
43#ifdef XPAR_UARTNS550_3_BASEADDR
44 { .vendor = OCP_VENDOR_XILINX,
45 .function = OCP_FUNC_16550,
46 .index = 3,
47 .paddr = XPAR_UARTNS550_3_BASEADDR,
48 .irq = XPAR_INTC_0_UARTNS550_3_VEC_ID,
49 .pm = OCP_CPM_NA
50 },
51#ifdef XPAR_UARTNS550_4_BASEADDR
52#error Edit this file to add more devices.
53#endif /* 4 */
54#endif /* 3 */
55#endif /* 2 */
56#endif /* 1 */
57#endif /* 0 */
58 { .vendor = OCP_VENDOR_INVALID
59 }
60};
diff --git a/arch/ppc/platforms/4xx/virtex-ii_pro.h b/arch/ppc/platforms/4xx/virtex-ii_pro.h
deleted file mode 100644
index 9014c4887339..000000000000
--- a/arch/ppc/platforms/4xx/virtex-ii_pro.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * arch/ppc/platforms/4xx/virtex-ii_pro.h
3 *
4 * Include file that defines the Xilinx Virtex-II Pro processor
5 *
6 * Author: MontaVista Software, Inc.
7 * source@mvista.com
8 *
9 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
10 * terms of the GNU General Public License version 2. This program is licensed
11 * "as is" without any warranty of any kind, whether express or implied.
12 */
13
14#ifdef __KERNEL__
15#ifndef __ASM_VIRTEXIIPRO_H__
16#define __ASM_VIRTEXIIPRO_H__
17
18#include <linux/config.h>
19#include <asm/xparameters.h>
20
21/* serial defines */
22
23#define RS_TABLE_SIZE 4 /* change this and add more devices below
24 if you have more then 4 16x50 UARTs */
25
26#define BASE_BAUD (XPAR_UARTNS550_0_CLOCK_FREQ_HZ/16)
27
28/* The serial ports in the Virtex-II Pro have each I/O byte in the
29 * LSByte of a word. This means that iomem_reg_shift needs to be 2 to
30 * change the byte offsets into word offsets. In addition the base
31 * addresses need to have 3 added to them to get to the LSByte.
32 */
33#define STD_UART_OP(num) \
34 { 0, BASE_BAUD, 0, XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
35 ASYNC_BOOT_AUTOCONF, \
36 .iomem_base = (u8 *)XPAR_UARTNS550_##num##_BASEADDR + 3, \
37 .iomem_reg_shift = 2, \
38 .io_type = SERIAL_IO_MEM},
39
40#if defined(XPAR_INTC_0_UARTNS550_0_VEC_ID)
41#define ML300_UART0 STD_UART_OP(0)
42#else
43#define ML300_UART0
44#endif
45
46#if defined(XPAR_INTC_0_UARTNS550_1_VEC_ID)
47#define ML300_UART1 STD_UART_OP(1)
48#else
49#define ML300_UART1
50#endif
51
52#if defined(XPAR_INTC_0_UARTNS550_2_VEC_ID)
53#define ML300_UART2 STD_UART_OP(2)
54#else
55#define ML300_UART2
56#endif
57
58#if defined(XPAR_INTC_0_UARTNS550_3_VEC_ID)
59#define ML300_UART3 STD_UART_OP(3)
60#else
61#define ML300_UART3
62#endif
63
64#if defined(XPAR_INTC_0_UARTNS550_4_VEC_ID)
65#error Edit this file to add more devices.
66#elif defined(XPAR_INTC_0_UARTNS550_3_VEC_ID)
67#define NR_SER_PORTS 4
68#elif defined(XPAR_INTC_0_UARTNS550_2_VEC_ID)
69#define NR_SER_PORTS 3
70#elif defined(XPAR_INTC_0_UARTNS550_1_VEC_ID)
71#define NR_SER_PORTS 2
72#elif defined(XPAR_INTC_0_UARTNS550_0_VEC_ID)
73#define NR_SER_PORTS 1
74#else
75#define NR_SER_PORTS 0
76#endif
77
78#if defined(CONFIG_UART0_TTYS0)
79#define SERIAL_PORT_DFNS \
80 ML300_UART0 \
81 ML300_UART1 \
82 ML300_UART2 \
83 ML300_UART3
84#endif
85
86#if defined(CONFIG_UART0_TTYS1)
87#define SERIAL_PORT_DFNS \
88 ML300_UART1 \
89 ML300_UART0 \
90 ML300_UART2 \
91 ML300_UART3
92#endif
93
94#define DCRN_CPMFR_BASE 0
95
96#include <asm/ibm405.h>
97
98#endif /* __ASM_VIRTEXIIPRO_H__ */
99#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/virtex.c b/arch/ppc/platforms/4xx/virtex.c
new file mode 100644
index 000000000000..133a83147199
--- /dev/null
+++ b/arch/ppc/platforms/4xx/virtex.c
@@ -0,0 +1,56 @@
1/*
2 * Virtex-II Pro & Virtex-4 FX common infrastructure
3 *
4 * Maintainer: Grant Likely <grant.likely@secretlab.ca>
5 *
6 * Copyright 2005 Secret Lab Technologies Ltd.
7 * Copyright 2005 General Dynamics Canada Ltd.
8 * Copyright 2005 Freescale Semiconductor Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/device.h>
19#include <linux/serial_8250.h>
20#include <asm/ppc_sys.h>
21#include <platforms/4xx/virtex.h>
22#include <platforms/4xx/xparameters/xparameters.h>
23
24#define XPAR_UART(num) { \
25 .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
26 .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
27 .iotype = UPIO_MEM, \
28 .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
29 .flags = UPF_BOOT_AUTOCONF, \
30 .regshift = 2, \
31 }
32
33struct plat_serial8250_port serial_platform_data[] = {
34#ifdef XPAR_UARTNS550_0_BASEADDR
35 XPAR_UART(0),
36#endif
37#ifdef XPAR_UARTNS550_1_BASEADDR
38 XPAR_UART(1),
39#endif
40#ifdef XPAR_UARTNS550_2_BASEADDR
41 XPAR_UART(2),
42#endif
43#ifdef XPAR_UARTNS550_3_BASEADDR
44 XPAR_UART(3),
45#endif
46 { }, /* terminated by empty record */
47};
48
49struct platform_device ppc_sys_platform_devices[] = {
50 [VIRTEX_UART] = {
51 .name = "serial8250",
52 .id = 0,
53 .dev.platform_data = serial_platform_data,
54 },
55};
56
diff --git a/arch/ppc/platforms/4xx/virtex.h b/arch/ppc/platforms/4xx/virtex.h
new file mode 100644
index 000000000000..c14325dfd7b1
--- /dev/null
+++ b/arch/ppc/platforms/4xx/virtex.h
@@ -0,0 +1,35 @@
1/*
2 * arch/ppc/platforms/4xx/virtex.h
3 *
4 * Include file that defines the Xilinx Virtex-II Pro processor
5 *
6 * Author: MontaVista Software, Inc.
7 * source@mvista.com
8 *
9 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
10 * terms of the GNU General Public License version 2. This program is licensed
11 * "as is" without any warranty of any kind, whether express or implied.
12 */
13
14#ifdef __KERNEL__
15#ifndef __ASM_VIRTEX_H__
16#define __ASM_VIRTEX_H__
17
18/* serial defines */
19
20#include <asm/ibm405.h>
21
22/* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */
23#if !defined(BASE_BAUD)
24 #define BASE_BAUD (0) /* dummy value; not used */
25#endif
26
27/* Device type enumeration for platform bus definitions */
28#ifndef __ASSEMBLY__
29enum ppc_sys_devices {
30 VIRTEX_UART, NUM_PPC_SYS_DEVS,
31};
32#endif
33
34#endif /* __ASM_VIRTEX_H__ */
35#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/walnut.c b/arch/ppc/platforms/4xx/walnut.c
index 74cb33182d9f..6bd77902b9a4 100644
--- a/arch/ppc/platforms/4xx/walnut.c
+++ b/arch/ppc/platforms/4xx/walnut.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/walnut.c
3 *
4 * Architecture- / platform-specific boot-time initialization code for 2 * Architecture- / platform-specific boot-time initialization code for
5 * IBM PowerPC 4xx based boards. Adapted from original 3 * IBM PowerPC 4xx based boards. Adapted from original
6 * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek 4 * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
diff --git a/arch/ppc/platforms/4xx/walnut.h b/arch/ppc/platforms/4xx/walnut.h
index dcf2691698c0..f13a577f0a41 100644
--- a/arch/ppc/platforms/4xx/walnut.h
+++ b/arch/ppc/platforms/4xx/walnut.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/walnut.h
3 *
4 * Walnut board definitions 2 * Walnut board definitions
5 * 3 *
6 * Copyright (c) 2005 DENX Software Engineering 4 * Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.c b/arch/ppc/platforms/4xx/xilinx_ml300.c
index e90d97f64f76..d97a7f269f97 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/xilinx_ml300.c
3 *
4 * Xilinx ML300 evaluation board initialization 2 * Xilinx ML300 evaluation board initialization
5 * 3 *
6 * Author: MontaVista Software, Inc. 4 * Author: MontaVista Software, Inc.
@@ -17,12 +15,14 @@
17#include <linux/tty.h> 15#include <linux/tty.h>
18#include <linux/serial.h> 16#include <linux/serial.h>
19#include <linux/serial_core.h> 17#include <linux/serial_core.h>
18#include <linux/serial_8250.h>
20#include <linux/serialP.h> 19#include <linux/serialP.h>
21#include <asm/io.h> 20#include <asm/io.h>
22#include <asm/machdep.h> 21#include <asm/machdep.h>
23#include <asm/ocp.h> 22#include <asm/ppc_sys.h>
24 23
25#include <platforms/4xx/virtex-ii_pro.h> /* for NR_SER_PORTS */ 24#include <syslib/gen550.h>
25#include <platforms/4xx/xparameters/xparameters.h>
26 26
27/* 27/*
28 * As an overview of how the following functions (platform_init, 28 * As an overview of how the following functions (platform_init,
@@ -54,6 +54,22 @@
54 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c 54 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
55 */ 55 */
56 56
57/* Board specifications structures */
58struct ppc_sys_spec *cur_ppc_sys_spec;
59struct ppc_sys_spec ppc_sys_specs[] = {
60 {
61 /* Only one entry, always assume the same design */
62 .ppc_sys_name = "Xilinx ML300 Reference Design",
63 .mask = 0x00000000,
64 .value = 0x00000000,
65 .num_devices = 1,
66 .device_list = (enum ppc_sys_devices[])
67 {
68 VIRTEX_UART,
69 },
70 },
71};
72
57#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR) 73#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
58 74
59static volatile unsigned *powerdown_base = 75static volatile unsigned *powerdown_base =
@@ -80,28 +96,39 @@ ml300_map_io(void)
80#endif 96#endif
81} 97}
82 98
99/* Early serial support functions */
83static void __init 100static void __init
101ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
102{
103#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
104 struct uart_port serial_req;
105
106 memset(&serial_req, 0, sizeof(serial_req));
107 serial_req.mapbase = pdata->mapbase;
108 serial_req.membase = pdata->membase;
109 serial_req.irq = pdata->irq;
110 serial_req.uartclk = pdata->uartclk;
111 serial_req.regshift = pdata->regshift;
112 serial_req.iotype = pdata->iotype;
113 serial_req.flags = pdata->flags;
114 gen550_init(num, &serial_req);
115#endif
116}
117
118void __init
84ml300_early_serial_map(void) 119ml300_early_serial_map(void)
85{ 120{
86#ifdef CONFIG_SERIAL_8250 121#ifdef CONFIG_SERIAL_8250
87 struct serial_state old_ports[] = { SERIAL_PORT_DFNS }; 122 struct plat_serial8250_port *pdata;
88 struct uart_port port; 123 int i = 0;
89 int i; 124
90 125 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
91 /* Setup ioremapped serial port access */ 126 while(pdata && pdata->flags)
92 for (i = 0; i < ARRAY_SIZE(old_ports); i++ ) { 127 {
93 memset(&port, 0, sizeof(port)); 128 pdata->membase = ioremap(pdata->mapbase, 0x100);
94 port.membase = ioremap((phys_addr_t)(old_ports[i].iomem_base), 16); 129 ml300_early_serial_init(i, pdata);
95 port.irq = old_ports[i].irq; 130 pdata++;
96 port.uartclk = old_ports[i].baud_base * 16; 131 i++;
97 port.regshift = old_ports[i].iomem_reg_shift;
98 port.iotype = UPIO_MEM;
99 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
100 port.line = i;
101
102 if (early_serial_setup(&port) != 0) {
103 printk("Early serial init of port %d failed\n", i);
104 }
105 } 132 }
106#endif /* CONFIG_SERIAL_8250 */ 133#endif /* CONFIG_SERIAL_8250 */
107} 134}
@@ -109,9 +136,8 @@ ml300_early_serial_map(void)
109void __init 136void __init
110ml300_setup_arch(void) 137ml300_setup_arch(void)
111{ 138{
112 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
113
114 ml300_early_serial_map(); 139 ml300_early_serial_map();
140 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
115 141
116 /* Identify the system */ 142 /* Identify the system */
117 printk(KERN_INFO "Xilinx Virtex-II Pro port\n"); 143 printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
@@ -131,6 +157,8 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
131{ 157{
132 ppc4xx_init(r3, r4, r5, r6, r7); 158 ppc4xx_init(r3, r4, r5, r6, r7);
133 159
160 identify_ppc_sys_by_id(mfspr(SPRN_PVR));
161
134 ppc_md.setup_arch = ml300_setup_arch; 162 ppc_md.setup_arch = ml300_setup_arch;
135 ppc_md.setup_io_mappings = ml300_map_io; 163 ppc_md.setup_io_mappings = ml300_map_io;
136 ppc_md.init_IRQ = ml300_init_irq; 164 ppc_md.init_IRQ = ml300_init_irq;
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.h b/arch/ppc/platforms/4xx/xilinx_ml300.h
index f8c588412336..3d57332ba820 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.h
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/xilinx_ml300.h
3 *
4 * Include file that defines the Xilinx ML300 evaluation board 2 * Include file that defines the Xilinx ML300 evaluation board
5 * 3 *
6 * Author: MontaVista Software, Inc. 4 * Author: MontaVista Software, Inc.
@@ -16,7 +14,7 @@
16#define __ASM_XILINX_ML300_H__ 14#define __ASM_XILINX_ML300_H__
17 15
18/* ML300 has a Xilinx Virtex-II Pro processor */ 16/* ML300 has a Xilinx Virtex-II Pro processor */
19#include <platforms/4xx/virtex-ii_pro.h> 17#include <platforms/4xx/virtex.h>
20 18
21#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
22 20
@@ -41,7 +39,7 @@ typedef struct board_info {
41#define PPC4xx_ONB_IO_VADDR 0u 39#define PPC4xx_ONB_IO_VADDR 0u
42#define PPC4xx_ONB_IO_SIZE 0u 40#define PPC4xx_ONB_IO_SIZE 0u
43 41
44#define PPC4xx_MACHINE_NAME "Xilinx ML300" 42#define PPC4xx_MACHINE_NAME "Xilinx ML300 Reference System"
45 43
46#endif /* __ASM_XILINX_ML300_H__ */ 44#endif /* __ASM_XILINX_ML300_H__ */
47#endif /* __KERNEL__ */ 45#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.c b/arch/ppc/platforms/4xx/xilinx_ml403.c
new file mode 100644
index 000000000000..4c0c7e4c1114
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.c
@@ -0,0 +1,177 @@
1/*
2 * arch/ppc/platforms/4xx/xilinx_ml403.c
3 *
4 * Xilinx ML403 evaluation board initialization
5 *
6 * Author: Grant Likely <grant.likely@secretlab.ca>
7 *
8 * 2005 (c) Secret Lab Technologies Ltd.
9 * 2002-2004 (c) MontaVista Software, Inc.
10 *
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any
13 * kind, whether express or implied.
14 */
15
16#include <linux/config.h>
17#include <linux/init.h>
18#include <linux/irq.h>
19#include <linux/tty.h>
20#include <linux/serial.h>
21#include <linux/serial_core.h>
22#include <linux/serial_8250.h>
23#include <linux/serialP.h>
24#include <asm/io.h>
25#include <asm/machdep.h>
26#include <asm/ppc_sys.h>
27
28#include <syslib/gen550.h>
29#include <platforms/4xx/xparameters/xparameters.h>
30
31/*
32 * As an overview of how the following functions (platform_init,
33 * ml403_map_io, ml403_setup_arch and ml403_init_IRQ) fit into the
34 * kernel startup procedure, here's a call tree:
35 *
36 * start_here arch/ppc/kernel/head_4xx.S
37 * early_init arch/ppc/kernel/setup.c
38 * machine_init arch/ppc/kernel/setup.c
39 * platform_init this file
40 * ppc4xx_init arch/ppc/syslib/ppc4xx_setup.c
41 * parse_bootinfo
42 * find_bootinfo
43 * "setup some default ppc_md pointers"
44 * MMU_init arch/ppc/mm/init.c
45 * *ppc_md.setup_io_mappings == ml403_map_io this file
46 * ppc4xx_map_io arch/ppc/syslib/ppc4xx_setup.c
47 * start_kernel init/main.c
48 * setup_arch arch/ppc/kernel/setup.c
49 * #if defined(CONFIG_KGDB)
50 * *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
51 * #endif
52 * *ppc_md.setup_arch == ml403_setup_arch this file
53 * ppc4xx_setup_arch arch/ppc/syslib/ppc4xx_setup.c
54 * ppc4xx_find_bridges arch/ppc/syslib/ppc405_pci.c
55 * init_IRQ arch/ppc/kernel/irq.c
56 * *ppc_md.init_IRQ == ml403_init_IRQ this file
57 * ppc4xx_init_IRQ arch/ppc/syslib/ppc4xx_setup.c
58 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
59 */
60
61/* Board specifications structures */
62struct ppc_sys_spec *cur_ppc_sys_spec;
63struct ppc_sys_spec ppc_sys_specs[] = {
64 {
65 /* Only one entry, always assume the same design */
66 .ppc_sys_name = "Xilinx ML403 Reference Design",
67 .mask = 0x00000000,
68 .value = 0x00000000,
69 .num_devices = 1,
70 .device_list = (enum ppc_sys_devices[])
71 {
72 VIRTEX_UART,
73 },
74 },
75};
76
77#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
78
79static volatile unsigned *powerdown_base =
80 (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
81
82static void
83xilinx_power_off(void)
84{
85 local_irq_disable();
86 out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
87 while (1) ;
88}
89#endif
90
91void __init
92ml403_map_io(void)
93{
94 ppc4xx_map_io();
95
96#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
97 powerdown_base = ioremap((unsigned long) powerdown_base,
98 XPAR_POWER_0_POWERDOWN_HIGHADDR -
99 XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
100#endif
101}
102
103/* Early serial support functions */
104static void __init
105ml403_early_serial_init(int num, struct plat_serial8250_port *pdata)
106{
107#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
108 struct uart_port serial_req;
109
110 memset(&serial_req, 0, sizeof(serial_req));
111 serial_req.mapbase = pdata->mapbase;
112 serial_req.membase = pdata->membase;
113 serial_req.irq = pdata->irq;
114 serial_req.uartclk = pdata->uartclk;
115 serial_req.regshift = pdata->regshift;
116 serial_req.iotype = pdata->iotype;
117 serial_req.flags = pdata->flags;
118 gen550_init(num, &serial_req);
119#endif
120}
121
122void __init
123ml403_early_serial_map(void)
124{
125#ifdef CONFIG_SERIAL_8250
126 struct plat_serial8250_port *pdata;
127 int i = 0;
128
129 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
130 while(pdata && pdata->flags)
131 {
132 pdata->membase = ioremap(pdata->mapbase, 0x100);
133 ml403_early_serial_init(i, pdata);
134 pdata++;
135 i++;
136 }
137#endif /* CONFIG_SERIAL_8250 */
138}
139
140void __init
141ml403_setup_arch(void)
142{
143 ml403_early_serial_map();
144 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
145
146 /* Identify the system */
147 printk(KERN_INFO "Xilinx ML403 Reference System (Virtex-4 FX)\n");
148}
149
150/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
151void __init
152ml403_init_irq(void)
153{
154 ppc4xx_init_IRQ();
155}
156
157void __init
158platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
159 unsigned long r6, unsigned long r7)
160{
161 ppc4xx_init(r3, r4, r5, r6, r7);
162
163 identify_ppc_sys_by_id(mfspr(SPRN_PVR));
164
165 ppc_md.setup_arch = ml403_setup_arch;
166 ppc_md.setup_io_mappings = ml403_map_io;
167 ppc_md.init_IRQ = ml403_init_irq;
168
169#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
170 ppc_md.power_off = xilinx_power_off;
171#endif
172
173#ifdef CONFIG_KGDB
174 ppc_md.early_serial_map = ml403_early_serial_map;
175#endif
176}
177
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.h b/arch/ppc/platforms/4xx/xilinx_ml403.h
new file mode 100644
index 000000000000..473596959902
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.h
@@ -0,0 +1,49 @@
1/*
2 * arch/ppc/platforms/4xx/xilinx_ml403.h
3 *
4 * Include file that defines the Xilinx ML403 reference design
5 *
6 * Author: Grant Likely <grant.likely@secretlab.ca>
7 *
8 * 2005 (c) Secret Lab Technologies Ltd.
9 * 2002-2004 (c) MontaVista Software, Inc.
10 *
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any
13 * kind, whether express or implied.
14 */
15
16#ifdef __KERNEL__
17#ifndef __ASM_XILINX_ML403_H__
18#define __ASM_XILINX_ML403_H__
19
20/* ML403 has a Xilinx Virtex-4 FPGA with a PPC405 hard core */
21#include <platforms/4xx/virtex.h>
22
23#ifndef __ASSEMBLY__
24
25#include <linux/types.h>
26
27typedef struct board_info {
28 unsigned int bi_memsize; /* DRAM installed, in bytes */
29 unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
30 unsigned int bi_intfreq; /* Processor speed, in Hz */
31 unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
32 unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
33} bd_t;
34
35/* Some 4xx parts use a different timebase frequency from the internal clock.
36*/
37#define bi_tbfreq bi_intfreq
38
39#endif /* !__ASSEMBLY__ */
40
41/* We don't need anything mapped. Size of zero will accomplish that. */
42#define PPC4xx_ONB_IO_PADDR 0u
43#define PPC4xx_ONB_IO_VADDR 0u
44#define PPC4xx_ONB_IO_SIZE 0u
45
46#define PPC4xx_MACHINE_NAME "Xilinx ML403 Reference Design"
47
48#endif /* __ASM_XILINX_ML403_H__ */
49#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xparameters/xparameters.h b/arch/ppc/platforms/4xx/xparameters/xparameters.h
new file mode 100644
index 000000000000..4cf21f256356
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xparameters/xparameters.h
@@ -0,0 +1,37 @@
1/*
2 * include/asm-ppc/xparameters.h
3 *
4 * This file includes the correct xparameters.h for the CONFIG'ed board plus
5 * fixups to translate board specific XPAR values to a common set of names
6 *
7 * Author: MontaVista Software, Inc.
8 * source@mvista.com
9 *
10 * 2004 (c) MontaVista Software, Inc. This file is licensed under the terms
11 * of the GNU General Public License version 2. This program is licensed
12 * "as is" without any warranty of any kind, whether express or implied.
13 */
14
15#include <linux/config.h>
16
17#if defined(CONFIG_XILINX_ML300)
18 #include "xparameters_ml300.h"
19#elif defined(CONFIG_XILINX_ML403)
20 #include "xparameters_ml403.h"
21#else
22 /* Add other board xparameter includes here before the #else */
23 #error No xparameters_*.h file included
24#endif
25
26#ifndef SERIAL_PORT_DFNS
27 /* zImage serial port definitions */
28 #define RS_TABLE_SIZE 1
29 #define SERIAL_PORT_DFNS { \
30 .baud_base = XPAR_UARTNS550_0_CLOCK_FREQ_HZ/16, \
31 .irq = XPAR_INTC_0_UARTNS550_0_VEC_ID, \
32 .flags = ASYNC_BOOT_AUTOCONF, \
33 .iomem_base = (u8 *)XPAR_UARTNS550_0_BASEADDR + 3, \
34 .iomem_reg_shift = 2, \
35 .io_type = SERIAL_IO_MEM, \
36 },
37#endif
diff --git a/arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h b/arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h
new file mode 100644
index 000000000000..5cacdcb3964d
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h
@@ -0,0 +1,243 @@
1
2/*******************************************************************
3*
4* CAUTION: This file is automatically generated by libgen.
5* Version: Xilinx EDK 7.1.2 EDK_H.12.5.1
6* DO NOT EDIT.
7*
8* Copyright (c) 2005 Xilinx, Inc. All rights reserved.
9*
10* Description: Driver parameters
11*
12*******************************************************************/
13
14#define XPAR_PLB_BRAM_IF_CNTLR_0_BASEADDR 0xFFFF0000
15#define XPAR_PLB_BRAM_IF_CNTLR_0_HIGHADDR 0xFFFFFFFF
16
17/******************************************************************/
18
19#define XPAR_OPB_EMC_0_MEM0_BASEADDR 0x20000000
20#define XPAR_OPB_EMC_0_MEM0_HIGHADDR 0x200FFFFF
21#define XPAR_OPB_EMC_0_MEM1_BASEADDR 0x28000000
22#define XPAR_OPB_EMC_0_MEM1_HIGHADDR 0x287FFFFF
23#define XPAR_OPB_AC97_CONTROLLER_REF_0_BASEADDR 0xA6000000
24#define XPAR_OPB_AC97_CONTROLLER_REF_0_HIGHADDR 0xA60000FF
25#define XPAR_OPB_EMC_USB_0_MEM0_BASEADDR 0xA5000000
26#define XPAR_OPB_EMC_USB_0_MEM0_HIGHADDR 0xA50000FF
27#define XPAR_PLB_DDR_0_MEM0_BASEADDR 0x00000000
28#define XPAR_PLB_DDR_0_MEM0_HIGHADDR 0x0FFFFFFF
29
30/******************************************************************/
31
32#define XPAR_XEMAC_NUM_INSTANCES 1
33#define XPAR_OPB_ETHERNET_0_BASEADDR 0x60000000
34#define XPAR_OPB_ETHERNET_0_HIGHADDR 0x60003FFF
35#define XPAR_OPB_ETHERNET_0_DEVICE_ID 0
36#define XPAR_OPB_ETHERNET_0_ERR_COUNT_EXIST 1
37#define XPAR_OPB_ETHERNET_0_DMA_PRESENT 1
38#define XPAR_OPB_ETHERNET_0_MII_EXIST 1
39
40/******************************************************************/
41
42#define XPAR_XUARTNS550_NUM_INSTANCES 1
43#define XPAR_XUARTNS550_CLOCK_HZ 100000000
44#define XPAR_OPB_UART16550_0_BASEADDR 0xA0000000
45#define XPAR_OPB_UART16550_0_HIGHADDR 0xA0001FFF
46#define XPAR_OPB_UART16550_0_DEVICE_ID 0
47
48/******************************************************************/
49
50#define XPAR_XGPIO_NUM_INSTANCES 3
51#define XPAR_OPB_GPIO_0_BASEADDR 0x90000000
52#define XPAR_OPB_GPIO_0_HIGHADDR 0x900001FF
53#define XPAR_OPB_GPIO_0_DEVICE_ID 0
54#define XPAR_OPB_GPIO_0_INTERRUPT_PRESENT 0
55#define XPAR_OPB_GPIO_0_IS_DUAL 1
56#define XPAR_OPB_GPIO_EXP_HDR_0_BASEADDR 0x90001000
57#define XPAR_OPB_GPIO_EXP_HDR_0_HIGHADDR 0x900011FF
58#define XPAR_OPB_GPIO_EXP_HDR_0_DEVICE_ID 1
59#define XPAR_OPB_GPIO_EXP_HDR_0_INTERRUPT_PRESENT 0
60#define XPAR_OPB_GPIO_EXP_HDR_0_IS_DUAL 1
61#define XPAR_OPB_GPIO_CHAR_LCD_0_BASEADDR 0x90002000
62#define XPAR_OPB_GPIO_CHAR_LCD_0_HIGHADDR 0x900021FF
63#define XPAR_OPB_GPIO_CHAR_LCD_0_DEVICE_ID 2
64#define XPAR_OPB_GPIO_CHAR_LCD_0_INTERRUPT_PRESENT 0
65#define XPAR_OPB_GPIO_CHAR_LCD_0_IS_DUAL 0
66
67/******************************************************************/
68
69#define XPAR_XPS2_NUM_INSTANCES 2
70#define XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_0 0
71#define XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_0 0xA9000000
72#define XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_0 (0xA9000000+0x3F)
73#define XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_1 1
74#define XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_1 (0xA9000000+0x1000)
75#define XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_1 (0xA9000000+0x103F)
76
77/******************************************************************/
78
79#define XPAR_XIIC_NUM_INSTANCES 1
80#define XPAR_OPB_IIC_0_BASEADDR 0xA8000000
81#define XPAR_OPB_IIC_0_HIGHADDR 0xA80001FF
82#define XPAR_OPB_IIC_0_DEVICE_ID 0
83#define XPAR_OPB_IIC_0_TEN_BIT_ADR 0
84#define XPAR_OPB_IIC_0_GPO_WIDTH 1
85
86/******************************************************************/
87
88#define XPAR_INTC_MAX_NUM_INTR_INPUTS 10
89#define XPAR_XINTC_HAS_IPR 1
90#define XPAR_XINTC_USE_DCR 0
91#define XPAR_XINTC_NUM_INSTANCES 1
92#define XPAR_OPB_INTC_0_BASEADDR 0xD1000FC0
93#define XPAR_OPB_INTC_0_HIGHADDR 0xD1000FDF
94#define XPAR_OPB_INTC_0_DEVICE_ID 0
95#define XPAR_OPB_INTC_0_KIND_OF_INTR 0x00000000
96
97/******************************************************************/
98
99#define XPAR_INTC_SINGLE_BASEADDR 0xD1000FC0
100#define XPAR_INTC_SINGLE_HIGHADDR 0xD1000FDF
101#define XPAR_INTC_SINGLE_DEVICE_ID XPAR_OPB_INTC_0_DEVICE_ID
102#define XPAR_OPB_ETHERNET_0_IP2INTC_IRPT_MASK 0X000001
103#define XPAR_OPB_INTC_0_OPB_ETHERNET_0_IP2INTC_IRPT_INTR 0
104#define XPAR_SYSTEM_USB_HPI_INT_MASK 0X000002
105#define XPAR_OPB_INTC_0_SYSTEM_USB_HPI_INT_INTR 1
106#define XPAR_MISC_LOGIC_0_PHY_MII_INT_MASK 0X000004
107#define XPAR_OPB_INTC_0_MISC_LOGIC_0_PHY_MII_INT_INTR 2
108#define XPAR_OPB_SYSACE_0_SYSACE_IRQ_MASK 0X000008
109#define XPAR_OPB_INTC_0_OPB_SYSACE_0_SYSACE_IRQ_INTR 3
110#define XPAR_OPB_AC97_CONTROLLER_REF_0_RECORD_INTERRUPT_MASK 0X000010
111#define XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_0_RECORD_INTERRUPT_INTR 4
112#define XPAR_OPB_AC97_CONTROLLER_REF_0_PLAYBACK_INTERRUPT_MASK 0X000020
113#define XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_0_PLAYBACK_INTERRUPT_INTR 5
114#define XPAR_OPB_IIC_0_IP2INTC_IRPT_MASK 0X000040
115#define XPAR_OPB_INTC_0_OPB_IIC_0_IP2INTC_IRPT_INTR 6
116#define XPAR_OPB_PS2_DUAL_REF_0_SYS_INTR2_MASK 0X000080
117#define XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR2_INTR 7
118#define XPAR_OPB_PS2_DUAL_REF_0_SYS_INTR1_MASK 0X000100
119#define XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR1_INTR 8
120#define XPAR_OPB_UART16550_0_IP2INTC_IRPT_MASK 0X000200
121#define XPAR_OPB_INTC_0_OPB_UART16550_0_IP2INTC_IRPT_INTR 9
122
123/******************************************************************/
124
125#define XPAR_XTFT_NUM_INSTANCES 1
126#define XPAR_PLB_TFT_CNTLR_REF_0_DCR_BASEADDR 0xD0000200
127#define XPAR_PLB_TFT_CNTLR_REF_0_DCR_HIGHADDR 0xD0000207
128#define XPAR_PLB_TFT_CNTLR_REF_0_DEVICE_ID 0
129
130/******************************************************************/
131
132#define XPAR_XSYSACE_MEM_WIDTH 16
133#define XPAR_XSYSACE_NUM_INSTANCES 1
134#define XPAR_OPB_SYSACE_0_BASEADDR 0xCF000000
135#define XPAR_OPB_SYSACE_0_HIGHADDR 0xCF0001FF
136#define XPAR_OPB_SYSACE_0_DEVICE_ID 0
137#define XPAR_OPB_SYSACE_0_MEM_WIDTH 16
138
139/******************************************************************/
140
141#define XPAR_CPU_PPC405_CORE_CLOCK_FREQ_HZ 300000000
142
143/******************************************************************/
144
145
146/******************************************************************/
147
148/* Linux Redefines */
149
150/******************************************************************/
151
152#define XPAR_UARTNS550_0_BASEADDR (XPAR_OPB_UART16550_0_BASEADDR+0x1000)
153#define XPAR_UARTNS550_0_HIGHADDR XPAR_OPB_UART16550_0_HIGHADDR
154#define XPAR_UARTNS550_0_CLOCK_FREQ_HZ XPAR_XUARTNS550_CLOCK_HZ
155#define XPAR_UARTNS550_0_DEVICE_ID XPAR_OPB_UART16550_0_DEVICE_ID
156
157/******************************************************************/
158
159#define XPAR_INTC_0_BASEADDR XPAR_OPB_INTC_0_BASEADDR
160#define XPAR_INTC_0_HIGHADDR XPAR_OPB_INTC_0_HIGHADDR
161#define XPAR_INTC_0_KIND_OF_INTR XPAR_OPB_INTC_0_KIND_OF_INTR
162#define XPAR_INTC_0_DEVICE_ID XPAR_OPB_INTC_0_DEVICE_ID
163
164/******************************************************************/
165
166#define XPAR_INTC_0_EMAC_0_VEC_ID XPAR_OPB_INTC_0_OPB_ETHERNET_0_IP2INTC_IRPT_INTR
167#define XPAR_INTC_0_SYSACE_0_VEC_ID XPAR_OPB_INTC_0_OPB_SYSACE_0_SYSACE_IRQ_INTR
168#define XPAR_INTC_0_IIC_0_VEC_ID XPAR_OPB_INTC_0_OPB_IIC_0_IP2INTC_IRPT_INTR
169#define XPAR_INTC_0_PS2_1_VEC_ID XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR2_INTR
170#define XPAR_INTC_0_PS2_0_VEC_ID XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR1_INTR
171#define XPAR_INTC_0_UARTNS550_0_VEC_ID XPAR_OPB_INTC_0_OPB_UART16550_0_IP2INTC_IRPT_INTR
172
173/******************************************************************/
174
175#define XPAR_TFT_0_BASEADDR XPAR_PLB_TFT_CNTLR_REF_0_DCR_BASEADDR
176
177/******************************************************************/
178
179#define XPAR_EMAC_0_BASEADDR XPAR_OPB_ETHERNET_0_BASEADDR
180#define XPAR_EMAC_0_HIGHADDR XPAR_OPB_ETHERNET_0_HIGHADDR
181#define XPAR_EMAC_0_DMA_PRESENT XPAR_OPB_ETHERNET_0_DMA_PRESENT
182#define XPAR_EMAC_0_MII_EXIST XPAR_OPB_ETHERNET_0_MII_EXIST
183#define XPAR_EMAC_0_ERR_COUNT_EXIST XPAR_OPB_ETHERNET_0_ERR_COUNT_EXIST
184#define XPAR_EMAC_0_DEVICE_ID XPAR_OPB_ETHERNET_0_DEVICE_ID
185
186/******************************************************************/
187
188#define XPAR_GPIO_0_BASEADDR XPAR_OPB_GPIO_0_BASEADDR_0
189#define XPAR_GPIO_0_HIGHADDR XPAR_OPB_GPIO_0_HIGHADDR_0
190#define XPAR_GPIO_0_DEVICE_ID XPAR_OPB_GPIO_0_DEVICE_ID_0
191#define XPAR_GPIO_1_BASEADDR XPAR_OPB_GPIO_0_BASEADDR_1
192#define XPAR_GPIO_1_HIGHADDR XPAR_OPB_GPIO_0_HIGHADDR_1
193#define XPAR_GPIO_1_DEVICE_ID XPAR_OPB_GPIO_0_DEVICE_ID_1
194#define XPAR_GPIO_2_BASEADDR XPAR_OPB_GPIO_EXP_HDR_0_BASEADDR_0
195#define XPAR_GPIO_2_HIGHADDR XPAR_OPB_GPIO_EXP_HDR_0_HIGHADDR_0
196#define XPAR_GPIO_2_DEVICE_ID XPAR_OPB_GPIO_EXP_HDR_0_DEVICE_ID_0
197#define XPAR_GPIO_3_BASEADDR XPAR_OPB_GPIO_EXP_HDR_0_BASEADDR_1
198#define XPAR_GPIO_3_HIGHADDR XPAR_OPB_GPIO_EXP_HDR_0_HIGHADDR_1
199#define XPAR_GPIO_3_DEVICE_ID XPAR_OPB_GPIO_EXP_HDR_0_DEVICE_ID_1
200#define XPAR_GPIO_4_BASEADDR XPAR_OPB_GPIO_CHAR_LCD_0_BASEADDR
201#define XPAR_GPIO_4_HIGHADDR XPAR_OPB_GPIO_CHAR_LCD_0_HIGHADDR
202#define XPAR_GPIO_4_DEVICE_ID XPAR_OPB_GPIO_CHAR_LCD_0_DEVICE_ID
203
204/******************************************************************/
205
206#define XPAR_PS2_0_BASEADDR XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_0
207#define XPAR_PS2_0_HIGHADDR XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_0
208#define XPAR_PS2_0_DEVICE_ID XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_0
209#define XPAR_PS2_1_BASEADDR XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_1
210#define XPAR_PS2_1_HIGHADDR XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_1
211#define XPAR_PS2_1_DEVICE_ID XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_1
212
213/******************************************************************/
214
215#define XPAR_SYSACE_0_BASEADDR XPAR_OPB_SYSACE_0_BASEADDR
216#define XPAR_SYSACE_0_HIGHADDR XPAR_OPB_SYSACE_0_HIGHADDR
217#define XPAR_SYSACE_0_DEVICE_ID XPAR_OPB_SYSACE_0_DEVICE_ID
218
219/******************************************************************/
220
221#define XPAR_IIC_0_BASEADDR XPAR_OPB_IIC_0_BASEADDR
222#define XPAR_IIC_0_HIGHADDR XPAR_OPB_IIC_0_HIGHADDR
223#define XPAR_IIC_0_TEN_BIT_ADR XPAR_OPB_IIC_0_TEN_BIT_ADR
224#define XPAR_IIC_0_DEVICE_ID XPAR_OPB_IIC_0_DEVICE_ID
225
226/******************************************************************/
227
228#define XPAR_PLB_CLOCK_FREQ_HZ 100000000
229#define XPAR_CORE_CLOCK_FREQ_HZ XPAR_CPU_PPC405_CORE_CLOCK_FREQ_HZ
230#define XPAR_DDR_0_SIZE 0x4000000
231
232/******************************************************************/
233
234#define XPAR_PERSISTENT_0_IIC_0_BASEADDR 0x00000400
235#define XPAR_PERSISTENT_0_IIC_0_HIGHADDR 0x000007FF
236#define XPAR_PERSISTENT_0_IIC_0_EEPROMADDR 0xA0
237
238/******************************************************************/
239
240#define XPAR_PCI_0_CLOCK_FREQ_HZ 0
241
242/******************************************************************/
243
diff --git a/arch/ppc/platforms/4xx/yucca.c b/arch/ppc/platforms/4xx/yucca.c
index b065b8babcd3..f287dcdbffce 100644
--- a/arch/ppc/platforms/4xx/yucca.c
+++ b/arch/ppc/platforms/4xx/yucca.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/yucca.c
3 *
4 * Yucca board specific routines 2 * Yucca board specific routines
5 * 3 *
6 * Roland Dreier <rolandd@cisco.com> (based on luan.c by Matt Porter) 4 * Roland Dreier <rolandd@cisco.com> (based on luan.c by Matt Porter)
diff --git a/arch/ppc/platforms/4xx/yucca.h b/arch/ppc/platforms/4xx/yucca.h
index 01a4afea1514..7ae23012237a 100644
--- a/arch/ppc/platforms/4xx/yucca.h
+++ b/arch/ppc/platforms/4xx/yucca.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/yucca.h
3 *
4 * Yucca board definitions 2 * Yucca board definitions
5 * 3 *
6 * Roland Dreier <rolandd@cisco.com> (based on luan.h by Matt Porter) 4 * Roland Dreier <rolandd@cisco.com> (based on luan.h by Matt Porter)
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.c b/arch/ppc/platforms/83xx/mpc834x_sys.c
index 1a659bbc1860..11626dd9090f 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.c
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/83xx/mpc834x_sys.c
3 *
4 * MPC834x SYS board specific routines 2 * MPC834x SYS board specific routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.h b/arch/ppc/platforms/83xx/mpc834x_sys.h
index 2e514d316fb8..6727bbdc36ec 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.h
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/83xx/mpc834x_sys.h
3 *
4 * MPC834X SYS common board definitions 2 * MPC834X SYS common board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
@@ -25,7 +23,7 @@
25#define VIRT_IMMRBAR ((uint)0xfe000000) 23#define VIRT_IMMRBAR ((uint)0xfe000000)
26 24
27#define BCSR_PHYS_ADDR ((uint)0xf8000000) 25#define BCSR_PHYS_ADDR ((uint)0xf8000000)
28#define BCSR_SIZE ((uint)(128 * 1024)) 26#define BCSR_SIZE ((uint)(32 * 1024))
29 27
30#define BCSR_MISC_REG2_OFF 0x07 28#define BCSR_MISC_REG2_OFF 0x07
31#define BCSR_MISC_REG2_PORESET 0x01 29#define BCSR_MISC_REG2_PORESET 0x01
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c
index 408d64f18e1a..9b014df516b9 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc8540_ads.c
3 *
4 * MPC8540ADS board specific routines 2 * MPC8540ADS board specific routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.h b/arch/ppc/platforms/85xx/mpc8540_ads.h
index e48ca3a97397..0b5e7ff856f5 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.h
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc8540_ads.h
3 *
4 * MPC8540ADS board definitions 2 * MPC8540ADS board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8555_cds.h b/arch/ppc/platforms/85xx/mpc8555_cds.h
index 1a8e6c67355d..9754dbd5d18c 100644
--- a/arch/ppc/platforms/85xx/mpc8555_cds.h
+++ b/arch/ppc/platforms/85xx/mpc8555_cds.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/mpc8555_cds.h
3 *
4 * MPC8555CDS board definitions 2 * MPC8555CDS board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
index 442c7ff195d3..0cb2e86470e2 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc8560_ads.c
3 *
4 * MPC8560ADS board specific routines 2 * MPC8560ADS board specific routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.h b/arch/ppc/platforms/85xx/mpc8560_ads.h
index 143ae7eefa7c..c2247c21fc53 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.h
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/mpc8560_ads.h
3 *
4 * MPC8540ADS board definitions 2 * MPC8540ADS board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
index 17ce48fe3503..8fd9d763f58d 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc85xx_ads_common.c
3 *
4 * MPC85xx ADS board common routines 2 * MPC85xx ADS board common routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_ads_common.h b/arch/ppc/platforms/85xx/mpc85xx_ads_common.h
index 198a6a02cde8..de8d41aafe11 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.h
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc85xx_ads_common.h
3 *
4 * MPC85XX ADS common board definitions 2 * MPC85XX ADS common board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
index 1801ab392e22..c9e0aeeca3d8 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platform/85xx/mpc85xx_cds_common.c
3 *
4 * MPC85xx CDS board specific routines 2 * MPC85xx CDS board specific routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.h b/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
index 5b588cfd0e41..62df54f61ae3 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc85xx_cds_common.h
3 *
4 * MPC85xx CDS board definitions 2 * MPC85xx CDS board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/sbc8560.c b/arch/ppc/platforms/85xx/sbc8560.c
index 8a72221f816c..b73778ecf827 100644
--- a/arch/ppc/platforms/85xx/sbc8560.c
+++ b/arch/ppc/platforms/85xx/sbc8560.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/sbc8560.c
3 *
4 * Wind River SBC8560 board specific routines 2 * Wind River SBC8560 board specific routines
5 * 3 *
6 * Maintainer: Kumar Gala 4 * Maintainer: Kumar Gala
diff --git a/arch/ppc/platforms/85xx/sbc8560.h b/arch/ppc/platforms/85xx/sbc8560.h
index 5e1b00c77da5..44ffaa2d2c87 100644
--- a/arch/ppc/platforms/85xx/sbc8560.h
+++ b/arch/ppc/platforms/85xx/sbc8560.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/sbc8560.h
3 *
4 * Wind River SBC8560 board definitions 2 * Wind River SBC8560 board definitions
5 * 3 *
6 * Copyright 2003 Motorola Inc. 4 * Copyright 2003 Motorola Inc.
diff --git a/arch/ppc/platforms/85xx/sbc85xx.c b/arch/ppc/platforms/85xx/sbc85xx.c
index c02f110219f5..d3ff280510ff 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.c
+++ b/arch/ppc/platforms/85xx/sbc85xx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platform/85xx/sbc85xx.c
3 *
4 * WindRiver PowerQUICC III SBC85xx board common routines 2 * WindRiver PowerQUICC III SBC85xx board common routines
5 * 3 *
6 * Copyright 2002, 2003 Motorola Inc. 4 * Copyright 2002, 2003 Motorola Inc.
diff --git a/arch/ppc/platforms/85xx/sbc85xx.h b/arch/ppc/platforms/85xx/sbc85xx.h
index 7af93c691a6b..5dd8b6a98c9b 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.h
+++ b/arch/ppc/platforms/85xx/sbc85xx.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/sbc85xx.h
3 *
4 * WindRiver PowerQUICC III SBC85xx common board definitions 2 * WindRiver PowerQUICC III SBC85xx common board definitions
5 * 3 *
6 * Copyright 2003 Motorola Inc. 4 * Copyright 2003 Motorola Inc.
diff --git a/arch/ppc/platforms/85xx/stx_gp3.c b/arch/ppc/platforms/85xx/stx_gp3.c
index 061bb7cf2d9a..8d7baa9a397a 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.c
+++ b/arch/ppc/platforms/85xx/stx_gp3.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/stx_gp3.c
3 *
4 * STx GP3 board specific routines 2 * STx GP3 board specific routines
5 * 3 *
6 * Dan Malek <dan@embeddededge.com> 4 * Dan Malek <dan@embeddededge.com>
diff --git a/arch/ppc/platforms/85xx/stx_gp3.h b/arch/ppc/platforms/85xx/stx_gp3.h
index 2f25b5195152..3f71f8f59370 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.h
+++ b/arch/ppc/platforms/85xx/stx_gp3.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/stx8560_gp3.h
3 *
4 * STx GP3 board definitions 2 * STx GP3 board definitions
5 * 3 *
6 * Dan Malek (dan@embeddededge.com) 4 * Dan Malek (dan@embeddededge.com)
diff --git a/arch/ppc/platforms/85xx/tqm85xx.c b/arch/ppc/platforms/85xx/tqm85xx.c
index a5e38ba62732..00af132262b3 100644
--- a/arch/ppc/platforms/85xx/tqm85xx.c
+++ b/arch/ppc/platforms/85xx/tqm85xx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/tqm85xx.c
3 *
4 * TQM85xx (40/41/55/60) board specific routines 2 * TQM85xx (40/41/55/60) board specific routines
5 * 3 *
6 * Copyright (c) 2005 DENX Software Engineering 4 * Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/85xx/tqm85xx.h b/arch/ppc/platforms/85xx/tqm85xx.h
index 3775eb363fde..612d80504f9b 100644
--- a/arch/ppc/platforms/85xx/tqm85xx.h
+++ b/arch/ppc/platforms/85xx/tqm85xx.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/tqm85xx.h
3 *
4 * TQM85xx (40/41/55/60) board definitions 2 * TQM85xx (40/41/55/60) board definitions
5 * 3 *
6 * Copyright (c) 2005 DENX Software Engineering 4 * Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/Makefile b/arch/ppc/platforms/Makefile
index 51430e294b32..e8b91a33ce91 100644
--- a/arch/ppc/platforms/Makefile
+++ b/arch/ppc/platforms/Makefile
@@ -37,6 +37,9 @@ obj-$(CONFIG_SBC82xx) += sbc82xx.o
37obj-$(CONFIG_SPRUCE) += spruce.o 37obj-$(CONFIG_SPRUCE) += spruce.o
38obj-$(CONFIG_LITE5200) += lite5200.o 38obj-$(CONFIG_LITE5200) += lite5200.o
39obj-$(CONFIG_EV64360) += ev64360.o 39obj-$(CONFIG_EV64360) += ev64360.o
40obj-$(CONFIG_MPC86XADS) += mpc866ads_setup.o
41obj-$(CONFIG_MPC885ADS) += mpc885ads_setup.o
42obj-$(CONFIG_ADS8272) += mpc8272ads_setup.o
40 43
41ifeq ($(CONFIG_SMP),y) 44ifeq ($(CONFIG_SMP),y)
42obj-$(CONFIG_PPC_CHRP) += chrp_smp.o 45obj-$(CONFIG_PPC_CHRP) += chrp_smp.o
diff --git a/arch/ppc/platforms/apus_setup.c b/arch/ppc/platforms/apus_setup.c
index c42c50073da5..fe0cdc04d436 100644
--- a/arch/ppc/platforms/apus_setup.c
+++ b/arch/ppc/platforms/apus_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/apus_setup.c
3 *
4 * Copyright (C) 1998, 1999 Jesper Skov 2 * Copyright (C) 1998, 1999 Jesper Skov
5 * 3 *
6 * Basically what is needed to replace functionality found in 4 * Basically what is needed to replace functionality found in
diff --git a/arch/ppc/platforms/chestnut.c b/arch/ppc/platforms/chestnut.c
index aefcc0e7be57..f324f757cae1 100644
--- a/arch/ppc/platforms/chestnut.c
+++ b/arch/ppc/platforms/chestnut.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/chestnut.c
3 *
4 * Board setup routines for IBM Chestnut 2 * Board setup routines for IBM Chestnut
5 * 3 *
6 * Author: <source@mvista.com> 4 * Author: <source@mvista.com>
diff --git a/arch/ppc/platforms/chestnut.h b/arch/ppc/platforms/chestnut.h
index 0400b2be40ab..e00fd9f8bbd0 100644
--- a/arch/ppc/platforms/chestnut.h
+++ b/arch/ppc/platforms/chestnut.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/chestnut.h
3 *
4 * Definitions for IBM 750FXGX Eval (Chestnut) 2 * Definitions for IBM 750FXGX Eval (Chestnut)
5 * 3 *
6 * Author: <source@mvista.com> 4 * Author: <source@mvista.com>
diff --git a/arch/ppc/platforms/chrp_pegasos_eth.c b/arch/ppc/platforms/chrp_pegasos_eth.c
index 108a6e265185..9305c8aa1373 100644
--- a/arch/ppc/platforms/chrp_pegasos_eth.c
+++ b/arch/ppc/platforms/chrp_pegasos_eth.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/chrp_pegasos_eth.c
3 *
4 * Copyright (C) 2005 Sven Luther <sl@bplan-gmbh.de> 2 * Copyright (C) 2005 Sven Luther <sl@bplan-gmbh.de>
5 * Thanks to : 3 * Thanks to :
6 * Dale Farnsworth <dale@farnsworth.org> 4 * Dale Farnsworth <dale@farnsworth.org>
diff --git a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
index 48996b787378..f9fd3f4f8e2e 100644
--- a/arch/ppc/platforms/chrp_setup.c
+++ b/arch/ppc/platforms/chrp_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas 3 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu) 4 * Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/platforms/chrp_time.c b/arch/ppc/platforms/chrp_time.c
index 57753a55b580..c8627770af13 100644
--- a/arch/ppc/platforms/chrp_time.c
+++ b/arch/ppc/platforms/chrp_time.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/chrp_time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 2 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * 3 *
6 * Adapted for PowerPC (PReP) by Gary Thomas 4 * Adapted for PowerPC (PReP) by Gary Thomas
diff --git a/arch/ppc/platforms/cpci690.c b/arch/ppc/platforms/cpci690.c
index 6ca7bcac9474..790475c22fd7 100644
--- a/arch/ppc/platforms/cpci690.c
+++ b/arch/ppc/platforms/cpci690.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/cpci690.c
3 *
4 * Board setup routines for the Force CPCI690 board. 2 * Board setup routines for the Force CPCI690 board.
5 * 3 *
6 * Author: Mark A. Greer <mgreer@mvista.com> 4 * Author: Mark A. Greer <mgreer@mvista.com>
@@ -290,7 +288,7 @@ cpci690_fixup_mpsc_pdata(struct platform_device *pdev)
290 pdata->brg_clk_freq = cpci690_get_bus_freq(); 288 pdata->brg_clk_freq = cpci690_get_bus_freq();
291} 289}
292 290
293static int __init 291static int
294cpci690_platform_notify(struct device *dev) 292cpci690_platform_notify(struct device *dev)
295{ 293{
296 static struct { 294 static struct {
diff --git a/arch/ppc/platforms/cpci690.h b/arch/ppc/platforms/cpci690.h
index 49584c9cedf3..0fa5a4c31b67 100644
--- a/arch/ppc/platforms/cpci690.h
+++ b/arch/ppc/platforms/cpci690.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/cpci690.h
3 *
4 * Definitions for Force CPCI690 2 * Definitions for Force CPCI690
5 * 3 *
6 * Author: Mark A. Greer <mgreer@mvista.com> 4 * Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/platforms/ev64260.c b/arch/ppc/platforms/ev64260.c
index ffde8f6f6302..31e8e21e1d5c 100644
--- a/arch/ppc/platforms/ev64260.c
+++ b/arch/ppc/platforms/ev64260.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ev64260.c
3 *
4 * Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board. 2 * Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board.
5 * 3 *
6 * Author: Mark A. Greer <mgreer@mvista.com> 4 * Author: Mark A. Greer <mgreer@mvista.com>
@@ -416,7 +414,7 @@ ev64260_fixup_mpsc_pdata(struct platform_device *pdev)
416 return; 414 return;
417} 415}
418 416
419static int __init 417static int
420ev64260_platform_notify(struct device *dev) 418ev64260_platform_notify(struct device *dev)
421{ 419{
422 static struct { 420 static struct {
diff --git a/arch/ppc/platforms/ev64260.h b/arch/ppc/platforms/ev64260.h
index bedffced3a02..44d90d56745a 100644
--- a/arch/ppc/platforms/ev64260.h
+++ b/arch/ppc/platforms/ev64260.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ev64260.h
3 *
4 * Definitions for Marvell/Galileo EV-64260-BP Evaluation Board. 2 * Definitions for Marvell/Galileo EV-64260-BP Evaluation Board.
5 * 3 *
6 * Author: Mark A. Greer <mgreer@mvista.com> 4 * Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c
index b9d844f88c2b..104ac9b16e8b 100644
--- a/arch/ppc/platforms/ev64360.c
+++ b/arch/ppc/platforms/ev64360.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ev64360.c
3 *
4 * Board setup routines for the Marvell EV-64360-BP Evaluation Board. 2 * Board setup routines for the Marvell EV-64360-BP Evaluation Board.
5 * 3 *
6 * Author: Lee Nicks <allinux@gmail.com> 4 * Author: Lee Nicks <allinux@gmail.com>
@@ -300,7 +298,7 @@ ev64360_fixup_eth_pdata(struct platform_device *pdev)
300} 298}
301#endif 299#endif
302 300
303static int __init 301static int
304ev64360_platform_notify(struct device *dev) 302ev64360_platform_notify(struct device *dev)
305{ 303{
306 static struct { 304 static struct {
diff --git a/arch/ppc/platforms/ev64360.h b/arch/ppc/platforms/ev64360.h
index 68eabe490397..b30f4722690a 100644
--- a/arch/ppc/platforms/ev64360.h
+++ b/arch/ppc/platforms/ev64360.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/ev64360.h
3 *
4 * Definitions for Marvell EV-64360-BP Evaluation Board. 2 * Definitions for Marvell EV-64360-BP Evaluation Board.
5 * 3 *
6 * Author: Lee Nicks <allinux@gmail.com> 4 * Author: Lee Nicks <allinux@gmail.com>
diff --git a/arch/ppc/platforms/fads.h b/arch/ppc/platforms/fads.h
index a48fb8d723e4..e1c0b1b6dcb3 100644
--- a/arch/ppc/platforms/fads.h
+++ b/arch/ppc/platforms/fads.h
@@ -112,7 +112,7 @@
112 112
113/* CPM Ethernet through SCC1 or SCC2 */ 113/* CPM Ethernet through SCC1 or SCC2 */
114 114
115#ifdef CONFIG_SCC1_ENET /* Probably 860 variant */ 115#if defined(CONFIG_SCC1_ENET) || defined(CONFIG_MPC8xx_SECOND_ETH_SCC1) /* Probably 860 variant */
116/* Bits in parallel I/O port registers that have to be set/cleared 116/* Bits in parallel I/O port registers that have to be set/cleared
117 * to configure the pins for SCC1 use. 117 * to configure the pins for SCC1 use.
118 * TCLK - CLK1, RCLK - CLK2. 118 * TCLK - CLK1, RCLK - CLK2.
diff --git a/arch/ppc/platforms/gemini.h b/arch/ppc/platforms/gemini.h
index 06de59248918..5528fd0a1216 100644
--- a/arch/ppc/platforms/gemini.h
+++ b/arch/ppc/platforms/gemini.h
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/gemini.h
3 *
4 *
5 * Onboard registers and descriptions for Synergy Microsystems' 2 * Onboard registers and descriptions for Synergy Microsystems'
6 * "Gemini" boards. 3 * "Gemini" boards.
7 * 4 *
diff --git a/arch/ppc/platforms/gemini_prom.S b/arch/ppc/platforms/gemini_prom.S
index 8c5065d56505..b181f2108001 100644
--- a/arch/ppc/platforms/gemini_prom.S
+++ b/arch/ppc/platforms/gemini_prom.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/gemini_prom.S
3 *
4 * Not really prom support code (yet), but sort of anti-prom code. The current 2 * Not really prom support code (yet), but sort of anti-prom code. The current
5 * bootloader does a number of things it shouldn't and doesn't do things that it 3 * bootloader does a number of things it shouldn't and doesn't do things that it
6 * should. The stuff in here is mainly a hodge-podge collection of setup code 4 * should. The stuff in here is mainly a hodge-podge collection of setup code
diff --git a/arch/ppc/platforms/gemini_setup.c b/arch/ppc/platforms/gemini_setup.c
index 729897c59033..0090ff154608 100644
--- a/arch/ppc/platforms/gemini_setup.c
+++ b/arch/ppc/platforms/gemini_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/gemini_setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas 3 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu) 4 * Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/platforms/hdpu.c b/arch/ppc/platforms/hdpu.c
index f945416960e9..75dc2ee87d2f 100644
--- a/arch/ppc/platforms/hdpu.c
+++ b/arch/ppc/platforms/hdpu.c
@@ -1,7 +1,4 @@
1
2/* 1/*
3 * arch/ppc/platforms/hdpu_setup.c
4 *
5 * Board setup routines for the Sky Computers HDPU Compute Blade. 2 * Board setup routines for the Sky Computers HDPU Compute Blade.
6 * 3 *
7 * Written by Brian Waite <waite@skycomputers.com> 4 * Written by Brian Waite <waite@skycomputers.com>
@@ -353,7 +350,7 @@ static void __init hdpu_fixup_cpustate_pdata(struct platform_device *pd)
353} 350}
354#endif 351#endif
355 352
356static int __init hdpu_platform_notify(struct device *dev) 353static int hdpu_platform_notify(struct device *dev)
357{ 354{
358 static struct { 355 static struct {
359 char *bus_id; 356 char *bus_id;
diff --git a/arch/ppc/platforms/hdpu.h b/arch/ppc/platforms/hdpu.h
index 07c3cffb5c7b..f9e020b6970c 100644
--- a/arch/ppc/platforms/hdpu.h
+++ b/arch/ppc/platforms/hdpu.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/hdpu.h
3 *
4 * Definitions for Sky Computers HDPU board. 2 * Definitions for Sky Computers HDPU board.
5 * 3 *
6 * Brian Waite <waite@skycomputers.com> 4 * Brian Waite <waite@skycomputers.com>
diff --git a/arch/ppc/platforms/katana.c b/arch/ppc/platforms/katana.c
index 6e58e30ceed1..ad21280e8920 100644
--- a/arch/ppc/platforms/katana.c
+++ b/arch/ppc/platforms/katana.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/katana.c
3 *
4 * Board setup routines for the Artesyn Katana cPCI boards. 2 * Board setup routines for the Artesyn Katana cPCI boards.
5 * 3 *
6 * Author: Tim Montgomery <timm@artesyncp.com> 4 * Author: Tim Montgomery <timm@artesyncp.com>
@@ -598,7 +596,7 @@ katana_fixup_mv64xxx_pdata(struct platform_device *pdev)
598} 596}
599#endif 597#endif
600 598
601static int __init 599static int
602katana_platform_notify(struct device *dev) 600katana_platform_notify(struct device *dev)
603{ 601{
604 static struct { 602 static struct {
@@ -664,12 +662,11 @@ katana_setup_mtd(void)
664 662
665 ptbl_entries = (size >= (64*MB)) ? 6 : 4; 663 ptbl_entries = (size >= (64*MB)) ? 6 : 4;
666 664
667 if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition), 665 if ((ptbl = kcalloc(ptbl_entries, sizeof(struct mtd_partition),
668 GFP_KERNEL)) == NULL) { 666 GFP_KERNEL)) == NULL) {
669 printk(KERN_WARNING "Can't alloc MTD partition table\n"); 667 printk(KERN_WARNING "Can't alloc MTD partition table\n");
670 return -ENOMEM; 668 return -ENOMEM;
671 } 669 }
672 memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition));
673 670
674 ptbl[0].name = "Monitor"; 671 ptbl[0].name = "Monitor";
675 ptbl[0].size = KATANA_MTD_MONITOR_SIZE; 672 ptbl[0].size = KATANA_MTD_MONITOR_SIZE;
diff --git a/arch/ppc/platforms/katana.h b/arch/ppc/platforms/katana.h
index 597257eff2ec..0a9b036526b1 100644
--- a/arch/ppc/platforms/katana.h
+++ b/arch/ppc/platforms/katana.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/katana.h
3 *
4 * Definitions for Artesyn Katana750i/3750 board. 2 * Definitions for Artesyn Katana750i/3750 board.
5 * 3 *
6 * Author: Tim Montgomery <timm@artesyncp.com> 4 * Author: Tim Montgomery <timm@artesyncp.com>
diff --git a/arch/ppc/platforms/lite5200.c b/arch/ppc/platforms/lite5200.c
index 7ed52dc340c9..5171b53bccb5 100644
--- a/arch/ppc/platforms/lite5200.c
+++ b/arch/ppc/platforms/lite5200.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/lite5200.c
3 *
4 * Platform support file for the Freescale LITE5200 based on MPC52xx. 2 * Platform support file for the Freescale LITE5200 based on MPC52xx.
5 * A maximum of this file should be moved to syslib/mpc52xx_????? 3 * A maximum of this file should be moved to syslib/mpc52xx_?????
6 * so that new platform based on MPC52xx need a minimal platform file 4 * so that new platform based on MPC52xx need a minimal platform file
diff --git a/arch/ppc/platforms/lite5200.h b/arch/ppc/platforms/lite5200.h
index c1de2aa47175..852a18e24d0b 100644
--- a/arch/ppc/platforms/lite5200.h
+++ b/arch/ppc/platforms/lite5200.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/lite5200.h
3 *
4 * Definitions for Freescale LITE5200 : MPC52xx Standard Development 2 * Definitions for Freescale LITE5200 : MPC52xx Standard Development
5 * Platform board support 3 * Platform board support
6 * 4 *
diff --git a/arch/ppc/platforms/lopec.c b/arch/ppc/platforms/lopec.c
index 06d247c23b82..c6445a727ca3 100644
--- a/arch/ppc/platforms/lopec.c
+++ b/arch/ppc/platforms/lopec.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/lopec.c
3 *
4 * Setup routines for the Motorola LoPEC. 2 * Setup routines for the Motorola LoPEC.
5 * 3 *
6 * Author: Dan Cox 4 * Author: Dan Cox
diff --git a/arch/ppc/platforms/mpc8272ads_setup.c b/arch/ppc/platforms/mpc8272ads_setup.c
new file mode 100644
index 000000000000..bc9b94f77e39
--- /dev/null
+++ b/arch/ppc/platforms/mpc8272ads_setup.c
@@ -0,0 +1,236 @@
1/*
2 * arch/ppc/platforms/82xx/pq2ads_pd.c
3 *
4 * MPC82xx Board-specific PlatformDevice descriptions
5 *
6 * 2005 (c) MontaVista Software, Inc.
7 * Vitaly Bordug <vbordug@ru.mvista.com>
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 */
13
14
15#include <linux/init.h>
16#include <linux/module.h>
17#include <linux/device.h>
18#include <linux/ioport.h>
19#include <linux/fs_enet_pd.h>
20#include <linux/platform_device.h>
21
22#include <asm/io.h>
23#include <asm/mpc8260.h>
24#include <asm/cpm2.h>
25#include <asm/immap_cpm2.h>
26#include <asm/irq.h>
27#include <asm/ppc_sys.h>
28#include <asm/ppcboot.h>
29
30#include "pq2ads_pd.h"
31
32static void init_fcc1_ioports(void);
33static void init_fcc2_ioports(void);
34
35static struct fs_mii_bus_info mii_bus_info = {
36 .method = fsmii_bitbang,
37 .id = 0,
38 .i.bitbang = {
39 .mdio_port = fsiop_portc,
40 .mdio_bit = 18,
41 .mdc_port = fsiop_portc,
42 .mdc_bit = 19,
43 .delay = 1,
44 },
45};
46
47static struct fs_platform_info mpc82xx_fcc1_pdata = {
48 .fs_no = fsid_fcc1,
49 .cp_page = CPM_CR_FCC1_PAGE,
50 .cp_block = CPM_CR_FCC1_SBLOCK,
51 .clk_trx = (PC_F1RXCLK | PC_F1TXCLK),
52 .clk_route = CMX1_CLK_ROUTE,
53 .clk_mask = CMX1_CLK_MASK,
54 .init_ioports = init_fcc1_ioports,
55
56 .phy_addr = 0,
57#ifdef PHY_INTERRUPT
58 .phy_irq = PHY_INTERRUPT,
59#else
60 .phy_irq = -1;
61#endif
62 .mem_offset = FCC1_MEM_OFFSET,
63 .bus_info = &mii_bus_info,
64 .rx_ring = 32,
65 .tx_ring = 32,
66 .rx_copybreak = 240,
67 .use_napi = 0,
68 .napi_weight = 17,
69};
70
71static struct fs_platform_info mpc82xx_fcc2_pdata = {
72 .fs_no = fsid_fcc2,
73 .cp_page = CPM_CR_FCC2_PAGE,
74 .cp_block = CPM_CR_FCC2_SBLOCK,
75 .clk_trx = (PC_F2RXCLK | PC_F2TXCLK),
76 .clk_route = CMX2_CLK_ROUTE,
77 .clk_mask = CMX2_CLK_MASK,
78 .init_ioports = init_fcc2_ioports,
79
80 .phy_addr = 3,
81#ifdef PHY_INTERRUPT
82 .phy_irq = PHY_INTERRUPT,
83#else
84 .phy_irq = -1;
85#endif
86 .mem_offset = FCC2_MEM_OFFSET,
87 .bus_info = &mii_bus_info,
88 .rx_ring = 32,
89 .tx_ring = 32,
90 .rx_copybreak = 240,
91 .use_napi = 0,
92 .napi_weight = 17,
93};
94
95static void init_fcc1_ioports(void)
96{
97 struct io_port *io;
98 u32 tempval;
99 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
100 u32 *bcsr = ioremap(BCSR_ADDR+4, sizeof(u32));
101
102 io = &immap->im_ioport;
103
104 /* Enable the PHY */
105 clrbits32(bcsr, BCSR1_FETHIEN);
106 setbits32(bcsr, BCSR1_FETH_RST);
107
108 /* FCC1 pins are on port A/C. */
109 /* Configure port A and C pins for FCC1 Ethernet. */
110
111 tempval = in_be32(&io->iop_pdira);
112 tempval &= ~PA1_DIRA0;
113 tempval |= PA1_DIRA1;
114 out_be32(&io->iop_pdira, tempval);
115
116 tempval = in_be32(&io->iop_psora);
117 tempval &= ~PA1_PSORA0;
118 tempval |= PA1_PSORA1;
119 out_be32(&io->iop_psora, tempval);
120
121 setbits32(&io->iop_ppara,PA1_DIRA0 | PA1_DIRA1);
122
123 /* Alter clocks */
124 tempval = PC_F1TXCLK|PC_F1RXCLK;
125
126 clrbits32(&io->iop_psorc, tempval);
127 clrbits32(&io->iop_pdirc, tempval);
128 setbits32(&io->iop_pparc, tempval);
129
130 clrbits32(&immap->im_cpmux.cmx_fcr, CMX1_CLK_MASK);
131 setbits32(&immap->im_cpmux.cmx_fcr, CMX1_CLK_ROUTE);
132 iounmap(bcsr);
133 iounmap(immap);
134}
135
136static void init_fcc2_ioports(void)
137{
138 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
139 u32 *bcsr = ioremap(BCSR_ADDR+12, sizeof(u32));
140
141 struct io_port *io;
142 u32 tempval;
143
144 immap = cpm2_immr;
145
146 io = &immap->im_ioport;
147
148 /* Enable the PHY */
149 clrbits32(bcsr, BCSR3_FETHIEN2);
150 setbits32(bcsr, BCSR3_FETH2_RST);
151
152 /* FCC2 are port B/C. */
153 /* Configure port A and C pins for FCC2 Ethernet. */
154
155 tempval = in_be32(&io->iop_pdirb);
156 tempval &= ~PB2_DIRB0;
157 tempval |= PB2_DIRB1;
158 out_be32(&io->iop_pdirb, tempval);
159
160 tempval = in_be32(&io->iop_psorb);
161 tempval &= ~PB2_PSORB0;
162 tempval |= PB2_PSORB1;
163 out_be32(&io->iop_psorb, tempval);
164
165 setbits32(&io->iop_pparb,PB2_DIRB0 | PB2_DIRB1);
166
167 tempval = PC_F2RXCLK|PC_F2TXCLK;
168
169 /* Alter clocks */
170 clrbits32(&io->iop_psorc,tempval);
171 clrbits32(&io->iop_pdirc,tempval);
172 setbits32(&io->iop_pparc,tempval);
173
174 clrbits32(&immap->im_cpmux.cmx_fcr, CMX2_CLK_MASK);
175 setbits32(&immap->im_cpmux.cmx_fcr, CMX2_CLK_ROUTE);
176
177 iounmap(bcsr);
178 iounmap(immap);
179}
180
181
182static void __init mpc8272ads_fixup_enet_pdata(struct platform_device *pdev,
183 int idx)
184{
185 bd_t* bi = (void*)__res;
186 int fs_no = fsid_fcc1+pdev->id-1;
187
188 mpc82xx_fcc1_pdata.dpram_offset = mpc82xx_fcc2_pdata.dpram_offset = (u32)cpm2_immr->im_dprambase;
189 mpc82xx_fcc1_pdata.fcc_regs_c = mpc82xx_fcc2_pdata.fcc_regs_c = (u32)cpm2_immr->im_fcc_c;
190
191 switch(fs_no) {
192 case fsid_fcc1:
193 memcpy(&mpc82xx_fcc1_pdata.macaddr,bi->bi_enetaddr,6);
194 pdev->dev.platform_data = &mpc82xx_fcc1_pdata;
195 break;
196 case fsid_fcc2:
197 memcpy(&mpc82xx_fcc2_pdata.macaddr,bi->bi_enetaddr,6);
198 mpc82xx_fcc2_pdata.macaddr[5] ^= 1;
199 pdev->dev.platform_data = &mpc82xx_fcc2_pdata;
200 break;
201 }
202}
203
204static int mpc8272ads_platform_notify(struct device *dev)
205{
206 static const struct platform_notify_dev_map dev_map[] = {
207 {
208 .bus_id = "fsl-cpm-fcc",
209 .rtn = mpc8272ads_fixup_enet_pdata
210 },
211 {
212 .bus_id = NULL
213 }
214 };
215 platform_notify_map(dev_map,dev);
216
217 return 0;
218
219}
220
221int __init mpc8272ads_init(void)
222{
223 printk(KERN_NOTICE "mpc8272ads: Init\n");
224
225 platform_notify = mpc8272ads_platform_notify;
226
227 ppc_sys_device_initfunc();
228
229 ppc_sys_device_disable_all();
230 ppc_sys_device_enable(MPC82xx_CPM_FCC1);
231 ppc_sys_device_enable(MPC82xx_CPM_FCC2);
232
233 return 0;
234}
235
236arch_initcall(mpc8272ads_init);
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c
new file mode 100644
index 000000000000..ac8fcc68afeb
--- /dev/null
+++ b/arch/ppc/platforms/mpc866ads_setup.c
@@ -0,0 +1,273 @@
1/*arch/ppc/platforms/mpc885ads-setup.c
2 *
3 * Platform setup for the Freescale mpc885ads board
4 *
5 * Vitaly Bordug <vbordug@ru.mvista.com>
6 *
7 * Copyright 2005 MontaVista Software Inc.
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 */
13
14#include <linux/config.h>
15#include <linux/init.h>
16#include <linux/module.h>
17#include <linux/param.h>
18#include <linux/string.h>
19#include <linux/ioport.h>
20#include <linux/device.h>
21
22#include <linux/fs_enet_pd.h>
23#include <linux/mii.h>
24
25#include <asm/delay.h>
26#include <asm/io.h>
27#include <asm/machdep.h>
28#include <asm/page.h>
29#include <asm/processor.h>
30#include <asm/system.h>
31#include <asm/time.h>
32#include <asm/ppcboot.h>
33#include <asm/8xx_immap.h>
34#include <asm/commproc.h>
35#include <asm/ppc_sys.h>
36#include <asm/mpc8xx.h>
37
38extern unsigned char __res[];
39
40static struct fs_mii_bus_info fec_mii_bus_info = {
41 .method = fsmii_fec,
42 .id = 0,
43};
44
45static struct fs_mii_bus_info scc_mii_bus_info = {
46 .method = fsmii_fixed,
47 .id = 0,
48 .i.fixed.speed = 10,
49 .i.fixed.duplex = 0,
50};
51
52static struct fs_platform_info mpc8xx_fec_pdata[] = {
53 {
54 .rx_ring = 128,
55 .tx_ring = 16,
56 .rx_copybreak = 240,
57
58 .use_napi = 1,
59 .napi_weight = 17,
60
61 .phy_addr = 15,
62 .phy_irq = -1,
63
64 .use_rmii = 0,
65
66 .bus_info = &fec_mii_bus_info,
67 }
68};
69
70static struct fs_platform_info mpc8xx_scc_pdata = {
71 .rx_ring = 64,
72 .tx_ring = 8,
73 .rx_copybreak = 240,
74
75 .use_napi = 1,
76 .napi_weight = 17,
77
78 .phy_addr = -1,
79 .phy_irq = -1,
80
81 .bus_info = &scc_mii_bus_info,
82};
83
84void __init board_init(void)
85{
86 volatile cpm8xx_t *cp = cpmp;
87 unsigned *bcsr_io;
88
89 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
90
91 if (bcsr_io == NULL) {
92 printk(KERN_CRIT "Could not remap BCSR1\n");
93 return;
94 }
95#ifdef CONFIG_SERIAL_CPM_SMC1
96 cp->cp_simode &= ~(0xe0000000 >> 17); /* brg1 */
97 clrbits32(bcsr_io,(0x80000000 >> 7));
98#else
99 setbits32(bcsr_io,(0x80000000 >> 7));
100
101 cp->cp_pbpar &= ~(0x000000c0);
102 cp->cp_pbdir |= 0x000000c0;
103 cp->cp_smc[0].smc_smcmr = 0;
104 cp->cp_smc[0].smc_smce = 0;
105#endif
106
107#ifdef CONFIG_SERIAL_CPM_SMC2
108 cp->cp_simode &= ~(0xe0000000 >> 1);
109 cp->cp_simode |= (0x20000000 >> 1); /* brg2 */
110 clrbits32(bcsr_io,(0x80000000 >> 13));
111#else
112 clrbits32(bcsr_io,(0x80000000 >> 13));
113 cp->cp_pbpar &= ~(0x00000c00);
114 cp->cp_pbdir |= 0x00000c00;
115 cp->cp_smc[1].smc_smcmr = 0;
116 cp->cp_smc[1].smc_smce = 0;
117#endif
118 iounmap(bcsr_io);
119}
120
121static void setup_fec1_ioports(void)
122{
123 immap_t *immap = (immap_t *) IMAP_ADDR;
124
125 setbits16(&immap->im_ioport.iop_pdpar, 0x1fff);
126 setbits16(&immap->im_ioport.iop_pddir, 0x1fff);
127}
128
129static void setup_scc1_ioports(void)
130{
131 immap_t *immap = (immap_t *) IMAP_ADDR;
132 unsigned *bcsr_io;
133
134 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
135
136 if (bcsr_io == NULL) {
137 printk(KERN_CRIT "Could not remap BCSR1\n");
138 return;
139 }
140
141 /* Enable the PHY.
142 */
143 clrbits32(bcsr_io,BCSR1_ETHEN);
144
145 /* Configure port A pins for Txd and Rxd.
146 */
147 /* Disable receive and transmit in case EPPC-Bug started it.
148 */
149 setbits16(&immap->im_ioport.iop_papar, PA_ENET_RXD | PA_ENET_TXD);
150 clrbits16(&immap->im_ioport.iop_padir, PA_ENET_RXD | PA_ENET_TXD);
151 clrbits16(&immap->im_ioport.iop_paodr, PA_ENET_TXD);
152
153 /* Configure port C pins to enable CLSN and RENA.
154 */
155 clrbits16(&immap->im_ioport.iop_pcpar, PC_ENET_CLSN | PC_ENET_RENA);
156 clrbits16(&immap->im_ioport.iop_pcdir, PC_ENET_CLSN | PC_ENET_RENA);
157 setbits16(&immap->im_ioport.iop_pcso, PC_ENET_CLSN | PC_ENET_RENA);
158 /* Configure port A for TCLK and RCLK.
159 */
160 setbits16(&immap->im_ioport.iop_papar, PA_ENET_TCLK | PA_ENET_RCLK);
161 clrbits16(&immap->im_ioport.iop_padir, PA_ENET_TCLK | PA_ENET_RCLK);
162 clrbits32(&immap->im_cpm.cp_pbpar, PB_ENET_TENA);
163 clrbits32(&immap->im_cpm.cp_pbdir, PB_ENET_TENA);
164
165 /* Configure Serial Interface clock routing.
166 * First, clear all SCC bits to zero, then set the ones we want.
167 */
168 clrbits32(&immap->im_cpm.cp_sicr, SICR_ENET_MASK);
169 setbits32(&immap->im_cpm.cp_sicr, SICR_ENET_CLKRT);
170
171 /* In the original SCC enet driver the following code is placed at
172 the end of the initialization */
173 setbits32(&immap->im_cpm.cp_pbpar, PB_ENET_TENA);
174 setbits32(&immap->im_cpm.cp_pbdir, PB_ENET_TENA);
175
176}
177
178static void mpc866ads_fixup_enet_pdata(struct platform_device *pdev, int fs_no)
179{
180 struct fs_platform_info *fpi = pdev->dev.platform_data;
181
182 volatile cpm8xx_t *cp;
183 bd_t *bd = (bd_t *) __res;
184 char *e;
185 int i;
186
187 /* Get pointer to Communication Processor */
188 cp = cpmp;
189 switch (fs_no) {
190 case fsid_fec1:
191 fpi = &mpc8xx_fec_pdata[0];
192 fpi->init_ioports = &setup_fec1_ioports;
193
194 break;
195 case fsid_scc1:
196 fpi = &mpc8xx_scc_pdata;
197 fpi->init_ioports = &setup_scc1_ioports;
198
199 break;
200 default:
201 printk(KERN_WARNING"Device %s is not supported!\n", pdev->name);
202 return;
203 }
204
205 pdev->dev.platform_data = fpi;
206 fpi->fs_no = fs_no;
207
208 e = (unsigned char *)&bd->bi_enetaddr;
209 for (i = 0; i < 6; i++)
210 fpi->macaddr[i] = *e++;
211
212 fpi->macaddr[5 - pdev->id]++;
213
214}
215
216static void mpc866ads_fixup_fec_enet_pdata(struct platform_device *pdev,
217 int idx)
218{
219 /* This is for FEC devices only */
220 if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-fec")))
221 return;
222 mpc866ads_fixup_enet_pdata(pdev, fsid_fec1 + pdev->id - 1);
223}
224
225static void mpc866ads_fixup_scc_enet_pdata(struct platform_device *pdev,
226 int idx)
227{
228 /* This is for SCC devices only */
229 if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-scc")))
230 return;
231
232 mpc866ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1);
233}
234
235static int mpc866ads_platform_notify(struct device *dev)
236{
237 static const struct platform_notify_dev_map dev_map[] = {
238 {
239 .bus_id = "fsl-cpm-fec",
240 .rtn = mpc866ads_fixup_fec_enet_pdata,
241 },
242 {
243 .bus_id = "fsl-cpm-scc",
244 .rtn = mpc866ads_fixup_scc_enet_pdata,
245 },
246 {
247 .bus_id = NULL
248 }
249 };
250
251 platform_notify_map(dev_map,dev);
252
253 return 0;
254}
255
256int __init mpc866ads_init(void)
257{
258 printk(KERN_NOTICE "mpc866ads: Init\n");
259
260 platform_notify = mpc866ads_platform_notify;
261
262 ppc_sys_device_initfunc();
263 ppc_sys_device_disable_all();
264
265#ifdef MPC8xx_SECOND_ETH_SCC1
266 ppc_sys_device_enable(MPC8xx_CPM_SCC1);
267#endif
268 ppc_sys_device_enable(MPC8xx_CPM_FEC1);
269
270 return 0;
271}
272
273arch_initcall(mpc866ads_init);
diff --git a/arch/ppc/platforms/mpc885ads_setup.c b/arch/ppc/platforms/mpc885ads_setup.c
new file mode 100644
index 000000000000..50a99e5f7c68
--- /dev/null
+++ b/arch/ppc/platforms/mpc885ads_setup.c
@@ -0,0 +1,389 @@
1/*arch/ppc/platforms/mpc885ads-setup.c
2 *
3 * Platform setup for the Freescale mpc885ads board
4 *
5 * Vitaly Bordug <vbordug@ru.mvista.com>
6 *
7 * Copyright 2005 MontaVista Software Inc.
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 */
13
14#include <linux/config.h>
15#include <linux/init.h>
16#include <linux/module.h>
17#include <linux/param.h>
18#include <linux/string.h>
19#include <linux/ioport.h>
20#include <linux/device.h>
21
22#include <linux/fs_enet_pd.h>
23#include <linux/mii.h>
24
25#include <asm/delay.h>
26#include <asm/io.h>
27#include <asm/machdep.h>
28#include <asm/page.h>
29#include <asm/processor.h>
30#include <asm/system.h>
31#include <asm/time.h>
32#include <asm/ppcboot.h>
33#include <asm/8xx_immap.h>
34#include <asm/commproc.h>
35#include <asm/ppc_sys.h>
36
37extern unsigned char __res[];
38
39static void __init mpc885ads_scc_phy_init(char);
40
41static struct fs_mii_bus_info fec_mii_bus_info = {
42 .method = fsmii_fec,
43 .id = 0,
44};
45
46static struct fs_mii_bus_info scc_mii_bus_info = {
47#ifdef CONFIG_SCC_ENET_8xx_FIXED
48 .method = fsmii_fixed,
49#else
50 .method = fsmii_fec,
51#endif
52
53 .id = 0,
54};
55
56static struct fs_platform_info mpc8xx_fec_pdata[] = {
57 {
58 .rx_ring = 128,
59 .tx_ring = 16,
60 .rx_copybreak = 240,
61
62 .use_napi = 1,
63 .napi_weight = 17,
64
65 .phy_addr = 0,
66 .phy_irq = SIU_IRQ7,
67
68 .bus_info = &fec_mii_bus_info,
69 }, {
70 .rx_ring = 128,
71 .tx_ring = 16,
72 .rx_copybreak = 240,
73
74 .use_napi = 1,
75 .napi_weight = 17,
76
77 .phy_addr = 1,
78 .phy_irq = SIU_IRQ7,
79
80 .bus_info = &fec_mii_bus_info,
81 }
82};
83
84static struct fs_platform_info mpc8xx_scc_pdata = {
85 .rx_ring = 64,
86 .tx_ring = 8,
87 .rx_copybreak = 240,
88
89 .use_napi = 1,
90 .napi_weight = 17,
91
92 .phy_addr = 2,
93#ifdef CONFIG_MPC8xx_SCC_ENET_FIXED
94 .phy_irq = -1,
95#else
96 .phy_irq = SIU_IRQ7,
97#endif
98
99 .bus_info = &scc_mii_bus_info,
100};
101
102void __init board_init(void)
103{
104 volatile cpm8xx_t *cp = cpmp;
105 unsigned int *bcsr_io;
106
107#ifdef CONFIG_FS_ENET
108 immap_t *immap = (immap_t *) IMAP_ADDR;
109#endif
110 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
111
112 if (bcsr_io == NULL) {
113 printk(KERN_CRIT "Could not remap BCSR\n");
114 return;
115 }
116#ifdef CONFIG_SERIAL_CPM_SMC1
117 cp->cp_simode &= ~(0xe0000000 >> 17); /* brg1 */
118 clrbits32(bcsr_io, BCSR1_RS232EN_1);
119#else
120 setbits32(bcsr_io,BCSR1_RS232EN_1);
121 cp->cp_smc[0].smc_smcmr = 0;
122 cp->cp_smc[0].smc_smce = 0;
123#endif
124
125#ifdef CONFIG_SERIAL_CPM_SMC2
126 cp->cp_simode &= ~(0xe0000000 >> 1);
127 cp->cp_simode |= (0x20000000 >> 1); /* brg2 */
128 clrbits32(bcsr_io,BCSR1_RS232EN_2);
129#else
130 setbits32(bcsr_io,BCSR1_RS232EN_2);
131 cp->cp_smc[1].smc_smcmr = 0;
132 cp->cp_smc[1].smc_smce = 0;
133#endif
134 iounmap(bcsr_io);
135
136#ifdef CONFIG_FS_ENET
137 /* use MDC for MII (common) */
138 setbits16(&immap->im_ioport.iop_pdpar, 0x0080);
139 clrbits16(&immap->im_ioport.iop_pddir, 0x0080);
140#endif
141}
142
143static void setup_fec1_ioports(void)
144{
145 immap_t *immap = (immap_t *) IMAP_ADDR;
146
147 /* configure FEC1 pins */
148 setbits16(&immap->im_ioport.iop_papar, 0xf830);
149 setbits16(&immap->im_ioport.iop_padir, 0x0830);
150 clrbits16(&immap->im_ioport.iop_padir, 0xf000);
151 setbits32(&immap->im_cpm.cp_pbpar, 0x00001001);
152
153 clrbits32(&immap->im_cpm.cp_pbdir, 0x00001001);
154 setbits16(&immap->im_ioport.iop_pcpar, 0x000c);
155 clrbits16(&immap->im_ioport.iop_pcdir, 0x000c);
156 setbits32(&immap->im_cpm.cp_pepar, 0x00000003);
157
158 setbits32(&immap->im_cpm.cp_pedir, 0x00000003);
159 clrbits32(&immap->im_cpm.cp_peso, 0x00000003);
160 clrbits32(&immap->im_cpm.cp_cptr, 0x00000100);
161}
162
163static void setup_fec2_ioports(void)
164{
165 immap_t *immap = (immap_t *) IMAP_ADDR;
166
167 /* configure FEC2 pins */
168 setbits32(&immap->im_cpm.cp_pepar, 0x0003fffc);
169 setbits32(&immap->im_cpm.cp_pedir, 0x0003fffc);
170 setbits32(&immap->im_cpm.cp_peso, 0x00037800);
171 clrbits32(&immap->im_cpm.cp_peso, 0x000087fc);
172 clrbits32(&immap->im_cpm.cp_cptr, 0x00000080);
173}
174
175static void setup_scc3_ioports(void)
176{
177 immap_t *immap = (immap_t *) IMAP_ADDR;
178 unsigned *bcsr_io;
179
180 bcsr_io = ioremap(BCSR_ADDR, BCSR_SIZE);
181
182 if (bcsr_io == NULL) {
183 printk(KERN_CRIT "Could not remap BCSR\n");
184 return;
185 }
186
187 /* Enable the PHY.
188 */
189 setbits32(bcsr_io+4, BCSR4_ETH10_RST);
190 /* Configure port A pins for Txd and Rxd.
191 */
192 setbits16(&immap->im_ioport.iop_papar, PA_ENET_RXD | PA_ENET_TXD);
193 clrbits16(&immap->im_ioport.iop_padir, PA_ENET_RXD | PA_ENET_TXD);
194
195 /* Configure port C pins to enable CLSN and RENA.
196 */
197 clrbits16(&immap->im_ioport.iop_pcpar, PC_ENET_CLSN | PC_ENET_RENA);
198 clrbits16(&immap->im_ioport.iop_pcdir, PC_ENET_CLSN | PC_ENET_RENA);
199 setbits16(&immap->im_ioport.iop_pcso, PC_ENET_CLSN | PC_ENET_RENA);
200
201 /* Configure port E for TCLK and RCLK.
202 */
203 setbits32(&immap->im_cpm.cp_pepar, PE_ENET_TCLK | PE_ENET_RCLK);
204 clrbits32(&immap->im_cpm.cp_pepar, PE_ENET_TENA);
205 clrbits32(&immap->im_cpm.cp_pedir,
206 PE_ENET_TCLK | PE_ENET_RCLK | PE_ENET_TENA);
207 clrbits32(&immap->im_cpm.cp_peso, PE_ENET_TCLK | PE_ENET_RCLK);
208 setbits32(&immap->im_cpm.cp_peso, PE_ENET_TENA);
209
210 /* Configure Serial Interface clock routing.
211 * First, clear all SCC bits to zero, then set the ones we want.
212 */
213 clrbits32(&immap->im_cpm.cp_sicr, SICR_ENET_MASK);
214 setbits32(&immap->im_cpm.cp_sicr, SICR_ENET_CLKRT);
215
216 /* Disable Rx and Tx. SMC1 sshould be stopped if SCC3 eternet are used.
217 */
218 immap->im_cpm.cp_smc[0].smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
219 /* On the MPC885ADS SCC ethernet PHY is initialized in the full duplex mode
220 * by H/W setting after reset. SCC ethernet controller support only half duplex.
221 * This discrepancy of modes causes a lot of carrier lost errors.
222 */
223
224 /* In the original SCC enet driver the following code is placed at
225 the end of the initialization */
226 setbits32(&immap->im_cpm.cp_pepar, PE_ENET_TENA);
227 clrbits32(&immap->im_cpm.cp_pedir, PE_ENET_TENA);
228 setbits32(&immap->im_cpm.cp_peso, PE_ENET_TENA);
229
230 setbits32(bcsr_io+1, BCSR1_ETHEN);
231 iounmap(bcsr_io);
232}
233
234static void mpc885ads_fixup_enet_pdata(struct platform_device *pdev, int fs_no)
235{
236 struct fs_platform_info *fpi = pdev->dev.platform_data;
237
238 volatile cpm8xx_t *cp;
239 bd_t *bd = (bd_t *) __res;
240 char *e;
241 int i;
242
243 /* Get pointer to Communication Processor */
244 cp = cpmp;
245 switch (fs_no) {
246 case fsid_fec1:
247 fpi = &mpc8xx_fec_pdata[0];
248 fpi->init_ioports = &setup_fec1_ioports;
249 break;
250 case fsid_fec2:
251 fpi = &mpc8xx_fec_pdata[1];
252 fpi->init_ioports = &setup_fec2_ioports;
253 break;
254 case fsid_scc3:
255 fpi = &mpc8xx_scc_pdata;
256 fpi->init_ioports = &setup_scc3_ioports;
257 mpc885ads_scc_phy_init(fpi->phy_addr);
258 break;
259 default:
260 printk(KERN_WARNING"Device %s is not supported!\n", pdev->name);
261 return;
262 }
263
264 pdev->dev.platform_data = fpi;
265 fpi->fs_no = fs_no;
266
267 e = (unsigned char *)&bd->bi_enetaddr;
268 for (i = 0; i < 6; i++)
269 fpi->macaddr[i] = *e++;
270
271 fpi->macaddr[5 - pdev->id]++;
272
273}
274
275static void mpc885ads_fixup_fec_enet_pdata(struct platform_device *pdev,
276 int idx)
277{
278 /* This is for FEC devices only */
279 if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-fec")))
280 return;
281 mpc885ads_fixup_enet_pdata(pdev, fsid_fec1 + pdev->id - 1);
282}
283
284static void __init mpc885ads_fixup_scc_enet_pdata(struct platform_device *pdev,
285 int idx)
286{
287 /* This is for SCC devices only */
288 if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-scc")))
289 return;
290
291 mpc885ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1);
292}
293
294/* SCC ethernet controller does not have MII management channel. FEC1 MII
295 * channel is used to communicate with the 10Mbit PHY.
296 */
297
298#define MII_ECNTRL_PINMUX 0x4
299#define FEC_ECNTRL_PINMUX 0x00000004
300#define FEC_RCNTRL_MII_MODE 0x00000004
301
302/* Make MII read/write commands.
303 */
304#define mk_mii_write(REG, VAL, PHY_ADDR) (0x50020000 | (((REG) & 0x1f) << 18) | \
305 ((VAL) & 0xffff) | ((PHY_ADDR) << 23))
306
307static void mpc885ads_scc_phy_init(char phy_addr)
308{
309 volatile immap_t *immap;
310 volatile fec_t *fecp;
311 bd_t *bd;
312
313 bd = (bd_t *) __res;
314 immap = (immap_t *) IMAP_ADDR; /* pointer to internal registers */
315 fecp = &(immap->im_cpm.cp_fec);
316
317 /* Enable MII pins of the FEC1
318 */
319 setbits16(&immap->im_ioport.iop_pdpar, 0x0080);
320 clrbits16(&immap->im_ioport.iop_pddir, 0x0080);
321 /* Set MII speed to 2.5 MHz
322 */
323 out_be32(&fecp->fec_mii_speed,
324 ((((bd->bi_intfreq + 4999999) / 2500000) / 2) & 0x3F) << 1);
325
326 /* Enable FEC pin MUX
327 */
328 setbits32(&fecp->fec_ecntrl, MII_ECNTRL_PINMUX);
329 setbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE);
330
331 out_be32(&fecp->fec_mii_data,
332 mk_mii_write(MII_BMCR, BMCR_ISOLATE, phy_addr));
333 udelay(100);
334 out_be32(&fecp->fec_mii_data,
335 mk_mii_write(MII_ADVERTISE,
336 ADVERTISE_10HALF | ADVERTISE_CSMA, phy_addr));
337 udelay(100);
338
339 /* Disable FEC MII settings
340 */
341 clrbits32(&fecp->fec_ecntrl, MII_ECNTRL_PINMUX);
342 clrbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE);
343 out_be32(&fecp->fec_mii_speed, 0);
344}
345
346static int mpc885ads_platform_notify(struct device *dev)
347{
348
349 static const struct platform_notify_dev_map dev_map[] = {
350 {
351 .bus_id = "fsl-cpm-fec",
352 .rtn = mpc885ads_fixup_fec_enet_pdata,
353 },
354 {
355 .bus_id = "fsl-cpm-scc",
356 .rtn = mpc885ads_fixup_scc_enet_pdata,
357 },
358 {
359 .bus_id = NULL
360 }
361 };
362
363 platform_notify_map(dev_map,dev);
364
365}
366
367int __init mpc885ads_init(void)
368{
369 printk(KERN_NOTICE "mpc885ads: Init\n");
370
371 platform_notify = mpc885ads_platform_notify;
372
373 ppc_sys_device_initfunc();
374 ppc_sys_device_disable_all();
375
376 ppc_sys_device_enable(MPC8xx_CPM_FEC1);
377
378#ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3
379 ppc_sys_device_enable(MPC8xx_CPM_SCC1);
380
381#endif
382#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2
383 ppc_sys_device_enable(MPC8xx_CPM_FEC2);
384#endif
385
386 return 0;
387}
388
389arch_initcall(mpc885ads_init);
diff --git a/arch/ppc/platforms/mvme5100.c b/arch/ppc/platforms/mvme5100.c
index 108eb182dddc..c717cd92c028 100644
--- a/arch/ppc/platforms/mvme5100.c
+++ b/arch/ppc/platforms/mvme5100.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/mvme5100.c
3 *
4 * Board setup routines for the Motorola MVME5100. 2 * Board setup routines for the Motorola MVME5100.
5 * 3 *
6 * Author: Matt Porter <mporter@mvista.com> 4 * Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/pal4.h b/arch/ppc/platforms/pal4.h
index 641a11a31657..8569c423d887 100644
--- a/arch/ppc/platforms/pal4.h
+++ b/arch/ppc/platforms/pal4.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pal4.h
3 *
4 * Definitions for SBS Palomar IV board 2 * Definitions for SBS Palomar IV board
5 * 3 *
6 * Author: Dan Cox 4 * Author: Dan Cox
diff --git a/arch/ppc/platforms/pal4_pci.c b/arch/ppc/platforms/pal4_pci.c
index c3b1b757a48b..d81ae1c7e1cf 100644
--- a/arch/ppc/platforms/pal4_pci.c
+++ b/arch/ppc/platforms/pal4_pci.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pal4_pci.c
3 *
4 * PCI support for SBS Palomar IV 2 * PCI support for SBS Palomar IV
5 * 3 *
6 * Author: Dan Cox 4 * Author: Dan Cox
diff --git a/arch/ppc/platforms/pal4_serial.h b/arch/ppc/platforms/pal4_serial.h
index a715c66e1adf..a75343224cfd 100644
--- a/arch/ppc/platforms/pal4_serial.h
+++ b/arch/ppc/platforms/pal4_serial.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pal4_serial.h
3 *
4 * Definitions for SBS PalomarIV serial support 2 * Definitions for SBS PalomarIV serial support
5 * 3 *
6 * Author: Dan Cox 4 * Author: Dan Cox
diff --git a/arch/ppc/platforms/pal4_setup.c b/arch/ppc/platforms/pal4_setup.c
index f93a3f871932..3c3d881df00d 100644
--- a/arch/ppc/platforms/pal4_setup.c
+++ b/arch/ppc/platforms/pal4_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pal4_setup.c
3 *
4 * Board setup routines for the SBS PalomarIV. 2 * Board setup routines for the SBS PalomarIV.
5 * 3 *
6 * Author: Dan Cox 4 * Author: Dan Cox
diff --git a/arch/ppc/platforms/powerpmc250.c b/arch/ppc/platforms/powerpmc250.c
index e6b520e6e13f..c3a86be11fb7 100644
--- a/arch/ppc/platforms/powerpmc250.c
+++ b/arch/ppc/platforms/powerpmc250.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/powerpmc250.c
3 *
4 * Board setup routines for Force PowerPMC-250 Processor PMC 2 * Board setup routines for Force PowerPMC-250 Processor PMC
5 * 3 *
6 * Author: Troy Benjegerdes <tbenjegerdes@mvista.com> 4 * Author: Troy Benjegerdes <tbenjegerdes@mvista.com>
diff --git a/arch/ppc/platforms/pplus.c b/arch/ppc/platforms/pplus.c
index 22bd40cfb092..de2761ebe0d9 100644
--- a/arch/ppc/platforms/pplus.c
+++ b/arch/ppc/platforms/pplus.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pplus.c
3 *
4 * Board and PCI setup routines for MCG PowerPlus 2 * Board and PCI setup routines for MCG PowerPlus
5 * 3 *
6 * Author: Randy Vinson <rvinson@mvista.com> 4 * Author: Randy Vinson <rvinson@mvista.com>
diff --git a/arch/ppc/platforms/pplus.h b/arch/ppc/platforms/pplus.h
index 90f0cb2d409f..a07cbbdd72c6 100644
--- a/arch/ppc/platforms/pplus.h
+++ b/arch/ppc/platforms/pplus.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pplus.h
3 *
4 * Definitions for Motorola MCG Falcon/Raven & HAWK North Bridge & Memory ctlr. 2 * Definitions for Motorola MCG Falcon/Raven & HAWK North Bridge & Memory ctlr.
5 * 3 *
6 * Author: Mark A. Greerinclude/asm-ppc/hawk.h 4 * Author: Mark A. Greerinclude/asm-ppc/hawk.h
diff --git a/arch/ppc/platforms/pq2ads.c b/arch/ppc/platforms/pq2ads.c
index 71c9fca1fe9b..3365fd788a7a 100644
--- a/arch/ppc/platforms/pq2ads.c
+++ b/arch/ppc/platforms/pq2ads.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/pq2ads.c
3 *
4 * PQ2ADS platform support 2 * PQ2ADS platform support
5 * 3 *
6 * Author: Kumar Gala <galak@kernel.crashing.org> 4 * Author: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/pq2ads.h b/arch/ppc/platforms/pq2ads.h
index 067d9a5aebc1..6b26dd36c640 100644
--- a/arch/ppc/platforms/pq2ads.h
+++ b/arch/ppc/platforms/pq2ads.h
@@ -13,6 +13,10 @@
13 13
14#include <asm/ppcboot.h> 14#include <asm/ppcboot.h>
15 15
16#if defined(CONFIG_ADS8272)
17#define BOARD_CHIP_NAME "8272"
18#endif
19
16/* Memory map is configured by the PROM startup. 20/* Memory map is configured by the PROM startup.
17 * We just map a few things we need. The CSR is actually 4 byte-wide 21 * We just map a few things we need. The CSR is actually 4 byte-wide
18 * registers that can be accessed as 8-, 16-, or 32-bit values. 22 * registers that can be accessed as 8-, 16-, or 32-bit values.
diff --git a/arch/ppc/platforms/pq2ads_pd.h b/arch/ppc/platforms/pq2ads_pd.h
new file mode 100644
index 000000000000..8f14a43eafec
--- /dev/null
+++ b/arch/ppc/platforms/pq2ads_pd.h
@@ -0,0 +1,114 @@
1#ifndef __PQ2ADS_PD_H
2#define __PQ2ADS_PD_H
3/*
4 * arch/ppc/platforms/82xx/pq2ads_pd.h
5 *
6 * Some defines for MPC82xx board-specific PlatformDevice descriptions
7 *
8 * 2005 (c) MontaVista Software, Inc.
9 * Vitaly Bordug <vbordug@ru.mvista.com>
10 *
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any
13 * kind, whether express or implied.
14 */
15
16/* FCC1 Clock Source Configuration. These can be redefined in the board specific file.
17 Can only choose from CLK9-12 */
18
19#define F1_RXCLK 11
20#define F1_TXCLK 10
21
22/* FCC2 Clock Source Configuration. These can be redefined in the board specific file.
23 Can only choose from CLK13-16 */
24#define F2_RXCLK 15
25#define F2_TXCLK 16
26
27/* FCC3 Clock Source Configuration. These can be redefined in the board specific file.
28 Can only choose from CLK13-16 */
29#define F3_RXCLK 13
30#define F3_TXCLK 14
31
32/* Automatically generates register configurations */
33#define PC_CLK(x) ((uint)(1<<(x-1))) /* FCC CLK I/O ports */
34
35#define CMXFCR_RF1CS(x) ((uint)((x-5)<<27)) /* FCC1 Receive Clock Source */
36#define CMXFCR_TF1CS(x) ((uint)((x-5)<<24)) /* FCC1 Transmit Clock Source */
37#define CMXFCR_RF2CS(x) ((uint)((x-9)<<19)) /* FCC2 Receive Clock Source */
38#define CMXFCR_TF2CS(x) ((uint)((x-9)<<16)) /* FCC2 Transmit Clock Source */
39#define CMXFCR_RF3CS(x) ((uint)((x-9)<<11)) /* FCC3 Receive Clock Source */
40#define CMXFCR_TF3CS(x) ((uint)((x-9)<<8)) /* FCC3 Transmit Clock Source */
41
42#define PC_F1RXCLK PC_CLK(F1_RXCLK)
43#define PC_F1TXCLK PC_CLK(F1_TXCLK)
44#define CMX1_CLK_ROUTE (CMXFCR_RF1CS(F1_RXCLK) | CMXFCR_TF1CS(F1_TXCLK))
45#define CMX1_CLK_MASK ((uint)0xff000000)
46
47#define PC_F2RXCLK PC_CLK(F2_RXCLK)
48#define PC_F2TXCLK PC_CLK(F2_TXCLK)
49#define CMX2_CLK_ROUTE (CMXFCR_RF2CS(F2_RXCLK) | CMXFCR_TF2CS(F2_TXCLK))
50#define CMX2_CLK_MASK ((uint)0x00ff0000)
51
52#define PC_F3RXCLK PC_CLK(F3_RXCLK)
53#define PC_F3TXCLK PC_CLK(F3_TXCLK)
54#define CMX3_CLK_ROUTE (CMXFCR_RF3CS(F3_RXCLK) | CMXFCR_TF3CS(F3_TXCLK))
55#define CMX3_CLK_MASK ((uint)0x0000ff00)
56
57/* I/O Pin assignment for FCC1. I don't yet know the best way to do this,
58 * but there is little variation among the choices.
59 */
60#define PA1_COL 0x00000001U
61#define PA1_CRS 0x00000002U
62#define PA1_TXER 0x00000004U
63#define PA1_TXEN 0x00000008U
64#define PA1_RXDV 0x00000010U
65#define PA1_RXER 0x00000020U
66#define PA1_TXDAT 0x00003c00U
67#define PA1_RXDAT 0x0003c000U
68#define PA1_PSORA0 (PA1_RXDAT | PA1_TXDAT)
69#define PA1_PSORA1 (PA1_COL | PA1_CRS | PA1_TXER | PA1_TXEN | \
70 PA1_RXDV | PA1_RXER)
71#define PA1_DIRA0 (PA1_RXDAT | PA1_CRS | PA1_COL | PA1_RXER | PA1_RXDV)
72#define PA1_DIRA1 (PA1_TXDAT | PA1_TXEN | PA1_TXER)
73
74
75/* I/O Pin assignment for FCC2. I don't yet know the best way to do this,
76 * but there is little variation among the choices.
77 */
78#define PB2_TXER 0x00000001U
79#define PB2_RXDV 0x00000002U
80#define PB2_TXEN 0x00000004U
81#define PB2_RXER 0x00000008U
82#define PB2_COL 0x00000010U
83#define PB2_CRS 0x00000020U
84#define PB2_TXDAT 0x000003c0U
85#define PB2_RXDAT 0x00003c00U
86#define PB2_PSORB0 (PB2_RXDAT | PB2_TXDAT | PB2_CRS | PB2_COL | \
87 PB2_RXER | PB2_RXDV | PB2_TXER)
88#define PB2_PSORB1 (PB2_TXEN)
89#define PB2_DIRB0 (PB2_RXDAT | PB2_CRS | PB2_COL | PB2_RXER | PB2_RXDV)
90#define PB2_DIRB1 (PB2_TXDAT | PB2_TXEN | PB2_TXER)
91
92
93/* I/O Pin assignment for FCC3. I don't yet know the best way to do this,
94 * but there is little variation among the choices.
95 */
96#define PB3_RXDV 0x00004000U
97#define PB3_RXER 0x00008000U
98#define PB3_TXER 0x00010000U
99#define PB3_TXEN 0x00020000U
100#define PB3_COL 0x00040000U
101#define PB3_CRS 0x00080000U
102#define PB3_TXDAT 0x0f000000U
103#define PB3_RXDAT 0x00f00000U
104#define PB3_PSORB0 (PB3_RXDAT | PB3_TXDAT | PB3_CRS | PB3_COL | \
105 PB3_RXER | PB3_RXDV | PB3_TXER | PB3_TXEN)
106#define PB3_PSORB1 0
107#define PB3_DIRB0 (PB3_RXDAT | PB3_CRS | PB3_COL | PB3_RXER | PB3_RXDV)
108#define PB3_DIRB1 (PB3_TXDAT | PB3_TXEN | PB3_TXER)
109
110#define FCC_MEM_OFFSET(x) (CPM_FCC_SPECIAL_BASE + (x*128))
111#define FCC1_MEM_OFFSET FCC_MEM_OFFSET(0)
112#define FCC2_MEM_OFFSET FCC_MEM_OFFSET(1)
113
114#endif
diff --git a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
index d06535802003..a0fc628ffb1e 100644
--- a/arch/ppc/platforms/prep_setup.c
+++ b/arch/ppc/platforms/prep_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas 3 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu) 4 * Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/platforms/prpmc750.c b/arch/ppc/platforms/prpmc750.c
index 0bb14a5e824c..cdd9cfb13ee9 100644
--- a/arch/ppc/platforms/prpmc750.c
+++ b/arch/ppc/platforms/prpmc750.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/prpmc750_setup.c
3 *
4 * Board setup routines for Motorola PrPMC750 2 * Board setup routines for Motorola PrPMC750
5 * 3 *
6 * Author: Matt Porter <mporter@mvista.com> 4 * Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/prpmc800.c b/arch/ppc/platforms/prpmc800.c
index de7baefacd3a..e459a199fb1d 100644
--- a/arch/ppc/platforms/prpmc800.c
+++ b/arch/ppc/platforms/prpmc800.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/prpmc800.c
3 *
4 * Author: Dale Farnsworth <dale.farnsworth@mvista.com> 2 * Author: Dale Farnsworth <dale.farnsworth@mvista.com>
5 * 3 *
6 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under 4 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/radstone_ppc7d.c b/arch/ppc/platforms/radstone_ppc7d.c
index 872c0a3ba3c7..bc26b6d71c1d 100644
--- a/arch/ppc/platforms/radstone_ppc7d.c
+++ b/arch/ppc/platforms/radstone_ppc7d.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/radstone_ppc7d.c
3 *
4 * Board setup routines for the Radstone PPC7D boards. 2 * Board setup routines for the Radstone PPC7D boards.
5 * 3 *
6 * Author: James Chapman <jchapman@katalix.com> 4 * Author: James Chapman <jchapman@katalix.com>
@@ -685,11 +683,10 @@ ppc7d_fixup_i2c_pdata(struct platform_device *pdev)
685 683
686 pdata = pdev->dev.platform_data; 684 pdata = pdev->dev.platform_data;
687 if (pdata == NULL) { 685 if (pdata == NULL) {
688 pdata = kmalloc(sizeof(*pdata), GFP_KERNEL); 686 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
689 if (pdata == NULL) 687 if (pdata == NULL)
690 return; 688 return;
691 689
692 memset(pdata, 0, sizeof(*pdata));
693 pdev->dev.platform_data = pdata; 690 pdev->dev.platform_data = pdata;
694 } 691 }
695 692
@@ -712,7 +709,7 @@ ppc7d_fixup_i2c_pdata(struct platform_device *pdev)
712} 709}
713#endif 710#endif
714 711
715static int __init ppc7d_platform_notify(struct device *dev) 712static int ppc7d_platform_notify(struct device *dev)
716{ 713{
717 static struct { 714 static struct {
718 char *bus_id; 715 char *bus_id;
diff --git a/arch/ppc/platforms/radstone_ppc7d.h b/arch/ppc/platforms/radstone_ppc7d.h
index 938375510be4..2bb093a0c03e 100644
--- a/arch/ppc/platforms/radstone_ppc7d.h
+++ b/arch/ppc/platforms/radstone_ppc7d.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/radstone_ppc7d.h
3 *
4 * Board definitions for the Radstone PPC7D boards. 2 * Board definitions for the Radstone PPC7D boards.
5 * 3 *
6 * Author: James Chapman <jchapman@katalix.com> 4 * Author: James Chapman <jchapman@katalix.com>
diff --git a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
index 9eeed3572309..6dc459decb2d 100644
--- a/arch/ppc/platforms/sandpoint.c
+++ b/arch/ppc/platforms/sandpoint.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/sandpoint_setup.c
3 *
4 * Board setup routines for the Motorola SPS Sandpoint Test Platform. 2 * Board setup routines for the Motorola SPS Sandpoint Test Platform.
5 * 3 *
6 * Author: Mark A. Greer 4 * Author: Mark A. Greer
diff --git a/arch/ppc/platforms/sandpoint.h b/arch/ppc/platforms/sandpoint.h
index f4e982cb69df..3b64e6418489 100644
--- a/arch/ppc/platforms/sandpoint.h
+++ b/arch/ppc/platforms/sandpoint.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/sandpoint.h
3 *
4 * Definitions for Motorola SPS Sandpoint Test Platform 2 * Definitions for Motorola SPS Sandpoint Test Platform
5 * 3 *
6 * Author: Mark A. Greer 4 * Author: Mark A. Greer
diff --git a/arch/ppc/platforms/sbc82xx.c b/arch/ppc/platforms/sbc82xx.c
index 74c9ff72c3dd..866807b4ad0b 100644
--- a/arch/ppc/platforms/sbc82xx.c
+++ b/arch/ppc/platforms/sbc82xx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/sbc82xx.c
3 *
4 * SBC82XX platform support 2 * SBC82XX platform support
5 * 3 *
6 * Author: Guy Streeter <streeter@redhat.com> 4 * Author: Guy Streeter <streeter@redhat.com>
diff --git a/arch/ppc/platforms/spruce.c b/arch/ppc/platforms/spruce.c
index 69e1de7971f2..3783deccd9b2 100644
--- a/arch/ppc/platforms/spruce.c
+++ b/arch/ppc/platforms/spruce.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/spruce.c
3 *
4 * Board and PCI setup routines for IBM Spruce 2 * Board and PCI setup routines for IBM Spruce
5 * 3 *
6 * Author: MontaVista Software <source@mvista.com> 4 * Author: MontaVista Software <source@mvista.com>
diff --git a/arch/ppc/platforms/tqm8260_setup.c b/arch/ppc/platforms/tqm8260_setup.c
index 3409139330b1..b766339f44ac 100644
--- a/arch/ppc/platforms/tqm8260_setup.c
+++ b/arch/ppc/platforms/tqm8260_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/tqm8260_setup.c
3 *
4 * TQM8260 platform support 2 * TQM8260 platform support
5 * 3 *
6 * Author: Allen Curtis <acurtis@onz.com> 4 * Author: Allen Curtis <acurtis@onz.com>
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index 159dcd92a6d1..5cb62c6a51c8 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -17,8 +17,8 @@ obj-$(CONFIG_440GX) += ibm440gx_common.o
17obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o 17obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o
18obj-$(CONFIG_440SPE) += ibm440gx_common.o ibm440sp_common.o ppc440spe_pcie.o 18obj-$(CONFIG_440SPE) += ibm440gx_common.o ibm440sp_common.o ppc440spe_pcie.o
19ifeq ($(CONFIG_4xx),y) 19ifeq ($(CONFIG_4xx),y)
20ifeq ($(CONFIG_VIRTEX_II_PRO),y) 20ifeq ($(CONFIG_XILINX_VIRTEX),y)
21obj-$(CONFIG_40x) += xilinx_pic.o 21obj-$(CONFIG_40x) += xilinx_pic.o ppc_sys.o
22else 22else
23ifeq ($(CONFIG_403),y) 23ifeq ($(CONFIG_403),y)
24obj-$(CONFIG_40x) += ppc403_pic.o 24obj-$(CONFIG_40x) += ppc403_pic.o
diff --git a/arch/ppc/syslib/cpc700.h b/arch/ppc/syslib/cpc700.h
index f2c002531019..0a8a5d84390f 100644
--- a/arch/ppc/syslib/cpc700.h
+++ b/arch/ppc/syslib/cpc700.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/cpc700.h
3 *
4 * Header file for IBM CPC700 Host Bridge, et. al. 2 * Header file for IBM CPC700 Host Bridge, et. al.
5 * 3 *
6 * Author: Mark A. Greer 4 * Author: Mark A. Greer
diff --git a/arch/ppc/syslib/cpc700_pic.c b/arch/ppc/syslib/cpc700_pic.c
index 75fe8eb10693..5add0a919ef6 100644
--- a/arch/ppc/syslib/cpc700_pic.c
+++ b/arch/ppc/syslib/cpc700_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/cpc700_pic.c
3 *
4 * Interrupt controller support for IBM Spruce 2 * Interrupt controller support for IBM Spruce
5 * 3 *
6 * Authors: Mark Greer, Matt Porter, and Johnnie Peters 4 * Authors: Mark Greer, Matt Porter, and Johnnie Peters
diff --git a/arch/ppc/syslib/cpc710.h b/arch/ppc/syslib/cpc710.h
index cc0afd804029..5299bf8b5d01 100644
--- a/arch/ppc/syslib/cpc710.h
+++ b/arch/ppc/syslib/cpc710.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/cpc710.h
3 *
4 * Definitions for the IBM CPC710 PCI Host Bridge 2 * Definitions for the IBM CPC710 PCI Host Bridge
5 * 3 *
6 * Author: Matt Porter <mporter@mvista.com> 4 * Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/syslib/gen550.h b/arch/ppc/syslib/gen550.h
index 039d249e19a8..5254d3cdbca6 100644
--- a/arch/ppc/syslib/gen550.h
+++ b/arch/ppc/syslib/gen550.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/gen550.h
3 *
4 * gen550 prototypes 2 * gen550 prototypes
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/gen550_dbg.c b/arch/ppc/syslib/gen550_dbg.c
index 9ef0113c83d1..9fcff74bfdd0 100644
--- a/arch/ppc/syslib/gen550_dbg.c
+++ b/arch/ppc/syslib/gen550_dbg.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/gen550_dbg.c
3 *
4 * A library of polled 16550 serial routines. These are intended to 2 * A library of polled 16550 serial routines. These are intended to
5 * be used to support progress messages, xmon, kgdb, etc. on a 3 * be used to support progress messages, xmon, kgdb, etc. on a
6 * variety of platforms. 4 * variety of platforms.
diff --git a/arch/ppc/syslib/gen550_kgdb.c b/arch/ppc/syslib/gen550_kgdb.c
index 7239d5d7ddcd..874078a7664d 100644
--- a/arch/ppc/syslib/gen550_kgdb.c
+++ b/arch/ppc/syslib/gen550_kgdb.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/gen550_kgdb.c
3 *
4 * Generic 16550 kgdb support intended to be useful on a variety 2 * Generic 16550 kgdb support intended to be useful on a variety
5 * of platforms. To enable this support, it is necessary to set 3 * of platforms. To enable this support, it is necessary to set
6 * the CONFIG_GEN550 option. Any virtual mapping of the serial 4 * the CONFIG_GEN550 option. Any virtual mapping of the serial
diff --git a/arch/ppc/syslib/gt64260_pic.c b/arch/ppc/syslib/gt64260_pic.c
index f97b3a9abd1e..dc3bd9ecbbf6 100644
--- a/arch/ppc/syslib/gt64260_pic.c
+++ b/arch/ppc/syslib/gt64260_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/gt64260_pic.c
3 *
4 * Interrupt controller support for Galileo's GT64260. 2 * Interrupt controller support for Galileo's GT64260.
5 * 3 *
6 * Author: Chris Zankel <source@mvista.com> 4 * Author: Chris Zankel <source@mvista.com>
diff --git a/arch/ppc/syslib/harrier.c b/arch/ppc/syslib/harrier.c
index a6b3f8645793..c1583f488325 100644
--- a/arch/ppc/syslib/harrier.c
+++ b/arch/ppc/syslib/harrier.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/harrier.c
3 *
4 * Motorola MCG Harrier northbridge/memory controller support 2 * Motorola MCG Harrier northbridge/memory controller support
5 * 3 *
6 * Author: Dale Farnsworth 4 * Author: Dale Farnsworth
diff --git a/arch/ppc/syslib/hawk_common.c b/arch/ppc/syslib/hawk_common.c
index a9911dc3a82f..c5bf16b0d6a1 100644
--- a/arch/ppc/syslib/hawk_common.c
+++ b/arch/ppc/syslib/hawk_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/hawk_common.c
3 *
4 * Common Motorola PowerPlus Platform--really Falcon/Raven or HAWK. 2 * Common Motorola PowerPlus Platform--really Falcon/Raven or HAWK.
5 * 3 *
6 * Author: Mark A. Greer 4 * Author: Mark A. Greer
diff --git a/arch/ppc/syslib/ibm440gp_common.c b/arch/ppc/syslib/ibm440gp_common.c
index 0d6be2d6dd67..fbaae5f6d834 100644
--- a/arch/ppc/syslib/ibm440gp_common.c
+++ b/arch/ppc/syslib/ibm440gp_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ibm440gp_common.c
3 *
4 * PPC440GP system library 2 * PPC440GP system library
5 * 3 *
6 * Matt Porter <mporter@mvista.com> 4 * Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/syslib/ibm440gp_common.h b/arch/ppc/syslib/ibm440gp_common.h
index a054d83cb1ac..f48529f3c23d 100644
--- a/arch/ppc/syslib/ibm440gp_common.h
+++ b/arch/ppc/syslib/ibm440gp_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ibm440gp_common.h
3 *
4 * PPC440GP system library 2 * PPC440GP system library
5 * 3 *
6 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 4 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ibm440gx_common.c b/arch/ppc/syslib/ibm440gx_common.c
index c36db279b43d..a7dd55f1c63e 100644
--- a/arch/ppc/syslib/ibm440gx_common.c
+++ b/arch/ppc/syslib/ibm440gx_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ibm440gx_common.c
3 *
4 * PPC440GX system library 2 * PPC440GX system library
5 * 3 *
6 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 4 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ibm440gx_common.h b/arch/ppc/syslib/ibm440gx_common.h
index e73aa0411d35..a2ab9fab8e34 100644
--- a/arch/ppc/syslib/ibm440gx_common.h
+++ b/arch/ppc/syslib/ibm440gx_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ibm440gx_common.h
3 *
4 * PPC440GX system library 2 * PPC440GX system library
5 * 3 *
6 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 4 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ibm440sp_common.c b/arch/ppc/syslib/ibm440sp_common.c
index cdafda127d81..293e4138d172 100644
--- a/arch/ppc/syslib/ibm440sp_common.c
+++ b/arch/ppc/syslib/ibm440sp_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ibm440sp_common.c
3 *
4 * PPC440SP/PPC440SPe system library 2 * PPC440SP/PPC440SPe system library
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ibm440sp_common.h b/arch/ppc/syslib/ibm440sp_common.h
index a21a9906dcc9..8077bf8ed118 100644
--- a/arch/ppc/syslib/ibm440sp_common.h
+++ b/arch/ppc/syslib/ibm440sp_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ibm440sp_common.h
3 *
4 * PPC440SP system library 2 * PPC440SP system library
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ibm44x_common.c b/arch/ppc/syslib/ibm44x_common.c
index 71db11d22158..14a981a5cea7 100644
--- a/arch/ppc/syslib/ibm44x_common.c
+++ b/arch/ppc/syslib/ibm44x_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ibm44x_common.c
3 *
4 * PPC44x system library 2 * PPC44x system library
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ibm44x_common.h b/arch/ppc/syslib/ibm44x_common.h
index b25a8995e4e9..f179db8634e0 100644
--- a/arch/ppc/syslib/ibm44x_common.h
+++ b/arch/ppc/syslib/ibm44x_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ibm44x_common.h
3 *
4 * PPC44x system library 2 * PPC44x system library
5 * 3 *
6 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 4 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/m8260_pci_erratum9.c b/arch/ppc/syslib/m8260_pci_erratum9.c
index 1dc7e4e1d491..99e4bc0e42af 100644
--- a/arch/ppc/syslib/m8260_pci_erratum9.c
+++ b/arch/ppc/syslib/m8260_pci_erratum9.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/mpc8260_pci9.c
3 *
4 * Workaround for device erratum PCI 9. 2 * Workaround for device erratum PCI 9.
5 * See Motorola's "XPC826xA Family Device Errata Reference." 3 * See Motorola's "XPC826xA Family Device Errata Reference."
6 * The erratum applies to all 8260 family Hip4 processors. It is scheduled 4 * The erratum applies to all 8260 family Hip4 processors. It is scheduled
diff --git a/arch/ppc/syslib/m8260_setup.c b/arch/ppc/syslib/m8260_setup.c
index 76a2aa4ce65e..b7a6cb2d8d52 100644
--- a/arch/ppc/syslib/m8260_setup.c
+++ b/arch/ppc/syslib/m8260_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/m8260_setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas 3 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu) 4 * Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
index 688616de3cde..dae9af78bde1 100644
--- a/arch/ppc/syslib/m8xx_setup.c
+++ b/arch/ppc/syslib/m8xx_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas 3 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu) 4 * Modified by Cort Dougan (cort@cs.nmt.edu)
@@ -34,6 +32,13 @@
34#include <linux/seq_file.h> 32#include <linux/seq_file.h>
35#include <linux/root_dev.h> 33#include <linux/root_dev.h>
36 34
35#if defined(CONFIG_MTD) && defined(CONFIG_MTD_PHYSMAP)
36#include <linux/mtd/partitions.h>
37#include <linux/mtd/physmap.h>
38#include <linux/mtd/mtd.h>
39#include <linux/mtd/map.h>
40#endif
41
37#include <asm/mmu.h> 42#include <asm/mmu.h>
38#include <asm/reg.h> 43#include <asm/reg.h>
39#include <asm/residual.h> 44#include <asm/residual.h>
@@ -49,6 +54,34 @@
49 54
50#include "ppc8xx_pic.h" 55#include "ppc8xx_pic.h"
51 56
57#ifdef CONFIG_MTD_PHYSMAP
58#define MPC8xxADS_BANK_WIDTH 4
59#endif
60
61#define MPC8xxADS_U_BOOT_SIZE 0x80000
62#define MPC8xxADS_FREE_AREA_OFFSET MPC8xxADS_U_BOOT_SIZE
63
64#if defined(CONFIG_MTD_PARTITIONS)
65 /*
66 NOTE: bank width and interleave relative to the installed flash
67 should have been chosen within MTD_CFI_GEOMETRY options.
68 */
69static struct mtd_partition mpc8xxads_partitions[] = {
70 {
71 .name = "bootloader",
72 .size = MPC8xxADS_U_BOOT_SIZE,
73 .offset = 0,
74 .mask_flags = MTD_WRITEABLE, /* force read-only */
75 }, {
76 .name = "User FS",
77 .offset = MPC8xxADS_FREE_AREA_OFFSET
78 }
79};
80
81#define mpc8xxads_part_num (sizeof (mpc8xxads_partitions) / sizeof (mpc8xxads_partitions[0]))
82
83#endif
84
52static int m8xx_set_rtc_time(unsigned long time); 85static int m8xx_set_rtc_time(unsigned long time);
53static unsigned long m8xx_get_rtc_time(void); 86static unsigned long m8xx_get_rtc_time(void);
54void m8xx_calibrate_decr(void); 87void m8xx_calibrate_decr(void);
@@ -71,6 +104,10 @@ board_init(void)
71void __init 104void __init
72m8xx_setup_arch(void) 105m8xx_setup_arch(void)
73{ 106{
107#if defined(CONFIG_MTD) && defined(CONFIG_MTD_PHYSMAP)
108 bd_t *binfo = (bd_t *)__res;
109#endif
110
74 /* Reset the Communication Processor Module. 111 /* Reset the Communication Processor Module.
75 */ 112 */
76 m8xx_cpm_reset(); 113 m8xx_cpm_reset();
@@ -106,6 +143,17 @@ m8xx_setup_arch(void)
106 } 143 }
107#endif 144#endif
108#endif 145#endif
146
147#if defined (CONFIG_MPC86XADS) || defined (CONFIG_MPC885ADS)
148#if defined(CONFIG_MTD_PHYSMAP)
149 physmap_configure(binfo->bi_flashstart, binfo->bi_flashsize,
150 MPC8xxADS_BANK_WIDTH, NULL);
151#ifdef CONFIG_MTD_PARTITIONS
152 physmap_set_partitions(mpc8xxads_partitions, mpc8xxads_part_num);
153#endif /* CONFIG_MTD_PARTITIONS */
154#endif /* CONFIG_MTD_PHYSMAP */
155#endif
156
109 board_init(); 157 board_init();
110} 158}
111 159
@@ -140,9 +188,11 @@ void __init __attribute__ ((weak))
140init_internal_rtc(void) 188init_internal_rtc(void)
141{ 189{
142 /* Disable the RTC one second and alarm interrupts. */ 190 /* Disable the RTC one second and alarm interrupts. */
143 out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, in_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc) & ~(RTCSC_SIE | RTCSC_ALE)); 191 clrbits16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, (RTCSC_SIE | RTCSC_ALE));
192
144 /* Enable the RTC */ 193 /* Enable the RTC */
145 out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, in_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc) | (RTCSC_RTF | RTCSC_RTE)); 194 setbits16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, (RTCSC_RTF | RTCSC_RTE));
195
146} 196}
147 197
148/* The decrementer counts at the system (internal) clock frequency divided by 198/* The decrementer counts at the system (internal) clock frequency divided by
@@ -159,8 +209,7 @@ void __init m8xx_calibrate_decr(void)
159 out_be32(&((immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk, KAPWR_KEY); 209 out_be32(&((immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk, KAPWR_KEY);
160 210
161 /* Force all 8xx processors to use divide by 16 processor clock. */ 211 /* Force all 8xx processors to use divide by 16 processor clock. */
162 out_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr, 212 setbits32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr, 0x02000000);
163 in_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr)|0x02000000);
164 /* Processor frequency is MHz. 213 /* Processor frequency is MHz.
165 * The value 'fp' is the number of decrementer ticks per second. 214 * The value 'fp' is the number of decrementer ticks per second.
166 */ 215 */
@@ -239,8 +288,8 @@ m8xx_restart(char *cmd)
239 __volatile__ unsigned char dummy; 288 __volatile__ unsigned char dummy;
240 289
241 local_irq_disable(); 290 local_irq_disable();
242 out_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr, in_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr) | 0x00000080);
243 291
292 setbits32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr, 0x00000080);
244 /* Clear the ME bit in MSR to cause checkstop on machine check 293 /* Clear the ME bit in MSR to cause checkstop on machine check
245 */ 294 */
246 mtmsr(mfmsr() & ~0x1000); 295 mtmsr(mfmsr() & ~0x1000);
@@ -310,8 +359,8 @@ m8xx_init_IRQ(void)
310 i8259_init(0); 359 i8259_init(0);
311 360
312 /* The i8259 cascade interrupt must be level sensitive. */ 361 /* The i8259 cascade interrupt must be level sensitive. */
313 out_be32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel, in_be32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel & ~(0x80000000 >> ISA_BRIDGE_INT)));
314 362
363 clrbits32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel, (0x80000000 >> ISA_BRIDGE_INT));
315 if (setup_irq(ISA_BRIDGE_INT, &mbx_i8259_irqaction)) 364 if (setup_irq(ISA_BRIDGE_INT, &mbx_i8259_irqaction))
316 enable_irq(ISA_BRIDGE_INT); 365 enable_irq(ISA_BRIDGE_INT);
317#endif /* CONFIG_PCI */ 366#endif /* CONFIG_PCI */
diff --git a/arch/ppc/syslib/m8xx_wdt.c b/arch/ppc/syslib/m8xx_wdt.c
index df6c9557b86a..ac11d7bab443 100644
--- a/arch/ppc/syslib/m8xx_wdt.c
+++ b/arch/ppc/syslib/m8xx_wdt.c
@@ -41,8 +41,7 @@ static irqreturn_t m8xx_wdt_interrupt(int irq, void *dev, struct pt_regs *regs)
41 41
42 m8xx_wdt_reset(); 42 m8xx_wdt_reset();
43 43
44 out_be16(&imap->im_sit.sit_piscr, in_be16(&imap->im_sit.sit_piscr) | PISCR_PS); /* clear irq */ 44 setbits16(&imap->im_sit.sit_piscr, PISCR_PS);
45
46 return IRQ_HANDLED; 45 return IRQ_HANDLED;
47} 46}
48 47
diff --git a/arch/ppc/syslib/mpc10x_common.c b/arch/ppc/syslib/mpc10x_common.c
index 3e039706bdbc..2fc7c4150a18 100644
--- a/arch/ppc/syslib/mpc10x_common.c
+++ b/arch/ppc/syslib/mpc10x_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc10x_common.c
3 *
4 * Common routines for the Motorola SPS MPC106, MPC107 and MPC8240 Host bridge, 2 * Common routines for the Motorola SPS MPC106, MPC107 and MPC8240 Host bridge,
5 * Mem ctlr, EPIC, etc. 3 * Mem ctlr, EPIC, etc.
6 * 4 *
diff --git a/arch/ppc/syslib/mpc52xx_devices.c b/arch/ppc/syslib/mpc52xx_devices.c
index da3c74bfdc92..7487539a4e92 100644
--- a/arch/ppc/syslib/mpc52xx_devices.c
+++ b/arch/ppc/syslib/mpc52xx_devices.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc52xx_devices.c
3 *
4 * Freescale MPC52xx device descriptions 2 * Freescale MPC52xx device descriptions
5 * 3 *
6 * 4 *
diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c
index 313c96ec7eb1..9ec525f9fe98 100644
--- a/arch/ppc/syslib/mpc52xx_pci.c
+++ b/arch/ppc/syslib/mpc52xx_pci.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc52xx_pci.c
3 *
4 * PCI code for the Freescale MPC52xx embedded CPU. 2 * PCI code for the Freescale MPC52xx embedded CPU.
5 * 3 *
6 * 4 *
diff --git a/arch/ppc/syslib/mpc52xx_pci.h b/arch/ppc/syslib/mpc52xx_pci.h
index 04b509a02530..77d47dbba85e 100644
--- a/arch/ppc/syslib/mpc52xx_pci.h
+++ b/arch/ppc/syslib/mpc52xx_pci.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc52xx_pci.h
3 *
4 * PCI Include file the Freescale MPC52xx embedded cpu chips 2 * PCI Include file the Freescale MPC52xx embedded cpu chips
5 * 3 *
6 * 4 *
diff --git a/arch/ppc/syslib/mpc52xx_pic.c b/arch/ppc/syslib/mpc52xx_pic.c
index 4c4497e62517..c4406f9dc6a3 100644
--- a/arch/ppc/syslib/mpc52xx_pic.c
+++ b/arch/ppc/syslib/mpc52xx_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc52xx_pic.c
3 *
4 * Programmable Interrupt Controller functions for the Freescale MPC52xx 2 * Programmable Interrupt Controller functions for the Freescale MPC52xx
5 * embedded CPU. 3 * embedded CPU.
6 * 4 *
diff --git a/arch/ppc/syslib/mpc52xx_setup.c b/arch/ppc/syslib/mpc52xx_setup.c
index a4a4b02227df..2ee48ce0a517 100644
--- a/arch/ppc/syslib/mpc52xx_setup.c
+++ b/arch/ppc/syslib/mpc52xx_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc52xx_setup.c
3 *
4 * Common code for the boards based on Freescale MPC52xx embedded CPU. 2 * Common code for the boards based on Freescale MPC52xx embedded CPU.
5 * 3 *
6 * 4 *
diff --git a/arch/ppc/syslib/mpc52xx_sys.c b/arch/ppc/syslib/mpc52xx_sys.c
index 9a0f90aa8aac..b4e6f978f057 100644
--- a/arch/ppc/syslib/mpc52xx_sys.c
+++ b/arch/ppc/syslib/mpc52xx_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc52xx_sys.c
3 *
4 * Freescale MPC52xx system descriptions 2 * Freescale MPC52xx system descriptions
5 * 3 *
6 * 4 *
diff --git a/arch/ppc/syslib/mpc83xx_devices.c b/arch/ppc/syslib/mpc83xx_devices.c
index f9b95de70e23..1af2c000fcfa 100644
--- a/arch/ppc/syslib/mpc83xx_devices.c
+++ b/arch/ppc/syslib/mpc83xx_devices.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/83xx/mpc83xx_devices.c
3 *
4 * MPC83xx Device descriptions 2 * MPC83xx Device descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc83xx_sys.c b/arch/ppc/syslib/mpc83xx_sys.c
index 82cf3ab77f4a..0498ae7e01e3 100644
--- a/arch/ppc/syslib/mpc83xx_sys.c
+++ b/arch/ppc/syslib/mpc83xx_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/83xx/mpc83xx_sys.c
3 *
4 * MPC83xx System descriptions 2 * MPC83xx System descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc85xx_devices.c b/arch/ppc/syslib/mpc85xx_devices.c
index 00e9b6ff2f6e..7735336f5b8f 100644
--- a/arch/ppc/syslib/mpc85xx_devices.c
+++ b/arch/ppc/syslib/mpc85xx_devices.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc85xx_devices.c
3 *
4 * MPC85xx Device descriptions 2 * MPC85xx Device descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc85xx_sys.c b/arch/ppc/syslib/mpc85xx_sys.c
index 397cfbcce5ea..d96a93dbcb5a 100644
--- a/arch/ppc/syslib/mpc85xx_sys.c
+++ b/arch/ppc/syslib/mpc85xx_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/85xx/mpc85xx_sys.c
3 *
4 * MPC85xx System descriptions 2 * MPC85xx System descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc8xx_devices.c b/arch/ppc/syslib/mpc8xx_devices.c
index 92dc98b36bde..bd41ed83beb3 100644
--- a/arch/ppc/syslib/mpc8xx_devices.c
+++ b/arch/ppc/syslib/mpc8xx_devices.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mpc8xx_devices.c
3 *
4 * MPC8xx Device descriptions 2 * MPC8xx Device descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc8xx_sys.c b/arch/ppc/syslib/mpc8xx_sys.c
index d3c617521603..eee213284855 100644
--- a/arch/ppc/syslib/mpc8xx_sys.c
+++ b/arch/ppc/syslib/mpc8xx_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/platforms/mpc8xx_sys.c
3 *
4 * MPC8xx System descriptions 2 * MPC8xx System descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mv64360_pic.c b/arch/ppc/syslib/mv64360_pic.c
index 58b0aa813e85..5a19697060f0 100644
--- a/arch/ppc/syslib/mv64360_pic.c
+++ b/arch/ppc/syslib/mv64360_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/mv64360_pic.c
3 *
4 * Interrupt controller support for Marvell's MV64360. 2 * Interrupt controller support for Marvell's MV64360.
5 * 3 *
6 * Author: Rabeeh Khoury <rabeeh@galileo.co.il> 4 * Author: Rabeeh Khoury <rabeeh@galileo.co.il>
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index 1f01b7e2376b..3b039c30a439 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mv64x60.c
3 *
4 * Common routines for the Marvell/Galileo Discovery line of host bridges 2 * Common routines for the Marvell/Galileo Discovery line of host bridges
5 * (gt64260, mv64360, mv64460, ...). 3 * (gt64260, mv64360, mv64460, ...).
6 * 4 *
diff --git a/arch/ppc/syslib/mv64x60_dbg.c b/arch/ppc/syslib/mv64x60_dbg.c
index fa5b2e45e0ca..9cf18764a1a1 100644
--- a/arch/ppc/syslib/mv64x60_dbg.c
+++ b/arch/ppc/syslib/mv64x60_dbg.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mv64x60_dbg.c
3 *
4 * KGDB and progress routines for the Marvell/Galileo MV64x60 (Discovery). 2 * KGDB and progress routines for the Marvell/Galileo MV64x60 (Discovery).
5 * 3 *
6 * Author: Mark A. Greer <mgreer@mvista.com> 4 * Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/syslib/mv64x60_win.c b/arch/ppc/syslib/mv64x60_win.c
index 5b827e2bbe22..4bf1ad17bf1a 100644
--- a/arch/ppc/syslib/mv64x60_win.c
+++ b/arch/ppc/syslib/mv64x60_win.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/mv64x60_win.c
3 *
4 * Tables with info on how to manipulate the 32 & 64 bit windows on the 2 * Tables with info on how to manipulate the 32 & 64 bit windows on the
5 * various types of Marvell bridge chips. 3 * various types of Marvell bridge chips.
6 * 4 *
diff --git a/arch/ppc/syslib/ocp.c b/arch/ppc/syslib/ocp.c
index 2fe28ded2c60..a4ecc2ee579f 100644
--- a/arch/ppc/syslib/ocp.c
+++ b/arch/ppc/syslib/ocp.c
@@ -451,10 +451,9 @@ ocp_driver_init(void)
451 DBG(("ocp: ocp_driver_init()...\n")); 451 DBG(("ocp: ocp_driver_init()...\n"));
452 452
453 /* Allocate/register primary OCP bus */ 453 /* Allocate/register primary OCP bus */
454 ocp_bus = kmalloc(sizeof(struct device), GFP_KERNEL); 454 ocp_bus = kzalloc(sizeof(struct device), GFP_KERNEL);
455 if (ocp_bus == NULL) 455 if (ocp_bus == NULL)
456 return 1; 456 return 1;
457 memset(ocp_bus, 0, sizeof(struct device));
458 strcpy(ocp_bus->bus_id, "ocp"); 457 strcpy(ocp_bus->bus_id, "ocp");
459 458
460 bus_register(&ocp_bus_type); 459 bus_register(&ocp_bus_type);
diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
index 894779712b46..38e5b93fbe41 100644
--- a/arch/ppc/syslib/open_pic.c
+++ b/arch/ppc/syslib/open_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
3 *
4 * Copyright (C) 1997 Geert Uytterhoeven 2 * Copyright (C) 1997 Geert Uytterhoeven
5 * 3 *
6 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
diff --git a/arch/ppc/syslib/open_pic2.c b/arch/ppc/syslib/open_pic2.c
index 1c40049b9a45..bcbe40de26fe 100644
--- a/arch/ppc/syslib/open_pic2.c
+++ b/arch/ppc/syslib/open_pic2.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
3 *
4 * Copyright (C) 1997 Geert Uytterhoeven 2 * Copyright (C) 1997 Geert Uytterhoeven
5 * 3 *
6 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
diff --git a/arch/ppc/syslib/open_pic_defs.h b/arch/ppc/syslib/open_pic_defs.h
index 6c94e7131463..3a25de7cb572 100644
--- a/arch/ppc/syslib/open_pic_defs.h
+++ b/arch/ppc/syslib/open_pic_defs.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/open_pic_defs.h -- OpenPIC definitions
3 *
4 * Copyright (C) 1997 Geert Uytterhoeven 2 * Copyright (C) 1997 Geert Uytterhoeven
5 * 3 *
6 * This file is based on the following documentation: 4 * This file is based on the following documentation:
diff --git a/arch/ppc/syslib/pci_auto.c b/arch/ppc/syslib/pci_auto.c
index d64207c2a972..ee20a86fcc4b 100644
--- a/arch/ppc/syslib/pci_auto.c
+++ b/arch/ppc/syslib/pci_auto.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/pci_auto.c
3 *
4 * PCI autoconfiguration library 2 * PCI autoconfiguration library
5 * 3 *
6 * Author: Matt Porter <mporter@mvista.com> 4 * Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/syslib/ppc4xx_dma.c b/arch/ppc/syslib/ppc4xx_dma.c
index 05ccd598dd4e..b40b96a8c609 100644
--- a/arch/ppc/syslib/ppc4xx_dma.c
+++ b/arch/ppc/syslib/ppc4xx_dma.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ppc4xx_dma.c
3 *
4 * IBM PPC4xx DMA engine core library 2 * IBM PPC4xx DMA engine core library
5 * 3 *
6 * Copyright 2000-2004 MontaVista Software Inc. 4 * Copyright 2000-2004 MontaVista Software Inc.
diff --git a/arch/ppc/syslib/ppc4xx_pic.c b/arch/ppc/syslib/ppc4xx_pic.c
index aa4165144ec2..fd9af0fc0e9f 100644
--- a/arch/ppc/syslib/ppc4xx_pic.c
+++ b/arch/ppc/syslib/ppc4xx_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc4xx_pic.c
3 *
4 * Interrupt controller driver for PowerPC 4xx-based processors. 2 * Interrupt controller driver for PowerPC 4xx-based processors.
5 * 3 *
6 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 4 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ppc4xx_pm.c b/arch/ppc/syslib/ppc4xx_pm.c
deleted file mode 100644
index 60a479204885..000000000000
--- a/arch/ppc/syslib/ppc4xx_pm.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * Author: Armin Kuster <akuster@mvista.com>
3 *
4 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
5 * the terms of the GNU General Public License version 2. This program
6 * is licensed "as is" without any warranty of any kind, whether express
7 * or implied.
8 *
9 * This an attempt to get Power Management going for the IBM 4xx processor.
10 * This was derived from the ppc4xx._setup.c file
11 */
12
13#include <linux/config.h>
14#include <linux/init.h>
15
16#include <asm/ibm4xx.h>
17
18void __init
19ppc4xx_pm_init(void)
20{
21
22 unsigned int value = 0;
23
24 /* turn off unused hardware to save power */
25#ifdef CONFIG_405GP
26 value |= CPM_DCP; /* CodePack */
27#endif
28
29#if !defined(CONFIG_IBM_OCP_GPIO)
30 value |= CPM_GPIO0;
31#endif
32
33#if !defined(CONFIG_PPC405_I2C_ADAP)
34 value |= CPM_IIC0;
35#ifdef CONFIG_STB03xxx
36 value |= CPM_IIC1;
37#endif
38#endif
39
40
41#if !defined(CONFIG_405_DMA)
42 value |= CPM_DMA;
43#endif
44
45 mtdcr(DCRN_CPMFR, value);
46
47}
diff --git a/arch/ppc/syslib/ppc4xx_sgdma.c b/arch/ppc/syslib/ppc4xx_sgdma.c
index 9f76e8ee39ed..280ea010a9c8 100644
--- a/arch/ppc/syslib/ppc4xx_sgdma.c
+++ b/arch/ppc/syslib/ppc4xx_sgdma.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/ppc4xx_sgdma.c
3 *
4 * IBM PPC4xx DMA engine scatter/gather library 2 * IBM PPC4xx DMA engine scatter/gather library
5 * 3 *
6 * Copyright 2002-2003 MontaVista Software Inc. 4 * Copyright 2002-2003 MontaVista Software Inc.
diff --git a/arch/ppc/syslib/ppc83xx_setup.c b/arch/ppc/syslib/ppc83xx_setup.c
index 7bada82527a8..26afd637dc81 100644
--- a/arch/ppc/syslib/ppc83xx_setup.c
+++ b/arch/ppc/syslib/ppc83xx_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc83xx_setup.c
3 *
4 * MPC83XX common board code 2 * MPC83XX common board code
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc83xx_setup.h b/arch/ppc/syslib/ppc83xx_setup.h
index a122a7322e5e..478b011cd963 100644
--- a/arch/ppc/syslib/ppc83xx_setup.h
+++ b/arch/ppc/syslib/ppc83xx_setup.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc83xx_setup.h
3 *
4 * MPC83XX common board definitions 2 * MPC83XX common board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_common.c b/arch/ppc/syslib/ppc85xx_common.c
index 19ad537225e4..0145c968f9ad 100644
--- a/arch/ppc/syslib/ppc85xx_common.c
+++ b/arch/ppc/syslib/ppc85xx_common.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc85xx_common.c
3 *
4 * MPC85xx support routines 2 * MPC85xx support routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_common.h b/arch/ppc/syslib/ppc85xx_common.h
index 94edf32151dd..182744a1321c 100644
--- a/arch/ppc/syslib/ppc85xx_common.h
+++ b/arch/ppc/syslib/ppc85xx_common.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc85xx_common.h
3 *
4 * MPC85xx support routines 2 * MPC85xx support routines
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
index e4dda43fdaa7..e70b34ee6275 100644
--- a/arch/ppc/syslib/ppc85xx_setup.c
+++ b/arch/ppc/syslib/ppc85xx_setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc85xx_setup.c
3 *
4 * MPC85XX common board code 2 * MPC85XX common board code
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_setup.h b/arch/ppc/syslib/ppc85xx_setup.h
index e340b0545fb5..f55b8032d3d9 100644
--- a/arch/ppc/syslib/ppc85xx_setup.h
+++ b/arch/ppc/syslib/ppc85xx_setup.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc85xx_setup.h
3 *
4 * MPC85XX common board definitions 2 * MPC85XX common board definitions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc_sys.c b/arch/ppc/syslib/ppc_sys.c
index c0b93c4191ee..60c724e11584 100644
--- a/arch/ppc/syslib/ppc_sys.c
+++ b/arch/ppc/syslib/ppc_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/ppc_sys.c
3 *
4 * PPC System library functions 2 * PPC System library functions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
@@ -15,11 +13,22 @@
15 */ 13 */
16 14
17#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/bootmem.h>
18#include <asm/ppc_sys.h> 17#include <asm/ppc_sys.h>
19 18
20int (*ppc_sys_device_fixup) (struct platform_device * pdev); 19int (*ppc_sys_device_fixup) (struct platform_device * pdev);
21 20
22static int ppc_sys_inited; 21static int ppc_sys_inited;
22static int ppc_sys_func_inited;
23
24static const char *ppc_sys_func_names[] = {
25 [PPC_SYS_FUNC_DUMMY] = "dummy",
26 [PPC_SYS_FUNC_ETH] = "eth",
27 [PPC_SYS_FUNC_UART] = "uart",
28 [PPC_SYS_FUNC_HLDC] = "hldc",
29 [PPC_SYS_FUNC_USB] = "usb",
30 [PPC_SYS_FUNC_IRDA] = "irda",
31};
23 32
24void __init identify_ppc_sys_by_id(u32 id) 33void __init identify_ppc_sys_by_id(u32 id)
25{ 34{
@@ -38,13 +47,13 @@ void __init identify_ppc_sys_by_id(u32 id)
38void __init identify_ppc_sys_by_name(char *name) 47void __init identify_ppc_sys_by_name(char *name)
39{ 48{
40 unsigned int i = 0; 49 unsigned int i = 0;
41 while (ppc_sys_specs[i].ppc_sys_name[0]) 50 while (ppc_sys_specs[i].ppc_sys_name[0]) {
42 {
43 if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name)) 51 if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name))
44 break; 52 break;
45 i++; 53 i++;
46 } 54 }
47 cur_ppc_sys_spec = &ppc_sys_specs[i]; 55 cur_ppc_sys_spec = &ppc_sys_specs[i];
56
48 return; 57 return;
49} 58}
50 59
@@ -128,6 +137,165 @@ void ppc_sys_device_remove(enum ppc_sys_devices dev)
128 } 137 }
129} 138}
130 139
140/* Platform-notify mapping
141 * Helper function for BSP code to assign board-specific platfom-divice bits
142 */
143
144void platform_notify_map(const struct platform_notify_dev_map *map,
145 struct device *dev)
146{
147 struct platform_device *pdev;
148 int len, idx;
149 const char *s;
150
151 /* do nothing if no device or no bus_id */
152 if (!dev || !dev->bus_id)
153 return;
154
155 /* call per device map */
156 while (map->bus_id != NULL) {
157 idx = -1;
158 s = strrchr(dev->bus_id, '.');
159 if (s != NULL)
160 idx = (int)simple_strtol(s + 1, NULL, 10);
161 else
162 s = dev->bus_id;
163
164 len = s - dev->bus_id;
165
166 if (!strncmp(dev->bus_id, map->bus_id, len)) {
167 pdev = container_of(dev, struct platform_device, dev);
168 map->rtn(pdev, idx);
169 }
170 map++;
171 }
172}
173
174/*
175 Function assignment stuff.
176 Intended to work as follows:
177 the device name defined in foo_devices.c will be concatenated with :"func",
178 where func is string map of respective function from platfom_device_func enum
179
180 The PPC_SYS_FUNC_DUMMY function is intended to remove all assignments, making the device to appear
181 in platform bus with unmodified name.
182 */
183
184/*
185 Here we'll replace .name pointers with fixed-lenght strings
186 Hereby, this should be called *before* any func stuff triggeded.
187 */
188void ppc_sys_device_initfunc(void)
189{
190 int i;
191 const char *name;
192 static char new_names[NUM_PPC_SYS_DEVS][BUS_ID_SIZE];
193 enum ppc_sys_devices cur_dev;
194
195 /* If inited yet, do nothing */
196 if (ppc_sys_func_inited)
197 return;
198
199 for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
200 if ((cur_dev = cur_ppc_sys_spec->device_list[i]) < 0)
201 continue;
202
203 if (ppc_sys_platform_devices[cur_dev].name) {
204 /*backup name */
205 name = ppc_sys_platform_devices[cur_dev].name;
206 strlcpy(new_names[i], name, BUS_ID_SIZE);
207 ppc_sys_platform_devices[cur_dev].name = new_names[i];
208 }
209 }
210
211 ppc_sys_func_inited = 1;
212}
213
214/*The "engine" of the func stuff. Here we either concat specified function string description
215 to the name, or remove it if PPC_SYS_FUNC_DUMMY parameter is passed here*/
216void ppc_sys_device_setfunc(enum ppc_sys_devices dev,
217 enum platform_device_func func)
218{
219 char *s;
220 char *name = (char *)ppc_sys_platform_devices[dev].name;
221 char tmp[BUS_ID_SIZE];
222
223 if (!ppc_sys_func_inited) {
224 printk(KERN_ERR "Unable to alter function - not inited!\n");
225 return;
226 }
227
228 if (ppc_sys_inited) {
229 platform_device_unregister(&ppc_sys_platform_devices[dev]);
230 }
231
232 if ((s = (char *)strchr(name, ':')) != NULL) { /* reassign */
233 /* Either change the name after ':' or remove func modifications */
234 if (func != PPC_SYS_FUNC_DUMMY)
235 strlcpy(s + 1, ppc_sys_func_names[func], BUS_ID_SIZE);
236 else
237 *s = 0;
238 } else if (func != PPC_SYS_FUNC_DUMMY) {
239 /* do assignment if it is not just "clear" request */
240 sprintf(tmp, "%s:%s", name, ppc_sys_func_names[func]);
241 strlcpy(name, tmp, BUS_ID_SIZE);
242 }
243
244 if (ppc_sys_inited) {
245 platform_device_register(&ppc_sys_platform_devices[dev]);
246 }
247}
248
249void ppc_sys_device_disable(enum ppc_sys_devices dev)
250{
251 BUG_ON(cur_ppc_sys_spec == NULL);
252
253 /*Check if it is enabled*/
254 if(!(cur_ppc_sys_spec->config[dev] & PPC_SYS_CONFIG_DISABLED)) {
255 if (ppc_sys_inited) {
256 platform_device_unregister(&ppc_sys_platform_devices[dev]);
257 }
258 cur_ppc_sys_spec->config[dev] |= PPC_SYS_CONFIG_DISABLED;
259 }
260}
261
262void ppc_sys_device_enable(enum ppc_sys_devices dev)
263{
264 BUG_ON(cur_ppc_sys_spec == NULL);
265
266 /*Check if it is disabled*/
267 if(cur_ppc_sys_spec->config[dev] & PPC_SYS_CONFIG_DISABLED) {
268 if (ppc_sys_inited) {
269 platform_device_register(&ppc_sys_platform_devices[dev]);
270 }
271 cur_ppc_sys_spec->config[dev] &= ~PPC_SYS_CONFIG_DISABLED;
272 }
273
274}
275
276void ppc_sys_device_enable_all(void)
277{
278 enum ppc_sys_devices cur_dev;
279 int i;
280
281 for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
282 cur_dev = cur_ppc_sys_spec->device_list[i];
283 ppc_sys_device_enable(cur_dev);
284 }
285}
286
287void ppc_sys_device_disable_all(void)
288{
289 enum ppc_sys_devices cur_dev;
290 int i;
291
292 for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
293 cur_dev = cur_ppc_sys_spec->device_list[i];
294 ppc_sys_device_disable(cur_dev);
295 }
296}
297
298
131static int __init ppc_sys_init(void) 299static int __init ppc_sys_init(void)
132{ 300{
133 unsigned int i, dev_id, ret = 0; 301 unsigned int i, dev_id, ret = 0;
@@ -136,7 +304,8 @@ static int __init ppc_sys_init(void)
136 304
137 for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) { 305 for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
138 dev_id = cur_ppc_sys_spec->device_list[i]; 306 dev_id = cur_ppc_sys_spec->device_list[i];
139 if (dev_id != -1) { 307 if ((dev_id != -1) &&
308 !(cur_ppc_sys_spec->config[dev_id] & PPC_SYS_CONFIG_DISABLED)) {
140 if (ppc_sys_device_fixup != NULL) 309 if (ppc_sys_device_fixup != NULL)
141 ppc_sys_device_fixup(&ppc_sys_platform_devices 310 ppc_sys_device_fixup(&ppc_sys_platform_devices
142 [dev_id]); 311 [dev_id]);
diff --git a/arch/ppc/syslib/pq2_devices.c b/arch/ppc/syslib/pq2_devices.c
index 6ff3aab82fc3..0636aed7b827 100644
--- a/arch/ppc/syslib/pq2_devices.c
+++ b/arch/ppc/syslib/pq2_devices.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/pq2_devices.c
3 *
4 * PQ2 Device descriptions 2 * PQ2 Device descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/pq2_sys.c b/arch/ppc/syslib/pq2_sys.c
index 36d6e2179940..75e64f1c144d 100644
--- a/arch/ppc/syslib/pq2_sys.c
+++ b/arch/ppc/syslib/pq2_sys.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/pq2_devices.c
3 *
4 * PQ2 System descriptions 2 * PQ2 System descriptions
5 * 3 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/prep_nvram.c b/arch/ppc/syslib/prep_nvram.c
index 2c6364d9641f..474dccbc4a8a 100644
--- a/arch/ppc/syslib/prep_nvram.c
+++ b/arch/ppc/syslib/prep_nvram.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/prep_nvram.c
3 *
4 * Copyright (C) 1998 Corey Minyard 2 * Copyright (C) 1998 Corey Minyard
5 * 3 *
6 * This reads the NvRAM on PReP compliant machines (generally from IBM or 4 * This reads the NvRAM on PReP compliant machines (generally from IBM or
diff --git a/arch/ppc/syslib/todc_time.c b/arch/ppc/syslib/todc_time.c
index 1323c641c19d..a8168b8e5683 100644
--- a/arch/ppc/syslib/todc_time.c
+++ b/arch/ppc/syslib/todc_time.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/todc_time.c
3 *
4 * Time of Day Clock support for the M48T35, M48T37, M48T59, and MC146818 2 * Time of Day Clock support for the M48T35, M48T37, M48T59, and MC146818
5 * Real Time Clocks/Timekeepers. 3 * Real Time Clocks/Timekeepers.
6 * 4 *
diff --git a/arch/ppc/syslib/xilinx_pic.c b/arch/ppc/syslib/xilinx_pic.c
index 47f04c71fe9c..e672b600f315 100644
--- a/arch/ppc/syslib/xilinx_pic.c
+++ b/arch/ppc/syslib/xilinx_pic.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/syslib/xilinx_pic.c
3 *
4 * Interrupt controller driver for Xilinx Virtex-II Pro. 2 * Interrupt controller driver for Xilinx Virtex-II Pro.
5 * 3 *
6 * Author: MontaVista Software, Inc. 4 * Author: MontaVista Software, Inc.
@@ -15,7 +13,7 @@
15#include <linux/init.h> 13#include <linux/init.h>
16#include <linux/irq.h> 14#include <linux/irq.h>
17#include <asm/io.h> 15#include <asm/io.h>
18#include <asm/xparameters.h> 16#include <platforms/4xx/xparameters/xparameters.h>
19#include <asm/ibm4xx.h> 17#include <asm/ibm4xx.h>
20#include <asm/machdep.h> 18#include <asm/machdep.h>
21 19
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 7dbe00c76c6b..d52d6d211d9f 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -799,9 +799,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
799 */ 799 */
800 print_cpu_info(&S390_lowcore.cpu_data); 800 print_cpu_info(&S390_lowcore.cpu_data);
801 801
802 for(i = 0; i < NR_CPUS; i++) { 802 for_each_cpu(i) {
803 if (!cpu_possible(i))
804 continue;
805 lowcore_ptr[i] = (struct _lowcore *) 803 lowcore_ptr[i] = (struct _lowcore *)
806 __get_free_pages(GFP_KERNEL|GFP_DMA, 804 __get_free_pages(GFP_KERNEL|GFP_DMA,
807 sizeof(void*) == 8 ? 1 : 0); 805 sizeof(void*) == 8 ? 1 : 0);
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 6883c00728cb..b56e79632f24 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -35,9 +35,8 @@ int show_interrupts(struct seq_file *p, void *v)
35 35
36 if (i == 0) { 36 if (i == 0) {
37 seq_puts(p, " "); 37 seq_puts(p, " ");
38 for (j=0; j<NR_CPUS; j++) 38 for_each_online_cpu(j)
39 if (cpu_online(j)) 39 seq_printf(p, "CPU%d ",j);
40 seq_printf(p, "CPU%d ",j);
41 seq_putc(p, '\n'); 40 seq_putc(p, '\n');
42 } 41 }
43 42
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index a067a34e0b64..c0e79843f580 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -404,9 +404,8 @@ static int __init topology_init(void)
404{ 404{
405 int cpu_id; 405 int cpu_id;
406 406
407 for (cpu_id = 0; cpu_id < NR_CPUS; cpu_id++) 407 for_each_cpu(cpu_id)
408 if (cpu_possible(cpu_id)) 408 register_cpu(&cpu[cpu_id], cpu_id, NULL);
409 register_cpu(&cpu[cpu_id], cpu_id, NULL);
410 409
411 return 0; 410 return 0;
412} 411}
diff --git a/arch/sh64/kernel/irq.c b/arch/sh64/kernel/irq.c
index 9fc2b71dbd84..d69879c0e063 100644
--- a/arch/sh64/kernel/irq.c
+++ b/arch/sh64/kernel/irq.c
@@ -53,9 +53,8 @@ int show_interrupts(struct seq_file *p, void *v)
53 53
54 if (i == 0) { 54 if (i == 0) {
55 seq_puts(p, " "); 55 seq_puts(p, " ");
56 for (j=0; j<NR_CPUS; j++) 56 for_each_online_cpu(j)
57 if (cpu_online(j)) 57 seq_printf(p, "CPU%d ",j);
58 seq_printf(p, "CPU%d ",j);
59 seq_putc(p, '\n'); 58 seq_putc(p, '\n');
60 } 59 }
61 60
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index 410b9a72aba9..4c60a6ef54a9 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -184,9 +184,8 @@ int show_interrupts(struct seq_file *p, void *v)
184#ifndef CONFIG_SMP 184#ifndef CONFIG_SMP
185 seq_printf(p, "%10u ", kstat_irqs(i)); 185 seq_printf(p, "%10u ", kstat_irqs(i));
186#else 186#else
187 for (j = 0; j < NR_CPUS; j++) { 187 for_each_online_cpu(j) {
188 if (cpu_online(j)) 188 seq_printf(p, "%10u ",
189 seq_printf(p, "%10u ",
190 kstat_cpu(cpu_logical_map(j)).irqs[i]); 189 kstat_cpu(cpu_logical_map(j)).irqs[i]);
191 } 190 }
192#endif 191#endif
diff --git a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
index c6e721d8f477..ea5682ce7031 100644
--- a/arch/sparc/kernel/smp.c
+++ b/arch/sparc/kernel/smp.c
@@ -243,9 +243,8 @@ int setup_profiling_timer(unsigned int multiplier)
243 return -EINVAL; 243 return -EINVAL;
244 244
245 spin_lock_irqsave(&prof_setup_lock, flags); 245 spin_lock_irqsave(&prof_setup_lock, flags);
246 for(i = 0; i < NR_CPUS; i++) { 246 for_each_cpu(i) {
247 if (cpu_possible(i)) 247 load_profile_irq(i, lvl14_resolution / multiplier);
248 load_profile_irq(i, lvl14_resolution / multiplier);
249 prof_multiplier(i) = multiplier; 248 prof_multiplier(i) = multiplier;
250 } 249 }
251 spin_unlock_irqrestore(&prof_setup_lock, flags); 250 spin_unlock_irqrestore(&prof_setup_lock, flags);
@@ -273,13 +272,12 @@ void smp_bogo(struct seq_file *m)
273{ 272{
274 int i; 273 int i;
275 274
276 for (i = 0; i < NR_CPUS; i++) { 275 for_each_online_cpu(i) {
277 if (cpu_online(i)) 276 seq_printf(m,
278 seq_printf(m, 277 "Cpu%dBogo\t: %lu.%02lu\n",
279 "Cpu%dBogo\t: %lu.%02lu\n", 278 i,
280 i, 279 cpu_data(i).udelay_val/(500000/HZ),
281 cpu_data(i).udelay_val/(500000/HZ), 280 (cpu_data(i).udelay_val/(5000/HZ))%100);
282 (cpu_data(i).udelay_val/(5000/HZ))%100);
283 } 281 }
284} 282}
285 283
@@ -288,8 +286,6 @@ void smp_info(struct seq_file *m)
288 int i; 286 int i;
289 287
290 seq_printf(m, "State:\n"); 288 seq_printf(m, "State:\n");
291 for (i = 0; i < NR_CPUS; i++) { 289 for_each_online_cpu(i)
292 if (cpu_online(i)) 290 seq_printf(m, "CPU%d\t\t: online\n", i);
293 seq_printf(m, "CPU%d\t\t: online\n", i);
294 }
295} 291}
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index 52621348a56c..cea7fc6fc6e5 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -103,11 +103,9 @@ found_it: seq_printf(p, "%3d: ", i);
103#ifndef CONFIG_SMP 103#ifndef CONFIG_SMP
104 seq_printf(p, "%10u ", kstat_irqs(i)); 104 seq_printf(p, "%10u ", kstat_irqs(i));
105#else 105#else
106 for (x = 0; x < NR_CPUS; x++) { 106 for_each_online_cpu(x)
107 if (cpu_online(x)) 107 seq_printf(p, "%10u ",
108 seq_printf(p, "%10u ", 108 kstat_cpu(cpu_logical_map(x)).irqs[i]);
109 kstat_cpu(cpu_logical_map(x)).irqs[i]);
110 }
111#endif 109#endif
112 seq_printf(p, "%c %s", 110 seq_printf(p, "%c %s",
113 (action->flags & SA_INTERRUPT) ? '+' : ' ', 111 (action->flags & SA_INTERRUPT) ? '+' : ' ',
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 4219dd2ce3a2..41bb9596be48 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -249,11 +249,9 @@ void __init smp4d_boot_cpus(void)
249 } else { 249 } else {
250 unsigned long bogosum = 0; 250 unsigned long bogosum = 0;
251 251
252 for(i = 0; i < NR_CPUS; i++) { 252 for_each_present_cpu(i) {
253 if (cpu_isset(i, cpu_present_map)) { 253 bogosum += cpu_data(i).udelay_val;
254 bogosum += cpu_data(i).udelay_val; 254 smp_highest_cpu = i;
255 smp_highest_cpu = i;
256 }
257 } 255 }
258 SMP_PRINTK(("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n", cpucount + 1, bogosum/(500000/HZ), (bogosum/(5000/HZ))%100)); 256 SMP_PRINTK(("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n", cpucount + 1, bogosum/(500000/HZ), (bogosum/(5000/HZ))%100));
259 printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n", 257 printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n",
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index fbbd8a474c4c..1dde312eebda 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -218,10 +218,8 @@ void __init smp4m_boot_cpus(void)
218 cpu_present_map = cpumask_of_cpu(smp_processor_id()); 218 cpu_present_map = cpumask_of_cpu(smp_processor_id());
219 } else { 219 } else {
220 unsigned long bogosum = 0; 220 unsigned long bogosum = 0;
221 for(i = 0; i < NR_CPUS; i++) { 221 for_each_present_cpu(i)
222 if (cpu_isset(i, cpu_present_map)) 222 bogosum += cpu_data(i).udelay_val;
223 bogosum += cpu_data(i).udelay_val;
224 }
225 printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n", 223 printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n",
226 cpucount + 1, 224 cpucount + 1,
227 bogosum/(500000/HZ), 225 bogosum/(500000/HZ),
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index 8c93ba655b33..e505a4125e35 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -117,9 +117,7 @@ int show_interrupts(struct seq_file *p, void *v)
117#ifndef CONFIG_SMP 117#ifndef CONFIG_SMP
118 seq_printf(p, "%10u ", kstat_irqs(i)); 118 seq_printf(p, "%10u ", kstat_irqs(i));
119#else 119#else
120 for (j = 0; j < NR_CPUS; j++) { 120 for_each_online_cpu(j) {
121 if (!cpu_online(j))
122 continue;
123 seq_printf(p, "%10u ", 121 seq_printf(p, "%10u ",
124 kstat_cpu(j).irqs[i]); 122 kstat_cpu(j).irqs[i]);
125 } 123 }
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 373a701c90a5..1b6e2ade1008 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -57,25 +57,21 @@ void smp_info(struct seq_file *m)
57 int i; 57 int i;
58 58
59 seq_printf(m, "State:\n"); 59 seq_printf(m, "State:\n");
60 for (i = 0; i < NR_CPUS; i++) { 60 for_each_online_cpu(i)
61 if (cpu_online(i)) 61 seq_printf(m, "CPU%d:\t\tonline\n", i);
62 seq_printf(m,
63 "CPU%d:\t\tonline\n", i);
64 }
65} 62}
66 63
67void smp_bogo(struct seq_file *m) 64void smp_bogo(struct seq_file *m)
68{ 65{
69 int i; 66 int i;
70 67
71 for (i = 0; i < NR_CPUS; i++) 68 for_each_online_cpu(i)
72 if (cpu_online(i)) 69 seq_printf(m,
73 seq_printf(m, 70 "Cpu%dBogo\t: %lu.%02lu\n"
74 "Cpu%dBogo\t: %lu.%02lu\n" 71 "Cpu%dClkTck\t: %016lx\n",
75 "Cpu%dClkTck\t: %016lx\n", 72 i, cpu_data(i).udelay_val / (500000/HZ),
76 i, cpu_data(i).udelay_val / (500000/HZ), 73 (cpu_data(i).udelay_val / (5000/HZ)) % 100,
77 (cpu_data(i).udelay_val / (5000/HZ)) % 100, 74 i, cpu_data(i).clock_tick);
78 i, cpu_data(i).clock_tick);
79} 75}
80 76
81void __init smp_store_cpu_info(int id) 77void __init smp_store_cpu_info(int id)
@@ -1282,7 +1278,7 @@ int setup_profiling_timer(unsigned int multiplier)
1282 return -EINVAL; 1278 return -EINVAL;
1283 1279
1284 spin_lock_irqsave(&prof_setup_lock, flags); 1280 spin_lock_irqsave(&prof_setup_lock, flags);
1285 for (i = 0; i < NR_CPUS; i++) 1281 for_each_cpu(i)
1286 prof_multiplier(i) = multiplier; 1282 prof_multiplier(i) = multiplier;
1287 current_tick_offset = (timer_tick_offset / multiplier); 1283 current_tick_offset = (timer_tick_offset / multiplier);
1288 spin_unlock_irqrestore(&prof_setup_lock, flags); 1284 spin_unlock_irqrestore(&prof_setup_lock, flags);
@@ -1384,10 +1380,8 @@ void __init smp_cpus_done(unsigned int max_cpus)
1384 unsigned long bogosum = 0; 1380 unsigned long bogosum = 0;
1385 int i; 1381 int i;
1386 1382
1387 for (i = 0; i < NR_CPUS; i++) { 1383 for_each_online_cpu(i)
1388 if (cpu_online(i)) 1384 bogosum += cpu_data(i).udelay_val;
1389 bogosum += cpu_data(i).udelay_val;
1390 }
1391 printk("Total of %ld processors activated " 1385 printk("Total of %ld processors activated "
1392 "(%lu.%02lu BogoMIPS).\n", 1386 "(%lu.%02lu BogoMIPS).\n",
1393 (long) num_online_cpus(), 1387 (long) num_online_cpus(),
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index ded63ee9c4fd..1539a8362b6f 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -1828,8 +1828,8 @@ void __flush_tlb_all(void)
1828void online_page(struct page *page) 1828void online_page(struct page *page)
1829{ 1829{
1830 ClearPageReserved(page); 1830 ClearPageReserved(page);
1831 set_page_count(page, 0); 1831 init_page_count(page);
1832 free_cold_page(page); 1832 __free_page(page);
1833 totalram_pages++; 1833 totalram_pages++;
1834 num_physpages++; 1834 num_physpages++;
1835} 1835}
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 27cdf9164422..80c9c18aae94 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -491,6 +491,16 @@ void __init check_bugs(void)
491 check_devanon(); 491 check_devanon();
492} 492}
493 493
494void apply_alternatives(void *start, void *end) 494void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
495{
496}
497
498void alternatives_smp_module_add(struct module *mod, char *name,
499 void *locks, void *locks_end,
500 void *text, void *text_end)
501{
502}
503
504void alternatives_smp_module_del(struct module *mod)
495{ 505{
496} 506}
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 6dffb498ccd7..a8a6aa70d695 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -17,11 +17,8 @@
17#define VGABASE ((void __iomem *)0xffffffff800b8000UL) 17#define VGABASE ((void __iomem *)0xffffffff800b8000UL)
18#endif 18#endif
19 19
20#define MAX_YPOS max_ypos
21#define MAX_XPOS max_xpos
22
23static int max_ypos = 25, max_xpos = 80; 20static int max_ypos = 25, max_xpos = 80;
24static int current_ypos = 1, current_xpos = 0; 21static int current_ypos = 25, current_xpos = 0;
25 22
26static void early_vga_write(struct console *con, const char *str, unsigned n) 23static void early_vga_write(struct console *con, const char *str, unsigned n)
27{ 24{
@@ -29,26 +26,26 @@ static void early_vga_write(struct console *con, const char *str, unsigned n)
29 int i, k, j; 26 int i, k, j;
30 27
31 while ((c = *str++) != '\0' && n-- > 0) { 28 while ((c = *str++) != '\0' && n-- > 0) {
32 if (current_ypos >= MAX_YPOS) { 29 if (current_ypos >= max_ypos) {
33 /* scroll 1 line up */ 30 /* scroll 1 line up */
34 for (k = 1, j = 0; k < MAX_YPOS; k++, j++) { 31 for (k = 1, j = 0; k < max_ypos; k++, j++) {
35 for (i = 0; i < MAX_XPOS; i++) { 32 for (i = 0; i < max_xpos; i++) {
36 writew(readw(VGABASE + 2*(MAX_XPOS*k + i)), 33 writew(readw(VGABASE+2*(max_xpos*k+i)),
37 VGABASE + 2*(MAX_XPOS*j + i)); 34 VGABASE + 2*(max_xpos*j + i));
38 } 35 }
39 } 36 }
40 for (i = 0; i < MAX_XPOS; i++) 37 for (i = 0; i < max_xpos; i++)
41 writew(0x720, VGABASE + 2*(MAX_XPOS*j + i)); 38 writew(0x720, VGABASE + 2*(max_xpos*j + i));
42 current_ypos = MAX_YPOS-1; 39 current_ypos = max_ypos-1;
43 } 40 }
44 if (c == '\n') { 41 if (c == '\n') {
45 current_xpos = 0; 42 current_xpos = 0;
46 current_ypos++; 43 current_ypos++;
47 } else if (c != '\r') { 44 } else if (c != '\r') {
48 writew(((0x7 << 8) | (unsigned short) c), 45 writew(((0x7 << 8) | (unsigned short) c),
49 VGABASE + 2*(MAX_XPOS*current_ypos + 46 VGABASE + 2*(max_xpos*current_ypos +
50 current_xpos++)); 47 current_xpos++));
51 if (current_xpos >= MAX_XPOS) { 48 if (current_xpos >= max_xpos) {
52 current_xpos = 0; 49 current_xpos = 0;
53 current_ypos++; 50 current_ypos++;
54 } 51 }
@@ -244,6 +241,7 @@ int __init setup_early_printk(char *opt)
244 && SCREEN_INFO.orig_video_isVGA == 1) { 241 && SCREEN_INFO.orig_video_isVGA == 1) {
245 max_xpos = SCREEN_INFO.orig_video_cols; 242 max_xpos = SCREEN_INFO.orig_video_cols;
246 max_ypos = SCREEN_INFO.orig_video_lines; 243 max_ypos = SCREEN_INFO.orig_video_lines;
244 current_ypos = SCREEN_INFO.orig_y;
247 early_console = &early_vga_console; 245 early_console = &early_vga_console;
248 } else if (!strncmp(buf, "simnow", 6)) { 246 } else if (!strncmp(buf, "simnow", 6)) {
249 simnow_init(buf + 6); 247 simnow_init(buf + 6);
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index 30d2a1e545fe..d8bd0b345b1e 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -38,9 +38,8 @@ int show_interrupts(struct seq_file *p, void *v)
38 38
39 if (i == 0) { 39 if (i == 0) {
40 seq_printf(p, " "); 40 seq_printf(p, " ");
41 for (j=0; j<NR_CPUS; j++) 41 for_each_online_cpu(j)
42 if (cpu_online(j)) 42 seq_printf(p, "CPU%d ",j);
43 seq_printf(p, "CPU%d ",j);
44 seq_putc(p, '\n'); 43 seq_putc(p, '\n');
45 } 44 }
46 45
@@ -53,10 +52,8 @@ int show_interrupts(struct seq_file *p, void *v)
53#ifndef CONFIG_SMP 52#ifndef CONFIG_SMP
54 seq_printf(p, "%10u ", kstat_irqs(i)); 53 seq_printf(p, "%10u ", kstat_irqs(i));
55#else 54#else
56 for (j=0; j<NR_CPUS; j++) 55 for_each_online_cpu(j)
57 if (cpu_online(j)) 56 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
58 seq_printf(p, "%10u ",
59 kstat_cpu(j).irqs[i]);
60#endif 57#endif
61 seq_printf(p, " %14s", irq_desc[i].handler->typename); 58 seq_printf(p, " %14s", irq_desc[i].handler->typename);
62 59
@@ -68,15 +65,13 @@ skip:
68 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 65 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
69 } else if (i == NR_IRQS) { 66 } else if (i == NR_IRQS) {
70 seq_printf(p, "NMI: "); 67 seq_printf(p, "NMI: ");
71 for (j = 0; j < NR_CPUS; j++) 68 for_each_online_cpu(j)
72 if (cpu_online(j)) 69 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
73 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
74 seq_putc(p, '\n'); 70 seq_putc(p, '\n');
75#ifdef CONFIG_X86_LOCAL_APIC 71#ifdef CONFIG_X86_LOCAL_APIC
76 seq_printf(p, "LOC: "); 72 seq_printf(p, "LOC: ");
77 for (j = 0; j < NR_CPUS; j++) 73 for_each_online_cpu(j)
78 if (cpu_online(j)) 74 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
79 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
80 seq_putc(p, '\n'); 75 seq_putc(p, '\n');
81#endif 76#endif
82 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); 77 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index 8b866a8572cf..14f0ced613b6 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -222,9 +222,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
222 222
223void __kprobes arch_remove_kprobe(struct kprobe *p) 223void __kprobes arch_remove_kprobe(struct kprobe *p)
224{ 224{
225 down(&kprobe_mutex); 225 mutex_lock(&kprobe_mutex);
226 free_insn_slot(p->ainsn.insn); 226 free_insn_slot(p->ainsn.insn);
227 up(&kprobe_mutex); 227 mutex_unlock(&kprobe_mutex);
228} 228}
229 229
230static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) 230static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 5bf17e41cd2d..66c009e10bac 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -162,9 +162,7 @@ int __init check_nmi_watchdog (void)
162 local_irq_enable(); 162 local_irq_enable();
163 mdelay((10*1000)/nmi_hz); // wait 10 ticks 163 mdelay((10*1000)/nmi_hz); // wait 10 ticks
164 164
165 for (cpu = 0; cpu < NR_CPUS; cpu++) { 165 for_each_online_cpu(cpu) {
166 if (!cpu_online(cpu))
167 continue;
168 if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) { 166 if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
169 endflag = 1; 167 endflag = 1;
170 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n", 168 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 5876df116c92..e5f5ce7909a3 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -443,9 +443,6 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
443 if (!user_mode(regs)) 443 if (!user_mode(regs))
444 return 1; 444 return 1;
445 445
446 if (try_to_freeze())
447 goto no_signal;
448
449 if (!oldset) 446 if (!oldset)
450 oldset = &current->blocked; 447 oldset = &current->blocked;
451 448
@@ -463,7 +460,6 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
463 return handle_signal(signr, &info, &ka, oldset, regs); 460 return handle_signal(signr, &info, &ka, oldset, regs);
464 } 461 }
465 462
466 no_signal:
467 /* Did we come from a system call? */ 463 /* Did we come from a system call? */
468 if ((long)regs->orig_rax >= 0) { 464 if ((long)regs->orig_rax >= 0) {
469 /* Restart the system call - no handlers present */ 465 /* Restart the system call - no handlers present */
diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
index 4cbf6d91571f..51f9bed455fa 100644
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -83,9 +83,8 @@ int show_interrupts(struct seq_file *p, void *v)
83 83
84 if (i == 0) { 84 if (i == 0) {
85 seq_printf(p, " "); 85 seq_printf(p, " ");
86 for (j=0; j<NR_CPUS; j++) 86 for_each_online_cpu(j)
87 if (cpu_online(j)) 87 seq_printf(p, "CPU%d ",j);
88 seq_printf(p, "CPU%d ",j);
89 seq_putc(p, '\n'); 88 seq_putc(p, '\n');
90 } 89 }
91 90
@@ -98,9 +97,8 @@ int show_interrupts(struct seq_file *p, void *v)
98#ifndef CONFIG_SMP 97#ifndef CONFIG_SMP
99 seq_printf(p, "%10u ", kstat_irqs(i)); 98 seq_printf(p, "%10u ", kstat_irqs(i));
100#else 99#else
101 for (j = 0; j < NR_CPUS; j++) 100 for_each_online_cpu(j)
102 if (cpu_online(j)) 101 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
103 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
104#endif 102#endif
105 seq_printf(p, " %14s", irq_desc[i].handler->typename); 103 seq_printf(p, " %14s", irq_desc[i].handler->typename);
106 seq_printf(p, " %s", action->name); 104 seq_printf(p, " %s", action->name);
@@ -113,9 +111,8 @@ skip:
113 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 111 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
114 } else if (i == NR_IRQS) { 112 } else if (i == NR_IRQS) {
115 seq_printf(p, "NMI: "); 113 seq_printf(p, "NMI: ");
116 for (j = 0; j < NR_CPUS; j++) 114 for_each_online_cpu(j)
117 if (cpu_online(j)) 115 seq_printf(p, "%10u ", nmi_count(j));
118 seq_printf(p, "%10u ", nmi_count(j));
119 seq_putc(p, '\n'); 116 seq_putc(p, '\n');
120 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); 117 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
121 } 118 }
diff --git a/arch/xtensa/platform-iss/console.c b/arch/xtensa/platform-iss/console.c
index 94fdfe474ac1..2a580efb58ec 100644
--- a/arch/xtensa/platform-iss/console.c
+++ b/arch/xtensa/platform-iss/console.c
@@ -31,10 +31,6 @@
31#include <linux/tty.h> 31#include <linux/tty.h>
32#include <linux/tty_flip.h> 32#include <linux/tty_flip.h>
33 33
34#ifdef SERIAL_INLINE
35#define _INLINE_ inline
36#endif
37
38#define SERIAL_MAX_NUM_LINES 1 34#define SERIAL_MAX_NUM_LINES 1
39#define SERIAL_TIMER_VALUE (20 * HZ) 35#define SERIAL_TIMER_VALUE (20 * HZ)
40 36
diff --git a/block/ioctl.c b/block/ioctl.c
index e1109491c234..35fdb7dc6512 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -42,9 +42,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
42 return -EINVAL; 42 return -EINVAL;
43 } 43 }
44 /* partition number in use? */ 44 /* partition number in use? */
45 down(&bdev->bd_sem); 45 mutex_lock(&bdev->bd_mutex);
46 if (disk->part[part - 1]) { 46 if (disk->part[part - 1]) {
47 up(&bdev->bd_sem); 47 mutex_unlock(&bdev->bd_mutex);
48 return -EBUSY; 48 return -EBUSY;
49 } 49 }
50 /* overlap? */ 50 /* overlap? */
@@ -55,13 +55,13 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
55 continue; 55 continue;
56 if (!(start+length <= s->start_sect || 56 if (!(start+length <= s->start_sect ||
57 start >= s->start_sect + s->nr_sects)) { 57 start >= s->start_sect + s->nr_sects)) {
58 up(&bdev->bd_sem); 58 mutex_unlock(&bdev->bd_mutex);
59 return -EBUSY; 59 return -EBUSY;
60 } 60 }
61 } 61 }
62 /* all seems OK */ 62 /* all seems OK */
63 add_partition(disk, part, start, length); 63 add_partition(disk, part, start, length);
64 up(&bdev->bd_sem); 64 mutex_unlock(&bdev->bd_mutex);
65 return 0; 65 return 0;
66 case BLKPG_DEL_PARTITION: 66 case BLKPG_DEL_PARTITION:
67 if (!disk->part[part-1]) 67 if (!disk->part[part-1])
@@ -71,9 +71,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
71 bdevp = bdget_disk(disk, part); 71 bdevp = bdget_disk(disk, part);
72 if (!bdevp) 72 if (!bdevp)
73 return -ENOMEM; 73 return -ENOMEM;
74 down(&bdevp->bd_sem); 74 mutex_lock(&bdevp->bd_mutex);
75 if (bdevp->bd_openers) { 75 if (bdevp->bd_openers) {
76 up(&bdevp->bd_sem); 76 mutex_unlock(&bdevp->bd_mutex);
77 bdput(bdevp); 77 bdput(bdevp);
78 return -EBUSY; 78 return -EBUSY;
79 } 79 }
@@ -81,10 +81,10 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
81 fsync_bdev(bdevp); 81 fsync_bdev(bdevp);
82 invalidate_bdev(bdevp, 0); 82 invalidate_bdev(bdevp, 0);
83 83
84 down(&bdev->bd_sem); 84 mutex_lock(&bdev->bd_mutex);
85 delete_partition(disk, part); 85 delete_partition(disk, part);
86 up(&bdev->bd_sem); 86 mutex_unlock(&bdev->bd_mutex);
87 up(&bdevp->bd_sem); 87 mutex_unlock(&bdevp->bd_mutex);
88 bdput(bdevp); 88 bdput(bdevp);
89 89
90 return 0; 90 return 0;
@@ -102,10 +102,10 @@ static int blkdev_reread_part(struct block_device *bdev)
102 return -EINVAL; 102 return -EINVAL;
103 if (!capable(CAP_SYS_ADMIN)) 103 if (!capable(CAP_SYS_ADMIN))
104 return -EACCES; 104 return -EACCES;
105 if (down_trylock(&bdev->bd_sem)) 105 if (!mutex_trylock(&bdev->bd_mutex))
106 return -EBUSY; 106 return -EBUSY;
107 res = rescan_partitions(disk, bdev); 107 res = rescan_partitions(disk, bdev);
108 up(&bdev->bd_sem); 108 mutex_unlock(&bdev->bd_mutex);
109 return res; 109 return res;
110} 110}
111 111
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index 8660779fb288..bdb60663f2ef 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -8,6 +8,7 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/vt_kern.h>
11#include <linux/device.h> 12#include <linux/device.h>
12#include "../base.h" 13#include "../base.h"
13#include "power.h" 14#include "power.h"
@@ -62,7 +63,6 @@ int suspend_device(struct device * dev, pm_message_t state)
62 return error; 63 return error;
63} 64}
64 65
65
66/** 66/**
67 * device_suspend - Save state and stop all devices in system. 67 * device_suspend - Save state and stop all devices in system.
68 * @state: Power state to put each device in. 68 * @state: Power state to put each device in.
@@ -82,6 +82,9 @@ int device_suspend(pm_message_t state)
82{ 82{
83 int error = 0; 83 int error = 0;
84 84
85 if (!is_console_suspend_safe())
86 return -EINVAL;
87
85 down(&dpm_sem); 88 down(&dpm_sem);
86 down(&dpm_list_sem); 89 down(&dpm_list_sem);
87 while (!list_empty(&dpm_active) && error == 0) { 90 while (!list_empty(&dpm_active) && error == 0) {
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index cf39cf9aac25..e29b8926f80e 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3268,8 +3268,8 @@ clean2:
3268 unregister_blkdev(hba[i]->major, hba[i]->devname); 3268 unregister_blkdev(hba[i]->major, hba[i]->devname);
3269clean1: 3269clean1:
3270 release_io_mem(hba[i]); 3270 release_io_mem(hba[i]);
3271 free_hba(i);
3272 hba[i]->busy_initializing = 0; 3271 hba[i]->busy_initializing = 0;
3272 free_hba(i);
3273 return(-1); 3273 return(-1);
3274} 3274}
3275 3275
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index d23b54332d7e..fb2d0be7cdeb 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -179,6 +179,7 @@ static int print_unex = 1;
179#include <linux/devfs_fs_kernel.h> 179#include <linux/devfs_fs_kernel.h>
180#include <linux/platform_device.h> 180#include <linux/platform_device.h>
181#include <linux/buffer_head.h> /* for invalidate_buffers() */ 181#include <linux/buffer_head.h> /* for invalidate_buffers() */
182#include <linux/mutex.h>
182 183
183/* 184/*
184 * PS/2 floppies have much slower step rates than regular floppies. 185 * PS/2 floppies have much slower step rates than regular floppies.
@@ -413,7 +414,7 @@ static struct floppy_write_errors write_errors[N_DRIVE];
413static struct timer_list motor_off_timer[N_DRIVE]; 414static struct timer_list motor_off_timer[N_DRIVE];
414static struct gendisk *disks[N_DRIVE]; 415static struct gendisk *disks[N_DRIVE];
415static struct block_device *opened_bdev[N_DRIVE]; 416static struct block_device *opened_bdev[N_DRIVE];
416static DECLARE_MUTEX(open_lock); 417static DEFINE_MUTEX(open_lock);
417static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; 418static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
418 419
419/* 420/*
@@ -3333,7 +3334,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3333 if (type) { 3334 if (type) {
3334 if (!capable(CAP_SYS_ADMIN)) 3335 if (!capable(CAP_SYS_ADMIN))
3335 return -EPERM; 3336 return -EPERM;
3336 down(&open_lock); 3337 mutex_lock(&open_lock);
3337 LOCK_FDC(drive, 1); 3338 LOCK_FDC(drive, 1);
3338 floppy_type[type] = *g; 3339 floppy_type[type] = *g;
3339 floppy_type[type].name = "user format"; 3340 floppy_type[type].name = "user format";
@@ -3347,7 +3348,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3347 continue; 3348 continue;
3348 __invalidate_device(bdev); 3349 __invalidate_device(bdev);
3349 } 3350 }
3350 up(&open_lock); 3351 mutex_unlock(&open_lock);
3351 } else { 3352 } else {
3352 int oldStretch; 3353 int oldStretch;
3353 LOCK_FDC(drive, 1); 3354 LOCK_FDC(drive, 1);
@@ -3674,7 +3675,7 @@ static int floppy_release(struct inode *inode, struct file *filp)
3674{ 3675{
3675 int drive = (long)inode->i_bdev->bd_disk->private_data; 3676 int drive = (long)inode->i_bdev->bd_disk->private_data;
3676 3677
3677 down(&open_lock); 3678 mutex_lock(&open_lock);
3678 if (UDRS->fd_ref < 0) 3679 if (UDRS->fd_ref < 0)
3679 UDRS->fd_ref = 0; 3680 UDRS->fd_ref = 0;
3680 else if (!UDRS->fd_ref--) { 3681 else if (!UDRS->fd_ref--) {
@@ -3684,7 +3685,7 @@ static int floppy_release(struct inode *inode, struct file *filp)
3684 if (!UDRS->fd_ref) 3685 if (!UDRS->fd_ref)
3685 opened_bdev[drive] = NULL; 3686 opened_bdev[drive] = NULL;
3686 floppy_release_irq_and_dma(); 3687 floppy_release_irq_and_dma();
3687 up(&open_lock); 3688 mutex_unlock(&open_lock);
3688 return 0; 3689 return 0;
3689} 3690}
3690 3691
@@ -3702,7 +3703,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
3702 char *tmp; 3703 char *tmp;
3703 3704
3704 filp->private_data = (void *)0; 3705 filp->private_data = (void *)0;
3705 down(&open_lock); 3706 mutex_lock(&open_lock);
3706 old_dev = UDRS->fd_device; 3707 old_dev = UDRS->fd_device;
3707 if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) 3708 if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
3708 goto out2; 3709 goto out2;
@@ -3785,7 +3786,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
3785 if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) 3786 if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
3786 goto out; 3787 goto out;
3787 } 3788 }
3788 up(&open_lock); 3789 mutex_unlock(&open_lock);
3789 return 0; 3790 return 0;
3790out: 3791out:
3791 if (UDRS->fd_ref < 0) 3792 if (UDRS->fd_ref < 0)
@@ -3796,7 +3797,7 @@ out:
3796 opened_bdev[drive] = NULL; 3797 opened_bdev[drive] = NULL;
3797 floppy_release_irq_and_dma(); 3798 floppy_release_irq_and_dma();
3798out2: 3799out2:
3799 up(&open_lock); 3800 mutex_unlock(&open_lock);
3800 return res; 3801 return res;
3801} 3802}
3802 3803
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 0010704739e3..74bf0255e98f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1144,7 +1144,7 @@ static int lo_ioctl(struct inode * inode, struct file * file,
1144 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1144 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1145 int err; 1145 int err;
1146 1146
1147 down(&lo->lo_ctl_mutex); 1147 mutex_lock(&lo->lo_ctl_mutex);
1148 switch (cmd) { 1148 switch (cmd) {
1149 case LOOP_SET_FD: 1149 case LOOP_SET_FD:
1150 err = loop_set_fd(lo, file, inode->i_bdev, arg); 1150 err = loop_set_fd(lo, file, inode->i_bdev, arg);
@@ -1170,7 +1170,7 @@ static int lo_ioctl(struct inode * inode, struct file * file,
1170 default: 1170 default:
1171 err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL; 1171 err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
1172 } 1172 }
1173 up(&lo->lo_ctl_mutex); 1173 mutex_unlock(&lo->lo_ctl_mutex);
1174 return err; 1174 return err;
1175} 1175}
1176 1176
@@ -1178,9 +1178,9 @@ static int lo_open(struct inode *inode, struct file *file)
1178{ 1178{
1179 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1179 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1180 1180
1181 down(&lo->lo_ctl_mutex); 1181 mutex_lock(&lo->lo_ctl_mutex);
1182 lo->lo_refcnt++; 1182 lo->lo_refcnt++;
1183 up(&lo->lo_ctl_mutex); 1183 mutex_unlock(&lo->lo_ctl_mutex);
1184 1184
1185 return 0; 1185 return 0;
1186} 1186}
@@ -1189,9 +1189,9 @@ static int lo_release(struct inode *inode, struct file *file)
1189{ 1189{
1190 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1190 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1191 1191
1192 down(&lo->lo_ctl_mutex); 1192 mutex_lock(&lo->lo_ctl_mutex);
1193 --lo->lo_refcnt; 1193 --lo->lo_refcnt;
1194 up(&lo->lo_ctl_mutex); 1194 mutex_unlock(&lo->lo_ctl_mutex);
1195 1195
1196 return 0; 1196 return 0;
1197} 1197}
@@ -1233,12 +1233,12 @@ int loop_unregister_transfer(int number)
1233 xfer_funcs[n] = NULL; 1233 xfer_funcs[n] = NULL;
1234 1234
1235 for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) { 1235 for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) {
1236 down(&lo->lo_ctl_mutex); 1236 mutex_lock(&lo->lo_ctl_mutex);
1237 1237
1238 if (lo->lo_encryption == xfer) 1238 if (lo->lo_encryption == xfer)
1239 loop_release_xfer(lo); 1239 loop_release_xfer(lo);
1240 1240
1241 up(&lo->lo_ctl_mutex); 1241 mutex_unlock(&lo->lo_ctl_mutex);
1242 } 1242 }
1243 1243
1244 return 0; 1244 return 0;
@@ -1285,7 +1285,7 @@ static int __init loop_init(void)
1285 lo->lo_queue = blk_alloc_queue(GFP_KERNEL); 1285 lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
1286 if (!lo->lo_queue) 1286 if (!lo->lo_queue)
1287 goto out_mem4; 1287 goto out_mem4;
1288 init_MUTEX(&lo->lo_ctl_mutex); 1288 mutex_init(&lo->lo_ctl_mutex);
1289 init_completion(&lo->lo_done); 1289 init_completion(&lo->lo_done);
1290 init_completion(&lo->lo_bh_done); 1290 init_completion(&lo->lo_bh_done);
1291 lo->lo_number = i; 1291 lo->lo_number = i;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 6997d8e6bfb5..a9bde30dadad 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -459,9 +459,9 @@ static void do_nbd_request(request_queue_t * q)
459 req->errors = 0; 459 req->errors = 0;
460 spin_unlock_irq(q->queue_lock); 460 spin_unlock_irq(q->queue_lock);
461 461
462 down(&lo->tx_lock); 462 mutex_lock(&lo->tx_lock);
463 if (unlikely(!lo->sock)) { 463 if (unlikely(!lo->sock)) {
464 up(&lo->tx_lock); 464 mutex_unlock(&lo->tx_lock);
465 printk(KERN_ERR "%s: Attempted send on closed socket\n", 465 printk(KERN_ERR "%s: Attempted send on closed socket\n",
466 lo->disk->disk_name); 466 lo->disk->disk_name);
467 req->errors++; 467 req->errors++;
@@ -484,7 +484,7 @@ static void do_nbd_request(request_queue_t * q)
484 } 484 }
485 485
486 lo->active_req = NULL; 486 lo->active_req = NULL;
487 up(&lo->tx_lock); 487 mutex_unlock(&lo->tx_lock);
488 wake_up_all(&lo->active_wq); 488 wake_up_all(&lo->active_wq);
489 489
490 spin_lock_irq(q->queue_lock); 490 spin_lock_irq(q->queue_lock);
@@ -534,9 +534,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
534 534
535 case NBD_CLEAR_SOCK: 535 case NBD_CLEAR_SOCK:
536 error = 0; 536 error = 0;
537 down(&lo->tx_lock); 537 mutex_lock(&lo->tx_lock);
538 lo->sock = NULL; 538 lo->sock = NULL;
539 up(&lo->tx_lock); 539 mutex_unlock(&lo->tx_lock);
540 file = lo->file; 540 file = lo->file;
541 lo->file = NULL; 541 lo->file = NULL;
542 nbd_clear_que(lo); 542 nbd_clear_que(lo);
@@ -590,7 +590,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
590 * FIXME: This code is duplicated from sys_shutdown, but 590 * FIXME: This code is duplicated from sys_shutdown, but
591 * there should be a more generic interface rather than 591 * there should be a more generic interface rather than
592 * calling socket ops directly here */ 592 * calling socket ops directly here */
593 down(&lo->tx_lock); 593 mutex_lock(&lo->tx_lock);
594 if (lo->sock) { 594 if (lo->sock) {
595 printk(KERN_WARNING "%s: shutting down socket\n", 595 printk(KERN_WARNING "%s: shutting down socket\n",
596 lo->disk->disk_name); 596 lo->disk->disk_name);
@@ -598,7 +598,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
598 SEND_SHUTDOWN|RCV_SHUTDOWN); 598 SEND_SHUTDOWN|RCV_SHUTDOWN);
599 lo->sock = NULL; 599 lo->sock = NULL;
600 } 600 }
601 up(&lo->tx_lock); 601 mutex_unlock(&lo->tx_lock);
602 file = lo->file; 602 file = lo->file;
603 lo->file = NULL; 603 lo->file = NULL;
604 nbd_clear_que(lo); 604 nbd_clear_que(lo);
@@ -683,7 +683,7 @@ static int __init nbd_init(void)
683 nbd_dev[i].flags = 0; 683 nbd_dev[i].flags = 0;
684 spin_lock_init(&nbd_dev[i].queue_lock); 684 spin_lock_init(&nbd_dev[i].queue_lock);
685 INIT_LIST_HEAD(&nbd_dev[i].queue_head); 685 INIT_LIST_HEAD(&nbd_dev[i].queue_head);
686 init_MUTEX(&nbd_dev[i].tx_lock); 686 mutex_init(&nbd_dev[i].tx_lock);
687 init_waitqueue_head(&nbd_dev[i].active_wq); 687 init_waitqueue_head(&nbd_dev[i].active_wq);
688 nbd_dev[i].blksize = 1024; 688 nbd_dev[i].blksize = 1024;
689 nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ 689 nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 476a5b553f34..1d261f985f31 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -56,6 +56,7 @@
56#include <linux/seq_file.h> 56#include <linux/seq_file.h>
57#include <linux/miscdevice.h> 57#include <linux/miscdevice.h>
58#include <linux/suspend.h> 58#include <linux/suspend.h>
59#include <linux/mutex.h>
59#include <scsi/scsi_cmnd.h> 60#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_ioctl.h> 61#include <scsi/scsi_ioctl.h>
61#include <scsi/scsi.h> 62#include <scsi/scsi.h>
@@ -81,7 +82,7 @@
81static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 82static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
82static struct proc_dir_entry *pkt_proc; 83static struct proc_dir_entry *pkt_proc;
83static int pkt_major; 84static int pkt_major;
84static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */ 85static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
85static mempool_t *psd_pool; 86static mempool_t *psd_pool;
86 87
87 88
@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file)
2018 2019
2019 VPRINTK("pktcdvd: entering open\n"); 2020 VPRINTK("pktcdvd: entering open\n");
2020 2021
2021 down(&ctl_mutex); 2022 mutex_lock(&ctl_mutex);
2022 pd = pkt_find_dev_from_minor(iminor(inode)); 2023 pd = pkt_find_dev_from_minor(iminor(inode));
2023 if (!pd) { 2024 if (!pd) {
2024 ret = -ENODEV; 2025 ret = -ENODEV;
@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file)
2044 set_blocksize(inode->i_bdev, CD_FRAMESIZE); 2045 set_blocksize(inode->i_bdev, CD_FRAMESIZE);
2045 } 2046 }
2046 2047
2047 up(&ctl_mutex); 2048 mutex_unlock(&ctl_mutex);
2048 return 0; 2049 return 0;
2049 2050
2050out_dec: 2051out_dec:
2051 pd->refcnt--; 2052 pd->refcnt--;
2052out: 2053out:
2053 VPRINTK("pktcdvd: failed open (%d)\n", ret); 2054 VPRINTK("pktcdvd: failed open (%d)\n", ret);
2054 up(&ctl_mutex); 2055 mutex_unlock(&ctl_mutex);
2055 return ret; 2056 return ret;
2056} 2057}
2057 2058
@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file)
2060 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; 2061 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;
2061 int ret = 0; 2062 int ret = 0;
2062 2063
2063 down(&ctl_mutex); 2064 mutex_lock(&ctl_mutex);
2064 pd->refcnt--; 2065 pd->refcnt--;
2065 BUG_ON(pd->refcnt < 0); 2066 BUG_ON(pd->refcnt < 0);
2066 if (pd->refcnt == 0) { 2067 if (pd->refcnt == 0) {
2067 int flush = test_bit(PACKET_WRITABLE, &pd->flags); 2068 int flush = test_bit(PACKET_WRITABLE, &pd->flags);
2068 pkt_release_dev(pd, flush); 2069 pkt_release_dev(pd, flush);
2069 } 2070 }
2070 up(&ctl_mutex); 2071 mutex_unlock(&ctl_mutex);
2071 return ret; 2072 return ret;
2072} 2073}
2073 2074
@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
2596 case PKT_CTRL_CMD_SETUP: 2597 case PKT_CTRL_CMD_SETUP:
2597 if (!capable(CAP_SYS_ADMIN)) 2598 if (!capable(CAP_SYS_ADMIN))
2598 return -EPERM; 2599 return -EPERM;
2599 down(&ctl_mutex); 2600 mutex_lock(&ctl_mutex);
2600 ret = pkt_setup_dev(&ctrl_cmd); 2601 ret = pkt_setup_dev(&ctrl_cmd);
2601 up(&ctl_mutex); 2602 mutex_unlock(&ctl_mutex);
2602 break; 2603 break;
2603 case PKT_CTRL_CMD_TEARDOWN: 2604 case PKT_CTRL_CMD_TEARDOWN:
2604 if (!capable(CAP_SYS_ADMIN)) 2605 if (!capable(CAP_SYS_ADMIN))
2605 return -EPERM; 2606 return -EPERM;
2606 down(&ctl_mutex); 2607 mutex_lock(&ctl_mutex);
2607 ret = pkt_remove_dev(&ctrl_cmd); 2608 ret = pkt_remove_dev(&ctrl_cmd);
2608 up(&ctl_mutex); 2609 mutex_unlock(&ctl_mutex);
2609 break; 2610 break;
2610 case PKT_CTRL_CMD_STATUS: 2611 case PKT_CTRL_CMD_STATUS:
2611 down(&ctl_mutex); 2612 mutex_lock(&ctl_mutex);
2612 pkt_get_status(&ctrl_cmd); 2613 pkt_get_status(&ctrl_cmd);
2613 up(&ctl_mutex); 2614 mutex_unlock(&ctl_mutex);
2614 break; 2615 break;
2615 default: 2616 default:
2616 return -ENOTTY; 2617 return -ENOTTY;
@@ -2656,7 +2657,7 @@ static int __init pkt_init(void)
2656 goto out; 2657 goto out;
2657 } 2658 }
2658 2659
2659 init_MUTEX(&ctl_mutex); 2660 mutex_init(&ctl_mutex);
2660 2661
2661 pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); 2662 pkt_proc = proc_mkdir("pktcdvd", proc_root_driver);
2662 2663
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index ffd6abd6d5a0..1c54f46d3f70 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -310,12 +310,12 @@ static int rd_ioctl(struct inode *inode, struct file *file,
310 * cache 310 * cache
311 */ 311 */
312 error = -EBUSY; 312 error = -EBUSY;
313 down(&bdev->bd_sem); 313 mutex_lock(&bdev->bd_mutex);
314 if (bdev->bd_openers <= 2) { 314 if (bdev->bd_openers <= 2) {
315 truncate_inode_pages(bdev->bd_inode->i_mapping, 0); 315 truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
316 error = 0; 316 error = 0;
317 } 317 }
318 up(&bdev->bd_sem); 318 mutex_unlock(&bdev->bd_mutex);
319 return error; 319 return error;
320} 320}
321 321
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 879bbc26ce96..a59876a0bfa1 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -407,7 +407,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
407 ENSURE(get_mcn, CDC_MCN); 407 ENSURE(get_mcn, CDC_MCN);
408 ENSURE(reset, CDC_RESET); 408 ENSURE(reset, CDC_RESET);
409 ENSURE(audio_ioctl, CDC_PLAY_AUDIO); 409 ENSURE(audio_ioctl, CDC_PLAY_AUDIO);
410 ENSURE(dev_ioctl, CDC_IOCTLS);
411 ENSURE(generic_packet, CDC_GENERIC_PACKET); 410 ENSURE(generic_packet, CDC_GENERIC_PACKET);
412 cdi->mc_flags = 0; 411 cdi->mc_flags = 0;
413 cdo->n_minors = 0; 412 cdo->n_minors = 0;
@@ -2196,395 +2195,586 @@ retry:
2196 return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); 2195 return cdrom_read_cdda_old(cdi, ubuf, lba, nframes);
2197} 2196}
2198 2197
2199/* Just about every imaginable ioctl is supported in the Uniform layer 2198static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi,
2200 * these days. ATAPI / SCSI specific code now mainly resides in 2199 void __user *argp)
2201 * mmc_ioct().
2202 */
2203int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
2204 struct inode *ip, unsigned int cmd, unsigned long arg)
2205{ 2200{
2206 struct cdrom_device_ops *cdo = cdi->ops; 2201 struct cdrom_multisession ms_info;
2202 u8 requested_format;
2207 int ret; 2203 int ret;
2208 2204
2209 /* Try the generic SCSI command ioctl's first.. */ 2205 cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n");
2210 ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, (void __user *)arg); 2206
2211 if (ret != -ENOTTY) 2207 if (!(cdi->ops->capability & CDC_MULTI_SESSION))
2208 return -ENOSYS;
2209
2210 if (copy_from_user(&ms_info, argp, sizeof(ms_info)))
2211 return -EFAULT;
2212
2213 requested_format = ms_info.addr_format;
2214 if (requested_format != CDROM_MSF && requested_format != CDROM_LBA)
2215 return -EINVAL;
2216 ms_info.addr_format = CDROM_LBA;
2217
2218 ret = cdi->ops->get_last_session(cdi, &ms_info);
2219 if (ret)
2212 return ret; 2220 return ret;
2213 2221
2214 /* the first few commands do not deal with audio drive_info, but 2222 sanitize_format(&ms_info.addr, &ms_info.addr_format, requested_format);
2215 only with routines in cdrom device operations. */ 2223
2216 switch (cmd) { 2224 if (copy_to_user(argp, &ms_info, sizeof(ms_info)))
2217 case CDROMMULTISESSION: { 2225 return -EFAULT;
2218 struct cdrom_multisession ms_info; 2226
2219 u_char requested_format; 2227 cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n");
2220 cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n"); 2228 return 0;
2221 if (!(cdo->capability & CDC_MULTI_SESSION)) 2229}
2222 return -ENOSYS; 2230
2223 IOCTL_IN(arg, struct cdrom_multisession, ms_info); 2231static int cdrom_ioctl_eject(struct cdrom_device_info *cdi)
2224 requested_format = ms_info.addr_format; 2232{
2225 if (!((requested_format == CDROM_MSF) || 2233 cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n");
2226 (requested_format == CDROM_LBA))) 2234
2227 return -EINVAL; 2235 if (!CDROM_CAN(CDC_OPEN_TRAY))
2228 ms_info.addr_format = CDROM_LBA; 2236 return -ENOSYS;
2229 if ((ret=cdo->get_last_session(cdi, &ms_info))) 2237 if (cdi->use_count != 1 || keeplocked)
2238 return -EBUSY;
2239 if (CDROM_CAN(CDC_LOCK)) {
2240 int ret = cdi->ops->lock_door(cdi, 0);
2241 if (ret)
2230 return ret; 2242 return ret;
2231 sanitize_format(&ms_info.addr, &ms_info.addr_format, 2243 }
2232 requested_format);
2233 IOCTL_OUT(arg, struct cdrom_multisession, ms_info);
2234 cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n");
2235 return 0;
2236 }
2237 2244
2238 case CDROMEJECT: { 2245 return cdi->ops->tray_move(cdi, 1);
2239 cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n"); 2246}
2240 if (!CDROM_CAN(CDC_OPEN_TRAY))
2241 return -ENOSYS;
2242 if (cdi->use_count != 1 || keeplocked)
2243 return -EBUSY;
2244 if (CDROM_CAN(CDC_LOCK))
2245 if ((ret=cdo->lock_door(cdi, 0)))
2246 return ret;
2247 2247
2248 return cdo->tray_move(cdi, 1); 2248static int cdrom_ioctl_closetray(struct cdrom_device_info *cdi)
2249 } 2249{
2250 cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n");
2250 2251
2251 case CDROMCLOSETRAY: { 2252 if (!CDROM_CAN(CDC_CLOSE_TRAY))
2252 cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n"); 2253 return -ENOSYS;
2253 if (!CDROM_CAN(CDC_CLOSE_TRAY)) 2254 return cdi->ops->tray_move(cdi, 0);
2254 return -ENOSYS; 2255}
2255 return cdo->tray_move(cdi, 0);
2256 }
2257 2256
2258 case CDROMEJECT_SW: { 2257static int cdrom_ioctl_eject_sw(struct cdrom_device_info *cdi,
2259 cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n"); 2258 unsigned long arg)
2260 if (!CDROM_CAN(CDC_OPEN_TRAY)) 2259{
2261 return -ENOSYS; 2260 cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n");
2262 if (keeplocked)
2263 return -EBUSY;
2264 cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT);
2265 if (arg)
2266 cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT;
2267 return 0;
2268 }
2269 2261
2270 case CDROM_MEDIA_CHANGED: { 2262 if (!CDROM_CAN(CDC_OPEN_TRAY))
2271 struct cdrom_changer_info *info; 2263 return -ENOSYS;
2272 int changed; 2264 if (keeplocked)
2265 return -EBUSY;
2273 2266
2274 cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n"); 2267 cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT);
2275 if (!CDROM_CAN(CDC_MEDIA_CHANGED)) 2268 if (arg)
2276 return -ENOSYS; 2269 cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT;
2270 return 0;
2271}
2277 2272
2278 /* cannot select disc or select current disc */ 2273static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi,
2279 if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT) 2274 unsigned long arg)
2280 return media_changed(cdi, 1); 2275{
2276 struct cdrom_changer_info *info;
2277 int ret;
2281 2278
2282 if ((unsigned int)arg >= cdi->capacity) 2279 cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n");
2283 return -EINVAL;
2284 2280
2285 info = kmalloc(sizeof(*info), GFP_KERNEL); 2281 if (!CDROM_CAN(CDC_MEDIA_CHANGED))
2286 if (!info) 2282 return -ENOSYS;
2287 return -ENOMEM;
2288 2283
2289 if ((ret = cdrom_read_mech_status(cdi, info))) { 2284 /* cannot select disc or select current disc */
2290 kfree(info); 2285 if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT)
2291 return ret; 2286 return media_changed(cdi, 1);
2292 }
2293 2287
2294 changed = info->slots[arg].change; 2288 if ((unsigned int)arg >= cdi->capacity)
2295 kfree(info); 2289 return -EINVAL;
2296 return changed;
2297 }
2298 2290
2299 case CDROM_SET_OPTIONS: { 2291 info = kmalloc(sizeof(*info), GFP_KERNEL);
2300 cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n"); 2292 if (!info)
2301 /* options need to be in sync with capability. too late for 2293 return -ENOMEM;
2302 that, so we have to check each one separately... */
2303 switch (arg) {
2304 case CDO_USE_FFLAGS:
2305 case CDO_CHECK_TYPE:
2306 break;
2307 case CDO_LOCK:
2308 if (!CDROM_CAN(CDC_LOCK))
2309 return -ENOSYS;
2310 break;
2311 case 0:
2312 return cdi->options;
2313 /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */
2314 default:
2315 if (!CDROM_CAN(arg))
2316 return -ENOSYS;
2317 }
2318 cdi->options |= (int) arg;
2319 return cdi->options;
2320 }
2321 2294
2322 case CDROM_CLEAR_OPTIONS: { 2295 ret = cdrom_read_mech_status(cdi, info);
2323 cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n"); 2296 if (!ret)
2324 cdi->options &= ~(int) arg; 2297 ret = info->slots[arg].change;
2325 return cdi->options; 2298 kfree(info);
2326 } 2299 return ret;
2300}
2327 2301
2328 case CDROM_SELECT_SPEED: { 2302static int cdrom_ioctl_set_options(struct cdrom_device_info *cdi,
2329 cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n"); 2303 unsigned long arg)
2330 if (!CDROM_CAN(CDC_SELECT_SPEED)) 2304{
2331 return -ENOSYS; 2305 cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n");
2332 return cdo->select_speed(cdi, arg);
2333 }
2334 2306
2335 case CDROM_SELECT_DISC: { 2307 /*
2336 cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n"); 2308 * Options need to be in sync with capability.
2337 if (!CDROM_CAN(CDC_SELECT_DISC)) 2309 * Too late for that, so we have to check each one separately.
2310 */
2311 switch (arg) {
2312 case CDO_USE_FFLAGS:
2313 case CDO_CHECK_TYPE:
2314 break;
2315 case CDO_LOCK:
2316 if (!CDROM_CAN(CDC_LOCK))
2317 return -ENOSYS;
2318 break;
2319 case 0:
2320 return cdi->options;
2321 /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */
2322 default:
2323 if (!CDROM_CAN(arg))
2338 return -ENOSYS; 2324 return -ENOSYS;
2325 }
2326 cdi->options |= (int) arg;
2327 return cdi->options;
2328}
2339 2329
2340 if ((arg != CDSL_CURRENT) && (arg != CDSL_NONE)) 2330static int cdrom_ioctl_clear_options(struct cdrom_device_info *cdi,
2341 if ((int)arg >= cdi->capacity) 2331 unsigned long arg)
2342 return -EINVAL; 2332{
2343 2333 cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n");
2344 /* cdo->select_disc is a hook to allow a driver-specific
2345 * way of seleting disc. However, since there is no
2346 * equiv hook for cdrom_slot_status this may not
2347 * actually be useful...
2348 */
2349 if (cdo->select_disc != NULL)
2350 return cdo->select_disc(cdi, arg);
2351
2352 /* no driver specific select_disc(), call our own */
2353 cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n");
2354 return cdrom_select_disc(cdi, arg);
2355 }
2356 2334
2357 case CDROMRESET: { 2335 cdi->options &= ~(int) arg;
2358 if (!capable(CAP_SYS_ADMIN)) 2336 return cdi->options;
2359 return -EACCES; 2337}
2360 cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
2361 if (!CDROM_CAN(CDC_RESET))
2362 return -ENOSYS;
2363 invalidate_bdev(ip->i_bdev, 0);
2364 return cdo->reset(cdi);
2365 }
2366 2338
2367 case CDROM_LOCKDOOR: { 2339static int cdrom_ioctl_select_speed(struct cdrom_device_info *cdi,
2368 cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl"); 2340 unsigned long arg)
2369 if (!CDROM_CAN(CDC_LOCK)) 2341{
2370 return -EDRIVE_CANT_DO_THIS; 2342 cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n");
2371 keeplocked = arg ? 1 : 0;
2372 /* don't unlock the door on multiple opens,but allow root
2373 * to do so */
2374 if ((cdi->use_count != 1) && !arg && !capable(CAP_SYS_ADMIN))
2375 return -EBUSY;
2376 return cdo->lock_door(cdi, arg);
2377 }
2378 2343
2379 case CDROM_DEBUG: { 2344 if (!CDROM_CAN(CDC_SELECT_SPEED))
2380 if (!capable(CAP_SYS_ADMIN)) 2345 return -ENOSYS;
2381 return -EACCES; 2346 return cdi->ops->select_speed(cdi, arg);
2382 cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis"); 2347}
2383 debug = arg ? 1 : 0;
2384 return debug;
2385 }
2386 2348
2387 case CDROM_GET_CAPABILITY: { 2349static int cdrom_ioctl_select_disc(struct cdrom_device_info *cdi,
2388 cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n"); 2350 unsigned long arg)
2389 return (cdo->capability & ~cdi->mask); 2351{
2390 } 2352 cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n");
2353
2354 if (!CDROM_CAN(CDC_SELECT_DISC))
2355 return -ENOSYS;
2356
2357 if (arg != CDSL_CURRENT && arg != CDSL_NONE) {
2358 if ((int)arg >= cdi->capacity)
2359 return -EINVAL;
2360 }
2361
2362 /*
2363 * ->select_disc is a hook to allow a driver-specific way of
2364 * seleting disc. However, since there is no equivalent hook for
2365 * cdrom_slot_status this may not actually be useful...
2366 */
2367 if (cdi->ops->select_disc)
2368 return cdi->ops->select_disc(cdi, arg);
2369
2370 cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n");
2371 return cdrom_select_disc(cdi, arg);
2372}
2373
2374static int cdrom_ioctl_reset(struct cdrom_device_info *cdi,
2375 struct block_device *bdev)
2376{
2377 cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
2378
2379 if (!capable(CAP_SYS_ADMIN))
2380 return -EACCES;
2381 if (!CDROM_CAN(CDC_RESET))
2382 return -ENOSYS;
2383 invalidate_bdev(bdev, 0);
2384 return cdi->ops->reset(cdi);
2385}
2386
2387static int cdrom_ioctl_lock_door(struct cdrom_device_info *cdi,
2388 unsigned long arg)
2389{
2390 cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl");
2391
2392 if (!CDROM_CAN(CDC_LOCK))
2393 return -EDRIVE_CANT_DO_THIS;
2394
2395 keeplocked = arg ? 1 : 0;
2396
2397 /*
2398 * Don't unlock the door on multiple opens by default, but allow
2399 * root to do so.
2400 */
2401 if (cdi->use_count != 1 && !arg && !capable(CAP_SYS_ADMIN))
2402 return -EBUSY;
2403 return cdi->ops->lock_door(cdi, arg);
2404}
2405
2406static int cdrom_ioctl_debug(struct cdrom_device_info *cdi,
2407 unsigned long arg)
2408{
2409 cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis");
2410
2411 if (!capable(CAP_SYS_ADMIN))
2412 return -EACCES;
2413 debug = arg ? 1 : 0;
2414 return debug;
2415}
2391 2416
2392/* The following function is implemented, although very few audio 2417static int cdrom_ioctl_get_capability(struct cdrom_device_info *cdi)
2418{
2419 cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n");
2420 return (cdi->ops->capability & ~cdi->mask);
2421}
2422
2423/*
2424 * The following function is implemented, although very few audio
2393 * discs give Universal Product Code information, which should just be 2425 * discs give Universal Product Code information, which should just be
2394 * the Medium Catalog Number on the box. Note, that the way the code 2426 * the Medium Catalog Number on the box. Note, that the way the code
2395 * is written on the CD is /not/ uniform across all discs! 2427 * is written on the CD is /not/ uniform across all discs!
2396 */ 2428 */
2397 case CDROM_GET_MCN: { 2429static int cdrom_ioctl_get_mcn(struct cdrom_device_info *cdi,
2398 struct cdrom_mcn mcn; 2430 void __user *argp)
2399 cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n"); 2431{
2400 if (!(cdo->capability & CDC_MCN)) 2432 struct cdrom_mcn mcn;
2401 return -ENOSYS; 2433 int ret;
2402 if ((ret=cdo->get_mcn(cdi, &mcn)))
2403 return ret;
2404 IOCTL_OUT(arg, struct cdrom_mcn, mcn);
2405 cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n");
2406 return 0;
2407 }
2408 2434
2409 case CDROM_DRIVE_STATUS: { 2435 cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n");
2410 cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n");
2411 if (!(cdo->capability & CDC_DRIVE_STATUS))
2412 return -ENOSYS;
2413 if (!CDROM_CAN(CDC_SELECT_DISC))
2414 return cdo->drive_status(cdi, CDSL_CURRENT);
2415 if ((arg == CDSL_CURRENT) || (arg == CDSL_NONE))
2416 return cdo->drive_status(cdi, CDSL_CURRENT);
2417 if (((int)arg >= cdi->capacity))
2418 return -EINVAL;
2419 return cdrom_slot_status(cdi, arg);
2420 }
2421 2436
2422 /* Ok, this is where problems start. The current interface for the 2437 if (!(cdi->ops->capability & CDC_MCN))
2423 CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption 2438 return -ENOSYS;
2424 that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, 2439 ret = cdi->ops->get_mcn(cdi, &mcn);
2425 while this is often the case, it is also very common for CDs to 2440 if (ret)
2426 have some tracks with data, and some tracks with audio. Just 2441 return ret;
2427 because I feel like it, I declare the following to be the best
2428 way to cope. If the CD has ANY data tracks on it, it will be
2429 returned as a data CD. If it has any XA tracks, I will return
2430 it as that. Now I could simplify this interface by combining these
2431 returns with the above, but this more clearly demonstrates
2432 the problem with the current interface. Too bad this wasn't
2433 designed to use bitmasks... -Erik
2434
2435 Well, now we have the option CDS_MIXED: a mixed-type CD.
2436 User level programmers might feel the ioctl is not very useful.
2437 ---david
2438 */
2439 case CDROM_DISC_STATUS: {
2440 tracktype tracks;
2441 cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n");
2442 cdrom_count_tracks(cdi, &tracks);
2443 if (tracks.error)
2444 return(tracks.error);
2445
2446 /* Policy mode on */
2447 if (tracks.audio > 0) {
2448 if (tracks.data==0 && tracks.cdi==0 && tracks.xa==0)
2449 return CDS_AUDIO;
2450 else
2451 return CDS_MIXED;
2452 }
2453 if (tracks.cdi > 0) return CDS_XA_2_2;
2454 if (tracks.xa > 0) return CDS_XA_2_1;
2455 if (tracks.data > 0) return CDS_DATA_1;
2456 /* Policy mode off */
2457 2442
2458 cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n"); 2443 if (copy_to_user(argp, &mcn, sizeof(mcn)))
2459 return CDS_NO_INFO; 2444 return -EFAULT;
2460 } 2445 cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n");
2446 return 0;
2447}
2461 2448
2462 case CDROM_CHANGER_NSLOTS: { 2449static int cdrom_ioctl_drive_status(struct cdrom_device_info *cdi,
2463 cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n"); 2450 unsigned long arg)
2464 return cdi->capacity; 2451{
2465 } 2452 cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n");
2453
2454 if (!(cdi->ops->capability & CDC_DRIVE_STATUS))
2455 return -ENOSYS;
2456 if (!CDROM_CAN(CDC_SELECT_DISC) ||
2457 (arg == CDSL_CURRENT || arg == CDSL_NONE))
2458 return cdi->ops->drive_status(cdi, CDSL_CURRENT);
2459 if (((int)arg >= cdi->capacity))
2460 return -EINVAL;
2461 return cdrom_slot_status(cdi, arg);
2462}
2463
2464/*
2465 * Ok, this is where problems start. The current interface for the
2466 * CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption that
2467 * CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, while this
2468 * is often the case, it is also very common for CDs to have some tracks
2469 * with data, and some tracks with audio. Just because I feel like it,
2470 * I declare the following to be the best way to cope. If the CD has ANY
2471 * data tracks on it, it will be returned as a data CD. If it has any XA
2472 * tracks, I will return it as that. Now I could simplify this interface
2473 * by combining these returns with the above, but this more clearly
2474 * demonstrates the problem with the current interface. Too bad this
2475 * wasn't designed to use bitmasks... -Erik
2476 *
2477 * Well, now we have the option CDS_MIXED: a mixed-type CD.
2478 * User level programmers might feel the ioctl is not very useful.
2479 * ---david
2480 */
2481static int cdrom_ioctl_disc_status(struct cdrom_device_info *cdi)
2482{
2483 tracktype tracks;
2484
2485 cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n");
2486
2487 cdrom_count_tracks(cdi, &tracks);
2488 if (tracks.error)
2489 return tracks.error;
2490
2491 /* Policy mode on */
2492 if (tracks.audio > 0) {
2493 if (!tracks.data && !tracks.cdi && !tracks.xa)
2494 return CDS_AUDIO;
2495 else
2496 return CDS_MIXED;
2466 } 2497 }
2467 2498
2468 /* use the ioctls that are implemented through the generic_packet() 2499 if (tracks.cdi > 0)
2469 interface. this may look at bit funny, but if -ENOTTY is 2500 return CDS_XA_2_2;
2470 returned that particular ioctl is not implemented and we 2501 if (tracks.xa > 0)
2471 let it go through the device specific ones. */ 2502 return CDS_XA_2_1;
2503 if (tracks.data > 0)
2504 return CDS_DATA_1;
2505 /* Policy mode off */
2506
2507 cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n");
2508 return CDS_NO_INFO;
2509}
2510
2511static int cdrom_ioctl_changer_nslots(struct cdrom_device_info *cdi)
2512{
2513 cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n");
2514 return cdi->capacity;
2515}
2516
2517static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi,
2518 void __user *argp)
2519{
2520 struct cdrom_subchnl q;
2521 u8 requested, back;
2522 int ret;
2523
2524 /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/
2525
2526 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2527 return -ENOSYS;
2528 if (copy_from_user(&q, argp, sizeof(q)))
2529 return -EFAULT;
2530
2531 requested = q.cdsc_format;
2532 if (requested != CDROM_MSF && requested != CDROM_LBA)
2533 return -EINVAL;
2534 q.cdsc_format = CDROM_MSF;
2535
2536 ret = cdi->ops->audio_ioctl(cdi, CDROMSUBCHNL, &q);
2537 if (ret)
2538 return ret;
2539
2540 back = q.cdsc_format; /* local copy */
2541 sanitize_format(&q.cdsc_absaddr, &back, requested);
2542 sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested);
2543
2544 if (copy_to_user(argp, &q, sizeof(q)))
2545 return -EFAULT;
2546 /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */
2547 return 0;
2548}
2549
2550static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi,
2551 void __user *argp)
2552{
2553 struct cdrom_tochdr header;
2554 int ret;
2555
2556 /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */
2557
2558 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2559 return -ENOSYS;
2560 if (copy_from_user(&header, argp, sizeof(header)))
2561 return -EFAULT;
2562
2563 ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header);
2564 if (ret)
2565 return ret;
2566
2567 if (copy_to_user(argp, &header, sizeof(header)))
2568 return -EFAULT;
2569 /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */
2570 return 0;
2571}
2572
2573static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi,
2574 void __user *argp)
2575{
2576 struct cdrom_tocentry entry;
2577 u8 requested_format;
2578 int ret;
2579
2580 /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
2581
2582 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2583 return -ENOSYS;
2584 if (copy_from_user(&entry, argp, sizeof(entry)))
2585 return -EFAULT;
2586
2587 requested_format = entry.cdte_format;
2588 if (requested_format != CDROM_MSF && requested_format != CDROM_LBA)
2589 return -EINVAL;
2590 /* make interface to low-level uniform */
2591 entry.cdte_format = CDROM_MSF;
2592 ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &entry);
2593 if (ret)
2594 return ret;
2595 sanitize_format(&entry.cdte_addr, &entry.cdte_format, requested_format);
2596
2597 if (copy_to_user(argp, &entry, sizeof(entry)))
2598 return -EFAULT;
2599 /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */
2600 return 0;
2601}
2602
2603static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi,
2604 void __user *argp)
2605{
2606 struct cdrom_msf msf;
2607
2608 cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n");
2609
2610 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2611 return -ENOSYS;
2612 if (copy_from_user(&msf, argp, sizeof(msf)))
2613 return -EFAULT;
2614 return cdi->ops->audio_ioctl(cdi, CDROMPLAYMSF, &msf);
2615}
2616
2617static int cdrom_ioctl_play_trkind(struct cdrom_device_info *cdi,
2618 void __user *argp)
2619{
2620 struct cdrom_ti ti;
2621 int ret;
2622
2623 cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n");
2624
2625 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2626 return -ENOSYS;
2627 if (copy_from_user(&ti, argp, sizeof(ti)))
2628 return -EFAULT;
2629
2630 ret = check_for_audio_disc(cdi, cdi->ops);
2631 if (ret)
2632 return ret;
2633 return cdi->ops->audio_ioctl(cdi, CDROMPLAYTRKIND, &ti);
2634}
2635static int cdrom_ioctl_volctrl(struct cdrom_device_info *cdi,
2636 void __user *argp)
2637{
2638 struct cdrom_volctrl volume;
2639
2640 cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n");
2641
2642 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2643 return -ENOSYS;
2644 if (copy_from_user(&volume, argp, sizeof(volume)))
2645 return -EFAULT;
2646 return cdi->ops->audio_ioctl(cdi, CDROMVOLCTRL, &volume);
2647}
2648
2649static int cdrom_ioctl_volread(struct cdrom_device_info *cdi,
2650 void __user *argp)
2651{
2652 struct cdrom_volctrl volume;
2653 int ret;
2654
2655 cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n");
2656
2657 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2658 return -ENOSYS;
2659
2660 ret = cdi->ops->audio_ioctl(cdi, CDROMVOLREAD, &volume);
2661 if (ret)
2662 return ret;
2663
2664 if (copy_to_user(argp, &volume, sizeof(volume)))
2665 return -EFAULT;
2666 return 0;
2667}
2668
2669static int cdrom_ioctl_audioctl(struct cdrom_device_info *cdi,
2670 unsigned int cmd)
2671{
2672 int ret;
2673
2674 cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n");
2675
2676 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2677 return -ENOSYS;
2678 ret = check_for_audio_disc(cdi, cdi->ops);
2679 if (ret)
2680 return ret;
2681 return cdi->ops->audio_ioctl(cdi, cmd, NULL);
2682}
2683
2684/*
2685 * Just about every imaginable ioctl is supported in the Uniform layer
2686 * these days.
2687 * ATAPI / SCSI specific code now mainly resides in mmc_ioctl().
2688 */
2689int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
2690 struct inode *ip, unsigned int cmd, unsigned long arg)
2691{
2692 void __user *argp = (void __user *)arg;
2693 int ret;
2694
2695 /*
2696 * Try the generic SCSI command ioctl's first.
2697 */
2698 ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, argp);
2699 if (ret != -ENOTTY)
2700 return ret;
2701
2702 switch (cmd) {
2703 case CDROMMULTISESSION:
2704 return cdrom_ioctl_multisession(cdi, argp);
2705 case CDROMEJECT:
2706 return cdrom_ioctl_eject(cdi);
2707 case CDROMCLOSETRAY:
2708 return cdrom_ioctl_closetray(cdi);
2709 case CDROMEJECT_SW:
2710 return cdrom_ioctl_eject_sw(cdi, arg);
2711 case CDROM_MEDIA_CHANGED:
2712 return cdrom_ioctl_media_changed(cdi, arg);
2713 case CDROM_SET_OPTIONS:
2714 return cdrom_ioctl_set_options(cdi, arg);
2715 case CDROM_CLEAR_OPTIONS:
2716 return cdrom_ioctl_clear_options(cdi, arg);
2717 case CDROM_SELECT_SPEED:
2718 return cdrom_ioctl_select_speed(cdi, arg);
2719 case CDROM_SELECT_DISC:
2720 return cdrom_ioctl_select_disc(cdi, arg);
2721 case CDROMRESET:
2722 return cdrom_ioctl_reset(cdi, ip->i_bdev);
2723 case CDROM_LOCKDOOR:
2724 return cdrom_ioctl_lock_door(cdi, arg);
2725 case CDROM_DEBUG:
2726 return cdrom_ioctl_debug(cdi, arg);
2727 case CDROM_GET_CAPABILITY:
2728 return cdrom_ioctl_get_capability(cdi);
2729 case CDROM_GET_MCN:
2730 return cdrom_ioctl_get_mcn(cdi, argp);
2731 case CDROM_DRIVE_STATUS:
2732 return cdrom_ioctl_drive_status(cdi, arg);
2733 case CDROM_DISC_STATUS:
2734 return cdrom_ioctl_disc_status(cdi);
2735 case CDROM_CHANGER_NSLOTS:
2736 return cdrom_ioctl_changer_nslots(cdi);
2737 }
2738
2739 /*
2740 * Use the ioctls that are implemented through the generic_packet()
2741 * interface. this may look at bit funny, but if -ENOTTY is
2742 * returned that particular ioctl is not implemented and we
2743 * let it go through the device specific ones.
2744 */
2472 if (CDROM_CAN(CDC_GENERIC_PACKET)) { 2745 if (CDROM_CAN(CDC_GENERIC_PACKET)) {
2473 ret = mmc_ioctl(cdi, cmd, arg); 2746 ret = mmc_ioctl(cdi, cmd, arg);
2474 if (ret != -ENOTTY) { 2747 if (ret != -ENOTTY)
2475 return ret; 2748 return ret;
2476 }
2477 } 2749 }
2478 2750
2479 /* note: most of the cdinfo() calls are commented out here, 2751 /*
2480 because they fill up the sys log when CD players poll 2752 * Note: most of the cdinfo() calls are commented out here,
2481 the drive. */ 2753 * because they fill up the sys log when CD players poll
2754 * the drive.
2755 */
2482 switch (cmd) { 2756 switch (cmd) {
2483 case CDROMSUBCHNL: { 2757 case CDROMSUBCHNL:
2484 struct cdrom_subchnl q; 2758 return cdrom_ioctl_get_subchnl(cdi, argp);
2485 u_char requested, back; 2759 case CDROMREADTOCHDR:
2486 if (!CDROM_CAN(CDC_PLAY_AUDIO)) 2760 return cdrom_ioctl_read_tochdr(cdi, argp);
2487 return -ENOSYS; 2761 case CDROMREADTOCENTRY:
2488 /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/ 2762 return cdrom_ioctl_read_tocentry(cdi, argp);
2489 IOCTL_IN(arg, struct cdrom_subchnl, q); 2763 case CDROMPLAYMSF:
2490 requested = q.cdsc_format; 2764 return cdrom_ioctl_play_msf(cdi, argp);
2491 if (!((requested == CDROM_MSF) || 2765 case CDROMPLAYTRKIND:
2492 (requested == CDROM_LBA))) 2766 return cdrom_ioctl_play_trkind(cdi, argp);
2493 return -EINVAL; 2767 case CDROMVOLCTRL:
2494 q.cdsc_format = CDROM_MSF; 2768 return cdrom_ioctl_volctrl(cdi, argp);
2495 if ((ret=cdo->audio_ioctl(cdi, cmd, &q))) 2769 case CDROMVOLREAD:
2496 return ret; 2770 return cdrom_ioctl_volread(cdi, argp);
2497 back = q.cdsc_format; /* local copy */
2498 sanitize_format(&q.cdsc_absaddr, &back, requested);
2499 sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested);
2500 IOCTL_OUT(arg, struct cdrom_subchnl, q);
2501 /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */
2502 return 0;
2503 }
2504 case CDROMREADTOCHDR: {
2505 struct cdrom_tochdr header;
2506 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2507 return -ENOSYS;
2508 /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */
2509 IOCTL_IN(arg, struct cdrom_tochdr, header);
2510 if ((ret=cdo->audio_ioctl(cdi, cmd, &header)))
2511 return ret;
2512 IOCTL_OUT(arg, struct cdrom_tochdr, header);
2513 /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */
2514 return 0;
2515 }
2516 case CDROMREADTOCENTRY: {
2517 struct cdrom_tocentry entry;
2518 u_char requested_format;
2519 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2520 return -ENOSYS;
2521 /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
2522 IOCTL_IN(arg, struct cdrom_tocentry, entry);
2523 requested_format = entry.cdte_format;
2524 if (!((requested_format == CDROM_MSF) ||
2525 (requested_format == CDROM_LBA)))
2526 return -EINVAL;
2527 /* make interface to low-level uniform */
2528 entry.cdte_format = CDROM_MSF;
2529 if ((ret=cdo->audio_ioctl(cdi, cmd, &entry)))
2530 return ret;
2531 sanitize_format(&entry.cdte_addr,
2532 &entry.cdte_format, requested_format);
2533 IOCTL_OUT(arg, struct cdrom_tocentry, entry);
2534 /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */
2535 return 0;
2536 }
2537 case CDROMPLAYMSF: {
2538 struct cdrom_msf msf;
2539 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2540 return -ENOSYS;
2541 cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n");
2542 IOCTL_IN(arg, struct cdrom_msf, msf);
2543 return cdo->audio_ioctl(cdi, cmd, &msf);
2544 }
2545 case CDROMPLAYTRKIND: {
2546 struct cdrom_ti ti;
2547 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2548 return -ENOSYS;
2549 cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n");
2550 IOCTL_IN(arg, struct cdrom_ti, ti);
2551 CHECKAUDIO;
2552 return cdo->audio_ioctl(cdi, cmd, &ti);
2553 }
2554 case CDROMVOLCTRL: {
2555 struct cdrom_volctrl volume;
2556 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2557 return -ENOSYS;
2558 cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n");
2559 IOCTL_IN(arg, struct cdrom_volctrl, volume);
2560 return cdo->audio_ioctl(cdi, cmd, &volume);
2561 }
2562 case CDROMVOLREAD: {
2563 struct cdrom_volctrl volume;
2564 if (!CDROM_CAN(CDC_PLAY_AUDIO))
2565 return -ENOSYS;
2566 cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n");
2567 if ((ret=cdo->audio_ioctl(cdi, cmd, &volume)))
2568 return ret;
2569 IOCTL_OUT(arg, struct cdrom_volctrl, volume);
2570 return 0;
2571 }
2572 case CDROMSTART: 2771 case CDROMSTART:
2573 case CDROMSTOP: 2772 case CDROMSTOP:
2574 case CDROMPAUSE: 2773 case CDROMPAUSE:
2575 case CDROMRESUME: { 2774 case CDROMRESUME:
2576 if (!CDROM_CAN(CDC_PLAY_AUDIO)) 2775 return cdrom_ioctl_audioctl(cdi, cmd);
2577 return -ENOSYS; 2776 }
2578 cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n");
2579 CHECKAUDIO;
2580 return cdo->audio_ioctl(cdi, cmd, NULL);
2581 }
2582 } /* switch */
2583 2777
2584 /* do the device specific ioctls */
2585 if (CDROM_CAN(CDC_IOCTLS))
2586 return cdo->dev_ioctl(cdi, cmd, arg);
2587
2588 return -ENOSYS; 2778 return -ENOSYS;
2589} 2779}
2590 2780
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
index 378e88d20757..72ffd64e8b1e 100644
--- a/drivers/cdrom/cdu31a.c
+++ b/drivers/cdrom/cdu31a.c
@@ -2668,7 +2668,7 @@ static int scd_audio_ioctl(struct cdrom_device_info *cdi,
2668 return retval; 2668 return retval;
2669} 2669}
2670 2670
2671static int scd_dev_ioctl(struct cdrom_device_info *cdi, 2671static int scd_read_audio(struct cdrom_device_info *cdi,
2672 unsigned int cmd, unsigned long arg) 2672 unsigned int cmd, unsigned long arg)
2673{ 2673{
2674 void __user *argp = (void __user *)arg; 2674 void __user *argp = (void __user *)arg;
@@ -2894,11 +2894,10 @@ static struct cdrom_device_ops scd_dops = {
2894 .get_mcn = scd_get_mcn, 2894 .get_mcn = scd_get_mcn,
2895 .reset = scd_reset, 2895 .reset = scd_reset,
2896 .audio_ioctl = scd_audio_ioctl, 2896 .audio_ioctl = scd_audio_ioctl,
2897 .dev_ioctl = scd_dev_ioctl,
2898 .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | 2897 .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK |
2899 CDC_SELECT_SPEED | CDC_MULTI_SESSION | 2898 CDC_SELECT_SPEED | CDC_MULTI_SESSION |
2900 CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | 2899 CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO |
2901 CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS, 2900 CDC_RESET | CDC_DRIVE_STATUS,
2902 .n_minors = 1, 2901 .n_minors = 1,
2903}; 2902};
2904 2903
@@ -2936,6 +2935,9 @@ static int scd_block_ioctl(struct inode *inode, struct file *file,
2936 case CDROMCLOSETRAY: 2935 case CDROMCLOSETRAY:
2937 retval = scd_tray_move(&scd_info, 0); 2936 retval = scd_tray_move(&scd_info, 0);
2938 break; 2937 break;
2938 case CDROMREADAUDIO:
2939 retval = scd_read_audio(&scd_info, CDROMREADAUDIO, arg);
2940 break;
2939 default: 2941 default:
2940 retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg); 2942 retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg);
2941 } 2943 }
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
index ce127f7ec0f6..fad27a87ce35 100644
--- a/drivers/cdrom/cm206.c
+++ b/drivers/cdrom/cm206.c
@@ -1157,32 +1157,6 @@ static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
1157 } 1157 }
1158} 1158}
1159 1159
1160/* Ioctl. These ioctls are specific to the cm206 driver. I have made
1161 some driver statistics accessible through ioctl calls.
1162 */
1163
1164static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
1165 unsigned long arg)
1166{
1167 switch (cmd) {
1168#ifdef STATISTICS
1169 case CM206CTL_GET_STAT:
1170 if (arg >= NR_STATS)
1171 return -EINVAL;
1172 else
1173 return cd->stats[arg];
1174 case CM206CTL_GET_LAST_STAT:
1175 if (arg >= NR_STATS)
1176 return -EINVAL;
1177 else
1178 return cd->last_stat[arg];
1179#endif
1180 default:
1181 debug(("Unknown ioctl call 0x%x\n", cmd));
1182 return -EINVAL;
1183 }
1184}
1185
1186static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) 1160static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr)
1187{ 1161{
1188 if (cd != NULL) { 1162 if (cd != NULL) {
@@ -1321,11 +1295,10 @@ static struct cdrom_device_ops cm206_dops = {
1321 .get_mcn = cm206_get_upc, 1295 .get_mcn = cm206_get_upc,
1322 .reset = cm206_reset, 1296 .reset = cm206_reset,
1323 .audio_ioctl = cm206_audio_ioctl, 1297 .audio_ioctl = cm206_audio_ioctl,
1324 .dev_ioctl = cm206_ioctl,
1325 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | 1298 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
1326 CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | 1299 CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
1327 CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED | 1300 CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED |
1328 CDC_IOCTLS | CDC_DRIVE_STATUS, 1301 CDC_DRIVE_STATUS,
1329 .n_minors = 1, 1302 .n_minors = 1,
1330}; 1303};
1331 1304
@@ -1350,6 +1323,21 @@ static int cm206_block_release(struct inode *inode, struct file *file)
1350static int cm206_block_ioctl(struct inode *inode, struct file *file, 1323static int cm206_block_ioctl(struct inode *inode, struct file *file,
1351 unsigned cmd, unsigned long arg) 1324 unsigned cmd, unsigned long arg)
1352{ 1325{
1326 switch (cmd) {
1327#ifdef STATISTICS
1328 case CM206CTL_GET_STAT:
1329 if (arg >= NR_STATS)
1330 return -EINVAL;
1331 return cd->stats[arg];
1332 case CM206CTL_GET_LAST_STAT:
1333 if (arg >= NR_STATS)
1334 return -EINVAL;
1335 return cd->last_stat[arg];
1336#endif
1337 default:
1338 break;
1339 }
1340
1353 return cdrom_ioctl(file, &cm206_info, inode, cmd, arg); 1341 return cdrom_ioctl(file, &cm206_info, inode, cmd, arg);
1354} 1342}
1355 1343
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index 466e9c2974bd..4760f515f591 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -4160,332 +4160,6 @@ static int sbpcd_get_last_session(struct cdrom_device_info *cdi, struct cdrom_mu
4160 return 0; 4160 return 0;
4161} 4161}
4162 4162
4163/*==========================================================================*/
4164/*==========================================================================*/
4165/*
4166 * ioctl support
4167 */
4168static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4169 u_long arg)
4170{
4171 struct sbpcd_drive *p = cdi->handle;
4172 int i;
4173
4174 msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg);
4175 if (p->drv_id==-1) {
4176 msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name);
4177 return (-ENXIO); /* no such drive */
4178 }
4179 down(&ioctl_read_sem);
4180 if (p != current_drive)
4181 switch_drive(p);
4182
4183 msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd);
4184 switch (cmd) /* Sun-compatible */
4185 {
4186 case DDIOCSDBG: /* DDI Debug */
4187 if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM);
4188 i=sbpcd_dbg_ioctl(arg,1);
4189 RETURN_UP(i);
4190 case CDROMRESET: /* hard reset the drive */
4191 msg(DBG_IOC,"ioctl: CDROMRESET entered.\n");
4192 i=DriveReset();
4193 current_drive->audio_state=0;
4194 RETURN_UP(i);
4195
4196 case CDROMREADMODE1:
4197 msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n");
4198#ifdef SAFE_MIXED
4199 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
4200#endif /* SAFE_MIXED */
4201 cc_ModeSelect(CD_FRAMESIZE);
4202 cc_ModeSense();
4203 current_drive->mode=READ_M1;
4204 RETURN_UP(0);
4205
4206 case CDROMREADMODE2: /* not usable at the moment */
4207 msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n");
4208#ifdef SAFE_MIXED
4209 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
4210#endif /* SAFE_MIXED */
4211 cc_ModeSelect(CD_FRAMESIZE_RAW1);
4212 cc_ModeSense();
4213 current_drive->mode=READ_M2;
4214 RETURN_UP(0);
4215
4216 case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */
4217 msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n");
4218 if (current_drive->sbp_audsiz>0)
4219 vfree(current_drive->aud_buf);
4220 current_drive->aud_buf=NULL;
4221 current_drive->sbp_audsiz=arg;
4222
4223 if (current_drive->sbp_audsiz>16)
4224 {
4225 current_drive->sbp_audsiz = 0;
4226 RETURN_UP(current_drive->sbp_audsiz);
4227 }
4228
4229 if (current_drive->sbp_audsiz>0)
4230 {
4231 current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW);
4232 if (current_drive->aud_buf==NULL)
4233 {
4234 msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz);
4235 current_drive->sbp_audsiz=0;
4236 }
4237 else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz);
4238 }
4239 RETURN_UP(current_drive->sbp_audsiz);
4240
4241 case CDROMREADAUDIO:
4242 { /* start of CDROMREADAUDIO */
4243 int i=0, j=0, frame, block=0;
4244 u_int try=0;
4245 u_long timeout;
4246 u_char *p;
4247 u_int data_tries = 0;
4248 u_int data_waits = 0;
4249 u_int data_retrying = 0;
4250 int status_tries;
4251 int error_flag;
4252
4253 msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n");
4254 if (fam0_drive) RETURN_UP(-EINVAL);
4255 if (famL_drive) RETURN_UP(-EINVAL);
4256 if (famV_drive) RETURN_UP(-EINVAL);
4257 if (famT_drive) RETURN_UP(-EINVAL);
4258#ifdef SAFE_MIXED
4259 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
4260#endif /* SAFE_MIXED */
4261 if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL);
4262 if (copy_from_user(&read_audio, (void __user *)arg,
4263 sizeof(struct cdrom_read_audio)))
4264 RETURN_UP(-EFAULT);
4265 if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL);
4266 if (!access_ok(VERIFY_WRITE, read_audio.buf,
4267 read_audio.nframes*CD_FRAMESIZE_RAW))
4268 RETURN_UP(-EFAULT);
4269
4270 if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */
4271 block=msf2lba(&read_audio.addr.msf.minute);
4272 else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */
4273 block=read_audio.addr.lba;
4274 else RETURN_UP(-EINVAL);
4275#if 000
4276 i=cc_SetSpeed(speed_150,0,0);
4277 if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i);
4278#endif
4279 msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n",
4280 block, blk2msf(block));
4281 msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n");
4282#if OLD_BUSY
4283 while (busy_data) sbp_sleep(HZ/10); /* wait a bit */
4284 busy_audio=1;
4285#endif /* OLD_BUSY */
4286 error_flag=0;
4287 for (data_tries=5; data_tries>0; data_tries--)
4288 {
4289 msg(DBG_AUD,"data_tries=%d ...\n", data_tries);
4290 current_drive->mode=READ_AU;
4291 cc_ModeSelect(CD_FRAMESIZE_RAW);
4292 cc_ModeSense();
4293 for (status_tries=3; status_tries > 0; status_tries--)
4294 {
4295 flags_cmd_out |= f_respo3;
4296 cc_ReadStatus();
4297 if (sbp_status() != 0) break;
4298 if (st_check) cc_ReadError();
4299 sbp_sleep(1); /* wait a bit, try again */
4300 }
4301 if (status_tries == 0)
4302 {
4303 msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__);
4304 continue;
4305 }
4306 msg(DBG_AUD,"read_audio: sbp_status: ok.\n");
4307
4308 flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
4309 if (fam0L_drive)
4310 {
4311 flags_cmd_out |= f_lopsta | f_getsta | f_bit1;
4312 cmd_type=READ_M2;
4313 drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */
4314 drvcmd[1]=(block>>16)&0x000000ff;
4315 drvcmd[2]=(block>>8)&0x000000ff;
4316 drvcmd[3]=block&0x000000ff;
4317 drvcmd[4]=0;
4318 drvcmd[5]=read_audio.nframes; /* # of frames */
4319 drvcmd[6]=0;
4320 }
4321 else if (fam1_drive)
4322 {
4323 drvcmd[0]=CMD1_READ; /* "read frames", new drives */
4324 lba2msf(block,&drvcmd[1]); /* msf-bin format required */
4325 drvcmd[4]=0;
4326 drvcmd[5]=0;
4327 drvcmd[6]=read_audio.nframes; /* # of frames */
4328 }
4329 else if (fam2_drive)
4330 {
4331 drvcmd[0]=CMD2_READ_XA2;
4332 lba2msf(block,&drvcmd[1]); /* msf-bin format required */
4333 drvcmd[4]=0;
4334 drvcmd[5]=read_audio.nframes; /* # of frames */
4335 drvcmd[6]=0x11; /* raw mode */
4336 }
4337 else if (famT_drive) /* CD-55A: not tested yet */
4338 {
4339 }
4340 msg(DBG_AUD,"read_audio: before giving \"read\" command.\n");
4341 flags_cmd_out=f_putcmd;
4342 response_count=0;
4343 i=cmd_out();
4344 if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i);
4345 sbp_sleep(0);
4346 msg(DBG_AUD,"read_audio: after giving \"read\" command.\n");
4347 for (frame=1;frame<2 && !error_flag; frame++)
4348 {
4349 try=maxtim_data;
4350 for (timeout=jiffies+9*HZ; ; )
4351 {
4352 for ( ; try!=0;try--)
4353 {
4354 j=inb(CDi_status);
4355 if (!(j&s_not_data_ready)) break;
4356 if (!(j&s_not_result_ready)) break;
4357 if (fam0L_drive) if (j&s_attention) break;
4358 }
4359 if (try != 0 || time_after_eq(jiffies, timeout)) break;
4360 if (data_retrying == 0) data_waits++;
4361 data_retrying = 1;
4362 sbp_sleep(1);
4363 try = 1;
4364 }
4365 if (try==0)
4366 {
4367 msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n");
4368 error_flag++;
4369 break;
4370 }
4371 msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n");
4372 if (j&s_not_data_ready)
4373 {
4374 msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n");
4375 error_flag++;
4376 break;
4377 }
4378 msg(DBG_AUD,"read_audio: before reading data.\n");
4379 error_flag=0;
4380 p = current_drive->aud_buf;
4381 if (sbpro_type==1) OUT(CDo_sel_i_d,1);
4382 if (do_16bit)
4383 {
4384 u_short *p2 = (u_short *) p;
4385
4386 for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
4387 {
4388 if ((inb_p(CDi_status)&s_not_data_ready)) continue;
4389
4390 /* get one sample */
4391 *p2++ = inw_p(CDi_data);
4392 *p2++ = inw_p(CDi_data);
4393 }
4394 } else {
4395 for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
4396 {
4397 if ((inb_p(CDi_status)&s_not_data_ready)) continue;
4398
4399 /* get one sample */
4400 *p++ = inb_p(CDi_data);
4401 *p++ = inb_p(CDi_data);
4402 *p++ = inb_p(CDi_data);
4403 *p++ = inb_p(CDi_data);
4404 }
4405 }
4406 if (sbpro_type==1) OUT(CDo_sel_i_d,0);
4407 data_retrying = 0;
4408 }
4409 msg(DBG_AUD,"read_audio: after reading data.\n");
4410 if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */
4411 {
4412 msg(DBG_AUD,"read_audio: read aborted by drive\n");
4413#if 0000
4414 i=cc_DriveReset(); /* ugly fix to prevent a hang */
4415#else
4416 i=cc_ReadError();
4417#endif
4418 continue;
4419 }
4420 if (fam0L_drive)
4421 {
4422 i=maxtim_data;
4423 for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--)
4424 {
4425 for ( ;i!=0;i--)
4426 {
4427 j=inb(CDi_status);
4428 if (!(j&s_not_data_ready)) break;
4429 if (!(j&s_not_result_ready)) break;
4430 if (j&s_attention) break;
4431 }
4432 if (i != 0 || time_after_eq(jiffies, timeout)) break;
4433 sbp_sleep(0);
4434 i = 1;
4435 }
4436 if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ");
4437 if (!(j&s_attention))
4438 {
4439 msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n");
4440 i=cc_DriveReset(); /* ugly fix to prevent a hang */
4441 continue;
4442 }
4443 }
4444 do
4445 {
4446 if (fam0L_drive) cc_ReadStatus();
4447 i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */
4448 if (i<0) { msg(DBG_AUD,
4449 "read_audio: cc_ReadStatus error after read: %02X\n",
4450 current_drive->status_bits);
4451 continue; /* FIXME */
4452 }
4453 }
4454 while ((fam0L_drive)&&(!st_check)&&(!(i&p_success)));
4455 if (st_check)
4456 {
4457 i=cc_ReadError();
4458 msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i);
4459 continue;
4460 }
4461 if (copy_to_user(read_audio.buf,
4462 current_drive->aud_buf,
4463 read_audio.nframes * CD_FRAMESIZE_RAW))
4464 RETURN_UP(-EFAULT);
4465 msg(DBG_AUD,"read_audio: copy_to_user done.\n");
4466 break;
4467 }
4468 cc_ModeSelect(CD_FRAMESIZE);
4469 cc_ModeSense();
4470 current_drive->mode=READ_M1;
4471#if OLD_BUSY
4472 busy_audio=0;
4473#endif /* OLD_BUSY */
4474 if (data_tries == 0)
4475 {
4476 msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__);
4477 RETURN_UP(-EIO);
4478 }
4479 msg(DBG_AUD,"read_audio: successful return.\n");
4480 RETURN_UP(0);
4481 } /* end of CDROMREADAUDIO */
4482
4483 default:
4484 msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
4485 RETURN_UP(-EINVAL);
4486 } /* end switch(cmd) */
4487}
4488
4489static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, 4163static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4490 void * arg) 4164 void * arg)
4491{ 4165{
@@ -4530,7 +4204,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4530 default: 4204 default:
4531 RETURN_UP(-EINVAL); 4205 RETURN_UP(-EINVAL);
4532 } 4206 }
4533 4207
4534 case CDROMRESUME: /* resume paused audio play */ 4208 case CDROMRESUME: /* resume paused audio play */
4535 msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n"); 4209 msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n");
4536 /* resume playing audio tracks when a previous PLAY AUDIO call has */ 4210 /* resume playing audio tracks when a previous PLAY AUDIO call has */
@@ -4544,12 +4218,12 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4544 if (i<0) RETURN_UP(-EIO); 4218 if (i<0) RETURN_UP(-EIO);
4545 current_drive->audio_state=audio_playing; 4219 current_drive->audio_state=audio_playing;
4546 RETURN_UP(0); 4220 RETURN_UP(0);
4547 4221
4548 case CDROMPLAYMSF: 4222 case CDROMPLAYMSF:
4549 msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n"); 4223 msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n");
4550#ifdef SAFE_MIXED 4224#ifdef SAFE_MIXED
4551 if (current_drive->has_data>1) RETURN_UP(-EBUSY); 4225 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
4552#endif /* SAFE_MIXED */ 4226#endif /* SAFE_MIXED */
4553 if (current_drive->audio_state==audio_playing) 4227 if (current_drive->audio_state==audio_playing)
4554 { 4228 {
4555 i=cc_Pause_Resume(1); 4229 i=cc_Pause_Resume(1);
@@ -4584,7 +4258,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4584 msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n"); 4258 msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n");
4585#ifdef SAFE_MIXED 4259#ifdef SAFE_MIXED
4586 if (current_drive->has_data>1) RETURN_UP(-EBUSY); 4260 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
4587#endif /* SAFE_MIXED */ 4261#endif /* SAFE_MIXED */
4588 if (current_drive->audio_state==audio_playing) 4262 if (current_drive->audio_state==audio_playing)
4589 { 4263 {
4590 msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n"); 4264 msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n");
@@ -4654,13 +4328,13 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4654 cc_DriveReset(); 4328 cc_DriveReset();
4655#endif 4329#endif
4656 RETURN_UP(i); 4330 RETURN_UP(i);
4657 4331
4658 case CDROMSTART: /* Spin up the drive */ 4332 case CDROMSTART: /* Spin up the drive */
4659 msg(DBG_IOC,"ioctl: CDROMSTART entered.\n"); 4333 msg(DBG_IOC,"ioctl: CDROMSTART entered.\n");
4660 cc_SpinUp(); 4334 cc_SpinUp();
4661 current_drive->audio_state=0; 4335 current_drive->audio_state=0;
4662 RETURN_UP(0); 4336 RETURN_UP(0);
4663 4337
4664 case CDROMVOLCTRL: /* Volume control */ 4338 case CDROMVOLCTRL: /* Volume control */
4665 msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n"); 4339 msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n");
4666 memcpy(&volctrl,(char *) arg,sizeof(volctrl)); 4340 memcpy(&volctrl,(char *) arg,sizeof(volctrl));
@@ -4670,7 +4344,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4670 current_drive->vol_ctrl1=volctrl.channel1; 4344 current_drive->vol_ctrl1=volctrl.channel1;
4671 i=cc_SetVolume(); 4345 i=cc_SetVolume();
4672 RETURN_UP(0); 4346 RETURN_UP(0);
4673 4347
4674 case CDROMVOLREAD: /* read Volume settings from drive */ 4348 case CDROMVOLREAD: /* read Volume settings from drive */
4675 msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n"); 4349 msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n");
4676 st=cc_GetVolume(); 4350 st=cc_GetVolume();
@@ -4694,7 +4368,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4694 if (i<0) { 4368 if (i<0) {
4695 j=cc_ReadError(); /* clear out error status from drive */ 4369 j=cc_ReadError(); /* clear out error status from drive */
4696 current_drive->audio_state=CDROM_AUDIO_NO_STATUS; 4370 current_drive->audio_state=CDROM_AUDIO_NO_STATUS;
4697 /* get and set the disk state here, 4371 /* get and set the disk state here,
4698 probably not the right place, but who cares! 4372 probably not the right place, but who cares!
4699 It makes it work properly! --AJK */ 4373 It makes it work properly! --AJK */
4700 if (current_drive->CD_changed==0xFF) { 4374 if (current_drive->CD_changed==0xFF) {
@@ -4715,8 +4389,8 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4715 } 4389 }
4716 } 4390 }
4717 memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl)); 4391 memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl));
4718 /* 4392 /*
4719 This virtual crap is very bogus! 4393 This virtual crap is very bogus!
4720 It doesn't detect when the cd is done playing audio! 4394 It doesn't detect when the cd is done playing audio!
4721 Lets do this right with proper hardware register reading! 4395 Lets do this right with proper hardware register reading!
4722 */ 4396 */
@@ -4775,7 +4449,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4775 SC.cdsc_trk,SC.cdsc_ind, 4449 SC.cdsc_trk,SC.cdsc_ind,
4776 SC.cdsc_absaddr,SC.cdsc_reladdr); 4450 SC.cdsc_absaddr,SC.cdsc_reladdr);
4777 RETURN_UP(0); 4451 RETURN_UP(0);
4778 4452
4779 default: 4453 default:
4780 msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); 4454 msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
4781 RETURN_UP(-EINVAL); 4455 RETURN_UP(-EINVAL);
@@ -4788,7 +4462,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4788static void sbp_transfer(struct request *req) 4462static void sbp_transfer(struct request *req)
4789{ 4463{
4790 long offs; 4464 long offs;
4791 4465
4792 while ( (req->nr_sectors > 0) && 4466 while ( (req->nr_sectors > 0) &&
4793 (req->sector/4 >= current_drive->sbp_first_frame) && 4467 (req->sector/4 >= current_drive->sbp_first_frame) &&
4794 (req->sector/4 <= current_drive->sbp_last_frame) ) 4468 (req->sector/4 <= current_drive->sbp_last_frame) )
@@ -4807,11 +4481,11 @@ static void sbp_transfer(struct request *req)
4807 * 4481 *
4808 * This is a kludge so we don't need to modify end_request. 4482 * This is a kludge so we don't need to modify end_request.
4809 * We put the req we take out after INIT_REQUEST in the requests list, 4483 * We put the req we take out after INIT_REQUEST in the requests list,
4810 * so that end_request will discard it. 4484 * so that end_request will discard it.
4811 * 4485 *
4812 * The bug could be present in other block devices, perhaps we 4486 * The bug could be present in other block devices, perhaps we
4813 * should modify INIT_REQUEST and end_request instead, and 4487 * should modify INIT_REQUEST and end_request instead, and
4814 * change every block device.. 4488 * change every block device..
4815 * 4489 *
4816 * Could be a race here?? Could e.g. a timer interrupt schedule() us? 4490 * Could be a race here?? Could e.g. a timer interrupt schedule() us?
4817 * If so, we should copy end_request here, and do it right.. (or 4491 * If so, we should copy end_request here, and do it right.. (or
@@ -4883,19 +4557,19 @@ static void do_sbpcd_request(request_queue_t * q)
4883 while (busy_audio) sbp_sleep(HZ); /* wait a bit */ 4557 while (busy_audio) sbp_sleep(HZ); /* wait a bit */
4884 busy_data=1; 4558 busy_data=1;
4885#endif /* OLD_BUSY */ 4559#endif /* OLD_BUSY */
4886 4560
4887 if (p->audio_state==audio_playing) goto err_done; 4561 if (p->audio_state==audio_playing) goto err_done;
4888 if (p != current_drive) 4562 if (p != current_drive)
4889 switch_drive(p); 4563 switch_drive(p);
4890 4564
4891 block = req->sector; /* always numbered as 512-byte-pieces */ 4565 block = req->sector; /* always numbered as 512-byte-pieces */
4892 nsect = req->nr_sectors; /* always counted as 512-byte-pieces */ 4566 nsect = req->nr_sectors; /* always counted as 512-byte-pieces */
4893 4567
4894 msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect); 4568 msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect);
4895#if 0 4569#if 0
4896 msg(DBG_MUL,"read LBA %d\n", block/4); 4570 msg(DBG_MUL,"read LBA %d\n", block/4);
4897#endif 4571#endif
4898 4572
4899 sbp_transfer(req); 4573 sbp_transfer(req);
4900 /* if we satisfied the request from the buffer, we're done. */ 4574 /* if we satisfied the request from the buffer, we're done. */
4901 if (req->nr_sectors == 0) 4575 if (req->nr_sectors == 0)
@@ -4914,10 +4588,10 @@ static void do_sbpcd_request(request_queue_t * q)
4914 i=prepare(0,0); /* at moment not really a hassle check, but ... */ 4588 i=prepare(0,0); /* at moment not really a hassle check, but ... */
4915 if (i!=0) 4589 if (i!=0)
4916 msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i); 4590 msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i);
4917#endif /* FUTURE */ 4591#endif /* FUTURE */
4918 4592
4919 if (!st_spinning) cc_SpinUp(); 4593 if (!st_spinning) cc_SpinUp();
4920 4594
4921 for (data_tries=n_retries; data_tries > 0; data_tries--) 4595 for (data_tries=n_retries; data_tries > 0; data_tries--)
4922 { 4596 {
4923 for (status_tries=3; status_tries > 0; status_tries--) 4597 for (status_tries=3; status_tries > 0; status_tries--)
@@ -4940,7 +4614,7 @@ static void do_sbpcd_request(request_queue_t * q)
4940 { 4614 {
4941#ifdef SAFE_MIXED 4615#ifdef SAFE_MIXED
4942 current_drive->has_data=2; /* is really a data disk */ 4616 current_drive->has_data=2; /* is really a data disk */
4943#endif /* SAFE_MIXED */ 4617#endif /* SAFE_MIXED */
4944#ifdef DEBUG_GTL 4618#ifdef DEBUG_GTL
4945 printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n", 4619 printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n",
4946 xnr, req, req->sector, req->nr_sectors, jiffies); 4620 xnr, req, req->sector, req->nr_sectors, jiffies);
@@ -4951,7 +4625,7 @@ static void do_sbpcd_request(request_queue_t * q)
4951 goto request_loop; 4625 goto request_loop;
4952 } 4626 }
4953 } 4627 }
4954 4628
4955 err_done: 4629 err_done:
4956#if OLD_BUSY 4630#if OLD_BUSY
4957 busy_data=0; 4631 busy_data=0;
@@ -4976,7 +4650,7 @@ static void sbp_read_cmd(struct request *req)
4976 4650
4977 int i; 4651 int i;
4978 int block; 4652 int block;
4979 4653
4980 current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */ 4654 current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */
4981 current_drive->sbp_current = 0; 4655 current_drive->sbp_current = 0;
4982 block=req->sector/4; 4656 block=req->sector/4;
@@ -4993,7 +4667,7 @@ static void sbp_read_cmd(struct request *req)
4993 current_drive->sbp_read_frames=1; 4667 current_drive->sbp_read_frames=1;
4994 } 4668 }
4995 } 4669 }
4996 4670
4997 flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; 4671 flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
4998 clr_cmdbuf(); 4672 clr_cmdbuf();
4999 if (famV_drive) 4673 if (famV_drive)
@@ -5092,7 +4766,7 @@ static int sbp_data(struct request *req)
5092 int success; 4766 int success;
5093 int wait; 4767 int wait;
5094 int duration; 4768 int duration;
5095 4769
5096 error_flag=0; 4770 error_flag=0;
5097 success=0; 4771 success=0;
5098#if LONG_TIMING 4772#if LONG_TIMING
@@ -5105,12 +4779,12 @@ static int sbp_data(struct request *req)
5105 for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++) 4779 for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++)
5106 { 4780 {
5107 SBPCD_CLI; 4781 SBPCD_CLI;
5108 4782
5109 del_timer(&data_timer); 4783 del_timer(&data_timer);
5110 data_timer.expires=jiffies+max_latency; 4784 data_timer.expires=jiffies+max_latency;
5111 timed_out_data=0; 4785 timed_out_data=0;
5112 add_timer(&data_timer); 4786 add_timer(&data_timer);
5113 while (!timed_out_data) 4787 while (!timed_out_data)
5114 { 4788 {
5115 if (current_drive->f_multisession) try=maxtim_data*4; 4789 if (current_drive->f_multisession) try=maxtim_data*4;
5116 else try=maxtim_data; 4790 else try=maxtim_data;
@@ -5207,9 +4881,9 @@ static int sbp_data(struct request *req)
5207 else 4881 else
5208 { 4882 {
5209 sbp_sleep(1); 4883 sbp_sleep(1);
5210 OUT(CDo_sel_i_d,0); 4884 OUT(CDo_sel_i_d,0);
5211 i=inb(CDi_status); 4885 i=inb(CDi_status);
5212 } 4886 }
5213 if (!(i&s_not_data_ready)) 4887 if (!(i&s_not_data_ready))
5214 { 4888 {
5215 OUT(CDo_sel_i_d,1); 4889 OUT(CDo_sel_i_d,1);
@@ -5311,7 +4985,7 @@ static int sbp_data(struct request *req)
5311 } 4985 }
5312 SBPCD_STI; 4986 SBPCD_STI;
5313 } 4987 }
5314 4988
5315#if 0 4989#if 0
5316 if (!success) 4990 if (!success)
5317#endif 4991#endif
@@ -5370,7 +5044,326 @@ static int sbpcd_block_ioctl(struct inode *inode, struct file *file,
5370 unsigned cmd, unsigned long arg) 5044 unsigned cmd, unsigned long arg)
5371{ 5045{
5372 struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data; 5046 struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
5373 return cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg); 5047 struct cdrom_device_info *cdi = p->sbpcd_infop;
5048 int ret, i;
5049
5050 ret = cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg);
5051 if (ret != -ENOSYS)
5052 return ret;
5053
5054 msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg);
5055 if (p->drv_id==-1) {
5056 msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name);
5057 return (-ENXIO); /* no such drive */
5058 }
5059 down(&ioctl_read_sem);
5060 if (p != current_drive)
5061 switch_drive(p);
5062
5063 msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd);
5064 switch (cmd) /* Sun-compatible */
5065 {
5066 case DDIOCSDBG: /* DDI Debug */
5067 if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM);
5068 i=sbpcd_dbg_ioctl(arg,1);
5069 RETURN_UP(i);
5070 case CDROMRESET: /* hard reset the drive */
5071 msg(DBG_IOC,"ioctl: CDROMRESET entered.\n");
5072 i=DriveReset();
5073 current_drive->audio_state=0;
5074 RETURN_UP(i);
5075
5076 case CDROMREADMODE1:
5077 msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n");
5078#ifdef SAFE_MIXED
5079 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
5080#endif /* SAFE_MIXED */
5081 cc_ModeSelect(CD_FRAMESIZE);
5082 cc_ModeSense();
5083 current_drive->mode=READ_M1;
5084 RETURN_UP(0);
5085
5086 case CDROMREADMODE2: /* not usable at the moment */
5087 msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n");
5088#ifdef SAFE_MIXED
5089 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
5090#endif /* SAFE_MIXED */
5091 cc_ModeSelect(CD_FRAMESIZE_RAW1);
5092 cc_ModeSense();
5093 current_drive->mode=READ_M2;
5094 RETURN_UP(0);
5095
5096 case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */
5097 msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n");
5098 if (current_drive->sbp_audsiz>0)
5099 vfree(current_drive->aud_buf);
5100 current_drive->aud_buf=NULL;
5101 current_drive->sbp_audsiz=arg;
5102
5103 if (current_drive->sbp_audsiz>16)
5104 {
5105 current_drive->sbp_audsiz = 0;
5106 RETURN_UP(current_drive->sbp_audsiz);
5107 }
5108
5109 if (current_drive->sbp_audsiz>0)
5110 {
5111 current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW);
5112 if (current_drive->aud_buf==NULL)
5113 {
5114 msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz);
5115 current_drive->sbp_audsiz=0;
5116 }
5117 else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz);
5118 }
5119 RETURN_UP(current_drive->sbp_audsiz);
5120
5121 case CDROMREADAUDIO:
5122 { /* start of CDROMREADAUDIO */
5123 int i=0, j=0, frame, block=0;
5124 u_int try=0;
5125 u_long timeout;
5126 u_char *p;
5127 u_int data_tries = 0;
5128 u_int data_waits = 0;
5129 u_int data_retrying = 0;
5130 int status_tries;
5131 int error_flag;
5132
5133 msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n");
5134 if (fam0_drive) RETURN_UP(-EINVAL);
5135 if (famL_drive) RETURN_UP(-EINVAL);
5136 if (famV_drive) RETURN_UP(-EINVAL);
5137 if (famT_drive) RETURN_UP(-EINVAL);
5138#ifdef SAFE_MIXED
5139 if (current_drive->has_data>1) RETURN_UP(-EBUSY);
5140#endif /* SAFE_MIXED */
5141 if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL);
5142 if (copy_from_user(&read_audio, (void __user *)arg,
5143 sizeof(struct cdrom_read_audio)))
5144 RETURN_UP(-EFAULT);
5145 if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL);
5146 if (!access_ok(VERIFY_WRITE, read_audio.buf,
5147 read_audio.nframes*CD_FRAMESIZE_RAW))
5148 RETURN_UP(-EFAULT);
5149
5150 if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */
5151 block=msf2lba(&read_audio.addr.msf.minute);
5152 else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */
5153 block=read_audio.addr.lba;
5154 else RETURN_UP(-EINVAL);
5155#if 000
5156 i=cc_SetSpeed(speed_150,0,0);
5157 if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i);
5158#endif
5159 msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n",
5160 block, blk2msf(block));
5161 msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n");
5162#if OLD_BUSY
5163 while (busy_data) sbp_sleep(HZ/10); /* wait a bit */
5164 busy_audio=1;
5165#endif /* OLD_BUSY */
5166 error_flag=0;
5167 for (data_tries=5; data_tries>0; data_tries--)
5168 {
5169 msg(DBG_AUD,"data_tries=%d ...\n", data_tries);
5170 current_drive->mode=READ_AU;
5171 cc_ModeSelect(CD_FRAMESIZE_RAW);
5172 cc_ModeSense();
5173 for (status_tries=3; status_tries > 0; status_tries--)
5174 {
5175 flags_cmd_out |= f_respo3;
5176 cc_ReadStatus();
5177 if (sbp_status() != 0) break;
5178 if (st_check) cc_ReadError();
5179 sbp_sleep(1); /* wait a bit, try again */
5180 }
5181 if (status_tries == 0)
5182 {
5183 msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__);
5184 continue;
5185 }
5186 msg(DBG_AUD,"read_audio: sbp_status: ok.\n");
5187
5188 flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
5189 if (fam0L_drive)
5190 {
5191 flags_cmd_out |= f_lopsta | f_getsta | f_bit1;
5192 cmd_type=READ_M2;
5193 drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */
5194 drvcmd[1]=(block>>16)&0x000000ff;
5195 drvcmd[2]=(block>>8)&0x000000ff;
5196 drvcmd[3]=block&0x000000ff;
5197 drvcmd[4]=0;
5198 drvcmd[5]=read_audio.nframes; /* # of frames */
5199 drvcmd[6]=0;
5200 }
5201 else if (fam1_drive)
5202 {
5203 drvcmd[0]=CMD1_READ; /* "read frames", new drives */
5204 lba2msf(block,&drvcmd[1]); /* msf-bin format required */
5205 drvcmd[4]=0;
5206 drvcmd[5]=0;
5207 drvcmd[6]=read_audio.nframes; /* # of frames */
5208 }
5209 else if (fam2_drive)
5210 {
5211 drvcmd[0]=CMD2_READ_XA2;
5212 lba2msf(block,&drvcmd[1]); /* msf-bin format required */
5213 drvcmd[4]=0;
5214 drvcmd[5]=read_audio.nframes; /* # of frames */
5215 drvcmd[6]=0x11; /* raw mode */
5216 }
5217 else if (famT_drive) /* CD-55A: not tested yet */
5218 {
5219 }
5220 msg(DBG_AUD,"read_audio: before giving \"read\" command.\n");
5221 flags_cmd_out=f_putcmd;
5222 response_count=0;
5223 i=cmd_out();
5224 if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i);
5225 sbp_sleep(0);
5226 msg(DBG_AUD,"read_audio: after giving \"read\" command.\n");
5227 for (frame=1;frame<2 && !error_flag; frame++)
5228 {
5229 try=maxtim_data;
5230 for (timeout=jiffies+9*HZ; ; )
5231 {
5232 for ( ; try!=0;try--)
5233 {
5234 j=inb(CDi_status);
5235 if (!(j&s_not_data_ready)) break;
5236 if (!(j&s_not_result_ready)) break;
5237 if (fam0L_drive) if (j&s_attention) break;
5238 }
5239 if (try != 0 || time_after_eq(jiffies, timeout)) break;
5240 if (data_retrying == 0) data_waits++;
5241 data_retrying = 1;
5242 sbp_sleep(1);
5243 try = 1;
5244 }
5245 if (try==0)
5246 {
5247 msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n");
5248 error_flag++;
5249 break;
5250 }
5251 msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n");
5252 if (j&s_not_data_ready)
5253 {
5254 msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n");
5255 error_flag++;
5256 break;
5257 }
5258 msg(DBG_AUD,"read_audio: before reading data.\n");
5259 error_flag=0;
5260 p = current_drive->aud_buf;
5261 if (sbpro_type==1) OUT(CDo_sel_i_d,1);
5262 if (do_16bit)
5263 {
5264 u_short *p2 = (u_short *) p;
5265
5266 for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
5267 {
5268 if ((inb_p(CDi_status)&s_not_data_ready)) continue;
5269
5270 /* get one sample */
5271 *p2++ = inw_p(CDi_data);
5272 *p2++ = inw_p(CDi_data);
5273 }
5274 } else {
5275 for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
5276 {
5277 if ((inb_p(CDi_status)&s_not_data_ready)) continue;
5278
5279 /* get one sample */
5280 *p++ = inb_p(CDi_data);
5281 *p++ = inb_p(CDi_data);
5282 *p++ = inb_p(CDi_data);
5283 *p++ = inb_p(CDi_data);
5284 }
5285 }
5286 if (sbpro_type==1) OUT(CDo_sel_i_d,0);
5287 data_retrying = 0;
5288 }
5289 msg(DBG_AUD,"read_audio: after reading data.\n");
5290 if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */
5291 {
5292 msg(DBG_AUD,"read_audio: read aborted by drive\n");
5293#if 0000
5294 i=cc_DriveReset(); /* ugly fix to prevent a hang */
5295#else
5296 i=cc_ReadError();
5297#endif
5298 continue;
5299 }
5300 if (fam0L_drive)
5301 {
5302 i=maxtim_data;
5303 for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--)
5304 {
5305 for ( ;i!=0;i--)
5306 {
5307 j=inb(CDi_status);
5308 if (!(j&s_not_data_ready)) break;
5309 if (!(j&s_not_result_ready)) break;
5310 if (j&s_attention) break;
5311 }
5312 if (i != 0 || time_after_eq(jiffies, timeout)) break;
5313 sbp_sleep(0);
5314 i = 1;
5315 }
5316 if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ");
5317 if (!(j&s_attention))
5318 {
5319 msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n");
5320 i=cc_DriveReset(); /* ugly fix to prevent a hang */
5321 continue;
5322 }
5323 }
5324 do
5325 {
5326 if (fam0L_drive) cc_ReadStatus();
5327 i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */
5328 if (i<0) { msg(DBG_AUD,
5329 "read_audio: cc_ReadStatus error after read: %02X\n",
5330 current_drive->status_bits);
5331 continue; /* FIXME */
5332 }
5333 }
5334 while ((fam0L_drive)&&(!st_check)&&(!(i&p_success)));
5335 if (st_check)
5336 {
5337 i=cc_ReadError();
5338 msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i);
5339 continue;
5340 }
5341 if (copy_to_user(read_audio.buf,
5342 current_drive->aud_buf,
5343 read_audio.nframes * CD_FRAMESIZE_RAW))
5344 RETURN_UP(-EFAULT);
5345 msg(DBG_AUD,"read_audio: copy_to_user done.\n");
5346 break;
5347 }
5348 cc_ModeSelect(CD_FRAMESIZE);
5349 cc_ModeSense();
5350 current_drive->mode=READ_M1;
5351#if OLD_BUSY
5352 busy_audio=0;
5353#endif /* OLD_BUSY */
5354 if (data_tries == 0)
5355 {
5356 msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__);
5357 RETURN_UP(-EIO);
5358 }
5359 msg(DBG_AUD,"read_audio: successful return.\n");
5360 RETURN_UP(0);
5361 } /* end of CDROMREADAUDIO */
5362
5363 default:
5364 msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
5365 RETURN_UP(-EINVAL);
5366 } /* end switch(cmd) */
5374} 5367}
5375 5368
5376static int sbpcd_block_media_changed(struct gendisk *disk) 5369static int sbpcd_block_media_changed(struct gendisk *disk)
@@ -5478,10 +5471,9 @@ static struct cdrom_device_ops sbpcd_dops = {
5478 .get_mcn = sbpcd_get_mcn, 5471 .get_mcn = sbpcd_get_mcn,
5479 .reset = sbpcd_reset, 5472 .reset = sbpcd_reset,
5480 .audio_ioctl = sbpcd_audio_ioctl, 5473 .audio_ioctl = sbpcd_audio_ioctl,
5481 .dev_ioctl = sbpcd_dev_ioctl,
5482 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | 5474 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
5483 CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | 5475 CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
5484 CDC_MCN | CDC_PLAY_AUDIO | CDC_IOCTLS, 5476 CDC_MCN | CDC_PLAY_AUDIO,
5485 .n_minors = 1, 5477 .n_minors = 1,
5486}; 5478};
5487 5479
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index e27617259552..c0f817ba7adb 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -627,7 +627,7 @@ static struct cdrom_device_ops viocd_dops = {
627 .media_changed = viocd_media_changed, 627 .media_changed = viocd_media_changed,
628 .lock_door = viocd_lock_door, 628 .lock_door = viocd_lock_door,
629 .generic_packet = viocd_packet, 629 .generic_packet = viocd_packet,
630 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM 630 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
631}; 631};
632 632
633static int __init find_capability(const char *type) 633static int __init find_capability(const char *type)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 05ba410682a3..b524f5ba78a9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -695,7 +695,7 @@ config NVRAM
695 695
696config RTC 696config RTC
697 tristate "Enhanced Real Time Clock Support" 697 tristate "Enhanced Real Time Clock Support"
698 depends on !PPC32 && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV 698 depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV
699 ---help--- 699 ---help---
700 If you say Y here and create a character special file /dev/rtc with 700 If you say Y here and create a character special file /dev/rtc with
701 major number 10 and minor number 135 using mknod ("man mknod"), you 701 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 7ac365b5d9ec..6602b3156df5 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -46,8 +46,6 @@
46 46
47/* Sanity checks */ 47/* Sanity checks */
48 48
49#define SERIAL_INLINE
50
51#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) 49#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
52#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 50#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
53 tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) 51 tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
@@ -95,10 +93,6 @@ static char *serial_version = "4.30";
95#include <asm/amigahw.h> 93#include <asm/amigahw.h>
96#include <asm/amigaints.h> 94#include <asm/amigaints.h>
97 95
98#ifdef SERIAL_INLINE
99#define _INLINE_ inline
100#endif
101
102#define custom amiga_custom 96#define custom amiga_custom
103static char *serial_name = "Amiga-builtin serial driver"; 97static char *serial_name = "Amiga-builtin serial driver";
104 98
@@ -253,14 +247,14 @@ static void rs_start(struct tty_struct *tty)
253 * This routine is used by the interrupt handler to schedule 247 * This routine is used by the interrupt handler to schedule
254 * processing in the software interrupt portion of the driver. 248 * processing in the software interrupt portion of the driver.
255 */ 249 */
256static _INLINE_ void rs_sched_event(struct async_struct *info, 250static void rs_sched_event(struct async_struct *info,
257 int event) 251 int event)
258{ 252{
259 info->event |= 1 << event; 253 info->event |= 1 << event;
260 tasklet_schedule(&info->tlet); 254 tasklet_schedule(&info->tlet);
261} 255}
262 256
263static _INLINE_ void receive_chars(struct async_struct *info) 257static void receive_chars(struct async_struct *info)
264{ 258{
265 int status; 259 int status;
266 int serdatr; 260 int serdatr;
@@ -349,7 +343,7 @@ out:
349 return; 343 return;
350} 344}
351 345
352static _INLINE_ void transmit_chars(struct async_struct *info) 346static void transmit_chars(struct async_struct *info)
353{ 347{
354 custom.intreq = IF_TBE; 348 custom.intreq = IF_TBE;
355 mb(); 349 mb();
@@ -389,7 +383,7 @@ static _INLINE_ void transmit_chars(struct async_struct *info)
389 } 383 }
390} 384}
391 385
392static _INLINE_ void check_modem_status(struct async_struct *info) 386static void check_modem_status(struct async_struct *info)
393{ 387{
394 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); 388 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
395 unsigned char dstatus; 389 unsigned char dstatus;
@@ -1959,7 +1953,7 @@ done:
1959 * number, and identifies which options were configured into this 1953 * number, and identifies which options were configured into this
1960 * driver. 1954 * driver.
1961 */ 1955 */
1962static _INLINE_ void show_serial_version(void) 1956static void show_serial_version(void)
1963{ 1957{
1964 printk(KERN_INFO "%s version %s\n", serial_name, serial_version); 1958 printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
1965} 1959}
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index e38a5f0e07bb..5e59c0b42731 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -48,8 +48,8 @@ static int gs_debug;
48#define NEW_WRITE_LOCKING 1 48#define NEW_WRITE_LOCKING 1
49#if NEW_WRITE_LOCKING 49#if NEW_WRITE_LOCKING
50#define DECL /* Nothing */ 50#define DECL /* Nothing */
51#define LOCKIT down (& port->port_write_sem); 51#define LOCKIT mutex_lock(& port->port_write_mutex);
52#define RELEASEIT up (&port->port_write_sem); 52#define RELEASEIT mutex_unlock(&port->port_write_mutex);
53#else 53#else
54#define DECL unsigned long flags; 54#define DECL unsigned long flags;
55#define LOCKIT save_flags (flags);cli () 55#define LOCKIT save_flags (flags);cli ()
@@ -124,14 +124,14 @@ int gs_write(struct tty_struct * tty,
124 /* get exclusive "write" access to this port (problem 3) */ 124 /* get exclusive "write" access to this port (problem 3) */
125 /* This is not a spinlock because we can have a disk access (page 125 /* This is not a spinlock because we can have a disk access (page
126 fault) in copy_from_user */ 126 fault) in copy_from_user */
127 down (& port->port_write_sem); 127 mutex_lock(& port->port_write_mutex);
128 128
129 while (1) { 129 while (1) {
130 130
131 c = count; 131 c = count;
132 132
133 /* This is safe because we "OWN" the "head". Noone else can 133 /* This is safe because we "OWN" the "head". Noone else can
134 change the "head": we own the port_write_sem. */ 134 change the "head": we own the port_write_mutex. */
135 /* Don't overrun the end of the buffer */ 135 /* Don't overrun the end of the buffer */
136 t = SERIAL_XMIT_SIZE - port->xmit_head; 136 t = SERIAL_XMIT_SIZE - port->xmit_head;
137 if (t < c) c = t; 137 if (t < c) c = t;
@@ -153,7 +153,7 @@ int gs_write(struct tty_struct * tty,
153 count -= c; 153 count -= c;
154 total += c; 154 total += c;
155 } 155 }
156 up (& port->port_write_sem); 156 mutex_unlock(& port->port_write_mutex);
157 157
158 gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", 158 gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n",
159 (port->flags & GS_TX_INTEN)?"enabled": "disabled"); 159 (port->flags & GS_TX_INTEN)?"enabled": "disabled");
@@ -214,7 +214,7 @@ int gs_write(struct tty_struct * tty,
214 c = count; 214 c = count;
215 215
216 /* This is safe because we "OWN" the "head". Noone else can 216 /* This is safe because we "OWN" the "head". Noone else can
217 change the "head": we own the port_write_sem. */ 217 change the "head": we own the port_write_mutex. */
218 /* Don't overrun the end of the buffer */ 218 /* Don't overrun the end of the buffer */
219 t = SERIAL_XMIT_SIZE - port->xmit_head; 219 t = SERIAL_XMIT_SIZE - port->xmit_head;
220 if (t < c) c = t; 220 if (t < c) c = t;
@@ -888,7 +888,7 @@ int gs_init_port(struct gs_port *port)
888 spin_lock_irqsave (&port->driver_lock, flags); 888 spin_lock_irqsave (&port->driver_lock, flags);
889 if (port->tty) 889 if (port->tty)
890 clear_bit(TTY_IO_ERROR, &port->tty->flags); 890 clear_bit(TTY_IO_ERROR, &port->tty->flags);
891 init_MUTEX(&port->port_write_sem); 891 mutex_init(&port->port_write_mutex);
892 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 892 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
893 spin_unlock_irqrestore(&port->driver_lock, flags); 893 spin_unlock_irqrestore(&port->driver_lock, flags);
894 gs_set_termios(port->tty, NULL); 894 gs_set_termios(port->tty, NULL);
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 831eb4e8d9d3..f7ac31856572 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -118,7 +118,7 @@
118 * the hvcs_final_close() function in order to get it out of the spinlock. 118 * the hvcs_final_close() function in order to get it out of the spinlock.
119 * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping 119 * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping
120 * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from 120 * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from
121 * arch/ppc64/hvcserver.h. 121 * include/asm-powerpc/hvcserver.h
122 * 122 *
123 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to 123 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to
124 * prevent possible lockup with realtime scheduling as similarily pointed out by 124 * prevent possible lockup with realtime scheduling as similarily pointed out by
@@ -168,9 +168,10 @@ MODULE_VERSION(HVCS_DRIVER_VERSION);
168 168
169/* 169/*
170 * The hcall interface involves putting 8 chars into each of two registers. 170 * The hcall interface involves putting 8 chars into each of two registers.
171 * We load up those 2 registers (in arch/ppc64/hvconsole.c) by casting char[16] 171 * We load up those 2 registers (in arch/powerpc/platforms/pseries/hvconsole.c)
172 * to long[2]. It would work without __ALIGNED__, but a little (tiny) bit 172 * by casting char[16] to long[2]. It would work without __ALIGNED__, but a
173 * slower because an unaligned load is slower than aligned load. 173 * little (tiny) bit slower because an unaligned load is slower than aligned
174 * load.
174 */ 175 */
175#define __ALIGNED__ __attribute__((__aligned__(8))) 176#define __ALIGNED__ __attribute__((__aligned__(8)))
176 177
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 28c5a3193b81..ede128356af2 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -181,7 +181,6 @@ static struct tty_driver *stli_serial;
181 * is already swapping a shared buffer won't make things any worse. 181 * is already swapping a shared buffer won't make things any worse.
182 */ 182 */
183static char *stli_tmpwritebuf; 183static char *stli_tmpwritebuf;
184static DECLARE_MUTEX(stli_tmpwritesem);
185 184
186#define STLI_TXBUFSIZE 4096 185#define STLI_TXBUFSIZE 4096
187 186
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index ccad7ae94541..ede365d05387 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -132,7 +132,7 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty)
132 * We test the TTY_THROTTLED bit first so that it always 132 * We test the TTY_THROTTLED bit first so that it always
133 * indicates the current state. The decision about whether 133 * indicates the current state. The decision about whether
134 * it is worth allowing more input has been taken by the caller. 134 * it is worth allowing more input has been taken by the caller.
135 * Can sleep, may be called under the atomic_read semaphore but 135 * Can sleep, may be called under the atomic_read_lock mutex but
136 * this is not guaranteed. 136 * this is not guaranteed.
137 */ 137 */
138 138
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1132 * buffer, and once to drain the space from the (physical) beginning of 1132 * buffer, and once to drain the space from the (physical) beginning of
1133 * the buffer to head pointer. 1133 * the buffer to head pointer.
1134 * 1134 *
1135 * Called under the tty->atomic_read sem and with TTY_DONT_FLIP set 1135 * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set
1136 * 1136 *
1137 */ 1137 */
1138 1138
@@ -1262,11 +1262,11 @@ do_it_again:
1262 * Internal serialization of reads. 1262 * Internal serialization of reads.
1263 */ 1263 */
1264 if (file->f_flags & O_NONBLOCK) { 1264 if (file->f_flags & O_NONBLOCK) {
1265 if (down_trylock(&tty->atomic_read)) 1265 if (!mutex_trylock(&tty->atomic_read_lock))
1266 return -EAGAIN; 1266 return -EAGAIN;
1267 } 1267 }
1268 else { 1268 else {
1269 if (down_interruptible(&tty->atomic_read)) 1269 if (mutex_lock_interruptible(&tty->atomic_read_lock))
1270 return -ERESTARTSYS; 1270 return -ERESTARTSYS;
1271 } 1271 }
1272 1272
@@ -1393,7 +1393,7 @@ do_it_again:
1393 timeout = time; 1393 timeout = time;
1394 } 1394 }
1395 clear_bit(TTY_DONT_FLIP, &tty->flags); 1395 clear_bit(TTY_DONT_FLIP, &tty->flags);
1396 up(&tty->atomic_read); 1396 mutex_unlock(&tty->atomic_read_lock);
1397 remove_wait_queue(&tty->read_wait, &wait); 1397 remove_wait_queue(&tty->read_wait, &wait);
1398 1398
1399 if (!waitqueue_active(&tty->read_wait)) 1399 if (!waitqueue_active(&tty->read_wait))
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index ca41d62b1d9d..8865387d3448 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -27,6 +27,7 @@
27#include <linux/rwsem.h> 27#include <linux/rwsem.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/smp_lock.h> 29#include <linux/smp_lock.h>
30#include <linux/mutex.h>
30 31
31#include <asm/hardware/dec21285.h> 32#include <asm/hardware/dec21285.h>
32#include <asm/io.h> 33#include <asm/io.h>
@@ -56,7 +57,7 @@ static int gbWriteEnable;
56static int gbWriteBase64Enable; 57static int gbWriteBase64Enable;
57static volatile unsigned char *FLASH_BASE; 58static volatile unsigned char *FLASH_BASE;
58static int gbFlashSize = KFLASH_SIZE; 59static int gbFlashSize = KFLASH_SIZE;
59static DECLARE_MUTEX(nwflash_sem); 60static DEFINE_MUTEX(nwflash_mutex);
60 61
61extern spinlock_t gpio_lock; 62extern spinlock_t gpio_lock;
62 63
@@ -140,7 +141,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
140 /* 141 /*
141 * We now lock against reads and writes. --rmk 142 * We now lock against reads and writes. --rmk
142 */ 143 */
143 if (down_interruptible(&nwflash_sem)) 144 if (mutex_lock_interruptible(&nwflash_mutex))
144 return -ERESTARTSYS; 145 return -ERESTARTSYS;
145 146
146 ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); 147 ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
@@ -149,7 +150,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
149 *ppos += count; 150 *ppos += count;
150 } else 151 } else
151 ret = -EFAULT; 152 ret = -EFAULT;
152 up(&nwflash_sem); 153 mutex_unlock(&nwflash_mutex);
153 } 154 }
154 return ret; 155 return ret;
155} 156}
@@ -188,7 +189,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
188 /* 189 /*
189 * We now lock against reads and writes. --rmk 190 * We now lock against reads and writes. --rmk
190 */ 191 */
191 if (down_interruptible(&nwflash_sem)) 192 if (mutex_lock_interruptible(&nwflash_mutex))
192 return -ERESTARTSYS; 193 return -ERESTARTSYS;
193 194
194 written = 0; 195 written = 0;
@@ -277,7 +278,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
277 */ 278 */
278 leds_event(led_release); 279 leds_event(led_release);
279 280
280 up(&nwflash_sem); 281 mutex_unlock(&nwflash_mutex);
281 282
282 return written; 283 return written;
283} 284}
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 30e4cbe16bb0..15a7b4086524 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,6 +19,7 @@
19#include <linux/uio.h> 19#include <linux/uio.h>
20#include <linux/cdev.h> 20#include <linux/cdev.h>
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/mutex.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
@@ -29,7 +30,7 @@ struct raw_device_data {
29 30
30static struct class *raw_class; 31static struct class *raw_class;
31static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 32static struct raw_device_data raw_devices[MAX_RAW_MINORS];
32static DECLARE_MUTEX(raw_mutex); 33static DEFINE_MUTEX(raw_mutex);
33static struct file_operations raw_ctl_fops; /* forward declaration */ 34static struct file_operations raw_ctl_fops; /* forward declaration */
34 35
35/* 36/*
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
53 return 0; 54 return 0;
54 } 55 }
55 56
56 down(&raw_mutex); 57 mutex_lock(&raw_mutex);
57 58
58 /* 59 /*
59 * All we need to do on open is check that the device is bound. 60 * All we need to do on open is check that the device is bound.
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp)
78 filp->f_dentry->d_inode->i_mapping = 79 filp->f_dentry->d_inode->i_mapping =
79 bdev->bd_inode->i_mapping; 80 bdev->bd_inode->i_mapping;
80 filp->private_data = bdev; 81 filp->private_data = bdev;
81 up(&raw_mutex); 82 mutex_unlock(&raw_mutex);
82 return 0; 83 return 0;
83 84
84out2: 85out2:
@@ -86,7 +87,7 @@ out2:
86out1: 87out1:
87 blkdev_put(bdev); 88 blkdev_put(bdev);
88out: 89out:
89 up(&raw_mutex); 90 mutex_unlock(&raw_mutex);
90 return err; 91 return err;
91} 92}
92 93
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp)
99 const int minor= iminor(inode); 100 const int minor= iminor(inode);
100 struct block_device *bdev; 101 struct block_device *bdev;
101 102
102 down(&raw_mutex); 103 mutex_lock(&raw_mutex);
103 bdev = raw_devices[minor].binding; 104 bdev = raw_devices[minor].binding;
104 if (--raw_devices[minor].inuse == 0) { 105 if (--raw_devices[minor].inuse == 0) {
105 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ 106 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */
106 inode->i_mapping = &inode->i_data; 107 inode->i_mapping = &inode->i_data;
107 inode->i_mapping->backing_dev_info = &default_backing_dev_info; 108 inode->i_mapping->backing_dev_info = &default_backing_dev_info;
108 } 109 }
109 up(&raw_mutex); 110 mutex_unlock(&raw_mutex);
110 111
111 bd_release(bdev); 112 bd_release(bdev);
112 blkdev_put(bdev); 113 blkdev_put(bdev);
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
187 goto out; 188 goto out;
188 } 189 }
189 190
190 down(&raw_mutex); 191 mutex_lock(&raw_mutex);
191 if (rawdev->inuse) { 192 if (rawdev->inuse) {
192 up(&raw_mutex); 193 mutex_unlock(&raw_mutex);
193 err = -EBUSY; 194 err = -EBUSY;
194 goto out; 195 goto out;
195 } 196 }
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
211 bind_device(&rq); 212 bind_device(&rq);
212 } 213 }
213 } 214 }
214 up(&raw_mutex); 215 mutex_unlock(&raw_mutex);
215 } else { 216 } else {
216 struct block_device *bdev; 217 struct block_device *bdev;
217 218
218 down(&raw_mutex); 219 mutex_lock(&raw_mutex);
219 bdev = rawdev->binding; 220 bdev = rawdev->binding;
220 if (bdev) { 221 if (bdev) {
221 rq.block_major = MAJOR(bdev->bd_dev); 222 rq.block_major = MAJOR(bdev->bd_dev);
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
223 } else { 224 } else {
224 rq.block_major = rq.block_minor = 0; 225 rq.block_major = rq.block_minor = 0;
225 } 226 }
226 up(&raw_mutex); 227 mutex_unlock(&raw_mutex);
227 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { 228 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
228 err = -EFAULT; 229 err = -EFAULT;
229 goto out; 230 goto out;
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index fee68cc895f8..510bd3e0e88b 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -97,7 +97,7 @@
97#include <asm/amigahw.h> 97#include <asm/amigahw.h>
98#include <linux/zorro.h> 98#include <linux/zorro.h>
99#include <asm/irq.h> 99#include <asm/irq.h>
100#include <asm/semaphore.h> 100#include <linux/mutex.h>
101 101
102#include <linux/delay.h> 102#include <linux/delay.h>
103 103
@@ -654,7 +654,7 @@ static void a2232_init_portstructs(void)
654 port->gs.closing_wait = 30 * HZ; 654 port->gs.closing_wait = 30 * HZ;
655 port->gs.rd = &a2232_real_driver; 655 port->gs.rd = &a2232_real_driver;
656#ifdef NEW_WRITE_LOCKING 656#ifdef NEW_WRITE_LOCKING
657 init_MUTEX(&(port->gs.port_write_sem)); 657 init_MUTEX(&(port->gs.port_write_mutex));
658#endif 658#endif
659 init_waitqueue_head(&port->gs.open_wait); 659 init_waitqueue_head(&port->gs.open_wait);
660 init_waitqueue_head(&port->gs.close_wait); 660 init_waitqueue_head(&port->gs.close_wait);
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 0e7d216e7eb0..b543821d8cb4 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -5,7 +5,7 @@
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 2004, 2006 Silicon Graphics, Inc. All rights reserved.
9 */ 9 */
10 10
11/* 11/*
@@ -77,7 +77,7 @@ scdrv_open(struct inode *inode, struct file *file)
77 scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev); 77 scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev);
78 78
79 /* allocate memory for subchannel data */ 79 /* allocate memory for subchannel data */
80 sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); 80 sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
81 if (sd == NULL) { 81 if (sd == NULL) {
82 printk("%s: couldn't allocate subchannel data\n", 82 printk("%s: couldn't allocate subchannel data\n",
83 __FUNCTION__); 83 __FUNCTION__);
@@ -85,7 +85,6 @@ scdrv_open(struct inode *inode, struct file *file)
85 } 85 }
86 86
87 /* initialize subch_data_s fields */ 87 /* initialize subch_data_s fields */
88 memset(sd, 0, sizeof (struct subch_data_s));
89 sd->sd_nasid = scd->scd_nasid; 88 sd->sd_nasid = scd->scd_nasid;
90 sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid); 89 sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid);
91 90
@@ -394,7 +393,7 @@ scdrv_init(void)
394 sprintf(devnamep, "#%d", geo_slab(geoid)); 393 sprintf(devnamep, "#%d", geo_slab(geoid));
395 394
396 /* allocate sysctl device data */ 395 /* allocate sysctl device data */
397 scd = kmalloc(sizeof (struct sysctl_data_s), 396 scd = kzalloc(sizeof (struct sysctl_data_s),
398 GFP_KERNEL); 397 GFP_KERNEL);
399 if (!scd) { 398 if (!scd) {
400 printk("%s: failed to allocate device info" 399 printk("%s: failed to allocate device info"
@@ -402,7 +401,6 @@ scdrv_init(void)
402 SYSCTL_BASENAME, devname); 401 SYSCTL_BASENAME, devname);
403 continue; 402 continue;
404 } 403 }
405 memset(scd, 0, sizeof (struct sysctl_data_s));
406 404
407 /* initialize sysctl device data fields */ 405 /* initialize sysctl device data fields */
408 scd->scd_nasid = cnodeid_to_nasid(cnode); 406 scd->scd_nasid = cnodeid_to_nasid(cnode);
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index a4fa507eed9e..e234d50e142a 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -287,7 +287,7 @@ scdrv_event_init(struct sysctl_data_s *scd)
287{ 287{
288 int rv; 288 int rv;
289 289
290 event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); 290 event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
291 if (event_sd == NULL) { 291 if (event_sd == NULL) {
292 printk(KERN_WARNING "%s: couldn't allocate subchannel info" 292 printk(KERN_WARNING "%s: couldn't allocate subchannel info"
293 " for event monitoring\n", __FUNCTION__); 293 " for event monitoring\n", __FUNCTION__);
@@ -295,7 +295,6 @@ scdrv_event_init(struct sysctl_data_s *scd)
295 } 295 }
296 296
297 /* initialize subch_data_s fields */ 297 /* initialize subch_data_s fields */
298 memset(event_sd, 0, sizeof (struct subch_data_s));
299 event_sd->sd_nasid = scd->scd_nasid; 298 event_sd->sd_nasid = scd->scd_nasid;
300 spin_lock_init(&event_sd->sd_rlock); 299 spin_lock_init(&event_sd->sd_rlock);
301 300
@@ -321,5 +320,3 @@ scdrv_event_init(struct sysctl_data_s *scd)
321 return; 320 return;
322 } 321 }
323} 322}
324
325
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index bdaab6992109..3f5d6077f39c 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -148,7 +148,6 @@ static struct tty_driver *stl_serial;
148 * is already swapping a shared buffer won't make things any worse. 148 * is already swapping a shared buffer won't make things any worse.
149 */ 149 */
150static char *stl_tmpwritebuf; 150static char *stl_tmpwritebuf;
151static DECLARE_MUTEX(stl_tmpwritesem);
152 151
153/* 152/*
154 * Define a local default termios struct. All ports will be created 153 * Define a local default termios struct. All ports will be created
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index a6b4f02bdceb..3b4747230270 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2318,7 +2318,7 @@ static int sx_init_portstructs (int nboards, int nports)
2318 port->board = board; 2318 port->board = board;
2319 port->gs.rd = &sx_real_driver; 2319 port->gs.rd = &sx_real_driver;
2320#ifdef NEW_WRITE_LOCKING 2320#ifdef NEW_WRITE_LOCKING
2321 port->gs.port_write_sem = MUTEX; 2321 port->gs.port_write_mutex = MUTEX;
2322#endif 2322#endif
2323 port->gs.driver_lock = SPIN_LOCK_UNLOCKED; 2323 port->gs.driver_lock = SPIN_LOCK_UNLOCKED;
2324 /* 2324 /*
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 53d3d066554e..76592ee1fb38 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -130,7 +130,7 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
130 130
131/* Semaphore to protect creating and releasing a tty. This is shared with 131/* Semaphore to protect creating and releasing a tty. This is shared with
132 vt.c for deeply disgusting hack reasons */ 132 vt.c for deeply disgusting hack reasons */
133DECLARE_MUTEX(tty_sem); 133DEFINE_MUTEX(tty_mutex);
134 134
135#ifdef CONFIG_UNIX98_PTYS 135#ifdef CONFIG_UNIX98_PTYS
136extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ 136extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */
@@ -1188,11 +1188,11 @@ void disassociate_ctty(int on_exit)
1188 1188
1189 lock_kernel(); 1189 lock_kernel();
1190 1190
1191 down(&tty_sem); 1191 mutex_lock(&tty_mutex);
1192 tty = current->signal->tty; 1192 tty = current->signal->tty;
1193 if (tty) { 1193 if (tty) {
1194 tty_pgrp = tty->pgrp; 1194 tty_pgrp = tty->pgrp;
1195 up(&tty_sem); 1195 mutex_unlock(&tty_mutex);
1196 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) 1196 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
1197 tty_vhangup(tty); 1197 tty_vhangup(tty);
1198 } else { 1198 } else {
@@ -1200,7 +1200,7 @@ void disassociate_ctty(int on_exit)
1200 kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); 1200 kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit);
1201 kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); 1201 kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit);
1202 } 1202 }
1203 up(&tty_sem); 1203 mutex_unlock(&tty_mutex);
1204 unlock_kernel(); 1204 unlock_kernel();
1205 return; 1205 return;
1206 } 1206 }
@@ -1211,7 +1211,7 @@ void disassociate_ctty(int on_exit)
1211 } 1211 }
1212 1212
1213 /* Must lock changes to tty_old_pgrp */ 1213 /* Must lock changes to tty_old_pgrp */
1214 down(&tty_sem); 1214 mutex_lock(&tty_mutex);
1215 current->signal->tty_old_pgrp = 0; 1215 current->signal->tty_old_pgrp = 0;
1216 tty->session = 0; 1216 tty->session = 0;
1217 tty->pgrp = -1; 1217 tty->pgrp = -1;
@@ -1222,7 +1222,7 @@ void disassociate_ctty(int on_exit)
1222 p->signal->tty = NULL; 1222 p->signal->tty = NULL;
1223 } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); 1223 } while_each_task_pid(current->signal->session, PIDTYPE_SID, p);
1224 read_unlock(&tasklist_lock); 1224 read_unlock(&tasklist_lock);
1225 up(&tty_sem); 1225 mutex_unlock(&tty_mutex);
1226 unlock_kernel(); 1226 unlock_kernel();
1227} 1227}
1228 1228
@@ -1306,7 +1306,7 @@ static inline ssize_t do_tty_write(
1306 ssize_t ret = 0, written = 0; 1306 ssize_t ret = 0, written = 0;
1307 unsigned int chunk; 1307 unsigned int chunk;
1308 1308
1309 if (down_interruptible(&tty->atomic_write)) { 1309 if (mutex_lock_interruptible(&tty->atomic_write_lock)) {
1310 return -ERESTARTSYS; 1310 return -ERESTARTSYS;
1311 } 1311 }
1312 1312
@@ -1329,7 +1329,7 @@ static inline ssize_t do_tty_write(
1329 if (count < chunk) 1329 if (count < chunk)
1330 chunk = count; 1330 chunk = count;
1331 1331
1332 /* write_buf/write_cnt is protected by the atomic_write semaphore */ 1332 /* write_buf/write_cnt is protected by the atomic_write_lock mutex */
1333 if (tty->write_cnt < chunk) { 1333 if (tty->write_cnt < chunk) {
1334 unsigned char *buf; 1334 unsigned char *buf;
1335 1335
@@ -1338,7 +1338,7 @@ static inline ssize_t do_tty_write(
1338 1338
1339 buf = kmalloc(chunk, GFP_KERNEL); 1339 buf = kmalloc(chunk, GFP_KERNEL);
1340 if (!buf) { 1340 if (!buf) {
1341 up(&tty->atomic_write); 1341 mutex_unlock(&tty->atomic_write_lock);
1342 return -ENOMEM; 1342 return -ENOMEM;
1343 } 1343 }
1344 kfree(tty->write_buf); 1344 kfree(tty->write_buf);
@@ -1374,7 +1374,7 @@ static inline ssize_t do_tty_write(
1374 inode->i_mtime = current_fs_time(inode->i_sb); 1374 inode->i_mtime = current_fs_time(inode->i_sb);
1375 ret = written; 1375 ret = written;
1376 } 1376 }
1377 up(&tty->atomic_write); 1377 mutex_unlock(&tty->atomic_write_lock);
1378 return ret; 1378 return ret;
1379} 1379}
1380 1380
@@ -1442,8 +1442,8 @@ static inline void tty_line_name(struct tty_driver *driver, int index, char *p)
1442 1442
1443/* 1443/*
1444 * WSH 06/09/97: Rewritten to remove races and properly clean up after a 1444 * WSH 06/09/97: Rewritten to remove races and properly clean up after a
1445 * failed open. The new code protects the open with a semaphore, so it's 1445 * failed open. The new code protects the open with a mutex, so it's
1446 * really quite straightforward. The semaphore locking can probably be 1446 * really quite straightforward. The mutex locking can probably be
1447 * relaxed for the (most common) case of reopening a tty. 1447 * relaxed for the (most common) case of reopening a tty.
1448 */ 1448 */
1449static int init_dev(struct tty_driver *driver, int idx, 1449static int init_dev(struct tty_driver *driver, int idx,
@@ -1640,7 +1640,7 @@ fast_track:
1640success: 1640success:
1641 *ret_tty = tty; 1641 *ret_tty = tty;
1642 1642
1643 /* All paths come through here to release the semaphore */ 1643 /* All paths come through here to release the mutex */
1644end_init: 1644end_init:
1645 return retval; 1645 return retval;
1646 1646
@@ -1837,7 +1837,7 @@ static void release_dev(struct file * filp)
1837 /* Guard against races with tty->count changes elsewhere and 1837 /* Guard against races with tty->count changes elsewhere and
1838 opens on /dev/tty */ 1838 opens on /dev/tty */
1839 1839
1840 down(&tty_sem); 1840 mutex_lock(&tty_mutex);
1841 tty_closing = tty->count <= 1; 1841 tty_closing = tty->count <= 1;
1842 o_tty_closing = o_tty && 1842 o_tty_closing = o_tty &&
1843 (o_tty->count <= (pty_master ? 1 : 0)); 1843 (o_tty->count <= (pty_master ? 1 : 0));
@@ -1868,7 +1868,7 @@ static void release_dev(struct file * filp)
1868 1868
1869 printk(KERN_WARNING "release_dev: %s: read/write wait queue " 1869 printk(KERN_WARNING "release_dev: %s: read/write wait queue "
1870 "active!\n", tty_name(tty, buf)); 1870 "active!\n", tty_name(tty, buf));
1871 up(&tty_sem); 1871 mutex_unlock(&tty_mutex);
1872 schedule(); 1872 schedule();
1873 } 1873 }
1874 1874
@@ -1934,7 +1934,7 @@ static void release_dev(struct file * filp)
1934 read_unlock(&tasklist_lock); 1934 read_unlock(&tasklist_lock);
1935 } 1935 }
1936 1936
1937 up(&tty_sem); 1937 mutex_unlock(&tty_mutex);
1938 1938
1939 /* check whether both sides are closing ... */ 1939 /* check whether both sides are closing ... */
1940 if (!tty_closing || (o_tty && !o_tty_closing)) 1940 if (!tty_closing || (o_tty && !o_tty_closing))
@@ -2040,11 +2040,11 @@ retry_open:
2040 index = -1; 2040 index = -1;
2041 retval = 0; 2041 retval = 0;
2042 2042
2043 down(&tty_sem); 2043 mutex_lock(&tty_mutex);
2044 2044
2045 if (device == MKDEV(TTYAUX_MAJOR,0)) { 2045 if (device == MKDEV(TTYAUX_MAJOR,0)) {
2046 if (!current->signal->tty) { 2046 if (!current->signal->tty) {
2047 up(&tty_sem); 2047 mutex_unlock(&tty_mutex);
2048 return -ENXIO; 2048 return -ENXIO;
2049 } 2049 }
2050 driver = current->signal->tty->driver; 2050 driver = current->signal->tty->driver;
@@ -2070,18 +2070,18 @@ retry_open:
2070 noctty = 1; 2070 noctty = 1;
2071 goto got_driver; 2071 goto got_driver;
2072 } 2072 }
2073 up(&tty_sem); 2073 mutex_unlock(&tty_mutex);
2074 return -ENODEV; 2074 return -ENODEV;
2075 } 2075 }
2076 2076
2077 driver = get_tty_driver(device, &index); 2077 driver = get_tty_driver(device, &index);
2078 if (!driver) { 2078 if (!driver) {
2079 up(&tty_sem); 2079 mutex_unlock(&tty_mutex);
2080 return -ENODEV; 2080 return -ENODEV;
2081 } 2081 }
2082got_driver: 2082got_driver:
2083 retval = init_dev(driver, index, &tty); 2083 retval = init_dev(driver, index, &tty);
2084 up(&tty_sem); 2084 mutex_unlock(&tty_mutex);
2085 if (retval) 2085 if (retval)
2086 return retval; 2086 return retval;
2087 2087
@@ -2167,9 +2167,9 @@ static int ptmx_open(struct inode * inode, struct file * filp)
2167 } 2167 }
2168 up(&allocated_ptys_lock); 2168 up(&allocated_ptys_lock);
2169 2169
2170 down(&tty_sem); 2170 mutex_lock(&tty_mutex);
2171 retval = init_dev(ptm_driver, index, &tty); 2171 retval = init_dev(ptm_driver, index, &tty);
2172 up(&tty_sem); 2172 mutex_unlock(&tty_mutex);
2173 2173
2174 if (retval) 2174 if (retval)
2175 goto out; 2175 goto out;
@@ -2915,8 +2915,8 @@ static void initialize_tty_struct(struct tty_struct *tty)
2915 init_waitqueue_head(&tty->write_wait); 2915 init_waitqueue_head(&tty->write_wait);
2916 init_waitqueue_head(&tty->read_wait); 2916 init_waitqueue_head(&tty->read_wait);
2917 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); 2917 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty);
2918 sema_init(&tty->atomic_read, 1); 2918 mutex_init(&tty->atomic_read_lock);
2919 sema_init(&tty->atomic_write, 1); 2919 mutex_init(&tty->atomic_write_lock);
2920 spin_lock_init(&tty->read_lock); 2920 spin_lock_init(&tty->read_lock);
2921 INIT_LIST_HEAD(&tty->tty_files); 2921 INIT_LIST_HEAD(&tty->tty_files);
2922 INIT_WORK(&tty->SAK_work, NULL, NULL); 2922 INIT_WORK(&tty->SAK_work, NULL, NULL);
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index d9325281e482..fd00822ac145 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -184,7 +184,7 @@ static void scc_init_portstructs(void)
184 port->gs.closing_wait = 30 * HZ; 184 port->gs.closing_wait = 30 * HZ;
185 port->gs.rd = &scc_real_driver; 185 port->gs.rd = &scc_real_driver;
186#ifdef NEW_WRITE_LOCKING 186#ifdef NEW_WRITE_LOCKING
187 port->gs.port_write_sem = MUTEX; 187 port->gs.port_write_mutex = MUTEX;
188#endif 188#endif
189 init_waitqueue_head(&port->gs.open_wait); 189 init_waitqueue_head(&port->gs.open_wait);
190 init_waitqueue_head(&port->gs.close_wait); 190 init_waitqueue_head(&port->gs.close_wait);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 0900d1dbee59..ca4844c527da 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2489,7 +2489,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2489} 2489}
2490 2490
2491/* 2491/*
2492 * We take tty_sem in here to prevent another thread from coming in via init_dev 2492 * We take tty_mutex in here to prevent another thread from coming in via init_dev
2493 * and taking a ref against the tty while we're in the process of forgetting 2493 * and taking a ref against the tty while we're in the process of forgetting
2494 * about it and cleaning things up. 2494 * about it and cleaning things up.
2495 * 2495 *
@@ -2497,7 +2497,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2497 */ 2497 */
2498static void con_close(struct tty_struct *tty, struct file *filp) 2498static void con_close(struct tty_struct *tty, struct file *filp)
2499{ 2499{
2500 down(&tty_sem); 2500 mutex_lock(&tty_mutex);
2501 acquire_console_sem(); 2501 acquire_console_sem();
2502 if (tty && tty->count == 1) { 2502 if (tty && tty->count == 1) {
2503 struct vc_data *vc = tty->driver_data; 2503 struct vc_data *vc = tty->driver_data;
@@ -2507,15 +2507,15 @@ static void con_close(struct tty_struct *tty, struct file *filp)
2507 tty->driver_data = NULL; 2507 tty->driver_data = NULL;
2508 release_console_sem(); 2508 release_console_sem();
2509 vcs_remove_devfs(tty); 2509 vcs_remove_devfs(tty);
2510 up(&tty_sem); 2510 mutex_unlock(&tty_mutex);
2511 /* 2511 /*
2512 * tty_sem is released, but we still hold BKL, so there is 2512 * tty_mutex is released, but we still hold BKL, so there is
2513 * still exclusion against init_dev() 2513 * still exclusion against init_dev()
2514 */ 2514 */
2515 return; 2515 return;
2516 } 2516 }
2517 release_console_sem(); 2517 release_console_sem();
2518 up(&tty_sem); 2518 mutex_unlock(&tty_mutex);
2519} 2519}
2520 2520
2521static void vc_init(struct vc_data *vc, unsigned int rows, 2521static void vc_init(struct vc_data *vc, unsigned int rows,
@@ -2869,9 +2869,9 @@ void unblank_screen(void)
2869} 2869}
2870 2870
2871/* 2871/*
2872 * We defer the timer blanking to work queue so it can take the console semaphore 2872 * We defer the timer blanking to work queue so it can take the console mutex
2873 * (console operations can still happen at irq time, but only from printk which 2873 * (console operations can still happen at irq time, but only from printk which
2874 * has the console semaphore. Not perfect yet, but better than no locking 2874 * has the console mutex. Not perfect yet, but better than no locking
2875 */ 2875 */
2876static void blank_screen_t(unsigned long dummy) 2876static void blank_screen_t(unsigned long dummy)
2877{ 2877{
@@ -3234,6 +3234,14 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
3234 } 3234 }
3235} 3235}
3236 3236
3237int is_console_suspend_safe(void)
3238{
3239 /* It is unsafe to suspend devices while X has control of the
3240 * hardware. Make sure we are running on a kernel-controlled console.
3241 */
3242 return vc_cons[fg_console].d->vc_mode == KD_TEXT;
3243}
3244
3237/* 3245/*
3238 * Visible symbols for modules 3246 * Visible symbols for modules
3239 */ 3247 */
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 1533f56baa42..2700c5c45b8a 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -42,6 +42,7 @@
42#include <linux/completion.h> 42#include <linux/completion.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <linux/usb.h> 44#include <linux/usb.h>
45#include <linux/mutex.h>
45 46
46 47
47#ifdef CONFIG_USB_DEBUG 48#ifdef CONFIG_USB_DEBUG
@@ -143,7 +144,7 @@ struct usb_pcwd_private {
143static struct usb_pcwd_private *usb_pcwd_device; 144static struct usb_pcwd_private *usb_pcwd_device;
144 145
145/* prevent races between open() and disconnect() */ 146/* prevent races between open() and disconnect() */
146static DECLARE_MUTEX (disconnect_sem); 147static DEFINE_MUTEX(disconnect_mutex);
147 148
148/* local function prototypes */ 149/* local function prototypes */
149static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); 150static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id);
@@ -723,7 +724,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
723 struct usb_pcwd_private *usb_pcwd; 724 struct usb_pcwd_private *usb_pcwd;
724 725
725 /* prevent races with open() */ 726 /* prevent races with open() */
726 down (&disconnect_sem); 727 mutex_lock(&disconnect_mutex);
727 728
728 usb_pcwd = usb_get_intfdata (interface); 729 usb_pcwd = usb_get_intfdata (interface);
729 usb_set_intfdata (interface, NULL); 730 usb_set_intfdata (interface, NULL);
@@ -749,7 +750,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
749 750
750 cards_found--; 751 cards_found--;
751 752
752 up (&disconnect_sem); 753 mutex_unlock(&disconnect_mutex);
753 754
754 printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); 755 printk(KERN_INFO PFX "USB PC Watchdog disconnected\n");
755} 756}
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index d7125f4d9113..35897079a78d 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -26,6 +26,7 @@
26#include <linux/netlink.h> 26#include <linux/netlink.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/connector.h> 28#include <linux/connector.h>
29#include <linux/mutex.h>
29 30
30#include <net/sock.h> 31#include <net/sock.h>
31 32
@@ -41,7 +42,7 @@ module_param(cn_val, uint, 0);
41MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); 42MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
42MODULE_PARM_DESC(cn_val, "Connector's main device val."); 43MODULE_PARM_DESC(cn_val, "Connector's main device val.");
43 44
44static DECLARE_MUTEX(notify_lock); 45static DEFINE_MUTEX(notify_lock);
45static LIST_HEAD(notify_list); 46static LIST_HEAD(notify_list);
46 47
47static struct cn_dev cdev; 48static struct cn_dev cdev;
@@ -260,7 +261,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
260{ 261{
261 struct cn_ctl_entry *ent; 262 struct cn_ctl_entry *ent;
262 263
263 down(&notify_lock); 264 mutex_lock(&notify_lock);
264 list_for_each_entry(ent, &notify_list, notify_entry) { 265 list_for_each_entry(ent, &notify_list, notify_entry) {
265 int i; 266 int i;
266 struct cn_notify_req *req; 267 struct cn_notify_req *req;
@@ -293,7 +294,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
293 cn_netlink_send(&m, ctl->group, GFP_KERNEL); 294 cn_netlink_send(&m, ctl->group, GFP_KERNEL);
294 } 295 }
295 } 296 }
296 up(&notify_lock); 297 mutex_unlock(&notify_lock);
297} 298}
298 299
299/* 300/*
@@ -407,14 +408,14 @@ static void cn_callback(void *data)
407 if (ctl->group == 0) { 408 if (ctl->group == 0) {
408 struct cn_ctl_entry *n; 409 struct cn_ctl_entry *n;
409 410
410 down(&notify_lock); 411 mutex_lock(&notify_lock);
411 list_for_each_entry_safe(ent, n, &notify_list, notify_entry) { 412 list_for_each_entry_safe(ent, n, &notify_list, notify_entry) {
412 if (cn_ctl_msg_equals(ent->msg, ctl)) { 413 if (cn_ctl_msg_equals(ent->msg, ctl)) {
413 list_del(&ent->notify_entry); 414 list_del(&ent->notify_entry);
414 kfree(ent); 415 kfree(ent);
415 } 416 }
416 } 417 }
417 up(&notify_lock); 418 mutex_unlock(&notify_lock);
418 419
419 return; 420 return;
420 } 421 }
@@ -429,9 +430,9 @@ static void cn_callback(void *data)
429 430
430 memcpy(ent->msg, ctl, size - sizeof(*ent)); 431 memcpy(ent->msg, ctl, size - sizeof(*ent));
431 432
432 down(&notify_lock); 433 mutex_lock(&notify_lock);
433 list_add(&ent->notify_entry, &notify_list); 434 list_add(&ent->notify_entry, &notify_list);
434 up(&notify_lock); 435 mutex_unlock(&notify_lock);
435} 436}
436 437
437static int __init cn_init(void) 438static int __init cn_init(void)
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 3a4e5c5b4e1f..d6543fc4a923 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -33,6 +33,7 @@
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/mutex.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/semaphore.h> 38#include <asm/semaphore.h>
38 39
@@ -48,7 +49,7 @@ static u8 *smi_data_buf;
48static dma_addr_t smi_data_buf_handle; 49static dma_addr_t smi_data_buf_handle;
49static unsigned long smi_data_buf_size; 50static unsigned long smi_data_buf_size;
50static u32 smi_data_buf_phys_addr; 51static u32 smi_data_buf_phys_addr;
51static DECLARE_MUTEX(smi_data_lock); 52static DEFINE_MUTEX(smi_data_lock);
52 53
53static unsigned int host_control_action; 54static unsigned int host_control_action;
54static unsigned int host_control_smi_type; 55static unsigned int host_control_smi_type;
@@ -139,9 +140,9 @@ static ssize_t smi_data_buf_size_store(struct device *dev,
139 buf_size = simple_strtoul(buf, NULL, 10); 140 buf_size = simple_strtoul(buf, NULL, 10);
140 141
141 /* make sure SMI data buffer is at least buf_size */ 142 /* make sure SMI data buffer is at least buf_size */
142 down(&smi_data_lock); 143 mutex_lock(&smi_data_lock);
143 ret = smi_data_buf_realloc(buf_size); 144 ret = smi_data_buf_realloc(buf_size);
144 up(&smi_data_lock); 145 mutex_unlock(&smi_data_lock);
145 if (ret) 146 if (ret)
146 return ret; 147 return ret;
147 148
@@ -154,7 +155,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
154 size_t max_read; 155 size_t max_read;
155 ssize_t ret; 156 ssize_t ret;
156 157
157 down(&smi_data_lock); 158 mutex_lock(&smi_data_lock);
158 159
159 if (pos >= smi_data_buf_size) { 160 if (pos >= smi_data_buf_size) {
160 ret = 0; 161 ret = 0;
@@ -165,7 +166,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
165 ret = min(max_read, count); 166 ret = min(max_read, count);
166 memcpy(buf, smi_data_buf + pos, ret); 167 memcpy(buf, smi_data_buf + pos, ret);
167out: 168out:
168 up(&smi_data_lock); 169 mutex_unlock(&smi_data_lock);
169 return ret; 170 return ret;
170} 171}
171 172
@@ -174,7 +175,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
174{ 175{
175 ssize_t ret; 176 ssize_t ret;
176 177
177 down(&smi_data_lock); 178 mutex_lock(&smi_data_lock);
178 179
179 ret = smi_data_buf_realloc(pos + count); 180 ret = smi_data_buf_realloc(pos + count);
180 if (ret) 181 if (ret)
@@ -183,7 +184,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
183 memcpy(smi_data_buf + pos, buf, count); 184 memcpy(smi_data_buf + pos, buf, count);
184 ret = count; 185 ret = count;
185out: 186out:
186 up(&smi_data_lock); 187 mutex_unlock(&smi_data_lock);
187 return ret; 188 return ret;
188} 189}
189 190
@@ -201,9 +202,9 @@ static ssize_t host_control_action_store(struct device *dev,
201 ssize_t ret; 202 ssize_t ret;
202 203
203 /* make sure buffer is available for host control command */ 204 /* make sure buffer is available for host control command */
204 down(&smi_data_lock); 205 mutex_lock(&smi_data_lock);
205 ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); 206 ret = smi_data_buf_realloc(sizeof(struct apm_cmd));
206 up(&smi_data_lock); 207 mutex_unlock(&smi_data_lock);
207 if (ret) 208 if (ret)
208 return ret; 209 return ret;
209 210
@@ -302,7 +303,7 @@ static ssize_t smi_request_store(struct device *dev,
302 unsigned long val = simple_strtoul(buf, NULL, 10); 303 unsigned long val = simple_strtoul(buf, NULL, 10);
303 ssize_t ret; 304 ssize_t ret;
304 305
305 down(&smi_data_lock); 306 mutex_lock(&smi_data_lock);
306 307
307 if (smi_data_buf_size < sizeof(struct smi_cmd)) { 308 if (smi_data_buf_size < sizeof(struct smi_cmd)) {
308 ret = -ENODEV; 309 ret = -ENODEV;
@@ -334,7 +335,7 @@ static ssize_t smi_request_store(struct device *dev,
334 } 335 }
335 336
336out: 337out:
337 up(&smi_data_lock); 338 mutex_unlock(&smi_data_lock);
338 return ret; 339 return ret;
339} 340}
340 341
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3325660f7248..c7671e188017 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -313,6 +313,7 @@
313#include <linux/cdrom.h> 313#include <linux/cdrom.h>
314#include <linux/ide.h> 314#include <linux/ide.h>
315#include <linux/completion.h> 315#include <linux/completion.h>
316#include <linux/mutex.h>
316 317
317#include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ 318#include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */
318 319
@@ -324,7 +325,7 @@
324 325
325#include "ide-cd.h" 326#include "ide-cd.h"
326 327
327static DECLARE_MUTEX(idecd_ref_sem); 328static DEFINE_MUTEX(idecd_ref_mutex);
328 329
329#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) 330#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)
330 331
@@ -335,11 +336,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk)
335{ 336{
336 struct cdrom_info *cd = NULL; 337 struct cdrom_info *cd = NULL;
337 338
338 down(&idecd_ref_sem); 339 mutex_lock(&idecd_ref_mutex);
339 cd = ide_cd_g(disk); 340 cd = ide_cd_g(disk);
340 if (cd) 341 if (cd)
341 kref_get(&cd->kref); 342 kref_get(&cd->kref);
342 up(&idecd_ref_sem); 343 mutex_unlock(&idecd_ref_mutex);
343 return cd; 344 return cd;
344} 345}
345 346
@@ -347,9 +348,9 @@ static void ide_cd_release(struct kref *);
347 348
348static void ide_cd_put(struct cdrom_info *cd) 349static void ide_cd_put(struct cdrom_info *cd)
349{ 350{
350 down(&idecd_ref_sem); 351 mutex_lock(&idecd_ref_mutex);
351 kref_put(&cd->kref, ide_cd_release); 352 kref_put(&cd->kref, ide_cd_release);
352 up(&idecd_ref_sem); 353 mutex_unlock(&idecd_ref_mutex);
353} 354}
354 355
355/**************************************************************************** 356/****************************************************************************
@@ -2471,52 +2472,6 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
2471} 2472}
2472 2473
2473static 2474static
2474int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi,
2475 unsigned int cmd, unsigned long arg)
2476{
2477 struct packet_command cgc;
2478 char buffer[16];
2479 int stat;
2480
2481 init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
2482
2483 /* These will be moved into the Uniform layer shortly... */
2484 switch (cmd) {
2485 case CDROMSETSPINDOWN: {
2486 char spindown;
2487
2488 if (copy_from_user(&spindown, (void __user *) arg, sizeof(char)))
2489 return -EFAULT;
2490
2491 if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0)))
2492 return stat;
2493
2494 buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f);
2495
2496 return cdrom_mode_select(cdi, &cgc);
2497 }
2498
2499 case CDROMGETSPINDOWN: {
2500 char spindown;
2501
2502 if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0)))
2503 return stat;
2504
2505 spindown = buffer[11] & 0x0f;
2506
2507 if (copy_to_user((void __user *) arg, &spindown, sizeof (char)))
2508 return -EFAULT;
2509
2510 return 0;
2511 }
2512
2513 default:
2514 return -EINVAL;
2515 }
2516
2517}
2518
2519static
2520int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, 2475int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
2521 unsigned int cmd, void *arg) 2476 unsigned int cmd, void *arg)
2522 2477
@@ -2852,12 +2807,11 @@ static struct cdrom_device_ops ide_cdrom_dops = {
2852 .get_mcn = ide_cdrom_get_mcn, 2807 .get_mcn = ide_cdrom_get_mcn,
2853 .reset = ide_cdrom_reset, 2808 .reset = ide_cdrom_reset,
2854 .audio_ioctl = ide_cdrom_audio_ioctl, 2809 .audio_ioctl = ide_cdrom_audio_ioctl,
2855 .dev_ioctl = ide_cdrom_dev_ioctl,
2856 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | 2810 .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
2857 CDC_SELECT_SPEED | CDC_SELECT_DISC | 2811 CDC_SELECT_SPEED | CDC_SELECT_DISC |
2858 CDC_MULTI_SESSION | CDC_MCN | 2812 CDC_MULTI_SESSION | CDC_MCN |
2859 CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | 2813 CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET |
2860 CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R | 2814 CDC_DRIVE_STATUS | CDC_CD_R |
2861 CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | 2815 CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM |
2862 CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | 2816 CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW |
2863 CDC_MRW_W | CDC_RAM, 2817 CDC_MRW_W | CDC_RAM,
@@ -3367,6 +3321,45 @@ static int idecd_release(struct inode * inode, struct file * file)
3367 return 0; 3321 return 0;
3368} 3322}
3369 3323
3324static int idecd_set_spindown(struct cdrom_device_info *cdi, unsigned long arg)
3325{
3326 struct packet_command cgc;
3327 char buffer[16];
3328 int stat;
3329 char spindown;
3330
3331 if (copy_from_user(&spindown, (void __user *)arg, sizeof(char)))
3332 return -EFAULT;
3333
3334 init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
3335
3336 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0);
3337 if (stat)
3338 return stat;
3339
3340 buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f);
3341 return cdrom_mode_select(cdi, &cgc);
3342}
3343
3344static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
3345{
3346 struct packet_command cgc;
3347 char buffer[16];
3348 int stat;
3349 char spindown;
3350
3351 init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
3352
3353 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0);
3354 if (stat)
3355 return stat;
3356
3357 spindown = buffer[11] & 0x0f;
3358 if (copy_to_user((void __user *)arg, &spindown, sizeof (char)))
3359 return -EFAULT;
3360 return 0;
3361}
3362
3370static int idecd_ioctl (struct inode *inode, struct file *file, 3363static int idecd_ioctl (struct inode *inode, struct file *file,
3371 unsigned int cmd, unsigned long arg) 3364 unsigned int cmd, unsigned long arg)
3372{ 3365{
@@ -3374,7 +3367,16 @@ static int idecd_ioctl (struct inode *inode, struct file *file,
3374 struct cdrom_info *info = ide_cd_g(bdev->bd_disk); 3367 struct cdrom_info *info = ide_cd_g(bdev->bd_disk);
3375 int err; 3368 int err;
3376 3369
3377 err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); 3370 switch (cmd) {
3371 case CDROMSETSPINDOWN:
3372 return idecd_set_spindown(&info->devinfo, arg);
3373 case CDROMGETSPINDOWN:
3374 return idecd_get_spindown(&info->devinfo, arg);
3375 default:
3376 break;
3377 }
3378
3379 err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg);
3378 if (err == -EINVAL) 3380 if (err == -EINVAL)
3379 err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); 3381 err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg);
3380 3382
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 09086b8b6486..e238b7da824b 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -60,6 +60,7 @@
60#include <linux/genhd.h> 60#include <linux/genhd.h>
61#include <linux/slab.h> 61#include <linux/slab.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/mutex.h>
63 64
64#define _IDE_DISK 65#define _IDE_DISK
65 66
@@ -78,7 +79,7 @@ struct ide_disk_obj {
78 struct kref kref; 79 struct kref kref;
79}; 80};
80 81
81static DECLARE_MUTEX(idedisk_ref_sem); 82static DEFINE_MUTEX(idedisk_ref_mutex);
82 83
83#define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) 84#define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref)
84 85
@@ -89,11 +90,11 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
89{ 90{
90 struct ide_disk_obj *idkp = NULL; 91 struct ide_disk_obj *idkp = NULL;
91 92
92 down(&idedisk_ref_sem); 93 mutex_lock(&idedisk_ref_mutex);
93 idkp = ide_disk_g(disk); 94 idkp = ide_disk_g(disk);
94 if (idkp) 95 if (idkp)
95 kref_get(&idkp->kref); 96 kref_get(&idkp->kref);
96 up(&idedisk_ref_sem); 97 mutex_unlock(&idedisk_ref_mutex);
97 return idkp; 98 return idkp;
98} 99}
99 100
@@ -101,9 +102,9 @@ static void ide_disk_release(struct kref *);
101 102
102static void ide_disk_put(struct ide_disk_obj *idkp) 103static void ide_disk_put(struct ide_disk_obj *idkp)
103{ 104{
104 down(&idedisk_ref_sem); 105 mutex_lock(&idedisk_ref_mutex);
105 kref_put(&idkp->kref, ide_disk_release); 106 kref_put(&idkp->kref, ide_disk_release);
106 up(&idedisk_ref_sem); 107 mutex_unlock(&idedisk_ref_mutex);
107} 108}
108 109
109/* 110/*
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 1f8db9ac05d1..a53e3ce4a142 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -98,6 +98,7 @@
98#include <linux/cdrom.h> 98#include <linux/cdrom.h>
99#include <linux/ide.h> 99#include <linux/ide.h>
100#include <linux/bitops.h> 100#include <linux/bitops.h>
101#include <linux/mutex.h>
101 102
102#include <asm/byteorder.h> 103#include <asm/byteorder.h>
103#include <asm/irq.h> 104#include <asm/irq.h>
@@ -517,7 +518,7 @@ typedef struct {
517 u8 reserved[4]; 518 u8 reserved[4];
518} idefloppy_mode_parameter_header_t; 519} idefloppy_mode_parameter_header_t;
519 520
520static DECLARE_MUTEX(idefloppy_ref_sem); 521static DEFINE_MUTEX(idefloppy_ref_mutex);
521 522
522#define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) 523#define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref)
523 524
@@ -528,11 +529,11 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
528{ 529{
529 struct ide_floppy_obj *floppy = NULL; 530 struct ide_floppy_obj *floppy = NULL;
530 531
531 down(&idefloppy_ref_sem); 532 mutex_lock(&idefloppy_ref_mutex);
532 floppy = ide_floppy_g(disk); 533 floppy = ide_floppy_g(disk);
533 if (floppy) 534 if (floppy)
534 kref_get(&floppy->kref); 535 kref_get(&floppy->kref);
535 up(&idefloppy_ref_sem); 536 mutex_unlock(&idefloppy_ref_mutex);
536 return floppy; 537 return floppy;
537} 538}
538 539
@@ -540,9 +541,9 @@ static void ide_floppy_release(struct kref *);
540 541
541static void ide_floppy_put(struct ide_floppy_obj *floppy) 542static void ide_floppy_put(struct ide_floppy_obj *floppy)
542{ 543{
543 down(&idefloppy_ref_sem); 544 mutex_lock(&idefloppy_ref_mutex);
544 kref_put(&floppy->kref, ide_floppy_release); 545 kref_put(&floppy->kref, ide_floppy_release);
545 up(&idefloppy_ref_sem); 546 mutex_unlock(&idefloppy_ref_mutex);
546} 547}
547 548
548/* 549/*
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0101d0def7c5..ebc59064b475 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -443,6 +443,7 @@
443#include <linux/smp_lock.h> 443#include <linux/smp_lock.h>
444#include <linux/completion.h> 444#include <linux/completion.h>
445#include <linux/bitops.h> 445#include <linux/bitops.h>
446#include <linux/mutex.h>
446 447
447#include <asm/byteorder.h> 448#include <asm/byteorder.h>
448#include <asm/irq.h> 449#include <asm/irq.h>
@@ -1011,7 +1012,7 @@ typedef struct ide_tape_obj {
1011 int debug_level; 1012 int debug_level;
1012} idetape_tape_t; 1013} idetape_tape_t;
1013 1014
1014static DECLARE_MUTEX(idetape_ref_sem); 1015static DEFINE_MUTEX(idetape_ref_mutex);
1015 1016
1016static struct class *idetape_sysfs_class; 1017static struct class *idetape_sysfs_class;
1017 1018
@@ -1024,11 +1025,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
1024{ 1025{
1025 struct ide_tape_obj *tape = NULL; 1026 struct ide_tape_obj *tape = NULL;
1026 1027
1027 down(&idetape_ref_sem); 1028 mutex_lock(&idetape_ref_mutex);
1028 tape = ide_tape_g(disk); 1029 tape = ide_tape_g(disk);
1029 if (tape) 1030 if (tape)
1030 kref_get(&tape->kref); 1031 kref_get(&tape->kref);
1031 up(&idetape_ref_sem); 1032 mutex_unlock(&idetape_ref_mutex);
1032 return tape; 1033 return tape;
1033} 1034}
1034 1035
@@ -1036,9 +1037,9 @@ static void ide_tape_release(struct kref *);
1036 1037
1037static void ide_tape_put(struct ide_tape_obj *tape) 1038static void ide_tape_put(struct ide_tape_obj *tape)
1038{ 1039{
1039 down(&idetape_ref_sem); 1040 mutex_lock(&idetape_ref_mutex);
1040 kref_put(&tape->kref, ide_tape_release); 1041 kref_put(&tape->kref, ide_tape_release);
1041 up(&idetape_ref_sem); 1042 mutex_unlock(&idetape_ref_mutex);
1042} 1043}
1043 1044
1044/* 1045/*
@@ -1290,11 +1291,11 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
1290{ 1291{
1291 struct ide_tape_obj *tape = NULL; 1292 struct ide_tape_obj *tape = NULL;
1292 1293
1293 down(&idetape_ref_sem); 1294 mutex_lock(&idetape_ref_mutex);
1294 tape = idetape_devs[i]; 1295 tape = idetape_devs[i];
1295 if (tape) 1296 if (tape)
1296 kref_get(&tape->kref); 1297 kref_get(&tape->kref);
1297 up(&idetape_ref_sem); 1298 mutex_unlock(&idetape_ref_mutex);
1298 return tape; 1299 return tape;
1299} 1300}
1300 1301
@@ -4870,11 +4871,11 @@ static int ide_tape_probe(ide_drive_t *drive)
4870 4871
4871 drive->driver_data = tape; 4872 drive->driver_data = tape;
4872 4873
4873 down(&idetape_ref_sem); 4874 mutex_lock(&idetape_ref_mutex);
4874 for (minor = 0; idetape_devs[minor]; minor++) 4875 for (minor = 0; idetape_devs[minor]; minor++)
4875 ; 4876 ;
4876 idetape_devs[minor] = tape; 4877 idetape_devs[minor] = tape;
4877 up(&idetape_ref_sem); 4878 mutex_unlock(&idetape_ref_mutex);
4878 4879
4879 idetape_setup(drive, tape, minor); 4880 idetape_setup(drive, tape, minor);
4880 4881
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index feec40cf5900..8c4fcb9027b3 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -32,6 +32,7 @@
32#ifdef CONFIG_AVMB1_COMPAT 32#ifdef CONFIG_AVMB1_COMPAT
33#include <linux/b1lli.h> 33#include <linux/b1lli.h>
34#endif 34#endif
35#include <linux/mutex.h>
35 36
36static char *revision = "$Revision: 1.1.2.8 $"; 37static char *revision = "$Revision: 1.1.2.8 $";
37 38
@@ -66,7 +67,7 @@ LIST_HEAD(capi_drivers);
66DEFINE_RWLOCK(capi_drivers_list_lock); 67DEFINE_RWLOCK(capi_drivers_list_lock);
67 68
68static DEFINE_RWLOCK(application_lock); 69static DEFINE_RWLOCK(application_lock);
69static DECLARE_MUTEX(controller_sem); 70static DEFINE_MUTEX(controller_mutex);
70 71
71struct capi20_appl *capi_applications[CAPI_MAXAPPL]; 72struct capi20_appl *capi_applications[CAPI_MAXAPPL];
72struct capi_ctr *capi_cards[CAPI_MAXCONTR]; 73struct capi_ctr *capi_cards[CAPI_MAXCONTR];
@@ -395,20 +396,20 @@ attach_capi_ctr(struct capi_ctr *card)
395{ 396{
396 int i; 397 int i;
397 398
398 down(&controller_sem); 399 mutex_lock(&controller_mutex);
399 400
400 for (i = 0; i < CAPI_MAXCONTR; i++) { 401 for (i = 0; i < CAPI_MAXCONTR; i++) {
401 if (capi_cards[i] == NULL) 402 if (capi_cards[i] == NULL)
402 break; 403 break;
403 } 404 }
404 if (i == CAPI_MAXCONTR) { 405 if (i == CAPI_MAXCONTR) {
405 up(&controller_sem); 406 mutex_unlock(&controller_mutex);
406 printk(KERN_ERR "kcapi: out of controller slots\n"); 407 printk(KERN_ERR "kcapi: out of controller slots\n");
407 return -EBUSY; 408 return -EBUSY;
408 } 409 }
409 capi_cards[i] = card; 410 capi_cards[i] = card;
410 411
411 up(&controller_sem); 412 mutex_unlock(&controller_mutex);
412 413
413 card->nrecvctlpkt = 0; 414 card->nrecvctlpkt = 0;
414 card->nrecvdatapkt = 0; 415 card->nrecvdatapkt = 0;
@@ -531,13 +532,13 @@ u16 capi20_register(struct capi20_appl *ap)
531 532
532 write_unlock_irqrestore(&application_lock, flags); 533 write_unlock_irqrestore(&application_lock, flags);
533 534
534 down(&controller_sem); 535 mutex_lock(&controller_mutex);
535 for (i = 0; i < CAPI_MAXCONTR; i++) { 536 for (i = 0; i < CAPI_MAXCONTR; i++) {
536 if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) 537 if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING)
537 continue; 538 continue;
538 register_appl(capi_cards[i], applid, &ap->rparam); 539 register_appl(capi_cards[i], applid, &ap->rparam);
539 } 540 }
540 up(&controller_sem); 541 mutex_unlock(&controller_mutex);
541 542
542 if (showcapimsgs & 1) { 543 if (showcapimsgs & 1) {
543 printk(KERN_DEBUG "kcapi: appl %d up\n", applid); 544 printk(KERN_DEBUG "kcapi: appl %d up\n", applid);
@@ -560,13 +561,13 @@ u16 capi20_release(struct capi20_appl *ap)
560 capi_applications[ap->applid - 1] = NULL; 561 capi_applications[ap->applid - 1] = NULL;
561 write_unlock_irqrestore(&application_lock, flags); 562 write_unlock_irqrestore(&application_lock, flags);
562 563
563 down(&controller_sem); 564 mutex_lock(&controller_mutex);
564 for (i = 0; i < CAPI_MAXCONTR; i++) { 565 for (i = 0; i < CAPI_MAXCONTR; i++) {
565 if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) 566 if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING)
566 continue; 567 continue;
567 release_appl(capi_cards[i], ap->applid); 568 release_appl(capi_cards[i], ap->applid);
568 } 569 }
569 up(&controller_sem); 570 mutex_unlock(&controller_mutex);
570 571
571 flush_scheduled_work(); 572 flush_scheduled_work();
572 skb_queue_purge(&ap->recv_queue); 573 skb_queue_purge(&ap->recv_queue);
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index df9d65201819..27332506f9f7 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -25,7 +25,6 @@
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#define HISAX_STATUS_BUFSIZE 4096 27#define HISAX_STATUS_BUFSIZE 4096
28#define INCLUDE_INLINE_FUNCS
29 28
30/* 29/*
31 * This structure array contains one entry per card. An entry looks 30 * This structure array contains one entry per card. An entry looks
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 110e9fd669c5..f8ca4b323331 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -108,7 +108,6 @@ static const char *ITACVer[] =
108#define ELSA_ASSIGN 4 108#define ELSA_ASSIGN 4
109 109
110#define RS_ISR_PASS_LIMIT 256 110#define RS_ISR_PASS_LIMIT 256
111#define _INLINE_ inline
112#define FLG_MODEM_ACTIVE 1 111#define FLG_MODEM_ACTIVE 1
113/* IPAC AUX */ 112/* IPAC AUX */
114#define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */ 113#define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 69596f6438e9..431bd37225a1 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -550,15 +550,12 @@ static void macio_pci_add_devices(struct macio_chip *chip)
550 */ 550 */
551int macio_register_driver(struct macio_driver *drv) 551int macio_register_driver(struct macio_driver *drv)
552{ 552{
553 int count = 0;
554
555 /* initialize common driver fields */ 553 /* initialize common driver fields */
556 drv->driver.name = drv->name; 554 drv->driver.name = drv->name;
557 drv->driver.bus = &macio_bus_type; 555 drv->driver.bus = &macio_bus_type;
558 556
559 /* register with core */ 557 /* register with core */
560 count = driver_register(&drv->driver); 558 return driver_register(&drv->driver);
561 return count ? count : 1;
562} 559}
563 560
564/** 561/**
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index db2ae71d07ef..4eb05d7143d8 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -629,8 +629,6 @@ static struct of_platform_driver smu_of_platform_driver =
629 629
630static int __init smu_init_sysfs(void) 630static int __init smu_init_sysfs(void)
631{ 631{
632 int rc;
633
634 /* 632 /*
635 * Due to sysfs bogosity, a sysdev is not a real device, so 633 * Due to sysfs bogosity, a sysdev is not a real device, so
636 * we should in fact create both if we want sysdev semantics 634 * we should in fact create both if we want sysdev semantics
@@ -639,7 +637,7 @@ static int __init smu_init_sysfs(void)
639 * I'm a bit too far from figuring out how that works with those 637 * I'm a bit too far from figuring out how that works with those
640 * new chipsets, but that will come back and bite us 638 * new chipsets, but that will come back and bite us
641 */ 639 */
642 rc = of_register_driver(&smu_of_platform_driver); 640 of_register_driver(&smu_of_platform_driver);
643 return 0; 641 return 0;
644} 642}
645 643
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 4f50ee5767a2..231146f439dd 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -104,7 +104,6 @@
104#include <linux/kernel.h> 104#include <linux/kernel.h>
105#include <linux/delay.h> 105#include <linux/delay.h>
106#include <linux/sched.h> 106#include <linux/sched.h>
107#include <linux/i2c.h>
108#include <linux/slab.h> 107#include <linux/slab.h>
109#include <linux/init.h> 108#include <linux/init.h>
110#include <linux/spinlock.h> 109#include <linux/spinlock.h>
@@ -113,7 +112,6 @@
113#include <linux/reboot.h> 112#include <linux/reboot.h>
114#include <linux/kmod.h> 113#include <linux/kmod.h>
115#include <linux/i2c.h> 114#include <linux/i2c.h>
116#include <linux/i2c-dev.h>
117#include <asm/prom.h> 115#include <asm/prom.h>
118#include <asm/machdep.h> 116#include <asm/machdep.h>
119#include <asm/io.h> 117#include <asm/io.h>
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 4a478eb0e27d..4f5f3abc9cb3 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -161,7 +161,9 @@ static int drop_interrupts;
161#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 161#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
162static int option_lid_wakeup = 1; 162static int option_lid_wakeup = 1;
163#endif /* CONFIG_PM && CONFIG_PPC32 */ 163#endif /* CONFIG_PM && CONFIG_PPC32 */
164#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT)
164static int sleep_in_progress; 165static int sleep_in_progress;
166#endif
165static unsigned long async_req_locks; 167static unsigned long async_req_locks;
166static unsigned int pmu_irq_stats[11]; 168static unsigned int pmu_irq_stats[11];
167 169
@@ -2201,8 +2203,7 @@ pmac_wakeup_devices(void)
2201#define GRACKLE_NAP (1<<4) 2203#define GRACKLE_NAP (1<<4)
2202#define GRACKLE_SLEEP (1<<3) 2204#define GRACKLE_SLEEP (1<<3)
2203 2205
2204int 2206static int powerbook_sleep_grackle(void)
2205powerbook_sleep_grackle(void)
2206{ 2207{
2207 unsigned long save_l2cr; 2208 unsigned long save_l2cr;
2208 unsigned short pmcr1; 2209 unsigned short pmcr1;
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 423bfa2432c0..3f7967feaf5b 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -15,7 +15,6 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/wait.h> 16#include <linux/wait.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/i2c-dev.h>
19#include <asm/prom.h> 18#include <asm/prom.h>
20#include <asm/machdep.h> 19#include <asm/machdep.h>
21#include <asm/io.h> 20#include <asm/io.h>
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index 8e99d408fddd..eae1189d6c41 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -11,7 +11,6 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/i2c-dev.h>
15#include <asm/prom.h> 14#include <asm/prom.h>
16#include <asm/pmac_low_i2c.h> 15#include <asm/pmac_low_i2c.h>
17 16
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 24e51d5e97fc..e295a07a1ebc 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/wait.h> 14#include <linux/wait.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/i2c-dev.h>
17#include <asm/semaphore.h> 16#include <asm/semaphore.h>
18#include <asm/prom.h> 17#include <asm/prom.h>
19#include <asm/smu.h> 18#include <asm/smu.h>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 00993e8ba589..e20b849a22e8 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2172,6 +2172,7 @@ config BNX2
2172config SPIDER_NET 2172config SPIDER_NET
2173 tristate "Spider Gigabit Ethernet driver" 2173 tristate "Spider Gigabit Ethernet driver"
2174 depends on PCI && PPC_CELL 2174 depends on PCI && PPC_CELL
2175 select FW_LOADER
2175 help 2176 help
2176 This driver supports the Gigabit Ethernet chips present on the 2177 This driver supports the Gigabit Ethernet chips present on the
2177 Cell Processor-Based Blades from IBM. 2178 Cell Processor-Based Blades from IBM.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 00e72b12fb92..b90468aea077 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -58,8 +58,8 @@ obj-$(CONFIG_STNIC) += stnic.o 8390.o
58obj-$(CONFIG_FEALNX) += fealnx.o 58obj-$(CONFIG_FEALNX) += fealnx.o
59obj-$(CONFIG_TIGON3) += tg3.o 59obj-$(CONFIG_TIGON3) += tg3.o
60obj-$(CONFIG_BNX2) += bnx2.o 60obj-$(CONFIG_BNX2) += bnx2.o
61spidernet-y += spider_net.o spider_net_ethtool.o sungem_phy.o 61spidernet-y += spider_net.o spider_net_ethtool.o
62obj-$(CONFIG_SPIDER_NET) += spidernet.o 62obj-$(CONFIG_SPIDER_NET) += spidernet.o sungem_phy.o
63obj-$(CONFIG_TC35815) += tc35815.o 63obj-$(CONFIG_TC35815) += tc35815.o
64obj-$(CONFIG_SKGE) += skge.o 64obj-$(CONFIG_SKGE) += skge.o
65obj-$(CONFIG_SKY2) += sky2.o 65obj-$(CONFIG_SKY2) += sky2.o
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index cd0b1dccfb61..1363083b4d83 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -90,8 +90,6 @@ static void au1000_tx_timeout(struct net_device *);
90static int au1000_set_config(struct net_device *dev, struct ifmap *map); 90static int au1000_set_config(struct net_device *dev, struct ifmap *map);
91static void set_rx_mode(struct net_device *); 91static void set_rx_mode(struct net_device *);
92static struct net_device_stats *au1000_get_stats(struct net_device *); 92static struct net_device_stats *au1000_get_stats(struct net_device *);
93static inline void update_tx_stats(struct net_device *, u32, u32);
94static inline void update_rx_stats(struct net_device *, u32);
95static void au1000_timer(unsigned long); 93static void au1000_timer(unsigned long);
96static int au1000_ioctl(struct net_device *, struct ifreq *, int); 94static int au1000_ioctl(struct net_device *, struct ifreq *, int);
97static int mdio_read(struct net_device *, int, int); 95static int mdio_read(struct net_device *, int, int);
@@ -1825,16 +1823,11 @@ static void __exit au1000_cleanup_module(void)
1825 } 1823 }
1826} 1824}
1827 1825
1828 1826static void update_tx_stats(struct net_device *dev, u32 status)
1829static inline void
1830update_tx_stats(struct net_device *dev, u32 status, u32 pkt_len)
1831{ 1827{
1832 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1828 struct au1000_private *aup = (struct au1000_private *) dev->priv;
1833 struct net_device_stats *ps = &aup->stats; 1829 struct net_device_stats *ps = &aup->stats;
1834 1830
1835 ps->tx_packets++;
1836 ps->tx_bytes += pkt_len;
1837
1838 if (status & TX_FRAME_ABORTED) { 1831 if (status & TX_FRAME_ABORTED) {
1839 if (dev->if_port == IF_PORT_100BASEFX) { 1832 if (dev->if_port == IF_PORT_100BASEFX) {
1840 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) { 1833 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) {
@@ -1867,7 +1860,7 @@ static void au1000_tx_ack(struct net_device *dev)
1867 ptxd = aup->tx_dma_ring[aup->tx_tail]; 1860 ptxd = aup->tx_dma_ring[aup->tx_tail];
1868 1861
1869 while (ptxd->buff_stat & TX_T_DONE) { 1862 while (ptxd->buff_stat & TX_T_DONE) {
1870 update_tx_stats(dev, ptxd->status, ptxd->len & 0x3ff); 1863 update_tx_stats(dev, ptxd->status);
1871 ptxd->buff_stat &= ~TX_T_DONE; 1864 ptxd->buff_stat &= ~TX_T_DONE;
1872 ptxd->len = 0; 1865 ptxd->len = 0;
1873 au_sync(); 1866 au_sync();
@@ -1889,6 +1882,7 @@ static void au1000_tx_ack(struct net_device *dev)
1889static int au1000_tx(struct sk_buff *skb, struct net_device *dev) 1882static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1890{ 1883{
1891 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1884 struct au1000_private *aup = (struct au1000_private *) dev->priv;
1885 struct net_device_stats *ps = &aup->stats;
1892 volatile tx_dma_t *ptxd; 1886 volatile tx_dma_t *ptxd;
1893 u32 buff_stat; 1887 u32 buff_stat;
1894 db_dest_t *pDB; 1888 db_dest_t *pDB;
@@ -1908,7 +1902,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1908 return 1; 1902 return 1;
1909 } 1903 }
1910 else if (buff_stat & TX_T_DONE) { 1904 else if (buff_stat & TX_T_DONE) {
1911 update_tx_stats(dev, ptxd->status, ptxd->len & 0x3ff); 1905 update_tx_stats(dev, ptxd->status);
1912 ptxd->len = 0; 1906 ptxd->len = 0;
1913 } 1907 }
1914 1908
@@ -1928,6 +1922,9 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1928 else 1922 else
1929 ptxd->len = skb->len; 1923 ptxd->len = skb->len;
1930 1924
1925 ps->tx_packets++;
1926 ps->tx_bytes += ptxd->len;
1927
1931 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE; 1928 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE;
1932 au_sync(); 1929 au_sync();
1933 dev_kfree_skb(skb); 1930 dev_kfree_skb(skb);
@@ -1936,7 +1933,6 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1936 return 0; 1933 return 0;
1937} 1934}
1938 1935
1939
1940static inline void update_rx_stats(struct net_device *dev, u32 status) 1936static inline void update_rx_stats(struct net_device *dev, u32 status)
1941{ 1937{
1942 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1938 struct au1000_private *aup = (struct au1000_private *) dev->priv;
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 03804cc38be0..0941d40f046f 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1412,7 +1412,7 @@ static int __init depca_mca_probe(struct device *device)
1412 irq = 11; 1412 irq = 11;
1413 break; 1413 break;
1414 default: 1414 default:
1415 printk("%s: mca_probe IRQ error. You should never get here (%d).\n", dev->name, where); 1415 printk("%s: mca_probe IRQ error. You should never get here (%d).\n", mdev->name, where);
1416 return -EINVAL; 1416 return -EINVAL;
1417 } 1417 }
1418 1418
diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c
index d82651a97bae..6f7dce8eba51 100644
--- a/drivers/net/ixp2000/enp2611.c
+++ b/drivers/net/ixp2000/enp2611.c
@@ -16,7 +16,7 @@
16#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <asm/arch/uengine.h> 19#include <asm/hardware/uengine.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include "ixpdev.h" 22#include "ixpdev.h"
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 09f03f493bea..77f104a005f3 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -16,7 +16,7 @@
16#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <asm/arch/uengine.h> 19#include <asm/hardware/uengine.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include "ixp2400_rx.ucode" 22#include "ixp2400_rx.ucode"
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 690a1aae0b34..0c13795dca38 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -172,11 +172,9 @@ static struct net_device_stats *get_stats(struct net_device *dev)
172 172
173 memset(stats, 0, sizeof(struct net_device_stats)); 173 memset(stats, 0, sizeof(struct net_device_stats));
174 174
175 for (i=0; i < NR_CPUS; i++) { 175 for_each_cpu(i) {
176 struct net_device_stats *lb_stats; 176 struct net_device_stats *lb_stats;
177 177
178 if (!cpu_possible(i))
179 continue;
180 lb_stats = &per_cpu(loopback_stats, i); 178 lb_stats = &per_cpu(loopback_stats, i);
181 stats->rx_bytes += lb_stats->rx_bytes; 179 stats->rx_bytes += lb_stats->rx_bytes;
182 stats->tx_bytes += lb_stats->tx_bytes; 180 stats->tx_bytes += lb_stats->tx_bytes;
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index f608c12e3e8b..b2073fce8216 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -46,6 +46,7 @@
46#include <linux/rwsem.h> 46#include <linux/rwsem.h>
47#include <linux/stddef.h> 47#include <linux/stddef.h>
48#include <linux/device.h> 48#include <linux/device.h>
49#include <linux/mutex.h>
49#include <net/slhc_vj.h> 50#include <net/slhc_vj.h>
50#include <asm/atomic.h> 51#include <asm/atomic.h>
51 52
@@ -198,11 +199,11 @@ static unsigned int cardmap_find_first_free(struct cardmap *map);
198static void cardmap_destroy(struct cardmap **map); 199static void cardmap_destroy(struct cardmap **map);
199 200
200/* 201/*
201 * all_ppp_sem protects the all_ppp_units mapping. 202 * all_ppp_mutex protects the all_ppp_units mapping.
202 * It also ensures that finding a ppp unit in the all_ppp_units map 203 * It also ensures that finding a ppp unit in the all_ppp_units map
203 * and updating its file.refcnt field is atomic. 204 * and updating its file.refcnt field is atomic.
204 */ 205 */
205static DECLARE_MUTEX(all_ppp_sem); 206static DEFINE_MUTEX(all_ppp_mutex);
206static struct cardmap *all_ppp_units; 207static struct cardmap *all_ppp_units;
207static atomic_t ppp_unit_count = ATOMIC_INIT(0); 208static atomic_t ppp_unit_count = ATOMIC_INIT(0);
208 209
@@ -804,7 +805,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
804 /* Attach to an existing ppp unit */ 805 /* Attach to an existing ppp unit */
805 if (get_user(unit, p)) 806 if (get_user(unit, p))
806 break; 807 break;
807 down(&all_ppp_sem); 808 mutex_lock(&all_ppp_mutex);
808 err = -ENXIO; 809 err = -ENXIO;
809 ppp = ppp_find_unit(unit); 810 ppp = ppp_find_unit(unit);
810 if (ppp != 0) { 811 if (ppp != 0) {
@@ -812,7 +813,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
812 file->private_data = &ppp->file; 813 file->private_data = &ppp->file;
813 err = 0; 814 err = 0;
814 } 815 }
815 up(&all_ppp_sem); 816 mutex_unlock(&all_ppp_mutex);
816 break; 817 break;
817 818
818 case PPPIOCATTCHAN: 819 case PPPIOCATTCHAN:
@@ -2446,7 +2447,7 @@ ppp_create_interface(int unit, int *retp)
2446 dev->do_ioctl = ppp_net_ioctl; 2447 dev->do_ioctl = ppp_net_ioctl;
2447 2448
2448 ret = -EEXIST; 2449 ret = -EEXIST;
2449 down(&all_ppp_sem); 2450 mutex_lock(&all_ppp_mutex);
2450 if (unit < 0) 2451 if (unit < 0)
2451 unit = cardmap_find_first_free(all_ppp_units); 2452 unit = cardmap_find_first_free(all_ppp_units);
2452 else if (cardmap_get(all_ppp_units, unit) != NULL) 2453 else if (cardmap_get(all_ppp_units, unit) != NULL)
@@ -2465,12 +2466,12 @@ ppp_create_interface(int unit, int *retp)
2465 2466
2466 atomic_inc(&ppp_unit_count); 2467 atomic_inc(&ppp_unit_count);
2467 cardmap_set(&all_ppp_units, unit, ppp); 2468 cardmap_set(&all_ppp_units, unit, ppp);
2468 up(&all_ppp_sem); 2469 mutex_unlock(&all_ppp_mutex);
2469 *retp = 0; 2470 *retp = 0;
2470 return ppp; 2471 return ppp;
2471 2472
2472out2: 2473out2:
2473 up(&all_ppp_sem); 2474 mutex_unlock(&all_ppp_mutex);
2474 free_netdev(dev); 2475 free_netdev(dev);
2475out1: 2476out1:
2476 kfree(ppp); 2477 kfree(ppp);
@@ -2500,7 +2501,7 @@ static void ppp_shutdown_interface(struct ppp *ppp)
2500{ 2501{
2501 struct net_device *dev; 2502 struct net_device *dev;
2502 2503
2503 down(&all_ppp_sem); 2504 mutex_lock(&all_ppp_mutex);
2504 ppp_lock(ppp); 2505 ppp_lock(ppp);
2505 dev = ppp->dev; 2506 dev = ppp->dev;
2506 ppp->dev = NULL; 2507 ppp->dev = NULL;
@@ -2514,7 +2515,7 @@ static void ppp_shutdown_interface(struct ppp *ppp)
2514 ppp->file.dead = 1; 2515 ppp->file.dead = 1;
2515 ppp->owner = NULL; 2516 ppp->owner = NULL;
2516 wake_up_interruptible(&ppp->file.rwait); 2517 wake_up_interruptible(&ppp->file.rwait);
2517 up(&all_ppp_sem); 2518 mutex_unlock(&all_ppp_mutex);
2518} 2519}
2519 2520
2520/* 2521/*
@@ -2556,7 +2557,7 @@ static void ppp_destroy_interface(struct ppp *ppp)
2556 2557
2557/* 2558/*
2558 * Locate an existing ppp unit. 2559 * Locate an existing ppp unit.
2559 * The caller should have locked the all_ppp_sem. 2560 * The caller should have locked the all_ppp_mutex.
2560 */ 2561 */
2561static struct ppp * 2562static struct ppp *
2562ppp_find_unit(int unit) 2563ppp_find_unit(int unit)
@@ -2601,7 +2602,7 @@ ppp_connect_channel(struct channel *pch, int unit)
2601 int ret = -ENXIO; 2602 int ret = -ENXIO;
2602 int hdrlen; 2603 int hdrlen;
2603 2604
2604 down(&all_ppp_sem); 2605 mutex_lock(&all_ppp_mutex);
2605 ppp = ppp_find_unit(unit); 2606 ppp = ppp_find_unit(unit);
2606 if (ppp == 0) 2607 if (ppp == 0)
2607 goto out; 2608 goto out;
@@ -2626,7 +2627,7 @@ ppp_connect_channel(struct channel *pch, int unit)
2626 outl: 2627 outl:
2627 write_unlock_bh(&pch->upl); 2628 write_unlock_bh(&pch->upl);
2628 out: 2629 out:
2629 up(&all_ppp_sem); 2630 mutex_unlock(&all_ppp_mutex);
2630 return ret; 2631 return ret;
2631} 2632}
2632 2633
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index a1cb07cdb60f..253440a98022 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -128,6 +128,7 @@ static const struct mii_chip_info {
128 { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN }, 128 { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN },
129 { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN }, 129 { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN },
130 { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN }, 130 { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN },
131 { "ADM 7001 LAN PHY", 0x002e, 0xcc60, LAN },
131 { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN }, 132 { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN },
132 { "AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, HOME}, 133 { "AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, HOME},
133 { "ICS LAN PHY", 0x0015, 0xF440, LAN }, 134 { "ICS LAN PHY", 0x0015, 0xF440, LAN },
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 4eda81d41b10..35dbf05c7f06 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -44,7 +44,7 @@
44#include "skge.h" 44#include "skge.h"
45 45
46#define DRV_NAME "skge" 46#define DRV_NAME "skge"
47#define DRV_VERSION "1.4" 47#define DRV_VERSION "1.5"
48#define PFX DRV_NAME " " 48#define PFX DRV_NAME " "
49 49
50#define DEFAULT_TX_RING_SIZE 128 50#define DEFAULT_TX_RING_SIZE 128
@@ -357,7 +357,7 @@ static struct net_device_stats *skge_get_stats(struct net_device *dev)
357 skge->net_stats.rx_bytes = data[1]; 357 skge->net_stats.rx_bytes = data[1];
358 skge->net_stats.tx_packets = data[2] + data[4] + data[6]; 358 skge->net_stats.tx_packets = data[2] + data[4] + data[6];
359 skge->net_stats.rx_packets = data[3] + data[5] + data[7]; 359 skge->net_stats.rx_packets = data[3] + data[5] + data[7];
360 skge->net_stats.multicast = data[5] + data[7]; 360 skge->net_stats.multicast = data[3] + data[5];
361 skge->net_stats.collisions = data[10]; 361 skge->net_stats.collisions = data[10];
362 skge->net_stats.tx_aborted_errors = data[12]; 362 skge->net_stats.tx_aborted_errors = data[12];
363 363
@@ -781,7 +781,7 @@ static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
781 * Note: DMA address is not changed by chip. 781 * Note: DMA address is not changed by chip.
782 * MTU not changed while receiver active. 782 * MTU not changed while receiver active.
783 */ 783 */
784static void skge_rx_reuse(struct skge_element *e, unsigned int size) 784static inline void skge_rx_reuse(struct skge_element *e, unsigned int size)
785{ 785{
786 struct skge_rx_desc *rd = e->desc; 786 struct skge_rx_desc *rd = e->desc;
787 787
@@ -829,7 +829,7 @@ static int skge_rx_fill(struct skge_port *skge)
829 do { 829 do {
830 struct sk_buff *skb; 830 struct sk_buff *skb;
831 831
832 skb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN); 832 skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
833 if (!skb) 833 if (!skb)
834 return -ENOMEM; 834 return -ENOMEM;
835 835
@@ -847,8 +847,7 @@ static void skge_link_up(struct skge_port *skge)
847 LED_BLK_OFF|LED_SYNC_OFF|LED_ON); 847 LED_BLK_OFF|LED_SYNC_OFF|LED_ON);
848 848
849 netif_carrier_on(skge->netdev); 849 netif_carrier_on(skge->netdev);
850 if (skge->tx_avail > MAX_SKB_FRAGS + 1) 850 netif_wake_queue(skge->netdev);
851 netif_wake_queue(skge->netdev);
852 851
853 if (netif_msg_link(skge)) 852 if (netif_msg_link(skge))
854 printk(KERN_INFO PFX 853 printk(KERN_INFO PFX
@@ -2155,7 +2154,7 @@ static int skge_up(struct net_device *dev)
2155 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); 2154 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
2156 2155
2157 if (dev->mtu > RX_BUF_SIZE) 2156 if (dev->mtu > RX_BUF_SIZE)
2158 skge->rx_buf_size = dev->mtu + ETH_HLEN + NET_IP_ALIGN; 2157 skge->rx_buf_size = dev->mtu + ETH_HLEN;
2159 else 2158 else
2160 skge->rx_buf_size = RX_BUF_SIZE; 2159 skge->rx_buf_size = RX_BUF_SIZE;
2161 2160
@@ -2190,8 +2189,6 @@ static int skge_up(struct net_device *dev)
2190 if (err) 2189 if (err)
2191 goto free_rx_ring; 2190 goto free_rx_ring;
2192 2191
2193 skge->tx_avail = skge->tx_ring.count - 1;
2194
2195 /* Initialize MAC */ 2192 /* Initialize MAC */
2196 spin_lock_bh(&hw->phy_lock); 2193 spin_lock_bh(&hw->phy_lock);
2197 if (hw->chip_id == CHIP_ID_GENESIS) 2194 if (hw->chip_id == CHIP_ID_GENESIS)
@@ -2294,6 +2291,12 @@ static int skge_down(struct net_device *dev)
2294 return 0; 2291 return 0;
2295} 2292}
2296 2293
2294static inline int skge_avail(const struct skge_ring *ring)
2295{
2296 return ((ring->to_clean > ring->to_use) ? 0 : ring->count)
2297 + (ring->to_clean - ring->to_use) - 1;
2298}
2299
2297static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev) 2300static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2298{ 2301{
2299 struct skge_port *skge = netdev_priv(dev); 2302 struct skge_port *skge = netdev_priv(dev);
@@ -2314,7 +2317,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2314 return NETDEV_TX_LOCKED; 2317 return NETDEV_TX_LOCKED;
2315 } 2318 }
2316 2319
2317 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) { 2320 if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1)) {
2318 if (!netif_queue_stopped(dev)) { 2321 if (!netif_queue_stopped(dev)) {
2319 netif_stop_queue(dev); 2322 netif_stop_queue(dev);
2320 2323
@@ -2390,8 +2393,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2390 dev->name, e - ring->start, skb->len); 2393 dev->name, e - ring->start, skb->len);
2391 2394
2392 ring->to_use = e->next; 2395 ring->to_use = e->next;
2393 skge->tx_avail -= skb_shinfo(skb)->nr_frags + 1; 2396 if (skge_avail(&skge->tx_ring) <= MAX_SKB_FRAGS + 1) {
2394 if (skge->tx_avail <= MAX_SKB_FRAGS + 1) {
2395 pr_debug("%s: transmit queue full\n", dev->name); 2397 pr_debug("%s: transmit queue full\n", dev->name);
2396 netif_stop_queue(dev); 2398 netif_stop_queue(dev);
2397 } 2399 }
@@ -2404,35 +2406,37 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2404 return NETDEV_TX_OK; 2406 return NETDEV_TX_OK;
2405} 2407}
2406 2408
2407static inline void skge_tx_free(struct skge_hw *hw, struct skge_element *e) 2409static void skge_tx_complete(struct skge_port *skge, struct skge_element *last)
2408{ 2410{
2409 /* This ring element can be skb or fragment */ 2411 struct pci_dev *pdev = skge->hw->pdev;
2410 if (e->skb) { 2412 struct skge_element *e;
2411 pci_unmap_single(hw->pdev, 2413
2412 pci_unmap_addr(e, mapaddr), 2414 for (e = skge->tx_ring.to_clean; e != last; e = e->next) {
2413 pci_unmap_len(e, maplen), 2415 struct sk_buff *skb = e->skb;
2414 PCI_DMA_TODEVICE); 2416 int i;
2415 dev_kfree_skb(e->skb); 2417
2416 e->skb = NULL; 2418 e->skb = NULL;
2417 } else { 2419 pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr),
2418 pci_unmap_page(hw->pdev, 2420 skb_headlen(skb), PCI_DMA_TODEVICE);
2419 pci_unmap_addr(e, mapaddr), 2421
2420 pci_unmap_len(e, maplen), 2422 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2421 PCI_DMA_TODEVICE); 2423 e = e->next;
2424 pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr),
2425 skb_shinfo(skb)->frags[i].size,
2426 PCI_DMA_TODEVICE);
2427 }
2428
2429 dev_kfree_skb(skb);
2422 } 2430 }
2431 skge->tx_ring.to_clean = e;
2423} 2432}
2424 2433
2425static void skge_tx_clean(struct skge_port *skge) 2434static void skge_tx_clean(struct skge_port *skge)
2426{ 2435{
2427 struct skge_ring *ring = &skge->tx_ring;
2428 struct skge_element *e;
2429 2436
2430 spin_lock_bh(&skge->tx_lock); 2437 spin_lock_bh(&skge->tx_lock);
2431 for (e = ring->to_clean; e != ring->to_use; e = e->next) { 2438 skge_tx_complete(skge, skge->tx_ring.to_use);
2432 ++skge->tx_avail; 2439 netif_wake_queue(skge->netdev);
2433 skge_tx_free(skge->hw, e);
2434 }
2435 ring->to_clean = e;
2436 spin_unlock_bh(&skge->tx_lock); 2440 spin_unlock_bh(&skge->tx_lock);
2437} 2441}
2438 2442
@@ -2592,7 +2596,7 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
2592 goto error; 2596 goto error;
2593 2597
2594 if (len < RX_COPY_THRESHOLD) { 2598 if (len < RX_COPY_THRESHOLD) {
2595 skb = dev_alloc_skb(len + 2); 2599 skb = alloc_skb(len + 2, GFP_ATOMIC);
2596 if (!skb) 2600 if (!skb)
2597 goto resubmit; 2601 goto resubmit;
2598 2602
@@ -2607,10 +2611,11 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
2607 skge_rx_reuse(e, skge->rx_buf_size); 2611 skge_rx_reuse(e, skge->rx_buf_size);
2608 } else { 2612 } else {
2609 struct sk_buff *nskb; 2613 struct sk_buff *nskb;
2610 nskb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN); 2614 nskb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_ATOMIC);
2611 if (!nskb) 2615 if (!nskb)
2612 goto resubmit; 2616 goto resubmit;
2613 2617
2618 skb_reserve(nskb, NET_IP_ALIGN);
2614 pci_unmap_single(skge->hw->pdev, 2619 pci_unmap_single(skge->hw->pdev,
2615 pci_unmap_addr(e, mapaddr), 2620 pci_unmap_addr(e, mapaddr),
2616 pci_unmap_len(e, maplen), 2621 pci_unmap_len(e, maplen),
@@ -2661,30 +2666,29 @@ resubmit:
2661static void skge_tx_done(struct skge_port *skge) 2666static void skge_tx_done(struct skge_port *skge)
2662{ 2667{
2663 struct skge_ring *ring = &skge->tx_ring; 2668 struct skge_ring *ring = &skge->tx_ring;
2664 struct skge_element *e; 2669 struct skge_element *e, *last;
2665 2670
2666 spin_lock(&skge->tx_lock); 2671 spin_lock(&skge->tx_lock);
2667 for (e = ring->to_clean; prefetch(e->next), e != ring->to_use; e = e->next) { 2672 last = ring->to_clean;
2673 for (e = ring->to_clean; e != ring->to_use; e = e->next) {
2668 struct skge_tx_desc *td = e->desc; 2674 struct skge_tx_desc *td = e->desc;
2669 u32 control;
2670 2675
2671 rmb(); 2676 if (td->control & BMU_OWN)
2672 control = td->control;
2673 if (control & BMU_OWN)
2674 break; 2677 break;
2675 2678
2676 if (unlikely(netif_msg_tx_done(skge))) 2679 if (td->control & BMU_EOF) {
2677 printk(KERN_DEBUG PFX "%s: tx done slot %td status 0x%x\n", 2680 last = e->next;
2678 skge->netdev->name, e - ring->start, td->status); 2681 if (unlikely(netif_msg_tx_done(skge)))
2679 2682 printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
2680 skge_tx_free(skge->hw, e); 2683 skge->netdev->name, e - ring->start);
2681 e->skb = NULL; 2684 }
2682 ++skge->tx_avail;
2683 } 2685 }
2684 ring->to_clean = e; 2686
2687 skge_tx_complete(skge, last);
2688
2685 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F); 2689 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
2686 2690
2687 if (skge->tx_avail > MAX_SKB_FRAGS + 1) 2691 if (skge_avail(&skge->tx_ring) > MAX_SKB_FRAGS + 1)
2688 netif_wake_queue(skge->netdev); 2692 netif_wake_queue(skge->netdev);
2689 2693
2690 spin_unlock(&skge->tx_lock); 2694 spin_unlock(&skge->tx_lock);
@@ -2718,8 +2722,7 @@ static int skge_poll(struct net_device *dev, int *budget)
2718 netif_receive_skb(skb); 2722 netif_receive_skb(skb);
2719 2723
2720 ++work_done; 2724 ++work_done;
2721 } else 2725 }
2722 skge_rx_reuse(e, skge->rx_buf_size);
2723 } 2726 }
2724 ring->to_clean = e; 2727 ring->to_clean = e;
2725 2728
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 2efdacc290e5..1f1ce88c8186 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2418,7 +2418,6 @@ struct skge_port {
2418 int port; 2418 int port;
2419 2419
2420 spinlock_t tx_lock; 2420 spinlock_t tx_lock;
2421 u32 tx_avail;
2422 struct skge_ring tx_ring; 2421 struct skge_ring tx_ring;
2423 struct skge_ring rx_ring; 2422 struct skge_ring rx_ring;
2424 2423
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index f08fe6c884b2..68f9c206a620 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1175,7 +1175,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1175 /* just drop the packet if non-linear expansion fails */ 1175 /* just drop the packet if non-linear expansion fails */
1176 if (skb_header_cloned(skb) && 1176 if (skb_header_cloned(skb) &&
1177 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { 1177 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
1178 dev_kfree_skb_any(skb); 1178 dev_kfree_skb(skb);
1179 goto out_unlock; 1179 goto out_unlock;
1180 } 1180 }
1181 1181
@@ -1324,7 +1324,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1324 PCI_DMA_TODEVICE); 1324 PCI_DMA_TODEVICE);
1325 } 1325 }
1326 1326
1327 dev_kfree_skb_any(skb); 1327 dev_kfree_skb(skb);
1328 } 1328 }
1329 1329
1330 sky2->tx_cons = put; 1330 sky2->tx_cons = put;
@@ -2478,17 +2478,34 @@ static const struct sky2_stat {
2478 { "rx_unicast", GM_RXF_UC_OK }, 2478 { "rx_unicast", GM_RXF_UC_OK },
2479 { "tx_mac_pause", GM_TXF_MPAUSE }, 2479 { "tx_mac_pause", GM_TXF_MPAUSE },
2480 { "rx_mac_pause", GM_RXF_MPAUSE }, 2480 { "rx_mac_pause", GM_RXF_MPAUSE },
2481 { "collisions", GM_TXF_SNG_COL }, 2481 { "collisions", GM_TXF_COL },
2482 { "late_collision",GM_TXF_LAT_COL }, 2482 { "late_collision",GM_TXF_LAT_COL },
2483 { "aborted", GM_TXF_ABO_COL }, 2483 { "aborted", GM_TXF_ABO_COL },
2484 { "single_collisions", GM_TXF_SNG_COL },
2484 { "multi_collisions", GM_TXF_MUL_COL }, 2485 { "multi_collisions", GM_TXF_MUL_COL },
2485 { "fifo_underrun", GM_TXE_FIFO_UR }, 2486
2486 { "fifo_overflow", GM_RXE_FIFO_OV }, 2487 { "rx_short", GM_RXF_SHT },
2487 { "rx_toolong", GM_RXF_LNG_ERR },
2488 { "rx_jabber", GM_RXF_JAB_PKT },
2489 { "rx_runt", GM_RXE_FRAG }, 2488 { "rx_runt", GM_RXE_FRAG },
2489 { "rx_64_byte_packets", GM_RXF_64B },
2490 { "rx_65_to_127_byte_packets", GM_RXF_127B },
2491 { "rx_128_to_255_byte_packets", GM_RXF_255B },
2492 { "rx_256_to_511_byte_packets", GM_RXF_511B },
2493 { "rx_512_to_1023_byte_packets", GM_RXF_1023B },
2494 { "rx_1024_to_1518_byte_packets", GM_RXF_1518B },
2495 { "rx_1518_to_max_byte_packets", GM_RXF_MAX_SZ },
2490 { "rx_too_long", GM_RXF_LNG_ERR }, 2496 { "rx_too_long", GM_RXF_LNG_ERR },
2497 { "rx_fifo_overflow", GM_RXE_FIFO_OV },
2498 { "rx_jabber", GM_RXF_JAB_PKT },
2491 { "rx_fcs_error", GM_RXF_FCS_ERR }, 2499 { "rx_fcs_error", GM_RXF_FCS_ERR },
2500
2501 { "tx_64_byte_packets", GM_TXF_64B },
2502 { "tx_65_to_127_byte_packets", GM_TXF_127B },
2503 { "tx_128_to_255_byte_packets", GM_TXF_255B },
2504 { "tx_256_to_511_byte_packets", GM_TXF_511B },
2505 { "tx_512_to_1023_byte_packets", GM_TXF_1023B },
2506 { "tx_1024_to_1518_byte_packets", GM_TXF_1518B },
2507 { "tx_1519_to_max_byte_packets", GM_TXF_MAX_SZ },
2508 { "tx_fifo_underrun", GM_TXE_FIFO_UR },
2492}; 2509};
2493 2510
2494static u32 sky2_get_rx_csum(struct net_device *dev) 2511static u32 sky2_get_rx_csum(struct net_device *dev)
@@ -2590,7 +2607,7 @@ static struct net_device_stats *sky2_get_stats(struct net_device *dev)
2590 sky2->net_stats.rx_bytes = data[1]; 2607 sky2->net_stats.rx_bytes = data[1];
2591 sky2->net_stats.tx_packets = data[2] + data[4] + data[6]; 2608 sky2->net_stats.tx_packets = data[2] + data[4] + data[6];
2592 sky2->net_stats.rx_packets = data[3] + data[5] + data[7]; 2609 sky2->net_stats.rx_packets = data[3] + data[5] + data[7];
2593 sky2->net_stats.multicast = data[5] + data[7]; 2610 sky2->net_stats.multicast = data[3] + data[5];
2594 sky2->net_stats.collisions = data[10]; 2611 sky2->net_stats.collisions = data[10];
2595 sky2->net_stats.tx_aborted_errors = data[12]; 2612 sky2->net_stats.tx_aborted_errors = data[12];
2596 2613
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index d63cd5a1b71c..2838f661b393 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1373,23 +1373,23 @@ enum {
1373 GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */ 1373 GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */
1374 GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */ 1374 GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */
1375 GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */ 1375 GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */
1376/* MIB Counters */
1377 GM_MIB_CNT_BASE = 0x0100, /* Base Address of MIB Counters */
1378 GM_MIB_CNT_SIZE = 256,
1376}; 1379};
1377 1380
1378/* MIB Counters */
1379#define GM_MIB_CNT_BASE 0x0100 /* Base Address of MIB Counters */
1380#define GM_MIB_CNT_SIZE 44 /* Number of MIB Counters */
1381 1381
1382/* 1382/*
1383 * MIB Counters base address definitions (low word) - 1383 * MIB Counters base address definitions (low word) -
1384 * use offset 4 for access to high word (32 bit r/o) 1384 * use offset 4 for access to high word (32 bit r/o)
1385 */ 1385 */
1386enum { 1386enum {
1387 GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */ 1387 GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */
1388 GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */ 1388 GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */
1389 GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */ 1389 GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */
1390 GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */ 1390 GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */
1391 GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */ 1391 GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */
1392 /* GM_MIB_CNT_BASE + 40: reserved */ 1392
1393 GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */ 1393 GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */
1394 GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */ 1394 GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */
1395 GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */ 1395 GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */
@@ -1397,37 +1397,36 @@ enum {
1397 GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */ 1397 GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */
1398 GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */ 1398 GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */
1399 GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */ 1399 GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */
1400 GM_RXF_127B = GM_MIB_CNT_BASE + 104, /* 65-127 Byte Rx Frame */ 1400 GM_RXF_127B = GM_MIB_CNT_BASE + 104,/* 65-127 Byte Rx Frame */
1401 GM_RXF_255B = GM_MIB_CNT_BASE + 112, /* 128-255 Byte Rx Frame */ 1401 GM_RXF_255B = GM_MIB_CNT_BASE + 112,/* 128-255 Byte Rx Frame */
1402 GM_RXF_511B = GM_MIB_CNT_BASE + 120, /* 256-511 Byte Rx Frame */ 1402 GM_RXF_511B = GM_MIB_CNT_BASE + 120,/* 256-511 Byte Rx Frame */
1403 GM_RXF_1023B = GM_MIB_CNT_BASE + 128, /* 512-1023 Byte Rx Frame */ 1403 GM_RXF_1023B = GM_MIB_CNT_BASE + 128,/* 512-1023 Byte Rx Frame */
1404 GM_RXF_1518B = GM_MIB_CNT_BASE + 136, /* 1024-1518 Byte Rx Frame */ 1404 GM_RXF_1518B = GM_MIB_CNT_BASE + 136,/* 1024-1518 Byte Rx Frame */
1405 GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144, /* 1519-MaxSize Byte Rx Frame */ 1405 GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144,/* 1519-MaxSize Byte Rx Frame */
1406 GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152, /* Rx Frame too Long Error */ 1406 GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152,/* Rx Frame too Long Error */
1407 GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160, /* Rx Jabber Packet Frame */ 1407 GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160,/* Rx Jabber Packet Frame */
1408 /* GM_MIB_CNT_BASE + 168: reserved */ 1408
1409 GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176, /* Rx FIFO overflow Event */ 1409 GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176,/* Rx FIFO overflow Event */
1410 /* GM_MIB_CNT_BASE + 184: reserved */ 1410 GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192,/* Unicast Frames Xmitted OK */
1411 GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192, /* Unicast Frames Xmitted OK */ 1411 GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200,/* Broadcast Frames Xmitted OK */
1412 GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200, /* Broadcast Frames Xmitted OK */ 1412 GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208,/* Pause MAC Ctrl Frames Xmitted */
1413 GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208, /* Pause MAC Ctrl Frames Xmitted */ 1413 GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216,/* Multicast Frames Xmitted OK */
1414 GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216, /* Multicast Frames Xmitted OK */ 1414 GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224,/* Octets Transmitted OK Low */
1415 GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224, /* Octets Transmitted OK Low */ 1415 GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232,/* Octets Transmitted OK High */
1416 GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232, /* Octets Transmitted OK High */ 1416 GM_TXF_64B = GM_MIB_CNT_BASE + 240,/* 64 Byte Tx Frame */
1417 GM_TXF_64B = GM_MIB_CNT_BASE + 240, /* 64 Byte Tx Frame */ 1417 GM_TXF_127B = GM_MIB_CNT_BASE + 248,/* 65-127 Byte Tx Frame */
1418 GM_TXF_127B = GM_MIB_CNT_BASE + 248, /* 65-127 Byte Tx Frame */ 1418 GM_TXF_255B = GM_MIB_CNT_BASE + 256,/* 128-255 Byte Tx Frame */
1419 GM_TXF_255B = GM_MIB_CNT_BASE + 256, /* 128-255 Byte Tx Frame */ 1419 GM_TXF_511B = GM_MIB_CNT_BASE + 264,/* 256-511 Byte Tx Frame */
1420 GM_TXF_511B = GM_MIB_CNT_BASE + 264, /* 256-511 Byte Tx Frame */ 1420 GM_TXF_1023B = GM_MIB_CNT_BASE + 272,/* 512-1023 Byte Tx Frame */
1421 GM_TXF_1023B = GM_MIB_CNT_BASE + 272, /* 512-1023 Byte Tx Frame */ 1421 GM_TXF_1518B = GM_MIB_CNT_BASE + 280,/* 1024-1518 Byte Tx Frame */
1422 GM_TXF_1518B = GM_MIB_CNT_BASE + 280, /* 1024-1518 Byte Tx Frame */ 1422 GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288,/* 1519-MaxSize Byte Tx Frame */
1423 GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288, /* 1519-MaxSize Byte Tx Frame */ 1423
1424 1424 GM_TXF_COL = GM_MIB_CNT_BASE + 304,/* Tx Collision */
1425 GM_TXF_COL = GM_MIB_CNT_BASE + 304, /* Tx Collision */ 1425 GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312,/* Tx Late Collision */
1426 GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312, /* Tx Late Collision */ 1426 GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320,/* Tx aborted due to Exces. Col. */
1427 GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320, /* Tx aborted due to Exces. Col. */ 1427 GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328,/* Tx Multiple Collision */
1428 GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328, /* Tx Multiple Collision */ 1428 GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336,/* Tx Single Collision */
1429 GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336, /* Tx Single Collision */ 1429 GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344,/* Tx FIFO Underrun Event */
1430 GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344, /* Tx FIFO Underrun Event */
1431}; 1430};
1432 1431
1433/* GMAC Bit Definitions */ 1432/* GMAC Bit Definitions */
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 6299e186c73f..e3dd144d326b 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1327,11 +1327,11 @@ static void de_clean_rings (struct de_private *de)
1327 struct sk_buff *skb = de->tx_skb[i].skb; 1327 struct sk_buff *skb = de->tx_skb[i].skb;
1328 if ((skb) && (skb != DE_DUMMY_SKB)) { 1328 if ((skb) && (skb != DE_DUMMY_SKB)) {
1329 if (skb != DE_SETUP_SKB) { 1329 if (skb != DE_SETUP_SKB) {
1330 dev_kfree_skb(skb);
1331 de->net_stats.tx_dropped++; 1330 de->net_stats.tx_dropped++;
1332 pci_unmap_single(de->pdev, 1331 pci_unmap_single(de->pdev,
1333 de->tx_skb[i].mapping, 1332 de->tx_skb[i].mapping,
1334 skb->len, PCI_DMA_TODEVICE); 1333 skb->len, PCI_DMA_TODEVICE);
1334 dev_kfree_skb(skb);
1335 } else { 1335 } else {
1336 pci_unmap_single(de->pdev, 1336 pci_unmap_single(de->pdev,
1337 de->tx_skb[i].mapping, 1337 de->tx_skb[i].mapping,
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 78193e4bbdb5..330d3869b41e 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -38,9 +38,8 @@ void free_cpu_buffers(void)
38{ 38{
39 int i; 39 int i;
40 40
41 for_each_online_cpu(i) { 41 for_each_online_cpu(i)
42 vfree(cpu_buffer[i].buffer); 42 vfree(cpu_buffer[i].buffer);
43 }
44} 43}
45 44
46int alloc_cpu_buffers(void) 45int alloc_cpu_buffers(void)
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 10845253c9e0..d121644646b9 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -31,14 +31,8 @@ enum parport_pc_pci_cards {
31 netmos_9xx5_combo, 31 netmos_9xx5_combo,
32 netmos_9855, 32 netmos_9855,
33 avlab_1s1p, 33 avlab_1s1p,
34 avlab_1s1p_650,
35 avlab_1s1p_850,
36 avlab_1s2p, 34 avlab_1s2p,
37 avlab_1s2p_650,
38 avlab_1s2p_850,
39 avlab_2s1p, 35 avlab_2s1p,
40 avlab_2s1p_650,
41 avlab_2s1p_850,
42 siig_1s1p_10x, 36 siig_1s1p_10x,
43 siig_2s1p_10x, 37 siig_2s1p_10x,
44 siig_2p1s_20x, 38 siig_2p1s_20x,
@@ -85,14 +79,8 @@ static struct parport_pc_pci cards[] __devinitdata = {
85 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init }, 79 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init },
86 /* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init }, 80 /* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init },
87 /* avlab_1s1p */ { 1, { { 1, 2}, } }, 81 /* avlab_1s1p */ { 1, { { 1, 2}, } },
88 /* avlab_1s1p_650 */ { 1, { { 1, 2}, } },
89 /* avlab_1s1p_850 */ { 1, { { 1, 2}, } },
90 /* avlab_1s2p */ { 2, { { 1, 2}, { 3, 4 },} }, 82 /* avlab_1s2p */ { 2, { { 1, 2}, { 3, 4 },} },
91 /* avlab_1s2p_650 */ { 2, { { 1, 2}, { 3, 4 },} },
92 /* avlab_1s2p_850 */ { 2, { { 1, 2}, { 3, 4 },} },
93 /* avlab_2s1p */ { 1, { { 2, 3}, } }, 83 /* avlab_2s1p */ { 1, { { 2, 3}, } },
94 /* avlab_2s1p_650 */ { 1, { { 2, 3}, } },
95 /* avlab_2s1p_850 */ { 1, { { 2, 3}, } },
96 /* siig_1s1p_10x */ { 1, { { 3, 4 }, } }, 84 /* siig_1s1p_10x */ { 1, { { 3, 4 }, } },
97 /* siig_2s1p_10x */ { 1, { { 4, 5 }, } }, 85 /* siig_2s1p_10x */ { 1, { { 4, 5 }, } },
98 /* siig_2p1s_20x */ { 2, { { 1, 2 }, { 3, 4 }, } }, 86 /* siig_2p1s_20x */ { 2, { { 1, 2 }, { 3, 4 }, } },
@@ -119,15 +107,24 @@ static struct pci_device_id parport_serial_pci_tbl[] = {
119 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855, 107 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855,
120 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 }, 108 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 },
121 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 109 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
122 { 0x14db, 0x2110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p}, 110 { PCI_VENDOR_ID_AFAVLAB, 0x2110,
123 { 0x14db, 0x2111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_650}, 111 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
124 { 0x14db, 0x2112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_850}, 112 { PCI_VENDOR_ID_AFAVLAB, 0x2111,
125 { 0x14db, 0x2140, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p}, 113 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
126 { 0x14db, 0x2141, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p_650}, 114 { PCI_VENDOR_ID_AFAVLAB, 0x2112,
127 { 0x14db, 0x2142, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p_850}, 115 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
128 { 0x14db, 0x2160, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p}, 116 { PCI_VENDOR_ID_AFAVLAB, 0x2140,
129 { 0x14db, 0x2161, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p_650}, 117 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
130 { 0x14db, 0x2162, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p_850}, 118 { PCI_VENDOR_ID_AFAVLAB, 0x2141,
119 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
120 { PCI_VENDOR_ID_AFAVLAB, 0x2142,
121 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
122 { PCI_VENDOR_ID_AFAVLAB, 0x2160,
123 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
124 { PCI_VENDOR_ID_AFAVLAB, 0x2161,
125 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
126 { PCI_VENDOR_ID_AFAVLAB, 0x2162,
127 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
131 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_550, 128 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_550,
132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, siig_1s1p_10x }, 129 PCI_ANY_ID, PCI_ANY_ID, 0, 0, siig_1s1p_10x },
133 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_650, 130 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_650,
@@ -201,54 +198,18 @@ static struct pciserial_board pci_parport_serial_boards[] __devinitdata = {
201 .base_baud = 115200, 198 .base_baud = 115200,
202 .uart_offset = 8, 199 .uart_offset = 8,
203 }, 200 },
204 [avlab_1s1p_650] = { /* nt */
205 .flags = FL_BASE0 | FL_BASE_BARS,
206 .num_ports = 1,
207 .base_baud = 115200,
208 .uart_offset = 8,
209 },
210 [avlab_1s1p_850] = { /* nt */
211 .flags = FL_BASE0 | FL_BASE_BARS,
212 .num_ports = 1,
213 .base_baud = 115200,
214 .uart_offset = 8,
215 },
216 [avlab_1s2p] = { /* n/t */ 201 [avlab_1s2p] = { /* n/t */
217 .flags = FL_BASE0 | FL_BASE_BARS, 202 .flags = FL_BASE0 | FL_BASE_BARS,
218 .num_ports = 1, 203 .num_ports = 1,
219 .base_baud = 115200, 204 .base_baud = 115200,
220 .uart_offset = 8, 205 .uart_offset = 8,
221 }, 206 },
222 [avlab_1s2p_650] = { /* nt */
223 .flags = FL_BASE0 | FL_BASE_BARS,
224 .num_ports = 1,
225 .base_baud = 115200,
226 .uart_offset = 8,
227 },
228 [avlab_1s2p_850] = { /* nt */
229 .flags = FL_BASE0 | FL_BASE_BARS,
230 .num_ports = 1,
231 .base_baud = 115200,
232 .uart_offset = 8,
233 },
234 [avlab_2s1p] = { /* n/t */ 207 [avlab_2s1p] = { /* n/t */
235 .flags = FL_BASE0 | FL_BASE_BARS, 208 .flags = FL_BASE0 | FL_BASE_BARS,
236 .num_ports = 2, 209 .num_ports = 2,
237 .base_baud = 115200, 210 .base_baud = 115200,
238 .uart_offset = 8, 211 .uart_offset = 8,
239 }, 212 },
240 [avlab_2s1p_650] = { /* nt */
241 .flags = FL_BASE0 | FL_BASE_BARS,
242 .num_ports = 2,
243 .base_baud = 115200,
244 .uart_offset = 8,
245 },
246 [avlab_2s1p_850] = { /* nt */
247 .flags = FL_BASE0 | FL_BASE_BARS,
248 .num_ports = 2,
249 .base_baud = 115200,
250 .uart_offset = 8,
251 },
252 [siig_1s1p_10x] = { 213 [siig_1s1p_10x] = {
253 .flags = FL_BASE2, 214 .flags = FL_BASE2,
254 .num_ports = 1, 215 .num_ports = 1,
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 5e38cd7335f7..c89c98a2cca8 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -448,11 +448,7 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
448 break; 448 break;
449 449
450 case SMALL_TAG_END: 450 case SMALL_TAG_END:
451 if (option_independent != option) 451 return p + 2;
452 printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_ENDDEP tag\n");
453 p = p + 2;
454 return (unsigned char *)p;
455 break;
456 452
457 default: /* an unkown tag */ 453 default: /* an unkown tag */
458 len_err: 454 len_err:
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index fafeeae52675..f9930552ab54 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -151,9 +151,9 @@ dasd_ioctl_enable(struct block_device *bdev, int no, long args)
151 return -ENODEV; 151 return -ENODEV;
152 dasd_enable_device(device); 152 dasd_enable_device(device);
153 /* Formatting the dasd device can change the capacity. */ 153 /* Formatting the dasd device can change the capacity. */
154 down(&bdev->bd_sem); 154 mutex_lock(&bdev->bd_mutex);
155 i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); 155 i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9);
156 up(&bdev->bd_sem); 156 mutex_unlock(&bdev->bd_mutex);
157 return 0; 157 return 0;
158} 158}
159 159
@@ -184,9 +184,9 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args)
184 * Set i_size to zero, since read, write, etc. check against this 184 * Set i_size to zero, since read, write, etc. check against this
185 * value. 185 * value.
186 */ 186 */
187 down(&bdev->bd_sem); 187 mutex_lock(&bdev->bd_mutex);
188 i_size_write(bdev->bd_inode, 0); 188 i_size_write(bdev->bd_inode, 0);
189 up(&bdev->bd_sem); 189 mutex_unlock(&bdev->bd_mutex);
190 return 0; 190 return 0;
191} 191}
192 192
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index dba7f7f02e79..021cd5d08c61 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1364,7 +1364,7 @@ qeth_wait_for_buffer(struct qeth_channel *channel)
1364static void 1364static void
1365qeth_clear_cmd_buffers(struct qeth_channel *channel) 1365qeth_clear_cmd_buffers(struct qeth_channel *channel)
1366{ 1366{
1367 int cnt = 0; 1367 int cnt;
1368 1368
1369 for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++) 1369 for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++)
1370 qeth_release_buffer(channel,&channel->iob[cnt]); 1370 qeth_release_buffer(channel,&channel->iob[cnt]);
@@ -2814,11 +2814,11 @@ qeth_handle_send_error(struct qeth_card *card,
2814 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); 2814 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2815 return QETH_SEND_ERROR_LINK_FAILURE; 2815 return QETH_SEND_ERROR_LINK_FAILURE;
2816 case 3: 2816 case 3:
2817 default:
2817 QETH_DBF_TEXT(trace, 1, "SIGAcc3"); 2818 QETH_DBF_TEXT(trace, 1, "SIGAcc3");
2818 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); 2819 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2819 return QETH_SEND_ERROR_KICK_IT; 2820 return QETH_SEND_ERROR_KICK_IT;
2820 } 2821 }
2821 return QETH_SEND_ERROR_LINK_FAILURE;
2822} 2822}
2823 2823
2824void 2824void
@@ -3865,6 +3865,7 @@ qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
3865 if ((hdr_mac == QETH_TR_MAC_NC) || 3865 if ((hdr_mac == QETH_TR_MAC_NC) ||
3866 (hdr_mac == QETH_TR_MAC_C)) 3866 (hdr_mac == QETH_TR_MAC_C))
3867 return RTN_MULTICAST; 3867 return RTN_MULTICAST;
3868 break;
3868 /* eth or so multicast? */ 3869 /* eth or so multicast? */
3869 default: 3870 default:
3870 if ((hdr_mac == QETH_ETH_MAC_V4) || 3871 if ((hdr_mac == QETH_ETH_MAC_V4) ||
@@ -4419,6 +4420,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4419 int elements_needed = 0; 4420 int elements_needed = 0;
4420 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; 4421 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
4421 struct qeth_eddp_context *ctx = NULL; 4422 struct qeth_eddp_context *ctx = NULL;
4423 int tx_bytes = skb->len;
4422 int rc; 4424 int rc;
4423 4425
4424 QETH_DBF_TEXT(trace, 6, "sendpkt"); 4426 QETH_DBF_TEXT(trace, 6, "sendpkt");
@@ -4499,7 +4501,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4499 elements_needed, ctx); 4501 elements_needed, ctx);
4500 if (!rc){ 4502 if (!rc){
4501 card->stats.tx_packets++; 4503 card->stats.tx_packets++;
4502 card->stats.tx_bytes += skb->len; 4504 card->stats.tx_bytes += tx_bytes;
4503#ifdef CONFIG_QETH_PERF_STATS 4505#ifdef CONFIG_QETH_PERF_STATS
4504 if (skb_shinfo(skb)->tso_size && 4506 if (skb_shinfo(skb)->tso_size &&
4505 !(large_send == QETH_LARGE_SEND_NO)) { 4507 !(large_send == QETH_LARGE_SEND_NO)) {
@@ -4585,38 +4587,11 @@ qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
4585 case MII_NCONFIG: /* network interface config */ 4587 case MII_NCONFIG: /* network interface config */
4586 break; 4588 break;
4587 default: 4589 default:
4588 rc = 0;
4589 break; 4590 break;
4590 } 4591 }
4591 return rc; 4592 return rc;
4592} 4593}
4593 4594
4594static void
4595qeth_mdio_write(struct net_device *dev, int phy_id, int regnum, int value)
4596{
4597 switch(regnum){
4598 case MII_BMCR: /* Basic mode control register */
4599 case MII_BMSR: /* Basic mode status register */
4600 case MII_PHYSID1: /* PHYS ID 1 */
4601 case MII_PHYSID2: /* PHYS ID 2 */
4602 case MII_ADVERTISE: /* Advertisement control reg */
4603 case MII_LPA: /* Link partner ability reg */
4604 case MII_EXPANSION: /* Expansion register */
4605 case MII_DCOUNTER: /* disconnect counter */
4606 case MII_FCSCOUNTER: /* false carrier counter */
4607 case MII_NWAYTEST: /* N-way auto-neg test register */
4608 case MII_RERRCOUNTER: /* rx error counter */
4609 case MII_SREVISION: /* silicon revision */
4610 case MII_RESV1: /* reserved 1 */
4611 case MII_LBRERROR: /* loopback, rx, bypass error */
4612 case MII_PHYADDR: /* physical address */
4613 case MII_RESV2: /* reserved 2 */
4614 case MII_TPISTATUS: /* TPI status for 10mbps */
4615 case MII_NCONFIG: /* network interface config */
4616 default:
4617 break;
4618 }
4619}
4620 4595
4621static inline const char * 4596static inline const char *
4622qeth_arp_get_error_cause(int *rc) 4597qeth_arp_get_error_cause(int *rc)
@@ -5236,21 +5211,6 @@ qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5236 mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id, 5211 mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id,
5237 mii_data->reg_num); 5212 mii_data->reg_num);
5238 break; 5213 break;
5239 case SIOCSMIIREG:
5240 rc = -EOPNOTSUPP;
5241 break;
5242 /* TODO: remove return if qeth_mdio_write does something */
5243 if (!capable(CAP_NET_ADMIN)){
5244 rc = -EPERM;
5245 break;
5246 }
5247 mii_data = if_mii(rq);
5248 if (mii_data->phy_id != 0)
5249 rc = -EINVAL;
5250 else
5251 qeth_mdio_write(dev, mii_data->phy_id, mii_data->reg_num,
5252 mii_data->val_in);
5253 break;
5254 default: 5214 default:
5255 rc = -EOPNOTSUPP; 5215 rc = -EOPNOTSUPP;
5256 } 5216 }
@@ -6900,7 +6860,7 @@ qeth_send_setassparms(struct qeth_card *card, struct qeth_cmd_buffer *iob,
6900 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); 6860 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6901 if (len <= sizeof(__u32)) 6861 if (len <= sizeof(__u32))
6902 cmd->data.setassparms.data.flags_32bit = (__u32) data; 6862 cmd->data.setassparms.data.flags_32bit = (__u32) data;
6903 else if (len > sizeof(__u32)) 6863 else /* (len > sizeof(__u32)) */
6904 memcpy(&cmd->data.setassparms.data, (void *) data, len); 6864 memcpy(&cmd->data.setassparms.data, (void *) data, len);
6905 6865
6906 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param); 6866 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param);
@@ -7379,11 +7339,6 @@ qeth_setrouting_v6(struct qeth_card *card)
7379 qeth_correct_routing_type(card, &card->options.route6.type, 7339 qeth_correct_routing_type(card, &card->options.route6.type,
7380 QETH_PROT_IPV6); 7340 QETH_PROT_IPV6);
7381 7341
7382 if ((card->options.route6.type == NO_ROUTER) ||
7383 ((card->info.type == QETH_CARD_TYPE_OSAE) &&
7384 (card->options.route6.type == MULTICAST_ROUTER) &&
7385 !qeth_is_supported6(card,IPA_OSA_MC_ROUTER)))
7386 return 0;
7387 rc = qeth_send_setrouting(card, card->options.route6.type, 7342 rc = qeth_send_setrouting(card, card->options.route6.type,
7388 QETH_PROT_IPV6); 7343 QETH_PROT_IPV6);
7389 if (rc) { 7344 if (rc) {
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index 3c6339df879d..360d782c7ada 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -74,7 +74,7 @@ qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
74static inline const char * 74static inline const char *
75qeth_get_router_str(struct qeth_card *card, int ipv) 75qeth_get_router_str(struct qeth_card *card, int ipv)
76{ 76{
77 int routing_type = 0; 77 enum qeth_routing_types routing_type = NO_ROUTER;
78 78
79 if (ipv == 4) { 79 if (ipv == 4) {
80 routing_type = card->options.route4.type; 80 routing_type = card->options.route4.type;
@@ -86,26 +86,26 @@ qeth_get_router_str(struct qeth_card *card, int ipv)
86#endif /* CONFIG_QETH_IPV6 */ 86#endif /* CONFIG_QETH_IPV6 */
87 } 87 }
88 88
89 if (routing_type == PRIMARY_ROUTER) 89 switch (routing_type){
90 case PRIMARY_ROUTER:
90 return "pri"; 91 return "pri";
91 else if (routing_type == SECONDARY_ROUTER) 92 case SECONDARY_ROUTER:
92 return "sec"; 93 return "sec";
93 else if (routing_type == MULTICAST_ROUTER) { 94 case MULTICAST_ROUTER:
94 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) 95 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
95 return "mc+"; 96 return "mc+";
96 return "mc"; 97 return "mc";
97 } else if (routing_type == PRIMARY_CONNECTOR) { 98 case PRIMARY_CONNECTOR:
98 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) 99 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
99 return "p+c"; 100 return "p+c";
100 return "p.c"; 101 return "p.c";
101 } else if (routing_type == SECONDARY_CONNECTOR) { 102 case SECONDARY_CONNECTOR:
102 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) 103 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
103 return "s+c"; 104 return "s+c";
104 return "s.c"; 105 return "s.c";
105 } else if (routing_type == NO_ROUTER) 106 default: /* NO_ROUTER */
106 return "no"; 107 return "no";
107 else 108 }
108 return "unk";
109} 109}
110 110
111static int 111static int
@@ -192,27 +192,27 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
192 CARD_DDEV_ID(card), 192 CARD_DDEV_ID(card),
193 QETH_CARD_IFNAME(card) 193 QETH_CARD_IFNAME(card)
194 ); 194 );
195 seq_printf(s, " Skb's/buffers received : %li/%i\n" 195 seq_printf(s, " Skb's/buffers received : %lu/%u\n"
196 " Skb's/buffers sent : %li/%i\n\n", 196 " Skb's/buffers sent : %lu/%u\n\n",
197 card->stats.rx_packets, card->perf_stats.bufs_rec, 197 card->stats.rx_packets, card->perf_stats.bufs_rec,
198 card->stats.tx_packets, card->perf_stats.bufs_sent 198 card->stats.tx_packets, card->perf_stats.bufs_sent
199 ); 199 );
200 seq_printf(s, " Skb's/buffers sent without packing : %li/%i\n" 200 seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n"
201 " Skb's/buffers sent with packing : %i/%i\n\n", 201 " Skb's/buffers sent with packing : %u/%u\n\n",
202 card->stats.tx_packets - card->perf_stats.skbs_sent_pack, 202 card->stats.tx_packets - card->perf_stats.skbs_sent_pack,
203 card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack, 203 card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack,
204 card->perf_stats.skbs_sent_pack, 204 card->perf_stats.skbs_sent_pack,
205 card->perf_stats.bufs_sent_pack 205 card->perf_stats.bufs_sent_pack
206 ); 206 );
207 seq_printf(s, " Skbs sent in SG mode : %i\n" 207 seq_printf(s, " Skbs sent in SG mode : %u\n"
208 " Skb fragments sent in SG mode : %i\n\n", 208 " Skb fragments sent in SG mode : %u\n\n",
209 card->perf_stats.sg_skbs_sent, 209 card->perf_stats.sg_skbs_sent,
210 card->perf_stats.sg_frags_sent); 210 card->perf_stats.sg_frags_sent);
211 seq_printf(s, " large_send tx (in Kbytes) : %i\n" 211 seq_printf(s, " large_send tx (in Kbytes) : %u\n"
212 " large_send count : %i\n\n", 212 " large_send count : %u\n\n",
213 card->perf_stats.large_send_bytes >> 10, 213 card->perf_stats.large_send_bytes >> 10,
214 card->perf_stats.large_send_cnt); 214 card->perf_stats.large_send_cnt);
215 seq_printf(s, " Packing state changes no pkg.->packing : %i/%i\n" 215 seq_printf(s, " Packing state changes no pkg.->packing : %u/%u\n"
216 " Watermarks L/H : %i/%i\n" 216 " Watermarks L/H : %i/%i\n"
217 " Current buffer usage (outbound q's) : " 217 " Current buffer usage (outbound q's) : "
218 "%i/%i/%i/%i\n\n", 218 "%i/%i/%i/%i\n\n",
@@ -229,16 +229,16 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
229 atomic_read(&card->qdio.out_qs[3]->used_buffers) 229 atomic_read(&card->qdio.out_qs[3]->used_buffers)
230 : 0 230 : 0
231 ); 231 );
232 seq_printf(s, " Inbound handler time (in us) : %i\n" 232 seq_printf(s, " Inbound handler time (in us) : %u\n"
233 " Inbound handler count : %i\n" 233 " Inbound handler count : %u\n"
234 " Inbound do_QDIO time (in us) : %i\n" 234 " Inbound do_QDIO time (in us) : %u\n"
235 " Inbound do_QDIO count : %i\n\n" 235 " Inbound do_QDIO count : %u\n\n"
236 " Outbound handler time (in us) : %i\n" 236 " Outbound handler time (in us) : %u\n"
237 " Outbound handler count : %i\n\n" 237 " Outbound handler count : %u\n\n"
238 " Outbound time (in us, incl QDIO) : %i\n" 238 " Outbound time (in us, incl QDIO) : %u\n"
239 " Outbound count : %i\n" 239 " Outbound count : %u\n"
240 " Outbound do_QDIO time (in us) : %i\n" 240 " Outbound do_QDIO time (in us) : %u\n"
241 " Outbound do_QDIO count : %i\n\n", 241 " Outbound do_QDIO count : %u\n\n",
242 card->perf_stats.inbound_time, 242 card->perf_stats.inbound_time,
243 card->perf_stats.inbound_cnt, 243 card->perf_stats.inbound_cnt,
244 card->perf_stats.inbound_do_qdio_time, 244 card->perf_stats.inbound_do_qdio_time,
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index c1831f572585..f2a076a2b2f1 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -115,7 +115,7 @@ qeth_dev_portno_store(struct device *dev, struct device_attribute *attr, const c
115 return -EPERM; 115 return -EPERM;
116 116
117 portno = simple_strtoul(buf, &tmp, 16); 117 portno = simple_strtoul(buf, &tmp, 16);
118 if ((portno < 0) || (portno > MAX_PORTNO)){ 118 if (portno > MAX_PORTNO){
119 PRINT_WARN("portno 0x%X is out of range\n", portno); 119 PRINT_WARN("portno 0x%X is out of range\n", portno);
120 return -EINVAL; 120 return -EINVAL;
121 } 121 }
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 5c94a5d4efc0..4035920ce3d8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -595,10 +595,10 @@ config SCSI_SATA_VIA
595 If unsure, say N. 595 If unsure, say N.
596 596
597config SCSI_SATA_VITESSE 597config SCSI_SATA_VITESSE
598 tristate "VITESSE VSC-7174 SATA support" 598 tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
599 depends on SCSI_SATA && PCI 599 depends on SCSI_SATA && PCI
600 help 600 help
601 This option enables support for Vitesse VSC7174 Serial ATA. 601 This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
602 602
603 If unsure, say N. 603 If unsure, say N.
604 604
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 15dc2e00e1b2..e513c3158ad9 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -117,7 +117,6 @@ obj-$(CONFIG_SCSI_PPA) += ppa.o
117obj-$(CONFIG_SCSI_IMM) += imm.o 117obj-$(CONFIG_SCSI_IMM) += imm.o
118obj-$(CONFIG_JAZZ_ESP) += NCR53C9x.o jazz_esp.o 118obj-$(CONFIG_JAZZ_ESP) += NCR53C9x.o jazz_esp.o
119obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o 119obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o
120obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
121obj-$(CONFIG_SCSI_FCAL) += fcal.o 120obj-$(CONFIG_SCSI_FCAL) += fcal.o
122obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o 121obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
123obj-$(CONFIG_SCSI_NSP32) += nsp32.o 122obj-$(CONFIG_SCSI_NSP32) += nsp32.o
@@ -148,6 +147,9 @@ obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o
148obj-$(CONFIG_CHR_DEV_SG) += sg.o 147obj-$(CONFIG_CHR_DEV_SG) += sg.o
149obj-$(CONFIG_CHR_DEV_SCH) += ch.o 148obj-$(CONFIG_CHR_DEV_SCH) += ch.o
150 149
150# This goes last, so that "real" scsi devices probe earlier
151obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
152
151scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 153scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
152 scsicam.o scsi_error.o scsi_lib.o \ 154 scsicam.o scsi_error.o scsi_lib.o \
153 scsi_scan.o scsi_sysfs.o \ 155 scsi_scan.o scsi_sysfs.o \
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index a1ddbba2cbdf..ffba65656a83 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -513,6 +513,138 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, u32 opts)
513 pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16); 513 pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
514} 514}
515 515
516static int ahci_poll_register(void __iomem *reg, u32 mask, u32 val,
517 unsigned long interval_msec,
518 unsigned long timeout_msec)
519{
520 unsigned long timeout;
521 u32 tmp;
522
523 timeout = jiffies + (timeout_msec * HZ) / 1000;
524 do {
525 tmp = readl(reg);
526 if ((tmp & mask) == val)
527 return 0;
528 msleep(interval_msec);
529 } while (time_before(jiffies, timeout));
530
531 return -1;
532}
533
534static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class)
535{
536 struct ahci_host_priv *hpriv = ap->host_set->private_data;
537 struct ahci_port_priv *pp = ap->private_data;
538 void __iomem *mmio = ap->host_set->mmio_base;
539 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
540 const u32 cmd_fis_len = 5; /* five dwords */
541 const char *reason = NULL;
542 struct ata_taskfile tf;
543 u8 *fis;
544 int rc;
545
546 DPRINTK("ENTER\n");
547
548 /* prepare for SRST (AHCI-1.1 10.4.1) */
549 rc = ahci_stop_engine(ap);
550 if (rc) {
551 reason = "failed to stop engine";
552 goto fail_restart;
553 }
554
555 /* check BUSY/DRQ, perform Command List Override if necessary */
556 ahci_tf_read(ap, &tf);
557 if (tf.command & (ATA_BUSY | ATA_DRQ)) {
558 u32 tmp;
559
560 if (!(hpriv->cap & HOST_CAP_CLO)) {
561 rc = -EIO;
562 reason = "port busy but no CLO";
563 goto fail_restart;
564 }
565
566 tmp = readl(port_mmio + PORT_CMD);
567 tmp |= PORT_CMD_CLO;
568 writel(tmp, port_mmio + PORT_CMD);
569 readl(port_mmio + PORT_CMD); /* flush */
570
571 if (ahci_poll_register(port_mmio + PORT_CMD, PORT_CMD_CLO, 0x0,
572 1, 500)) {
573 rc = -EIO;
574 reason = "CLO failed";
575 goto fail_restart;
576 }
577 }
578
579 /* restart engine */
580 ahci_start_engine(ap);
581
582 ata_tf_init(ap, &tf, 0);
583 fis = pp->cmd_tbl;
584
585 /* issue the first D2H Register FIS */
586 ahci_fill_cmd_slot(pp, cmd_fis_len | AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY);
587
588 tf.ctl |= ATA_SRST;
589 ata_tf_to_fis(&tf, fis, 0);
590 fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
591
592 writel(1, port_mmio + PORT_CMD_ISSUE);
593 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
594
595 if (ahci_poll_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x0, 1, 500)) {
596 rc = -EIO;
597 reason = "1st FIS failed";
598 goto fail;
599 }
600
601 /* spec says at least 5us, but be generous and sleep for 1ms */
602 msleep(1);
603
604 /* issue the second D2H Register FIS */
605 ahci_fill_cmd_slot(pp, cmd_fis_len);
606
607 tf.ctl &= ~ATA_SRST;
608 ata_tf_to_fis(&tf, fis, 0);
609 fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
610
611 writel(1, port_mmio + PORT_CMD_ISSUE);
612 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
613
614 /* spec mandates ">= 2ms" before checking status.
615 * We wait 150ms, because that was the magic delay used for
616 * ATAPI devices in Hale Landis's ATADRVR, for the period of time
617 * between when the ATA command register is written, and then
618 * status is checked. Because waiting for "a while" before
619 * checking status is fine, post SRST, we perform this magic
620 * delay here as well.
621 */
622 msleep(150);
623
624 *class = ATA_DEV_NONE;
625 if (sata_dev_present(ap)) {
626 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
627 rc = -EIO;
628 reason = "device not ready";
629 goto fail;
630 }
631 *class = ahci_dev_classify(ap);
632 }
633
634 DPRINTK("EXIT, class=%u\n", *class);
635 return 0;
636
637 fail_restart:
638 ahci_start_engine(ap);
639 fail:
640 if (verbose)
641 printk(KERN_ERR "ata%u: softreset failed (%s)\n",
642 ap->id, reason);
643 else
644 DPRINTK("EXIT, rc=%d reason=\"%s\"\n", rc, reason);
645 return rc;
646}
647
516static int ahci_hardreset(struct ata_port *ap, int verbose, unsigned int *class) 648static int ahci_hardreset(struct ata_port *ap, int verbose, unsigned int *class)
517{ 649{
518 int rc; 650 int rc;
@@ -553,7 +685,8 @@ static void ahci_postreset(struct ata_port *ap, unsigned int *class)
553 685
554static int ahci_probe_reset(struct ata_port *ap, unsigned int *classes) 686static int ahci_probe_reset(struct ata_port *ap, unsigned int *classes)
555{ 687{
556 return ata_drive_probe_reset(ap, NULL, NULL, ahci_hardreset, 688 return ata_drive_probe_reset(ap, ata_std_probeinit,
689 ahci_softreset, ahci_hardreset,
557 ahci_postreset, classes); 690 ahci_postreset, classes);
558} 691}
559 692
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 0cf0e4c7ac0c..39b760a24241 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -47,6 +47,7 @@
47#include <linux/ide.h> 47#include <linux/ide.h>
48#include <linux/scatterlist.h> 48#include <linux/scatterlist.h>
49#include <linux/delay.h> 49#include <linux/delay.h>
50#include <linux/mutex.h>
50 51
51#include <asm/io.h> 52#include <asm/io.h>
52#include <asm/bitops.h> 53#include <asm/bitops.h>
@@ -109,7 +110,7 @@ typedef struct ide_scsi_obj {
109 unsigned long log; /* log flags */ 110 unsigned long log; /* log flags */
110} idescsi_scsi_t; 111} idescsi_scsi_t;
111 112
112static DECLARE_MUTEX(idescsi_ref_sem); 113static DEFINE_MUTEX(idescsi_ref_mutex);
113 114
114#define ide_scsi_g(disk) \ 115#define ide_scsi_g(disk) \
115 container_of((disk)->private_data, struct ide_scsi_obj, driver) 116 container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -118,19 +119,19 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
118{ 119{
119 struct ide_scsi_obj *scsi = NULL; 120 struct ide_scsi_obj *scsi = NULL;
120 121
121 down(&idescsi_ref_sem); 122 mutex_lock(&idescsi_ref_mutex);
122 scsi = ide_scsi_g(disk); 123 scsi = ide_scsi_g(disk);
123 if (scsi) 124 if (scsi)
124 scsi_host_get(scsi->host); 125 scsi_host_get(scsi->host);
125 up(&idescsi_ref_sem); 126 mutex_unlock(&idescsi_ref_mutex);
126 return scsi; 127 return scsi;
127} 128}
128 129
129static void ide_scsi_put(struct ide_scsi_obj *scsi) 130static void ide_scsi_put(struct ide_scsi_obj *scsi)
130{ 131{
131 down(&idescsi_ref_sem); 132 mutex_lock(&idescsi_ref_mutex);
132 scsi_host_put(scsi->host); 133 scsi_host_put(scsi->host);
133 up(&idescsi_ref_sem); 134 mutex_unlock(&idescsi_ref_mutex);
134} 135}
135 136
136static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) 137static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host)
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index a93336adcd23..96b4d2160df8 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -214,6 +214,8 @@ static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile
214 * Issues MMIO write to ATA command register, with proper 214 * Issues MMIO write to ATA command register, with proper
215 * synchronization with interrupt handler / other threads. 215 * synchronization with interrupt handler / other threads.
216 * 216 *
217 * FIXME: missing write posting for 400nS delay enforcement
218 *
217 * LOCKING: 219 * LOCKING:
218 * spin_lock_irqsave(host_set lock) 220 * spin_lock_irqsave(host_set lock)
219 */ 221 */
@@ -648,6 +650,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
648 goto err_out_regions; 650 goto err_out_regions;
649 } 651 }
650 652
653 /* FIXME: If we get no DMA mask we should fall back to PIO */
651 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 654 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
652 if (rc) 655 if (rc)
653 goto err_out_regions; 656 goto err_out_regions;
@@ -699,5 +702,41 @@ err_out:
699 return rc; 702 return rc;
700} 703}
701 704
705/**
706 * ata_pci_clear_simplex - attempt to kick device out of simplex
707 * @pdev: PCI device
708 *
709 * Some PCI ATA devices report simplex mode but in fact can be told to
710 * enter non simplex mode. This implements the neccessary logic to
711 * perform the task on such devices. Calling it on other devices will
712 * have -undefined- behaviour.
713 */
714
715int ata_pci_clear_simplex(struct pci_dev *pdev)
716{
717 unsigned long bmdma = pci_resource_start(pdev, 4);
718 u8 simplex;
719
720 if (bmdma == 0)
721 return -ENOENT;
722
723 simplex = inb(bmdma + 0x02);
724 outb(simplex & 0x60, bmdma + 0x02);
725 simplex = inb(bmdma + 0x02);
726 if (simplex & 0x80)
727 return -EOPNOTSUPP;
728 return 0;
729}
730
731unsigned long ata_pci_default_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long xfer_mask)
732{
733 /* Filter out DMA modes if the device has been configured by
734 the BIOS as PIO only */
735
736 if (ap->ioaddr.bmdma_addr == 0)
737 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
738 return xfer_mask;
739}
740
702#endif /* CONFIG_PCI */ 741#endif /* CONFIG_PCI */
703 742
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 64dce00e9c46..0314abd97f2d 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -962,6 +962,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
962 spin_unlock_irqrestore(&ap->host_set->lock, flags); 962 spin_unlock_irqrestore(&ap->host_set->lock, flags);
963 963
964 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) { 964 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) {
965 ata_port_flush_task(ap);
966
965 spin_lock_irqsave(&ap->host_set->lock, flags); 967 spin_lock_irqsave(&ap->host_set->lock, flags);
966 968
967 /* We're racing with irq here. If we lose, the 969 /* We're racing with irq here. If we lose, the
@@ -1219,13 +1221,6 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1219 * common ATA, ATAPI feature tests 1221 * common ATA, ATAPI feature tests
1220 */ 1222 */
1221 1223
1222 /* we require DMA support (bits 8 of word 49) */
1223 if (!ata_id_has_dma(id)) {
1224 printk(KERN_DEBUG "ata%u: no dma\n", ap->id);
1225 rc = -EINVAL;
1226 goto err_out_nosup;
1227 }
1228
1229 /* find max transfer mode; for printk only */ 1224 /* find max transfer mode; for printk only */
1230 xfer_mask = ata_id_xfermask(id); 1225 xfer_mask = ata_id_xfermask(id);
1231 1226
@@ -1737,7 +1732,7 @@ static int ata_host_set_pio(struct ata_port *ap)
1737 continue; 1732 continue;
1738 1733
1739 if (!dev->pio_mode) { 1734 if (!dev->pio_mode) {
1740 printk(KERN_WARNING "ata%u: no PIO support\n", ap->id); 1735 printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i);
1741 return -1; 1736 return -1;
1742 } 1737 }
1743 1738
@@ -1999,9 +1994,19 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
1999 * status is checked. Because waiting for "a while" before 1994 * status is checked. Because waiting for "a while" before
2000 * checking status is fine, post SRST, we perform this magic 1995 * checking status is fine, post SRST, we perform this magic
2001 * delay here as well. 1996 * delay here as well.
1997 *
1998 * Old drivers/ide uses the 2mS rule and then waits for ready
2002 */ 1999 */
2003 msleep(150); 2000 msleep(150);
2004 2001
2002
2003 /* Before we perform post reset processing we want to see if
2004 the bus shows 0xFF because the odd clown forgets the D7 pulldown
2005 resistor */
2006
2007 if (ata_check_status(ap) == 0xFF)
2008 return 1; /* Positive is failure for some reason */
2009
2005 ata_bus_post_reset(ap, devmask); 2010 ata_bus_post_reset(ap, devmask);
2006 2011
2007 return 0; 2012 return 0;
@@ -2551,48 +2556,72 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
2551} 2556}
2552 2557
2553static const char * const ata_dma_blacklist [] = { 2558static const char * const ata_dma_blacklist [] = {
2554 "WDC AC11000H", 2559 "WDC AC11000H", NULL,
2555 "WDC AC22100H", 2560 "WDC AC22100H", NULL,
2556 "WDC AC32500H", 2561 "WDC AC32500H", NULL,
2557 "WDC AC33100H", 2562 "WDC AC33100H", NULL,
2558 "WDC AC31600H", 2563 "WDC AC31600H", NULL,
2559 "WDC AC32100H", 2564 "WDC AC32100H", "24.09P07",
2560 "WDC AC23200L", 2565 "WDC AC23200L", "21.10N21",
2561 "Compaq CRD-8241B", 2566 "Compaq CRD-8241B", NULL,
2562 "CRD-8400B", 2567 "CRD-8400B", NULL,
2563 "CRD-8480B", 2568 "CRD-8480B", NULL,
2564 "CRD-8482B", 2569 "CRD-8482B", NULL,
2565 "CRD-84", 2570 "CRD-84", NULL,
2566 "SanDisk SDP3B", 2571 "SanDisk SDP3B", NULL,
2567 "SanDisk SDP3B-64", 2572 "SanDisk SDP3B-64", NULL,
2568 "SANYO CD-ROM CRD", 2573 "SANYO CD-ROM CRD", NULL,
2569 "HITACHI CDR-8", 2574 "HITACHI CDR-8", NULL,
2570 "HITACHI CDR-8335", 2575 "HITACHI CDR-8335", NULL,
2571 "HITACHI CDR-8435", 2576 "HITACHI CDR-8435", NULL,
2572 "Toshiba CD-ROM XM-6202B", 2577 "Toshiba CD-ROM XM-6202B", NULL,
2573 "TOSHIBA CD-ROM XM-1702BC", 2578 "TOSHIBA CD-ROM XM-1702BC", NULL,
2574 "CD-532E-A", 2579 "CD-532E-A", NULL,
2575 "E-IDE CD-ROM CR-840", 2580 "E-IDE CD-ROM CR-840", NULL,
2576 "CD-ROM Drive/F5A", 2581 "CD-ROM Drive/F5A", NULL,
2577 "WPI CDD-820", 2582 "WPI CDD-820", NULL,
2578 "SAMSUNG CD-ROM SC-148C", 2583 "SAMSUNG CD-ROM SC-148C", NULL,
2579 "SAMSUNG CD-ROM SC", 2584 "SAMSUNG CD-ROM SC", NULL,
2580 "SanDisk SDP3B-64", 2585 "SanDisk SDP3B-64", NULL,
2581 "ATAPI CD-ROM DRIVE 40X MAXIMUM", 2586 "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,
2582 "_NEC DV5800A", 2587 "_NEC DV5800A", NULL,
2588 "SAMSUNG CD-ROM SN-124", "N001"
2583}; 2589};
2590
2591static int ata_strim(char *s, size_t len)
2592{
2593 len = strnlen(s, len);
2594
2595 /* ATAPI specifies that empty space is blank-filled; remove blanks */
2596 while ((len > 0) && (s[len - 1] == ' ')) {
2597 len--;
2598 s[len] = 0;
2599 }
2600 return len;
2601}
2584 2602
2585static int ata_dma_blacklisted(const struct ata_device *dev) 2603static int ata_dma_blacklisted(const struct ata_device *dev)
2586{ 2604{
2587 unsigned char model_num[41]; 2605 unsigned char model_num[40];
2606 unsigned char model_rev[16];
2607 unsigned int nlen, rlen;
2588 int i; 2608 int i;
2589 2609
2590 ata_id_c_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num)); 2610 ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
2591 2611 sizeof(model_num));
2592 for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i++) 2612 ata_id_string(dev->id, model_rev, ATA_ID_FW_REV_OFS,
2593 if (!strcmp(ata_dma_blacklist[i], model_num)) 2613 sizeof(model_rev));
2594 return 1; 2614 nlen = ata_strim(model_num, sizeof(model_num));
2615 rlen = ata_strim(model_rev, sizeof(model_rev));
2595 2616
2617 for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i += 2) {
2618 if (!strncmp(ata_dma_blacklist[i], model_num, nlen)) {
2619 if (ata_dma_blacklist[i+1] == NULL)
2620 return 1;
2621 if (!strncmp(ata_dma_blacklist[i], model_rev, rlen))
2622 return 1;
2623 }
2624 }
2596 return 0; 2625 return 0;
2597} 2626}
2598 2627
@@ -2863,6 +2892,8 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2863 ata_fill_sg(qc); 2892 ata_fill_sg(qc);
2864} 2893}
2865 2894
2895void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
2896
2866/** 2897/**
2867 * ata_sg_init_one - Associate command with memory buffer 2898 * ata_sg_init_one - Associate command with memory buffer
2868 * @qc: Command to be associated 2899 * @qc: Command to be associated
@@ -3907,7 +3938,6 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
3907 3938
3908 case ATA_PROT_ATAPI: 3939 case ATA_PROT_ATAPI:
3909 case ATA_PROT_PIO: 3940 case ATA_PROT_PIO:
3910 case ATA_PROT_PIO_MULT:
3911 if (ap->flags & ATA_FLAG_PIO_DMA) 3941 if (ap->flags & ATA_FLAG_PIO_DMA)
3912 return 1; 3942 return 1;
3913 3943
@@ -4199,14 +4229,17 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
4199 4229
4200void ata_bmdma_irq_clear(struct ata_port *ap) 4230void ata_bmdma_irq_clear(struct ata_port *ap)
4201{ 4231{
4202 if (ap->flags & ATA_FLAG_MMIO) { 4232 if (!ap->ioaddr.bmdma_addr)
4203 void __iomem *mmio = ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS; 4233 return;
4204 writeb(readb(mmio), mmio);
4205 } else {
4206 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4207 outb(inb(addr), addr);
4208 }
4209 4234
4235 if (ap->flags & ATA_FLAG_MMIO) {
4236 void __iomem *mmio =
4237 ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
4238 writeb(readb(mmio), mmio);
4239 } else {
4240 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4241 outb(inb(addr), addr);
4242 }
4210} 4243}
4211 4244
4212 4245
@@ -4337,9 +4370,9 @@ idle_irq:
4337 4370
4338#ifdef ATA_IRQ_TRAP 4371#ifdef ATA_IRQ_TRAP
4339 if ((ap->stats.idle_irq % 1000) == 0) { 4372 if ((ap->stats.idle_irq % 1000) == 0) {
4340 handled = 1;
4341 ata_irq_ack(ap, 0); /* debug trap */ 4373 ata_irq_ack(ap, 0); /* debug trap */
4342 printk(KERN_WARNING "ata%d: irq trap\n", ap->id); 4374 printk(KERN_WARNING "ata%d: irq trap\n", ap->id);
4375 return 1;
4343 } 4376 }
4344#endif 4377#endif
4345 return 0; /* irq not handled */ 4378 return 0; /* irq not handled */
@@ -5064,6 +5097,7 @@ EXPORT_SYMBOL_GPL(ata_port_stop);
5064EXPORT_SYMBOL_GPL(ata_host_stop); 5097EXPORT_SYMBOL_GPL(ata_host_stop);
5065EXPORT_SYMBOL_GPL(ata_interrupt); 5098EXPORT_SYMBOL_GPL(ata_interrupt);
5066EXPORT_SYMBOL_GPL(ata_qc_prep); 5099EXPORT_SYMBOL_GPL(ata_qc_prep);
5100EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
5067EXPORT_SYMBOL_GPL(ata_bmdma_setup); 5101EXPORT_SYMBOL_GPL(ata_bmdma_setup);
5068EXPORT_SYMBOL_GPL(ata_bmdma_start); 5102EXPORT_SYMBOL_GPL(ata_bmdma_start);
5069EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear); 5103EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear);
@@ -5109,6 +5143,8 @@ EXPORT_SYMBOL_GPL(ata_pci_init_one);
5109EXPORT_SYMBOL_GPL(ata_pci_remove_one); 5143EXPORT_SYMBOL_GPL(ata_pci_remove_one);
5110EXPORT_SYMBOL_GPL(ata_pci_device_suspend); 5144EXPORT_SYMBOL_GPL(ata_pci_device_suspend);
5111EXPORT_SYMBOL_GPL(ata_pci_device_resume); 5145EXPORT_SYMBOL_GPL(ata_pci_device_resume);
5146EXPORT_SYMBOL_GPL(ata_pci_default_filter);
5147EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
5112#endif /* CONFIG_PCI */ 5148#endif /* CONFIG_PCI */
5113 5149
5114EXPORT_SYMBOL_GPL(ata_device_suspend); 5150EXPORT_SYMBOL_GPL(ata_device_suspend);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index bd9f2176f79a..a1259b242b8e 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -521,13 +521,11 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
521 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", 521 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
522 id, drv_stat); 522 id, drv_stat);
523 523
524 /* For our last chance pick, use medium read error because 524 /* We need a sensible error return here, which is tricky, and one
525 * it's much more common than an ATA drive telling you a write 525 that won't cause people to do things like return a disk wrongly */
526 * has failed. 526 *sk = ABORTED_COMMAND;
527 */ 527 *asc = 0x00;
528 *sk = MEDIUM_ERROR; 528 *ascq = 0x00;
529 *asc = 0x11; /* "unrecovered read error" */
530 *ascq = 0x04; /* "auto-reallocation failed" */
531 529
532 translate_done: 530 translate_done:
533 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " 531 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to "
@@ -672,6 +670,41 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
672 } 670 }
673} 671}
674 672
673static void ata_scsi_sdev_config(struct scsi_device *sdev)
674{
675 sdev->use_10_for_rw = 1;
676 sdev->use_10_for_ms = 1;
677}
678
679static void ata_scsi_dev_config(struct scsi_device *sdev,
680 struct ata_device *dev)
681{
682 unsigned int max_sectors;
683
684 /* TODO: 2048 is an arbitrary number, not the
685 * hardware maximum. This should be increased to
686 * 65534 when Jens Axboe's patch for dynamically
687 * determining max_sectors is merged.
688 */
689 max_sectors = ATA_MAX_SECTORS;
690 if (dev->flags & ATA_DFLAG_LBA48)
691 max_sectors = 2048;
692 if (dev->max_sectors)
693 max_sectors = dev->max_sectors;
694
695 blk_queue_max_sectors(sdev->request_queue, max_sectors);
696
697 /*
698 * SATA DMA transfers must be multiples of 4 byte, so
699 * we need to pad ATAPI transfers using an extra sg.
700 * Decrement max hw segments accordingly.
701 */
702 if (dev->class == ATA_DEV_ATAPI) {
703 request_queue_t *q = sdev->request_queue;
704 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
705 }
706}
707
675/** 708/**
676 * ata_scsi_slave_config - Set SCSI device attributes 709 * ata_scsi_slave_config - Set SCSI device attributes
677 * @sdev: SCSI device to examine 710 * @sdev: SCSI device to examine
@@ -686,41 +719,18 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
686 719
687int ata_scsi_slave_config(struct scsi_device *sdev) 720int ata_scsi_slave_config(struct scsi_device *sdev)
688{ 721{
689 sdev->use_10_for_rw = 1; 722 ata_scsi_sdev_config(sdev);
690 sdev->use_10_for_ms = 1;
691 723
692 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); 724 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
693 725
694 if (sdev->id < ATA_MAX_DEVICES) { 726 if (sdev->id < ATA_MAX_DEVICES) {
695 struct ata_port *ap; 727 struct ata_port *ap;
696 struct ata_device *dev; 728 struct ata_device *dev;
697 unsigned int max_sectors;
698 729
699 ap = (struct ata_port *) &sdev->host->hostdata[0]; 730 ap = (struct ata_port *) &sdev->host->hostdata[0];
700 dev = &ap->device[sdev->id]; 731 dev = &ap->device[sdev->id];
701 732
702 /* TODO: 2048 is an arbitrary number, not the 733 ata_scsi_dev_config(sdev, dev);
703 * hardware maximum. This should be increased to
704 * 65534 when Jens Axboe's patch for dynamically
705 * determining max_sectors is merged.
706 */
707 max_sectors = ATA_MAX_SECTORS;
708 if (dev->flags & ATA_DFLAG_LBA48)
709 max_sectors = 2048;
710 if (dev->max_sectors)
711 max_sectors = dev->max_sectors;
712
713 blk_queue_max_sectors(sdev->request_queue, max_sectors);
714
715 /*
716 * SATA DMA transfers must be multiples of 4 byte, so
717 * we need to pad ATAPI transfers using an extra sg.
718 * Decrement max hw segments accordingly.
719 */
720 if (dev->class == ATA_DEV_ATAPI) {
721 request_queue_t *q = sdev->request_queue;
722 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
723 }
724 } 734 }
725 735
726 return 0; /* scsi layer doesn't check return value, sigh */ 736 return 0; /* scsi layer doesn't check return value, sigh */
@@ -1552,7 +1562,7 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1552 * @buflen: Response buffer length. 1562 * @buflen: Response buffer length.
1553 * 1563 *
1554 * Returns standard device identification data associated 1564 * Returns standard device identification data associated
1555 * with non-EVPD INQUIRY command output. 1565 * with non-VPD INQUIRY command output.
1556 * 1566 *
1557 * LOCKING: 1567 * LOCKING:
1558 * spin_lock_irqsave(host_set lock) 1568 * spin_lock_irqsave(host_set lock)
@@ -1603,12 +1613,12 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1603} 1613}
1604 1614
1605/** 1615/**
1606 * ata_scsiop_inq_00 - Simulate INQUIRY EVPD page 0, list of pages 1616 * ata_scsiop_inq_00 - Simulate INQUIRY VPD page 0, list of pages
1607 * @args: device IDENTIFY data / SCSI command of interest. 1617 * @args: device IDENTIFY data / SCSI command of interest.
1608 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1618 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1609 * @buflen: Response buffer length. 1619 * @buflen: Response buffer length.
1610 * 1620 *
1611 * Returns list of inquiry EVPD pages available. 1621 * Returns list of inquiry VPD pages available.
1612 * 1622 *
1613 * LOCKING: 1623 * LOCKING:
1614 * spin_lock_irqsave(host_set lock) 1624 * spin_lock_irqsave(host_set lock)
@@ -1622,7 +1632,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1622 0x80, /* page 0x80, unit serial no page */ 1632 0x80, /* page 0x80, unit serial no page */
1623 0x83 /* page 0x83, device ident page */ 1633 0x83 /* page 0x83, device ident page */
1624 }; 1634 };
1625 rbuf[3] = sizeof(pages); /* number of supported EVPD pages */ 1635 rbuf[3] = sizeof(pages); /* number of supported VPD pages */
1626 1636
1627 if (buflen > 6) 1637 if (buflen > 6)
1628 memcpy(rbuf + 4, pages, sizeof(pages)); 1638 memcpy(rbuf + 4, pages, sizeof(pages));
@@ -1631,7 +1641,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1631} 1641}
1632 1642
1633/** 1643/**
1634 * ata_scsiop_inq_80 - Simulate INQUIRY EVPD page 80, device serial number 1644 * ata_scsiop_inq_80 - Simulate INQUIRY VPD page 80, device serial number
1635 * @args: device IDENTIFY data / SCSI command of interest. 1645 * @args: device IDENTIFY data / SCSI command of interest.
1636 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1646 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1637 * @buflen: Response buffer length. 1647 * @buflen: Response buffer length.
@@ -1660,16 +1670,16 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1660 return 0; 1670 return 0;
1661} 1671}
1662 1672
1663static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1664
1665/** 1673/**
1666 * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity 1674 * ata_scsiop_inq_83 - Simulate INQUIRY VPD page 83, device identity
1667 * @args: device IDENTIFY data / SCSI command of interest. 1675 * @args: device IDENTIFY data / SCSI command of interest.
1668 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1676 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1669 * @buflen: Response buffer length. 1677 * @buflen: Response buffer length.
1670 * 1678 *
1671 * Returns device identification. Currently hardcoded to 1679 * Yields two logical unit device identification designators:
1672 * return "Linux ATA-SCSI simulator". 1680 * - vendor specific ASCII containing the ATA serial number
1681 * - SAT defined "t10 vendor id based" containing ASCII vendor
1682 * name ("ATA "), model and serial numbers.
1673 * 1683 *
1674 * LOCKING: 1684 * LOCKING:
1675 * spin_lock_irqsave(host_set lock) 1685 * spin_lock_irqsave(host_set lock)
@@ -1678,16 +1688,39 @@ static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1678unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, 1688unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1679 unsigned int buflen) 1689 unsigned int buflen)
1680{ 1690{
1681 rbuf[1] = 0x83; /* this page code */ 1691 int num;
1682 rbuf[3] = 4 + strlen(inq_83_str); /* page len */ 1692 const int sat_model_serial_desc_len = 68;
1693 const int ata_model_byte_len = 40;
1683 1694
1684 /* our one and only identification descriptor (vendor-specific) */ 1695 rbuf[1] = 0x83; /* this page code */
1685 if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) { 1696 num = 4;
1686 rbuf[4 + 0] = 2; /* code set: ASCII */ 1697
1687 rbuf[4 + 3] = strlen(inq_83_str); 1698 if (buflen > (ATA_SERNO_LEN + num + 3)) {
1688 memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str)); 1699 /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
1700 rbuf[num + 0] = 2;
1701 rbuf[num + 3] = ATA_SERNO_LEN;
1702 num += 4;
1703 ata_id_string(args->id, (unsigned char *) rbuf + num,
1704 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1705 num += ATA_SERNO_LEN;
1689 } 1706 }
1690 1707 if (buflen > (sat_model_serial_desc_len + num + 3)) {
1708 /* SAT defined lu model and serial numbers descriptor */
1709 /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
1710 rbuf[num + 0] = 2;
1711 rbuf[num + 1] = 1;
1712 rbuf[num + 3] = sat_model_serial_desc_len;
1713 num += 4;
1714 memcpy(rbuf + num, "ATA ", 8);
1715 num += 8;
1716 ata_id_string(args->id, (unsigned char *) rbuf + num,
1717 ATA_ID_PROD_OFS, ata_model_byte_len);
1718 num += ata_model_byte_len;
1719 ata_id_string(args->id, (unsigned char *) rbuf + num,
1720 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1721 num += ATA_SERNO_LEN;
1722 }
1723 rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */
1691 return 0; 1724 return 0;
1692} 1725}
1693 1726
@@ -2366,9 +2399,6 @@ ata_scsi_map_proto(u8 byte1)
2366 2399
2367 case 4: /* PIO Data-in */ 2400 case 4: /* PIO Data-in */
2368 case 5: /* PIO Data-out */ 2401 case 5: /* PIO Data-out */
2369 if (byte1 & 0xe0) {
2370 return ATA_PROT_PIO_MULT;
2371 }
2372 return ATA_PROT_PIO; 2402 return ATA_PROT_PIO;
2373 2403
2374 case 10: /* Device Reset */ 2404 case 10: /* Device Reset */
@@ -2407,6 +2437,10 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2407 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) 2437 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
2408 goto invalid_fld; 2438 goto invalid_fld;
2409 2439
2440 if (scsicmd[1] & 0xe0)
2441 /* PIO multi not supported yet */
2442 goto invalid_fld;
2443
2410 /* 2444 /*
2411 * 12 and 16 byte CDBs use different offsets to 2445 * 12 and 16 byte CDBs use different offsets to
2412 * provide the various register values. 2446 * provide the various register values.
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index b3dc5f85ae0b..3c85c4b66e19 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -321,7 +321,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
321 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); 321 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
322 i += 4; 322 i += 4;
323 323
324 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", nelem, 324 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
325 (unsigned long)addr, len); 325 (unsigned long)addr, len);
326 } 326 }
327 return i; 327 return i;
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 874c5be0843c..275ed9bd898c 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1262,6 +1262,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1262 void __iomem *port_mmio = mv_ap_base(ap); 1262 void __iomem *port_mmio = mv_ap_base(ap);
1263 struct mv_port_priv *pp = ap->private_data; 1263 struct mv_port_priv *pp = ap->private_data;
1264 u32 out_ptr; 1264 u32 out_ptr;
1265 u8 ata_status;
1265 1266
1266 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1267 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1267 1268
@@ -1269,6 +1270,8 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1269 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != 1270 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
1270 pp->rsp_consumer); 1271 pp->rsp_consumer);
1271 1272
1273 ata_status = pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT;
1274
1272 /* increment our consumer index... */ 1275 /* increment our consumer index... */
1273 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); 1276 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer);
1274 1277
@@ -1283,7 +1286,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1283 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1286 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1284 1287
1285 /* Return ATA status register for completed CRPB */ 1288 /* Return ATA status register for completed CRPB */
1286 return (pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT); 1289 return ata_status;
1287} 1290}
1288 1291
1289/** 1292/**
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 051e47d975ca..724f0ed6a52d 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -56,33 +56,35 @@
56#define DRV_NAME "sata_svw" 56#define DRV_NAME "sata_svw"
57#define DRV_VERSION "1.07" 57#define DRV_VERSION "1.07"
58 58
59/* Taskfile registers offsets */ 59enum {
60#define K2_SATA_TF_CMD_OFFSET 0x00 60 /* Taskfile registers offsets */
61#define K2_SATA_TF_DATA_OFFSET 0x00 61 K2_SATA_TF_CMD_OFFSET = 0x00,
62#define K2_SATA_TF_ERROR_OFFSET 0x04 62 K2_SATA_TF_DATA_OFFSET = 0x00,
63#define K2_SATA_TF_NSECT_OFFSET 0x08 63 K2_SATA_TF_ERROR_OFFSET = 0x04,
64#define K2_SATA_TF_LBAL_OFFSET 0x0c 64 K2_SATA_TF_NSECT_OFFSET = 0x08,
65#define K2_SATA_TF_LBAM_OFFSET 0x10 65 K2_SATA_TF_LBAL_OFFSET = 0x0c,
66#define K2_SATA_TF_LBAH_OFFSET 0x14 66 K2_SATA_TF_LBAM_OFFSET = 0x10,
67#define K2_SATA_TF_DEVICE_OFFSET 0x18 67 K2_SATA_TF_LBAH_OFFSET = 0x14,
68#define K2_SATA_TF_CMDSTAT_OFFSET 0x1c 68 K2_SATA_TF_DEVICE_OFFSET = 0x18,
69#define K2_SATA_TF_CTL_OFFSET 0x20 69 K2_SATA_TF_CMDSTAT_OFFSET = 0x1c,
70 70 K2_SATA_TF_CTL_OFFSET = 0x20,
71/* DMA base */ 71
72#define K2_SATA_DMA_CMD_OFFSET 0x30 72 /* DMA base */
73 73 K2_SATA_DMA_CMD_OFFSET = 0x30,
74/* SCRs base */ 74
75#define K2_SATA_SCR_STATUS_OFFSET 0x40 75 /* SCRs base */
76#define K2_SATA_SCR_ERROR_OFFSET 0x44 76 K2_SATA_SCR_STATUS_OFFSET = 0x40,
77#define K2_SATA_SCR_CONTROL_OFFSET 0x48 77 K2_SATA_SCR_ERROR_OFFSET = 0x44,
78 78 K2_SATA_SCR_CONTROL_OFFSET = 0x48,
79/* Others */ 79
80#define K2_SATA_SICR1_OFFSET 0x80 80 /* Others */
81#define K2_SATA_SICR2_OFFSET 0x84 81 K2_SATA_SICR1_OFFSET = 0x80,
82#define K2_SATA_SIM_OFFSET 0x88 82 K2_SATA_SICR2_OFFSET = 0x84,
83 83 K2_SATA_SIM_OFFSET = 0x88,
84/* Port stride */ 84
85#define K2_SATA_PORT_OFFSET 0x100 85 /* Port stride */
86 K2_SATA_PORT_OFFSET = 0x100,
87};
86 88
87static u8 k2_stat_check_status(struct ata_port *ap); 89static u8 k2_stat_check_status(struct ata_port *ap);
88 90
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index ee75b9b38ae8..9701a806539d 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -47,52 +47,58 @@
47#include <linux/libata.h> 47#include <linux/libata.h>
48 48
49#define DRV_NAME "sata_vsc" 49#define DRV_NAME "sata_vsc"
50#define DRV_VERSION "1.1" 50#define DRV_VERSION "1.2"
51 51
52/* Interrupt register offsets (from chip base address) */ 52enum {
53#define VSC_SATA_INT_STAT_OFFSET 0x00 53 /* Interrupt register offsets (from chip base address) */
54#define VSC_SATA_INT_MASK_OFFSET 0x04 54 VSC_SATA_INT_STAT_OFFSET = 0x00,
55 55 VSC_SATA_INT_MASK_OFFSET = 0x04,
56/* Taskfile registers offsets */ 56
57#define VSC_SATA_TF_CMD_OFFSET 0x00 57 /* Taskfile registers offsets */
58#define VSC_SATA_TF_DATA_OFFSET 0x00 58 VSC_SATA_TF_CMD_OFFSET = 0x00,
59#define VSC_SATA_TF_ERROR_OFFSET 0x04 59 VSC_SATA_TF_DATA_OFFSET = 0x00,
60#define VSC_SATA_TF_FEATURE_OFFSET 0x06 60 VSC_SATA_TF_ERROR_OFFSET = 0x04,
61#define VSC_SATA_TF_NSECT_OFFSET 0x08 61 VSC_SATA_TF_FEATURE_OFFSET = 0x06,
62#define VSC_SATA_TF_LBAL_OFFSET 0x0c 62 VSC_SATA_TF_NSECT_OFFSET = 0x08,
63#define VSC_SATA_TF_LBAM_OFFSET 0x10 63 VSC_SATA_TF_LBAL_OFFSET = 0x0c,
64#define VSC_SATA_TF_LBAH_OFFSET 0x14 64 VSC_SATA_TF_LBAM_OFFSET = 0x10,
65#define VSC_SATA_TF_DEVICE_OFFSET 0x18 65 VSC_SATA_TF_LBAH_OFFSET = 0x14,
66#define VSC_SATA_TF_STATUS_OFFSET 0x1c 66 VSC_SATA_TF_DEVICE_OFFSET = 0x18,
67#define VSC_SATA_TF_COMMAND_OFFSET 0x1d 67 VSC_SATA_TF_STATUS_OFFSET = 0x1c,
68#define VSC_SATA_TF_ALTSTATUS_OFFSET 0x28 68 VSC_SATA_TF_COMMAND_OFFSET = 0x1d,
69#define VSC_SATA_TF_CTL_OFFSET 0x29 69 VSC_SATA_TF_ALTSTATUS_OFFSET = 0x28,
70 70 VSC_SATA_TF_CTL_OFFSET = 0x29,
71/* DMA base */ 71
72#define VSC_SATA_UP_DESCRIPTOR_OFFSET 0x64 72 /* DMA base */
73#define VSC_SATA_UP_DATA_BUFFER_OFFSET 0x6C 73 VSC_SATA_UP_DESCRIPTOR_OFFSET = 0x64,
74#define VSC_SATA_DMA_CMD_OFFSET 0x70 74 VSC_SATA_UP_DATA_BUFFER_OFFSET = 0x6C,
75 75 VSC_SATA_DMA_CMD_OFFSET = 0x70,
76/* SCRs base */ 76
77#define VSC_SATA_SCR_STATUS_OFFSET 0x100 77 /* SCRs base */
78#define VSC_SATA_SCR_ERROR_OFFSET 0x104 78 VSC_SATA_SCR_STATUS_OFFSET = 0x100,
79#define VSC_SATA_SCR_CONTROL_OFFSET 0x108 79 VSC_SATA_SCR_ERROR_OFFSET = 0x104,
80 80 VSC_SATA_SCR_CONTROL_OFFSET = 0x108,
81/* Port stride */ 81
82#define VSC_SATA_PORT_OFFSET 0x200 82 /* Port stride */
83 83 VSC_SATA_PORT_OFFSET = 0x200,
84/* Error interrupt status bit offsets */ 84
85#define VSC_SATA_INT_ERROR_E_OFFSET 2 85 /* Error interrupt status bit offsets */
86#define VSC_SATA_INT_ERROR_P_OFFSET 4 86 VSC_SATA_INT_ERROR_CRC = 0x40,
87#define VSC_SATA_INT_ERROR_T_OFFSET 5 87 VSC_SATA_INT_ERROR_T = 0x20,
88#define VSC_SATA_INT_ERROR_M_OFFSET 1 88 VSC_SATA_INT_ERROR_P = 0x10,
89 VSC_SATA_INT_ERROR_R = 0x8,
90 VSC_SATA_INT_ERROR_E = 0x4,
91 VSC_SATA_INT_ERROR_M = 0x2,
92 VSC_SATA_INT_PHY_CHANGE = 0x1,
93 VSC_SATA_INT_ERROR = (VSC_SATA_INT_ERROR_CRC | VSC_SATA_INT_ERROR_T | \
94 VSC_SATA_INT_ERROR_P | VSC_SATA_INT_ERROR_R | \
95 VSC_SATA_INT_ERROR_E | VSC_SATA_INT_ERROR_M | \
96 VSC_SATA_INT_PHY_CHANGE),
97};
98
99
89#define is_vsc_sata_int_err(port_idx, int_status) \ 100#define is_vsc_sata_int_err(port_idx, int_status) \
90 (int_status & ((1 << (VSC_SATA_INT_ERROR_E_OFFSET + (8 * port_idx))) | \ 101 (int_status & (VSC_SATA_INT_ERROR << (8 * port_idx)))
91 (1 << (VSC_SATA_INT_ERROR_P_OFFSET + (8 * port_idx))) | \
92 (1 << (VSC_SATA_INT_ERROR_T_OFFSET + (8 * port_idx))) | \
93 (1 << (VSC_SATA_INT_ERROR_M_OFFSET + (8 * port_idx))) \
94 )\
95 )
96 102
97 103
98static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) 104static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
@@ -215,14 +221,6 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
215 221
216 ap = host_set->ports[i]; 222 ap = host_set->ports[i];
217 223
218 if (is_vsc_sata_int_err(i, int_status)) {
219 u32 err_status;
220 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
221 err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
222 vsc_sata_scr_write(ap, SCR_ERROR, err_status);
223 handled++;
224 }
225
226 if (ap && !(ap->flags & 224 if (ap && !(ap->flags &
227 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) { 225 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
228 struct ata_queued_cmd *qc; 226 struct ata_queued_cmd *qc;
@@ -230,12 +228,26 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
230 qc = ata_qc_from_tag(ap, ap->active_tag); 228 qc = ata_qc_from_tag(ap, ap->active_tag);
231 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 229 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
232 handled += ata_host_intr(ap, qc); 230 handled += ata_host_intr(ap, qc);
233 } else { 231 } else if (is_vsc_sata_int_err(i, int_status)) {
234 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__); 232 /*
233 * On some chips (i.e. Intel 31244), an error
234 * interrupt will sneak in at initialization
235 * time (phy state changes). Clearing the SCR
236 * error register is not required, but it prevents
237 * the phy state change interrupts from recurring
238 * later.
239 */
240 u32 err_status;
241 err_status = vsc_sata_scr_read(ap, SCR_ERROR);
242 printk(KERN_DEBUG "%s: clearing interrupt, "
243 "status %x; sata err status %x\n",
244 __FUNCTION__,
245 int_status, err_status);
246 vsc_sata_scr_write(ap, SCR_ERROR, err_status);
247 /* Clear interrupt status */
235 ata_chk_status(ap); 248 ata_chk_status(ap);
236 handled++; 249 handled++;
237 } 250 }
238
239 } 251 }
240 } 252 }
241 } 253 }
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index f9c1192dc15e..7c80711e18ed 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -71,7 +71,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR);
71#define SR_CAPABILITIES \ 71#define SR_CAPABILITIES \
72 (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ 72 (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \
73 CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ 73 CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \
74 CDC_PLAY_AUDIO|CDC_RESET|CDC_IOCTLS|CDC_DRIVE_STATUS| \ 74 CDC_PLAY_AUDIO|CDC_RESET|CDC_DRIVE_STATUS| \
75 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ 75 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \
76 CDC_MRW|CDC_MRW_W|CDC_RAM) 76 CDC_MRW|CDC_MRW_W|CDC_RAM)
77 77
@@ -118,7 +118,6 @@ static struct cdrom_device_ops sr_dops = {
118 .get_mcn = sr_get_mcn, 118 .get_mcn = sr_get_mcn,
119 .reset = sr_reset, 119 .reset = sr_reset,
120 .audio_ioctl = sr_audio_ioctl, 120 .audio_ioctl = sr_audio_ioctl,
121 .dev_ioctl = sr_dev_ioctl,
122 .capability = SR_CAPABILITIES, 121 .capability = SR_CAPABILITIES,
123 .generic_packet = sr_packet, 122 .generic_packet = sr_packet,
124}; 123};
@@ -456,17 +455,33 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
456{ 455{
457 struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); 456 struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
458 struct scsi_device *sdev = cd->device; 457 struct scsi_device *sdev = cd->device;
458 void __user *argp = (void __user *)arg;
459 int ret;
459 460
460 /* 461 /*
461 * Send SCSI addressing ioctls directly to mid level, send other 462 * Send SCSI addressing ioctls directly to mid level, send other
462 * ioctls to cdrom/block level. 463 * ioctls to cdrom/block level.
463 */ 464 */
464 switch (cmd) { 465 switch (cmd) {
465 case SCSI_IOCTL_GET_IDLUN: 466 case SCSI_IOCTL_GET_IDLUN:
466 case SCSI_IOCTL_GET_BUS_NUMBER: 467 case SCSI_IOCTL_GET_BUS_NUMBER:
467 return scsi_ioctl(sdev, cmd, (void __user *)arg); 468 return scsi_ioctl(sdev, cmd, argp);
468 } 469 }
469 return cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); 470
471 ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg);
472 if (ret != ENOSYS)
473 return ret;
474
475 /*
476 * ENODEV means that we didn't recognise the ioctl, or that we
477 * cannot execute it in the current device state. In either
478 * case fall through to scsi_ioctl, which will return ENDOEV again
479 * if it doesn't recognise the ioctl
480 */
481 ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL);
482 if (ret != -ENODEV)
483 return ret;
484 return scsi_ioctl(sdev, cmd, argp);
470} 485}
471 486
472static int sr_block_media_changed(struct gendisk *disk) 487static int sr_block_media_changed(struct gendisk *disk)
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
index d2bcd99c272f..d65de9621b27 100644
--- a/drivers/scsi/sr.h
+++ b/drivers/scsi/sr.h
@@ -55,7 +55,6 @@ int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
55int sr_reset(struct cdrom_device_info *); 55int sr_reset(struct cdrom_device_info *);
56int sr_select_speed(struct cdrom_device_info *cdi, int speed); 56int sr_select_speed(struct cdrom_device_info *cdi, int speed);
57int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); 57int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
58int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long);
59 58
60int sr_is_xa(Scsi_CD *); 59int sr_is_xa(Scsi_CD *);
61 60
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index b65462f76484..d1268cb46837 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -562,22 +562,3 @@ int sr_is_xa(Scsi_CD *cd)
562#endif 562#endif
563 return is_xa; 563 return is_xa;
564} 564}
565
566int sr_dev_ioctl(struct cdrom_device_info *cdi,
567 unsigned int cmd, unsigned long arg)
568{
569 Scsi_CD *cd = cdi->handle;
570 int ret;
571
572 ret = scsi_nonblockable_ioctl(cd->device, cmd,
573 (void __user *)arg, NULL);
574 /*
575 * ENODEV means that we didn't recognise the ioctl, or that we
576 * cannot execute it in the current device state. In either
577 * case fall through to scsi_ioctl, which will return ENDOEV again
578 * if it doesn't recognise the ioctl
579 */
580 if (ret != -ENODEV)
581 return ret;
582 return scsi_ioctl(cd->device, cmd, (void __user *)arg);
583}
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 8c5c276c5577..7572665a8855 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -375,23 +375,18 @@ static void serial21285_setup_ports(void)
375} 375}
376 376
377#ifdef CONFIG_SERIAL_21285_CONSOLE 377#ifdef CONFIG_SERIAL_21285_CONSOLE
378static void serial21285_console_putchar(struct uart_port *port, int ch)
379{
380 while (*CSR_UARTFLG & 0x20)
381 barrier();
382 *CSR_UARTDR = ch;
383}
378 384
379static void 385static void
380serial21285_console_write(struct console *co, const char *s, 386serial21285_console_write(struct console *co, const char *s,
381 unsigned int count) 387 unsigned int count)
382{ 388{
383 int i; 389 uart_console_write(&serial21285_port, s, count, serial21285_console_putchar);
384
385 for (i = 0; i < count; i++) {
386 while (*CSR_UARTFLG & 0x20)
387 barrier();
388 *CSR_UARTDR = s[i];
389 if (s[i] == '\n') {
390 while (*CSR_UARTFLG & 0x20)
391 barrier();
392 *CSR_UARTDR = '\r';
393 }
394 }
395} 390}
396 391
397static void __init 392static void __init
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index 7f0f35a05dca..b88a7c1158af 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -101,8 +101,6 @@ struct tty_driver *serial_driver;
101 101
102#define RS_ISR_PASS_LIMIT 256 102#define RS_ISR_PASS_LIMIT 256
103 103
104#define _INLINE_ inline
105
106static void change_speed(struct m68k_serial *info); 104static void change_speed(struct m68k_serial *info);
107 105
108/* 106/*
@@ -262,7 +260,7 @@ static void batten_down_hatches(void)
262 /* Drop into the debugger */ 260 /* Drop into the debugger */
263} 261}
264 262
265static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status) 263static void status_handle(struct m68k_serial *info, unsigned short status)
266{ 264{
267#if 0 265#if 0
268 if(status & DCD) { 266 if(status & DCD) {
@@ -289,7 +287,8 @@ static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short stat
289 return; 287 return;
290} 288}
291 289
292static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx) 290static void receive_chars(struct m68k_serial *info, struct pt_regs *regs,
291 unsigned short rx)
293{ 292{
294 struct tty_struct *tty = info->tty; 293 struct tty_struct *tty = info->tty;
295 m68328_uart *uart = &uart_addr[info->line]; 294 m68328_uart *uart = &uart_addr[info->line];
@@ -359,7 +358,7 @@ clear_and_exit:
359 return; 358 return;
360} 359}
361 360
362static _INLINE_ void transmit_chars(struct m68k_serial *info) 361static void transmit_chars(struct m68k_serial *info)
363{ 362{
364 m68328_uart *uart = &uart_addr[info->line]; 363 m68328_uart *uart = &uart_addr[info->line];
365 364
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 7aca22c9976d..5996d3cd0ed8 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2182,6 +2182,14 @@ static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
2182 } 2182 }
2183} 2183}
2184 2184
2185static void serial8250_console_putchar(struct uart_port *port, int ch)
2186{
2187 struct uart_8250_port *up = (struct uart_8250_port *)port;
2188
2189 wait_for_xmitr(up, UART_LSR_THRE);
2190 serial_out(up, UART_TX, ch);
2191}
2192
2185/* 2193/*
2186 * Print a string to the serial port trying not to disturb 2194 * Print a string to the serial port trying not to disturb
2187 * any possible real use of the port... 2195 * any possible real use of the port...
@@ -2193,7 +2201,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2193{ 2201{
2194 struct uart_8250_port *up = &serial8250_ports[co->index]; 2202 struct uart_8250_port *up = &serial8250_ports[co->index];
2195 unsigned int ier; 2203 unsigned int ier;
2196 int i;
2197 2204
2198 touch_nmi_watchdog(); 2205 touch_nmi_watchdog();
2199 2206
@@ -2207,22 +2214,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2207 else 2214 else
2208 serial_out(up, UART_IER, 0); 2215 serial_out(up, UART_IER, 0);
2209 2216
2210 /* 2217 uart_console_write(&up->port, s, count, serial8250_console_putchar);
2211 * Now, do each character
2212 */
2213 for (i = 0; i < count; i++, s++) {
2214 wait_for_xmitr(up, UART_LSR_THRE);
2215
2216 /*
2217 * Send the character out.
2218 * If a LF, also do CR...
2219 */
2220 serial_out(up, UART_TX, *s);
2221 if (*s == 10) {
2222 wait_for_xmitr(up, UART_LSR_THRE);
2223 serial_out(up, UART_TX, 13);
2224 }
2225 }
2226 2218
2227 /* 2219 /*
2228 * Finally, wait for transmitter to become empty 2220 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 59ba5d993b4b..7e511199b4c5 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -74,7 +74,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
74 } 74 }
75} 75}
76 76
77static void __init putc(struct uart_port *port, unsigned char c) 77static void __init putc(struct uart_port *port, int c)
78{ 78{
79 wait_for_xmitr(port); 79 wait_for_xmitr(port);
80 serial_out(port, UART_TX, c); 80 serial_out(port, UART_TX, c);
@@ -89,12 +89,7 @@ static void __init early_uart_write(struct console *console, const char *s, unsi
89 ier = serial_in(port, UART_IER); 89 ier = serial_in(port, UART_IER);
90 serial_out(port, UART_IER, 0); 90 serial_out(port, UART_IER, 0);
91 91
92 while (*s && count-- > 0) { 92 uart_console_write(port, s, count, putc);
93 putc(port, *s);
94 if (*s == '\n')
95 putc(port, '\r');
96 s++;
97 }
98 93
99 /* Wait for transmitter to become empty and restore the IER */ 94 /* Wait for transmitter to become empty and restore the IER */
100 wait_for_xmitr(port); 95 wait_for_xmitr(port);
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 321a3b3a5728..e04d5e82d9ae 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -591,12 +591,18 @@ static struct uart_amba_port amba_ports[UART_NR] = {
591 591
592#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE 592#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
593 593
594static void pl010_console_putchar(struct uart_port *port, int ch)
595{
596 while (!UART_TX_READY(UART_GET_FR(port)))
597 barrier();
598 UART_PUT_CHAR(port, ch);
599}
600
594static void 601static void
595pl010_console_write(struct console *co, const char *s, unsigned int count) 602pl010_console_write(struct console *co, const char *s, unsigned int count)
596{ 603{
597 struct uart_port *port = &amba_ports[co->index].port; 604 struct uart_port *port = &amba_ports[co->index].port;
598 unsigned int status, old_cr; 605 unsigned int status, old_cr;
599 int i;
600 606
601 /* 607 /*
602 * First save the CR then disable the interrupts 608 * First save the CR then disable the interrupts
@@ -604,21 +610,7 @@ pl010_console_write(struct console *co, const char *s, unsigned int count)
604 old_cr = UART_GET_CR(port); 610 old_cr = UART_GET_CR(port);
605 UART_PUT_CR(port, UART01x_CR_UARTEN); 611 UART_PUT_CR(port, UART01x_CR_UARTEN);
606 612
607 /* 613 uart_console_write(port, s, count, pl010_console_putchar);
608 * Now, do each character
609 */
610 for (i = 0; i < count; i++) {
611 do {
612 status = UART_GET_FR(port);
613 } while (!UART_TX_READY(status));
614 UART_PUT_CHAR(port, s[i]);
615 if (s[i] == '\n') {
616 do {
617 status = UART_GET_FR(port);
618 } while (!UART_TX_READY(status));
619 UART_PUT_CHAR(port, '\r');
620 }
621 }
622 614
623 /* 615 /*
624 * Finally, wait for transmitter to become empty 616 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 034a029e356e..3d966cfc9a38 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -587,14 +587,12 @@ static struct uart_amba_port *amba_ports[UART_NR];
587 587
588#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE 588#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
589 589
590static inline void 590static void pl011_console_putchar(struct uart_port *port, int ch)
591pl011_console_write_char(struct uart_amba_port *uap, char ch)
592{ 591{
593 unsigned int status; 592 struct uart_amba_port *uap = (struct uart_amba_port *)port;
594 593
595 do { 594 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
596 status = readw(uap->port.membase + UART01x_FR); 595 barrier();
597 } while (status & UART01x_FR_TXFF);
598 writew(ch, uap->port.membase + UART01x_DR); 596 writew(ch, uap->port.membase + UART01x_DR);
599} 597}
600 598
@@ -603,7 +601,6 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
603{ 601{
604 struct uart_amba_port *uap = amba_ports[co->index]; 602 struct uart_amba_port *uap = amba_ports[co->index];
605 unsigned int status, old_cr, new_cr; 603 unsigned int status, old_cr, new_cr;
606 int i;
607 604
608 clk_enable(uap->clk); 605 clk_enable(uap->clk);
609 606
@@ -615,14 +612,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
615 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 612 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
616 writew(new_cr, uap->port.membase + UART011_CR); 613 writew(new_cr, uap->port.membase + UART011_CR);
617 614
618 /* 615 uart_console_write(&uap->port, s, count, pl011_console_putchar);
619 * Now, do each character
620 */
621 for (i = 0; i < count; i++) {
622 pl011_console_write_char(uap, s[i]);
623 if (s[i] == '\n')
624 pl011_console_write_char(uap, '\r');
625 }
626 616
627 /* 617 /*
628 * Finally, wait for transmitter to become empty 618 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/at91_serial.c b/drivers/serial/at91_serial.c
index 2113feb75c39..6547fe0cef96 100644
--- a/drivers/serial/at91_serial.c
+++ b/drivers/serial/at91_serial.c
@@ -711,6 +711,12 @@ void __init at91_register_uart(int idx, int port)
711} 711}
712 712
713#ifdef CONFIG_SERIAL_AT91_CONSOLE 713#ifdef CONFIG_SERIAL_AT91_CONSOLE
714static void at91_console_putchar(struct uart_port *port, int ch)
715{
716 while (!(UART_GET_CSR(port) & AT91_US_TXRDY))
717 barrier();
718 UART_PUT_CHAR(port, ch);
719}
714 720
715/* 721/*
716 * Interrupts are disabled on entering 722 * Interrupts are disabled on entering
@@ -718,7 +724,7 @@ void __init at91_register_uart(int idx, int port)
718static void at91_console_write(struct console *co, const char *s, u_int count) 724static void at91_console_write(struct console *co, const char *s, u_int count)
719{ 725{
720 struct uart_port *port = at91_ports + co->index; 726 struct uart_port *port = at91_ports + co->index;
721 unsigned int status, i, imr; 727 unsigned int status, imr;
722 728
723 /* 729 /*
724 * First, save IMR and then disable interrupts 730 * First, save IMR and then disable interrupts
@@ -726,21 +732,7 @@ static void at91_console_write(struct console *co, const char *s, u_int count)
726 imr = UART_GET_IMR(port); /* get interrupt mask */ 732 imr = UART_GET_IMR(port); /* get interrupt mask */
727 UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY); 733 UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY);
728 734
729 /* 735 uart_console_write(port, s, count, at91_console_putchar);
730 * Now, do each character
731 */
732 for (i = 0; i < count; i++) {
733 do {
734 status = UART_GET_CSR(port);
735 } while (!(status & AT91_US_TXRDY));
736 UART_PUT_CHAR(port, s[i]);
737 if (s[i] == '\n') {
738 do {
739 status = UART_GET_CSR(port);
740 } while (!(status & AT91_US_TXRDY));
741 UART_PUT_CHAR(port, '\r');
742 }
743 }
744 736
745 /* 737 /*
746 * Finally, wait for transmitter to become empty 738 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c
index 344022fe53ef..948880ac5878 100644
--- a/drivers/serial/au1x00_uart.c
+++ b/drivers/serial/au1x00_uart.c
@@ -133,13 +133,12 @@ static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = {
133 { "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO }, 133 { "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO },
134}; 134};
135 135
136static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) 136static unsigned int serial_in(struct uart_8250_port *up, int offset)
137{ 137{
138 return au_readl((unsigned long)up->port.membase + offset); 138 return au_readl((unsigned long)up->port.membase + offset);
139} 139}
140 140
141static _INLINE_ void 141static void serial_out(struct uart_8250_port *up, int offset, int value)
142serial_out(struct uart_8250_port *up, int offset, int value)
143{ 142{
144 au_writel(value, (unsigned long)up->port.membase + offset); 143 au_writel(value, (unsigned long)up->port.membase + offset);
145} 144}
@@ -237,7 +236,7 @@ static void serial8250_enable_ms(struct uart_port *port)
237 serial_out(up, UART_IER, up->ier); 236 serial_out(up, UART_IER, up->ier);
238} 237}
239 238
240static _INLINE_ void 239static void
241receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) 240receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
242{ 241{
243 struct tty_struct *tty = up->port.info->tty; 242 struct tty_struct *tty = up->port.info->tty;
@@ -312,7 +311,7 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
312 spin_lock(&up->port.lock); 311 spin_lock(&up->port.lock);
313} 312}
314 313
315static _INLINE_ void transmit_chars(struct uart_8250_port *up) 314static void transmit_chars(struct uart_8250_port *up)
316{ 315{
317 struct circ_buf *xmit = &up->port.info->xmit; 316 struct circ_buf *xmit = &up->port.info->xmit;
318 int count; 317 int count;
@@ -346,7 +345,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
346 serial8250_stop_tx(&up->port); 345 serial8250_stop_tx(&up->port);
347} 346}
348 347
349static _INLINE_ void check_modem_status(struct uart_8250_port *up) 348static void check_modem_status(struct uart_8250_port *up)
350{ 349{
351 int status; 350 int status;
352 351
@@ -1121,6 +1120,14 @@ static inline void wait_for_xmitr(struct uart_8250_port *up)
1121 } 1120 }
1122} 1121}
1123 1122
1123static void au1x00_console_putchar(struct uart_port *port, int ch)
1124{
1125 struct uart_8250_port *up = (struct uart_8250_port *)port;
1126
1127 wait_for_xmitr(up);
1128 serial_out(up, UART_TX, ch);
1129}
1130
1124/* 1131/*
1125 * Print a string to the serial port trying not to disturb 1132 * Print a string to the serial port trying not to disturb
1126 * any possible real use of the port... 1133 * any possible real use of the port...
@@ -1132,7 +1139,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
1132{ 1139{
1133 struct uart_8250_port *up = &serial8250_ports[co->index]; 1140 struct uart_8250_port *up = &serial8250_ports[co->index];
1134 unsigned int ier; 1141 unsigned int ier;
1135 int i;
1136 1142
1137 /* 1143 /*
1138 * First save the UER then disable the interrupts 1144 * First save the UER then disable the interrupts
@@ -1140,22 +1146,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
1140 ier = serial_in(up, UART_IER); 1146 ier = serial_in(up, UART_IER);
1141 serial_out(up, UART_IER, 0); 1147 serial_out(up, UART_IER, 0);
1142 1148
1143 /* 1149 uart_console_write(&up->port, s, count, au1x00_console_putchar);
1144 * Now, do each character
1145 */
1146 for (i = 0; i < count; i++, s++) {
1147 wait_for_xmitr(up);
1148
1149 /*
1150 * Send the character out.
1151 * If a LF, also do CR...
1152 */
1153 serial_out(up, UART_TX, *s);
1154 if (*s == 10) {
1155 wait_for_xmitr(up);
1156 serial_out(up, UART_TX, 13);
1157 }
1158 }
1159 1150
1160 /* 1151 /*
1161 * Finally, wait for transmitter to become empty 1152 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index ce7b2e4ecd17..2691112c84ad 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -424,6 +424,13 @@ static struct uart_port clps711x_ports[UART_NR] = {
424}; 424};
425 425
426#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE 426#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
427static void clps711xuart_console_putchar(struct uart_port *port, int ch)
428{
429 while (clps_readl(SYSFLG(port)) & SYSFLG_UTXFF)
430 barrier();
431 clps_writel(ch, UARTDR(port));
432}
433
427/* 434/*
428 * Print a string to the serial port trying not to disturb 435 * Print a string to the serial port trying not to disturb
429 * any possible real use of the port... 436 * any possible real use of the port...
@@ -438,7 +445,6 @@ clps711xuart_console_write(struct console *co, const char *s,
438{ 445{
439 struct uart_port *port = clps711x_ports + co->index; 446 struct uart_port *port = clps711x_ports + co->index;
440 unsigned int status, syscon; 447 unsigned int status, syscon;
441 int i;
442 448
443 /* 449 /*
444 * Ensure that the port is enabled. 450 * Ensure that the port is enabled.
@@ -446,21 +452,7 @@ clps711xuart_console_write(struct console *co, const char *s,
446 syscon = clps_readl(SYSCON(port)); 452 syscon = clps_readl(SYSCON(port));
447 clps_writel(syscon | SYSCON_UARTEN, SYSCON(port)); 453 clps_writel(syscon | SYSCON_UARTEN, SYSCON(port));
448 454
449 /* 455 uart_console_write(port, s, count, clps711xuart_console_putchar);
450 * Now, do each character
451 */
452 for (i = 0; i < count; i++) {
453 do {
454 status = clps_readl(SYSFLG(port));
455 } while (status & SYSFLG_UTXFF);
456 clps_writel(s[i], UARTDR(port));
457 if (s[i] == '\n') {
458 do {
459 status = clps_readl(SYSFLG(port));
460 } while (status & SYSFLG_UTXFF);
461 clps_writel('\r', UARTDR(port));
462 }
463 }
464 456
465 /* 457 /*
466 * Finally, wait for transmitter to become empty 458 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index be12623d8544..89700141f87e 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -481,8 +481,6 @@ static char *serial_version = "$Revision: 1.25 $";
481#include "serial_compat.h" 481#include "serial_compat.h"
482#endif 482#endif
483 483
484#define _INLINE_ inline
485
486struct tty_driver *serial_driver; 484struct tty_driver *serial_driver;
487 485
488/* serial subtype definitions */ 486/* serial subtype definitions */
@@ -591,8 +589,6 @@ static void rs_throttle(struct tty_struct * tty);
591static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 589static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
592static int rs_write(struct tty_struct * tty, int from_user, 590static int rs_write(struct tty_struct * tty, int from_user,
593 const unsigned char *buf, int count); 591 const unsigned char *buf, int count);
594extern _INLINE_ int rs_raw_write(struct tty_struct * tty, int from_user,
595 const unsigned char *buf, int count);
596#ifdef CONFIG_ETRAX_RS485 592#ifdef CONFIG_ETRAX_RS485
597static int e100_write_rs485(struct tty_struct * tty, int from_user, 593static int e100_write_rs485(struct tty_struct * tty, int from_user,
598 const unsigned char *buf, int count); 594 const unsigned char *buf, int count);
@@ -1538,8 +1534,7 @@ e100_enable_rxdma_irq(struct e100_serial *info)
1538 1534
1539/* the tx DMA uses only dma_descr interrupt */ 1535/* the tx DMA uses only dma_descr interrupt */
1540 1536
1541static _INLINE_ void 1537static void e100_disable_txdma_irq(struct e100_serial *info)
1542e100_disable_txdma_irq(struct e100_serial *info)
1543{ 1538{
1544#ifdef SERIAL_DEBUG_INTR 1539#ifdef SERIAL_DEBUG_INTR
1545 printk("txdma_irq(%d): 0\n",info->line); 1540 printk("txdma_irq(%d): 0\n",info->line);
@@ -1548,8 +1543,7 @@ e100_disable_txdma_irq(struct e100_serial *info)
1548 *R_IRQ_MASK2_CLR = info->irq; 1543 *R_IRQ_MASK2_CLR = info->irq;
1549} 1544}
1550 1545
1551static _INLINE_ void 1546static void e100_enable_txdma_irq(struct e100_serial *info)
1552e100_enable_txdma_irq(struct e100_serial *info)
1553{ 1547{
1554#ifdef SERIAL_DEBUG_INTR 1548#ifdef SERIAL_DEBUG_INTR
1555 printk("txdma_irq(%d): 1\n",info->line); 1549 printk("txdma_irq(%d): 1\n",info->line);
@@ -1558,8 +1552,7 @@ e100_enable_txdma_irq(struct e100_serial *info)
1558 *R_IRQ_MASK2_SET = info->irq; 1552 *R_IRQ_MASK2_SET = info->irq;
1559} 1553}
1560 1554
1561static _INLINE_ void 1555static void e100_disable_txdma_channel(struct e100_serial *info)
1562e100_disable_txdma_channel(struct e100_serial *info)
1563{ 1556{
1564 unsigned long flags; 1557 unsigned long flags;
1565 1558
@@ -1599,8 +1592,7 @@ e100_disable_txdma_channel(struct e100_serial *info)
1599} 1592}
1600 1593
1601 1594
1602static _INLINE_ void 1595static void e100_enable_txdma_channel(struct e100_serial *info)
1603e100_enable_txdma_channel(struct e100_serial *info)
1604{ 1596{
1605 unsigned long flags; 1597 unsigned long flags;
1606 1598
@@ -1625,8 +1617,7 @@ e100_enable_txdma_channel(struct e100_serial *info)
1625 restore_flags(flags); 1617 restore_flags(flags);
1626} 1618}
1627 1619
1628static _INLINE_ void 1620static void e100_disable_rxdma_channel(struct e100_serial *info)
1629e100_disable_rxdma_channel(struct e100_serial *info)
1630{ 1621{
1631 unsigned long flags; 1622 unsigned long flags;
1632 1623
@@ -1665,8 +1656,7 @@ e100_disable_rxdma_channel(struct e100_serial *info)
1665} 1656}
1666 1657
1667 1658
1668static _INLINE_ void 1659static void e100_enable_rxdma_channel(struct e100_serial *info)
1669e100_enable_rxdma_channel(struct e100_serial *info)
1670{ 1660{
1671 unsigned long flags; 1661 unsigned long flags;
1672 1662
@@ -1913,9 +1903,7 @@ rs_start(struct tty_struct *tty)
1913 * This routine is used by the interrupt handler to schedule 1903 * This routine is used by the interrupt handler to schedule
1914 * processing in the software interrupt portion of the driver. 1904 * processing in the software interrupt portion of the driver.
1915 */ 1905 */
1916static _INLINE_ void 1906static void rs_sched_event(struct e100_serial *info, int event)
1917rs_sched_event(struct e100_serial *info,
1918 int event)
1919{ 1907{
1920 if (info->event & (1 << event)) 1908 if (info->event & (1 << event))
1921 return; 1909 return;
@@ -2155,8 +2143,9 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl
2155 return 1; 2143 return 1;
2156} 2144}
2157 2145
2158extern _INLINE_ unsigned int 2146static unsigned int handle_descr_data(struct e100_serial *info,
2159handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsigned int recvl) 2147 struct etrax_dma_descr *descr,
2148 unsigned int recvl)
2160{ 2149{
2161 struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer; 2150 struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer;
2162 2151
@@ -2182,8 +2171,7 @@ handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsig
2182 return recvl; 2171 return recvl;
2183} 2172}
2184 2173
2185static _INLINE_ unsigned int 2174static unsigned int handle_all_descr_data(struct e100_serial *info)
2186handle_all_descr_data(struct e100_serial *info)
2187{ 2175{
2188 struct etrax_dma_descr *descr; 2176 struct etrax_dma_descr *descr;
2189 unsigned int recvl; 2177 unsigned int recvl;
@@ -2230,8 +2218,7 @@ handle_all_descr_data(struct e100_serial *info)
2230 return ret; 2218 return ret;
2231} 2219}
2232 2220
2233static _INLINE_ void 2221static void receive_chars_dma(struct e100_serial *info)
2234receive_chars_dma(struct e100_serial *info)
2235{ 2222{
2236 struct tty_struct *tty; 2223 struct tty_struct *tty;
2237 unsigned char rstat; 2224 unsigned char rstat;
@@ -2292,8 +2279,7 @@ receive_chars_dma(struct e100_serial *info)
2292 *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); 2279 *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
2293} 2280}
2294 2281
2295static _INLINE_ int 2282static int start_recv_dma(struct e100_serial *info)
2296start_recv_dma(struct e100_serial *info)
2297{ 2283{
2298 struct etrax_dma_descr *descr = info->rec_descr; 2284 struct etrax_dma_descr *descr = info->rec_descr;
2299 struct etrax_recv_buffer *buffer; 2285 struct etrax_recv_buffer *buffer;
@@ -2348,11 +2334,6 @@ start_receive(struct e100_serial *info)
2348} 2334}
2349 2335
2350 2336
2351static _INLINE_ void
2352status_handle(struct e100_serial *info, unsigned short status)
2353{
2354}
2355
2356/* the bits in the MASK2 register are laid out like this: 2337/* the bits in the MASK2 register are laid out like this:
2357 DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR 2338 DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR
2358 where I is the input channel and O is the output channel for the port. 2339 where I is the input channel and O is the output channel for the port.
@@ -2454,8 +2435,7 @@ rec_interrupt(int irq, void *dev_id, struct pt_regs * regs)
2454 return IRQ_RETVAL(handled); 2435 return IRQ_RETVAL(handled);
2455} /* rec_interrupt */ 2436} /* rec_interrupt */
2456 2437
2457static _INLINE_ int 2438static int force_eop_if_needed(struct e100_serial *info)
2458force_eop_if_needed(struct e100_serial *info)
2459{ 2439{
2460 /* We check data_avail bit to determine if data has 2440 /* We check data_avail bit to determine if data has
2461 * arrived since last time 2441 * arrived since last time
@@ -2499,8 +2479,7 @@ force_eop_if_needed(struct e100_serial *info)
2499 return 1; 2479 return 1;
2500} 2480}
2501 2481
2502extern _INLINE_ void 2482static void flush_to_flip_buffer(struct e100_serial *info)
2503flush_to_flip_buffer(struct e100_serial *info)
2504{ 2483{
2505 struct tty_struct *tty; 2484 struct tty_struct *tty;
2506 struct etrax_recv_buffer *buffer; 2485 struct etrax_recv_buffer *buffer;
@@ -2611,8 +2590,7 @@ flush_to_flip_buffer(struct e100_serial *info)
2611 tty_flip_buffer_push(tty); 2590 tty_flip_buffer_push(tty);
2612} 2591}
2613 2592
2614static _INLINE_ void 2593static void check_flush_timeout(struct e100_serial *info)
2615check_flush_timeout(struct e100_serial *info)
2616{ 2594{
2617 /* Flip what we've got (if we can) */ 2595 /* Flip what we've got (if we can) */
2618 flush_to_flip_buffer(info); 2596 flush_to_flip_buffer(info);
@@ -2741,7 +2719,7 @@ TODO: The break will be delayed until an F or V character is received.
2741 2719
2742*/ 2720*/
2743 2721
2744extern _INLINE_ 2722static
2745struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) 2723struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2746{ 2724{
2747 unsigned long data_read; 2725 unsigned long data_read;
@@ -2875,8 +2853,7 @@ more_data:
2875 return info; 2853 return info;
2876} 2854}
2877 2855
2878extern _INLINE_ 2856static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2879struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2880{ 2857{
2881 unsigned char rstat; 2858 unsigned char rstat;
2882 2859
@@ -2995,7 +2972,7 @@ struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2995 return info; 2972 return info;
2996} /* handle_ser_rx_interrupt */ 2973} /* handle_ser_rx_interrupt */
2997 2974
2998extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info) 2975static void handle_ser_tx_interrupt(struct e100_serial *info)
2999{ 2976{
3000 unsigned long flags; 2977 unsigned long flags;
3001 2978
@@ -3621,9 +3598,8 @@ rs_flush_chars(struct tty_struct *tty)
3621 restore_flags(flags); 3598 restore_flags(flags);
3622} 3599}
3623 3600
3624extern _INLINE_ int 3601static int rs_raw_write(struct tty_struct * tty, int from_user,
3625rs_raw_write(struct tty_struct * tty, int from_user, 3602 const unsigned char *buf, int count)
3626 const unsigned char *buf, int count)
3627{ 3603{
3628 int c, ret = 0; 3604 int c, ret = 0;
3629 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3605 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
@@ -4710,7 +4686,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
4710 * /proc fs routines.... 4686 * /proc fs routines....
4711 */ 4687 */
4712 4688
4713extern _INLINE_ int line_info(char *buf, struct e100_serial *info) 4689static int line_info(char *buf, struct e100_serial *info)
4714{ 4690{
4715 char stat_buf[30]; 4691 char stat_buf[30];
4716 int ret; 4692 int ret;
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index ba5541de673b..bf71bad5c34f 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -674,11 +674,12 @@ static void dz_reset(struct dz_port *dport)
674} 674}
675 675
676#ifdef CONFIG_SERIAL_DZ_CONSOLE 676#ifdef CONFIG_SERIAL_DZ_CONSOLE
677static void dz_console_put_char(struct dz_port *dport, unsigned char ch) 677static void dz_console_putchar(struct uart_port *port, int ch)
678{ 678{
679 struct dz_port *dport = (struct dz_port *)uport;
679 unsigned long flags; 680 unsigned long flags;
680 int loops = 2500; 681 int loops = 2500;
681 unsigned short tmp = ch; 682 unsigned short tmp = (unsigned char)ch;
682 /* this code sends stuff out to serial device - spinning its 683 /* this code sends stuff out to serial device - spinning its
683 wheels and waiting. */ 684 wheels and waiting. */
684 685
@@ -694,6 +695,7 @@ static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
694 695
695 spin_unlock_irqrestore(&dport->port.lock, flags); 696 spin_unlock_irqrestore(&dport->port.lock, flags);
696} 697}
698
697/* 699/*
698 * ------------------------------------------------------------------- 700 * -------------------------------------------------------------------
699 * dz_console_print () 701 * dz_console_print ()
@@ -710,11 +712,7 @@ static void dz_console_print(struct console *cons,
710#ifdef DEBUG_DZ 712#ifdef DEBUG_DZ
711 prom_printf((char *) str); 713 prom_printf((char *) str);
712#endif 714#endif
713 while (count--) { 715 uart_console_write(&dport->port, str, count, dz_console_putchar);
714 if (*str == '\n')
715 dz_console_put_char(dport, '\r');
716 dz_console_put_char(dport, *str++);
717 }
718} 716}
719 717
720static int __init dz_console_setup(struct console *co, char *options) 718static int __init dz_console_setup(struct console *co, char *options)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 4d53fb5ca87b..c3b7a6673e9c 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -743,6 +743,13 @@ static void __init imx_init_ports(void)
743} 743}
744 744
745#ifdef CONFIG_SERIAL_IMX_CONSOLE 745#ifdef CONFIG_SERIAL_IMX_CONSOLE
746static void imx_console_putchar(struct uart_port *port, int ch)
747{
748 struct imx_port *sport = (struct imx_port *)port;
749 while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
750 barrier();
751 URTX0((u32)sport->port.membase) = ch;
752}
746 753
747/* 754/*
748 * Interrupts are disabled on entering 755 * Interrupts are disabled on entering
@@ -751,7 +758,7 @@ static void
751imx_console_write(struct console *co, const char *s, unsigned int count) 758imx_console_write(struct console *co, const char *s, unsigned int count)
752{ 759{
753 struct imx_port *sport = &imx_ports[co->index]; 760 struct imx_port *sport = &imx_ports[co->index];
754 unsigned int old_ucr1, old_ucr2, i; 761 unsigned int old_ucr1, old_ucr2;
755 762
756 /* 763 /*
757 * First, save UCR1/2 and then disable interrupts 764 * First, save UCR1/2 and then disable interrupts
@@ -764,22 +771,7 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
764 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN); 771 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN);
765 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN; 772 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN;
766 773
767 /* 774 uart_console_write(&sport->port, s, count, imx_console_putchar);
768 * Now, do each character
769 */
770 for (i = 0; i < count; i++) {
771
772 while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
773 barrier();
774
775 URTX0((u32)sport->port.membase) = s[i];
776
777 if (s[i] == '\n') {
778 while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
779 barrier();
780 URTX0((u32)sport->port.membase) = '\r';
781 }
782 }
783 775
784 /* 776 /*
785 * Finally, wait for transmitter to become empty 777 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 193722d680cf..651772474ac1 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -967,8 +967,9 @@ static struct zilog_layout * __init get_zs(int chip)
967#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */ 967#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
968 968
969#ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE 969#ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE
970static void ip22zilog_put_char(struct zilog_channel *channel, unsigned char ch) 970static void ip22zilog_put_char(struct uart_port *port, int ch)
971{ 971{
972 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
972 int loops = ZS_PUT_CHAR_MAX_DELAY; 973 int loops = ZS_PUT_CHAR_MAX_DELAY;
973 974
974 /* This is a timed polling loop so do not switch the explicit 975 /* This is a timed polling loop so do not switch the explicit
@@ -992,16 +993,10 @@ static void
992ip22zilog_console_write(struct console *con, const char *s, unsigned int count) 993ip22zilog_console_write(struct console *con, const char *s, unsigned int count)
993{ 994{
994 struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index]; 995 struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
995 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
996 unsigned long flags; 996 unsigned long flags;
997 int i;
998 997
999 spin_lock_irqsave(&up->port.lock, flags); 998 spin_lock_irqsave(&up->port.lock, flags);
1000 for (i = 0; i < count; i++, s++) { 999 uart_console_write(&up->port, s, count, ip22zilog_put_char);
1001 ip22zilog_put_char(channel, *s);
1002 if (*s == 10)
1003 ip22zilog_put_char(channel, 13);
1004 }
1005 udelay(2); 1000 udelay(2);
1006 spin_unlock_irqrestore(&up->port.lock, flags); 1001 spin_unlock_irqrestore(&up->port.lock, flags);
1007} 1002}
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c
index 242a04104393..e9c10c0a30fc 100644
--- a/drivers/serial/m32r_sio.c
+++ b/drivers/serial/m32r_sio.c
@@ -248,17 +248,17 @@ static void sio_error(int *status)
248 248
249#endif /* CONFIG_SERIAL_M32R_PLDSIO */ 249#endif /* CONFIG_SERIAL_M32R_PLDSIO */
250 250
251static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset) 251static unsigned int sio_in(struct uart_sio_port *up, int offset)
252{ 252{
253 return __sio_in(up->port.iobase + offset); 253 return __sio_in(up->port.iobase + offset);
254} 254}
255 255
256static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value) 256static void sio_out(struct uart_sio_port *up, int offset, int value)
257{ 257{
258 __sio_out(value, up->port.iobase + offset); 258 __sio_out(value, up->port.iobase + offset);
259} 259}
260 260
261static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset) 261static unsigned int serial_in(struct uart_sio_port *up, int offset)
262{ 262{
263 if (!offset) 263 if (!offset)
264 return 0; 264 return 0;
@@ -266,8 +266,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset)
266 return __sio_in(offset); 266 return __sio_in(offset);
267} 267}
268 268
269static _INLINE_ void 269static void serial_out(struct uart_sio_port *up, int offset, int value)
270serial_out(struct uart_sio_port *up, int offset, int value)
271{ 270{
272 if (!offset) 271 if (!offset)
273 return; 272 return;
@@ -326,8 +325,8 @@ static void m32r_sio_enable_ms(struct uart_port *port)
326 serial_out(up, UART_IER, up->ier); 325 serial_out(up, UART_IER, up->ier);
327} 326}
328 327
329static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, 328static void receive_chars(struct uart_sio_port *up, int *status,
330 struct pt_regs *regs) 329 struct pt_regs *regs)
331{ 330{
332 struct tty_struct *tty = up->port.info->tty; 331 struct tty_struct *tty = up->port.info->tty;
333 unsigned char ch; 332 unsigned char ch;
@@ -400,7 +399,7 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
400 tty_flip_buffer_push(tty); 399 tty_flip_buffer_push(tty);
401} 400}
402 401
403static _INLINE_ void transmit_chars(struct uart_sio_port *up) 402static void transmit_chars(struct uart_sio_port *up)
404{ 403{
405 struct circ_buf *xmit = &up->port.info->xmit; 404 struct circ_buf *xmit = &up->port.info->xmit;
406 int count; 405 int count;
@@ -1039,6 +1038,14 @@ static inline void wait_for_xmitr(struct uart_sio_port *up)
1039 } 1038 }
1040} 1039}
1041 1040
1041static void m32r_sio_console_putchar(struct uart_port *port, int ch)
1042{
1043 struct uart_sio_port *up = (struct uart_sio_port *)port;
1044
1045 wait_for_xmitr(up);
1046 sio_out(up, SIOTXB, ch);
1047}
1048
1042/* 1049/*
1043 * Print a string to the serial port trying not to disturb 1050 * Print a string to the serial port trying not to disturb
1044 * any possible real use of the port... 1051 * any possible real use of the port...
@@ -1058,23 +1065,7 @@ static void m32r_sio_console_write(struct console *co, const char *s,
1058 ier = sio_in(up, SIOTRCR); 1065 ier = sio_in(up, SIOTRCR);
1059 sio_out(up, SIOTRCR, 0); 1066 sio_out(up, SIOTRCR, 0);
1060 1067
1061 /* 1068 uart_console_write(&up->port, s, count, m32r_sio_console_putchar);
1062 * Now, do each character
1063 */
1064 for (i = 0; i < count; i++, s++) {
1065 wait_for_xmitr(up);
1066
1067 /*
1068 * Send the character out.
1069 * If a LF, also do CR...
1070 */
1071 sio_out(up, SIOTXB, *s);
1072
1073 if (*s == 10) {
1074 wait_for_xmitr(up);
1075 sio_out(up, SIOTXB, 13);
1076 }
1077 }
1078 1069
1079 /* 1070 /*
1080 * Finally, wait for transmitter to become empty 1071 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 61dd17d7bace..928e6cf12dca 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -603,15 +603,14 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
603 udelay(1); 603 udelay(1);
604 604
605 /* Write all the chars */ 605 /* Write all the chars */
606 for ( i=0 ; i<count ; i++ ) { 606 for (i = 0; i < count; i++, s++) {
607
608 /* Send the char */
609 out_8(&psc->mpc52xx_psc_buffer_8, *s);
610
611 /* Line return handling */ 607 /* Line return handling */
612 if ( *s++ == '\n' ) 608 if (*s == '\n')
613 out_8(&psc->mpc52xx_psc_buffer_8, '\r'); 609 out_8(&psc->mpc52xx_psc_buffer_8, '\r');
614 610
611 /* Send the char */
612 out_8(&psc->mpc52xx_psc_buffer_8, *s);
613
615 /* Wait the TX buffer to be empty */ 614 /* Wait the TX buffer to be empty */
616 j = 20000; /* Maximum wait */ 615 j = 20000; /* Maximum wait */
617 while (!(in_be16(&psc->mpc52xx_psc_status) & 616 while (!(in_be16(&psc->mpc52xx_psc_status) &
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 9b7ed58cb53b..513ff8597707 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1916,6 +1916,16 @@ static void __exit exit_pmz(void)
1916 1916
1917#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE 1917#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
1918 1918
1919static void pmz_console_putchar(struct uart_port *port, int ch)
1920{
1921 struct uart_pmac_port *uap = (struct uart_pmac_port *)port;
1922
1923 /* Wait for the transmit buffer to empty. */
1924 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
1925 udelay(5);
1926 write_zsdata(uap, ch);
1927}
1928
1919/* 1929/*
1920 * Print a string to the serial port trying not to disturb 1930 * Print a string to the serial port trying not to disturb
1921 * any possible real use of the port... 1931 * any possible real use of the port...
@@ -1924,7 +1934,6 @@ static void pmz_console_write(struct console *con, const char *s, unsigned int c
1924{ 1934{
1925 struct uart_pmac_port *uap = &pmz_ports[con->index]; 1935 struct uart_pmac_port *uap = &pmz_ports[con->index];
1926 unsigned long flags; 1936 unsigned long flags;
1927 int i;
1928 1937
1929 if (ZS_IS_ASLEEP(uap)) 1938 if (ZS_IS_ASLEEP(uap))
1930 return; 1939 return;
@@ -1934,17 +1943,7 @@ static void pmz_console_write(struct console *con, const char *s, unsigned int c
1934 write_zsreg(uap, R1, uap->curregs[1] & ~TxINT_ENAB); 1943 write_zsreg(uap, R1, uap->curregs[1] & ~TxINT_ENAB);
1935 write_zsreg(uap, R5, uap->curregs[5] | TxENABLE | RTS | DTR); 1944 write_zsreg(uap, R5, uap->curregs[5] | TxENABLE | RTS | DTR);
1936 1945
1937 for (i = 0; i < count; i++) { 1946 uart_console_write(&uap->port, s, count, pmz_console_putchar);
1938 /* Wait for the transmit buffer to empty. */
1939 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
1940 udelay(5);
1941 write_zsdata(uap, s[i]);
1942 if (s[i] == 10) {
1943 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
1944 udelay(5);
1945 write_zsdata(uap, R13);
1946 }
1947 }
1948 1947
1949 /* Restore the values in the registers. */ 1948 /* Restore the values in the registers. */
1950 write_zsreg(uap, R1, uap->curregs[1]); 1949 write_zsreg(uap, R1, uap->curregs[1]);
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 10535f00301f..77d4568ccc3a 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -619,6 +619,14 @@ static inline void wait_for_xmitr(struct uart_pxa_port *up)
619 } 619 }
620} 620}
621 621
622static void serial_pxa_console_putchar(struct uart_port *port, int ch)
623{
624 struct uart_pxa_port *up = (struct uart_pxa_port *)port;
625
626 wait_for_xmitr(up);
627 serial_out(up, UART_TX, ch);
628}
629
622/* 630/*
623 * Print a string to the serial port trying not to disturb 631 * Print a string to the serial port trying not to disturb
624 * any possible real use of the port... 632 * any possible real use of the port...
@@ -630,7 +638,6 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
630{ 638{
631 struct uart_pxa_port *up = &serial_pxa_ports[co->index]; 639 struct uart_pxa_port *up = &serial_pxa_ports[co->index];
632 unsigned int ier; 640 unsigned int ier;
633 int i;
634 641
635 /* 642 /*
636 * First save the IER then disable the interrupts 643 * First save the IER then disable the interrupts
@@ -638,22 +645,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
638 ier = serial_in(up, UART_IER); 645 ier = serial_in(up, UART_IER);
639 serial_out(up, UART_IER, UART_IER_UUE); 646 serial_out(up, UART_IER, UART_IER_UUE);
640 647
641 /* 648 uart_console_write(&up->port, s, count, serial_pxa_console_putchar);
642 * Now, do each character
643 */
644 for (i = 0; i < count; i++, s++) {
645 wait_for_xmitr(up);
646
647 /*
648 * Send the character out.
649 * If a LF, also do CR...
650 */
651 serial_out(up, UART_TX, *s);
652 if (*s == 10) {
653 wait_for_xmitr(up);
654 serial_out(up, UART_TX, 13);
655 }
656 }
657 649
658 /* 650 /*
659 * Finally, wait for transmitter to become empty 651 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 00d7c0ad8cbf..f5aac92fb798 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1586,25 +1586,19 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
1586} 1586}
1587 1587
1588static void 1588static void
1589s3c24xx_serial_console_write(struct console *co, const char *s, 1589s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
1590 unsigned int count)
1591{ 1590{
1592 int i;
1593 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1591 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
1592 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1593 barrier();
1594 wr_regb(cons_uart, S3C2410_UTXH, ch);
1595}
1594 1596
1595 for (i = 0; i < count; i++) { 1597static void
1596 while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon)) 1598s3c24xx_serial_console_write(struct console *co, const char *s,
1597 barrier(); 1599 unsigned int count)
1598 1600{
1599 wr_regb(cons_uart, S3C2410_UTXH, s[i]); 1601 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar);
1600
1601 if (s[i] == '\n') {
1602 while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
1603 barrier();
1604
1605 wr_regb(cons_uart, S3C2410_UTXH, '\r');
1606 }
1607 }
1608} 1602}
1609 1603
1610static void __init 1604static void __init
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 2c00b8625852..c2d9068b491d 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -689,6 +689,14 @@ void __init sa1100_register_uart(int idx, int port)
689 689
690 690
691#ifdef CONFIG_SERIAL_SA1100_CONSOLE 691#ifdef CONFIG_SERIAL_SA1100_CONSOLE
692static void sa1100_console_putchar(struct uart_port *port, int ch)
693{
694 struct sa1100_port *sport = (struct sa1100_port *)port;
695
696 while (!(UART_GET_UTSR1(sport) & UTSR1_TNF))
697 barrier();
698 UART_PUT_CHAR(sport, ch);
699}
692 700
693/* 701/*
694 * Interrupts are disabled on entering 702 * Interrupts are disabled on entering
@@ -697,7 +705,7 @@ static void
697sa1100_console_write(struct console *co, const char *s, unsigned int count) 705sa1100_console_write(struct console *co, const char *s, unsigned int count)
698{ 706{
699 struct sa1100_port *sport = &sa1100_ports[co->index]; 707 struct sa1100_port *sport = &sa1100_ports[co->index];
700 unsigned int old_utcr3, status, i; 708 unsigned int old_utcr3, status;
701 709
702 /* 710 /*
703 * First, save UTCR3 and then disable interrupts 711 * First, save UTCR3 and then disable interrupts
@@ -706,21 +714,7 @@ sa1100_console_write(struct console *co, const char *s, unsigned int count)
706 UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) | 714 UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) |
707 UTCR3_TXE); 715 UTCR3_TXE);
708 716
709 /* 717 uart_console_write(&sport->port, s, count, sa1100_console_putchar);
710 * Now, do each character
711 */
712 for (i = 0; i < count; i++) {
713 do {
714 status = UART_GET_UTSR1(sport);
715 } while (!(status & UTSR1_TNF));
716 UART_PUT_CHAR(sport, s[i]);
717 if (s[i] == '\n') {
718 do {
719 status = UART_GET_UTSR1(sport);
720 } while (!(status & UTSR1_TNF));
721 UART_PUT_CHAR(sport, '\r');
722 }
723 }
724 718
725 /* 719 /*
726 * Finally, wait for transmitter to become empty 720 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index cc1faa31d124..fcd7744c4253 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1755,6 +1755,27 @@ static int uart_read_proc(char *page, char **start, off_t off,
1755 1755
1756#ifdef CONFIG_SERIAL_CORE_CONSOLE 1756#ifdef CONFIG_SERIAL_CORE_CONSOLE
1757/* 1757/*
1758 * uart_console_write - write a console message to a serial port
1759 * @port: the port to write the message
1760 * @s: array of characters
1761 * @count: number of characters in string to write
1762 * @write: function to write character to port
1763 */
1764void uart_console_write(struct uart_port *port, const char *s,
1765 unsigned int count,
1766 void (*putchar)(struct uart_port *, int))
1767{
1768 unsigned int i;
1769
1770 for (i = 0; i < count; i++, s++) {
1771 if (*s == '\n')
1772 putchar(port, '\r');
1773 putchar(port, *s);
1774 }
1775}
1776EXPORT_SYMBOL_GPL(uart_console_write);
1777
1778/*
1758 * Check whether an invalid uart number has been specified, and 1779 * Check whether an invalid uart number has been specified, and
1759 * if so, search for the first available port that does have 1780 * if so, search for the first available port that does have
1760 * console support. 1781 * console support.
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 04186eaae227..aa521b8e0d4e 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -543,6 +543,12 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
543#else 543#else
544# define LH7A40X_CONSOLE &lh7a40x_console 544# define LH7A40X_CONSOLE &lh7a40x_console
545 545
546static void lh7a40xuart_console_putchar(struct uart_port *port, int ch)
547{
548 while (UR(port, UART_R_STATUS) & nTxRdy)
549 ;
550 UR(port, UART_R_DATA) = ch;
551}
546 552
547static void lh7a40xuart_console_write (struct console* co, 553static void lh7a40xuart_console_write (struct console* co,
548 const char* s, 554 const char* s,
@@ -556,16 +562,7 @@ static void lh7a40xuart_console_write (struct console* co,
556 UR (port, UART_R_INTEN) = 0; /* Disable all interrupts */ 562 UR (port, UART_R_INTEN) = 0; /* Disable all interrupts */
557 BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */ 563 BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */
558 564
559 for (; count-- > 0; ++s) { 565 uart_console_write(port, s, count, lh7a40xuart_console_putchar);
560 while (UR (port, UART_R_STATUS) & nTxRdy)
561 ;
562 UR (port, UART_R_DATA) = *s;
563 if (*s == '\n') {
564 while ((UR (port, UART_R_STATUS) & TxBusy))
565 ;
566 UR (port, UART_R_DATA) = '\r';
567 }
568 }
569 566
570 /* Wait until all characters are sent */ 567 /* Wait until all characters are sent */
571 while (UR (port, UART_R_STATUS) & TxBusy) 568 while (UR (port, UART_R_STATUS) & TxBusy)
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 141173efd463..b848b7d94412 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -863,6 +863,14 @@ static inline void wait_for_xmitr(struct uart_txx9_port *up)
863 } 863 }
864} 864}
865 865
866static void serial_txx9_console_putchar(struct uart_port *port, int ch)
867{
868 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
869
870 wait_for_xmitr(up);
871 sio_out(up, TXX9_SITFIFO, ch);
872}
873
866/* 874/*
867 * Print a string to the serial port trying not to disturb 875 * Print a string to the serial port trying not to disturb
868 * any possible real use of the port... 876 * any possible real use of the port...
@@ -874,7 +882,6 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
874{ 882{
875 struct uart_txx9_port *up = &serial_txx9_ports[co->index]; 883 struct uart_txx9_port *up = &serial_txx9_ports[co->index];
876 unsigned int ier, flcr; 884 unsigned int ier, flcr;
877 int i;
878 885
879 /* 886 /*
880 * First save the UER then disable the interrupts 887 * First save the UER then disable the interrupts
@@ -888,22 +895,7 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
888 if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES)) 895 if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES))
889 sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES); 896 sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES);
890 897
891 /* 898 uart_console_write(&up->port, s, count, serial_txx9_console_putchar);
892 * Now, do each character
893 */
894 for (i = 0; i < count; i++, s++) {
895 wait_for_xmitr(up);
896
897 /*
898 * Send the character out.
899 * If a LF, also do CR...
900 */
901 sio_out(up, TXX9_SITFIFO, *s);
902 if (*s == 10) {
903 wait_for_xmitr(up);
904 sio_out(up, TXX9_SITFIFO, 13);
905 }
906 }
907 899
908 /* 900 /*
909 * Finally, wait for transmitter to become empty 901 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index a2fb0c2fb121..bfbe9dc90cca 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -861,8 +861,9 @@ static int num_channels;
861 861
862#ifdef CONFIG_SERIAL_SUNSAB_CONSOLE 862#ifdef CONFIG_SERIAL_SUNSAB_CONSOLE
863 863
864static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char c) 864static void sunsab_console_putchar(struct uart_port *port, int c)
865{ 865{
866 struct uart_sunsab_port *up = (struct uart_sunsab_port *)port;
866 unsigned long flags; 867 unsigned long flags;
867 868
868 spin_lock_irqsave(&up->port.lock, flags); 869 spin_lock_irqsave(&up->port.lock, flags);
@@ -876,13 +877,8 @@ static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char
876static void sunsab_console_write(struct console *con, const char *s, unsigned n) 877static void sunsab_console_write(struct console *con, const char *s, unsigned n)
877{ 878{
878 struct uart_sunsab_port *up = &sunsab_ports[con->index]; 879 struct uart_sunsab_port *up = &sunsab_ports[con->index];
879 int i;
880 880
881 for (i = 0; i < n; i++) { 881 uart_console_write(&up->port, s, n, sunsab_console_putchar);
882 if (*s == '\n')
883 sunsab_console_putchar(up, '\r');
884 sunsab_console_putchar(up, *s++);
885 }
886 sunsab_tec_wait(up); 882 sunsab_tec_wait(up);
887} 883}
888 884
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 46c44b83f57c..9fe2283d91e5 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -102,9 +102,7 @@ struct uart_sunsu_port {
102#endif 102#endif
103}; 103};
104 104
105#define _INLINE_ 105static unsigned int serial_in(struct uart_sunsu_port *up, int offset)
106
107static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset)
108{ 106{
109 offset <<= up->port.regshift; 107 offset <<= up->port.regshift;
110 108
@@ -121,8 +119,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset)
121 } 119 }
122} 120}
123 121
124static _INLINE_ void 122static void serial_out(struct uart_sunsu_port *up, int offset, int value)
125serial_out(struct uart_sunsu_port *up, int offset, int value)
126{ 123{
127#ifndef CONFIG_SPARC64 124#ifndef CONFIG_SPARC64
128 /* 125 /*
@@ -316,7 +313,7 @@ static void sunsu_enable_ms(struct uart_port *port)
316 spin_unlock_irqrestore(&up->port.lock, flags); 313 spin_unlock_irqrestore(&up->port.lock, flags);
317} 314}
318 315
319static _INLINE_ struct tty_struct * 316static struct tty_struct *
320receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) 317receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs)
321{ 318{
322 struct tty_struct *tty = up->port.info->tty; 319 struct tty_struct *tty = up->port.info->tty;
@@ -395,7 +392,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs
395 return tty; 392 return tty;
396} 393}
397 394
398static _INLINE_ void transmit_chars(struct uart_sunsu_port *up) 395static void transmit_chars(struct uart_sunsu_port *up)
399{ 396{
400 struct circ_buf *xmit = &up->port.info->xmit; 397 struct circ_buf *xmit = &up->port.info->xmit;
401 int count; 398 int count;
@@ -431,7 +428,7 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
431 __stop_tx(up); 428 __stop_tx(up);
432} 429}
433 430
434static _INLINE_ void check_modem_status(struct uart_sunsu_port *up) 431static void check_modem_status(struct uart_sunsu_port *up)
435{ 432{
436 int status; 433 int status;
437 434
@@ -1377,6 +1374,14 @@ static __inline__ void wait_for_xmitr(struct uart_sunsu_port *up)
1377 } 1374 }
1378} 1375}
1379 1376
1377static void sunsu_console_putchar(struct uart_port *port, int ch)
1378{
1379 struct uart_sunsu_port *up = (struct uart_sunsu_port *)port;
1380
1381 wait_for_xmitr(up);
1382 serial_out(up, UART_TX, ch);
1383}
1384
1380/* 1385/*
1381 * Print a string to the serial port trying not to disturb 1386 * Print a string to the serial port trying not to disturb
1382 * any possible real use of the port... 1387 * any possible real use of the port...
@@ -1386,7 +1391,6 @@ static void sunsu_console_write(struct console *co, const char *s,
1386{ 1391{
1387 struct uart_sunsu_port *up = &sunsu_ports[co->index]; 1392 struct uart_sunsu_port *up = &sunsu_ports[co->index];
1388 unsigned int ier; 1393 unsigned int ier;
1389 int i;
1390 1394
1391 /* 1395 /*
1392 * First save the UER then disable the interrupts 1396 * First save the UER then disable the interrupts
@@ -1394,22 +1398,7 @@ static void sunsu_console_write(struct console *co, const char *s,
1394 ier = serial_in(up, UART_IER); 1398 ier = serial_in(up, UART_IER);
1395 serial_out(up, UART_IER, 0); 1399 serial_out(up, UART_IER, 0);
1396 1400
1397 /* 1401 uart_console_write(&up->port, s, count, sunsu_console_putchar);
1398 * Now, do each character
1399 */
1400 for (i = 0; i < count; i++, s++) {
1401 wait_for_xmitr(up);
1402
1403 /*
1404 * Send the character out.
1405 * If a LF, also do CR...
1406 */
1407 serial_out(up, UART_TX, *s);
1408 if (*s == 10) {
1409 wait_for_xmitr(up);
1410 serial_out(up, UART_TX, 13);
1411 }
1412 }
1413 1402
1414 /* 1403 /*
1415 * Finally, wait for transmitter to become empty 1404 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 10b35c6f287d..cd49ebbf4a45 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1252,8 +1252,9 @@ static struct zilog_layout __iomem * __init get_zs(int chip, int node)
1252 1252
1253#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */ 1253#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
1254 1254
1255static void sunzilog_put_char(struct zilog_channel __iomem *channel, unsigned char ch) 1255static void sunzilog_putchar(struct uart_port *port, int ch)
1256{ 1256{
1257 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
1257 int loops = ZS_PUT_CHAR_MAX_DELAY; 1258 int loops = ZS_PUT_CHAR_MAX_DELAY;
1258 1259
1259 /* This is a timed polling loop so do not switch the explicit 1260 /* This is a timed polling loop so do not switch the explicit
@@ -1284,7 +1285,7 @@ static int sunzilog_serio_write(struct serio *serio, unsigned char ch)
1284 1285
1285 spin_lock_irqsave(&sunzilog_serio_lock, flags); 1286 spin_lock_irqsave(&sunzilog_serio_lock, flags);
1286 1287
1287 sunzilog_put_char(ZILOG_CHANNEL_FROM_PORT(&up->port), ch); 1288 sunzilog_putchar(&up->port, ch);
1288 1289
1289 spin_unlock_irqrestore(&sunzilog_serio_lock, flags); 1290 spin_unlock_irqrestore(&sunzilog_serio_lock, flags);
1290 1291
@@ -1325,16 +1326,10 @@ static void
1325sunzilog_console_write(struct console *con, const char *s, unsigned int count) 1326sunzilog_console_write(struct console *con, const char *s, unsigned int count)
1326{ 1327{
1327 struct uart_sunzilog_port *up = &sunzilog_port_table[con->index]; 1328 struct uart_sunzilog_port *up = &sunzilog_port_table[con->index];
1328 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
1329 unsigned long flags; 1329 unsigned long flags;
1330 int i;
1331 1330
1332 spin_lock_irqsave(&up->port.lock, flags); 1331 spin_lock_irqsave(&up->port.lock, flags);
1333 for (i = 0; i < count; i++, s++) { 1332 uart_console_write(&up->port, s, count, sunzilog_putchar);
1334 sunzilog_put_char(channel, *s);
1335 if (*s == 10)
1336 sunzilog_put_char(channel, 13);
1337 }
1338 udelay(2); 1333 udelay(2);
1339 spin_unlock_irqrestore(&up->port.lock, flags); 1334 spin_unlock_irqrestore(&up->port.lock, flags);
1340} 1335}
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index bd6294132c18..df5e8713fa31 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -821,25 +821,23 @@ static void wait_for_xmitr(struct uart_port *port)
821 } 821 }
822} 822}
823 823
824static void siu_console_putchar(struct uart_port *port, int ch)
825{
826 wait_for_xmitr(port);
827 siu_write(port, UART_TX, ch);
828}
829
824static void siu_console_write(struct console *con, const char *s, unsigned count) 830static void siu_console_write(struct console *con, const char *s, unsigned count)
825{ 831{
826 struct uart_port *port; 832 struct uart_port *port;
827 uint8_t ier; 833 uint8_t ier;
828 unsigned i;
829 834
830 port = &siu_uart_ports[con->index]; 835 port = &siu_uart_ports[con->index];
831 836
832 ier = siu_read(port, UART_IER); 837 ier = siu_read(port, UART_IER);
833 siu_write(port, UART_IER, 0); 838 siu_write(port, UART_IER, 0);
834 839
835 for (i = 0; i < count && *s != '\0'; i++, s++) { 840 uart_console_write(port, s, count, siu_console_putchar);
836 wait_for_xmitr(port);
837 siu_write(port, UART_TX, *s);
838 if (*s == '\n') {
839 wait_for_xmitr(port);
840 siu_write(port, UART_TX, '\r');
841 }
842 }
843 841
844 wait_for_xmitr(port); 842 wait_for_xmitr(port);
845 siu_write(port, UART_IER, ier); 843 siu_write(port, UART_IER, ier);
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 6756d0fab6fe..2dffa8e303b2 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -186,8 +186,6 @@ static struct tty_driver *serial_driver;
186#define RS_STROBE_TIME 10 186#define RS_STROBE_TIME 10
187#define RS_ISR_PASS_LIMIT 256 187#define RS_ISR_PASS_LIMIT 256
188 188
189#define _INLINE_ inline
190
191static void probe_sccs(void); 189static void probe_sccs(void);
192static void change_speed(struct dec_serial *info); 190static void change_speed(struct dec_serial *info);
193static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 191static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
@@ -344,14 +342,13 @@ static inline void rs_recv_clear(struct dec_zschannel *zsc)
344 * This routine is used by the interrupt handler to schedule 342 * This routine is used by the interrupt handler to schedule
345 * processing in the software interrupt portion of the driver. 343 * processing in the software interrupt portion of the driver.
346 */ 344 */
347static _INLINE_ void rs_sched_event(struct dec_serial *info, int event) 345static void rs_sched_event(struct dec_serial *info, int event)
348{ 346{
349 info->event |= 1 << event; 347 info->event |= 1 << event;
350 tasklet_schedule(&info->tlet); 348 tasklet_schedule(&info->tlet);
351} 349}
352 350
353static _INLINE_ void receive_chars(struct dec_serial *info, 351static void receive_chars(struct dec_serial *info, struct pt_regs *regs)
354 struct pt_regs *regs)
355{ 352{
356 struct tty_struct *tty = info->tty; 353 struct tty_struct *tty = info->tty;
357 unsigned char ch, stat, flag; 354 unsigned char ch, stat, flag;
@@ -441,7 +438,7 @@ static void transmit_chars(struct dec_serial *info)
441 rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); 438 rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
442} 439}
443 440
444static _INLINE_ void status_handle(struct dec_serial *info) 441static void status_handle(struct dec_serial *info)
445{ 442{
446 unsigned char stat; 443 unsigned char stat;
447 444
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index ea1134eb47c8..8e8356c1c229 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -31,6 +31,7 @@
31#include <linux/poll.h> 31#include <linux/poll.h>
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33#include <linux/idr.h> 33#include <linux/idr.h>
34#include <linux/mutex.h>
34 35
35#include "debug.h" 36#include "debug.h"
36#include "v9fs.h" 37#include "v9fs.h"
@@ -110,7 +111,7 @@ static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
110static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); 111static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
111static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16); 112static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16);
112 113
113static DECLARE_MUTEX(v9fs_mux_task_lock); 114static DEFINE_MUTEX(v9fs_mux_task_lock);
114static struct workqueue_struct *v9fs_mux_wq; 115static struct workqueue_struct *v9fs_mux_wq;
115 116
116static int v9fs_mux_num; 117static int v9fs_mux_num;
@@ -166,7 +167,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
166 167
167 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num, 168 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
168 v9fs_mux_poll_task_num); 169 v9fs_mux_poll_task_num);
169 up(&v9fs_mux_task_lock); 170 mutex_lock(&v9fs_mux_task_lock);
170 171
171 n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1); 172 n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1);
172 if (n > v9fs_mux_poll_task_num) { 173 if (n > v9fs_mux_poll_task_num) {
@@ -225,7 +226,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
225 } 226 }
226 227
227 v9fs_mux_num++; 228 v9fs_mux_num++;
228 down(&v9fs_mux_task_lock); 229 mutex_unlock(&v9fs_mux_task_lock);
229 230
230 return 0; 231 return 0;
231} 232}
@@ -235,7 +236,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
235 int i; 236 int i;
236 struct v9fs_mux_poll_task *vpt; 237 struct v9fs_mux_poll_task *vpt;
237 238
238 up(&v9fs_mux_task_lock); 239 mutex_lock(&v9fs_mux_task_lock);
239 vpt = m->poll_task; 240 vpt = m->poll_task;
240 list_del(&m->mux_list); 241 list_del(&m->mux_list);
241 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { 242 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
@@ -252,7 +253,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
252 v9fs_mux_poll_task_num--; 253 v9fs_mux_poll_task_num--;
253 } 254 }
254 v9fs_mux_num--; 255 v9fs_mux_num--;
255 down(&v9fs_mux_task_lock); 256 mutex_unlock(&v9fs_mux_task_lock);
256} 257}
257 258
258/** 259/**
diff --git a/fs/adfs/file.c b/fs/adfs/file.c
index afebbfde6968..6af10885f9d6 100644
--- a/fs/adfs/file.c
+++ b/fs/adfs/file.c
@@ -19,11 +19,7 @@
19 * 19 *
20 * adfs regular file handling primitives 20 * adfs regular file handling primitives
21 */ 21 */
22#include <linux/errno.h>
23#include <linux/fs.h> 22#include <linux/fs.h>
24#include <linux/fcntl.h>
25#include <linux/time.h>
26#include <linux/stat.h>
27#include <linux/buffer_head.h> /* for file_fsync() */ 23#include <linux/buffer_head.h> /* for file_fsync() */
28#include <linux/adfs_fs.h> 24#include <linux/adfs_fs.h>
29 25
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 385bed09b0d8..f54c5b21f876 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -13,6 +13,7 @@
13/* Internal header file for autofs */ 13/* Internal header file for autofs */
14 14
15#include <linux/auto_fs4.h> 15#include <linux/auto_fs4.h>
16#include <linux/mutex.h>
16#include <linux/list.h> 17#include <linux/list.h>
17 18
18/* This is the range of ioctl() numbers we claim as ours */ 19/* This is the range of ioctl() numbers we claim as ours */
@@ -102,7 +103,7 @@ struct autofs_sb_info {
102 int reghost_enabled; 103 int reghost_enabled;
103 int needs_reghost; 104 int needs_reghost;
104 struct super_block *sb; 105 struct super_block *sb;
105 struct semaphore wq_sem; 106 struct mutex wq_mutex;
106 spinlock_t fs_lock; 107 spinlock_t fs_lock;
107 struct autofs_wait_queue *queues; /* Wait queue pointer */ 108 struct autofs_wait_queue *queues; /* Wait queue pointer */
108}; 109};
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 2d3082854a29..1ad98d48e550 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -269,7 +269,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
269 sbi->sb = s; 269 sbi->sb = s;
270 sbi->version = 0; 270 sbi->version = 0;
271 sbi->sub_version = 0; 271 sbi->sub_version = 0;
272 init_MUTEX(&sbi->wq_sem); 272 mutex_init(&sbi->wq_mutex);
273 spin_lock_init(&sbi->fs_lock); 273 spin_lock_init(&sbi->fs_lock);
274 sbi->queues = NULL; 274 sbi->queues = NULL;
275 s->s_blocksize = 1024; 275 s->s_blocksize = 1024;
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 394ff36ef8f1..be78e9378c03 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -178,7 +178,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
178 return -ENOENT; 178 return -ENOENT;
179 } 179 }
180 180
181 if (down_interruptible(&sbi->wq_sem)) { 181 if (mutex_lock_interruptible(&sbi->wq_mutex)) {
182 kfree(name); 182 kfree(name);
183 return -EINTR; 183 return -EINTR;
184 } 184 }
@@ -194,7 +194,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
194 /* Can't wait for an expire if there's no mount */ 194 /* Can't wait for an expire if there's no mount */
195 if (notify == NFY_NONE && !d_mountpoint(dentry)) { 195 if (notify == NFY_NONE && !d_mountpoint(dentry)) {
196 kfree(name); 196 kfree(name);
197 up(&sbi->wq_sem); 197 mutex_unlock(&sbi->wq_mutex);
198 return -ENOENT; 198 return -ENOENT;
199 } 199 }
200 200
@@ -202,7 +202,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
202 wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL); 202 wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
203 if ( !wq ) { 203 if ( !wq ) {
204 kfree(name); 204 kfree(name);
205 up(&sbi->wq_sem); 205 mutex_unlock(&sbi->wq_mutex);
206 return -ENOMEM; 206 return -ENOMEM;
207 } 207 }
208 208
@@ -218,10 +218,10 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
218 wq->status = -EINTR; /* Status return if interrupted */ 218 wq->status = -EINTR; /* Status return if interrupted */
219 atomic_set(&wq->wait_ctr, 2); 219 atomic_set(&wq->wait_ctr, 2);
220 atomic_set(&wq->notified, 1); 220 atomic_set(&wq->notified, 1);
221 up(&sbi->wq_sem); 221 mutex_unlock(&sbi->wq_mutex);
222 } else { 222 } else {
223 atomic_inc(&wq->wait_ctr); 223 atomic_inc(&wq->wait_ctr);
224 up(&sbi->wq_sem); 224 mutex_unlock(&sbi->wq_mutex);
225 kfree(name); 225 kfree(name);
226 DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d", 226 DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
227 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify); 227 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
@@ -282,19 +282,19 @@ int autofs4_wait_release(struct autofs_sb_info *sbi, autofs_wqt_t wait_queue_tok
282{ 282{
283 struct autofs_wait_queue *wq, **wql; 283 struct autofs_wait_queue *wq, **wql;
284 284
285 down(&sbi->wq_sem); 285 mutex_lock(&sbi->wq_mutex);
286 for ( wql = &sbi->queues ; (wq = *wql) != 0 ; wql = &wq->next ) { 286 for ( wql = &sbi->queues ; (wq = *wql) != 0 ; wql = &wq->next ) {
287 if ( wq->wait_queue_token == wait_queue_token ) 287 if ( wq->wait_queue_token == wait_queue_token )
288 break; 288 break;
289 } 289 }
290 290
291 if ( !wq ) { 291 if ( !wq ) {
292 up(&sbi->wq_sem); 292 mutex_unlock(&sbi->wq_mutex);
293 return -EINVAL; 293 return -EINVAL;
294 } 294 }
295 295
296 *wql = wq->next; /* Unlink from chain */ 296 *wql = wq->next; /* Unlink from chain */
297 up(&sbi->wq_sem); 297 mutex_unlock(&sbi->wq_mutex);
298 kfree(wq->name); 298 kfree(wq->name);
299 wq->name = NULL; /* Do not wait on this queue */ 299 wq->name = NULL; /* Do not wait on this queue */
300 300
diff --git a/fs/bio.c b/fs/bio.c
index 1f3bb501c262..8f1d2e815c96 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1243,11 +1243,11 @@ static int __init init_bio(void)
1243 scale = 4; 1243 scale = 4;
1244 1244
1245 /* 1245 /*
1246 * scale number of entries 1246 * Limit number of entries reserved -- mempools are only used when
1247 * the system is completely unable to allocate memory, so we only
1248 * need enough to make progress.
1247 */ 1249 */
1248 bvec_pool_entries = megabytes * 2; 1250 bvec_pool_entries = 1 + scale;
1249 if (bvec_pool_entries > 256)
1250 bvec_pool_entries = 256;
1251 1251
1252 fs_bio_set = bioset_create(BIO_POOL_SIZE, bvec_pool_entries, scale); 1252 fs_bio_set = bioset_create(BIO_POOL_SIZE, bvec_pool_entries, scale);
1253 if (!fs_bio_set) 1253 if (!fs_bio_set)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6e50346fb1ee..44d05e6e34db 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -265,8 +265,8 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
265 SLAB_CTOR_CONSTRUCTOR) 265 SLAB_CTOR_CONSTRUCTOR)
266 { 266 {
267 memset(bdev, 0, sizeof(*bdev)); 267 memset(bdev, 0, sizeof(*bdev));
268 sema_init(&bdev->bd_sem, 1); 268 mutex_init(&bdev->bd_mutex);
269 sema_init(&bdev->bd_mount_sem, 1); 269 mutex_init(&bdev->bd_mount_mutex);
270 INIT_LIST_HEAD(&bdev->bd_inodes); 270 INIT_LIST_HEAD(&bdev->bd_inodes);
271 INIT_LIST_HEAD(&bdev->bd_list); 271 INIT_LIST_HEAD(&bdev->bd_list);
272 inode_init_once(&ei->vfs_inode); 272 inode_init_once(&ei->vfs_inode);
@@ -574,7 +574,7 @@ static int do_open(struct block_device *bdev, struct file *file)
574 } 574 }
575 owner = disk->fops->owner; 575 owner = disk->fops->owner;
576 576
577 down(&bdev->bd_sem); 577 mutex_lock(&bdev->bd_mutex);
578 if (!bdev->bd_openers) { 578 if (!bdev->bd_openers) {
579 bdev->bd_disk = disk; 579 bdev->bd_disk = disk;
580 bdev->bd_contains = bdev; 580 bdev->bd_contains = bdev;
@@ -605,21 +605,21 @@ static int do_open(struct block_device *bdev, struct file *file)
605 if (ret) 605 if (ret)
606 goto out_first; 606 goto out_first;
607 bdev->bd_contains = whole; 607 bdev->bd_contains = whole;
608 down(&whole->bd_sem); 608 mutex_lock(&whole->bd_mutex);
609 whole->bd_part_count++; 609 whole->bd_part_count++;
610 p = disk->part[part - 1]; 610 p = disk->part[part - 1];
611 bdev->bd_inode->i_data.backing_dev_info = 611 bdev->bd_inode->i_data.backing_dev_info =
612 whole->bd_inode->i_data.backing_dev_info; 612 whole->bd_inode->i_data.backing_dev_info;
613 if (!(disk->flags & GENHD_FL_UP) || !p || !p->nr_sects) { 613 if (!(disk->flags & GENHD_FL_UP) || !p || !p->nr_sects) {
614 whole->bd_part_count--; 614 whole->bd_part_count--;
615 up(&whole->bd_sem); 615 mutex_unlock(&whole->bd_mutex);
616 ret = -ENXIO; 616 ret = -ENXIO;
617 goto out_first; 617 goto out_first;
618 } 618 }
619 kobject_get(&p->kobj); 619 kobject_get(&p->kobj);
620 bdev->bd_part = p; 620 bdev->bd_part = p;
621 bd_set_size(bdev, (loff_t) p->nr_sects << 9); 621 bd_set_size(bdev, (loff_t) p->nr_sects << 9);
622 up(&whole->bd_sem); 622 mutex_unlock(&whole->bd_mutex);
623 } 623 }
624 } else { 624 } else {
625 put_disk(disk); 625 put_disk(disk);
@@ -633,13 +633,13 @@ static int do_open(struct block_device *bdev, struct file *file)
633 if (bdev->bd_invalidated) 633 if (bdev->bd_invalidated)
634 rescan_partitions(bdev->bd_disk, bdev); 634 rescan_partitions(bdev->bd_disk, bdev);
635 } else { 635 } else {
636 down(&bdev->bd_contains->bd_sem); 636 mutex_lock(&bdev->bd_contains->bd_mutex);
637 bdev->bd_contains->bd_part_count++; 637 bdev->bd_contains->bd_part_count++;
638 up(&bdev->bd_contains->bd_sem); 638 mutex_unlock(&bdev->bd_contains->bd_mutex);
639 } 639 }
640 } 640 }
641 bdev->bd_openers++; 641 bdev->bd_openers++;
642 up(&bdev->bd_sem); 642 mutex_unlock(&bdev->bd_mutex);
643 unlock_kernel(); 643 unlock_kernel();
644 return 0; 644 return 0;
645 645
@@ -652,7 +652,7 @@ out_first:
652 put_disk(disk); 652 put_disk(disk);
653 module_put(owner); 653 module_put(owner);
654out: 654out:
655 up(&bdev->bd_sem); 655 mutex_unlock(&bdev->bd_mutex);
656 unlock_kernel(); 656 unlock_kernel();
657 if (ret) 657 if (ret)
658 bdput(bdev); 658 bdput(bdev);
@@ -714,7 +714,7 @@ int blkdev_put(struct block_device *bdev)
714 struct inode *bd_inode = bdev->bd_inode; 714 struct inode *bd_inode = bdev->bd_inode;
715 struct gendisk *disk = bdev->bd_disk; 715 struct gendisk *disk = bdev->bd_disk;
716 716
717 down(&bdev->bd_sem); 717 mutex_lock(&bdev->bd_mutex);
718 lock_kernel(); 718 lock_kernel();
719 if (!--bdev->bd_openers) { 719 if (!--bdev->bd_openers) {
720 sync_blockdev(bdev); 720 sync_blockdev(bdev);
@@ -724,9 +724,9 @@ int blkdev_put(struct block_device *bdev)
724 if (disk->fops->release) 724 if (disk->fops->release)
725 ret = disk->fops->release(bd_inode, NULL); 725 ret = disk->fops->release(bd_inode, NULL);
726 } else { 726 } else {
727 down(&bdev->bd_contains->bd_sem); 727 mutex_lock(&bdev->bd_contains->bd_mutex);
728 bdev->bd_contains->bd_part_count--; 728 bdev->bd_contains->bd_part_count--;
729 up(&bdev->bd_contains->bd_sem); 729 mutex_unlock(&bdev->bd_contains->bd_mutex);
730 } 730 }
731 if (!bdev->bd_openers) { 731 if (!bdev->bd_openers) {
732 struct module *owner = disk->fops->owner; 732 struct module *owner = disk->fops->owner;
@@ -746,7 +746,7 @@ int blkdev_put(struct block_device *bdev)
746 bdev->bd_contains = NULL; 746 bdev->bd_contains = NULL;
747 } 747 }
748 unlock_kernel(); 748 unlock_kernel();
749 up(&bdev->bd_sem); 749 mutex_unlock(&bdev->bd_mutex);
750 bdput(bdev); 750 bdput(bdev);
751 return ret; 751 return ret;
752} 752}
diff --git a/fs/buffer.c b/fs/buffer.c
index 1d3683d496f8..0d6ca7bac6c8 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -201,7 +201,7 @@ int fsync_bdev(struct block_device *bdev)
201 * freeze_bdev -- lock a filesystem and force it into a consistent state 201 * freeze_bdev -- lock a filesystem and force it into a consistent state
202 * @bdev: blockdevice to lock 202 * @bdev: blockdevice to lock
203 * 203 *
204 * This takes the block device bd_mount_sem to make sure no new mounts 204 * This takes the block device bd_mount_mutex to make sure no new mounts
205 * happen on bdev until thaw_bdev() is called. 205 * happen on bdev until thaw_bdev() is called.
206 * If a superblock is found on this device, we take the s_umount semaphore 206 * If a superblock is found on this device, we take the s_umount semaphore
207 * on it to make sure nobody unmounts until the snapshot creation is done. 207 * on it to make sure nobody unmounts until the snapshot creation is done.
@@ -210,7 +210,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
210{ 210{
211 struct super_block *sb; 211 struct super_block *sb;
212 212
213 down(&bdev->bd_mount_sem); 213 mutex_lock(&bdev->bd_mount_mutex);
214 sb = get_super(bdev); 214 sb = get_super(bdev);
215 if (sb && !(sb->s_flags & MS_RDONLY)) { 215 if (sb && !(sb->s_flags & MS_RDONLY)) {
216 sb->s_frozen = SB_FREEZE_WRITE; 216 sb->s_frozen = SB_FREEZE_WRITE;
@@ -264,7 +264,7 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb)
264 drop_super(sb); 264 drop_super(sb);
265 } 265 }
266 266
267 up(&bdev->bd_mount_sem); 267 mutex_unlock(&bdev->bd_mount_mutex);
268} 268}
269EXPORT_SYMBOL(thaw_bdev); 269EXPORT_SYMBOL(thaw_bdev);
270 270
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index fed55e3c53df..632561dd9c50 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -138,9 +138,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
138 cifs_sb = CIFS_SB(inode->i_sb); 138 cifs_sb = CIFS_SB(inode->i_sb);
139 pTcon = cifs_sb->tcon; 139 pTcon = cifs_sb->tcon;
140 140
141 down(&direntry->d_sb->s_vfs_rename_sem); 141 mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
142 full_path = build_path_from_dentry(direntry); 142 full_path = build_path_from_dentry(direntry);
143 up(&direntry->d_sb->s_vfs_rename_sem); 143 mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
144 if(full_path == NULL) { 144 if(full_path == NULL) {
145 FreeXid(xid); 145 FreeXid(xid);
146 return -ENOMEM; 146 return -ENOMEM;
@@ -317,9 +317,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
317 cifs_sb = CIFS_SB(inode->i_sb); 317 cifs_sb = CIFS_SB(inode->i_sb);
318 pTcon = cifs_sb->tcon; 318 pTcon = cifs_sb->tcon;
319 319
320 down(&direntry->d_sb->s_vfs_rename_sem); 320 mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
321 full_path = build_path_from_dentry(direntry); 321 full_path = build_path_from_dentry(direntry);
322 up(&direntry->d_sb->s_vfs_rename_sem); 322 mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
323 if(full_path == NULL) 323 if(full_path == NULL)
324 rc = -ENOMEM; 324 rc = -ENOMEM;
325 else if (pTcon->ses->capabilities & CAP_UNIX) { 325 else if (pTcon->ses->capabilities & CAP_UNIX) {
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index a7a47bb36bf3..ec4dfe9bf5ef 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -86,9 +86,9 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
86 cifs_sb = CIFS_SB(file->f_dentry->d_sb); 86 cifs_sb = CIFS_SB(file->f_dentry->d_sb);
87 pTcon = cifs_sb->tcon; 87 pTcon = cifs_sb->tcon;
88 88
89 down(&file->f_dentry->d_sb->s_vfs_rename_sem); 89 mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
90 full_path = build_path_from_dentry(file->f_dentry); 90 full_path = build_path_from_dentry(file->f_dentry);
91 up(&file->f_dentry->d_sb->s_vfs_rename_sem); 91 mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
92 92
93 if(full_path == NULL) { 93 if(full_path == NULL) {
94 rc = -ENOMEM; 94 rc = -ENOMEM;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 675bd2568297..165d67426381 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -203,9 +203,9 @@ int cifs_open(struct inode *inode, struct file *file)
203 } 203 }
204 } 204 }
205 205
206 down(&inode->i_sb->s_vfs_rename_sem); 206 mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
207 full_path = build_path_from_dentry(file->f_dentry); 207 full_path = build_path_from_dentry(file->f_dentry);
208 up(&inode->i_sb->s_vfs_rename_sem); 208 mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
209 if (full_path == NULL) { 209 if (full_path == NULL) {
210 FreeXid(xid); 210 FreeXid(xid);
211 return -ENOMEM; 211 return -ENOMEM;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 59359911f481..ff93a9f81d1c 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -574,9 +574,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
574 574
575 /* Unlink can be called from rename so we can not grab the sem here 575 /* Unlink can be called from rename so we can not grab the sem here
576 since we deadlock otherwise */ 576 since we deadlock otherwise */
577/* down(&direntry->d_sb->s_vfs_rename_sem);*/ 577/* mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);*/
578 full_path = build_path_from_dentry(direntry); 578 full_path = build_path_from_dentry(direntry);
579/* up(&direntry->d_sb->s_vfs_rename_sem);*/ 579/* mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);*/
580 if (full_path == NULL) { 580 if (full_path == NULL) {
581 FreeXid(xid); 581 FreeXid(xid);
582 return -ENOMEM; 582 return -ENOMEM;
@@ -718,9 +718,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
718 cifs_sb = CIFS_SB(inode->i_sb); 718 cifs_sb = CIFS_SB(inode->i_sb);
719 pTcon = cifs_sb->tcon; 719 pTcon = cifs_sb->tcon;
720 720
721 down(&inode->i_sb->s_vfs_rename_sem); 721 mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
722 full_path = build_path_from_dentry(direntry); 722 full_path = build_path_from_dentry(direntry);
723 up(&inode->i_sb->s_vfs_rename_sem); 723 mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
724 if (full_path == NULL) { 724 if (full_path == NULL) {
725 FreeXid(xid); 725 FreeXid(xid);
726 return -ENOMEM; 726 return -ENOMEM;
@@ -803,9 +803,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
803 cifs_sb = CIFS_SB(inode->i_sb); 803 cifs_sb = CIFS_SB(inode->i_sb);
804 pTcon = cifs_sb->tcon; 804 pTcon = cifs_sb->tcon;
805 805
806 down(&inode->i_sb->s_vfs_rename_sem); 806 mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
807 full_path = build_path_from_dentry(direntry); 807 full_path = build_path_from_dentry(direntry);
808 up(&inode->i_sb->s_vfs_rename_sem); 808 mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
809 if (full_path == NULL) { 809 if (full_path == NULL) {
810 FreeXid(xid); 810 FreeXid(xid);
811 return -ENOMEM; 811 return -ENOMEM;
@@ -1137,9 +1137,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1137 rc = 0; 1137 rc = 0;
1138 } 1138 }
1139 1139
1140 down(&direntry->d_sb->s_vfs_rename_sem); 1140 mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
1141 full_path = build_path_from_dentry(direntry); 1141 full_path = build_path_from_dentry(direntry);
1142 up(&direntry->d_sb->s_vfs_rename_sem); 1142 mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
1143 if (full_path == NULL) { 1143 if (full_path == NULL) {
1144 FreeXid(xid); 1144 FreeXid(xid);
1145 return -ENOMEM; 1145 return -ENOMEM;
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 0f99aae33162..8d0da7c87c7b 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -48,10 +48,10 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
48/* No need to check for cross device links since server will do that 48/* No need to check for cross device links since server will do that
49 BB note DFS case in future though (when we may have to check) */ 49 BB note DFS case in future though (when we may have to check) */
50 50
51 down(&inode->i_sb->s_vfs_rename_sem); 51 mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
52 fromName = build_path_from_dentry(old_file); 52 fromName = build_path_from_dentry(old_file);
53 toName = build_path_from_dentry(direntry); 53 toName = build_path_from_dentry(direntry);
54 up(&inode->i_sb->s_vfs_rename_sem); 54 mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
55 if((fromName == NULL) || (toName == NULL)) { 55 if((fromName == NULL) || (toName == NULL)) {
56 rc = -ENOMEM; 56 rc = -ENOMEM;
57 goto cifs_hl_exit; 57 goto cifs_hl_exit;
@@ -103,9 +103,9 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
103 103
104 xid = GetXid(); 104 xid = GetXid();
105 105
106 down(&direntry->d_sb->s_vfs_rename_sem); 106 mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
107 full_path = build_path_from_dentry(direntry); 107 full_path = build_path_from_dentry(direntry);
108 up(&direntry->d_sb->s_vfs_rename_sem); 108 mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
109 109
110 if (!full_path) 110 if (!full_path)
111 goto out_no_free; 111 goto out_no_free;
@@ -164,9 +164,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
164 cifs_sb = CIFS_SB(inode->i_sb); 164 cifs_sb = CIFS_SB(inode->i_sb);
165 pTcon = cifs_sb->tcon; 165 pTcon = cifs_sb->tcon;
166 166
167 down(&inode->i_sb->s_vfs_rename_sem); 167 mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
168 full_path = build_path_from_dentry(direntry); 168 full_path = build_path_from_dentry(direntry);
169 up(&inode->i_sb->s_vfs_rename_sem); 169 mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
170 170
171 if(full_path == NULL) { 171 if(full_path == NULL) {
172 FreeXid(xid); 172 FreeXid(xid);
@@ -232,9 +232,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
232 232
233/* BB would it be safe against deadlock to grab this sem 233/* BB would it be safe against deadlock to grab this sem
234 even though rename itself grabs the sem and calls lookup? */ 234 even though rename itself grabs the sem and calls lookup? */
235/* down(&inode->i_sb->s_vfs_rename_sem);*/ 235/* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/
236 full_path = build_path_from_dentry(direntry); 236 full_path = build_path_from_dentry(direntry);
237/* up(&inode->i_sb->s_vfs_rename_sem);*/ 237/* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/
238 238
239 if(full_path == NULL) { 239 if(full_path == NULL) {
240 FreeXid(xid); 240 FreeXid(xid);
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 288cc048d37f..edb3b6eb34bc 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -404,9 +404,9 @@ static int initiate_cifs_search(const int xid, struct file *file)
404 if(pTcon == NULL) 404 if(pTcon == NULL)
405 return -EINVAL; 405 return -EINVAL;
406 406
407 down(&file->f_dentry->d_sb->s_vfs_rename_sem); 407 mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
408 full_path = build_path_from_dentry(file->f_dentry); 408 full_path = build_path_from_dentry(file->f_dentry);
409 up(&file->f_dentry->d_sb->s_vfs_rename_sem); 409 mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
410 410
411 if(full_path == NULL) { 411 if(full_path == NULL) {
412 return -ENOMEM; 412 return -ENOMEM;
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 777e3363c2a4..3938444d87b2 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -62,9 +62,9 @@ int cifs_removexattr(struct dentry * direntry, const char * ea_name)
62 cifs_sb = CIFS_SB(sb); 62 cifs_sb = CIFS_SB(sb);
63 pTcon = cifs_sb->tcon; 63 pTcon = cifs_sb->tcon;
64 64
65 down(&sb->s_vfs_rename_sem); 65 mutex_lock(&sb->s_vfs_rename_mutex);
66 full_path = build_path_from_dentry(direntry); 66 full_path = build_path_from_dentry(direntry);
67 up(&sb->s_vfs_rename_sem); 67 mutex_unlock(&sb->s_vfs_rename_mutex);
68 if(full_path == NULL) { 68 if(full_path == NULL) {
69 FreeXid(xid); 69 FreeXid(xid);
70 return -ENOMEM; 70 return -ENOMEM;
@@ -116,9 +116,9 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name,
116 cifs_sb = CIFS_SB(sb); 116 cifs_sb = CIFS_SB(sb);
117 pTcon = cifs_sb->tcon; 117 pTcon = cifs_sb->tcon;
118 118
119 down(&sb->s_vfs_rename_sem); 119 mutex_lock(&sb->s_vfs_rename_mutex);
120 full_path = build_path_from_dentry(direntry); 120 full_path = build_path_from_dentry(direntry);
121 up(&sb->s_vfs_rename_sem); 121 mutex_unlock(&sb->s_vfs_rename_mutex);
122 if(full_path == NULL) { 122 if(full_path == NULL) {
123 FreeXid(xid); 123 FreeXid(xid);
124 return -ENOMEM; 124 return -ENOMEM;
@@ -223,9 +223,9 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name,
223 cifs_sb = CIFS_SB(sb); 223 cifs_sb = CIFS_SB(sb);
224 pTcon = cifs_sb->tcon; 224 pTcon = cifs_sb->tcon;
225 225
226 down(&sb->s_vfs_rename_sem); 226 mutex_lock(&sb->s_vfs_rename_mutex);
227 full_path = build_path_from_dentry(direntry); 227 full_path = build_path_from_dentry(direntry);
228 up(&sb->s_vfs_rename_sem); 228 mutex_unlock(&sb->s_vfs_rename_mutex);
229 if(full_path == NULL) { 229 if(full_path == NULL) {
230 FreeXid(xid); 230 FreeXid(xid);
231 return -ENOMEM; 231 return -ENOMEM;
@@ -341,9 +341,9 @@ ssize_t cifs_listxattr(struct dentry * direntry, char * data, size_t buf_size)
341 cifs_sb = CIFS_SB(sb); 341 cifs_sb = CIFS_SB(sb);
342 pTcon = cifs_sb->tcon; 342 pTcon = cifs_sb->tcon;
343 343
344 down(&sb->s_vfs_rename_sem); 344 mutex_lock(&sb->s_vfs_rename_mutex);
345 full_path = build_path_from_dentry(direntry); 345 full_path = build_path_from_dentry(direntry);
346 up(&sb->s_vfs_rename_sem); 346 mutex_unlock(&sb->s_vfs_rename_mutex);
347 if(full_path == NULL) { 347 if(full_path == NULL) {
348 FreeXid(xid); 348 FreeXid(xid);
349 return -ENOMEM; 349 return -ENOMEM;
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index bfb8a230bac9..14c5620b5cab 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -18,6 +18,7 @@
18#include <linux/mount.h> 18#include <linux/mount.h>
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/devpts_fs.h> 20#include <linux/devpts_fs.h>
21#include <linux/parser.h>
21 22
22#define DEVPTS_SUPER_MAGIC 0x1cd1 23#define DEVPTS_SUPER_MAGIC 0x1cd1
23 24
@@ -32,39 +33,60 @@ static struct {
32 umode_t mode; 33 umode_t mode;
33} config = {.mode = 0600}; 34} config = {.mode = 0600};
34 35
36enum {
37 Opt_uid, Opt_gid, Opt_mode,
38 Opt_err
39};
40
41static match_table_t tokens = {
42 {Opt_uid, "uid=%u"},
43 {Opt_gid, "gid=%u"},
44 {Opt_mode, "mode=%o"},
45 {Opt_err, NULL}
46};
47
35static int devpts_remount(struct super_block *sb, int *flags, char *data) 48static int devpts_remount(struct super_block *sb, int *flags, char *data)
36{ 49{
37 int setuid = 0; 50 char *p;
38 int setgid = 0; 51
39 uid_t uid = 0; 52 config.setuid = 0;
40 gid_t gid = 0; 53 config.setgid = 0;
41 umode_t mode = 0600; 54 config.uid = 0;
42 char *this_char; 55 config.gid = 0;
43 56 config.mode = 0600;
44 this_char = NULL; 57
45 while ((this_char = strsep(&data, ",")) != NULL) { 58 while ((p = strsep(&data, ",")) != NULL) {
46 int n; 59 substring_t args[MAX_OPT_ARGS];
47 char dummy; 60 int token;
48 if (!*this_char) 61 int option;
62
63 if (!*p)
49 continue; 64 continue;
50 if (sscanf(this_char, "uid=%i%c", &n, &dummy) == 1) { 65
51 setuid = 1; 66 token = match_token(p, tokens, args);
52 uid = n; 67 switch (token) {
53 } else if (sscanf(this_char, "gid=%i%c", &n, &dummy) == 1) { 68 case Opt_uid:
54 setgid = 1; 69 if (match_int(&args[0], &option))
55 gid = n; 70 return -EINVAL;
56 } else if (sscanf(this_char, "mode=%o%c", &n, &dummy) == 1) 71 config.uid = option;
57 mode = n & ~S_IFMT; 72 config.setuid = 1;
58 else { 73 break;
59 printk("devpts: called with bogus options\n"); 74 case Opt_gid:
75 if (match_int(&args[0], &option))
76 return -EINVAL;
77 config.gid = option;
78 config.setgid = 1;
79 break;
80 case Opt_mode:
81 if (match_octal(&args[0], &option))
82 return -EINVAL;
83 config.mode = option & ~S_IFMT;
84 break;
85 default:
86 printk(KERN_ERR "devpts: called with bogus options\n");
60 return -EINVAL; 87 return -EINVAL;
61 } 88 }
62 } 89 }
63 config.setuid = setuid;
64 config.setgid = setgid;
65 config.uid = uid;
66 config.gid = gid;
67 config.mode = mode;
68 90
69 return 0; 91 return 0;
70} 92}
diff --git a/fs/dquot.c b/fs/dquot.c
index 1966c890b48d..acf07e581f8c 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -103,12 +103,12 @@
103 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that 103 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that
104 * for altering the flag i_mutex is also needed). If operation is holding 104 * for altering the flag i_mutex is also needed). If operation is holding
105 * reference to dquot in other way (e.g. quotactl ops) it must be guarded by 105 * reference to dquot in other way (e.g. quotactl ops) it must be guarded by
106 * dqonoff_sem. 106 * dqonoff_mutex.
107 * This locking assures that: 107 * This locking assures that:
108 * a) update/access to dquot pointers in inode is serialized 108 * a) update/access to dquot pointers in inode is serialized
109 * b) everyone is guarded against invalidate_dquots() 109 * b) everyone is guarded against invalidate_dquots()
110 * 110 *
111 * Each dquot has its dq_lock semaphore. Locked dquots might not be referenced 111 * Each dquot has its dq_lock mutex. Locked dquots might not be referenced
112 * from inodes (dquot_alloc_space() and such don't check the dq_lock). 112 * from inodes (dquot_alloc_space() and such don't check the dq_lock).
113 * Currently dquot is locked only when it is being read to memory (or space for 113 * Currently dquot is locked only when it is being read to memory (or space for
114 * it is being allocated) on the first dqget() and when it is being released on 114 * it is being allocated) on the first dqget() and when it is being released on
@@ -118,9 +118,9 @@
118 * spinlock to internal buffers before writing. 118 * spinlock to internal buffers before writing.
119 * 119 *
120 * Lock ordering (including related VFS locks) is the following: 120 * Lock ordering (including related VFS locks) is the following:
121 * i_mutex > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem > 121 * i_mutex > dqonoff_sem > journal_lock > dqptr_sem > dquot->dq_lock >
122 * > dquot->dq_lock > dqio_sem 122 * dqio_mutex
123 * i_mutex on quota files is special (it's below dqio_sem) 123 * i_mutex on quota files is special (it's below dqio_mutex)
124 */ 124 */
125 125
126static DEFINE_SPINLOCK(dq_list_lock); 126static DEFINE_SPINLOCK(dq_list_lock);
@@ -281,8 +281,8 @@ static inline void remove_inuse(struct dquot *dquot)
281 281
282static void wait_on_dquot(struct dquot *dquot) 282static void wait_on_dquot(struct dquot *dquot)
283{ 283{
284 down(&dquot->dq_lock); 284 mutex_lock(&dquot->dq_lock);
285 up(&dquot->dq_lock); 285 mutex_unlock(&dquot->dq_lock);
286} 286}
287 287
288#define mark_dquot_dirty(dquot) ((dquot)->dq_sb->dq_op->mark_dirty(dquot)) 288#define mark_dquot_dirty(dquot) ((dquot)->dq_sb->dq_op->mark_dirty(dquot))
@@ -321,8 +321,8 @@ int dquot_acquire(struct dquot *dquot)
321 int ret = 0, ret2 = 0; 321 int ret = 0, ret2 = 0;
322 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); 322 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
323 323
324 down(&dquot->dq_lock); 324 mutex_lock(&dquot->dq_lock);
325 down(&dqopt->dqio_sem); 325 mutex_lock(&dqopt->dqio_mutex);
326 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) 326 if (!test_bit(DQ_READ_B, &dquot->dq_flags))
327 ret = dqopt->ops[dquot->dq_type]->read_dqblk(dquot); 327 ret = dqopt->ops[dquot->dq_type]->read_dqblk(dquot);
328 if (ret < 0) 328 if (ret < 0)
@@ -343,8 +343,8 @@ int dquot_acquire(struct dquot *dquot)
343 } 343 }
344 set_bit(DQ_ACTIVE_B, &dquot->dq_flags); 344 set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
345out_iolock: 345out_iolock:
346 up(&dqopt->dqio_sem); 346 mutex_unlock(&dqopt->dqio_mutex);
347 up(&dquot->dq_lock); 347 mutex_unlock(&dquot->dq_lock);
348 return ret; 348 return ret;
349} 349}
350 350
@@ -356,7 +356,7 @@ int dquot_commit(struct dquot *dquot)
356 int ret = 0, ret2 = 0; 356 int ret = 0, ret2 = 0;
357 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); 357 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
358 358
359 down(&dqopt->dqio_sem); 359 mutex_lock(&dqopt->dqio_mutex);
360 spin_lock(&dq_list_lock); 360 spin_lock(&dq_list_lock);
361 if (!clear_dquot_dirty(dquot)) { 361 if (!clear_dquot_dirty(dquot)) {
362 spin_unlock(&dq_list_lock); 362 spin_unlock(&dq_list_lock);
@@ -373,7 +373,7 @@ int dquot_commit(struct dquot *dquot)
373 ret = ret2; 373 ret = ret2;
374 } 374 }
375out_sem: 375out_sem:
376 up(&dqopt->dqio_sem); 376 mutex_unlock(&dqopt->dqio_mutex);
377 return ret; 377 return ret;
378} 378}
379 379
@@ -385,11 +385,11 @@ int dquot_release(struct dquot *dquot)
385 int ret = 0, ret2 = 0; 385 int ret = 0, ret2 = 0;
386 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); 386 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
387 387
388 down(&dquot->dq_lock); 388 mutex_lock(&dquot->dq_lock);
389 /* Check whether we are not racing with some other dqget() */ 389 /* Check whether we are not racing with some other dqget() */
390 if (atomic_read(&dquot->dq_count) > 1) 390 if (atomic_read(&dquot->dq_count) > 1)
391 goto out_dqlock; 391 goto out_dqlock;
392 down(&dqopt->dqio_sem); 392 mutex_lock(&dqopt->dqio_mutex);
393 if (dqopt->ops[dquot->dq_type]->release_dqblk) { 393 if (dqopt->ops[dquot->dq_type]->release_dqblk) {
394 ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot); 394 ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot);
395 /* Write the info */ 395 /* Write the info */
@@ -399,31 +399,57 @@ int dquot_release(struct dquot *dquot)
399 ret = ret2; 399 ret = ret2;
400 } 400 }
401 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags); 401 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
402 up(&dqopt->dqio_sem); 402 mutex_unlock(&dqopt->dqio_mutex);
403out_dqlock: 403out_dqlock:
404 up(&dquot->dq_lock); 404 mutex_unlock(&dquot->dq_lock);
405 return ret; 405 return ret;
406} 406}
407 407
408/* Invalidate all dquots on the list. Note that this function is called after 408/* Invalidate all dquots on the list. Note that this function is called after
409 * quota is disabled and pointers from inodes removed so there cannot be new 409 * quota is disabled and pointers from inodes removed so there cannot be new
410 * quota users. Also because we hold dqonoff_sem there can be no quota users 410 * quota users. There can still be some users of quotas due to inodes being
411 * for this sb+type at all. */ 411 * just deleted or pruned by prune_icache() (those are not attached to any
412 * list). We have to wait for such users.
413 */
412static void invalidate_dquots(struct super_block *sb, int type) 414static void invalidate_dquots(struct super_block *sb, int type)
413{ 415{
414 struct dquot *dquot, *tmp; 416 struct dquot *dquot, *tmp;
415 417
418restart:
416 spin_lock(&dq_list_lock); 419 spin_lock(&dq_list_lock);
417 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) { 420 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
418 if (dquot->dq_sb != sb) 421 if (dquot->dq_sb != sb)
419 continue; 422 continue;
420 if (dquot->dq_type != type) 423 if (dquot->dq_type != type)
421 continue; 424 continue;
422#ifdef __DQUOT_PARANOIA 425 /* Wait for dquot users */
423 if (atomic_read(&dquot->dq_count)) 426 if (atomic_read(&dquot->dq_count)) {
424 BUG(); 427 DEFINE_WAIT(wait);
425#endif 428
426 /* Quota now has no users and it has been written on last dqput() */ 429 atomic_inc(&dquot->dq_count);
430 prepare_to_wait(&dquot->dq_wait_unused, &wait,
431 TASK_UNINTERRUPTIBLE);
432 spin_unlock(&dq_list_lock);
433 /* Once dqput() wakes us up, we know it's time to free
434 * the dquot.
435 * IMPORTANT: we rely on the fact that there is always
436 * at most one process waiting for dquot to free.
437 * Otherwise dq_count would be > 1 and we would never
438 * wake up.
439 */
440 if (atomic_read(&dquot->dq_count) > 1)
441 schedule();
442 finish_wait(&dquot->dq_wait_unused, &wait);
443 dqput(dquot);
444 /* At this moment dquot() need not exist (it could be
445 * reclaimed by prune_dqcache(). Hence we must
446 * restart. */
447 goto restart;
448 }
449 /*
450 * Quota now has no users and it has been written on last
451 * dqput()
452 */
427 remove_dquot_hash(dquot); 453 remove_dquot_hash(dquot);
428 remove_free_dquot(dquot); 454 remove_free_dquot(dquot);
429 remove_inuse(dquot); 455 remove_inuse(dquot);
@@ -439,7 +465,7 @@ int vfs_quota_sync(struct super_block *sb, int type)
439 struct quota_info *dqopt = sb_dqopt(sb); 465 struct quota_info *dqopt = sb_dqopt(sb);
440 int cnt; 466 int cnt;
441 467
442 down(&dqopt->dqonoff_sem); 468 mutex_lock(&dqopt->dqonoff_mutex);
443 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 469 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
444 if (type != -1 && cnt != type) 470 if (type != -1 && cnt != type)
445 continue; 471 continue;
@@ -474,7 +500,7 @@ int vfs_quota_sync(struct super_block *sb, int type)
474 spin_lock(&dq_list_lock); 500 spin_lock(&dq_list_lock);
475 dqstats.syncs++; 501 dqstats.syncs++;
476 spin_unlock(&dq_list_lock); 502 spin_unlock(&dq_list_lock);
477 up(&dqopt->dqonoff_sem); 503 mutex_unlock(&dqopt->dqonoff_mutex);
478 504
479 return 0; 505 return 0;
480} 506}
@@ -515,7 +541,7 @@ static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
515/* 541/*
516 * Put reference to dquot 542 * Put reference to dquot
517 * NOTE: If you change this function please check whether dqput_blocks() works right... 543 * NOTE: If you change this function please check whether dqput_blocks() works right...
518 * MUST be called with either dqptr_sem or dqonoff_sem held 544 * MUST be called with either dqptr_sem or dqonoff_mutex held
519 */ 545 */
520static void dqput(struct dquot *dquot) 546static void dqput(struct dquot *dquot)
521{ 547{
@@ -540,6 +566,10 @@ we_slept:
540 if (atomic_read(&dquot->dq_count) > 1) { 566 if (atomic_read(&dquot->dq_count) > 1) {
541 /* We have more than one user... nothing to do */ 567 /* We have more than one user... nothing to do */
542 atomic_dec(&dquot->dq_count); 568 atomic_dec(&dquot->dq_count);
569 /* Releasing dquot during quotaoff phase? */
570 if (!sb_has_quota_enabled(dquot->dq_sb, dquot->dq_type) &&
571 atomic_read(&dquot->dq_count) == 1)
572 wake_up(&dquot->dq_wait_unused);
543 spin_unlock(&dq_list_lock); 573 spin_unlock(&dq_list_lock);
544 return; 574 return;
545 } 575 }
@@ -576,11 +606,12 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
576 return NODQUOT; 606 return NODQUOT;
577 607
578 memset((caddr_t)dquot, 0, sizeof(struct dquot)); 608 memset((caddr_t)dquot, 0, sizeof(struct dquot));
579 sema_init(&dquot->dq_lock, 1); 609 mutex_init(&dquot->dq_lock);
580 INIT_LIST_HEAD(&dquot->dq_free); 610 INIT_LIST_HEAD(&dquot->dq_free);
581 INIT_LIST_HEAD(&dquot->dq_inuse); 611 INIT_LIST_HEAD(&dquot->dq_inuse);
582 INIT_HLIST_NODE(&dquot->dq_hash); 612 INIT_HLIST_NODE(&dquot->dq_hash);
583 INIT_LIST_HEAD(&dquot->dq_dirty); 613 INIT_LIST_HEAD(&dquot->dq_dirty);
614 init_waitqueue_head(&dquot->dq_wait_unused);
584 dquot->dq_sb = sb; 615 dquot->dq_sb = sb;
585 dquot->dq_type = type; 616 dquot->dq_type = type;
586 atomic_set(&dquot->dq_count, 1); 617 atomic_set(&dquot->dq_count, 1);
@@ -590,7 +621,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
590 621
591/* 622/*
592 * Get reference to dquot 623 * Get reference to dquot
593 * MUST be called with either dqptr_sem or dqonoff_sem held 624 * MUST be called with either dqptr_sem or dqonoff_mutex held
594 */ 625 */
595static struct dquot *dqget(struct super_block *sb, unsigned int id, int type) 626static struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
596{ 627{
@@ -656,7 +687,7 @@ static int dqinit_needed(struct inode *inode, int type)
656 return 0; 687 return 0;
657} 688}
658 689
659/* This routine is guarded by dqonoff_sem semaphore */ 690/* This routine is guarded by dqonoff_mutex mutex */
660static void add_dquot_ref(struct super_block *sb, int type) 691static void add_dquot_ref(struct super_block *sb, int type)
661{ 692{
662 struct list_head *p; 693 struct list_head *p;
@@ -732,13 +763,9 @@ static void drop_dquot_ref(struct super_block *sb, int type)
732{ 763{
733 LIST_HEAD(tofree_head); 764 LIST_HEAD(tofree_head);
734 765
735 /* We need to be guarded against prune_icache to reach all the
736 * inodes - otherwise some can be on the local list of prune_icache */
737 down(&iprune_sem);
738 down_write(&sb_dqopt(sb)->dqptr_sem); 766 down_write(&sb_dqopt(sb)->dqptr_sem);
739 remove_dquot_ref(sb, type, &tofree_head); 767 remove_dquot_ref(sb, type, &tofree_head);
740 up_write(&sb_dqopt(sb)->dqptr_sem); 768 up_write(&sb_dqopt(sb)->dqptr_sem);
741 up(&iprune_sem);
742 put_dquot_list(&tofree_head); 769 put_dquot_list(&tofree_head);
743} 770}
744 771
@@ -938,8 +965,8 @@ int dquot_initialize(struct inode *inode, int type)
938 unsigned int id = 0; 965 unsigned int id = 0;
939 int cnt, ret = 0; 966 int cnt, ret = 0;
940 967
941 /* First test before acquiring semaphore - solves deadlocks when we 968 /* First test before acquiring mutex - solves deadlocks when we
942 * re-enter the quota code and are already holding the semaphore */ 969 * re-enter the quota code and are already holding the mutex */
943 if (IS_NOQUOTA(inode)) 970 if (IS_NOQUOTA(inode))
944 return 0; 971 return 0;
945 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 972 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1002,8 +1029,8 @@ int dquot_alloc_space(struct inode *inode, qsize_t number, int warn)
1002 int cnt, ret = NO_QUOTA; 1029 int cnt, ret = NO_QUOTA;
1003 char warntype[MAXQUOTAS]; 1030 char warntype[MAXQUOTAS];
1004 1031
1005 /* First test before acquiring semaphore - solves deadlocks when we 1032 /* First test before acquiring mutex - solves deadlocks when we
1006 * re-enter the quota code and are already holding the semaphore */ 1033 * re-enter the quota code and are already holding the mutex */
1007 if (IS_NOQUOTA(inode)) { 1034 if (IS_NOQUOTA(inode)) {
1008out_add: 1035out_add:
1009 inode_add_bytes(inode, number); 1036 inode_add_bytes(inode, number);
@@ -1051,8 +1078,8 @@ int dquot_alloc_inode(const struct inode *inode, unsigned long number)
1051 int cnt, ret = NO_QUOTA; 1078 int cnt, ret = NO_QUOTA;
1052 char warntype[MAXQUOTAS]; 1079 char warntype[MAXQUOTAS];
1053 1080
1054 /* First test before acquiring semaphore - solves deadlocks when we 1081 /* First test before acquiring mutex - solves deadlocks when we
1055 * re-enter the quota code and are already holding the semaphore */ 1082 * re-enter the quota code and are already holding the mutex */
1056 if (IS_NOQUOTA(inode)) 1083 if (IS_NOQUOTA(inode))
1057 return QUOTA_OK; 1084 return QUOTA_OK;
1058 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1085 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
@@ -1095,8 +1122,8 @@ int dquot_free_space(struct inode *inode, qsize_t number)
1095{ 1122{
1096 unsigned int cnt; 1123 unsigned int cnt;
1097 1124
1098 /* First test before acquiring semaphore - solves deadlocks when we 1125 /* First test before acquiring mutex - solves deadlocks when we
1099 * re-enter the quota code and are already holding the semaphore */ 1126 * re-enter the quota code and are already holding the mutex */
1100 if (IS_NOQUOTA(inode)) { 1127 if (IS_NOQUOTA(inode)) {
1101out_sub: 1128out_sub:
1102 inode_sub_bytes(inode, number); 1129 inode_sub_bytes(inode, number);
@@ -1131,8 +1158,8 @@ int dquot_free_inode(const struct inode *inode, unsigned long number)
1131{ 1158{
1132 unsigned int cnt; 1159 unsigned int cnt;
1133 1160
1134 /* First test before acquiring semaphore - solves deadlocks when we 1161 /* First test before acquiring mutex - solves deadlocks when we
1135 * re-enter the quota code and are already holding the semaphore */ 1162 * re-enter the quota code and are already holding the mutex */
1136 if (IS_NOQUOTA(inode)) 1163 if (IS_NOQUOTA(inode))
1137 return QUOTA_OK; 1164 return QUOTA_OK;
1138 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1165 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1171,8 +1198,8 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1171 chgid = (iattr->ia_valid & ATTR_GID) && inode->i_gid != iattr->ia_gid; 1198 chgid = (iattr->ia_valid & ATTR_GID) && inode->i_gid != iattr->ia_gid;
1172 char warntype[MAXQUOTAS]; 1199 char warntype[MAXQUOTAS];
1173 1200
1174 /* First test before acquiring semaphore - solves deadlocks when we 1201 /* First test before acquiring mutex - solves deadlocks when we
1175 * re-enter the quota code and are already holding the semaphore */ 1202 * re-enter the quota code and are already holding the mutex */
1176 if (IS_NOQUOTA(inode)) 1203 if (IS_NOQUOTA(inode))
1177 return QUOTA_OK; 1204 return QUOTA_OK;
1178 /* Clear the arrays */ 1205 /* Clear the arrays */
@@ -1266,9 +1293,9 @@ int dquot_commit_info(struct super_block *sb, int type)
1266 int ret; 1293 int ret;
1267 struct quota_info *dqopt = sb_dqopt(sb); 1294 struct quota_info *dqopt = sb_dqopt(sb);
1268 1295
1269 down(&dqopt->dqio_sem); 1296 mutex_lock(&dqopt->dqio_mutex);
1270 ret = dqopt->ops[type]->write_file_info(sb, type); 1297 ret = dqopt->ops[type]->write_file_info(sb, type);
1271 up(&dqopt->dqio_sem); 1298 mutex_unlock(&dqopt->dqio_mutex);
1272 return ret; 1299 return ret;
1273} 1300}
1274 1301
@@ -1324,7 +1351,7 @@ int vfs_quota_off(struct super_block *sb, int type)
1324 struct inode *toputinode[MAXQUOTAS]; 1351 struct inode *toputinode[MAXQUOTAS];
1325 1352
1326 /* We need to serialize quota_off() for device */ 1353 /* We need to serialize quota_off() for device */
1327 down(&dqopt->dqonoff_sem); 1354 mutex_lock(&dqopt->dqonoff_mutex);
1328 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1355 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1329 toputinode[cnt] = NULL; 1356 toputinode[cnt] = NULL;
1330 if (type != -1 && cnt != type) 1357 if (type != -1 && cnt != type)
@@ -1353,7 +1380,7 @@ int vfs_quota_off(struct super_block *sb, int type)
1353 dqopt->info[cnt].dqi_bgrace = 0; 1380 dqopt->info[cnt].dqi_bgrace = 0;
1354 dqopt->ops[cnt] = NULL; 1381 dqopt->ops[cnt] = NULL;
1355 } 1382 }
1356 up(&dqopt->dqonoff_sem); 1383 mutex_unlock(&dqopt->dqonoff_mutex);
1357 /* Sync the superblock so that buffers with quota data are written to 1384 /* Sync the superblock so that buffers with quota data are written to
1358 * disk (and so userspace sees correct data afterwards). */ 1385 * disk (and so userspace sees correct data afterwards). */
1359 if (sb->s_op->sync_fs) 1386 if (sb->s_op->sync_fs)
@@ -1366,7 +1393,7 @@ int vfs_quota_off(struct super_block *sb, int type)
1366 * changes done by userspace on the next quotaon() */ 1393 * changes done by userspace on the next quotaon() */
1367 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1394 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
1368 if (toputinode[cnt]) { 1395 if (toputinode[cnt]) {
1369 down(&dqopt->dqonoff_sem); 1396 mutex_lock(&dqopt->dqonoff_mutex);
1370 /* If quota was reenabled in the meantime, we have 1397 /* If quota was reenabled in the meantime, we have
1371 * nothing to do */ 1398 * nothing to do */
1372 if (!sb_has_quota_enabled(sb, cnt)) { 1399 if (!sb_has_quota_enabled(sb, cnt)) {
@@ -1378,7 +1405,7 @@ int vfs_quota_off(struct super_block *sb, int type)
1378 mark_inode_dirty(toputinode[cnt]); 1405 mark_inode_dirty(toputinode[cnt]);
1379 iput(toputinode[cnt]); 1406 iput(toputinode[cnt]);
1380 } 1407 }
1381 up(&dqopt->dqonoff_sem); 1408 mutex_unlock(&dqopt->dqonoff_mutex);
1382 } 1409 }
1383 if (sb->s_bdev) 1410 if (sb->s_bdev)
1384 invalidate_bdev(sb->s_bdev, 0); 1411 invalidate_bdev(sb->s_bdev, 0);
@@ -1419,7 +1446,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1419 /* And now flush the block cache so that kernel sees the changes */ 1446 /* And now flush the block cache so that kernel sees the changes */
1420 invalidate_bdev(sb->s_bdev, 0); 1447 invalidate_bdev(sb->s_bdev, 0);
1421 mutex_lock(&inode->i_mutex); 1448 mutex_lock(&inode->i_mutex);
1422 down(&dqopt->dqonoff_sem); 1449 mutex_lock(&dqopt->dqonoff_mutex);
1423 if (sb_has_quota_enabled(sb, type)) { 1450 if (sb_has_quota_enabled(sb, type)) {
1424 error = -EBUSY; 1451 error = -EBUSY;
1425 goto out_lock; 1452 goto out_lock;
@@ -1444,17 +1471,17 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1444 dqopt->ops[type] = fmt->qf_ops; 1471 dqopt->ops[type] = fmt->qf_ops;
1445 dqopt->info[type].dqi_format = fmt; 1472 dqopt->info[type].dqi_format = fmt;
1446 INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list); 1473 INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list);
1447 down(&dqopt->dqio_sem); 1474 mutex_lock(&dqopt->dqio_mutex);
1448 if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) { 1475 if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) {
1449 up(&dqopt->dqio_sem); 1476 mutex_unlock(&dqopt->dqio_mutex);
1450 goto out_file_init; 1477 goto out_file_init;
1451 } 1478 }
1452 up(&dqopt->dqio_sem); 1479 mutex_unlock(&dqopt->dqio_mutex);
1453 mutex_unlock(&inode->i_mutex); 1480 mutex_unlock(&inode->i_mutex);
1454 set_enable_flags(dqopt, type); 1481 set_enable_flags(dqopt, type);
1455 1482
1456 add_dquot_ref(sb, type); 1483 add_dquot_ref(sb, type);
1457 up(&dqopt->dqonoff_sem); 1484 mutex_unlock(&dqopt->dqonoff_mutex);
1458 1485
1459 return 0; 1486 return 0;
1460 1487
@@ -1462,7 +1489,7 @@ out_file_init:
1462 dqopt->files[type] = NULL; 1489 dqopt->files[type] = NULL;
1463 iput(inode); 1490 iput(inode);
1464out_lock: 1491out_lock:
1465 up(&dqopt->dqonoff_sem); 1492 mutex_unlock(&dqopt->dqonoff_mutex);
1466 if (oldflags != -1) { 1493 if (oldflags != -1) {
1467 down_write(&dqopt->dqptr_sem); 1494 down_write(&dqopt->dqptr_sem);
1468 /* Set the flags back (in the case of accidental quotaon() 1495 /* Set the flags back (in the case of accidental quotaon()
@@ -1550,14 +1577,14 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
1550{ 1577{
1551 struct dquot *dquot; 1578 struct dquot *dquot;
1552 1579
1553 down(&sb_dqopt(sb)->dqonoff_sem); 1580 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1554 if (!(dquot = dqget(sb, id, type))) { 1581 if (!(dquot = dqget(sb, id, type))) {
1555 up(&sb_dqopt(sb)->dqonoff_sem); 1582 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1556 return -ESRCH; 1583 return -ESRCH;
1557 } 1584 }
1558 do_get_dqblk(dquot, di); 1585 do_get_dqblk(dquot, di);
1559 dqput(dquot); 1586 dqput(dquot);
1560 up(&sb_dqopt(sb)->dqonoff_sem); 1587 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1561 return 0; 1588 return 0;
1562} 1589}
1563 1590
@@ -1619,14 +1646,14 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
1619{ 1646{
1620 struct dquot *dquot; 1647 struct dquot *dquot;
1621 1648
1622 down(&sb_dqopt(sb)->dqonoff_sem); 1649 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1623 if (!(dquot = dqget(sb, id, type))) { 1650 if (!(dquot = dqget(sb, id, type))) {
1624 up(&sb_dqopt(sb)->dqonoff_sem); 1651 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1625 return -ESRCH; 1652 return -ESRCH;
1626 } 1653 }
1627 do_set_dqblk(dquot, di); 1654 do_set_dqblk(dquot, di);
1628 dqput(dquot); 1655 dqput(dquot);
1629 up(&sb_dqopt(sb)->dqonoff_sem); 1656 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1630 return 0; 1657 return 0;
1631} 1658}
1632 1659
@@ -1635,9 +1662,9 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
1635{ 1662{
1636 struct mem_dqinfo *mi; 1663 struct mem_dqinfo *mi;
1637 1664
1638 down(&sb_dqopt(sb)->dqonoff_sem); 1665 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1639 if (!sb_has_quota_enabled(sb, type)) { 1666 if (!sb_has_quota_enabled(sb, type)) {
1640 up(&sb_dqopt(sb)->dqonoff_sem); 1667 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1641 return -ESRCH; 1668 return -ESRCH;
1642 } 1669 }
1643 mi = sb_dqopt(sb)->info + type; 1670 mi = sb_dqopt(sb)->info + type;
@@ -1647,7 +1674,7 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
1647 ii->dqi_flags = mi->dqi_flags & DQF_MASK; 1674 ii->dqi_flags = mi->dqi_flags & DQF_MASK;
1648 ii->dqi_valid = IIF_ALL; 1675 ii->dqi_valid = IIF_ALL;
1649 spin_unlock(&dq_data_lock); 1676 spin_unlock(&dq_data_lock);
1650 up(&sb_dqopt(sb)->dqonoff_sem); 1677 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1651 return 0; 1678 return 0;
1652} 1679}
1653 1680
@@ -1656,9 +1683,9 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
1656{ 1683{
1657 struct mem_dqinfo *mi; 1684 struct mem_dqinfo *mi;
1658 1685
1659 down(&sb_dqopt(sb)->dqonoff_sem); 1686 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1660 if (!sb_has_quota_enabled(sb, type)) { 1687 if (!sb_has_quota_enabled(sb, type)) {
1661 up(&sb_dqopt(sb)->dqonoff_sem); 1688 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1662 return -ESRCH; 1689 return -ESRCH;
1663 } 1690 }
1664 mi = sb_dqopt(sb)->info + type; 1691 mi = sb_dqopt(sb)->info + type;
@@ -1673,7 +1700,7 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
1673 mark_info_dirty(sb, type); 1700 mark_info_dirty(sb, type);
1674 /* Force write to disk */ 1701 /* Force write to disk */
1675 sb->dq_op->write_info(sb, type); 1702 sb->dq_op->write_info(sb, type);
1676 up(&sb_dqopt(sb)->dqonoff_sem); 1703 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1677 return 0; 1704 return 0;
1678} 1705}
1679 1706
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 4284cd31eba6..1c2b16fda13a 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -34,6 +34,7 @@
34#include <linux/eventpoll.h> 34#include <linux/eventpoll.h>
35#include <linux/mount.h> 35#include <linux/mount.h>
36#include <linux/bitops.h> 36#include <linux/bitops.h>
37#include <linux/mutex.h>
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include <asm/system.h> 39#include <asm/system.h>
39#include <asm/io.h> 40#include <asm/io.h>
@@ -46,7 +47,7 @@
46 * LOCKING: 47 * LOCKING:
47 * There are three level of locking required by epoll : 48 * There are three level of locking required by epoll :
48 * 49 *
49 * 1) epsem (semaphore) 50 * 1) epmutex (mutex)
50 * 2) ep->sem (rw_semaphore) 51 * 2) ep->sem (rw_semaphore)
51 * 3) ep->lock (rw_lock) 52 * 3) ep->lock (rw_lock)
52 * 53 *
@@ -67,9 +68,9 @@
67 * if a file has been pushed inside an epoll set and it is then 68 * if a file has been pushed inside an epoll set and it is then
68 * close()d without a previous call toepoll_ctl(EPOLL_CTL_DEL). 69 * close()d without a previous call toepoll_ctl(EPOLL_CTL_DEL).
69 * It is possible to drop the "ep->sem" and to use the global 70 * It is possible to drop the "ep->sem" and to use the global
70 * semaphore "epsem" (together with "ep->lock") to have it working, 71 * semaphore "epmutex" (together with "ep->lock") to have it working,
71 * but having "ep->sem" will make the interface more scalable. 72 * but having "ep->sem" will make the interface more scalable.
72 * Events that require holding "epsem" are very rare, while for 73 * Events that require holding "epmutex" are very rare, while for
73 * normal operations the epoll private "ep->sem" will guarantee 74 * normal operations the epoll private "ep->sem" will guarantee
74 * a greater scalability. 75 * a greater scalability.
75 */ 76 */
@@ -274,7 +275,7 @@ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
274/* 275/*
275 * This semaphore is used to serialize ep_free() and eventpoll_release_file(). 276 * This semaphore is used to serialize ep_free() and eventpoll_release_file().
276 */ 277 */
277static struct semaphore epsem; 278static struct mutex epmutex;
278 279
279/* Safe wake up implementation */ 280/* Safe wake up implementation */
280static struct poll_safewake psw; 281static struct poll_safewake psw;
@@ -451,15 +452,6 @@ static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq)
451} 452}
452 453
453 454
454/* Used to initialize the epoll bits inside the "struct file" */
455void eventpoll_init_file(struct file *file)
456{
457
458 INIT_LIST_HEAD(&file->f_ep_links);
459 spin_lock_init(&file->f_ep_lock);
460}
461
462
463/* 455/*
464 * This is called from eventpoll_release() to unlink files from the eventpoll 456 * This is called from eventpoll_release() to unlink files from the eventpoll
465 * interface. We need to have this facility to cleanup correctly files that are 457 * interface. We need to have this facility to cleanup correctly files that are
@@ -477,10 +469,10 @@ void eventpoll_release_file(struct file *file)
477 * cleanup path, and this means that noone is using this file anymore. 469 * cleanup path, and this means that noone is using this file anymore.
478 * The only hit might come from ep_free() but by holding the semaphore 470 * The only hit might come from ep_free() but by holding the semaphore
479 * will correctly serialize the operation. We do need to acquire 471 * will correctly serialize the operation. We do need to acquire
480 * "ep->sem" after "epsem" because ep_remove() requires it when called 472 * "ep->sem" after "epmutex" because ep_remove() requires it when called
481 * from anywhere but ep_free(). 473 * from anywhere but ep_free().
482 */ 474 */
483 down(&epsem); 475 mutex_lock(&epmutex);
484 476
485 while (!list_empty(lsthead)) { 477 while (!list_empty(lsthead)) {
486 epi = list_entry(lsthead->next, struct epitem, fllink); 478 epi = list_entry(lsthead->next, struct epitem, fllink);
@@ -492,7 +484,7 @@ void eventpoll_release_file(struct file *file)
492 up_write(&ep->sem); 484 up_write(&ep->sem);
493 } 485 }
494 486
495 up(&epsem); 487 mutex_unlock(&epmutex);
496} 488}
497 489
498 490
@@ -819,9 +811,9 @@ static void ep_free(struct eventpoll *ep)
819 * We do not need to hold "ep->sem" here because the epoll file 811 * We do not need to hold "ep->sem" here because the epoll file
820 * is on the way to be removed and no one has references to it 812 * is on the way to be removed and no one has references to it
821 * anymore. The only hit might come from eventpoll_release_file() but 813 * anymore. The only hit might come from eventpoll_release_file() but
822 * holding "epsem" is sufficent here. 814 * holding "epmutex" is sufficent here.
823 */ 815 */
824 down(&epsem); 816 mutex_lock(&epmutex);
825 817
826 /* 818 /*
827 * Walks through the whole tree by unregistering poll callbacks. 819 * Walks through the whole tree by unregistering poll callbacks.
@@ -843,7 +835,7 @@ static void ep_free(struct eventpoll *ep)
843 ep_remove(ep, epi); 835 ep_remove(ep, epi);
844 } 836 }
845 837
846 up(&epsem); 838 mutex_unlock(&epmutex);
847} 839}
848 840
849 841
@@ -1615,7 +1607,7 @@ static int __init eventpoll_init(void)
1615{ 1607{
1616 int error; 1608 int error;
1617 1609
1618 init_MUTEX(&epsem); 1610 mutex_init(&epmutex);
1619 1611
1620 /* Initialize the structure used to perform safe poll wait head wake ups */ 1612 /* Initialize the structure used to perform safe poll wait head wake ups */
1621 ep_poll_safewake_init(&psw); 1613 ep_poll_safewake_init(&psw);
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index ad1432a2a62e..4ca824985321 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -36,22 +36,6 @@
36#include "acl.h" 36#include "acl.h"
37#include "xip.h" 37#include "xip.h"
38 38
39/*
40 * Couple of helper functions - make the code slightly cleaner.
41 */
42
43static inline void ext2_inc_count(struct inode *inode)
44{
45 inode->i_nlink++;
46 mark_inode_dirty(inode);
47}
48
49static inline void ext2_dec_count(struct inode *inode)
50{
51 inode->i_nlink--;
52 mark_inode_dirty(inode);
53}
54
55static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) 39static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
56{ 40{
57 int err = ext2_add_link(dentry, inode); 41 int err = ext2_add_link(dentry, inode);
@@ -59,7 +43,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
59 d_instantiate(dentry, inode); 43 d_instantiate(dentry, inode);
60 return 0; 44 return 0;
61 } 45 }
62 ext2_dec_count(inode); 46 inode_dec_link_count(inode);
63 iput(inode); 47 iput(inode);
64 return err; 48 return err;
65} 49}
@@ -201,7 +185,7 @@ out:
201 return err; 185 return err;
202 186
203out_fail: 187out_fail:
204 ext2_dec_count(inode); 188 inode_dec_link_count(inode);
205 iput (inode); 189 iput (inode);
206 goto out; 190 goto out;
207} 191}
@@ -215,7 +199,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
215 return -EMLINK; 199 return -EMLINK;
216 200
217 inode->i_ctime = CURRENT_TIME_SEC; 201 inode->i_ctime = CURRENT_TIME_SEC;
218 ext2_inc_count(inode); 202 inode_inc_link_count(inode);
219 atomic_inc(&inode->i_count); 203 atomic_inc(&inode->i_count);
220 204
221 return ext2_add_nondir(dentry, inode); 205 return ext2_add_nondir(dentry, inode);
@@ -229,7 +213,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
229 if (dir->i_nlink >= EXT2_LINK_MAX) 213 if (dir->i_nlink >= EXT2_LINK_MAX)
230 goto out; 214 goto out;
231 215
232 ext2_inc_count(dir); 216 inode_inc_link_count(dir);
233 217
234 inode = ext2_new_inode (dir, S_IFDIR | mode); 218 inode = ext2_new_inode (dir, S_IFDIR | mode);
235 err = PTR_ERR(inode); 219 err = PTR_ERR(inode);
@@ -243,7 +227,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
243 else 227 else
244 inode->i_mapping->a_ops = &ext2_aops; 228 inode->i_mapping->a_ops = &ext2_aops;
245 229
246 ext2_inc_count(inode); 230 inode_inc_link_count(inode);
247 231
248 err = ext2_make_empty(inode, dir); 232 err = ext2_make_empty(inode, dir);
249 if (err) 233 if (err)
@@ -258,11 +242,11 @@ out:
258 return err; 242 return err;
259 243
260out_fail: 244out_fail:
261 ext2_dec_count(inode); 245 inode_dec_link_count(inode);
262 ext2_dec_count(inode); 246 inode_dec_link_count(inode);
263 iput(inode); 247 iput(inode);
264out_dir: 248out_dir:
265 ext2_dec_count(dir); 249 inode_dec_link_count(dir);
266 goto out; 250 goto out;
267} 251}
268 252
@@ -282,7 +266,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
282 goto out; 266 goto out;
283 267
284 inode->i_ctime = dir->i_ctime; 268 inode->i_ctime = dir->i_ctime;
285 ext2_dec_count(inode); 269 inode_dec_link_count(inode);
286 err = 0; 270 err = 0;
287out: 271out:
288 return err; 272 return err;
@@ -297,8 +281,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
297 err = ext2_unlink(dir, dentry); 281 err = ext2_unlink(dir, dentry);
298 if (!err) { 282 if (!err) {
299 inode->i_size = 0; 283 inode->i_size = 0;
300 ext2_dec_count(inode); 284 inode_dec_link_count(inode);
301 ext2_dec_count(dir); 285 inode_dec_link_count(dir);
302 } 286 }
303 } 287 }
304 return err; 288 return err;
@@ -338,41 +322,41 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
338 new_de = ext2_find_entry (new_dir, new_dentry, &new_page); 322 new_de = ext2_find_entry (new_dir, new_dentry, &new_page);
339 if (!new_de) 323 if (!new_de)
340 goto out_dir; 324 goto out_dir;
341 ext2_inc_count(old_inode); 325 inode_inc_link_count(old_inode);
342 ext2_set_link(new_dir, new_de, new_page, old_inode); 326 ext2_set_link(new_dir, new_de, new_page, old_inode);
343 new_inode->i_ctime = CURRENT_TIME_SEC; 327 new_inode->i_ctime = CURRENT_TIME_SEC;
344 if (dir_de) 328 if (dir_de)
345 new_inode->i_nlink--; 329 new_inode->i_nlink--;
346 ext2_dec_count(new_inode); 330 inode_dec_link_count(new_inode);
347 } else { 331 } else {
348 if (dir_de) { 332 if (dir_de) {
349 err = -EMLINK; 333 err = -EMLINK;
350 if (new_dir->i_nlink >= EXT2_LINK_MAX) 334 if (new_dir->i_nlink >= EXT2_LINK_MAX)
351 goto out_dir; 335 goto out_dir;
352 } 336 }
353 ext2_inc_count(old_inode); 337 inode_inc_link_count(old_inode);
354 err = ext2_add_link(new_dentry, old_inode); 338 err = ext2_add_link(new_dentry, old_inode);
355 if (err) { 339 if (err) {
356 ext2_dec_count(old_inode); 340 inode_dec_link_count(old_inode);
357 goto out_dir; 341 goto out_dir;
358 } 342 }
359 if (dir_de) 343 if (dir_de)
360 ext2_inc_count(new_dir); 344 inode_inc_link_count(new_dir);
361 } 345 }
362 346
363 /* 347 /*
364 * Like most other Unix systems, set the ctime for inodes on a 348 * Like most other Unix systems, set the ctime for inodes on a
365 * rename. 349 * rename.
366 * ext2_dec_count() will mark the inode dirty. 350 * inode_dec_link_count() will mark the inode dirty.
367 */ 351 */
368 old_inode->i_ctime = CURRENT_TIME_SEC; 352 old_inode->i_ctime = CURRENT_TIME_SEC;
369 353
370 ext2_delete_entry (old_de, old_page); 354 ext2_delete_entry (old_de, old_page);
371 ext2_dec_count(old_inode); 355 inode_dec_link_count(old_inode);
372 356
373 if (dir_de) { 357 if (dir_de) {
374 ext2_set_link(old_inode, dir_de, dir_page, new_dir); 358 ext2_set_link(old_inode, dir_de, dir_page, new_dir);
375 ext2_dec_count(old_dir); 359 inode_dec_link_count(old_dir);
376 } 360 }
377 return 0; 361 return 0;
378 362
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index 832867aef3dc..773459164bb2 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -95,11 +95,10 @@ static int ext3_readdir(struct file * filp,
95 void * dirent, filldir_t filldir) 95 void * dirent, filldir_t filldir)
96{ 96{
97 int error = 0; 97 int error = 0;
98 unsigned long offset, blk; 98 unsigned long offset;
99 int i, num, stored; 99 int i, stored;
100 struct buffer_head * bh, * tmp, * bha[16]; 100 struct ext3_dir_entry_2 *de;
101 struct ext3_dir_entry_2 * de; 101 struct super_block *sb;
102 struct super_block * sb;
103 int err; 102 int err;
104 struct inode *inode = filp->f_dentry->d_inode; 103 struct inode *inode = filp->f_dentry->d_inode;
105 int ret = 0; 104 int ret = 0;
@@ -124,12 +123,29 @@ static int ext3_readdir(struct file * filp,
124 } 123 }
125#endif 124#endif
126 stored = 0; 125 stored = 0;
127 bh = NULL;
128 offset = filp->f_pos & (sb->s_blocksize - 1); 126 offset = filp->f_pos & (sb->s_blocksize - 1);
129 127
130 while (!error && !stored && filp->f_pos < inode->i_size) { 128 while (!error && !stored && filp->f_pos < inode->i_size) {
131 blk = (filp->f_pos) >> EXT3_BLOCK_SIZE_BITS(sb); 129 unsigned long blk = filp->f_pos >> EXT3_BLOCK_SIZE_BITS(sb);
132 bh = ext3_bread(NULL, inode, blk, 0, &err); 130 struct buffer_head map_bh;
131 struct buffer_head *bh = NULL;
132
133 map_bh.b_state = 0;
134 err = ext3_get_block_handle(NULL, inode, blk, &map_bh, 0, 0);
135 if (!err) {
136 page_cache_readahead(sb->s_bdev->bd_inode->i_mapping,
137 &filp->f_ra,
138 filp,
139 map_bh.b_blocknr >>
140 (PAGE_CACHE_SHIFT - inode->i_blkbits),
141 1);
142 bh = ext3_bread(NULL, inode, blk, 0, &err);
143 }
144
145 /*
146 * We ignore I/O errors on directories so users have a chance
147 * of recovering data when there's a bad sector
148 */
133 if (!bh) { 149 if (!bh) {
134 ext3_error (sb, "ext3_readdir", 150 ext3_error (sb, "ext3_readdir",
135 "directory #%lu contains a hole at offset %lu", 151 "directory #%lu contains a hole at offset %lu",
@@ -138,26 +154,6 @@ static int ext3_readdir(struct file * filp,
138 continue; 154 continue;
139 } 155 }
140 156
141 /*
142 * Do the readahead
143 */
144 if (!offset) {
145 for (i = 16 >> (EXT3_BLOCK_SIZE_BITS(sb) - 9), num = 0;
146 i > 0; i--) {
147 tmp = ext3_getblk (NULL, inode, ++blk, 0, &err);
148 if (tmp && !buffer_uptodate(tmp) &&
149 !buffer_locked(tmp))
150 bha[num++] = tmp;
151 else
152 brelse (tmp);
153 }
154 if (num) {
155 ll_rw_block (READA, num, bha);
156 for (i = 0; i < num; i++)
157 brelse (bha[i]);
158 }
159 }
160
161revalidate: 157revalidate:
162 /* If the dir block has changed since the last call to 158 /* If the dir block has changed since the last call to
163 * readdir(2), then we might be pointing to an invalid 159 * readdir(2), then we might be pointing to an invalid
diff --git a/fs/ext3/file.c b/fs/ext3/file.c
index 98e78345ead9..59098ea56711 100644
--- a/fs/ext3/file.c
+++ b/fs/ext3/file.c
@@ -37,9 +37,9 @@ static int ext3_release_file (struct inode * inode, struct file * filp)
37 if ((filp->f_mode & FMODE_WRITE) && 37 if ((filp->f_mode & FMODE_WRITE) &&
38 (atomic_read(&inode->i_writecount) == 1)) 38 (atomic_read(&inode->i_writecount) == 1))
39 { 39 {
40 down(&EXT3_I(inode)->truncate_sem); 40 mutex_lock(&EXT3_I(inode)->truncate_mutex);
41 ext3_discard_reservation(inode); 41 ext3_discard_reservation(inode);
42 up(&EXT3_I(inode)->truncate_sem); 42 mutex_unlock(&EXT3_I(inode)->truncate_mutex);
43 } 43 }
44 if (is_dx(inode) && filp->private_data) 44 if (is_dx(inode) && filp->private_data)
45 ext3_htree_free_dir_info(filp->private_data); 45 ext3_htree_free_dir_info(filp->private_data);
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 0384e539b88f..2c361377e0a5 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -671,7 +671,7 @@ err_out:
671 * The BKL may not be held on entry here. Be sure to take it early. 671 * The BKL may not be held on entry here. Be sure to take it early.
672 */ 672 */
673 673
674static int 674int
675ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock, 675ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
676 struct buffer_head *bh_result, int create, int extend_disksize) 676 struct buffer_head *bh_result, int create, int extend_disksize)
677{ 677{
@@ -702,7 +702,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
702 if (!create || err == -EIO) 702 if (!create || err == -EIO)
703 goto cleanup; 703 goto cleanup;
704 704
705 down(&ei->truncate_sem); 705 mutex_lock(&ei->truncate_mutex);
706 706
707 /* 707 /*
708 * If the indirect block is missing while we are reading 708 * If the indirect block is missing while we are reading
@@ -723,7 +723,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
723 } 723 }
724 partial = ext3_get_branch(inode, depth, offsets, chain, &err); 724 partial = ext3_get_branch(inode, depth, offsets, chain, &err);
725 if (!partial) { 725 if (!partial) {
726 up(&ei->truncate_sem); 726 mutex_unlock(&ei->truncate_mutex);
727 if (err) 727 if (err)
728 goto cleanup; 728 goto cleanup;
729 clear_buffer_new(bh_result); 729 clear_buffer_new(bh_result);
@@ -759,13 +759,13 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
759 err = ext3_splice_branch(handle, inode, iblock, chain, 759 err = ext3_splice_branch(handle, inode, iblock, chain,
760 partial, left); 760 partial, left);
761 /* 761 /*
762 * i_disksize growing is protected by truncate_sem. Don't forget to 762 * i_disksize growing is protected by truncate_mutex. Don't forget to
763 * protect it if you're about to implement concurrent 763 * protect it if you're about to implement concurrent
764 * ext3_get_block() -bzzz 764 * ext3_get_block() -bzzz
765 */ 765 */
766 if (!err && extend_disksize && inode->i_size > ei->i_disksize) 766 if (!err && extend_disksize && inode->i_size > ei->i_disksize)
767 ei->i_disksize = inode->i_size; 767 ei->i_disksize = inode->i_size;
768 up(&ei->truncate_sem); 768 mutex_unlock(&ei->truncate_mutex);
769 if (err) 769 if (err)
770 goto cleanup; 770 goto cleanup;
771 771
@@ -1227,7 +1227,7 @@ static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
1227 * ext3_file_write() -> generic_file_write() -> __alloc_pages() -> ... 1227 * ext3_file_write() -> generic_file_write() -> __alloc_pages() -> ...
1228 * 1228 *
1229 * Same applies to ext3_get_block(). We will deadlock on various things like 1229 * Same applies to ext3_get_block(). We will deadlock on various things like
1230 * lock_journal and i_truncate_sem. 1230 * lock_journal and i_truncate_mutex.
1231 * 1231 *
1232 * Setting PF_MEMALLOC here doesn't work - too many internal memory 1232 * Setting PF_MEMALLOC here doesn't work - too many internal memory
1233 * allocations fail. 1233 * allocations fail.
@@ -2161,7 +2161,7 @@ void ext3_truncate(struct inode * inode)
2161 * From here we block out all ext3_get_block() callers who want to 2161 * From here we block out all ext3_get_block() callers who want to
2162 * modify the block allocation tree. 2162 * modify the block allocation tree.
2163 */ 2163 */
2164 down(&ei->truncate_sem); 2164 mutex_lock(&ei->truncate_mutex);
2165 2165
2166 if (n == 1) { /* direct blocks */ 2166 if (n == 1) { /* direct blocks */
2167 ext3_free_data(handle, inode, NULL, i_data+offsets[0], 2167 ext3_free_data(handle, inode, NULL, i_data+offsets[0],
@@ -2228,7 +2228,7 @@ do_indirects:
2228 2228
2229 ext3_discard_reservation(inode); 2229 ext3_discard_reservation(inode);
2230 2230
2231 up(&ei->truncate_sem); 2231 mutex_unlock(&ei->truncate_mutex);
2232 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 2232 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
2233 ext3_mark_inode_dirty(handle, inode); 2233 ext3_mark_inode_dirty(handle, inode);
2234 2234
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index 556cd5510078..aaf1da17b6d4 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -182,7 +182,7 @@ flags_err:
182 * need to allocate reservation structure for this inode 182 * need to allocate reservation structure for this inode
183 * before set the window size 183 * before set the window size
184 */ 184 */
185 down(&ei->truncate_sem); 185 mutex_lock(&ei->truncate_mutex);
186 if (!ei->i_block_alloc_info) 186 if (!ei->i_block_alloc_info)
187 ext3_init_block_alloc_info(inode); 187 ext3_init_block_alloc_info(inode);
188 188
@@ -190,7 +190,7 @@ flags_err:
190 struct ext3_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node; 190 struct ext3_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
191 rsv->rsv_goal_size = rsv_window_size; 191 rsv->rsv_goal_size = rsv_window_size;
192 } 192 }
193 up(&ei->truncate_sem); 193 mutex_unlock(&ei->truncate_mutex);
194 return 0; 194 return 0;
195 } 195 }
196 case EXT3_IOC_GROUP_EXTEND: { 196 case EXT3_IOC_GROUP_EXTEND: {
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 56bf76586019..efe5b20d7a5a 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -472,7 +472,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
472#ifdef CONFIG_EXT3_FS_XATTR 472#ifdef CONFIG_EXT3_FS_XATTR
473 init_rwsem(&ei->xattr_sem); 473 init_rwsem(&ei->xattr_sem);
474#endif 474#endif
475 init_MUTEX(&ei->truncate_sem); 475 mutex_init(&ei->truncate_mutex);
476 inode_init_once(&ei->vfs_inode); 476 inode_init_once(&ei->vfs_inode);
477 } 477 }
478} 478}
@@ -2382,8 +2382,8 @@ static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
2382 * Process 1 Process 2 2382 * Process 1 Process 2
2383 * ext3_create() quota_sync() 2383 * ext3_create() quota_sync()
2384 * journal_start() write_dquot() 2384 * journal_start() write_dquot()
2385 * DQUOT_INIT() down(dqio_sem) 2385 * DQUOT_INIT() down(dqio_mutex)
2386 * down(dqio_sem) journal_start() 2386 * down(dqio_mutex) journal_start()
2387 * 2387 *
2388 */ 2388 */
2389 2389
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index a1a9e0451217..ab171ea8e869 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -267,19 +267,19 @@ static struct fatent_operations fat32_ops = {
267 267
268static inline void lock_fat(struct msdos_sb_info *sbi) 268static inline void lock_fat(struct msdos_sb_info *sbi)
269{ 269{
270 down(&sbi->fat_lock); 270 mutex_lock(&sbi->fat_lock);
271} 271}
272 272
273static inline void unlock_fat(struct msdos_sb_info *sbi) 273static inline void unlock_fat(struct msdos_sb_info *sbi)
274{ 274{
275 up(&sbi->fat_lock); 275 mutex_unlock(&sbi->fat_lock);
276} 276}
277 277
278void fat_ent_access_init(struct super_block *sb) 278void fat_ent_access_init(struct super_block *sb)
279{ 279{
280 struct msdos_sb_info *sbi = MSDOS_SB(sb); 280 struct msdos_sb_info *sbi = MSDOS_SB(sb);
281 281
282 init_MUTEX(&sbi->fat_lock); 282 mutex_init(&sbi->fat_lock);
283 283
284 switch (sbi->fat_bits) { 284 switch (sbi->fat_bits) {
285 case 32: 285 case 32:
diff --git a/fs/fcntl.c b/fs/fcntl.c
index dc4a7007f4e7..03c789560fb8 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -73,8 +73,8 @@ repeat:
73 * orig_start..fdt->next_fd 73 * orig_start..fdt->next_fd
74 */ 74 */
75 start = orig_start; 75 start = orig_start;
76 if (start < fdt->next_fd) 76 if (start < files->next_fd)
77 start = fdt->next_fd; 77 start = files->next_fd;
78 78
79 newfd = start; 79 newfd = start;
80 if (start < fdt->max_fdset) { 80 if (start < fdt->max_fdset) {
@@ -102,9 +102,8 @@ repeat:
102 * we reacquire the fdtable pointer and use it while holding 102 * we reacquire the fdtable pointer and use it while holding
103 * the lock, no one can free it during that time. 103 * the lock, no one can free it during that time.
104 */ 104 */
105 fdt = files_fdtable(files); 105 if (start <= files->next_fd)
106 if (start <= fdt->next_fd) 106 files->next_fd = newfd + 1;
107 fdt->next_fd = newfd + 1;
108 107
109 error = newfd; 108 error = newfd;
110 109
diff --git a/fs/file.c b/fs/file.c
index cea7cbea11d0..bbc743314730 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -125,7 +125,8 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
125 kmem_cache_free(files_cachep, fdt->free_files); 125 kmem_cache_free(files_cachep, fdt->free_files);
126 return; 126 return;
127 } 127 }
128 if (fdt->max_fdset <= __FD_SETSIZE && fdt->max_fds <= NR_OPEN_DEFAULT) { 128 if (fdt->max_fdset <= EMBEDDED_FD_SET_SIZE &&
129 fdt->max_fds <= NR_OPEN_DEFAULT) {
129 /* 130 /*
130 * The fdtable was embedded 131 * The fdtable was embedded
131 */ 132 */
@@ -155,8 +156,9 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
155 156
156void free_fdtable(struct fdtable *fdt) 157void free_fdtable(struct fdtable *fdt)
157{ 158{
158 if (fdt->free_files || fdt->max_fdset > __FD_SETSIZE || 159 if (fdt->free_files ||
159 fdt->max_fds > NR_OPEN_DEFAULT) 160 fdt->max_fdset > EMBEDDED_FD_SET_SIZE ||
161 fdt->max_fds > NR_OPEN_DEFAULT)
160 call_rcu(&fdt->rcu, free_fdtable_rcu); 162 call_rcu(&fdt->rcu, free_fdtable_rcu);
161} 163}
162 164
@@ -199,7 +201,6 @@ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *fdt)
199 (nfdt->max_fds - fdt->max_fds) * 201 (nfdt->max_fds - fdt->max_fds) *
200 sizeof(struct file *)); 202 sizeof(struct file *));
201 } 203 }
202 nfdt->next_fd = fdt->next_fd;
203} 204}
204 205
205/* 206/*
@@ -220,11 +221,9 @@ fd_set * alloc_fdset(int num)
220 221
221void free_fdset(fd_set *array, int num) 222void free_fdset(fd_set *array, int num)
222{ 223{
223 int size = num / 8; 224 if (num <= EMBEDDED_FD_SET_SIZE) /* Don't free an embedded fdset */
224
225 if (num <= __FD_SETSIZE) /* Don't free an embedded fdset */
226 return; 225 return;
227 else if (size <= PAGE_SIZE) 226 else if (num <= 8 * PAGE_SIZE)
228 kfree(array); 227 kfree(array);
229 else 228 else
230 vfree(array); 229 vfree(array);
@@ -237,22 +236,17 @@ static struct fdtable *alloc_fdtable(int nr)
237 fd_set *new_openset = NULL, *new_execset = NULL; 236 fd_set *new_openset = NULL, *new_execset = NULL;
238 struct file **new_fds; 237 struct file **new_fds;
239 238
240 fdt = kmalloc(sizeof(*fdt), GFP_KERNEL); 239 fdt = kzalloc(sizeof(*fdt), GFP_KERNEL);
241 if (!fdt) 240 if (!fdt)
242 goto out; 241 goto out;
243 memset(fdt, 0, sizeof(*fdt));
244 242
245 nfds = __FD_SETSIZE; 243 nfds = 8 * L1_CACHE_BYTES;
246 /* Expand to the max in easy steps */ 244 /* Expand to the max in easy steps */
247 do { 245 while (nfds <= nr) {
248 if (nfds < (PAGE_SIZE * 8)) 246 nfds = nfds * 2;
249 nfds = PAGE_SIZE * 8; 247 if (nfds > NR_OPEN)
250 else { 248 nfds = NR_OPEN;
251 nfds = nfds * 2; 249 }
252 if (nfds > NR_OPEN)
253 nfds = NR_OPEN;
254 }
255 } while (nfds <= nr);
256 250
257 new_openset = alloc_fdset(nfds); 251 new_openset = alloc_fdset(nfds);
258 new_execset = alloc_fdset(nfds); 252 new_execset = alloc_fdset(nfds);
diff --git a/fs/file_table.c b/fs/file_table.c
index 44fabeaa9415..bcea1998b4de 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -88,6 +88,7 @@ int proc_nr_files(ctl_table *table, int write, struct file *filp,
88 */ 88 */
89struct file *get_empty_filp(void) 89struct file *get_empty_filp(void)
90{ 90{
91 struct task_struct *tsk;
91 static int old_max; 92 static int old_max;
92 struct file * f; 93 struct file * f;
93 94
@@ -112,13 +113,14 @@ struct file *get_empty_filp(void)
112 if (security_file_alloc(f)) 113 if (security_file_alloc(f))
113 goto fail_sec; 114 goto fail_sec;
114 115
115 eventpoll_init_file(f); 116 tsk = current;
117 INIT_LIST_HEAD(&f->f_u.fu_list);
116 atomic_set(&f->f_count, 1); 118 atomic_set(&f->f_count, 1);
117 f->f_uid = current->fsuid;
118 f->f_gid = current->fsgid;
119 rwlock_init(&f->f_owner.lock); 119 rwlock_init(&f->f_owner.lock);
120 f->f_uid = tsk->fsuid;
121 f->f_gid = tsk->fsgid;
122 eventpoll_init_file(f);
120 /* f->f_version: 0 */ 123 /* f->f_version: 0 */
121 INIT_LIST_HEAD(&f->f_u.fu_list);
122 return f; 124 return f;
123 125
124over: 126over:
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 6628c3b352cb..4c6473ab3b34 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -9,6 +9,7 @@
9//#define DBG 9//#define DBG
10//#define DEBUG_LOCKS 10//#define DEBUG_LOCKS
11 11
12#include <linux/mutex.h>
12#include <linux/pagemap.h> 13#include <linux/pagemap.h>
13#include <linux/buffer_head.h> 14#include <linux/buffer_head.h>
14#include <linux/hpfs_fs.h> 15#include <linux/hpfs_fs.h>
@@ -57,8 +58,8 @@ struct hpfs_inode_info {
57 unsigned i_ea_uid : 1; /* file's uid is stored in ea */ 58 unsigned i_ea_uid : 1; /* file's uid is stored in ea */
58 unsigned i_ea_gid : 1; /* file's gid is stored in ea */ 59 unsigned i_ea_gid : 1; /* file's gid is stored in ea */
59 unsigned i_dirty : 1; 60 unsigned i_dirty : 1;
60 struct semaphore i_sem; 61 struct mutex i_mutex;
61 struct semaphore i_parent; 62 struct mutex i_parent_mutex;
62 loff_t **i_rddir_off; 63 loff_t **i_rddir_off;
63 struct inode vfs_inode; 64 struct inode vfs_inode;
64}; 65};
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index e3d17e9ea6c1..56f2c338c4d9 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -186,9 +186,9 @@ void hpfs_write_inode(struct inode *i)
186 kfree(hpfs_inode->i_rddir_off); 186 kfree(hpfs_inode->i_rddir_off);
187 hpfs_inode->i_rddir_off = NULL; 187 hpfs_inode->i_rddir_off = NULL;
188 } 188 }
189 down(&hpfs_inode->i_parent); 189 mutex_lock(&hpfs_inode->i_parent_mutex);
190 if (!i->i_nlink) { 190 if (!i->i_nlink) {
191 up(&hpfs_inode->i_parent); 191 mutex_unlock(&hpfs_inode->i_parent_mutex);
192 return; 192 return;
193 } 193 }
194 parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); 194 parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
@@ -199,14 +199,14 @@ void hpfs_write_inode(struct inode *i)
199 hpfs_read_inode(parent); 199 hpfs_read_inode(parent);
200 unlock_new_inode(parent); 200 unlock_new_inode(parent);
201 } 201 }
202 down(&hpfs_inode->i_sem); 202 mutex_lock(&hpfs_inode->i_mutex);
203 hpfs_write_inode_nolock(i); 203 hpfs_write_inode_nolock(i);
204 up(&hpfs_inode->i_sem); 204 mutex_unlock(&hpfs_inode->i_mutex);
205 iput(parent); 205 iput(parent);
206 } else { 206 } else {
207 mark_inode_dirty(i); 207 mark_inode_dirty(i);
208 } 208 }
209 up(&hpfs_inode->i_parent); 209 mutex_unlock(&hpfs_inode->i_parent_mutex);
210} 210}
211 211
212void hpfs_write_inode_nolock(struct inode *i) 212void hpfs_write_inode_nolock(struct inode *i)
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 8ff8fc433fc1..a03abb12c610 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -60,7 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
60 if (dee.read_only) 60 if (dee.read_only)
61 result->i_mode &= ~0222; 61 result->i_mode &= ~0222;
62 62
63 down(&hpfs_i(dir)->i_sem); 63 mutex_lock(&hpfs_i(dir)->i_mutex);
64 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); 64 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
65 if (r == 1) 65 if (r == 1)
66 goto bail3; 66 goto bail3;
@@ -101,11 +101,11 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
101 hpfs_write_inode_nolock(result); 101 hpfs_write_inode_nolock(result);
102 } 102 }
103 d_instantiate(dentry, result); 103 d_instantiate(dentry, result);
104 up(&hpfs_i(dir)->i_sem); 104 mutex_unlock(&hpfs_i(dir)->i_mutex);
105 unlock_kernel(); 105 unlock_kernel();
106 return 0; 106 return 0;
107bail3: 107bail3:
108 up(&hpfs_i(dir)->i_sem); 108 mutex_unlock(&hpfs_i(dir)->i_mutex);
109 iput(result); 109 iput(result);
110bail2: 110bail2:
111 hpfs_brelse4(&qbh0); 111 hpfs_brelse4(&qbh0);
@@ -168,7 +168,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
168 result->i_data.a_ops = &hpfs_aops; 168 result->i_data.a_ops = &hpfs_aops;
169 hpfs_i(result)->mmu_private = 0; 169 hpfs_i(result)->mmu_private = 0;
170 170
171 down(&hpfs_i(dir)->i_sem); 171 mutex_lock(&hpfs_i(dir)->i_mutex);
172 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); 172 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
173 if (r == 1) 173 if (r == 1)
174 goto bail2; 174 goto bail2;
@@ -193,12 +193,12 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
193 hpfs_write_inode_nolock(result); 193 hpfs_write_inode_nolock(result);
194 } 194 }
195 d_instantiate(dentry, result); 195 d_instantiate(dentry, result);
196 up(&hpfs_i(dir)->i_sem); 196 mutex_unlock(&hpfs_i(dir)->i_mutex);
197 unlock_kernel(); 197 unlock_kernel();
198 return 0; 198 return 0;
199 199
200bail2: 200bail2:
201 up(&hpfs_i(dir)->i_sem); 201 mutex_unlock(&hpfs_i(dir)->i_mutex);
202 iput(result); 202 iput(result);
203bail1: 203bail1:
204 brelse(bh); 204 brelse(bh);
@@ -254,7 +254,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
254 result->i_blocks = 1; 254 result->i_blocks = 1;
255 init_special_inode(result, mode, rdev); 255 init_special_inode(result, mode, rdev);
256 256
257 down(&hpfs_i(dir)->i_sem); 257 mutex_lock(&hpfs_i(dir)->i_mutex);
258 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); 258 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
259 if (r == 1) 259 if (r == 1)
260 goto bail2; 260 goto bail2;
@@ -271,12 +271,12 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
271 271
272 hpfs_write_inode_nolock(result); 272 hpfs_write_inode_nolock(result);
273 d_instantiate(dentry, result); 273 d_instantiate(dentry, result);
274 up(&hpfs_i(dir)->i_sem); 274 mutex_unlock(&hpfs_i(dir)->i_mutex);
275 brelse(bh); 275 brelse(bh);
276 unlock_kernel(); 276 unlock_kernel();
277 return 0; 277 return 0;
278bail2: 278bail2:
279 up(&hpfs_i(dir)->i_sem); 279 mutex_unlock(&hpfs_i(dir)->i_mutex);
280 iput(result); 280 iput(result);
281bail1: 281bail1:
282 brelse(bh); 282 brelse(bh);
@@ -333,7 +333,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
333 result->i_op = &page_symlink_inode_operations; 333 result->i_op = &page_symlink_inode_operations;
334 result->i_data.a_ops = &hpfs_symlink_aops; 334 result->i_data.a_ops = &hpfs_symlink_aops;
335 335
336 down(&hpfs_i(dir)->i_sem); 336 mutex_lock(&hpfs_i(dir)->i_mutex);
337 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); 337 r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
338 if (r == 1) 338 if (r == 1)
339 goto bail2; 339 goto bail2;
@@ -352,11 +352,11 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
352 352
353 hpfs_write_inode_nolock(result); 353 hpfs_write_inode_nolock(result);
354 d_instantiate(dentry, result); 354 d_instantiate(dentry, result);
355 up(&hpfs_i(dir)->i_sem); 355 mutex_unlock(&hpfs_i(dir)->i_mutex);
356 unlock_kernel(); 356 unlock_kernel();
357 return 0; 357 return 0;
358bail2: 358bail2:
359 up(&hpfs_i(dir)->i_sem); 359 mutex_unlock(&hpfs_i(dir)->i_mutex);
360 iput(result); 360 iput(result);
361bail1: 361bail1:
362 brelse(bh); 362 brelse(bh);
@@ -382,8 +382,8 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
382 lock_kernel(); 382 lock_kernel();
383 hpfs_adjust_length((char *)name, &len); 383 hpfs_adjust_length((char *)name, &len);
384again: 384again:
385 down(&hpfs_i(inode)->i_parent); 385 mutex_lock(&hpfs_i(inode)->i_parent_mutex);
386 down(&hpfs_i(dir)->i_sem); 386 mutex_lock(&hpfs_i(dir)->i_mutex);
387 err = -ENOENT; 387 err = -ENOENT;
388 de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh); 388 de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh);
389 if (!de) 389 if (!de)
@@ -410,8 +410,8 @@ again:
410 if (rep++) 410 if (rep++)
411 break; 411 break;
412 412
413 up(&hpfs_i(dir)->i_sem); 413 mutex_unlock(&hpfs_i(dir)->i_mutex);
414 up(&hpfs_i(inode)->i_parent); 414 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
415 d_drop(dentry); 415 d_drop(dentry);
416 spin_lock(&dentry->d_lock); 416 spin_lock(&dentry->d_lock);
417 if (atomic_read(&dentry->d_count) > 1 || 417 if (atomic_read(&dentry->d_count) > 1 ||
@@ -442,8 +442,8 @@ again:
442out1: 442out1:
443 hpfs_brelse4(&qbh); 443 hpfs_brelse4(&qbh);
444out: 444out:
445 up(&hpfs_i(dir)->i_sem); 445 mutex_unlock(&hpfs_i(dir)->i_mutex);
446 up(&hpfs_i(inode)->i_parent); 446 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
447 unlock_kernel(); 447 unlock_kernel();
448 return err; 448 return err;
449} 449}
@@ -463,8 +463,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
463 463
464 hpfs_adjust_length((char *)name, &len); 464 hpfs_adjust_length((char *)name, &len);
465 lock_kernel(); 465 lock_kernel();
466 down(&hpfs_i(inode)->i_parent); 466 mutex_lock(&hpfs_i(inode)->i_parent_mutex);
467 down(&hpfs_i(dir)->i_sem); 467 mutex_lock(&hpfs_i(dir)->i_mutex);
468 err = -ENOENT; 468 err = -ENOENT;
469 de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh); 469 de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh);
470 if (!de) 470 if (!de)
@@ -502,8 +502,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
502out1: 502out1:
503 hpfs_brelse4(&qbh); 503 hpfs_brelse4(&qbh);
504out: 504out:
505 up(&hpfs_i(dir)->i_sem); 505 mutex_unlock(&hpfs_i(dir)->i_mutex);
506 up(&hpfs_i(inode)->i_parent); 506 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
507 unlock_kernel(); 507 unlock_kernel();
508 return err; 508 return err;
509} 509}
@@ -565,12 +565,12 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
565 565
566 lock_kernel(); 566 lock_kernel();
567 /* order doesn't matter, due to VFS exclusion */ 567 /* order doesn't matter, due to VFS exclusion */
568 down(&hpfs_i(i)->i_parent); 568 mutex_lock(&hpfs_i(i)->i_parent_mutex);
569 if (new_inode) 569 if (new_inode)
570 down(&hpfs_i(new_inode)->i_parent); 570 mutex_lock(&hpfs_i(new_inode)->i_parent_mutex);
571 down(&hpfs_i(old_dir)->i_sem); 571 mutex_lock(&hpfs_i(old_dir)->i_mutex);
572 if (new_dir != old_dir) 572 if (new_dir != old_dir)
573 down(&hpfs_i(new_dir)->i_sem); 573 mutex_lock(&hpfs_i(new_dir)->i_mutex);
574 574
575 /* Erm? Moving over the empty non-busy directory is perfectly legal */ 575 /* Erm? Moving over the empty non-busy directory is perfectly legal */
576 if (new_inode && S_ISDIR(new_inode->i_mode)) { 576 if (new_inode && S_ISDIR(new_inode->i_mode)) {
@@ -650,11 +650,11 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
650 hpfs_decide_conv(i, (char *)new_name, new_len); 650 hpfs_decide_conv(i, (char *)new_name, new_len);
651end1: 651end1:
652 if (old_dir != new_dir) 652 if (old_dir != new_dir)
653 up(&hpfs_i(new_dir)->i_sem); 653 mutex_unlock(&hpfs_i(new_dir)->i_mutex);
654 up(&hpfs_i(old_dir)->i_sem); 654 mutex_unlock(&hpfs_i(old_dir)->i_mutex);
655 up(&hpfs_i(i)->i_parent); 655 mutex_unlock(&hpfs_i(i)->i_parent_mutex);
656 if (new_inode) 656 if (new_inode)
657 up(&hpfs_i(new_inode)->i_parent); 657 mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex);
658 unlock_kernel(); 658 unlock_kernel();
659 return err; 659 return err;
660} 660}
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 63e88d7e2c3b..9488a794076e 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -181,8 +181,8 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
181 181
182 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 182 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
183 SLAB_CTOR_CONSTRUCTOR) { 183 SLAB_CTOR_CONSTRUCTOR) {
184 init_MUTEX(&ei->i_sem); 184 mutex_init(&ei->i_mutex);
185 init_MUTEX(&ei->i_parent); 185 mutex_init(&ei->i_parent_mutex);
186 inode_init_once(&ei->vfs_inode); 186 inode_init_once(&ei->vfs_inode);
187 } 187 }
188} 188}
diff --git a/fs/inode.c b/fs/inode.c
index d0be6159eb7f..25967b67903d 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -84,14 +84,14 @@ static struct hlist_head *inode_hashtable;
84DEFINE_SPINLOCK(inode_lock); 84DEFINE_SPINLOCK(inode_lock);
85 85
86/* 86/*
87 * iprune_sem provides exclusion between the kswapd or try_to_free_pages 87 * iprune_mutex provides exclusion between the kswapd or try_to_free_pages
88 * icache shrinking path, and the umount path. Without this exclusion, 88 * icache shrinking path, and the umount path. Without this exclusion,
89 * by the time prune_icache calls iput for the inode whose pages it has 89 * by the time prune_icache calls iput for the inode whose pages it has
90 * been invalidating, or by the time it calls clear_inode & destroy_inode 90 * been invalidating, or by the time it calls clear_inode & destroy_inode
91 * from its final dispose_list, the struct super_block they refer to 91 * from its final dispose_list, the struct super_block they refer to
92 * (for inode->i_sb->s_op) may already have been freed and reused. 92 * (for inode->i_sb->s_op) may already have been freed and reused.
93 */ 93 */
94DECLARE_MUTEX(iprune_sem); 94DEFINE_MUTEX(iprune_mutex);
95 95
96/* 96/*
97 * Statistics gathering.. 97 * Statistics gathering..
@@ -206,7 +206,7 @@ void inode_init_once(struct inode *inode)
206 i_size_ordered_init(inode); 206 i_size_ordered_init(inode);
207#ifdef CONFIG_INOTIFY 207#ifdef CONFIG_INOTIFY
208 INIT_LIST_HEAD(&inode->inotify_watches); 208 INIT_LIST_HEAD(&inode->inotify_watches);
209 sema_init(&inode->inotify_sem, 1); 209 mutex_init(&inode->inotify_mutex);
210#endif 210#endif
211} 211}
212 212
@@ -319,7 +319,7 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
319 /* 319 /*
320 * We can reschedule here without worrying about the list's 320 * We can reschedule here without worrying about the list's
321 * consistency because the per-sb list of inodes must not 321 * consistency because the per-sb list of inodes must not
322 * change during umount anymore, and because iprune_sem keeps 322 * change during umount anymore, and because iprune_mutex keeps
323 * shrink_icache_memory() away. 323 * shrink_icache_memory() away.
324 */ 324 */
325 cond_resched_lock(&inode_lock); 325 cond_resched_lock(&inode_lock);
@@ -355,14 +355,14 @@ int invalidate_inodes(struct super_block * sb)
355 int busy; 355 int busy;
356 LIST_HEAD(throw_away); 356 LIST_HEAD(throw_away);
357 357
358 down(&iprune_sem); 358 mutex_lock(&iprune_mutex);
359 spin_lock(&inode_lock); 359 spin_lock(&inode_lock);
360 inotify_unmount_inodes(&sb->s_inodes); 360 inotify_unmount_inodes(&sb->s_inodes);
361 busy = invalidate_list(&sb->s_inodes, &throw_away); 361 busy = invalidate_list(&sb->s_inodes, &throw_away);
362 spin_unlock(&inode_lock); 362 spin_unlock(&inode_lock);
363 363
364 dispose_list(&throw_away); 364 dispose_list(&throw_away);
365 up(&iprune_sem); 365 mutex_unlock(&iprune_mutex);
366 366
367 return busy; 367 return busy;
368} 368}
@@ -377,7 +377,7 @@ int __invalidate_device(struct block_device *bdev)
377 if (sb) { 377 if (sb) {
378 /* 378 /*
379 * no need to lock the super, get_super holds the 379 * no need to lock the super, get_super holds the
380 * read semaphore so the filesystem cannot go away 380 * read mutex so the filesystem cannot go away
381 * under us (->put_super runs with the write lock 381 * under us (->put_super runs with the write lock
382 * hold). 382 * hold).
383 */ 383 */
@@ -423,7 +423,7 @@ static void prune_icache(int nr_to_scan)
423 int nr_scanned; 423 int nr_scanned;
424 unsigned long reap = 0; 424 unsigned long reap = 0;
425 425
426 down(&iprune_sem); 426 mutex_lock(&iprune_mutex);
427 spin_lock(&inode_lock); 427 spin_lock(&inode_lock);
428 for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) { 428 for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) {
429 struct inode *inode; 429 struct inode *inode;
@@ -459,7 +459,7 @@ static void prune_icache(int nr_to_scan)
459 spin_unlock(&inode_lock); 459 spin_unlock(&inode_lock);
460 460
461 dispose_list(&freeable); 461 dispose_list(&freeable);
462 up(&iprune_sem); 462 mutex_unlock(&iprune_mutex);
463 463
464 if (current_is_kswapd()) 464 if (current_is_kswapd())
465 mod_page_state(kswapd_inodesteal, reap); 465 mod_page_state(kswapd_inodesteal, reap);
diff --git a/fs/inotify.c b/fs/inotify.c
index 3041503bde02..0ee39ef591c6 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -54,10 +54,10 @@ int inotify_max_queued_events;
54 * Lock ordering: 54 * Lock ordering:
55 * 55 *
56 * dentry->d_lock (used to keep d_move() away from dentry->d_parent) 56 * dentry->d_lock (used to keep d_move() away from dentry->d_parent)
57 * iprune_sem (synchronize shrink_icache_memory()) 57 * iprune_mutex (synchronize shrink_icache_memory())
58 * inode_lock (protects the super_block->s_inodes list) 58 * inode_lock (protects the super_block->s_inodes list)
59 * inode->inotify_sem (protects inode->inotify_watches and watches->i_list) 59 * inode->inotify_mutex (protects inode->inotify_watches and watches->i_list)
60 * inotify_dev->sem (protects inotify_device and watches->d_list) 60 * inotify_dev->mutex (protects inotify_device and watches->d_list)
61 */ 61 */
62 62
63/* 63/*
@@ -79,12 +79,12 @@ int inotify_max_queued_events;
79/* 79/*
80 * struct inotify_device - represents an inotify instance 80 * struct inotify_device - represents an inotify instance
81 * 81 *
82 * This structure is protected by the semaphore 'sem'. 82 * This structure is protected by the mutex 'mutex'.
83 */ 83 */
84struct inotify_device { 84struct inotify_device {
85 wait_queue_head_t wq; /* wait queue for i/o */ 85 wait_queue_head_t wq; /* wait queue for i/o */
86 struct idr idr; /* idr mapping wd -> watch */ 86 struct idr idr; /* idr mapping wd -> watch */
87 struct semaphore sem; /* protects this bad boy */ 87 struct mutex mutex; /* protects this bad boy */
88 struct list_head events; /* list of queued events */ 88 struct list_head events; /* list of queued events */
89 struct list_head watches; /* list of watches */ 89 struct list_head watches; /* list of watches */
90 atomic_t count; /* reference count */ 90 atomic_t count; /* reference count */
@@ -101,7 +101,7 @@ struct inotify_device {
101 * device. In read(), this list is walked and all events that can fit in the 101 * device. In read(), this list is walked and all events that can fit in the
102 * buffer are returned. 102 * buffer are returned.
103 * 103 *
104 * Protected by dev->sem of the device in which we are queued. 104 * Protected by dev->mutex of the device in which we are queued.
105 */ 105 */
106struct inotify_kernel_event { 106struct inotify_kernel_event {
107 struct inotify_event event; /* the user-space event */ 107 struct inotify_event event; /* the user-space event */
@@ -112,8 +112,8 @@ struct inotify_kernel_event {
112/* 112/*
113 * struct inotify_watch - represents a watch request on a specific inode 113 * struct inotify_watch - represents a watch request on a specific inode
114 * 114 *
115 * d_list is protected by dev->sem of the associated watch->dev. 115 * d_list is protected by dev->mutex of the associated watch->dev.
116 * i_list and mask are protected by inode->inotify_sem of the associated inode. 116 * i_list and mask are protected by inode->inotify_mutex of the associated inode.
117 * dev, inode, and wd are never written to once the watch is created. 117 * dev, inode, and wd are never written to once the watch is created.
118 */ 118 */
119struct inotify_watch { 119struct inotify_watch {
@@ -261,7 +261,7 @@ static struct inotify_kernel_event * kernel_event(s32 wd, u32 mask, u32 cookie,
261/* 261/*
262 * inotify_dev_get_event - return the next event in the given dev's queue 262 * inotify_dev_get_event - return the next event in the given dev's queue
263 * 263 *
264 * Caller must hold dev->sem. 264 * Caller must hold dev->mutex.
265 */ 265 */
266static inline struct inotify_kernel_event * 266static inline struct inotify_kernel_event *
267inotify_dev_get_event(struct inotify_device *dev) 267inotify_dev_get_event(struct inotify_device *dev)
@@ -272,7 +272,7 @@ inotify_dev_get_event(struct inotify_device *dev)
272/* 272/*
273 * inotify_dev_queue_event - add a new event to the given device 273 * inotify_dev_queue_event - add a new event to the given device
274 * 274 *
275 * Caller must hold dev->sem. Can sleep (calls kernel_event()). 275 * Caller must hold dev->mutex. Can sleep (calls kernel_event()).
276 */ 276 */
277static void inotify_dev_queue_event(struct inotify_device *dev, 277static void inotify_dev_queue_event(struct inotify_device *dev,
278 struct inotify_watch *watch, u32 mask, 278 struct inotify_watch *watch, u32 mask,
@@ -315,7 +315,7 @@ static void inotify_dev_queue_event(struct inotify_device *dev,
315/* 315/*
316 * remove_kevent - cleans up and ultimately frees the given kevent 316 * remove_kevent - cleans up and ultimately frees the given kevent
317 * 317 *
318 * Caller must hold dev->sem. 318 * Caller must hold dev->mutex.
319 */ 319 */
320static void remove_kevent(struct inotify_device *dev, 320static void remove_kevent(struct inotify_device *dev,
321 struct inotify_kernel_event *kevent) 321 struct inotify_kernel_event *kevent)
@@ -332,7 +332,7 @@ static void remove_kevent(struct inotify_device *dev,
332/* 332/*
333 * inotify_dev_event_dequeue - destroy an event on the given device 333 * inotify_dev_event_dequeue - destroy an event on the given device
334 * 334 *
335 * Caller must hold dev->sem. 335 * Caller must hold dev->mutex.
336 */ 336 */
337static void inotify_dev_event_dequeue(struct inotify_device *dev) 337static void inotify_dev_event_dequeue(struct inotify_device *dev)
338{ 338{
@@ -346,7 +346,7 @@ static void inotify_dev_event_dequeue(struct inotify_device *dev)
346/* 346/*
347 * inotify_dev_get_wd - returns the next WD for use by the given dev 347 * inotify_dev_get_wd - returns the next WD for use by the given dev
348 * 348 *
349 * Callers must hold dev->sem. This function can sleep. 349 * Callers must hold dev->mutex. This function can sleep.
350 */ 350 */
351static int inotify_dev_get_wd(struct inotify_device *dev, 351static int inotify_dev_get_wd(struct inotify_device *dev,
352 struct inotify_watch *watch) 352 struct inotify_watch *watch)
@@ -383,7 +383,7 @@ static int find_inode(const char __user *dirname, struct nameidata *nd,
383/* 383/*
384 * create_watch - creates a watch on the given device. 384 * create_watch - creates a watch on the given device.
385 * 385 *
386 * Callers must hold dev->sem. Calls inotify_dev_get_wd() so may sleep. 386 * Callers must hold dev->mutex. Calls inotify_dev_get_wd() so may sleep.
387 * Both 'dev' and 'inode' (by way of nameidata) need to be pinned. 387 * Both 'dev' and 'inode' (by way of nameidata) need to be pinned.
388 */ 388 */
389static struct inotify_watch *create_watch(struct inotify_device *dev, 389static struct inotify_watch *create_watch(struct inotify_device *dev,
@@ -434,7 +434,7 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
434/* 434/*
435 * inotify_find_dev - find the watch associated with the given inode and dev 435 * inotify_find_dev - find the watch associated with the given inode and dev
436 * 436 *
437 * Callers must hold inode->inotify_sem. 437 * Callers must hold inode->inotify_mutex.
438 */ 438 */
439static struct inotify_watch *inode_find_dev(struct inode *inode, 439static struct inotify_watch *inode_find_dev(struct inode *inode,
440 struct inotify_device *dev) 440 struct inotify_device *dev)
@@ -469,7 +469,7 @@ static void remove_watch_no_event(struct inotify_watch *watch,
469 * the IN_IGNORED event to the given device signifying that the inode is no 469 * the IN_IGNORED event to the given device signifying that the inode is no
470 * longer watched. 470 * longer watched.
471 * 471 *
472 * Callers must hold both inode->inotify_sem and dev->sem. We drop a 472 * Callers must hold both inode->inotify_mutex and dev->mutex. We drop a
473 * reference to the inode before returning. 473 * reference to the inode before returning.
474 * 474 *
475 * The inode is not iput() so as to remain atomic. If the inode needs to be 475 * The inode is not iput() so as to remain atomic. If the inode needs to be
@@ -507,21 +507,21 @@ void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
507 if (!inotify_inode_watched(inode)) 507 if (!inotify_inode_watched(inode))
508 return; 508 return;
509 509
510 down(&inode->inotify_sem); 510 mutex_lock(&inode->inotify_mutex);
511 list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) { 511 list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
512 u32 watch_mask = watch->mask; 512 u32 watch_mask = watch->mask;
513 if (watch_mask & mask) { 513 if (watch_mask & mask) {
514 struct inotify_device *dev = watch->dev; 514 struct inotify_device *dev = watch->dev;
515 get_inotify_watch(watch); 515 get_inotify_watch(watch);
516 down(&dev->sem); 516 mutex_lock(&dev->mutex);
517 inotify_dev_queue_event(dev, watch, mask, cookie, name); 517 inotify_dev_queue_event(dev, watch, mask, cookie, name);
518 if (watch_mask & IN_ONESHOT) 518 if (watch_mask & IN_ONESHOT)
519 remove_watch_no_event(watch, dev); 519 remove_watch_no_event(watch, dev);
520 up(&dev->sem); 520 mutex_unlock(&dev->mutex);
521 put_inotify_watch(watch); 521 put_inotify_watch(watch);
522 } 522 }
523 } 523 }
524 up(&inode->inotify_sem); 524 mutex_unlock(&inode->inotify_mutex);
525} 525}
526EXPORT_SYMBOL_GPL(inotify_inode_queue_event); 526EXPORT_SYMBOL_GPL(inotify_inode_queue_event);
527 527
@@ -569,7 +569,7 @@ EXPORT_SYMBOL_GPL(inotify_get_cookie);
569 * @list: list of inodes being unmounted (sb->s_inodes) 569 * @list: list of inodes being unmounted (sb->s_inodes)
570 * 570 *
571 * Called with inode_lock held, protecting the unmounting super block's list 571 * Called with inode_lock held, protecting the unmounting super block's list
572 * of inodes, and with iprune_sem held, keeping shrink_icache_memory() at bay. 572 * of inodes, and with iprune_mutex held, keeping shrink_icache_memory() at bay.
573 * We temporarily drop inode_lock, however, and CAN block. 573 * We temporarily drop inode_lock, however, and CAN block.
574 */ 574 */
575void inotify_unmount_inodes(struct list_head *list) 575void inotify_unmount_inodes(struct list_head *list)
@@ -618,7 +618,7 @@ void inotify_unmount_inodes(struct list_head *list)
618 * We can safely drop inode_lock here because we hold 618 * We can safely drop inode_lock here because we hold
619 * references on both inode and next_i. Also no new inodes 619 * references on both inode and next_i. Also no new inodes
620 * will be added since the umount has begun. Finally, 620 * will be added since the umount has begun. Finally,
621 * iprune_sem keeps shrink_icache_memory() away. 621 * iprune_mutex keeps shrink_icache_memory() away.
622 */ 622 */
623 spin_unlock(&inode_lock); 623 spin_unlock(&inode_lock);
624 624
@@ -626,16 +626,16 @@ void inotify_unmount_inodes(struct list_head *list)
626 iput(need_iput_tmp); 626 iput(need_iput_tmp);
627 627
628 /* for each watch, send IN_UNMOUNT and then remove it */ 628 /* for each watch, send IN_UNMOUNT and then remove it */
629 down(&inode->inotify_sem); 629 mutex_lock(&inode->inotify_mutex);
630 watches = &inode->inotify_watches; 630 watches = &inode->inotify_watches;
631 list_for_each_entry_safe(watch, next_w, watches, i_list) { 631 list_for_each_entry_safe(watch, next_w, watches, i_list) {
632 struct inotify_device *dev = watch->dev; 632 struct inotify_device *dev = watch->dev;
633 down(&dev->sem); 633 mutex_lock(&dev->mutex);
634 inotify_dev_queue_event(dev, watch, IN_UNMOUNT,0,NULL); 634 inotify_dev_queue_event(dev, watch, IN_UNMOUNT,0,NULL);
635 remove_watch(watch, dev); 635 remove_watch(watch, dev);
636 up(&dev->sem); 636 mutex_unlock(&dev->mutex);
637 } 637 }
638 up(&inode->inotify_sem); 638 mutex_unlock(&inode->inotify_mutex);
639 iput(inode); 639 iput(inode);
640 640
641 spin_lock(&inode_lock); 641 spin_lock(&inode_lock);
@@ -651,14 +651,14 @@ void inotify_inode_is_dead(struct inode *inode)
651{ 651{
652 struct inotify_watch *watch, *next; 652 struct inotify_watch *watch, *next;
653 653
654 down(&inode->inotify_sem); 654 mutex_lock(&inode->inotify_mutex);
655 list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) { 655 list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
656 struct inotify_device *dev = watch->dev; 656 struct inotify_device *dev = watch->dev;
657 down(&dev->sem); 657 mutex_lock(&dev->mutex);
658 remove_watch(watch, dev); 658 remove_watch(watch, dev);
659 up(&dev->sem); 659 mutex_unlock(&dev->mutex);
660 } 660 }
661 up(&inode->inotify_sem); 661 mutex_unlock(&inode->inotify_mutex);
662} 662}
663EXPORT_SYMBOL_GPL(inotify_inode_is_dead); 663EXPORT_SYMBOL_GPL(inotify_inode_is_dead);
664 664
@@ -670,10 +670,10 @@ static unsigned int inotify_poll(struct file *file, poll_table *wait)
670 int ret = 0; 670 int ret = 0;
671 671
672 poll_wait(file, &dev->wq, wait); 672 poll_wait(file, &dev->wq, wait);
673 down(&dev->sem); 673 mutex_lock(&dev->mutex);
674 if (!list_empty(&dev->events)) 674 if (!list_empty(&dev->events))
675 ret = POLLIN | POLLRDNORM; 675 ret = POLLIN | POLLRDNORM;
676 up(&dev->sem); 676 mutex_unlock(&dev->mutex);
677 677
678 return ret; 678 return ret;
679} 679}
@@ -695,9 +695,9 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
695 695
696 prepare_to_wait(&dev->wq, &wait, TASK_INTERRUPTIBLE); 696 prepare_to_wait(&dev->wq, &wait, TASK_INTERRUPTIBLE);
697 697
698 down(&dev->sem); 698 mutex_lock(&dev->mutex);
699 events = !list_empty(&dev->events); 699 events = !list_empty(&dev->events);
700 up(&dev->sem); 700 mutex_unlock(&dev->mutex);
701 if (events) { 701 if (events) {
702 ret = 0; 702 ret = 0;
703 break; 703 break;
@@ -720,7 +720,7 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
720 if (ret) 720 if (ret)
721 return ret; 721 return ret;
722 722
723 down(&dev->sem); 723 mutex_lock(&dev->mutex);
724 while (1) { 724 while (1) {
725 struct inotify_kernel_event *kevent; 725 struct inotify_kernel_event *kevent;
726 726
@@ -750,7 +750,7 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
750 750
751 remove_kevent(dev, kevent); 751 remove_kevent(dev, kevent);
752 } 752 }
753 up(&dev->sem); 753 mutex_unlock(&dev->mutex);
754 754
755 return ret; 755 return ret;
756} 756}
@@ -763,37 +763,37 @@ static int inotify_release(struct inode *ignored, struct file *file)
763 * Destroy all of the watches on this device. Unfortunately, not very 763 * Destroy all of the watches on this device. Unfortunately, not very
764 * pretty. We cannot do a simple iteration over the list, because we 764 * pretty. We cannot do a simple iteration over the list, because we
765 * do not know the inode until we iterate to the watch. But we need to 765 * do not know the inode until we iterate to the watch. But we need to
766 * hold inode->inotify_sem before dev->sem. The following works. 766 * hold inode->inotify_mutex before dev->mutex. The following works.
767 */ 767 */
768 while (1) { 768 while (1) {
769 struct inotify_watch *watch; 769 struct inotify_watch *watch;
770 struct list_head *watches; 770 struct list_head *watches;
771 struct inode *inode; 771 struct inode *inode;
772 772
773 down(&dev->sem); 773 mutex_lock(&dev->mutex);
774 watches = &dev->watches; 774 watches = &dev->watches;
775 if (list_empty(watches)) { 775 if (list_empty(watches)) {
776 up(&dev->sem); 776 mutex_unlock(&dev->mutex);
777 break; 777 break;
778 } 778 }
779 watch = list_entry(watches->next, struct inotify_watch, d_list); 779 watch = list_entry(watches->next, struct inotify_watch, d_list);
780 get_inotify_watch(watch); 780 get_inotify_watch(watch);
781 up(&dev->sem); 781 mutex_unlock(&dev->mutex);
782 782
783 inode = watch->inode; 783 inode = watch->inode;
784 down(&inode->inotify_sem); 784 mutex_lock(&inode->inotify_mutex);
785 down(&dev->sem); 785 mutex_lock(&dev->mutex);
786 remove_watch_no_event(watch, dev); 786 remove_watch_no_event(watch, dev);
787 up(&dev->sem); 787 mutex_unlock(&dev->mutex);
788 up(&inode->inotify_sem); 788 mutex_unlock(&inode->inotify_mutex);
789 put_inotify_watch(watch); 789 put_inotify_watch(watch);
790 } 790 }
791 791
792 /* destroy all of the events on this device */ 792 /* destroy all of the events on this device */
793 down(&dev->sem); 793 mutex_lock(&dev->mutex);
794 while (!list_empty(&dev->events)) 794 while (!list_empty(&dev->events))
795 inotify_dev_event_dequeue(dev); 795 inotify_dev_event_dequeue(dev);
796 up(&dev->sem); 796 mutex_unlock(&dev->mutex);
797 797
798 /* free this device: the put matching the get in inotify_init() */ 798 /* free this device: the put matching the get in inotify_init() */
799 put_inotify_dev(dev); 799 put_inotify_dev(dev);
@@ -811,26 +811,26 @@ static int inotify_ignore(struct inotify_device *dev, s32 wd)
811 struct inotify_watch *watch; 811 struct inotify_watch *watch;
812 struct inode *inode; 812 struct inode *inode;
813 813
814 down(&dev->sem); 814 mutex_lock(&dev->mutex);
815 watch = idr_find(&dev->idr, wd); 815 watch = idr_find(&dev->idr, wd);
816 if (unlikely(!watch)) { 816 if (unlikely(!watch)) {
817 up(&dev->sem); 817 mutex_unlock(&dev->mutex);
818 return -EINVAL; 818 return -EINVAL;
819 } 819 }
820 get_inotify_watch(watch); 820 get_inotify_watch(watch);
821 inode = watch->inode; 821 inode = watch->inode;
822 up(&dev->sem); 822 mutex_unlock(&dev->mutex);
823 823
824 down(&inode->inotify_sem); 824 mutex_lock(&inode->inotify_mutex);
825 down(&dev->sem); 825 mutex_lock(&dev->mutex);
826 826
827 /* make sure that we did not race */ 827 /* make sure that we did not race */
828 watch = idr_find(&dev->idr, wd); 828 watch = idr_find(&dev->idr, wd);
829 if (likely(watch)) 829 if (likely(watch))
830 remove_watch(watch, dev); 830 remove_watch(watch, dev);
831 831
832 up(&dev->sem); 832 mutex_unlock(&dev->mutex);
833 up(&inode->inotify_sem); 833 mutex_unlock(&inode->inotify_mutex);
834 put_inotify_watch(watch); 834 put_inotify_watch(watch);
835 835
836 return 0; 836 return 0;
@@ -905,7 +905,7 @@ asmlinkage long sys_inotify_init(void)
905 INIT_LIST_HEAD(&dev->events); 905 INIT_LIST_HEAD(&dev->events);
906 INIT_LIST_HEAD(&dev->watches); 906 INIT_LIST_HEAD(&dev->watches);
907 init_waitqueue_head(&dev->wq); 907 init_waitqueue_head(&dev->wq);
908 sema_init(&dev->sem, 1); 908 mutex_init(&dev->mutex);
909 dev->event_count = 0; 909 dev->event_count = 0;
910 dev->queue_size = 0; 910 dev->queue_size = 0;
911 dev->max_events = inotify_max_queued_events; 911 dev->max_events = inotify_max_queued_events;
@@ -960,8 +960,8 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
960 inode = nd.dentry->d_inode; 960 inode = nd.dentry->d_inode;
961 dev = filp->private_data; 961 dev = filp->private_data;
962 962
963 down(&inode->inotify_sem); 963 mutex_lock(&inode->inotify_mutex);
964 down(&dev->sem); 964 mutex_lock(&dev->mutex);
965 965
966 if (mask & IN_MASK_ADD) 966 if (mask & IN_MASK_ADD)
967 mask_add = 1; 967 mask_add = 1;
@@ -998,8 +998,8 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
998 list_add(&watch->i_list, &inode->inotify_watches); 998 list_add(&watch->i_list, &inode->inotify_watches);
999 ret = watch->wd; 999 ret = watch->wd;
1000out: 1000out:
1001 up(&dev->sem); 1001 mutex_unlock(&dev->mutex);
1002 up(&inode->inotify_sem); 1002 mutex_unlock(&inode->inotify_mutex);
1003 path_release(&nd); 1003 path_release(&nd);
1004fput_and_out: 1004fput_and_out:
1005 fput_light(filp, fput_needed); 1005 fput_light(filp, fput_needed);
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
index 543ed543d1e5..3f5102b069db 100644
--- a/fs/jbd/checkpoint.c
+++ b/fs/jbd/checkpoint.c
@@ -85,7 +85,7 @@ void __log_wait_for_space(journal_t *journal)
85 if (journal->j_flags & JFS_ABORT) 85 if (journal->j_flags & JFS_ABORT)
86 return; 86 return;
87 spin_unlock(&journal->j_state_lock); 87 spin_unlock(&journal->j_state_lock);
88 down(&journal->j_checkpoint_sem); 88 mutex_lock(&journal->j_checkpoint_mutex);
89 89
90 /* 90 /*
91 * Test again, another process may have checkpointed while we 91 * Test again, another process may have checkpointed while we
@@ -98,7 +98,7 @@ void __log_wait_for_space(journal_t *journal)
98 log_do_checkpoint(journal); 98 log_do_checkpoint(journal);
99 spin_lock(&journal->j_state_lock); 99 spin_lock(&journal->j_state_lock);
100 } 100 }
101 up(&journal->j_checkpoint_sem); 101 mutex_unlock(&journal->j_checkpoint_mutex);
102 } 102 }
103} 103}
104 104
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index e4b516ac4989..95a628d8cac8 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -659,8 +659,8 @@ static journal_t * journal_init_common (void)
659 init_waitqueue_head(&journal->j_wait_checkpoint); 659 init_waitqueue_head(&journal->j_wait_checkpoint);
660 init_waitqueue_head(&journal->j_wait_commit); 660 init_waitqueue_head(&journal->j_wait_commit);
661 init_waitqueue_head(&journal->j_wait_updates); 661 init_waitqueue_head(&journal->j_wait_updates);
662 init_MUTEX(&journal->j_barrier); 662 mutex_init(&journal->j_barrier);
663 init_MUTEX(&journal->j_checkpoint_sem); 663 mutex_init(&journal->j_checkpoint_mutex);
664 spin_lock_init(&journal->j_revoke_lock); 664 spin_lock_init(&journal->j_revoke_lock);
665 spin_lock_init(&journal->j_list_lock); 665 spin_lock_init(&journal->j_list_lock);
666 spin_lock_init(&journal->j_state_lock); 666 spin_lock_init(&journal->j_state_lock);
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index ca917973c2c0..5fc40888f4cf 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -455,7 +455,7 @@ void journal_lock_updates(journal_t *journal)
455 * to make sure that we serialise special journal-locked operations 455 * to make sure that we serialise special journal-locked operations
456 * too. 456 * too.
457 */ 457 */
458 down(&journal->j_barrier); 458 mutex_lock(&journal->j_barrier);
459} 459}
460 460
461/** 461/**
@@ -470,7 +470,7 @@ void journal_unlock_updates (journal_t *journal)
470{ 470{
471 J_ASSERT(journal->j_barrier_count != 0); 471 J_ASSERT(journal->j_barrier_count != 0);
472 472
473 up(&journal->j_barrier); 473 mutex_unlock(&journal->j_barrier);
474 spin_lock(&journal->j_state_lock); 474 spin_lock(&journal->j_state_lock);
475 --journal->j_barrier_count; 475 --journal->j_barrier_count;
476 spin_unlock(&journal->j_state_lock); 476 spin_unlock(&journal->j_state_lock);
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index fc3855a1aef3..890d7ff7456d 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -42,7 +42,7 @@
42#include <linux/quotaops.h> 42#include <linux/quotaops.h>
43#include <linux/highmem.h> 43#include <linux/highmem.h>
44#include <linux/vfs.h> 44#include <linux/vfs.h>
45#include <asm/semaphore.h> 45#include <linux/mutex.h>
46#include <asm/byteorder.h> 46#include <asm/byteorder.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48 48
@@ -203,7 +203,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
203 fmc = c->fmc; 203 fmc = c->fmc;
204 204
205 D3(printk (KERN_NOTICE "notify_change(): down biglock\n")); 205 D3(printk (KERN_NOTICE "notify_change(): down biglock\n"));
206 down(&fmc->biglock); 206 mutex_lock(&fmc->biglock);
207 207
208 f = jffs_find_file(c, inode->i_ino); 208 f = jffs_find_file(c, inode->i_ino);
209 209
@@ -211,7 +211,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
211 printk("jffs_setattr(): Invalid inode number: %lu\n", 211 printk("jffs_setattr(): Invalid inode number: %lu\n",
212 inode->i_ino); 212 inode->i_ino);
213 D3(printk (KERN_NOTICE "notify_change(): up biglock\n")); 213 D3(printk (KERN_NOTICE "notify_change(): up biglock\n"));
214 up(&fmc->biglock); 214 mutex_unlock(&fmc->biglock);
215 res = -EINVAL; 215 res = -EINVAL;
216 goto out; 216 goto out;
217 }); 217 });
@@ -232,7 +232,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
232 if (!(new_node = jffs_alloc_node())) { 232 if (!(new_node = jffs_alloc_node())) {
233 D(printk("jffs_setattr(): Allocation failed!\n")); 233 D(printk("jffs_setattr(): Allocation failed!\n"));
234 D3(printk (KERN_NOTICE "notify_change(): up biglock\n")); 234 D3(printk (KERN_NOTICE "notify_change(): up biglock\n"));
235 up(&fmc->biglock); 235 mutex_unlock(&fmc->biglock);
236 res = -ENOMEM; 236 res = -ENOMEM;
237 goto out; 237 goto out;
238 } 238 }
@@ -319,7 +319,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
319 D(printk("jffs_notify_change(): The write failed!\n")); 319 D(printk("jffs_notify_change(): The write failed!\n"));
320 jffs_free_node(new_node); 320 jffs_free_node(new_node);
321 D3(printk (KERN_NOTICE "n_c(): up biglock\n")); 321 D3(printk (KERN_NOTICE "n_c(): up biglock\n"));
322 up(&c->fmc->biglock); 322 mutex_unlock(&c->fmc->biglock);
323 goto out; 323 goto out;
324 } 324 }
325 325
@@ -327,7 +327,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
327 327
328 mark_inode_dirty(inode); 328 mark_inode_dirty(inode);
329 D3(printk (KERN_NOTICE "n_c(): up biglock\n")); 329 D3(printk (KERN_NOTICE "n_c(): up biglock\n"));
330 up(&c->fmc->biglock); 330 mutex_unlock(&c->fmc->biglock);
331out: 331out:
332 unlock_kernel(); 332 unlock_kernel();
333 return res; 333 return res;
@@ -461,7 +461,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
461 goto jffs_rename_end; 461 goto jffs_rename_end;
462 } 462 }
463 D3(printk (KERN_NOTICE "rename(): down biglock\n")); 463 D3(printk (KERN_NOTICE "rename(): down biglock\n"));
464 down(&c->fmc->biglock); 464 mutex_lock(&c->fmc->biglock);
465 /* Create a node and initialize as much as needed. */ 465 /* Create a node and initialize as much as needed. */
466 result = -ENOMEM; 466 result = -ENOMEM;
467 if (!(node = jffs_alloc_node())) { 467 if (!(node = jffs_alloc_node())) {
@@ -555,7 +555,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
555 555
556jffs_rename_end: 556jffs_rename_end:
557 D3(printk (KERN_NOTICE "rename(): up biglock\n")); 557 D3(printk (KERN_NOTICE "rename(): up biglock\n"));
558 up(&c->fmc->biglock); 558 mutex_unlock(&c->fmc->biglock);
559 unlock_kernel(); 559 unlock_kernel();
560 return result; 560 return result;
561} /* jffs_rename() */ 561} /* jffs_rename() */
@@ -574,14 +574,14 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
574 int ddino; 574 int ddino;
575 lock_kernel(); 575 lock_kernel();
576 D3(printk (KERN_NOTICE "readdir(): down biglock\n")); 576 D3(printk (KERN_NOTICE "readdir(): down biglock\n"));
577 down(&c->fmc->biglock); 577 mutex_lock(&c->fmc->biglock);
578 578
579 D2(printk("jffs_readdir(): inode: 0x%p, filp: 0x%p\n", inode, filp)); 579 D2(printk("jffs_readdir(): inode: 0x%p, filp: 0x%p\n", inode, filp));
580 if (filp->f_pos == 0) { 580 if (filp->f_pos == 0) {
581 D3(printk("jffs_readdir(): \".\" %lu\n", inode->i_ino)); 581 D3(printk("jffs_readdir(): \".\" %lu\n", inode->i_ino));
582 if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0) { 582 if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0) {
583 D3(printk (KERN_NOTICE "readdir(): up biglock\n")); 583 D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
584 up(&c->fmc->biglock); 584 mutex_unlock(&c->fmc->biglock);
585 unlock_kernel(); 585 unlock_kernel();
586 return 0; 586 return 0;
587 } 587 }
@@ -598,7 +598,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
598 D3(printk("jffs_readdir(): \"..\" %u\n", ddino)); 598 D3(printk("jffs_readdir(): \"..\" %u\n", ddino));
599 if (filldir(dirent, "..", 2, filp->f_pos, ddino, DT_DIR) < 0) { 599 if (filldir(dirent, "..", 2, filp->f_pos, ddino, DT_DIR) < 0) {
600 D3(printk (KERN_NOTICE "readdir(): up biglock\n")); 600 D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
601 up(&c->fmc->biglock); 601 mutex_unlock(&c->fmc->biglock);
602 unlock_kernel(); 602 unlock_kernel();
603 return 0; 603 return 0;
604 } 604 }
@@ -617,7 +617,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
617 if (filldir(dirent, f->name, f->nsize, 617 if (filldir(dirent, f->name, f->nsize,
618 filp->f_pos , f->ino, DT_UNKNOWN) < 0) { 618 filp->f_pos , f->ino, DT_UNKNOWN) < 0) {
619 D3(printk (KERN_NOTICE "readdir(): up biglock\n")); 619 D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
620 up(&c->fmc->biglock); 620 mutex_unlock(&c->fmc->biglock);
621 unlock_kernel(); 621 unlock_kernel();
622 return 0; 622 return 0;
623 } 623 }
@@ -627,7 +627,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
627 } while(f && f->deleted); 627 } while(f && f->deleted);
628 } 628 }
629 D3(printk (KERN_NOTICE "readdir(): up biglock\n")); 629 D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
630 up(&c->fmc->biglock); 630 mutex_unlock(&c->fmc->biglock);
631 unlock_kernel(); 631 unlock_kernel();
632 return filp->f_pos; 632 return filp->f_pos;
633} /* jffs_readdir() */ 633} /* jffs_readdir() */
@@ -660,7 +660,7 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
660 }); 660 });
661 661
662 D3(printk (KERN_NOTICE "lookup(): down biglock\n")); 662 D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
663 down(&c->fmc->biglock); 663 mutex_lock(&c->fmc->biglock);
664 664
665 r = -ENAMETOOLONG; 665 r = -ENAMETOOLONG;
666 if (len > JFFS_MAX_NAME_LEN) { 666 if (len > JFFS_MAX_NAME_LEN) {
@@ -683,31 +683,31 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
683 683
684 if ((len == 1) && (name[0] == '.')) { 684 if ((len == 1) && (name[0] == '.')) {
685 D3(printk (KERN_NOTICE "lookup(): up biglock\n")); 685 D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
686 up(&c->fmc->biglock); 686 mutex_unlock(&c->fmc->biglock);
687 if (!(inode = iget(dir->i_sb, d->ino))) { 687 if (!(inode = iget(dir->i_sb, d->ino))) {
688 D(printk("jffs_lookup(): . iget() ==> NULL\n")); 688 D(printk("jffs_lookup(): . iget() ==> NULL\n"));
689 goto jffs_lookup_end_no_biglock; 689 goto jffs_lookup_end_no_biglock;
690 } 690 }
691 D3(printk (KERN_NOTICE "lookup(): down biglock\n")); 691 D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
692 down(&c->fmc->biglock); 692 mutex_lock(&c->fmc->biglock);
693 } else if ((len == 2) && (name[0] == '.') && (name[1] == '.')) { 693 } else if ((len == 2) && (name[0] == '.') && (name[1] == '.')) {
694 D3(printk (KERN_NOTICE "lookup(): up biglock\n")); 694 D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
695 up(&c->fmc->biglock); 695 mutex_unlock(&c->fmc->biglock);
696 if (!(inode = iget(dir->i_sb, d->pino))) { 696 if (!(inode = iget(dir->i_sb, d->pino))) {
697 D(printk("jffs_lookup(): .. iget() ==> NULL\n")); 697 D(printk("jffs_lookup(): .. iget() ==> NULL\n"));
698 goto jffs_lookup_end_no_biglock; 698 goto jffs_lookup_end_no_biglock;
699 } 699 }
700 D3(printk (KERN_NOTICE "lookup(): down biglock\n")); 700 D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
701 down(&c->fmc->biglock); 701 mutex_lock(&c->fmc->biglock);
702 } else if ((f = jffs_find_child(d, name, len))) { 702 } else if ((f = jffs_find_child(d, name, len))) {
703 D3(printk (KERN_NOTICE "lookup(): up biglock\n")); 703 D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
704 up(&c->fmc->biglock); 704 mutex_unlock(&c->fmc->biglock);
705 if (!(inode = iget(dir->i_sb, f->ino))) { 705 if (!(inode = iget(dir->i_sb, f->ino))) {
706 D(printk("jffs_lookup(): iget() ==> NULL\n")); 706 D(printk("jffs_lookup(): iget() ==> NULL\n"));
707 goto jffs_lookup_end_no_biglock; 707 goto jffs_lookup_end_no_biglock;
708 } 708 }
709 D3(printk (KERN_NOTICE "lookup(): down biglock\n")); 709 D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
710 down(&c->fmc->biglock); 710 mutex_lock(&c->fmc->biglock);
711 } else { 711 } else {
712 D3(printk("jffs_lookup(): Couldn't find the file. " 712 D3(printk("jffs_lookup(): Couldn't find the file. "
713 "f = 0x%p, name = \"%s\", d = 0x%p, d->ino = %u\n", 713 "f = 0x%p, name = \"%s\", d = 0x%p, d->ino = %u\n",
@@ -717,13 +717,13 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
717 717
718 d_add(dentry, inode); 718 d_add(dentry, inode);
719 D3(printk (KERN_NOTICE "lookup(): up biglock\n")); 719 D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
720 up(&c->fmc->biglock); 720 mutex_unlock(&c->fmc->biglock);
721 unlock_kernel(); 721 unlock_kernel();
722 return NULL; 722 return NULL;
723 723
724jffs_lookup_end: 724jffs_lookup_end:
725 D3(printk (KERN_NOTICE "lookup(): up biglock\n")); 725 D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
726 up(&c->fmc->biglock); 726 mutex_unlock(&c->fmc->biglock);
727 727
728jffs_lookup_end_no_biglock: 728jffs_lookup_end_no_biglock:
729 unlock_kernel(); 729 unlock_kernel();
@@ -753,7 +753,7 @@ jffs_do_readpage_nolock(struct file *file, struct page *page)
753 ClearPageError(page); 753 ClearPageError(page);
754 754
755 D3(printk (KERN_NOTICE "readpage(): down biglock\n")); 755 D3(printk (KERN_NOTICE "readpage(): down biglock\n"));
756 down(&c->fmc->biglock); 756 mutex_lock(&c->fmc->biglock);
757 757
758 read_len = 0; 758 read_len = 0;
759 result = 0; 759 result = 0;
@@ -782,7 +782,7 @@ jffs_do_readpage_nolock(struct file *file, struct page *page)
782 kunmap(page); 782 kunmap(page);
783 783
784 D3(printk (KERN_NOTICE "readpage(): up biglock\n")); 784 D3(printk (KERN_NOTICE "readpage(): up biglock\n"));
785 up(&c->fmc->biglock); 785 mutex_unlock(&c->fmc->biglock);
786 786
787 if (result) { 787 if (result) {
788 SetPageError(page); 788 SetPageError(page);
@@ -839,7 +839,7 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
839 839
840 c = dir_f->c; 840 c = dir_f->c;
841 D3(printk (KERN_NOTICE "mkdir(): down biglock\n")); 841 D3(printk (KERN_NOTICE "mkdir(): down biglock\n"));
842 down(&c->fmc->biglock); 842 mutex_lock(&c->fmc->biglock);
843 843
844 dir_mode = S_IFDIR | (mode & (S_IRWXUGO|S_ISVTX) 844 dir_mode = S_IFDIR | (mode & (S_IRWXUGO|S_ISVTX)
845 & ~current->fs->umask); 845 & ~current->fs->umask);
@@ -906,7 +906,7 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
906 result = 0; 906 result = 0;
907jffs_mkdir_end: 907jffs_mkdir_end:
908 D3(printk (KERN_NOTICE "mkdir(): up biglock\n")); 908 D3(printk (KERN_NOTICE "mkdir(): up biglock\n"));
909 up(&c->fmc->biglock); 909 mutex_unlock(&c->fmc->biglock);
910 unlock_kernel(); 910 unlock_kernel();
911 return result; 911 return result;
912} /* jffs_mkdir() */ 912} /* jffs_mkdir() */
@@ -921,10 +921,10 @@ jffs_rmdir(struct inode *dir, struct dentry *dentry)
921 D3(printk("***jffs_rmdir()\n")); 921 D3(printk("***jffs_rmdir()\n"));
922 D3(printk (KERN_NOTICE "rmdir(): down biglock\n")); 922 D3(printk (KERN_NOTICE "rmdir(): down biglock\n"));
923 lock_kernel(); 923 lock_kernel();
924 down(&c->fmc->biglock); 924 mutex_lock(&c->fmc->biglock);
925 ret = jffs_remove(dir, dentry, S_IFDIR); 925 ret = jffs_remove(dir, dentry, S_IFDIR);
926 D3(printk (KERN_NOTICE "rmdir(): up biglock\n")); 926 D3(printk (KERN_NOTICE "rmdir(): up biglock\n"));
927 up(&c->fmc->biglock); 927 mutex_unlock(&c->fmc->biglock);
928 unlock_kernel(); 928 unlock_kernel();
929 return ret; 929 return ret;
930} 930}
@@ -940,10 +940,10 @@ jffs_unlink(struct inode *dir, struct dentry *dentry)
940 lock_kernel(); 940 lock_kernel();
941 D3(printk("***jffs_unlink()\n")); 941 D3(printk("***jffs_unlink()\n"));
942 D3(printk (KERN_NOTICE "unlink(): down biglock\n")); 942 D3(printk (KERN_NOTICE "unlink(): down biglock\n"));
943 down(&c->fmc->biglock); 943 mutex_lock(&c->fmc->biglock);
944 ret = jffs_remove(dir, dentry, 0); 944 ret = jffs_remove(dir, dentry, 0);
945 D3(printk (KERN_NOTICE "unlink(): up biglock\n")); 945 D3(printk (KERN_NOTICE "unlink(): up biglock\n"));
946 up(&c->fmc->biglock); 946 mutex_unlock(&c->fmc->biglock);
947 unlock_kernel(); 947 unlock_kernel();
948 return ret; 948 return ret;
949} 949}
@@ -1086,7 +1086,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1086 c = dir_f->c; 1086 c = dir_f->c;
1087 1087
1088 D3(printk (KERN_NOTICE "mknod(): down biglock\n")); 1088 D3(printk (KERN_NOTICE "mknod(): down biglock\n"));
1089 down(&c->fmc->biglock); 1089 mutex_lock(&c->fmc->biglock);
1090 1090
1091 /* Create and initialize a new node. */ 1091 /* Create and initialize a new node. */
1092 if (!(node = jffs_alloc_node())) { 1092 if (!(node = jffs_alloc_node())) {
@@ -1152,7 +1152,7 @@ jffs_mknod_err:
1152 1152
1153jffs_mknod_end: 1153jffs_mknod_end:
1154 D3(printk (KERN_NOTICE "mknod(): up biglock\n")); 1154 D3(printk (KERN_NOTICE "mknod(): up biglock\n"));
1155 up(&c->fmc->biglock); 1155 mutex_unlock(&c->fmc->biglock);
1156 unlock_kernel(); 1156 unlock_kernel();
1157 return result; 1157 return result;
1158} /* jffs_mknod() */ 1158} /* jffs_mknod() */
@@ -1203,7 +1203,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1203 return -ENOMEM; 1203 return -ENOMEM;
1204 } 1204 }
1205 D3(printk (KERN_NOTICE "symlink(): down biglock\n")); 1205 D3(printk (KERN_NOTICE "symlink(): down biglock\n"));
1206 down(&c->fmc->biglock); 1206 mutex_lock(&c->fmc->biglock);
1207 1207
1208 node->data_offset = 0; 1208 node->data_offset = 0;
1209 node->removed_size = 0; 1209 node->removed_size = 0;
@@ -1253,7 +1253,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1253 d_instantiate(dentry, inode); 1253 d_instantiate(dentry, inode);
1254 jffs_symlink_end: 1254 jffs_symlink_end:
1255 D3(printk (KERN_NOTICE "symlink(): up biglock\n")); 1255 D3(printk (KERN_NOTICE "symlink(): up biglock\n"));
1256 up(&c->fmc->biglock); 1256 mutex_unlock(&c->fmc->biglock);
1257 unlock_kernel(); 1257 unlock_kernel();
1258 return err; 1258 return err;
1259} /* jffs_symlink() */ 1259} /* jffs_symlink() */
@@ -1306,7 +1306,7 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
1306 return -ENOMEM; 1306 return -ENOMEM;
1307 } 1307 }
1308 D3(printk (KERN_NOTICE "create(): down biglock\n")); 1308 D3(printk (KERN_NOTICE "create(): down biglock\n"));
1309 down(&c->fmc->biglock); 1309 mutex_lock(&c->fmc->biglock);
1310 1310
1311 node->data_offset = 0; 1311 node->data_offset = 0;
1312 node->removed_size = 0; 1312 node->removed_size = 0;
@@ -1359,7 +1359,7 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
1359 d_instantiate(dentry, inode); 1359 d_instantiate(dentry, inode);
1360 jffs_create_end: 1360 jffs_create_end:
1361 D3(printk (KERN_NOTICE "create(): up biglock\n")); 1361 D3(printk (KERN_NOTICE "create(): up biglock\n"));
1362 up(&c->fmc->biglock); 1362 mutex_unlock(&c->fmc->biglock);
1363 unlock_kernel(); 1363 unlock_kernel();
1364 return err; 1364 return err;
1365} /* jffs_create() */ 1365} /* jffs_create() */
@@ -1423,7 +1423,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
1423 thiscount = min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count); 1423 thiscount = min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count);
1424 1424
1425 D3(printk (KERN_NOTICE "file_write(): down biglock\n")); 1425 D3(printk (KERN_NOTICE "file_write(): down biglock\n"));
1426 down(&c->fmc->biglock); 1426 mutex_lock(&c->fmc->biglock);
1427 1427
1428 /* Urgh. POSIX says we can do short writes if we feel like it. 1428 /* Urgh. POSIX says we can do short writes if we feel like it.
1429 * In practice, we can't. Nothing will cope. So we loop until 1429 * In practice, we can't. Nothing will cope. So we loop until
@@ -1511,7 +1511,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
1511 } 1511 }
1512 out: 1512 out:
1513 D3(printk (KERN_NOTICE "file_write(): up biglock\n")); 1513 D3(printk (KERN_NOTICE "file_write(): up biglock\n"));
1514 up(&c->fmc->biglock); 1514 mutex_unlock(&c->fmc->biglock);
1515 1515
1516 /* Fix things in the real inode. */ 1516 /* Fix things in the real inode. */
1517 if (pos > inode->i_size) { 1517 if (pos > inode->i_size) {
@@ -1567,7 +1567,7 @@ jffs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1567 return -EIO; 1567 return -EIO;
1568 } 1568 }
1569 D3(printk (KERN_NOTICE "ioctl(): down biglock\n")); 1569 D3(printk (KERN_NOTICE "ioctl(): down biglock\n"));
1570 down(&c->fmc->biglock); 1570 mutex_lock(&c->fmc->biglock);
1571 1571
1572 switch (cmd) { 1572 switch (cmd) {
1573 case JFFS_PRINT_HASH: 1573 case JFFS_PRINT_HASH:
@@ -1609,7 +1609,7 @@ jffs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1609 ret = -ENOTTY; 1609 ret = -ENOTTY;
1610 } 1610 }
1611 D3(printk (KERN_NOTICE "ioctl(): up biglock\n")); 1611 D3(printk (KERN_NOTICE "ioctl(): up biglock\n"));
1612 up(&c->fmc->biglock); 1612 mutex_unlock(&c->fmc->biglock);
1613 return ret; 1613 return ret;
1614} /* jffs_ioctl() */ 1614} /* jffs_ioctl() */
1615 1615
@@ -1685,12 +1685,12 @@ jffs_read_inode(struct inode *inode)
1685 } 1685 }
1686 c = (struct jffs_control *)inode->i_sb->s_fs_info; 1686 c = (struct jffs_control *)inode->i_sb->s_fs_info;
1687 D3(printk (KERN_NOTICE "read_inode(): down biglock\n")); 1687 D3(printk (KERN_NOTICE "read_inode(): down biglock\n"));
1688 down(&c->fmc->biglock); 1688 mutex_lock(&c->fmc->biglock);
1689 if (!(f = jffs_find_file(c, inode->i_ino))) { 1689 if (!(f = jffs_find_file(c, inode->i_ino))) {
1690 D(printk("jffs_read_inode(): No such inode (%lu).\n", 1690 D(printk("jffs_read_inode(): No such inode (%lu).\n",
1691 inode->i_ino)); 1691 inode->i_ino));
1692 D3(printk (KERN_NOTICE "read_inode(): up biglock\n")); 1692 D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
1693 up(&c->fmc->biglock); 1693 mutex_unlock(&c->fmc->biglock);
1694 return; 1694 return;
1695 } 1695 }
1696 inode->u.generic_ip = (void *)f; 1696 inode->u.generic_ip = (void *)f;
@@ -1732,7 +1732,7 @@ jffs_read_inode(struct inode *inode)
1732 } 1732 }
1733 1733
1734 D3(printk (KERN_NOTICE "read_inode(): up biglock\n")); 1734 D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
1735 up(&c->fmc->biglock); 1735 mutex_unlock(&c->fmc->biglock);
1736} 1736}
1737 1737
1738 1738
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index ce7b54b0b2b7..0ef207dfaf6f 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -62,7 +62,7 @@
62#include <linux/fs.h> 62#include <linux/fs.h>
63#include <linux/stat.h> 63#include <linux/stat.h>
64#include <linux/pagemap.h> 64#include <linux/pagemap.h>
65#include <asm/semaphore.h> 65#include <linux/mutex.h>
66#include <asm/byteorder.h> 66#include <asm/byteorder.h>
67#include <linux/smp_lock.h> 67#include <linux/smp_lock.h>
68#include <linux/time.h> 68#include <linux/time.h>
@@ -3416,7 +3416,7 @@ jffs_garbage_collect_thread(void *ptr)
3416 D1(printk (KERN_NOTICE "jffs_garbage_collect_thread(): collecting.\n")); 3416 D1(printk (KERN_NOTICE "jffs_garbage_collect_thread(): collecting.\n"));
3417 3417
3418 D3(printk (KERN_NOTICE "g_c_thread(): down biglock\n")); 3418 D3(printk (KERN_NOTICE "g_c_thread(): down biglock\n"));
3419 down(&fmc->biglock); 3419 mutex_lock(&fmc->biglock);
3420 3420
3421 D1(printk("***jffs_garbage_collect_thread(): round #%u, " 3421 D1(printk("***jffs_garbage_collect_thread(): round #%u, "
3422 "fmc->dirty_size = %u\n", i++, fmc->dirty_size)); 3422 "fmc->dirty_size = %u\n", i++, fmc->dirty_size));
@@ -3447,6 +3447,6 @@ jffs_garbage_collect_thread(void *ptr)
3447 3447
3448 gc_end: 3448 gc_end:
3449 D3(printk (KERN_NOTICE "g_c_thread(): up biglock\n")); 3449 D3(printk (KERN_NOTICE "g_c_thread(): up biglock\n"));
3450 up(&fmc->biglock); 3450 mutex_unlock(&fmc->biglock);
3451 } /* for (;;) */ 3451 } /* for (;;) */
3452} /* jffs_garbage_collect_thread() */ 3452} /* jffs_garbage_collect_thread() */
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 6da13b309bd1..7d8ca1aeace2 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -139,7 +139,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
139 fmc->tail = NULL; 139 fmc->tail = NULL;
140 fmc->head_extra = NULL; 140 fmc->head_extra = NULL;
141 fmc->tail_extra = NULL; 141 fmc->tail_extra = NULL;
142 init_MUTEX(&fmc->biglock); 142 mutex_init(&fmc->biglock);
143 return fmc; 143 return fmc;
144} 144}
145 145
diff --git a/fs/jffs/jffs_fm.h b/fs/jffs/jffs_fm.h
index f64151e74122..c794d923df2a 100644
--- a/fs/jffs/jffs_fm.h
+++ b/fs/jffs/jffs_fm.h
@@ -20,10 +20,11 @@
20#ifndef __LINUX_JFFS_FM_H__ 20#ifndef __LINUX_JFFS_FM_H__
21#define __LINUX_JFFS_FM_H__ 21#define __LINUX_JFFS_FM_H__
22 22
23#include <linux/config.h>
23#include <linux/types.h> 24#include <linux/types.h>
24#include <linux/jffs.h> 25#include <linux/jffs.h>
25#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
26#include <linux/config.h> 27#include <linux/mutex.h>
27 28
28/* The alignment between two nodes in the flash memory. */ 29/* The alignment between two nodes in the flash memory. */
29#define JFFS_ALIGN_SIZE 4 30#define JFFS_ALIGN_SIZE 4
@@ -97,7 +98,7 @@ struct jffs_fmcontrol
97 struct jffs_fm *tail; 98 struct jffs_fm *tail;
98 struct jffs_fm *head_extra; 99 struct jffs_fm *head_extra;
99 struct jffs_fm *tail_extra; 100 struct jffs_fm *tail_extra;
100 struct semaphore biglock; 101 struct mutex biglock;
101}; 102};
102 103
103/* Notice the two members head_extra and tail_extra in the jffs_control 104/* Notice the two members head_extra and tail_extra in the jffs_control
diff --git a/fs/libfs.c b/fs/libfs.c
index 71fd08fa4103..4fdeaceb892c 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -7,6 +7,8 @@
7#include <linux/pagemap.h> 7#include <linux/pagemap.h>
8#include <linux/mount.h> 8#include <linux/mount.h>
9#include <linux/vfs.h> 9#include <linux/vfs.h>
10#include <linux/mutex.h>
11
10#include <asm/uaccess.h> 12#include <asm/uaccess.h>
11 13
12int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, 14int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,
@@ -530,7 +532,7 @@ struct simple_attr {
530 char set_buf[24]; 532 char set_buf[24];
531 void *data; 533 void *data;
532 const char *fmt; /* format for read operation */ 534 const char *fmt; /* format for read operation */
533 struct semaphore sem; /* protects access to these buffers */ 535 struct mutex mutex; /* protects access to these buffers */
534}; 536};
535 537
536/* simple_attr_open is called by an actual attribute open file operation 538/* simple_attr_open is called by an actual attribute open file operation
@@ -549,7 +551,7 @@ int simple_attr_open(struct inode *inode, struct file *file,
549 attr->set = set; 551 attr->set = set;
550 attr->data = inode->u.generic_ip; 552 attr->data = inode->u.generic_ip;
551 attr->fmt = fmt; 553 attr->fmt = fmt;
552 init_MUTEX(&attr->sem); 554 mutex_init(&attr->mutex);
553 555
554 file->private_data = attr; 556 file->private_data = attr;
555 557
@@ -575,7 +577,7 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
575 if (!attr->get) 577 if (!attr->get)
576 return -EACCES; 578 return -EACCES;
577 579
578 down(&attr->sem); 580 mutex_lock(&attr->mutex);
579 if (*ppos) /* continued read */ 581 if (*ppos) /* continued read */
580 size = strlen(attr->get_buf); 582 size = strlen(attr->get_buf);
581 else /* first read */ 583 else /* first read */
@@ -584,7 +586,7 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
584 (unsigned long long)attr->get(attr->data)); 586 (unsigned long long)attr->get(attr->data));
585 587
586 ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size); 588 ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
587 up(&attr->sem); 589 mutex_unlock(&attr->mutex);
588 return ret; 590 return ret;
589} 591}
590 592
@@ -602,7 +604,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
602 if (!attr->set) 604 if (!attr->set)
603 return -EACCES; 605 return -EACCES;
604 606
605 down(&attr->sem); 607 mutex_lock(&attr->mutex);
606 ret = -EFAULT; 608 ret = -EFAULT;
607 size = min(sizeof(attr->set_buf) - 1, len); 609 size = min(sizeof(attr->set_buf) - 1, len);
608 if (copy_from_user(attr->set_buf, buf, size)) 610 if (copy_from_user(attr->set_buf, buf, size))
@@ -613,7 +615,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
613 val = simple_strtol(attr->set_buf, NULL, 0); 615 val = simple_strtol(attr->set_buf, NULL, 0);
614 attr->set(attr->data, val); 616 attr->set(attr->data, val);
615out: 617out:
616 up(&attr->sem); 618 mutex_unlock(&attr->mutex);
617 return ret; 619 return ret;
618} 620}
619 621
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index b25bca5bdb57..5b6a4540a05b 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -6,18 +6,6 @@
6 6
7#include "minix.h" 7#include "minix.h"
8 8
9static inline void inc_count(struct inode *inode)
10{
11 inode->i_nlink++;
12 mark_inode_dirty(inode);
13}
14
15static inline void dec_count(struct inode *inode)
16{
17 inode->i_nlink--;
18 mark_inode_dirty(inode);
19}
20
21static int add_nondir(struct dentry *dentry, struct inode *inode) 9static int add_nondir(struct dentry *dentry, struct inode *inode)
22{ 10{
23 int err = minix_add_link(dentry, inode); 11 int err = minix_add_link(dentry, inode);
@@ -25,7 +13,7 @@ static int add_nondir(struct dentry *dentry, struct inode *inode)
25 d_instantiate(dentry, inode); 13 d_instantiate(dentry, inode);
26 return 0; 14 return 0;
27 } 15 }
28 dec_count(inode); 16 inode_dec_link_count(inode);
29 iput(inode); 17 iput(inode);
30 return err; 18 return err;
31} 19}
@@ -125,7 +113,7 @@ out:
125 return err; 113 return err;
126 114
127out_fail: 115out_fail:
128 dec_count(inode); 116 inode_dec_link_count(inode);
129 iput(inode); 117 iput(inode);
130 goto out; 118 goto out;
131} 119}
@@ -139,7 +127,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,
139 return -EMLINK; 127 return -EMLINK;
140 128
141 inode->i_ctime = CURRENT_TIME_SEC; 129 inode->i_ctime = CURRENT_TIME_SEC;
142 inc_count(inode); 130 inode_inc_link_count(inode);
143 atomic_inc(&inode->i_count); 131 atomic_inc(&inode->i_count);
144 return add_nondir(dentry, inode); 132 return add_nondir(dentry, inode);
145} 133}
@@ -152,7 +140,7 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
152 if (dir->i_nlink >= minix_sb(dir->i_sb)->s_link_max) 140 if (dir->i_nlink >= minix_sb(dir->i_sb)->s_link_max)
153 goto out; 141 goto out;
154 142
155 inc_count(dir); 143 inode_inc_link_count(dir);
156 144
157 inode = minix_new_inode(dir, &err); 145 inode = minix_new_inode(dir, &err);
158 if (!inode) 146 if (!inode)
@@ -163,7 +151,7 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
163 inode->i_mode |= S_ISGID; 151 inode->i_mode |= S_ISGID;
164 minix_set_inode(inode, 0); 152 minix_set_inode(inode, 0);
165 153
166 inc_count(inode); 154 inode_inc_link_count(inode);
167 155
168 err = minix_make_empty(inode, dir); 156 err = minix_make_empty(inode, dir);
169 if (err) 157 if (err)
@@ -178,11 +166,11 @@ out:
178 return err; 166 return err;
179 167
180out_fail: 168out_fail:
181 dec_count(inode); 169 inode_dec_link_count(inode);
182 dec_count(inode); 170 inode_dec_link_count(inode);
183 iput(inode); 171 iput(inode);
184out_dir: 172out_dir:
185 dec_count(dir); 173 inode_dec_link_count(dir);
186 goto out; 174 goto out;
187} 175}
188 176
@@ -202,7 +190,7 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry)
202 goto end_unlink; 190 goto end_unlink;
203 191
204 inode->i_ctime = dir->i_ctime; 192 inode->i_ctime = dir->i_ctime;
205 dec_count(inode); 193 inode_dec_link_count(inode);
206end_unlink: 194end_unlink:
207 return err; 195 return err;
208} 196}
@@ -215,8 +203,8 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
215 if (minix_empty_dir(inode)) { 203 if (minix_empty_dir(inode)) {
216 err = minix_unlink(dir, dentry); 204 err = minix_unlink(dir, dentry);
217 if (!err) { 205 if (!err) {
218 dec_count(dir); 206 inode_dec_link_count(dir);
219 dec_count(inode); 207 inode_dec_link_count(inode);
220 } 208 }
221 } 209 }
222 return err; 210 return err;
@@ -257,34 +245,34 @@ static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
257 new_de = minix_find_entry(new_dentry, &new_page); 245 new_de = minix_find_entry(new_dentry, &new_page);
258 if (!new_de) 246 if (!new_de)
259 goto out_dir; 247 goto out_dir;
260 inc_count(old_inode); 248 inode_inc_link_count(old_inode);
261 minix_set_link(new_de, new_page, old_inode); 249 minix_set_link(new_de, new_page, old_inode);
262 new_inode->i_ctime = CURRENT_TIME_SEC; 250 new_inode->i_ctime = CURRENT_TIME_SEC;
263 if (dir_de) 251 if (dir_de)
264 new_inode->i_nlink--; 252 new_inode->i_nlink--;
265 dec_count(new_inode); 253 inode_dec_link_count(new_inode);
266 } else { 254 } else {
267 if (dir_de) { 255 if (dir_de) {
268 err = -EMLINK; 256 err = -EMLINK;
269 if (new_dir->i_nlink >= info->s_link_max) 257 if (new_dir->i_nlink >= info->s_link_max)
270 goto out_dir; 258 goto out_dir;
271 } 259 }
272 inc_count(old_inode); 260 inode_inc_link_count(old_inode);
273 err = minix_add_link(new_dentry, old_inode); 261 err = minix_add_link(new_dentry, old_inode);
274 if (err) { 262 if (err) {
275 dec_count(old_inode); 263 inode_dec_link_count(old_inode);
276 goto out_dir; 264 goto out_dir;
277 } 265 }
278 if (dir_de) 266 if (dir_de)
279 inc_count(new_dir); 267 inode_inc_link_count(new_dir);
280 } 268 }
281 269
282 minix_delete_entry(old_de, old_page); 270 minix_delete_entry(old_de, old_page);
283 dec_count(old_inode); 271 inode_dec_link_count(old_inode);
284 272
285 if (dir_de) { 273 if (dir_de) {
286 minix_set_link(dir_de, dir_page, new_dir); 274 minix_set_link(dir_de, dir_page, new_dir);
287 dec_count(old_dir); 275 inode_dec_link_count(old_dir);
288 } 276 }
289 return 0; 277 return 0;
290 278
diff --git a/fs/namei.c b/fs/namei.c
index 8dc2b038d5d9..c72b940797fc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -104,7 +104,7 @@
104 */ 104 */
105/* 105/*
106 * [Sep 2001 AV] Single-semaphore locking scheme (kudos to David Holland) 106 * [Sep 2001 AV] Single-semaphore locking scheme (kudos to David Holland)
107 * implemented. Let's see if raised priority of ->s_vfs_rename_sem gives 107 * implemented. Let's see if raised priority of ->s_vfs_rename_mutex gives
108 * any extra contention... 108 * any extra contention...
109 */ 109 */
110 110
@@ -1422,7 +1422,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
1422 return NULL; 1422 return NULL;
1423 } 1423 }
1424 1424
1425 down(&p1->d_inode->i_sb->s_vfs_rename_sem); 1425 mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
1426 1426
1427 for (p = p1; p->d_parent != p; p = p->d_parent) { 1427 for (p = p1; p->d_parent != p; p = p->d_parent) {
1428 if (p->d_parent == p2) { 1428 if (p->d_parent == p2) {
@@ -1450,7 +1450,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
1450 mutex_unlock(&p1->d_inode->i_mutex); 1450 mutex_unlock(&p1->d_inode->i_mutex);
1451 if (p1 != p2) { 1451 if (p1 != p2) {
1452 mutex_unlock(&p2->d_inode->i_mutex); 1452 mutex_unlock(&p2->d_inode->i_mutex);
1453 up(&p1->d_inode->i_sb->s_vfs_rename_sem); 1453 mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
1454 } 1454 }
1455} 1455}
1456 1456
@@ -2277,17 +2277,17 @@ asmlinkage long sys_link(const char __user *oldname, const char __user *newname)
2277 * a) we can get into loop creation. Check is done in is_subdir(). 2277 * a) we can get into loop creation. Check is done in is_subdir().
2278 * b) race potential - two innocent renames can create a loop together. 2278 * b) race potential - two innocent renames can create a loop together.
2279 * That's where 4.4 screws up. Current fix: serialization on 2279 * That's where 4.4 screws up. Current fix: serialization on
2280 * sb->s_vfs_rename_sem. We might be more accurate, but that's another 2280 * sb->s_vfs_rename_mutex. We might be more accurate, but that's another
2281 * story. 2281 * story.
2282 * c) we have to lock _three_ objects - parents and victim (if it exists). 2282 * c) we have to lock _three_ objects - parents and victim (if it exists).
2283 * And that - after we got ->i_mutex on parents (until then we don't know 2283 * And that - after we got ->i_mutex on parents (until then we don't know
2284 * whether the target exists). Solution: try to be smart with locking 2284 * whether the target exists). Solution: try to be smart with locking
2285 * order for inodes. We rely on the fact that tree topology may change 2285 * order for inodes. We rely on the fact that tree topology may change
2286 * only under ->s_vfs_rename_sem _and_ that parent of the object we 2286 * only under ->s_vfs_rename_mutex _and_ that parent of the object we
2287 * move will be locked. Thus we can rank directories by the tree 2287 * move will be locked. Thus we can rank directories by the tree
2288 * (ancestors first) and rank all non-directories after them. 2288 * (ancestors first) and rank all non-directories after them.
2289 * That works since everybody except rename does "lock parent, lookup, 2289 * That works since everybody except rename does "lock parent, lookup,
2290 * lock child" and rename is under ->s_vfs_rename_sem. 2290 * lock child" and rename is under ->s_vfs_rename_mutex.
2291 * HOWEVER, it relies on the assumption that any object with ->lookup() 2291 * HOWEVER, it relies on the assumption that any object with ->lookup()
2292 * has no more than 1 dentry. If "hybrid" objects will ever appear, 2292 * has no more than 1 dentry. If "hybrid" objects will ever appear,
2293 * we'd better make sure that there's no link(2) for them. 2293 * we'd better make sure that there's no link(2) for them.
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 973b444d6914..ebdad8f6398f 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -46,7 +46,7 @@ int ncp_make_open(struct inode *inode, int right)
46 NCP_FINFO(inode)->volNumber, 46 NCP_FINFO(inode)->volNumber,
47 NCP_FINFO(inode)->dirEntNum); 47 NCP_FINFO(inode)->dirEntNum);
48 error = -EACCES; 48 error = -EACCES;
49 down(&NCP_FINFO(inode)->open_sem); 49 mutex_lock(&NCP_FINFO(inode)->open_mutex);
50 if (!atomic_read(&NCP_FINFO(inode)->opened)) { 50 if (!atomic_read(&NCP_FINFO(inode)->opened)) {
51 struct ncp_entry_info finfo; 51 struct ncp_entry_info finfo;
52 int result; 52 int result;
@@ -93,7 +93,7 @@ int ncp_make_open(struct inode *inode, int right)
93 } 93 }
94 94
95out_unlock: 95out_unlock:
96 up(&NCP_FINFO(inode)->open_sem); 96 mutex_unlock(&NCP_FINFO(inode)->open_mutex);
97out: 97out:
98 return error; 98 return error;
99} 99}
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index d277a58bd128..0b521d3d97ce 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -63,7 +63,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
63 63
64 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 64 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
65 SLAB_CTOR_CONSTRUCTOR) { 65 SLAB_CTOR_CONSTRUCTOR) {
66 init_MUTEX(&ei->open_sem); 66 mutex_init(&ei->open_mutex);
67 inode_init_once(&ei->vfs_inode); 67 inode_init_once(&ei->vfs_inode);
68 } 68 }
69} 69}
@@ -520,7 +520,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
520 } 520 }
521 521
522/* server->lock = 0; */ 522/* server->lock = 0; */
523 init_MUTEX(&server->sem); 523 mutex_init(&server->mutex);
524 server->packet = NULL; 524 server->packet = NULL;
525/* server->buffer_size = 0; */ 525/* server->buffer_size = 0; */
526/* server->conn_status = 0; */ 526/* server->conn_status = 0; */
@@ -557,7 +557,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
557 server->dentry_ttl = 0; /* no caching */ 557 server->dentry_ttl = 0; /* no caching */
558 558
559 INIT_LIST_HEAD(&server->tx.requests); 559 INIT_LIST_HEAD(&server->tx.requests);
560 init_MUTEX(&server->rcv.creq_sem); 560 mutex_init(&server->rcv.creq_mutex);
561 server->tx.creq = NULL; 561 server->tx.creq = NULL;
562 server->rcv.creq = NULL; 562 server->rcv.creq = NULL;
563 server->data_ready = sock->sk->sk_data_ready; 563 server->data_ready = sock->sk->sk_data_ready;
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index c755e1848a42..d9ebf6439f59 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -291,7 +291,7 @@ ncp_make_closed(struct inode *inode)
291 int err; 291 int err;
292 292
293 err = 0; 293 err = 0;
294 down(&NCP_FINFO(inode)->open_sem); 294 mutex_lock(&NCP_FINFO(inode)->open_mutex);
295 if (atomic_read(&NCP_FINFO(inode)->opened) == 1) { 295 if (atomic_read(&NCP_FINFO(inode)->opened) == 1) {
296 atomic_set(&NCP_FINFO(inode)->opened, 0); 296 atomic_set(&NCP_FINFO(inode)->opened, 0);
297 err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle); 297 err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle);
@@ -301,7 +301,7 @@ ncp_make_closed(struct inode *inode)
301 NCP_FINFO(inode)->volNumber, 301 NCP_FINFO(inode)->volNumber,
302 NCP_FINFO(inode)->dirEntNum, err); 302 NCP_FINFO(inode)->dirEntNum, err);
303 } 303 }
304 up(&NCP_FINFO(inode)->open_sem); 304 mutex_unlock(&NCP_FINFO(inode)->open_mutex);
305 return err; 305 return err;
306} 306}
307 307
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 6593a5ca88ba..8783eb7ec641 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -171,9 +171,9 @@ static inline void __ncp_abort_request(struct ncp_server *server, struct ncp_req
171 171
172static inline void ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, int err) 172static inline void ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, int err)
173{ 173{
174 down(&server->rcv.creq_sem); 174 mutex_lock(&server->rcv.creq_mutex);
175 __ncp_abort_request(server, req, err); 175 __ncp_abort_request(server, req, err);
176 up(&server->rcv.creq_sem); 176 mutex_unlock(&server->rcv.creq_mutex);
177} 177}
178 178
179static inline void __ncptcp_abort(struct ncp_server *server) 179static inline void __ncptcp_abort(struct ncp_server *server)
@@ -303,20 +303,20 @@ static inline void __ncp_start_request(struct ncp_server *server, struct ncp_req
303 303
304static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *req) 304static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *req)
305{ 305{
306 down(&server->rcv.creq_sem); 306 mutex_lock(&server->rcv.creq_mutex);
307 if (!ncp_conn_valid(server)) { 307 if (!ncp_conn_valid(server)) {
308 up(&server->rcv.creq_sem); 308 mutex_unlock(&server->rcv.creq_mutex);
309 printk(KERN_ERR "ncpfs: tcp: Server died\n"); 309 printk(KERN_ERR "ncpfs: tcp: Server died\n");
310 return -EIO; 310 return -EIO;
311 } 311 }
312 if (server->tx.creq || server->rcv.creq) { 312 if (server->tx.creq || server->rcv.creq) {
313 req->status = RQ_QUEUED; 313 req->status = RQ_QUEUED;
314 list_add_tail(&req->req, &server->tx.requests); 314 list_add_tail(&req->req, &server->tx.requests);
315 up(&server->rcv.creq_sem); 315 mutex_unlock(&server->rcv.creq_mutex);
316 return 0; 316 return 0;
317 } 317 }
318 __ncp_start_request(server, req); 318 __ncp_start_request(server, req);
319 up(&server->rcv.creq_sem); 319 mutex_unlock(&server->rcv.creq_mutex);
320 return 0; 320 return 0;
321} 321}
322 322
@@ -400,7 +400,7 @@ void ncpdgram_rcv_proc(void *s)
400 info_server(server, 0, server->unexpected_packet.data, result); 400 info_server(server, 0, server->unexpected_packet.data, result);
401 continue; 401 continue;
402 } 402 }
403 down(&server->rcv.creq_sem); 403 mutex_lock(&server->rcv.creq_mutex);
404 req = server->rcv.creq; 404 req = server->rcv.creq;
405 if (req && (req->tx_type == NCP_ALLOC_SLOT_REQUEST || (server->sequence == reply.sequence && 405 if (req && (req->tx_type == NCP_ALLOC_SLOT_REQUEST || (server->sequence == reply.sequence &&
406 server->connection == get_conn_number(&reply)))) { 406 server->connection == get_conn_number(&reply)))) {
@@ -430,11 +430,11 @@ void ncpdgram_rcv_proc(void *s)
430 server->rcv.creq = NULL; 430 server->rcv.creq = NULL;
431 ncp_finish_request(req, result); 431 ncp_finish_request(req, result);
432 __ncp_next_request(server); 432 __ncp_next_request(server);
433 up(&server->rcv.creq_sem); 433 mutex_unlock(&server->rcv.creq_mutex);
434 continue; 434 continue;
435 } 435 }
436 } 436 }
437 up(&server->rcv.creq_sem); 437 mutex_unlock(&server->rcv.creq_mutex);
438 } 438 }
439drop:; 439drop:;
440 _recv(sock, &reply, sizeof(reply), MSG_DONTWAIT); 440 _recv(sock, &reply, sizeof(reply), MSG_DONTWAIT);
@@ -472,9 +472,9 @@ static void __ncpdgram_timeout_proc(struct ncp_server *server)
472void ncpdgram_timeout_proc(void *s) 472void ncpdgram_timeout_proc(void *s)
473{ 473{
474 struct ncp_server *server = s; 474 struct ncp_server *server = s;
475 down(&server->rcv.creq_sem); 475 mutex_lock(&server->rcv.creq_mutex);
476 __ncpdgram_timeout_proc(server); 476 __ncpdgram_timeout_proc(server);
477 up(&server->rcv.creq_sem); 477 mutex_unlock(&server->rcv.creq_mutex);
478} 478}
479 479
480static inline void ncp_init_req(struct ncp_request_reply* req) 480static inline void ncp_init_req(struct ncp_request_reply* req)
@@ -657,18 +657,18 @@ void ncp_tcp_rcv_proc(void *s)
657{ 657{
658 struct ncp_server *server = s; 658 struct ncp_server *server = s;
659 659
660 down(&server->rcv.creq_sem); 660 mutex_lock(&server->rcv.creq_mutex);
661 __ncptcp_rcv_proc(server); 661 __ncptcp_rcv_proc(server);
662 up(&server->rcv.creq_sem); 662 mutex_unlock(&server->rcv.creq_mutex);
663} 663}
664 664
665void ncp_tcp_tx_proc(void *s) 665void ncp_tcp_tx_proc(void *s)
666{ 666{
667 struct ncp_server *server = s; 667 struct ncp_server *server = s;
668 668
669 down(&server->rcv.creq_sem); 669 mutex_lock(&server->rcv.creq_mutex);
670 __ncptcp_try_send(server); 670 __ncptcp_try_send(server);
671 up(&server->rcv.creq_sem); 671 mutex_unlock(&server->rcv.creq_mutex);
672} 672}
673 673
674static int do_ncp_rpc_call(struct ncp_server *server, int size, 674static int do_ncp_rpc_call(struct ncp_server *server, int size,
@@ -833,7 +833,7 @@ int ncp_disconnect(struct ncp_server *server)
833 833
834void ncp_lock_server(struct ncp_server *server) 834void ncp_lock_server(struct ncp_server *server)
835{ 835{
836 down(&server->sem); 836 mutex_lock(&server->mutex);
837 if (server->lock) 837 if (server->lock)
838 printk(KERN_WARNING "ncp_lock_server: was locked!\n"); 838 printk(KERN_WARNING "ncp_lock_server: was locked!\n");
839 server->lock = 1; 839 server->lock = 1;
@@ -846,5 +846,5 @@ void ncp_unlock_server(struct ncp_server *server)
846 return; 846 return;
847 } 847 }
848 server->lock = 0; 848 server->lock = 0;
849 up(&server->sem); 849 mutex_unlock(&server->mutex);
850} 850}
diff --git a/fs/open.c b/fs/open.c
index 70e0230d8e77..1091dadd6c38 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -973,7 +973,7 @@ repeat:
973 fdt = files_fdtable(files); 973 fdt = files_fdtable(files);
974 fd = find_next_zero_bit(fdt->open_fds->fds_bits, 974 fd = find_next_zero_bit(fdt->open_fds->fds_bits,
975 fdt->max_fdset, 975 fdt->max_fdset,
976 fdt->next_fd); 976 files->next_fd);
977 977
978 /* 978 /*
979 * N.B. For clone tasks sharing a files structure, this test 979 * N.B. For clone tasks sharing a files structure, this test
@@ -998,7 +998,7 @@ repeat:
998 998
999 FD_SET(fd, fdt->open_fds); 999 FD_SET(fd, fdt->open_fds);
1000 FD_CLR(fd, fdt->close_on_exec); 1000 FD_CLR(fd, fdt->close_on_exec);
1001 fdt->next_fd = fd + 1; 1001 files->next_fd = fd + 1;
1002#if 1 1002#if 1
1003 /* Sanity check */ 1003 /* Sanity check */
1004 if (fdt->fd[fd] != NULL) { 1004 if (fdt->fd[fd] != NULL) {
@@ -1019,8 +1019,8 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd)
1019{ 1019{
1020 struct fdtable *fdt = files_fdtable(files); 1020 struct fdtable *fdt = files_fdtable(files);
1021 __FD_CLR(fd, fdt->open_fds); 1021 __FD_CLR(fd, fdt->open_fds);
1022 if (fd < fdt->next_fd) 1022 if (fd < files->next_fd)
1023 fdt->next_fd = fd; 1023 files->next_fd = fd;
1024} 1024}
1025 1025
1026void fastcall put_unused_fd(unsigned int fd) 1026void fastcall put_unused_fd(unsigned int fd)
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 1d24fead51a6..826c131994c3 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -312,7 +312,7 @@ static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
312 case BLK_HDR: 312 case BLK_HDR:
313 info->state = BLK_LIST; 313 info->state = BLK_LIST;
314 (*pos)++; 314 (*pos)++;
315 break; 315 /*fallthrough*/
316 case BLK_LIST: 316 case BLK_LIST:
317 if (get_blkdev_info(info->blkdev,&idummy,&ndummy)) { 317 if (get_blkdev_info(info->blkdev,&idummy,&ndummy)) {
318 /* 318 /*
diff --git a/fs/qnx4/file.c b/fs/qnx4/file.c
index b471315e24ef..c33963fded9e 100644
--- a/fs/qnx4/file.c
+++ b/fs/qnx4/file.c
@@ -12,10 +12,7 @@
12 * 27-06-1998 by Frank Denis : file overwriting. 12 * 27-06-1998 by Frank Denis : file overwriting.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/types.h>
17#include <linux/fs.h> 15#include <linux/fs.h>
18#include <linux/time.h>
19#include <linux/qnx4_fs.h> 16#include <linux/qnx4_fs.h>
20 17
21/* 18/*
diff --git a/fs/quota.c b/fs/quota.c
index ba9e0bf32f67..d6a2be826e29 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -170,10 +170,10 @@ static void quota_sync_sb(struct super_block *sb, int type)
170 170
171 /* Now when everything is written we can discard the pagecache so 171 /* Now when everything is written we can discard the pagecache so
172 * that userspace sees the changes. We need i_mutex and so we could 172 * that userspace sees the changes. We need i_mutex and so we could
173 * not do it inside dqonoff_sem. Moreover we need to be carefull 173 * not do it inside dqonoff_mutex. Moreover we need to be carefull
174 * about races with quotaoff() (that is the reason why we have own 174 * about races with quotaoff() (that is the reason why we have own
175 * reference to inode). */ 175 * reference to inode). */
176 down(&sb_dqopt(sb)->dqonoff_sem); 176 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
177 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 177 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
178 discard[cnt] = NULL; 178 discard[cnt] = NULL;
179 if (type != -1 && cnt != type) 179 if (type != -1 && cnt != type)
@@ -182,7 +182,7 @@ static void quota_sync_sb(struct super_block *sb, int type)
182 continue; 182 continue;
183 discard[cnt] = igrab(sb_dqopt(sb)->files[cnt]); 183 discard[cnt] = igrab(sb_dqopt(sb)->files[cnt]);
184 } 184 }
185 up(&sb_dqopt(sb)->dqonoff_sem); 185 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
186 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 186 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
187 if (discard[cnt]) { 187 if (discard[cnt]) {
188 mutex_lock(&discard[cnt]->i_mutex); 188 mutex_lock(&discard[cnt]->i_mutex);
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index b4199ec3ece4..c519a583e681 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -394,7 +394,7 @@ static int v2_write_dquot(struct dquot *dquot)
394 ssize_t ret; 394 ssize_t ret;
395 struct v2_disk_dqblk ddquot, empty; 395 struct v2_disk_dqblk ddquot, empty;
396 396
397 /* dq_off is guarded by dqio_sem */ 397 /* dq_off is guarded by dqio_mutex */
398 if (!dquot->dq_off) 398 if (!dquot->dq_off)
399 if ((ret = dq_insert_tree(dquot)) < 0) { 399 if ((ret = dq_insert_tree(dquot)) < 0) {
400 printk(KERN_ERR "VFS: Error %zd occurred while creating quota.\n", ret); 400 printk(KERN_ERR "VFS: Error %zd occurred while creating quota.\n", ret);
diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c
index 2115383dcc8d..6ada2095b9ac 100644
--- a/fs/ramfs/file-mmu.c
+++ b/fs/ramfs/file-mmu.c
@@ -24,18 +24,7 @@
24 * caches is sufficient. 24 * caches is sufficient.
25 */ 25 */
26 26
27#include <linux/module.h>
28#include <linux/fs.h> 27#include <linux/fs.h>
29#include <linux/pagemap.h>
30#include <linux/highmem.h>
31#include <linux/init.h>
32#include <linux/string.h>
33#include <linux/smp_lock.h>
34#include <linux/backing-dev.h>
35#include <linux/ramfs.h>
36
37#include <asm/uaccess.h>
38#include "internal.h"
39 28
40struct address_space_operations ramfs_aops = { 29struct address_space_operations ramfs_aops = {
41 .readpage = simple_readpage, 30 .readpage = simple_readpage,
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 7c40570b71dc..555b9ac04c25 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -37,7 +37,7 @@ int seq_open(struct file *file, struct seq_operations *op)
37 file->private_data = p; 37 file->private_data = p;
38 } 38 }
39 memset(p, 0, sizeof(*p)); 39 memset(p, 0, sizeof(*p));
40 sema_init(&p->sem, 1); 40 mutex_init(&p->lock);
41 p->op = op; 41 p->op = op;
42 42
43 /* 43 /*
@@ -71,7 +71,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
71 void *p; 71 void *p;
72 int err = 0; 72 int err = 0;
73 73
74 down(&m->sem); 74 mutex_lock(&m->lock);
75 /* 75 /*
76 * seq_file->op->..m_start/m_stop/m_next may do special actions 76 * seq_file->op->..m_start/m_stop/m_next may do special actions
77 * or optimisations based on the file->f_version, so we want to 77 * or optimisations based on the file->f_version, so we want to
@@ -164,7 +164,7 @@ Done:
164 else 164 else
165 *ppos += copied; 165 *ppos += copied;
166 file->f_version = m->version; 166 file->f_version = m->version;
167 up(&m->sem); 167 mutex_unlock(&m->lock);
168 return copied; 168 return copied;
169Enomem: 169Enomem:
170 err = -ENOMEM; 170 err = -ENOMEM;
@@ -237,7 +237,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
237 struct seq_file *m = (struct seq_file *)file->private_data; 237 struct seq_file *m = (struct seq_file *)file->private_data;
238 long long retval = -EINVAL; 238 long long retval = -EINVAL;
239 239
240 down(&m->sem); 240 mutex_lock(&m->lock);
241 m->version = file->f_version; 241 m->version = file->f_version;
242 switch (origin) { 242 switch (origin) {
243 case 1: 243 case 1:
@@ -260,7 +260,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
260 } 260 }
261 } 261 }
262 } 262 }
263 up(&m->sem); 263 mutex_unlock(&m->lock);
264 file->f_version = m->version; 264 file->f_version = m->version;
265 return retval; 265 return retval;
266} 266}
diff --git a/fs/super.c b/fs/super.c
index e20b5580afd5..425861cb1caa 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -76,9 +76,9 @@ static struct super_block *alloc_super(void)
76 down_write(&s->s_umount); 76 down_write(&s->s_umount);
77 s->s_count = S_BIAS; 77 s->s_count = S_BIAS;
78 atomic_set(&s->s_active, 1); 78 atomic_set(&s->s_active, 1);
79 sema_init(&s->s_vfs_rename_sem,1); 79 mutex_init(&s->s_vfs_rename_mutex);
80 sema_init(&s->s_dquot.dqio_sem, 1); 80 mutex_init(&s->s_dquot.dqio_mutex);
81 sema_init(&s->s_dquot.dqonoff_sem, 1); 81 mutex_init(&s->s_dquot.dqonoff_mutex);
82 init_rwsem(&s->s_dquot.dqptr_sem); 82 init_rwsem(&s->s_dquot.dqptr_sem);
83 init_waitqueue_head(&s->s_wait_unfrozen); 83 init_waitqueue_head(&s->s_wait_unfrozen);
84 s->s_maxbytes = MAX_NON_LFS; 84 s->s_maxbytes = MAX_NON_LFS;
@@ -693,9 +693,9 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
693 * will protect the lockfs code from trying to start a snapshot 693 * will protect the lockfs code from trying to start a snapshot
694 * while we are mounting 694 * while we are mounting
695 */ 695 */
696 down(&bdev->bd_mount_sem); 696 mutex_lock(&bdev->bd_mount_mutex);
697 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev); 697 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
698 up(&bdev->bd_mount_sem); 698 mutex_unlock(&bdev->bd_mount_mutex);
699 if (IS_ERR(s)) 699 if (IS_ERR(s))
700 goto out; 700 goto out;
701 701
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index 7f0e4b53085e..b8a73f716fbe 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -16,18 +16,6 @@
16#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
17#include "sysv.h" 17#include "sysv.h"
18 18
19static inline void inc_count(struct inode *inode)
20{
21 inode->i_nlink++;
22 mark_inode_dirty(inode);
23}
24
25static inline void dec_count(struct inode *inode)
26{
27 inode->i_nlink--;
28 mark_inode_dirty(inode);
29}
30
31static int add_nondir(struct dentry *dentry, struct inode *inode) 19static int add_nondir(struct dentry *dentry, struct inode *inode)
32{ 20{
33 int err = sysv_add_link(dentry, inode); 21 int err = sysv_add_link(dentry, inode);
@@ -35,7 +23,7 @@ static int add_nondir(struct dentry *dentry, struct inode *inode)
35 d_instantiate(dentry, inode); 23 d_instantiate(dentry, inode);
36 return 0; 24 return 0;
37 } 25 }
38 dec_count(inode); 26 inode_dec_link_count(inode);
39 iput(inode); 27 iput(inode);
40 return err; 28 return err;
41} 29}
@@ -124,7 +112,7 @@ out:
124 return err; 112 return err;
125 113
126out_fail: 114out_fail:
127 dec_count(inode); 115 inode_dec_link_count(inode);
128 iput(inode); 116 iput(inode);
129 goto out; 117 goto out;
130} 118}
@@ -138,7 +126,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir,
138 return -EMLINK; 126 return -EMLINK;
139 127
140 inode->i_ctime = CURRENT_TIME_SEC; 128 inode->i_ctime = CURRENT_TIME_SEC;
141 inc_count(inode); 129 inode_inc_link_count(inode);
142 atomic_inc(&inode->i_count); 130 atomic_inc(&inode->i_count);
143 131
144 return add_nondir(dentry, inode); 132 return add_nondir(dentry, inode);
@@ -151,7 +139,7 @@ static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode)
151 139
152 if (dir->i_nlink >= SYSV_SB(dir->i_sb)->s_link_max) 140 if (dir->i_nlink >= SYSV_SB(dir->i_sb)->s_link_max)
153 goto out; 141 goto out;
154 inc_count(dir); 142 inode_inc_link_count(dir);
155 143
156 inode = sysv_new_inode(dir, S_IFDIR|mode); 144 inode = sysv_new_inode(dir, S_IFDIR|mode);
157 err = PTR_ERR(inode); 145 err = PTR_ERR(inode);
@@ -160,7 +148,7 @@ static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode)
160 148
161 sysv_set_inode(inode, 0); 149 sysv_set_inode(inode, 0);
162 150
163 inc_count(inode); 151 inode_inc_link_count(inode);
164 152
165 err = sysv_make_empty(inode, dir); 153 err = sysv_make_empty(inode, dir);
166 if (err) 154 if (err)
@@ -175,11 +163,11 @@ out:
175 return err; 163 return err;
176 164
177out_fail: 165out_fail:
178 dec_count(inode); 166 inode_dec_link_count(inode);
179 dec_count(inode); 167 inode_dec_link_count(inode);
180 iput(inode); 168 iput(inode);
181out_dir: 169out_dir:
182 dec_count(dir); 170 inode_dec_link_count(dir);
183 goto out; 171 goto out;
184} 172}
185 173
@@ -199,7 +187,7 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry)
199 goto out; 187 goto out;
200 188
201 inode->i_ctime = dir->i_ctime; 189 inode->i_ctime = dir->i_ctime;
202 dec_count(inode); 190 inode_dec_link_count(inode);
203out: 191out:
204 return err; 192 return err;
205} 193}
@@ -213,8 +201,8 @@ static int sysv_rmdir(struct inode * dir, struct dentry * dentry)
213 err = sysv_unlink(dir, dentry); 201 err = sysv_unlink(dir, dentry);
214 if (!err) { 202 if (!err) {
215 inode->i_size = 0; 203 inode->i_size = 0;
216 dec_count(inode); 204 inode_dec_link_count(inode);
217 dec_count(dir); 205 inode_dec_link_count(dir);
218 } 206 }
219 } 207 }
220 return err; 208 return err;
@@ -258,34 +246,34 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
258 new_de = sysv_find_entry(new_dentry, &new_page); 246 new_de = sysv_find_entry(new_dentry, &new_page);
259 if (!new_de) 247 if (!new_de)
260 goto out_dir; 248 goto out_dir;
261 inc_count(old_inode); 249 inode_inc_link_count(old_inode);
262 sysv_set_link(new_de, new_page, old_inode); 250 sysv_set_link(new_de, new_page, old_inode);
263 new_inode->i_ctime = CURRENT_TIME_SEC; 251 new_inode->i_ctime = CURRENT_TIME_SEC;
264 if (dir_de) 252 if (dir_de)
265 new_inode->i_nlink--; 253 new_inode->i_nlink--;
266 dec_count(new_inode); 254 inode_dec_link_count(new_inode);
267 } else { 255 } else {
268 if (dir_de) { 256 if (dir_de) {
269 err = -EMLINK; 257 err = -EMLINK;
270 if (new_dir->i_nlink >= SYSV_SB(new_dir->i_sb)->s_link_max) 258 if (new_dir->i_nlink >= SYSV_SB(new_dir->i_sb)->s_link_max)
271 goto out_dir; 259 goto out_dir;
272 } 260 }
273 inc_count(old_inode); 261 inode_inc_link_count(old_inode);
274 err = sysv_add_link(new_dentry, old_inode); 262 err = sysv_add_link(new_dentry, old_inode);
275 if (err) { 263 if (err) {
276 dec_count(old_inode); 264 inode_dec_link_count(old_inode);
277 goto out_dir; 265 goto out_dir;
278 } 266 }
279 if (dir_de) 267 if (dir_de)
280 inc_count(new_dir); 268 inode_inc_link_count(new_dir);
281 } 269 }
282 270
283 sysv_delete_entry(old_de, old_page); 271 sysv_delete_entry(old_de, old_page);
284 dec_count(old_inode); 272 inode_dec_link_count(old_inode);
285 273
286 if (dir_de) { 274 if (dir_de) {
287 sysv_set_link(dir_de, dir_page, new_dir); 275 sysv_set_link(dir_de, dir_page, new_dir);
288 dec_count(old_dir); 276 inode_dec_link_count(old_dir);
289 } 277 }
290 return 0; 278 return 0;
291 279
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 201049ac8a96..ea521f846d97 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -152,7 +152,7 @@ static void udf_bitmap_free_blocks(struct super_block * sb,
152 int bitmap_nr; 152 int bitmap_nr;
153 unsigned long overflow; 153 unsigned long overflow;
154 154
155 down(&sbi->s_alloc_sem); 155 mutex_lock(&sbi->s_alloc_mutex);
156 if (bloc.logicalBlockNum < 0 || 156 if (bloc.logicalBlockNum < 0 ||
157 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) 157 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
158 { 158 {
@@ -211,7 +211,7 @@ error_return:
211 sb->s_dirt = 1; 211 sb->s_dirt = 1;
212 if (UDF_SB_LVIDBH(sb)) 212 if (UDF_SB_LVIDBH(sb))
213 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 213 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
214 up(&sbi->s_alloc_sem); 214 mutex_unlock(&sbi->s_alloc_mutex);
215 return; 215 return;
216} 216}
217 217
@@ -226,7 +226,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block * sb,
226 int nr_groups, bitmap_nr; 226 int nr_groups, bitmap_nr;
227 struct buffer_head *bh; 227 struct buffer_head *bh;
228 228
229 down(&sbi->s_alloc_sem); 229 mutex_lock(&sbi->s_alloc_mutex);
230 if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition)) 230 if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
231 goto out; 231 goto out;
232 232
@@ -275,7 +275,7 @@ out:
275 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 275 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
276 } 276 }
277 sb->s_dirt = 1; 277 sb->s_dirt = 1;
278 up(&sbi->s_alloc_sem); 278 mutex_unlock(&sbi->s_alloc_mutex);
279 return alloc_count; 279 return alloc_count;
280} 280}
281 281
@@ -291,7 +291,7 @@ static int udf_bitmap_new_block(struct super_block * sb,
291 int newblock = 0; 291 int newblock = 0;
292 292
293 *err = -ENOSPC; 293 *err = -ENOSPC;
294 down(&sbi->s_alloc_sem); 294 mutex_lock(&sbi->s_alloc_mutex);
295 295
296repeat: 296repeat:
297 if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) 297 if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
@@ -364,7 +364,7 @@ repeat:
364 } 364 }
365 if (i >= (nr_groups*2)) 365 if (i >= (nr_groups*2))
366 { 366 {
367 up(&sbi->s_alloc_sem); 367 mutex_unlock(&sbi->s_alloc_mutex);
368 return newblock; 368 return newblock;
369 } 369 }
370 if (bit < sb->s_blocksize << 3) 370 if (bit < sb->s_blocksize << 3)
@@ -373,7 +373,7 @@ repeat:
373 bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3); 373 bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3);
374 if (bit >= sb->s_blocksize << 3) 374 if (bit >= sb->s_blocksize << 3)
375 { 375 {
376 up(&sbi->s_alloc_sem); 376 mutex_unlock(&sbi->s_alloc_mutex);
377 return 0; 377 return 0;
378 } 378 }
379 379
@@ -387,7 +387,7 @@ got_block:
387 */ 387 */
388 if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) 388 if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
389 { 389 {
390 up(&sbi->s_alloc_sem); 390 mutex_unlock(&sbi->s_alloc_mutex);
391 *err = -EDQUOT; 391 *err = -EDQUOT;
392 return 0; 392 return 0;
393 } 393 }
@@ -410,13 +410,13 @@ got_block:
410 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 410 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
411 } 411 }
412 sb->s_dirt = 1; 412 sb->s_dirt = 1;
413 up(&sbi->s_alloc_sem); 413 mutex_unlock(&sbi->s_alloc_mutex);
414 *err = 0; 414 *err = 0;
415 return newblock; 415 return newblock;
416 416
417error_return: 417error_return:
418 *err = -EIO; 418 *err = -EIO;
419 up(&sbi->s_alloc_sem); 419 mutex_unlock(&sbi->s_alloc_mutex);
420 return 0; 420 return 0;
421} 421}
422 422
@@ -433,7 +433,7 @@ static void udf_table_free_blocks(struct super_block * sb,
433 int8_t etype; 433 int8_t etype;
434 int i; 434 int i;
435 435
436 down(&sbi->s_alloc_sem); 436 mutex_lock(&sbi->s_alloc_mutex);
437 if (bloc.logicalBlockNum < 0 || 437 if (bloc.logicalBlockNum < 0 ||
438 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) 438 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
439 { 439 {
@@ -666,7 +666,7 @@ static void udf_table_free_blocks(struct super_block * sb,
666 666
667error_return: 667error_return:
668 sb->s_dirt = 1; 668 sb->s_dirt = 1;
669 up(&sbi->s_alloc_sem); 669 mutex_unlock(&sbi->s_alloc_mutex);
670 return; 670 return;
671} 671}
672 672
@@ -692,7 +692,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
692 else 692 else
693 return 0; 693 return 0;
694 694
695 down(&sbi->s_alloc_sem); 695 mutex_lock(&sbi->s_alloc_mutex);
696 extoffset = sizeof(struct unallocSpaceEntry); 696 extoffset = sizeof(struct unallocSpaceEntry);
697 bloc = UDF_I_LOCATION(table); 697 bloc = UDF_I_LOCATION(table);
698 698
@@ -736,7 +736,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
736 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 736 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
737 sb->s_dirt = 1; 737 sb->s_dirt = 1;
738 } 738 }
739 up(&sbi->s_alloc_sem); 739 mutex_unlock(&sbi->s_alloc_mutex);
740 return alloc_count; 740 return alloc_count;
741} 741}
742 742
@@ -761,7 +761,7 @@ static int udf_table_new_block(struct super_block * sb,
761 else 761 else
762 return newblock; 762 return newblock;
763 763
764 down(&sbi->s_alloc_sem); 764 mutex_lock(&sbi->s_alloc_mutex);
765 if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) 765 if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
766 goal = 0; 766 goal = 0;
767 767
@@ -811,7 +811,7 @@ static int udf_table_new_block(struct super_block * sb,
811 if (spread == 0xFFFFFFFF) 811 if (spread == 0xFFFFFFFF)
812 { 812 {
813 udf_release_data(goal_bh); 813 udf_release_data(goal_bh);
814 up(&sbi->s_alloc_sem); 814 mutex_unlock(&sbi->s_alloc_mutex);
815 return 0; 815 return 0;
816 } 816 }
817 817
@@ -827,7 +827,7 @@ static int udf_table_new_block(struct super_block * sb,
827 if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) 827 if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
828 { 828 {
829 udf_release_data(goal_bh); 829 udf_release_data(goal_bh);
830 up(&sbi->s_alloc_sem); 830 mutex_unlock(&sbi->s_alloc_mutex);
831 *err = -EDQUOT; 831 *err = -EDQUOT;
832 return 0; 832 return 0;
833 } 833 }
@@ -846,7 +846,7 @@ static int udf_table_new_block(struct super_block * sb,
846 } 846 }
847 847
848 sb->s_dirt = 1; 848 sb->s_dirt = 1;
849 up(&sbi->s_alloc_sem); 849 mutex_unlock(&sbi->s_alloc_mutex);
850 *err = 0; 850 *err = 0;
851 return newblock; 851 return newblock;
852} 852}
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index c9b707b470ca..3873c672cb4c 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -42,7 +42,7 @@ void udf_free_inode(struct inode * inode)
42 42
43 clear_inode(inode); 43 clear_inode(inode);
44 44
45 down(&sbi->s_alloc_sem); 45 mutex_lock(&sbi->s_alloc_mutex);
46 if (sbi->s_lvidbh) { 46 if (sbi->s_lvidbh) {
47 if (S_ISDIR(inode->i_mode)) 47 if (S_ISDIR(inode->i_mode))
48 UDF_SB_LVIDIU(sb)->numDirs = 48 UDF_SB_LVIDIU(sb)->numDirs =
@@ -53,7 +53,7 @@ void udf_free_inode(struct inode * inode)
53 53
54 mark_buffer_dirty(sbi->s_lvidbh); 54 mark_buffer_dirty(sbi->s_lvidbh);
55 } 55 }
56 up(&sbi->s_alloc_sem); 56 mutex_unlock(&sbi->s_alloc_mutex);
57 57
58 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1); 58 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1);
59} 59}
@@ -83,7 +83,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
83 return NULL; 83 return NULL;
84 } 84 }
85 85
86 down(&sbi->s_alloc_sem); 86 mutex_lock(&sbi->s_alloc_mutex);
87 UDF_I_UNIQUE(inode) = 0; 87 UDF_I_UNIQUE(inode) = 0;
88 UDF_I_LENEXTENTS(inode) = 0; 88 UDF_I_LENEXTENTS(inode) = 0;
89 UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; 89 UDF_I_NEXT_ALLOC_BLOCK(inode) = 0;
@@ -148,7 +148,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
148 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); 148 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
149 insert_inode_hash(inode); 149 insert_inode_hash(inode);
150 mark_inode_dirty(inode); 150 mark_inode_dirty(inode);
151 up(&sbi->s_alloc_sem); 151 mutex_unlock(&sbi->s_alloc_mutex);
152 152
153 if (DQUOT_ALLOC_INODE(inode)) 153 if (DQUOT_ALLOC_INODE(inode))
154 { 154 {
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 368d8f81fe54..9303c50c5d55 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1515,7 +1515,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1515 sb->s_fs_info = sbi; 1515 sb->s_fs_info = sbi;
1516 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); 1516 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
1517 1517
1518 init_MUTEX(&sbi->s_alloc_sem); 1518 mutex_init(&sbi->s_alloc_mutex);
1519 1519
1520 if (!udf_parse_options((char *)options, &uopt)) 1520 if (!udf_parse_options((char *)options, &uopt))
1521 goto error_out; 1521 goto error_out;
diff --git a/fs/ufs/file.c b/fs/ufs/file.c
index ed69d7fe1b5d..62ad481810ef 100644
--- a/fs/ufs/file.c
+++ b/fs/ufs/file.c
@@ -23,18 +23,8 @@
23 * ext2 fs regular file handling primitives 23 * ext2 fs regular file handling primitives
24 */ 24 */
25 25
26#include <asm/uaccess.h>
27#include <asm/system.h>
28
29#include <linux/errno.h>
30#include <linux/fs.h> 26#include <linux/fs.h>
31#include <linux/ufs_fs.h> 27#include <linux/ufs_fs.h>
32#include <linux/fcntl.h>
33#include <linux/time.h>
34#include <linux/stat.h>
35#include <linux/mm.h>
36#include <linux/pagemap.h>
37#include <linux/smp_lock.h>
38 28
39/* 29/*
40 * We have mostly NULL's here: the current defaults are ok for 30 * We have mostly NULL's here: the current defaults are ok for
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 2958cde7d3d6..8d5f98a01c74 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -43,18 +43,6 @@
43#define UFSD(x) 43#define UFSD(x)
44#endif 44#endif
45 45
46static inline void ufs_inc_count(struct inode *inode)
47{
48 inode->i_nlink++;
49 mark_inode_dirty(inode);
50}
51
52static inline void ufs_dec_count(struct inode *inode)
53{
54 inode->i_nlink--;
55 mark_inode_dirty(inode);
56}
57
58static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode) 46static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
59{ 47{
60 int err = ufs_add_link(dentry, inode); 48 int err = ufs_add_link(dentry, inode);
@@ -62,7 +50,7 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
62 d_instantiate(dentry, inode); 50 d_instantiate(dentry, inode);
63 return 0; 51 return 0;
64 } 52 }
65 ufs_dec_count(inode); 53 inode_dec_link_count(inode);
66 iput(inode); 54 iput(inode);
67 return err; 55 return err;
68} 56}
@@ -173,7 +161,7 @@ out:
173 return err; 161 return err;
174 162
175out_fail: 163out_fail:
176 ufs_dec_count(inode); 164 inode_dec_link_count(inode);
177 iput(inode); 165 iput(inode);
178 goto out; 166 goto out;
179} 167}
@@ -191,7 +179,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
191 } 179 }
192 180
193 inode->i_ctime = CURRENT_TIME_SEC; 181 inode->i_ctime = CURRENT_TIME_SEC;
194 ufs_inc_count(inode); 182 inode_inc_link_count(inode);
195 atomic_inc(&inode->i_count); 183 atomic_inc(&inode->i_count);
196 184
197 error = ufs_add_nondir(dentry, inode); 185 error = ufs_add_nondir(dentry, inode);
@@ -208,7 +196,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
208 goto out; 196 goto out;
209 197
210 lock_kernel(); 198 lock_kernel();
211 ufs_inc_count(dir); 199 inode_inc_link_count(dir);
212 200
213 inode = ufs_new_inode(dir, S_IFDIR|mode); 201 inode = ufs_new_inode(dir, S_IFDIR|mode);
214 err = PTR_ERR(inode); 202 err = PTR_ERR(inode);
@@ -218,7 +206,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
218 inode->i_op = &ufs_dir_inode_operations; 206 inode->i_op = &ufs_dir_inode_operations;
219 inode->i_fop = &ufs_dir_operations; 207 inode->i_fop = &ufs_dir_operations;
220 208
221 ufs_inc_count(inode); 209 inode_inc_link_count(inode);
222 210
223 err = ufs_make_empty(inode, dir); 211 err = ufs_make_empty(inode, dir);
224 if (err) 212 if (err)
@@ -234,11 +222,11 @@ out:
234 return err; 222 return err;
235 223
236out_fail: 224out_fail:
237 ufs_dec_count(inode); 225 inode_dec_link_count(inode);
238 ufs_dec_count(inode); 226 inode_dec_link_count(inode);
239 iput (inode); 227 iput (inode);
240out_dir: 228out_dir:
241 ufs_dec_count(dir); 229 inode_dec_link_count(dir);
242 unlock_kernel(); 230 unlock_kernel();
243 goto out; 231 goto out;
244} 232}
@@ -260,7 +248,7 @@ static int ufs_unlink(struct inode * dir, struct dentry *dentry)
260 goto out; 248 goto out;
261 249
262 inode->i_ctime = dir->i_ctime; 250 inode->i_ctime = dir->i_ctime;
263 ufs_dec_count(inode); 251 inode_dec_link_count(inode);
264 err = 0; 252 err = 0;
265out: 253out:
266 unlock_kernel(); 254 unlock_kernel();
@@ -277,8 +265,8 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
277 err = ufs_unlink(dir, dentry); 265 err = ufs_unlink(dir, dentry);
278 if (!err) { 266 if (!err) {
279 inode->i_size = 0; 267 inode->i_size = 0;
280 ufs_dec_count(inode); 268 inode_dec_link_count(inode);
281 ufs_dec_count(dir); 269 inode_dec_link_count(dir);
282 } 270 }
283 } 271 }
284 unlock_kernel(); 272 unlock_kernel();
@@ -319,35 +307,35 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
319 new_de = ufs_find_entry (new_dentry, &new_bh); 307 new_de = ufs_find_entry (new_dentry, &new_bh);
320 if (!new_de) 308 if (!new_de)
321 goto out_dir; 309 goto out_dir;
322 ufs_inc_count(old_inode); 310 inode_inc_link_count(old_inode);
323 ufs_set_link(new_dir, new_de, new_bh, old_inode); 311 ufs_set_link(new_dir, new_de, new_bh, old_inode);
324 new_inode->i_ctime = CURRENT_TIME_SEC; 312 new_inode->i_ctime = CURRENT_TIME_SEC;
325 if (dir_de) 313 if (dir_de)
326 new_inode->i_nlink--; 314 new_inode->i_nlink--;
327 ufs_dec_count(new_inode); 315 inode_dec_link_count(new_inode);
328 } else { 316 } else {
329 if (dir_de) { 317 if (dir_de) {
330 err = -EMLINK; 318 err = -EMLINK;
331 if (new_dir->i_nlink >= UFS_LINK_MAX) 319 if (new_dir->i_nlink >= UFS_LINK_MAX)
332 goto out_dir; 320 goto out_dir;
333 } 321 }
334 ufs_inc_count(old_inode); 322 inode_inc_link_count(old_inode);
335 err = ufs_add_link(new_dentry, old_inode); 323 err = ufs_add_link(new_dentry, old_inode);
336 if (err) { 324 if (err) {
337 ufs_dec_count(old_inode); 325 inode_dec_link_count(old_inode);
338 goto out_dir; 326 goto out_dir;
339 } 327 }
340 if (dir_de) 328 if (dir_de)
341 ufs_inc_count(new_dir); 329 inode_inc_link_count(new_dir);
342 } 330 }
343 331
344 ufs_delete_entry (old_dir, old_de, old_bh); 332 ufs_delete_entry (old_dir, old_de, old_bh);
345 333
346 ufs_dec_count(old_inode); 334 inode_dec_link_count(old_inode);
347 335
348 if (dir_de) { 336 if (dir_de) {
349 ufs_set_link(old_inode, dir_de, dir_bh, new_dir); 337 ufs_set_link(old_inode, dir_de, dir_bh, new_dir);
350 ufs_dec_count(old_dir); 338 inode_dec_link_count(old_dir);
351 } 339 }
352 unlock_kernel(); 340 unlock_kernel();
353 return 0; 341 return 0;
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
index 8955720a2c6b..713e6a7505d0 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -62,18 +62,15 @@ xfs_read_xfsstats(
62 while (j < xstats[i].endpoint) { 62 while (j < xstats[i].endpoint) {
63 val = 0; 63 val = 0;
64 /* sum over all cpus */ 64 /* sum over all cpus */
65 for (c = 0; c < NR_CPUS; c++) { 65 for_each_cpu(c)
66 if (!cpu_possible(c)) continue;
67 val += *(((__u32*)&per_cpu(xfsstats, c) + j)); 66 val += *(((__u32*)&per_cpu(xfsstats, c) + j));
68 }
69 len += sprintf(buffer + len, " %u", val); 67 len += sprintf(buffer + len, " %u", val);
70 j++; 68 j++;
71 } 69 }
72 buffer[len++] = '\n'; 70 buffer[len++] = '\n';
73 } 71 }
74 /* extra precision counters */ 72 /* extra precision counters */
75 for (i = 0; i < NR_CPUS; i++) { 73 for_each_cpu(i) {
76 if (!cpu_possible(i)) continue;
77 xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes; 74 xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
78 xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes; 75 xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
79 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes; 76 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
index a02564972420..7079cc837210 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c
@@ -38,8 +38,7 @@ xfs_stats_clear_proc_handler(
38 38
39 if (!ret && write && *valp) { 39 if (!ret && write && *valp) {
40 printk("XFS Clearing xfsstats\n"); 40 printk("XFS Clearing xfsstats\n");
41 for (c = 0; c < NR_CPUS; c++) { 41 for_each_cpu(c) {
42 if (!cpu_possible(c)) continue;
43 preempt_disable(); 42 preempt_disable();
44 /* save vn_active, it's a universal truth! */ 43 /* save vn_active, it's a universal truth! */
45 vn_active = per_cpu(xfsstats, c).vn_active; 44 vn_active = per_cpu(xfsstats, c).vn_active;
diff --git a/include/asm-alpha/mmu_context.h b/include/asm-alpha/mmu_context.h
index 6f92482cc96c..0c017fc181c1 100644
--- a/include/asm-alpha/mmu_context.h
+++ b/include/asm-alpha/mmu_context.h
@@ -231,9 +231,8 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
231{ 231{
232 int i; 232 int i;
233 233
234 for (i = 0; i < NR_CPUS; i++) 234 for_each_online_cpu(i)
235 if (cpu_online(i)) 235 mm->context[i] = 0;
236 mm->context[i] = 0;
237 if (tsk != current) 236 if (tsk != current)
238 task_thread_info(tsk)->pcb.ptbr 237 task_thread_info(tsk)->pcb.ptbr
239 = ((unsigned long)mm->pgd - IDENT_ADDR) >> PAGE_SHIFT; 238 = ((unsigned long)mm->pgd - IDENT_ADDR) >> PAGE_SHIFT;
diff --git a/include/asm-alpha/topology.h b/include/asm-alpha/topology.h
index eb740e280d9c..420ccde6b916 100644
--- a/include/asm-alpha/topology.h
+++ b/include/asm-alpha/topology.h
@@ -27,8 +27,8 @@ static inline cpumask_t node_to_cpumask(int node)
27 cpumask_t node_cpu_mask = CPU_MASK_NONE; 27 cpumask_t node_cpu_mask = CPU_MASK_NONE;
28 int cpu; 28 int cpu;
29 29
30 for(cpu = 0; cpu < NR_CPUS; cpu++) { 30 for_each_online_cpu(cpu) {
31 if (cpu_online(cpu) && (cpu_to_node(cpu) == node)) 31 if (cpu_to_node(cpu) == node)
32 cpu_set(cpu, node_cpu_mask); 32 cpu_set(cpu, node_cpu_mask);
33 } 33 }
34 34
diff --git a/include/asm-arm/arch-aaec2000/param.h b/include/asm-arm/arch-aaec2000/param.h
deleted file mode 100644
index 139936c2faf2..000000000000
--- a/include/asm-arm/arch-aaec2000/param.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/param.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_PARAM_H
12#define __ASM_ARCH_PARAM_H
13
14#endif /* __ASM_ARCH_PARAM_H */
15
diff --git a/include/asm-arm/arch-at91rm9200/param.h b/include/asm-arm/arch-at91rm9200/param.h
deleted file mode 100644
index 9480f8446852..000000000000
--- a/include/asm-arm/arch-at91rm9200/param.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * include/asm-arm/arch-at91rm9200/param.h
3 *
4 * Copyright (C) 2003 SAN People
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __ASM_ARCH_PARAM_H
22#define __ASM_ARCH_PARAM_H
23
24/*
25 * We use default params
26 */
27
28#endif
diff --git a/include/asm-arm/arch-cl7500/debug-macro.S b/include/asm-arm/arch-cl7500/debug-macro.S
index a5d489d7955a..9a2b67d24098 100644
--- a/include/asm-arm/arch-cl7500/debug-macro.S
+++ b/include/asm-arm/arch-cl7500/debug-macro.S
@@ -17,15 +17,5 @@
17 orr \rx, \rx, #0x00000be0 17 orr \rx, \rx, #0x00000be0
18 .endm 18 .endm
19 19
20 .macro senduart,rd,rx 20#define UART_SHIFT 2
21 strb \rd, [\rx] 21#include <asm/hardware/debug-8250.S>
22 .endm
23
24 .macro busyuart,rd,rx
25 .endm
26
27 .macro waituart,rd,rx
281001: ldrb \rd, [\rx, #0x14]
29 tst \rd, #0x20
30 beq 1001b
31 .endm
diff --git a/include/asm-arm/arch-cl7500/param.h b/include/asm-arm/arch-cl7500/param.h
deleted file mode 100644
index 974bf69fbb1a..000000000000
--- a/include/asm-arm/arch-cl7500/param.h
+++ /dev/null
@@ -1,5 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-cl7500/param.h
3 *
4 * Copyright (C) 1999 Nexus Electronics Ltd
5 */
diff --git a/include/asm-arm/arch-clps711x/param.h b/include/asm-arm/arch-clps711x/param.h
deleted file mode 100644
index 86f6bd29623d..000000000000
--- a/include/asm-arm/arch-clps711x/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-clps711x/param.h
3 *
4 * Copyright (C) 2000 Deep Blue Solutions Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
diff --git a/include/asm-arm/arch-ebsa110/debug-macro.S b/include/asm-arm/arch-ebsa110/debug-macro.S
index dcd03a40c502..f61cadabe0ec 100644
--- a/include/asm-arm/arch-ebsa110/debug-macro.S
+++ b/include/asm-arm/arch-ebsa110/debug-macro.S
@@ -16,19 +16,6 @@
16 orr \rx, \rx, #0x00000be0 16 orr \rx, \rx, #0x00000be0
17 .endm 17 .endm
18 18
19 .macro senduart,rd,rx 19#define UART_SHIFT 2
20 strb \rd, [\rx] 20#define FLOW_CONTROL
21 .endm 21#include <asm/hardware/debug-8250.h>
22
23 .macro busyuart,rd,rx
241002: ldrb \rd, [\rx, #0x14]
25 and \rd, \rd, #0x60
26 teq \rd, #0x60
27 bne 1002b
28 .endm
29
30 .macro waituart,rd,rx
311001: ldrb \rd, [\rx, #0x18]
32 tst \rd, #0x10
33 beq 1001b
34 .endm
diff --git a/include/asm-arm/arch-ebsa110/param.h b/include/asm-arm/arch-ebsa110/param.h
deleted file mode 100644
index be19b08d1c75..000000000000
--- a/include/asm-arm/arch-ebsa110/param.h
+++ /dev/null
@@ -1,4 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-ebsa110/param.h
3 */
4#define HZ 200
diff --git a/include/asm-arm/arch-ebsa285/debug-macro.S b/include/asm-arm/arch-ebsa285/debug-macro.S
index 97d15fc629af..b48cec4a0c45 100644
--- a/include/asm-arm/arch-ebsa285/debug-macro.S
+++ b/include/asm-arm/arch-ebsa285/debug-macro.S
@@ -23,22 +23,10 @@
23 orr \rx, \rx, #0x000003f8 23 orr \rx, \rx, #0x000003f8
24 .endm 24 .endm
25 25
26 .macro senduart,rd,rx 26#define UART_SHIFT 0
27 strb \rd, [\rx] 27#define FLOW_CONTROL
28 .endm 28#include <asm/hardware/debug-8250.S>
29 29
30 .macro busyuart,rd,rx
311002: ldrb \rd, [\rx, #0x5]
32 and \rd, \rd, #0x60
33 teq \rd, #0x60
34 bne 1002b
35 .endm
36
37 .macro waituart,rd,rx
381001: ldrb \rd, [\rx, #0x6]
39 tst \rd, #0x10
40 beq 1001b
41 .endm
42#else 30#else
43 /* For EBSA285 debugging */ 31 /* For EBSA285 debugging */
44 .equ dc21285_high, ARMCSR_BASE & 0xff000000 32 .equ dc21285_high, ARMCSR_BASE & 0xff000000
diff --git a/include/asm-arm/arch-ebsa285/param.h b/include/asm-arm/arch-ebsa285/param.h
deleted file mode 100644
index 3827103b27a0..000000000000
--- a/include/asm-arm/arch-ebsa285/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-ebsa285/param.h
3 */
diff --git a/include/asm-arm/arch-ep93xx/debug-macro.S b/include/asm-arm/arch-ep93xx/debug-macro.S
new file mode 100644
index 000000000000..397565a0c671
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/debug-macro.S
@@ -0,0 +1,22 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/debug-macro.S
3 * Debugging macro include header
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12#include <asm/arch/ep93xx-regs.h>
13
14 .macro addruart,rx
15 mrc p15, 0, \rx, c1, c0
16 tst \rx, #1 @ MMU enabled?
17 ldreq \rx, =EP93XX_APB_PHYS_BASE @ Physical base
18 ldrne \rx, =EP93XX_APB_VIRT_BASE @ virtual base
19 orr \rx, \rx, #0x000c0000
20 .endm
21
22#include <asm/hardware/debug-pl01x.S>
diff --git a/include/asm-arm/arch-ep93xx/dma.h b/include/asm-arm/arch-ep93xx/dma.h
new file mode 100644
index 000000000000..898b3ab7fd46
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/dma.h
@@ -0,0 +1,3 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/dma.h
3 */
diff --git a/include/asm-arm/arch-ep93xx/entry-macro.S b/include/asm-arm/arch-ep93xx/entry-macro.S
new file mode 100644
index 000000000000..84140a28dfcf
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/entry-macro.S
@@ -0,0 +1,53 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/entry-macro.S
3 * IRQ demultiplexing for EP93xx
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12#include <asm/arch/ep93xx-regs.h>
13
14 .macro disable_fiq
15 .endm
16
17 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
18 ldr \base, =(EP93XX_AHB_VIRT_BASE)
19 orr \base, \base, #0x000b0000
20 mov \irqnr, #0
21 ldr \irqstat, [\base] @ lower 32 interrupts
22 cmp \irqstat, #0
23 bne 1001f
24
25 eor \base, \base, #0x00070000
26 ldr \irqstat, [\base] @ upper 32 interrupts
27 cmp \irqstat, #0
28 beq 1002f
29 mov \irqnr, #0x20
30
311001:
32 movs \tmp, \irqstat, lsl #16
33 movne \irqstat, \tmp
34 addeq \irqnr, \irqnr, #16
35
36 movs \tmp, \irqstat, lsl #8
37 movne \irqstat, \tmp
38 addeq \irqnr, \irqnr, #8
39
40 movs \tmp, \irqstat, lsl #4
41 movne \irqstat, \tmp
42 addeq \irqnr, \irqnr, #4
43
44 movs \tmp, \irqstat, lsl #2
45 movne \irqstat, \tmp
46 addeq \irqnr, \irqnr, #2
47
48 movs \tmp, \irqstat, lsl #1
49 addeq \irqnr, \irqnr, #1
50 orrs \base, \base, #1
51
521002:
53 .endm
diff --git a/include/asm-arm/arch-ep93xx/ep93xx-regs.h b/include/asm-arm/arch-ep93xx/ep93xx-regs.h
new file mode 100644
index 000000000000..71cea0b5841b
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/ep93xx-regs.h
@@ -0,0 +1,125 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/ep93xx-regs.h
3 */
4
5#ifndef __ASM_ARCH_EP93XX_REGS_H
6#define __ASM_ARCH_EP93XX_REGS_H
7
8/*
9 * EP93xx linux memory map:
10 *
11 * virt phys size
12 * fe800000 5M per-platform mappings
13 * fed00000 80800000 2M APB
14 * fef00000 80000000 1M AHB
15 */
16
17#define EP93XX_AHB_PHYS_BASE 0x80000000
18#define EP93XX_AHB_VIRT_BASE 0xfef00000
19#define EP93XX_AHB_SIZE 0x00100000
20
21#define EP93XX_APB_PHYS_BASE 0x80800000
22#define EP93XX_APB_VIRT_BASE 0xfed00000
23#define EP93XX_APB_SIZE 0x00200000
24
25
26/* AHB peripherals */
27#define EP93XX_DMA_BASE (EP93XX_AHB_VIRT_BASE + 0x00000000)
28
29#define EP93XX_ETHERNET_BASE (EP93XX_AHB_VIRT_BASE + 0x00010000)
30
31#define EP93XX_USB_BASE (EP93XX_AHB_VIRT_BASE + 0x00020000)
32#define EP93XX_USB_PHYS_BASE (EP93XX_AHB_PHYS_BASE + 0x00020000)
33
34#define EP93XX_RASTER_BASE (EP93XX_AHB_VIRT_BASE + 0x00030000)
35
36#define EP93XX_GRAPHICS_ACCEL_BASE (EP93XX_AHB_VIRT_BASE + 0x00040000)
37
38#define EP93XX_SDRAM_CONTROLLER_BASE (EP93XX_AHB_VIRT_BASE + 0x00060000)
39
40#define EP93XX_PCMCIA_CONTROLLER_BASE (EP93XX_AHB_VIRT_BASE + 0x00080000)
41
42#define EP93XX_BOOT_ROM_BASE (EP93XX_AHB_VIRT_BASE + 0x00090000)
43
44#define EP93XX_IDE_BASE (EP93XX_AHB_VIRT_BASE + 0x000a0000)
45
46#define EP93XX_VIC1_BASE (EP93XX_AHB_VIRT_BASE + 0x000b0000)
47
48#define EP93XX_VIC2_BASE (EP93XX_AHB_VIRT_BASE + 0x000c0000)
49
50
51/* APB peripherals */
52#define EP93XX_TIMER_BASE (EP93XX_APB_VIRT_BASE + 0x00010000)
53#define EP93XX_TIMER_REG(x) (EP93XX_TIMER_BASE + (x))
54#define EP93XX_TIMER1_LOAD EP93XX_TIMER_REG(0x00)
55#define EP93XX_TIMER1_VALUE EP93XX_TIMER_REG(0x04)
56#define EP93XX_TIMER1_CONTROL EP93XX_TIMER_REG(0x08)
57#define EP93XX_TIMER1_CLEAR EP93XX_TIMER_REG(0x0c)
58#define EP93XX_TIMER2_LOAD EP93XX_TIMER_REG(0x20)
59#define EP93XX_TIMER2_VALUE EP93XX_TIMER_REG(0x24)
60#define EP93XX_TIMER2_CONTROL EP93XX_TIMER_REG(0x28)
61#define EP93XX_TIMER2_CLEAR EP93XX_TIMER_REG(0x2c)
62#define EP93XX_TIMER4_VALUE_LOW EP93XX_TIMER_REG(0x60)
63#define EP93XX_TIMER4_VALUE_HIGH EP93XX_TIMER_REG(0x64)
64#define EP93XX_TIMER3_LOAD EP93XX_TIMER_REG(0x80)
65#define EP93XX_TIMER3_VALUE EP93XX_TIMER_REG(0x84)
66#define EP93XX_TIMER3_CONTROL EP93XX_TIMER_REG(0x88)
67#define EP93XX_TIMER3_CLEAR EP93XX_TIMER_REG(0x8c)
68
69#define EP93XX_I2S_BASE (EP93XX_APB_VIRT_BASE + 0x00020000)
70
71#define EP93XX_SECURITY_BASE (EP93XX_APB_VIRT_BASE + 0x00030000)
72
73#define EP93XX_GPIO_BASE (EP93XX_APB_VIRT_BASE + 0x00040000)
74#define EP93XX_GPIO_REG(x) (EP93XX_GPIO_BASE + (x))
75#define EP93XX_GPIO_A_INT_TYPE1 EP93XX_GPIO_REG(0x90)
76#define EP93XX_GPIO_A_INT_TYPE2 EP93XX_GPIO_REG(0x94)
77#define EP93XX_GPIO_A_INT_ACK EP93XX_GPIO_REG(0x98)
78#define EP93XX_GPIO_A_INT_ENABLE EP93XX_GPIO_REG(0x9c)
79#define EP93XX_GPIO_A_INT_STATUS EP93XX_GPIO_REG(0xa0)
80#define EP93XX_GPIO_B_INT_TYPE1 EP93XX_GPIO_REG(0xac)
81#define EP93XX_GPIO_B_INT_TYPE2 EP93XX_GPIO_REG(0xb0)
82#define EP93XX_GPIO_B_INT_ACK EP93XX_GPIO_REG(0xb4)
83#define EP93XX_GPIO_B_INT_ENABLE EP93XX_GPIO_REG(0xb8)
84#define EP93XX_GPIO_B_INT_STATUS EP93XX_GPIO_REG(0xbc)
85
86#define EP93XX_AAC_BASE (EP93XX_APB_VIRT_BASE + 0x00080000)
87
88#define EP93XX_SPI_BASE (EP93XX_APB_VIRT_BASE + 0x000a0000)
89
90#define EP93XX_IRDA_BASE (EP93XX_APB_VIRT_BASE + 0x000b0000)
91
92#define EP93XX_UART1_BASE (EP93XX_APB_VIRT_BASE + 0x000c0000)
93#define EP93XX_UART1_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x000c0000)
94
95#define EP93XX_UART2_BASE (EP93XX_APB_VIRT_BASE + 0x000d0000)
96#define EP93XX_UART2_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x000d0000)
97
98#define EP93XX_UART3_BASE (EP93XX_APB_VIRT_BASE + 0x000e0000)
99#define EP93XX_UART3_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x000e0000)
100
101#define EP93XX_KEY_MATRIX_BASE (EP93XX_APB_VIRT_BASE + 0x000f0000)
102
103#define EP93XX_ADC_BASE (EP93XX_APB_VIRT_BASE + 0x00100000)
104#define EP93XX_TOUCHSCREEN_BASE (EP93XX_APB_VIRT_BASE + 0x00100000)
105
106#define EP93XX_PWM_BASE (EP93XX_APB_VIRT_BASE + 0x00110000)
107
108#define EP93XX_RTC_BASE (EP93XX_APB_VIRT_BASE + 0x00120000)
109
110#define EP93XX_SYSCON_BASE (EP93XX_APB_VIRT_BASE + 0x00130000)
111#define EP93XX_SYSCON_REG(x) (EP93XX_SYSCON_BASE + (x))
112#define EP93XX_SYSCON_POWER_STATE EP93XX_SYSCON_REG(0x00)
113#define EP93XX_SYSCON_CLOCK_CONTROL EP93XX_SYSCON_REG(0x04)
114#define EP93XX_SYSCON_CLOCK_UARTBAUD 0x20000000
115#define EP93XX_SYSCON_CLOCK_USH_EN 0x10000000
116#define EP93XX_SYSCON_HALT EP93XX_SYSCON_REG(0x08)
117#define EP93XX_SYSCON_STANDBY EP93XX_SYSCON_REG(0x0c)
118#define EP93XX_SYSCON_DEVICE_CONFIG EP93XX_SYSCON_REG(0x80)
119#define EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE 0x00800000
120#define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0)
121
122#define EP93XX_WATCHDOG_BASE (EP93XX_APB_VIRT_BASE + 0x00140000)
123
124
125#endif
diff --git a/include/asm-arm/arch-ep93xx/gesbc9312.h b/include/asm-arm/arch-ep93xx/gesbc9312.h
new file mode 100644
index 000000000000..4d0b3023bff7
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/gesbc9312.h
@@ -0,0 +1,3 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/gesbc9312.h
3 */
diff --git a/include/asm-arm/arch-ep93xx/gpio.h b/include/asm-arm/arch-ep93xx/gpio.h
new file mode 100644
index 000000000000..1ee14a14cba0
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/gpio.h
@@ -0,0 +1,107 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/gpio.h
3 */
4
5#ifndef __ASM_ARCH_GPIO_H
6#define __ASM_ARCH_GPIO_H
7
8#define GPIO_IN 0
9#define GPIO_OUT 1
10
11#define EP93XX_GPIO_LOW 0
12#define EP93XX_GPIO_HIGH 1
13
14extern void gpio_line_config(int line, int direction);
15extern int gpio_line_get(int line);
16extern void gpio_line_set(int line, int value);
17
18/* GPIO port A. */
19#define EP93XX_GPIO_LINE_A(x) ((x) + 0)
20#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0)
21#define EP93XX_GPIO_LINE_EGPIO1 EP93XX_GPIO_LINE_A(1)
22#define EP93XX_GPIO_LINE_EGPIO2 EP93XX_GPIO_LINE_A(2)
23#define EP93XX_GPIO_LINE_EGPIO3 EP93XX_GPIO_LINE_A(3)
24#define EP93XX_GPIO_LINE_EGPIO4 EP93XX_GPIO_LINE_A(4)
25#define EP93XX_GPIO_LINE_EGPIO5 EP93XX_GPIO_LINE_A(5)
26#define EP93XX_GPIO_LINE_EGPIO6 EP93XX_GPIO_LINE_A(6)
27#define EP93XX_GPIO_LINE_EGPIO7 EP93XX_GPIO_LINE_A(7)
28
29/* GPIO port B. */
30#define EP93XX_GPIO_LINE_B(x) ((x) + 8)
31#define EP93XX_GPIO_LINE_EGPIO8 EP93XX_GPIO_LINE_B(0)
32#define EP93XX_GPIO_LINE_EGPIO9 EP93XX_GPIO_LINE_B(1)
33#define EP93XX_GPIO_LINE_EGPIO10 EP93XX_GPIO_LINE_B(2)
34#define EP93XX_GPIO_LINE_EGPIO11 EP93XX_GPIO_LINE_B(3)
35#define EP93XX_GPIO_LINE_EGPIO12 EP93XX_GPIO_LINE_B(4)
36#define EP93XX_GPIO_LINE_EGPIO13 EP93XX_GPIO_LINE_B(5)
37#define EP93XX_GPIO_LINE_EGPIO14 EP93XX_GPIO_LINE_B(6)
38#define EP93XX_GPIO_LINE_EGPIO15 EP93XX_GPIO_LINE_B(7)
39
40/* GPIO port C. */
41#define EP93XX_GPIO_LINE_C(x) ((x) + 16)
42#define EP93XX_GPIO_LINE_ROW0 EP93XX_GPIO_LINE_C(0)
43#define EP93XX_GPIO_LINE_ROW1 EP93XX_GPIO_LINE_C(1)
44#define EP93XX_GPIO_LINE_ROW2 EP93XX_GPIO_LINE_C(2)
45#define EP93XX_GPIO_LINE_ROW3 EP93XX_GPIO_LINE_C(3)
46#define EP93XX_GPIO_LINE_ROW4 EP93XX_GPIO_LINE_C(4)
47#define EP93XX_GPIO_LINE_ROW5 EP93XX_GPIO_LINE_C(5)
48#define EP93XX_GPIO_LINE_ROW6 EP93XX_GPIO_LINE_C(6)
49#define EP93XX_GPIO_LINE_ROW7 EP93XX_GPIO_LINE_C(7)
50
51/* GPIO port D. */
52#define EP93XX_GPIO_LINE_D(x) ((x) + 24)
53#define EP93XX_GPIO_LINE_COL0 EP93XX_GPIO_LINE_D(0)
54#define EP93XX_GPIO_LINE_COL1 EP93XX_GPIO_LINE_D(1)
55#define EP93XX_GPIO_LINE_COL2 EP93XX_GPIO_LINE_D(2)
56#define EP93XX_GPIO_LINE_COL3 EP93XX_GPIO_LINE_D(3)
57#define EP93XX_GPIO_LINE_COL4 EP93XX_GPIO_LINE_D(4)
58#define EP93XX_GPIO_LINE_COL5 EP93XX_GPIO_LINE_D(5)
59#define EP93XX_GPIO_LINE_COL6 EP93XX_GPIO_LINE_D(6)
60#define EP93XX_GPIO_LINE_COL7 EP93XX_GPIO_LINE_D(7)
61
62/* GPIO port E. */
63#define EP93XX_GPIO_LINE_E(x) ((x) + 32)
64#define EP93XX_GPIO_LINE_GRLED EP93XX_GPIO_LINE_E(0)
65#define EP93XX_GPIO_LINE_RDLED EP93XX_GPIO_LINE_E(1)
66#define EP93XX_GPIO_LINE_DIORn EP93XX_GPIO_LINE_E(2)
67#define EP93XX_GPIO_LINE_IDECS1n EP93XX_GPIO_LINE_E(3)
68#define EP93XX_GPIO_LINE_IDECS2n EP93XX_GPIO_LINE_E(4)
69#define EP93XX_GPIO_LINE_IDEDA0 EP93XX_GPIO_LINE_E(5)
70#define EP93XX_GPIO_LINE_IDEDA1 EP93XX_GPIO_LINE_E(6)
71#define EP93XX_GPIO_LINE_IDEDA2 EP93XX_GPIO_LINE_E(7)
72
73/* GPIO port F. */
74#define EP93XX_GPIO_LINE_F(x) ((x) + 40)
75#define EP93XX_GPIO_LINE_WP EP93XX_GPIO_LINE_F(0)
76#define EP93XX_GPIO_LINE_MCCD1 EP93XX_GPIO_LINE_F(1)
77#define EP93XX_GPIO_LINE_MCCD2 EP93XX_GPIO_LINE_F(2)
78#define EP93XX_GPIO_LINE_MCBVD1 EP93XX_GPIO_LINE_F(3)
79#define EP93XX_GPIO_LINE_MCBVD2 EP93XX_GPIO_LINE_F(4)
80#define EP93XX_GPIO_LINE_VS1 EP93XX_GPIO_LINE_F(5)
81#define EP93XX_GPIO_LINE_READY EP93XX_GPIO_LINE_F(6)
82#define EP93XX_GPIO_LINE_VS2 EP93XX_GPIO_LINE_F(7)
83
84/* GPIO port G. */
85#define EP93XX_GPIO_LINE_G(x) ((x) + 48)
86#define EP93XX_GPIO_LINE_EECLK EP93XX_GPIO_LINE_G(0)
87#define EP93XX_GPIO_LINE_EEDAT EP93XX_GPIO_LINE_G(1)
88#define EP93XX_GPIO_LINE_SLA0 EP93XX_GPIO_LINE_G(2)
89#define EP93XX_GPIO_LINE_SLA1 EP93XX_GPIO_LINE_G(3)
90#define EP93XX_GPIO_LINE_DD12 EP93XX_GPIO_LINE_G(4)
91#define EP93XX_GPIO_LINE_DD13 EP93XX_GPIO_LINE_G(5)
92#define EP93XX_GPIO_LINE_DD14 EP93XX_GPIO_LINE_G(6)
93#define EP93XX_GPIO_LINE_DD15 EP93XX_GPIO_LINE_G(7)
94
95/* GPIO port H. */
96#define EP93XX_GPIO_LINE_H(x) ((x) + 56)
97#define EP93XX_GPIO_LINE_DD0 EP93XX_GPIO_LINE_H(0)
98#define EP93XX_GPIO_LINE_DD1 EP93XX_GPIO_LINE_H(1)
99#define EP93XX_GPIO_LINE_DD2 EP93XX_GPIO_LINE_H(2)
100#define EP93XX_GPIO_LINE_DD3 EP93XX_GPIO_LINE_H(3)
101#define EP93XX_GPIO_LINE_DD4 EP93XX_GPIO_LINE_H(4)
102#define EP93XX_GPIO_LINE_DD5 EP93XX_GPIO_LINE_H(5)
103#define EP93XX_GPIO_LINE_DD6 EP93XX_GPIO_LINE_H(6)
104#define EP93XX_GPIO_LINE_DD7 EP93XX_GPIO_LINE_H(7)
105
106
107#endif
diff --git a/include/asm-arm/arch-ep93xx/hardware.h b/include/asm-arm/arch-ep93xx/hardware.h
new file mode 100644
index 000000000000..9b69f454065d
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/hardware.h
@@ -0,0 +1,12 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/hardware.h
3 */
4
5#include "ep93xx-regs.h"
6
7#define pcibios_assign_all_busses() 0
8
9#include "platform.h"
10
11#include "gesbc9312.h"
12#include "ts72xx.h"
diff --git a/include/asm-arm/arch-ep93xx/io.h b/include/asm-arm/arch-ep93xx/io.h
new file mode 100644
index 000000000000..7b4d25e29060
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/io.h
@@ -0,0 +1,8 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/io.h
3 */
4
5#define IO_SPACE_LIMIT 0xffffffff
6
7#define __io(p) ((void __iomem *)(p))
8#define __mem_pci(p) (p)
diff --git a/include/asm-arm/arch-ep93xx/irqs.h b/include/asm-arm/arch-ep93xx/irqs.h
new file mode 100644
index 000000000000..9a42f5de9e57
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/irqs.h
@@ -0,0 +1,80 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/irqs.h
3 */
4
5#ifndef __ASM_ARCH_IRQS_H
6#define __ASM_ARCH_IRQS_H
7
8#define IRQ_EP93XX_COMMRX 2
9#define IRQ_EP93XX_COMMTX 3
10#define IRQ_EP93XX_TIMER1 4
11#define IRQ_EP93XX_TIMER2 5
12#define IRQ_EP93XX_AACINTR 6
13#define IRQ_EP93XX_DMAM2P0 7
14#define IRQ_EP93XX_DMAM2P1 8
15#define IRQ_EP93XX_DMAM2P2 9
16#define IRQ_EP93XX_DMAM2P3 10
17#define IRQ_EP93XX_DMAM2P4 11
18#define IRQ_EP93XX_DMAM2P5 12
19#define IRQ_EP93XX_DMAM2P6 13
20#define IRQ_EP93XX_DMAM2P7 14
21#define IRQ_EP93XX_DMAM2P8 15
22#define IRQ_EP93XX_DMAM2P9 16
23#define IRQ_EP93XX_DMAM2M0 17
24#define IRQ_EP93XX_DMAM2M1 18
25#define IRQ_EP93XX_GPIO0MUX 20
26#define IRQ_EP93XX_GPIO1MUX 21
27#define IRQ_EP93XX_GPIO2MUX 22
28#define IRQ_EP93XX_GPIO3MUX 22
29#define IRQ_EP93XX_UART1RX 23
30#define IRQ_EP93XX_UART1TX 24
31#define IRQ_EP93XX_UART2RX 25
32#define IRQ_EP93XX_UART2TX 26
33#define IRQ_EP93XX_UART3RX 27
34#define IRQ_EP93XX_UART3TX 28
35#define IRQ_EP93XX_KEY 29
36#define IRQ_EP93XX_TOUCH 30
37#define EP93XX_VIC1_VALID_IRQ_MASK 0x7ffffffc
38
39#define IRQ_EP93XX_EXT0 32
40#define IRQ_EP93XX_EXT1 33
41#define IRQ_EP93XX_EXT2 34
42#define IRQ_EP93XX_64HZ 35
43#define IRQ_EP93XX_WATCHDOG 36
44#define IRQ_EP93XX_RTC 37
45#define IRQ_EP93XX_IRDA 38
46#define IRQ_EP93XX_ETHERNET 39
47#define IRQ_EP93XX_EXT3 40
48#define IRQ_EP93XX_PROG 41
49#define IRQ_EP93XX_1HZ 42
50#define IRQ_EP93XX_VSYNC 43
51#define IRQ_EP93XX_VIDEO_FIFO 44
52#define IRQ_EP93XX_SSP1RX 45
53#define IRQ_EP93XX_SSP1TX 46
54#define IRQ_EP93XX_GPIO4MUX 47
55#define IRQ_EP93XX_GPIO5MUX 48
56#define IRQ_EP93XX_GPIO6MUX 49
57#define IRQ_EP93XX_GPIO7MUX 50
58#define IRQ_EP93XX_TIMER3 51
59#define IRQ_EP93XX_UART1 52
60#define IRQ_EP93XX_SSP 53
61#define IRQ_EP93XX_UART2 54
62#define IRQ_EP93XX_UART3 55
63#define IRQ_EP93XX_USB 56
64#define IRQ_EP93XX_ETHERNET_PME 57
65#define IRQ_EP93XX_DSP 58
66#define IRQ_EP93XX_GPIO_AB 59
67#define IRQ_EP93XX_SAI 60
68#define EP93XX_VIC2_VALID_IRQ_MASK 0x1fffffff
69
70#define IRQ_EP93XX_GPIO(x) (64 + (x))
71
72#define NR_EP93XX_IRQS IRQ_EP93XX_GPIO(16)
73
74#define EP93XX_BOARD_IRQ(x) (NR_EP93XX_IRQS + (x))
75#define EP93XX_BOARD_IRQS 32
76
77#define NR_IRQS (NR_EP93XX_IRQS + EP93XX_BOARD_IRQS)
78
79
80#endif
diff --git a/include/asm-arm/arch-ep93xx/memory.h b/include/asm-arm/arch-ep93xx/memory.h
new file mode 100644
index 000000000000..4b1a5c7c8363
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/memory.h
@@ -0,0 +1,14 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/memory.h
3 */
4
5#ifndef __ASM_ARCH_MEMORY_H
6#define __ASM_ARCH_MEMORY_H
7
8#define PHYS_OFFSET UL(0x00000000)
9
10#define __bus_to_virt(x) __phys_to_virt(x)
11#define __virt_to_bus(x) __virt_to_phys(x)
12
13
14#endif
diff --git a/include/asm-arm/arch-ep93xx/platform.h b/include/asm-arm/arch-ep93xx/platform.h
new file mode 100644
index 000000000000..df9cbb6ef660
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/platform.h
@@ -0,0 +1,14 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/platform.h
3 */
4
5#ifndef __ASSEMBLY__
6
7void ep93xx_map_io(void);
8void ep93xx_init_irq(void);
9void ep93xx_init_time(unsigned long);
10void ep93xx_init_devices(void);
11extern struct sys_timer ep93xx_timer;
12
13
14#endif
diff --git a/include/asm-arm/arch-ep93xx/system.h b/include/asm-arm/arch-ep93xx/system.h
new file mode 100644
index 000000000000..79b718586746
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/system.h
@@ -0,0 +1,26 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/system.h
3 */
4
5#include <asm/hardware.h>
6
7static inline void arch_idle(void)
8{
9 cpu_do_idle();
10}
11
12static inline void arch_reset(char mode)
13{
14 u32 devicecfg;
15
16 local_irq_disable();
17
18 devicecfg = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
19 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
20 __raw_writel(devicecfg | 0x80000000, EP93XX_SYSCON_DEVICE_CONFIG);
21 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
22 __raw_writel(devicecfg & ~0x80000000, EP93XX_SYSCON_DEVICE_CONFIG);
23
24 while (1)
25 ;
26}
diff --git a/include/asm-arm/arch-ep93xx/timex.h b/include/asm-arm/arch-ep93xx/timex.h
new file mode 100644
index 000000000000..4140bddc97e2
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/timex.h
@@ -0,0 +1,5 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/timex.h
3 */
4
5#define CLOCK_TICK_RATE 983040
diff --git a/include/asm-arm/arch-ep93xx/ts72xx.h b/include/asm-arm/arch-ep93xx/ts72xx.h
new file mode 100644
index 000000000000..412215e77f44
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/ts72xx.h
@@ -0,0 +1,90 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/ts72xx.h
3 */
4
5/*
6 * TS72xx memory map:
7 *
8 * virt phys size
9 * febff000 22000000 4K model number register
10 * febfe000 22400000 4K options register
11 * febfd000 22800000 4K options register #2
12 * febfc000 [67]0000000 4K NAND data register
13 * febfb000 [67]0400000 4K NAND control register
14 * febfa000 [67]0800000 4K NAND busy register
15 */
16
17#define TS72XX_MODEL_PHYS_BASE 0x22000000
18#define TS72XX_MODEL_VIRT_BASE 0xfebff000
19#define TS72XX_MODEL_SIZE 0x00001000
20
21#define TS72XX_MODEL_TS7200 0x00
22#define TS72XX_MODEL_TS7250 0x01
23#define TS72XX_MODEL_TS7260 0x02
24
25
26#define TS72XX_OPTIONS_PHYS_BASE 0x22400000
27#define TS72XX_OPTIONS_VIRT_BASE 0xfebfe000
28#define TS72XX_OPTIONS_SIZE 0x00001000
29
30#define TS72XX_OPTIONS_COM2_RS485 0x02
31#define TS72XX_OPTIONS_MAX197 0x01
32
33
34#define TS72XX_OPTIONS2_PHYS_BASE 0x22800000
35#define TS72XX_OPTIONS2_VIRT_BASE 0xfebfd000
36#define TS72XX_OPTIONS2_SIZE 0x00001000
37
38#define TS72XX_OPTIONS2_TS9420 0x04
39#define TS72XX_OPTIONS2_TS9420_BOOT 0x02
40
41
42#define TS72XX_NOR_PHYS_BASE 0x60000000
43#define TS72XX_NOR2_PHYS_BASE 0x62000000
44
45#define TS72XX_NAND1_DATA_PHYS_BASE 0x60000000
46#define TS72XX_NAND2_DATA_PHYS_BASE 0x70000000
47#define TS72XX_NAND_DATA_VIRT_BASE 0xfebfc000
48#define TS72XX_NAND_DATA_SIZE 0x00001000
49
50#define TS72XX_NAND1_CONTROL_PHYS_BASE 0x60400000
51#define TS72XX_NAND2_CONTROL_PHYS_BASE 0x70400000
52#define TS72XX_NAND_CONTROL_VIRT_BASE 0xfebfb000
53#define TS72XX_NAND_CONTROL_SIZE 0x00001000
54
55#define TS72XX_NAND1_BUSY_PHYS_BASE 0x60800000
56#define TS72XX_NAND2_BUSY_PHYS_BASE 0x70800000
57#define TS72XX_NAND_BUSY_VIRT_BASE 0xfebfa000
58#define TS72XX_NAND_BUSY_SIZE 0x00001000
59
60
61#ifndef __ASSEMBLY__
62#include <asm/io.h>
63
64static inline int board_is_ts7200(void)
65{
66 return __raw_readb(TS72XX_MODEL_VIRT_BASE) == TS72XX_MODEL_TS7200;
67}
68
69static inline int board_is_ts7250(void)
70{
71 return __raw_readb(TS72XX_MODEL_VIRT_BASE) == TS72XX_MODEL_TS7250;
72}
73
74static inline int board_is_ts7260(void)
75{
76 return __raw_readb(TS72XX_MODEL_VIRT_BASE) == TS72XX_MODEL_TS7260;
77}
78
79static inline int is_max197_installed(void)
80{
81 return !!(__raw_readb(TS72XX_OPTIONS_VIRT_BASE) &
82 TS72XX_OPTIONS_MAX197);
83}
84
85static inline int is_ts9420_installed(void)
86{
87 return !!(__raw_readb(TS72XX_OPTIONS2_VIRT_BASE) &
88 TS72XX_OPTIONS2_TS9420);
89}
90#endif
diff --git a/include/asm-arm/arch-ep93xx/uncompress.h b/include/asm-arm/arch-ep93xx/uncompress.h
new file mode 100644
index 000000000000..4410d217077e
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/uncompress.h
@@ -0,0 +1,53 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/uncompress.h
3 *
4 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 */
11
12#include <asm/arch/ep93xx-regs.h>
13
14static unsigned char __raw_readb(unsigned int ptr)
15{
16 return *((volatile unsigned char *)ptr);
17}
18
19static void __raw_writeb(unsigned char value, unsigned int ptr)
20{
21 *((volatile unsigned char *)ptr) = value;
22}
23
24
25#define PHYS_UART1_DATA 0x808c0000
26#define PHYS_UART1_FLAG 0x808c0018
27#define UART1_FLAG_TXFF 0x20
28
29static __inline__ void putc(char c)
30{
31 int i;
32
33 for (i = 0; i < 1000; i++) {
34 /* Transmit fifo not full? */
35 if (!(__raw_readb(PHYS_UART1_FLAG) & UART1_FLAG_TXFF))
36 break;
37 }
38
39 __raw_writeb(c, PHYS_UART1_DATA);
40}
41
42static void putstr(const char *s)
43{
44 while (*s) {
45 putc(*s);
46 if (*s == '\n')
47 putc('\r');
48 s++;
49 }
50}
51
52#define arch_decomp_setup()
53#define arch_decomp_wdog()
diff --git a/include/asm-arm/arch-ep93xx/vmalloc.h b/include/asm-arm/arch-ep93xx/vmalloc.h
new file mode 100644
index 000000000000..205ea6b1cf5e
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/vmalloc.h
@@ -0,0 +1,5 @@
1/*
2 * linux/include/asm-arm/arch-ep93xx/vmalloc.h
3 */
4
5#define VMALLOC_END 0xfe800000
diff --git a/include/asm-arm/arch-h720x/irq.h b/include/asm-arm/arch-h720x/irq.h
deleted file mode 100644
index b3821e957aa4..000000000000
--- a/include/asm-arm/arch-h720x/irq.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 * include/asm-arm/arch-h720x/irq.h
3 *
4 * Copyright (C) 2000-2002 Jungjun Kim
5 * (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>
6 * (C) 2003 Thomas Gleixner <tglx@linutronix.de>
7 */
8
9#ifndef __ASM_ARCH_IRQ_H
10#define __ASM_ARCH_IRQ_H
11
12extern void __init h720x_init_irq (void);
13
14#endif /* __ASM_ARCH_IRQ_H */
diff --git a/include/asm-arm/arch-h720x/param.h b/include/asm-arm/arch-h720x/param.h
deleted file mode 100644
index 2b80235f9847..000000000000
--- a/include/asm-arm/arch-h720x/param.h
+++ /dev/null
@@ -1,10 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-h720x/param.h
3 *
4 * Copyright (C) 2000 Jungjun Kim
5 */
6
7#ifndef __ASM_ARCH_PARAM_H
8#define __ASM_ARCH_PARAM_H
9
10#endif
diff --git a/include/asm-arm/arch-imx/irq.h b/include/asm-arm/arch-imx/irq.h
deleted file mode 100644
index 545e065d2325..000000000000
--- a/include/asm-arm/arch-imx/irq.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-imxads/irq.h
3 *
4 * Copyright (C) 1999 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#define fixup_irq(i) (i)
diff --git a/include/asm-arm/arch-imx/param.h b/include/asm-arm/arch-imx/param.h
deleted file mode 100644
index 7c724f03333e..000000000000
--- a/include/asm-arm/arch-imx/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-imx/param.h
3 *
4 * Copyright (C) 1999 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
diff --git a/include/asm-arm/arch-integrator/debug-macro.S b/include/asm-arm/arch-integrator/debug-macro.S
index 031d30941791..85b327c352df 100644
--- a/include/asm-arm/arch-integrator/debug-macro.S
+++ b/include/asm-arm/arch-integrator/debug-macro.S
@@ -11,8 +11,6 @@
11 * 11 *
12*/ 12*/
13 13
14#include <linux/amba/serial.h>
15
16 .macro addruart,rx 14 .macro addruart,rx
17 mrc p15, 0, \rx, c1, c0 15 mrc p15, 0, \rx, c1, c0
18 tst \rx, #1 @ MMU enabled? 16 tst \rx, #1 @ MMU enabled?
@@ -21,18 +19,4 @@
21 addne \rx, \rx, #0x16000000 >> 4 19 addne \rx, \rx, #0x16000000 >> 4
22 .endm 20 .endm
23 21
24 .macro senduart,rd,rx 22#include <asm/hardware/debug-pl01x.S>
25 strb \rd, [\rx, #UART01x_DR]
26 .endm
27
28 .macro waituart,rd,rx
291001: ldr \rd, [\rx, #0x18] @ UARTFLG
30 tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
31 bne 1001b
32 .endm
33
34 .macro busyuart,rd,rx
351001: ldr \rd, [\rx, #0x18] @ UARTFLG
36 tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
37 bne 1001b
38 .endm
diff --git a/include/asm-arm/arch-integrator/param.h b/include/asm-arm/arch-integrator/param.h
deleted file mode 100644
index afa582ff3717..000000000000
--- a/include/asm-arm/arch-integrator/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-integrator/param.h
3 *
4 * Copyright (C) 1999 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
diff --git a/include/asm-arm/arch-iop3xx/debug-macro.S b/include/asm-arm/arch-iop3xx/debug-macro.S
index cc15f80ebd9a..ce007e531994 100644
--- a/include/asm-arm/arch-iop3xx/debug-macro.S
+++ b/include/asm-arm/arch-iop3xx/debug-macro.S
@@ -28,21 +28,8 @@
28#endif 28#endif
29 .endm 29 .endm
30 30
31 .macro senduart,rd,rx
32 strb \rd, [\rx]
33 .endm
34
35 .macro busyuart,rd,rx
361002: ldrb \rd, [\rx, #0x5]
37 and \rd, \rd, #0x60
38 teq \rd, #0x60
39 bne 1002b
40 .endm
41
42 .macro waituart,rd,rx
43#if !defined(CONFIG_ARCH_IQ80321) || !defined(CONFIG_ARCH_IQ31244) || !defined(CONFIG_ARCH_IQ80331) 31#if !defined(CONFIG_ARCH_IQ80321) || !defined(CONFIG_ARCH_IQ31244) || !defined(CONFIG_ARCH_IQ80331)
441001: ldrb \rd, [\rx, #0x6] 32#define FLOW_CONTROL
45 tst \rd, #0x10
46 beq 1001b
47#endif 33#endif
48 .endm 34#define UART_SHIFT 0
35#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-iop3xx/param.h b/include/asm-arm/arch-iop3xx/param.h
deleted file mode 100644
index acf404e87358..000000000000
--- a/include/asm-arm/arch-iop3xx/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-iop3xx/param.h
3 */
diff --git a/include/asm-arm/arch-ixp2000/debug-macro.S b/include/asm-arm/arch-ixp2000/debug-macro.S
index 5631e0889861..bc8b39654793 100644
--- a/include/asm-arm/arch-ixp2000/debug-macro.S
+++ b/include/asm-arm/arch-ixp2000/debug-macro.S
@@ -23,18 +23,5 @@
23#endif 23#endif
24 .endm 24 .endm
25 25
26 .macro senduart,rd,rx 26#define UART_SHIFT 2
27 strb \rd, [\rx] 27#include <asm/hardware/debug-8250.S>
28 .endm
29
30 .macro busyuart,rd,rx
311002: ldrb \rd, [\rx, #0x14]
32 tst \rd, #0x20
33 beq 1002b
34 .endm
35
36 .macro waituart,rd,rx
37 nop
38 nop
39 nop
40 .endm
diff --git a/include/asm-arm/arch-ixp2000/irq.h b/include/asm-arm/arch-ixp2000/irq.h
deleted file mode 100644
index ba00b23f9828..000000000000
--- a/include/asm-arm/arch-ixp2000/irq.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-ixp2000/irq.h
3 *
4 * Copyright (C) 2002 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#define fixup_irq(irq) (irq)
12
13
diff --git a/include/asm-arm/arch-ixp2000/ixdp2x00.h b/include/asm-arm/arch-ixp2000/ixdp2x00.h
index 229381c64283..546e2e8e27b8 100644
--- a/include/asm-arm/arch-ixp2000/ixdp2x00.h
+++ b/include/asm-arm/arch-ixp2000/ixdp2x00.h
@@ -72,12 +72,11 @@
72 72
73#ifndef __ASSEMBLY__ 73#ifndef __ASSEMBLY__
74/* 74/*
75 * Master NPU will always have flash and be PCI master. 75 * The master NPU is always PCI master.
76 * Slave NPU may or may not have flash but will never be PCI master.
77 */ 76 */
78static inline unsigned int ixdp2x00_master_npu(void) 77static inline unsigned int ixdp2x00_master_npu(void)
79{ 78{
80 return ((ixp2000_has_flash()) && (ixp2000_is_pcimaster())); 79 return !!ixp2000_is_pcimaster();
81} 80}
82 81
83/* 82/*
diff --git a/include/asm-arm/arch-ixp2000/ixp2000-regs.h b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
index 2b57f91b4ebd..ccae4bec92c5 100644
--- a/include/asm-arm/arch-ixp2000/ixp2000-regs.h
+++ b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
@@ -353,8 +353,8 @@
353 * Masks and shifts for various fields in the WTC and RTC registers. 353 * Masks and shifts for various fields in the WTC and RTC registers.
354 */ 354 */
355#define SLOWPORT_WRTC_MASK_HD 0x0003 355#define SLOWPORT_WRTC_MASK_HD 0x0003
356#define SLOWPORT_WRTC_MASK_SU 0x003c 356#define SLOWPORT_WRTC_MASK_PW 0x003c
357#define SLOWPORT_WRTC_MASK_PW 0x03c0 357#define SLOWPORT_WRTC_MASK_SU 0x03c0
358 358
359#define SLOWPORT_WRTC_SHIFT_HD 0x00 359#define SLOWPORT_WRTC_SHIFT_HD 0x00
360#define SLOWPORT_WRTC_SHIFT_SU 0x02 360#define SLOWPORT_WRTC_SHIFT_SU 0x02
diff --git a/include/asm-arm/arch-ixp2000/param.h b/include/asm-arm/arch-ixp2000/param.h
deleted file mode 100644
index 2646d9e5919d..000000000000
--- a/include/asm-arm/arch-ixp2000/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-ixp2000/param.h
3 */
diff --git a/include/asm-arm/arch-ixp2000/system.h b/include/asm-arm/arch-ixp2000/system.h
index ddbbb34b5f95..3cc9a04f68cb 100644
--- a/include/asm-arm/arch-ixp2000/system.h
+++ b/include/asm-arm/arch-ixp2000/system.h
@@ -37,7 +37,7 @@ static inline void arch_reset(char mode)
37 * to cause a complete reset of the CPU and all external devices 37 * to cause a complete reset of the CPU and all external devices
38 * and move the flash bank register back to 0. 38 * and move the flash bank register back to 0.
39 */ 39 */
40 if (machine_is_ixdp2801()) { 40 if (machine_is_ixdp2801() || machine_is_ixdp28x5()) {
41 unsigned long reset_reg = *IXDP2X01_CPLD_RESET_REG; 41 unsigned long reset_reg = *IXDP2X01_CPLD_RESET_REG;
42 42
43 reset_reg = 0x55AA0000 | (reset_reg & 0x0000FFFF); 43 reset_reg = 0x55AA0000 | (reset_reg & 0x0000FFFF);
diff --git a/include/asm-arm/arch-ixp4xx/debug-macro.S b/include/asm-arm/arch-ixp4xx/debug-macro.S
index 2e23651e217f..37bc8ef23e67 100644
--- a/include/asm-arm/arch-ixp4xx/debug-macro.S
+++ b/include/asm-arm/arch-ixp4xx/debug-macro.S
@@ -20,16 +20,5 @@
20 @ byte writes used - Big Endian. 20 @ byte writes used - Big Endian.
21 .endm 21 .endm
22 22
23 .macro senduart,rd,rx 23#define UART_SHIFT 2
24 strb \rd, [\rx] 24#include <asm/hardware/debug-8250.S>
25 .endm
26
27 .macro waituart,rd,rx
281002: ldrb \rd, [\rx, #0x14]
29 and \rd, \rd, #0x60 @ check THRE and TEMT bits
30 teq \rd, #0x60
31 bne 1002b
32 .endm
33
34 .macro busyuart,rd,rx
35 .endm
diff --git a/include/asm-arm/arch-ixp4xx/irq.h b/include/asm-arm/arch-ixp4xx/irq.h
deleted file mode 100644
index 87da70695f0a..000000000000
--- a/include/asm-arm/arch-ixp4xx/irq.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * irq.h
3 *
4 * Copyright (C) 2002 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#define fixup_irq(irq) (irq)
13
diff --git a/include/asm-arm/arch-ixp4xx/param.h b/include/asm-arm/arch-ixp4xx/param.h
deleted file mode 100644
index 8a757125e5e7..000000000000
--- a/include/asm-arm/arch-ixp4xx/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-ixp4xx/param.h
3 */
diff --git a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h
index daf9790645ca..13aee17b0475 100644
--- a/include/asm-arm/arch-ixp4xx/platform.h
+++ b/include/asm-arm/arch-ixp4xx/platform.h
@@ -38,6 +38,33 @@ extern unsigned long ixp4xx_exp_bus_size;
38#define IXP4XX_EXP_BUS_BASE(region)\ 38#define IXP4XX_EXP_BUS_BASE(region)\
39 (IXP4XX_EXP_BUS_BASE_PHYS + ((region) * ixp4xx_exp_bus_size)) 39 (IXP4XX_EXP_BUS_BASE_PHYS + ((region) * ixp4xx_exp_bus_size))
40 40
41#define IXP4XX_EXP_BUS_END(region)\
42 (IXP4XX_EXP_BUS_BASE(region) + ixp4xx_exp_bus_size - 1)
43
44/* Those macros can be used to adjust timing and configure
45 * other features for each region.
46 */
47
48#define IXP4XX_EXP_BUS_RECOVERY_T(x) (((x) & 0x0f) << 16)
49#define IXP4XX_EXP_BUS_HOLD_T(x) (((x) & 0x03) << 20)
50#define IXP4XX_EXP_BUS_STROBE_T(x) (((x) & 0x0f) << 22)
51#define IXP4XX_EXP_BUS_SETUP_T(x) (((x) & 0x03) << 26)
52#define IXP4XX_EXP_BUS_ADDR_T(x) (((x) & 0x03) << 28)
53#define IXP4XX_EXP_BUS_SIZE(x) (((x) & 0x0f) << 10)
54#define IXP4XX_EXP_BUS_CYCLES(x) (((x) & 0x03) << 14)
55
56#define IXP4XX_EXP_BUS_CS_EN (1L << 31)
57#define IXP4XX_EXP_BUS_BYTE_RD16 (1L << 6)
58#define IXP4XX_EXP_BUS_HRDY_POL (1L << 5)
59#define IXP4XX_EXP_BUS_MUX_EN (1L << 4)
60#define IXP4XX_EXP_BUS_SPLT_EN (1L << 3)
61#define IXP4XX_EXP_BUS_WR_EN (1L << 1)
62#define IXP4XX_EXP_BUS_BYTE_EN (1L << 0)
63
64#define IXP4XX_EXP_BUS_CYCLES_INTEL 0x00
65#define IXP4XX_EXP_BUS_CYCLES_MOTOROLA 0x01
66#define IXP4XX_EXP_BUS_CYCLES_HPI 0x02
67
41#define IXP4XX_FLASH_WRITABLE (0x2) 68#define IXP4XX_FLASH_WRITABLE (0x2)
42#define IXP4XX_FLASH_DEFAULT (0xbcd23c40) 69#define IXP4XX_FLASH_DEFAULT (0xbcd23c40)
43#define IXP4XX_FLASH_WRITE (0xbcd23c42) 70#define IXP4XX_FLASH_WRITE (0xbcd23c42)
diff --git a/include/asm-arm/arch-l7200/param.h b/include/asm-arm/arch-l7200/param.h
deleted file mode 100644
index 9962a12ab158..000000000000
--- a/include/asm-arm/arch-l7200/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-l7200/param.h
3 *
4 * Copyright (C) 2000 Rob Scott (rscott@mtrob.fdns.net)
5 * Steve Hill (sjhill@cotw.com)
6 *
7 * This file contains the hardware definitions for the
8 * LinkUp Systems L7200 SOC development board.
9 *
10 * Changelog:
11 * 04-21-2000 RS Created L7200 version
12 * 04-25-2000 SJH Cleaned up file
13 * 05-03-2000 SJH Change comments and rate
14 */
15
16/*
17 * See 'time.h' for how the RTC HZ rate is set
18 */
19#define HZ 128
diff --git a/include/asm-arm/arch-lh7a40x/irq.h b/include/asm-arm/arch-lh7a40x/irq.h
deleted file mode 100644
index 0f5f0b10f6ca..000000000000
--- a/include/asm-arm/arch-lh7a40x/irq.h
+++ /dev/null
@@ -1,11 +0,0 @@
1/* include/asm-arm/arch-lh7a40x/irq.h
2 *
3 * Copyright (C) 2004 Logic Product Development
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 */
10
11void __init lh7a40x_init_board_irq (void);
diff --git a/include/asm-arm/arch-lh7a40x/param.h b/include/asm-arm/arch-lh7a40x/param.h
deleted file mode 100644
index acad0bc5deba..000000000000
--- a/include/asm-arm/arch-lh7a40x/param.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/* include/asm-arm/arch-lh7a40x/param.h
2 *
3 * Copyright (C) 2004 Coastal Environmental Systems
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 */
diff --git a/include/asm-arm/arch-omap/param.h b/include/asm-arm/arch-omap/param.h
deleted file mode 100644
index face9ad41e97..000000000000
--- a/include/asm-arm/arch-omap/param.h
+++ /dev/null
@@ -1,8 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-omap/param.h
3 *
4 */
5
6#ifdef CONFIG_OMAP_32K_TIMER_HZ
7#define HZ CONFIG_OMAP_32K_TIMER_HZ
8#endif
diff --git a/include/asm-arm/arch-pxa/debug-macro.S b/include/asm-arm/arch-pxa/debug-macro.S
index b6ec68879176..9012cbc0ad8b 100644
--- a/include/asm-arm/arch-pxa/debug-macro.S
+++ b/include/asm-arm/arch-pxa/debug-macro.S
@@ -21,18 +21,5 @@
21 orr \rx, \rx, #0x00100000 21 orr \rx, \rx, #0x00100000
22 .endm 22 .endm
23 23
24 .macro senduart,rd,rx 24#define UART_SHIFT 2
25 str \rd, [\rx, #0] 25#include <asm/hardware/debug-8250.S>
26 .endm
27
28 .macro busyuart,rd,rx
291002: ldr \rd, [\rx, #0x14]
30 tst \rd, #(1 << 6)
31 beq 1002b
32 .endm
33
34 .macro waituart,rd,rx
351001: ldr \rd, [\rx, #0x14]
36 tst \rd, #(1 << 5)
37 beq 1001b
38 .endm
diff --git a/include/asm-arm/arch-pxa/irq.h b/include/asm-arm/arch-pxa/irq.h
deleted file mode 100644
index 48c60f5eff6a..000000000000
--- a/include/asm-arm/arch-pxa/irq.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-pxa/irq.h
3 *
4 * Author: Nicolas Pitre
5 * Created: Jun 15, 2001
6 * Copyright: MontaVista Software Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#define fixup_irq(x) (x)
14
diff --git a/include/asm-arm/arch-pxa/param.h b/include/asm-arm/arch-pxa/param.h
deleted file mode 100644
index 3197d82d7573..000000000000
--- a/include/asm-arm/arch-pxa/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-pxa/param.h
3 */
diff --git a/include/asm-arm/arch-realview/debug-macro.S b/include/asm-arm/arch-realview/debug-macro.S
index 017ad996848d..f17efc65518a 100644
--- a/include/asm-arm/arch-realview/debug-macro.S
+++ b/include/asm-arm/arch-realview/debug-macro.S
@@ -11,8 +11,6 @@
11 * 11 *
12*/ 12*/
13 13
14#include <linux/amba/serial.h>
15
16 .macro addruart,rx 14 .macro addruart,rx
17 mrc p15, 0, \rx, c1, c0 15 mrc p15, 0, \rx, c1, c0
18 tst \rx, #1 @ MMU enabled? 16 tst \rx, #1 @ MMU enabled?
@@ -21,18 +19,4 @@
21 orr \rx, \rx, #0x00009000 19 orr \rx, \rx, #0x00009000
22 .endm 20 .endm
23 21
24 .macro senduart,rd,rx 22#include <asm/hardware/debug-pl01x.S>
25 strb \rd, [\rx, #UART01x_DR]
26 .endm
27
28 .macro waituart,rd,rx
291001: ldr \rd, [\rx, #0x18] @ UARTFLG
30 tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
31 bne 1001b
32 .endm
33
34 .macro busyuart,rd,rx
351001: ldr \rd, [\rx, #0x18] @ UARTFLG
36 tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
37 bne 1001b
38 .endm
diff --git a/include/asm-arm/arch-realview/param.h b/include/asm-arm/arch-realview/param.h
deleted file mode 100644
index 89b1235d32bd..000000000000
--- a/include/asm-arm/arch-realview/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-realview/param.h
3 *
4 * Copyright (C) 2002 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
diff --git a/include/asm-arm/arch-rpc/debug-macro.S b/include/asm-arm/arch-rpc/debug-macro.S
index 456d3d754c3d..c634c8d8f4a1 100644
--- a/include/asm-arm/arch-rpc/debug-macro.S
+++ b/include/asm-arm/arch-rpc/debug-macro.S
@@ -20,19 +20,6 @@
20 orr \rx, \rx, #0x00000fe0 20 orr \rx, \rx, #0x00000fe0
21 .endm 21 .endm
22 22
23 .macro senduart,rd,rx 23#define UART_SHIFT 2
24 strb \rd, [\rx] 24#define FLOW_CONTROL
25 .endm 25#include <asm/hardware/debug-8250.S>
26
27 .macro busyuart,rd,rx
281001: ldrb \rd, [\rx, #0x14]
29 and \rd, \rd, #0x60
30 teq \rd, #0x60
31 bne 1001b
32 .endm
33
34 .macro waituart,rd,rx
351001: ldrb \rd, [\rx, #0x18]
36 tst \rd, #0x10
37 beq 1001b
38 .endm
diff --git a/include/asm-arm/arch-rpc/param.h b/include/asm-arm/arch-rpc/param.h
deleted file mode 100644
index 721dcd658858..000000000000
--- a/include/asm-arm/arch-rpc/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-rpc/param.h
3 */
diff --git a/include/asm-arm/arch-s3c2410/osiris-cpld.h b/include/asm-arm/arch-s3c2410/osiris-cpld.h
new file mode 100644
index 000000000000..e9d1ae1f354f
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/osiris-cpld.h
@@ -0,0 +1,25 @@
1/* linux/include/asm-arm/arch-s3c2410/osiris-cpld.h
2 *
3 * (c) 2005 Simtec Electronics
4 * http://www.simtec.co.uk/products/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * OSIRIS - CPLD control constants
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#ifndef __ASM_ARCH_OSIRISCPLD_H
15#define __ASM_ARCH_OSIRISCPLD_H
16
17/* CTRL1 - NAND WP control */
18
19#define OSIRIS_CTRL1_NANDSEL (0x3)
20#define OSIRIS_CTRL1_BOOT_INT (1<<3)
21#define OSIRIS_CTRL1_PCMCIA (1<<4)
22#define OSIRIS_CTRL1_PCMCIA_nWAIT (1<<6)
23#define OSIRIS_CTRL1_PCMCIA_nIOIS16 (1<<7)
24
25#endif /* __ASM_ARCH_OSIRISCPLD_H */
diff --git a/include/asm-arm/arch-s3c2410/osiris-map.h b/include/asm-arm/arch-s3c2410/osiris-map.h
new file mode 100644
index 000000000000..7c4b0cd2d14d
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/osiris-map.h
@@ -0,0 +1,41 @@
1/* linux/include/asm-arm/arch-s3c2410/osiris-map.h
2 *
3 * (c) 2005 Simtec Electronics
4 * http://www.simtec.co.uk/products/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * OSIRIS - Memory map definitions
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * Changelog:
14*/
15
16/* needs arch/map.h including with this */
17
18#ifndef __ASM_ARCH_OSIRISMAP_H
19#define __ASM_ARCH_OSIRISMAP_H
20
21/* start peripherals off after the S3C2410 */
22
23#define OSIRIS_IOADDR(x) (S3C2410_ADDR((x) + 0x05000000))
24
25#define OSIRIS_PA_CPLD (S3C2410_CS1 | (3<<25))
26
27/* we put the CPLD registers next, to get them out of the way */
28
29#define OSIRIS_VA_CTRL1 OSIRIS_IOADDR(0x00000000) /* 0x01300000 */
30#define OSIRIS_PA_CTRL1 (OSIRIS_PA_CPLD)
31
32#define OSIRIS_VA_CTRL2 OSIRIS_IOADDR(0x00100000) /* 0x01400000 */
33#define OSIRIS_PA_CTRL2 (OSIRIS_PA_CPLD + (1<<24))
34
35#define OSIRIS_VA_CTRL3 OSIRIS_IOADDR(0x00200000) /* 0x01500000 */
36#define OSIRIS_PA_CTRL3 (OSIRIS_PA_CPLD + (2<<24))
37
38#define OSIRIS_VA_CTRL4 OSIRIS_IOADDR(0x00300000) /* 0x01600000 */
39#define OSIRIS_PA_CTRL4 (OSIRIS_PA_CPLD + (3<<24))
40
41#endif /* __ASM_ARCH_OSIRISMAP_H */
diff --git a/include/asm-arm/arch-s3c2410/param.h b/include/asm-arm/arch-s3c2410/param.h
deleted file mode 100644
index 483d3f149883..000000000000
--- a/include/asm-arm/arch-s3c2410/param.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/* linux/include/asm-arm/arch-s3c2410/param.h
2 *
3 * (c) 2003 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - Machine parameters
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Changelog:
13 * 02-Sep-2003 BJD Created file
14 * 12-Mar-2004 BJD Added include protection
15*/
16
17#ifndef __ASM_ARCH_PARAM_H
18#define __ASM_ARCH_PARAM_H
19
20/* we cannot get our timer down to 100Hz with the setup as is, but we can
21 * manage 200 clock ticks per second... if this is a problem, we can always
22 * add a software pre-scaler to the evil timer systems.
23*/
24
25#define HZ 200
26
27#endif /* __ASM_ARCH_PARAM_H */
diff --git a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
index 9697f93afe74..d2574084697f 100644
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h
@@ -979,6 +979,7 @@
979#define S3C2410_MISCCR_CLK0_HCLK (3<<4) 979#define S3C2410_MISCCR_CLK0_HCLK (3<<4)
980#define S3C2410_MISCCR_CLK0_PCLK (4<<4) 980#define S3C2410_MISCCR_CLK0_PCLK (4<<4)
981#define S3C2410_MISCCR_CLK0_DCLK0 (5<<4) 981#define S3C2410_MISCCR_CLK0_DCLK0 (5<<4)
982#define S3C2410_MISCCR_CLK0_MASK (7<<4)
982 983
983#define S3C2410_MISCCR_CLK1_MPLL (0<<8) 984#define S3C2410_MISCCR_CLK1_MPLL (0<<8)
984#define S3C2410_MISCCR_CLK1_UPLL (1<<8) 985#define S3C2410_MISCCR_CLK1_UPLL (1<<8)
@@ -986,6 +987,7 @@
986#define S3C2410_MISCCR_CLK1_HCLK (3<<8) 987#define S3C2410_MISCCR_CLK1_HCLK (3<<8)
987#define S3C2410_MISCCR_CLK1_PCLK (4<<8) 988#define S3C2410_MISCCR_CLK1_PCLK (4<<8)
988#define S3C2410_MISCCR_CLK1_DCLK1 (5<<8) 989#define S3C2410_MISCCR_CLK1_DCLK1 (5<<8)
990#define S3C2410_MISCCR_CLK1_MASK (7<<8)
989 991
990#define S3C2410_MISCCR_USBSUSPND0 (1<<12) 992#define S3C2410_MISCCR_USBSUSPND0 (1<<12)
991#define S3C2410_MISCCR_USBSUSPND1 (1<<13) 993#define S3C2410_MISCCR_USBSUSPND1 (1<<13)
diff --git a/include/asm-arm/arch-sa1100/debug-macro.S b/include/asm-arm/arch-sa1100/debug-macro.S
index 755fa3453862..267c317a7408 100644
--- a/include/asm-arm/arch-sa1100/debug-macro.S
+++ b/include/asm-arm/arch-sa1100/debug-macro.S
@@ -10,6 +10,7 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 * 11 *
12*/ 12*/
13#include <asm/hardware.h>
13 14
14 .macro addruart,rx 15 .macro addruart,rx
15 mrc p15, 0, \rx, c1, c0 16 mrc p15, 0, \rx, c1, c0
diff --git a/include/asm-arm/arch-sa1100/param.h b/include/asm-arm/arch-sa1100/param.h
deleted file mode 100644
index 867488909ecd..000000000000
--- a/include/asm-arm/arch-sa1100/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-sa1100/param.h
3 */
diff --git a/include/asm-arm/arch-shark/param.h b/include/asm-arm/arch-shark/param.h
deleted file mode 100644
index 997eeb71de00..000000000000
--- a/include/asm-arm/arch-shark/param.h
+++ /dev/null
@@ -1,5 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-shark/param.h
3 *
4 * by Alexander Schulz
5 */
diff --git a/include/asm-arm/arch-versatile/debug-macro.S b/include/asm-arm/arch-versatile/debug-macro.S
index ef6167116dbb..fe106d184e62 100644
--- a/include/asm-arm/arch-versatile/debug-macro.S
+++ b/include/asm-arm/arch-versatile/debug-macro.S
@@ -11,8 +11,6 @@
11 * 11 *
12*/ 12*/
13 13
14#include <linux/amba/serial.h>
15
16 .macro addruart,rx 14 .macro addruart,rx
17 mrc p15, 0, \rx, c1, c0 15 mrc p15, 0, \rx, c1, c0
18 tst \rx, #1 @ MMU enabled? 16 tst \rx, #1 @ MMU enabled?
@@ -22,18 +20,4 @@
22 orr \rx, \rx, #0x00001000 20 orr \rx, \rx, #0x00001000
23 .endm 21 .endm
24 22
25 .macro senduart,rd,rx 23#include <asm/hardware/debug-pl01x.S>
26 strb \rd, [\rx, #UART01x_DR]
27 .endm
28
29 .macro waituart,rd,rx
301001: ldr \rd, [\rx, #0x18] @ UARTFLG
31 tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
32 bne 1001b
33 .endm
34
35 .macro busyuart,rd,rx
361001: ldr \rd, [\rx, #0x18] @ UARTFLG
37 tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
38 bne 1001b
39 .endm
diff --git a/include/asm-arm/arch-versatile/param.h b/include/asm-arm/arch-versatile/param.h
deleted file mode 100644
index 34b897335f87..000000000000
--- a/include/asm-arm/arch-versatile/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-versatile/param.h
3 *
4 * Copyright (C) 2002 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
diff --git a/include/asm-arm/delay.h b/include/asm-arm/delay.h
index 1704360e9699..b2deda181549 100644
--- a/include/asm-arm/delay.h
+++ b/include/asm-arm/delay.h
@@ -6,6 +6,8 @@
6#ifndef __ASM_ARM_DELAY_H 6#ifndef __ASM_ARM_DELAY_H
7#define __ASM_ARM_DELAY_H 7#define __ASM_ARM_DELAY_H
8 8
9#include <asm/param.h> /* HZ */
10
9extern void __delay(int loops); 11extern void __delay(int loops);
10 12
11/* 13/*
@@ -13,7 +15,7 @@ extern void __delay(int loops);
13 * it, it means that you're calling udelay() with an out of range value. 15 * it, it means that you're calling udelay() with an out of range value.
14 * 16 *
15 * With currently imposed limits, this means that we support a max delay 17 * With currently imposed limits, this means that we support a max delay
16 * of 2000us and 671 bogomips 18 * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
17 */ 19 */
18extern void __bad_udelay(void); 20extern void __bad_udelay(void);
19 21
@@ -32,10 +34,10 @@ extern void __const_udelay(unsigned long);
32 34
33#define MAX_UDELAY_MS 2 35#define MAX_UDELAY_MS 2
34 36
35#define udelay(n) \ 37#define udelay(n) \
36 (__builtin_constant_p(n) ? \ 38 (__builtin_constant_p(n) ? \
37 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \ 39 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
38 __const_udelay((n) * 0x68dbul)) : \ 40 __const_udelay((n) * ((2199023U*HZ)>>11))) : \
39 __udelay(n)) 41 __udelay(n))
40 42
41#endif /* defined(_ARM_DELAY_H) */ 43#endif /* defined(_ARM_DELAY_H) */
diff --git a/include/asm-arm/hardware/debug-8250.S b/include/asm-arm/hardware/debug-8250.S
new file mode 100644
index 000000000000..4594fea91ec1
--- /dev/null
+++ b/include/asm-arm/hardware/debug-8250.S
@@ -0,0 +1,29 @@
1/*
2 * linux/include/asm-arm/hardware/debug-8250.h
3 *
4 * Copyright (C) 1994-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/serial_reg.h>
11
12 .macro senduart,rd,rx
13 strb \rd, [\rx, #UART_TX << UART_SHIFT]
14 .endm
15
16 .macro busyuart,rd,rx
171002: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT]
18 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
19 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
20 bne 1002b
21 .endm
22
23 .macro waituart,rd,rx
24#ifdef FLOW_CONTROL
251001: ldrb \rd, [\rx, #UART_MSR << UART_SHIFT]
26 tst \rd, #UART_MSR_CTS
27 beq 1001b
28#endif
29 .endm
diff --git a/include/asm-arm/hardware/debug-pl01x.S b/include/asm-arm/hardware/debug-pl01x.S
new file mode 100644
index 000000000000..db0d0f7de5e9
--- /dev/null
+++ b/include/asm-arm/hardware/debug-pl01x.S
@@ -0,0 +1,29 @@
1/* linux/include/asm-arm/arch-integrator/debug-macro.S
2 *
3 * Debugging macro include header
4 *
5 * Copyright (C) 1994-1999 Russell King
6 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12*/
13#include <linux/amba/serial.h>
14
15 .macro senduart,rd,rx
16 strb \rd, [\rx, #UART01x_DR]
17 .endm
18
19 .macro waituart,rd,rx
201001: ldr \rd, [\rx, #UART01x_FR]
21 tst \rd, #UART01x_FR_TXFF
22 bne 1001b
23 .endm
24
25 .macro busyuart,rd,rx
261001: ldr \rd, [\rx, #UART01x_FR]
27 tst \rd, #UART01x_FR_BUSY
28 bne 1001b
29 .endm
diff --git a/include/asm-arm/arch-ixp2000/uengine.h b/include/asm-arm/hardware/uengine.h
index b442d65c6593..b442d65c6593 100644
--- a/include/asm-arm/arch-ixp2000/uengine.h
+++ b/include/asm-arm/hardware/uengine.h
diff --git a/include/asm-arm/hardware/vic.h b/include/asm-arm/hardware/vic.h
index 81825eb54c9e..ed9ca3736a0b 100644
--- a/include/asm-arm/hardware/vic.h
+++ b/include/asm-arm/hardware/vic.h
@@ -39,7 +39,7 @@
39#define VIC_VECT_CNTL_ENABLE (1 << 5) 39#define VIC_VECT_CNTL_ENABLE (1 << 5)
40 40
41#ifndef __ASSEMBLY__ 41#ifndef __ASSEMBLY__
42void vic_init(void __iomem *base, u32 vic_sources); 42void vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources);
43#endif 43#endif
44 44
45#endif 45#endif
diff --git a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
index 2cd57b4d64d9..fd2f9bf4dcc6 100644
--- a/include/asm-arm/mach/arch.h
+++ b/include/asm-arm/mach/arch.h
@@ -10,19 +10,16 @@
10 10
11#ifndef __ASSEMBLY__ 11#ifndef __ASSEMBLY__
12 12
13#include <linux/compiler.h>
14
15struct tag; 13struct tag;
16struct meminfo; 14struct meminfo;
17struct sys_timer; 15struct sys_timer;
18 16
19struct machine_desc { 17struct machine_desc {
20 /* 18 /*
21 * Note! The first five elements are used 19 * Note! The first four elements are used
22 * by assembler code in head-armv.S 20 * by assembler code in head-armv.S
23 */ 21 */
24 unsigned int nr; /* architecture number */ 22 unsigned int nr; /* architecture number */
25 unsigned int __deprecated phys_ram; /* start of physical ram */
26 unsigned int phys_io; /* start of physical io */ 23 unsigned int phys_io; /* start of physical io */
27 unsigned int io_pg_offst; /* byte offset for io 24 unsigned int io_pg_offst; /* byte offset for io
28 * page tabe entry */ 25 * page tabe entry */
diff --git a/include/asm-arm/mach/irq.h b/include/asm-arm/mach/irq.h
index 0ce6ca588d8c..d4d420ecf3a8 100644
--- a/include/asm-arm/mach/irq.h
+++ b/include/asm-arm/mach/irq.h
@@ -61,7 +61,7 @@ struct irqdesc {
61 struct irqchip *chip; 61 struct irqchip *chip;
62 struct irqaction *action; 62 struct irqaction *action;
63 struct list_head pend; 63 struct list_head pend;
64 void *chipdata; 64 void __iomem *base;
65 void *data; 65 void *data;
66 unsigned int disable_depth; 66 unsigned int disable_depth;
67 67
@@ -74,6 +74,7 @@ struct irqdesc {
74 unsigned int noautoenable : 1; /* don't automatically enable IRQ */ 74 unsigned int noautoenable : 1; /* don't automatically enable IRQ */
75 unsigned int unused :25; 75 unsigned int unused :25;
76 76
77 unsigned int irqs_unhandled;
77 struct proc_dir_entry *procdir; 78 struct proc_dir_entry *procdir;
78 79
79#ifdef CONFIG_SMP 80#ifdef CONFIG_SMP
@@ -113,8 +114,8 @@ void __set_irq_handler(unsigned int irq, irq_handler_t, int);
113#define set_irq_handler(irq,handler) __set_irq_handler(irq,handler,0) 114#define set_irq_handler(irq,handler) __set_irq_handler(irq,handler,0)
114#define set_irq_chained_handler(irq,handler) __set_irq_handler(irq,handler,1) 115#define set_irq_chained_handler(irq,handler) __set_irq_handler(irq,handler,1)
115#define set_irq_data(irq,d) do { irq_desc[irq].data = d; } while (0) 116#define set_irq_data(irq,d) do { irq_desc[irq].data = d; } while (0)
116#define set_irq_chipdata(irq,d) do { irq_desc[irq].chipdata = d; } while (0) 117#define set_irq_chipdata(irq,d) do { irq_desc[irq].base = d; } while (0)
117#define get_irq_chipdata(irq) (irq_desc[irq].chipdata) 118#define get_irq_chipdata(irq) (irq_desc[irq].base)
118 119
119void set_irq_chip(unsigned int irq, struct irqchip *); 120void set_irq_chip(unsigned int irq, struct irqchip *);
120void set_irq_flags(unsigned int irq, unsigned int flags); 121void set_irq_flags(unsigned int irq, unsigned int flags);
diff --git a/include/asm-arm/param.h b/include/asm-arm/param.h
index 94223d4d7e88..15806468ba72 100644
--- a/include/asm-arm/param.h
+++ b/include/asm-arm/param.h
@@ -11,12 +11,7 @@
11#define __ASM_PARAM_H 11#define __ASM_PARAM_H
12 12
13#ifdef __KERNEL__ 13#ifdef __KERNEL__
14# include <asm/arch/param.h> /* for kernel version of HZ */ 14# define HZ CONFIG_HZ /* Internal kernel timer frequency */
15
16# ifndef HZ
17# define HZ 100 /* Internal kernel timer frequency */
18# endif
19
20# define USER_HZ 100 /* User interfaces are in "ticks" */ 15# define USER_HZ 100 /* User interfaces are in "ticks" */
21# define CLOCKS_PER_SEC (USER_HZ) /* like times() */ 16# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
22#else 17#else
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 400c2b41896e..1a565a9d2fa7 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -7,7 +7,7 @@
7#ifdef CONFIG_BUG 7#ifdef CONFIG_BUG
8#ifndef HAVE_ARCH_BUG 8#ifndef HAVE_ARCH_BUG
9#define BUG() do { \ 9#define BUG() do { \
10 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 10 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
11 panic("BUG!"); \ 11 panic("BUG!"); \
12} while (0) 12} while (0)
13#endif 13#endif
@@ -19,7 +19,7 @@
19#ifndef HAVE_ARCH_WARN_ON 19#ifndef HAVE_ARCH_WARN_ON
20#define WARN_ON(condition) do { \ 20#define WARN_ON(condition) do { \
21 if (unlikely((condition)!=0)) { \ 21 if (unlikely((condition)!=0)) { \
22 printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ 22 printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \
23 dump_stack(); \ 23 dump_stack(); \
24 } \ 24 } \
25} while (0) 25} while (0)
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 9044aeb37828..78cf45547e31 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -19,10 +19,9 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
19#define percpu_modcopy(pcpudst, src, size) \ 19#define percpu_modcopy(pcpudst, src, size) \
20do { \ 20do { \
21 unsigned int __i; \ 21 unsigned int __i; \
22 for (__i = 0; __i < NR_CPUS; __i++) \ 22 for_each_cpu(__i) \
23 if (cpu_possible(__i)) \ 23 memcpy((pcpudst)+__per_cpu_offset[__i], \
24 memcpy((pcpudst)+__per_cpu_offset[__i], \ 24 (src), (size)); \
25 (src), (size)); \
26} while (0) 25} while (0)
27#else /* ! SMP */ 26#else /* ! SMP */
28 27
diff --git a/include/asm-i386/alternative.h b/include/asm-i386/alternative.h
new file mode 100644
index 000000000000..e201decea0c9
--- /dev/null
+++ b/include/asm-i386/alternative.h
@@ -0,0 +1,129 @@
1#ifndef _I386_ALTERNATIVE_H
2#define _I386_ALTERNATIVE_H
3
4#ifdef __KERNEL__
5
6struct alt_instr {
7 u8 *instr; /* original instruction */
8 u8 *replacement;
9 u8 cpuid; /* cpuid bit set for replacement */
10 u8 instrlen; /* length of original instruction */
11 u8 replacementlen; /* length of new instruction, <= instrlen */
12 u8 pad;
13};
14
15extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
16
17struct module;
18extern void alternatives_smp_module_add(struct module *mod, char *name,
19 void *locks, void *locks_end,
20 void *text, void *text_end);
21extern void alternatives_smp_module_del(struct module *mod);
22extern void alternatives_smp_switch(int smp);
23
24#endif
25
26/*
27 * Alternative instructions for different CPU types or capabilities.
28 *
29 * This allows to use optimized instructions even on generic binary
30 * kernels.
31 *
32 * length of oldinstr must be longer or equal the length of newinstr
33 * It can be padded with nops as needed.
34 *
35 * For non barrier like inlines please define new variants
36 * without volatile and memory clobber.
37 */
38#define alternative(oldinstr, newinstr, feature) \
39 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
40 ".section .altinstructions,\"a\"\n" \
41 " .align 4\n" \
42 " .long 661b\n" /* label */ \
43 " .long 663f\n" /* new instruction */ \
44 " .byte %c0\n" /* feature bit */ \
45 " .byte 662b-661b\n" /* sourcelen */ \
46 " .byte 664f-663f\n" /* replacementlen */ \
47 ".previous\n" \
48 ".section .altinstr_replacement,\"ax\"\n" \
49 "663:\n\t" newinstr "\n664:\n" /* replacement */\
50 ".previous" :: "i" (feature) : "memory")
51
52/*
53 * Alternative inline assembly with input.
54 *
55 * Pecularities:
56 * No memory clobber here.
57 * Argument numbers start with 1.
58 * Best is to use constraints that are fixed size (like (%1) ... "r")
59 * If you use variable sized constraints like "m" or "g" in the
60 * replacement maake sure to pad to the worst case length.
61 */
62#define alternative_input(oldinstr, newinstr, feature, input...) \
63 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
64 ".section .altinstructions,\"a\"\n" \
65 " .align 4\n" \
66 " .long 661b\n" /* label */ \
67 " .long 663f\n" /* new instruction */ \
68 " .byte %c0\n" /* feature bit */ \
69 " .byte 662b-661b\n" /* sourcelen */ \
70 " .byte 664f-663f\n" /* replacementlen */ \
71 ".previous\n" \
72 ".section .altinstr_replacement,\"ax\"\n" \
73 "663:\n\t" newinstr "\n664:\n" /* replacement */\
74 ".previous" :: "i" (feature), ##input)
75
76/*
77 * Alternative inline assembly for SMP.
78 *
79 * alternative_smp() takes two versions (SMP first, UP second) and is
80 * for more complex stuff such as spinlocks.
81 *
82 * The LOCK_PREFIX macro defined here replaces the LOCK and
83 * LOCK_PREFIX macros used everywhere in the source tree.
84 *
85 * SMP alternatives use the same data structures as the other
86 * alternatives and the X86_FEATURE_UP flag to indicate the case of a
87 * UP system running a SMP kernel. The existing apply_alternatives()
88 * works fine for patching a SMP kernel for UP.
89 *
90 * The SMP alternative tables can be kept after boot and contain both
91 * UP and SMP versions of the instructions to allow switching back to
92 * SMP at runtime, when hotplugging in a new CPU, which is especially
93 * useful in virtualized environments.
94 *
95 * The very common lock prefix is handled as special case in a
96 * separate table which is a pure address list without replacement ptr
97 * and size information. That keeps the table sizes small.
98 */
99
100#ifdef CONFIG_SMP
101#define alternative_smp(smpinstr, upinstr, args...) \
102 asm volatile ("661:\n\t" smpinstr "\n662:\n" \
103 ".section .smp_altinstructions,\"a\"\n" \
104 " .align 4\n" \
105 " .long 661b\n" /* label */ \
106 " .long 663f\n" /* new instruction */ \
107 " .byte 0x68\n" /* X86_FEATURE_UP */ \
108 " .byte 662b-661b\n" /* sourcelen */ \
109 " .byte 664f-663f\n" /* replacementlen */ \
110 ".previous\n" \
111 ".section .smp_altinstr_replacement,\"awx\"\n" \
112 "663:\n\t" upinstr "\n" /* replacement */ \
113 "664:\n\t.fill 662b-661b,1,0x42\n" /* space for original */ \
114 ".previous" : args)
115
116#define LOCK_PREFIX \
117 ".section .smp_locks,\"a\"\n" \
118 " .align 4\n" \
119 " .long 661f\n" /* address */ \
120 ".previous\n" \
121 "661:\n\tlock; "
122
123#else /* ! CONFIG_SMP */
124#define alternative_smp(smpinstr, upinstr, args...) \
125 asm volatile (upinstr : args)
126#define LOCK_PREFIX ""
127#endif
128
129#endif /* _I386_ALTERNATIVE_H */
diff --git a/include/asm-i386/arch_hooks.h b/include/asm-i386/arch_hooks.h
index 28b96a6fb9fa..238cf4275b96 100644
--- a/include/asm-i386/arch_hooks.h
+++ b/include/asm-i386/arch_hooks.h
@@ -24,4 +24,7 @@ extern void trap_init_hook(void);
24extern void time_init_hook(void); 24extern void time_init_hook(void);
25extern void mca_nmi_hook(void); 25extern void mca_nmi_hook(void);
26 26
27extern int setup_early_printk(char *);
28extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2)));
29
27#endif 30#endif
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
index de649d3aa2d4..22d80ece95cb 100644
--- a/include/asm-i386/atomic.h
+++ b/include/asm-i386/atomic.h
@@ -10,12 +10,6 @@
10 * resource counting etc.. 10 * resource counting etc..
11 */ 11 */
12 12
13#ifdef CONFIG_SMP
14#define LOCK "lock ; "
15#else
16#define LOCK ""
17#endif
18
19/* 13/*
20 * Make sure gcc doesn't try to be clever and move things around 14 * Make sure gcc doesn't try to be clever and move things around
21 * on us. We need to use _exactly_ the address the user gave us, 15 * on us. We need to use _exactly_ the address the user gave us,
@@ -52,7 +46,7 @@ typedef struct { volatile int counter; } atomic_t;
52static __inline__ void atomic_add(int i, atomic_t *v) 46static __inline__ void atomic_add(int i, atomic_t *v)
53{ 47{
54 __asm__ __volatile__( 48 __asm__ __volatile__(
55 LOCK "addl %1,%0" 49 LOCK_PREFIX "addl %1,%0"
56 :"=m" (v->counter) 50 :"=m" (v->counter)
57 :"ir" (i), "m" (v->counter)); 51 :"ir" (i), "m" (v->counter));
58} 52}
@@ -67,7 +61,7 @@ static __inline__ void atomic_add(int i, atomic_t *v)
67static __inline__ void atomic_sub(int i, atomic_t *v) 61static __inline__ void atomic_sub(int i, atomic_t *v)
68{ 62{
69 __asm__ __volatile__( 63 __asm__ __volatile__(
70 LOCK "subl %1,%0" 64 LOCK_PREFIX "subl %1,%0"
71 :"=m" (v->counter) 65 :"=m" (v->counter)
72 :"ir" (i), "m" (v->counter)); 66 :"ir" (i), "m" (v->counter));
73} 67}
@@ -86,7 +80,7 @@ static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
86 unsigned char c; 80 unsigned char c;
87 81
88 __asm__ __volatile__( 82 __asm__ __volatile__(
89 LOCK "subl %2,%0; sete %1" 83 LOCK_PREFIX "subl %2,%0; sete %1"
90 :"=m" (v->counter), "=qm" (c) 84 :"=m" (v->counter), "=qm" (c)
91 :"ir" (i), "m" (v->counter) : "memory"); 85 :"ir" (i), "m" (v->counter) : "memory");
92 return c; 86 return c;
@@ -101,7 +95,7 @@ static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
101static __inline__ void atomic_inc(atomic_t *v) 95static __inline__ void atomic_inc(atomic_t *v)
102{ 96{
103 __asm__ __volatile__( 97 __asm__ __volatile__(
104 LOCK "incl %0" 98 LOCK_PREFIX "incl %0"
105 :"=m" (v->counter) 99 :"=m" (v->counter)
106 :"m" (v->counter)); 100 :"m" (v->counter));
107} 101}
@@ -115,7 +109,7 @@ static __inline__ void atomic_inc(atomic_t *v)
115static __inline__ void atomic_dec(atomic_t *v) 109static __inline__ void atomic_dec(atomic_t *v)
116{ 110{
117 __asm__ __volatile__( 111 __asm__ __volatile__(
118 LOCK "decl %0" 112 LOCK_PREFIX "decl %0"
119 :"=m" (v->counter) 113 :"=m" (v->counter)
120 :"m" (v->counter)); 114 :"m" (v->counter));
121} 115}
@@ -133,7 +127,7 @@ static __inline__ int atomic_dec_and_test(atomic_t *v)
133 unsigned char c; 127 unsigned char c;
134 128
135 __asm__ __volatile__( 129 __asm__ __volatile__(
136 LOCK "decl %0; sete %1" 130 LOCK_PREFIX "decl %0; sete %1"
137 :"=m" (v->counter), "=qm" (c) 131 :"=m" (v->counter), "=qm" (c)
138 :"m" (v->counter) : "memory"); 132 :"m" (v->counter) : "memory");
139 return c != 0; 133 return c != 0;
@@ -152,7 +146,7 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)
152 unsigned char c; 146 unsigned char c;
153 147
154 __asm__ __volatile__( 148 __asm__ __volatile__(
155 LOCK "incl %0; sete %1" 149 LOCK_PREFIX "incl %0; sete %1"
156 :"=m" (v->counter), "=qm" (c) 150 :"=m" (v->counter), "=qm" (c)
157 :"m" (v->counter) : "memory"); 151 :"m" (v->counter) : "memory");
158 return c != 0; 152 return c != 0;
@@ -172,7 +166,7 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
172 unsigned char c; 166 unsigned char c;
173 167
174 __asm__ __volatile__( 168 __asm__ __volatile__(
175 LOCK "addl %2,%0; sets %1" 169 LOCK_PREFIX "addl %2,%0; sets %1"
176 :"=m" (v->counter), "=qm" (c) 170 :"=m" (v->counter), "=qm" (c)
177 :"ir" (i), "m" (v->counter) : "memory"); 171 :"ir" (i), "m" (v->counter) : "memory");
178 return c; 172 return c;
@@ -195,7 +189,7 @@ static __inline__ int atomic_add_return(int i, atomic_t *v)
195 /* Modern 486+ processor */ 189 /* Modern 486+ processor */
196 __i = i; 190 __i = i;
197 __asm__ __volatile__( 191 __asm__ __volatile__(
198 LOCK "xaddl %0, %1;" 192 LOCK_PREFIX "xaddl %0, %1;"
199 :"=r"(i) 193 :"=r"(i)
200 :"m"(v->counter), "0"(i)); 194 :"m"(v->counter), "0"(i));
201 return i + __i; 195 return i + __i;
@@ -231,8 +225,14 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
231({ \ 225({ \
232 int c, old; \ 226 int c, old; \
233 c = atomic_read(v); \ 227 c = atomic_read(v); \
234 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 228 for (;;) { \
229 if (unlikely(c == (u))) \
230 break; \
231 old = atomic_cmpxchg((v), c, c + (a)); \
232 if (likely(old == c)) \
233 break; \
235 c = old; \ 234 c = old; \
235 } \
236 c != (u); \ 236 c != (u); \
237}) 237})
238#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 238#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
@@ -242,11 +242,11 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
242 242
243/* These are x86-specific, used by some header files */ 243/* These are x86-specific, used by some header files */
244#define atomic_clear_mask(mask, addr) \ 244#define atomic_clear_mask(mask, addr) \
245__asm__ __volatile__(LOCK "andl %0,%1" \ 245__asm__ __volatile__(LOCK_PREFIX "andl %0,%1" \
246: : "r" (~(mask)),"m" (*addr) : "memory") 246: : "r" (~(mask)),"m" (*addr) : "memory")
247 247
248#define atomic_set_mask(mask, addr) \ 248#define atomic_set_mask(mask, addr) \
249__asm__ __volatile__(LOCK "orl %0,%1" \ 249__asm__ __volatile__(LOCK_PREFIX "orl %0,%1" \
250: : "r" (mask),"m" (*(addr)) : "memory") 250: : "r" (mask),"m" (*(addr)) : "memory")
251 251
252/* Atomic operations are already serializing on x86 */ 252/* Atomic operations are already serializing on x86 */
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index 88e6ca248cd7..7d20b95edb3b 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -7,6 +7,7 @@
7 7
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/compiler.h> 9#include <linux/compiler.h>
10#include <asm/alternative.h>
10 11
11/* 12/*
12 * These have to be done with inline assembly: that way the bit-setting 13 * These have to be done with inline assembly: that way the bit-setting
@@ -16,12 +17,6 @@
16 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 17 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
17 */ 18 */
18 19
19#ifdef CONFIG_SMP
20#define LOCK_PREFIX "lock ; "
21#else
22#define LOCK_PREFIX ""
23#endif
24
25#define ADDR (*(volatile long *) addr) 20#define ADDR (*(volatile long *) addr)
26 21
27/** 22/**
diff --git a/include/asm-i386/cache.h b/include/asm-i386/cache.h
index 615911e5bd24..ca15c9c665cf 100644
--- a/include/asm-i386/cache.h
+++ b/include/asm-i386/cache.h
@@ -10,4 +10,6 @@
10#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) 10#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 11#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12 12
13#define __read_mostly __attribute__((__section__(".data.read_mostly")))
14
13#endif 15#endif
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index c4ec2a4d8fdf..5c0b5876b931 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -70,6 +70,7 @@
70#define X86_FEATURE_P3 (3*32+ 6) /* P3 */ 70#define X86_FEATURE_P3 (3*32+ 6) /* P3 */
71#define X86_FEATURE_P4 (3*32+ 7) /* P4 */ 71#define X86_FEATURE_P4 (3*32+ 7) /* P4 */
72#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */ 72#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
73#define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */
73 74
74/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ 75/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
75#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */ 76#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
diff --git a/include/asm-i386/mach-default/do_timer.h b/include/asm-i386/mach-default/do_timer.h
index 56211414fc95..6312c3e79814 100644
--- a/include/asm-i386/mach-default/do_timer.h
+++ b/include/asm-i386/mach-default/do_timer.h
@@ -18,7 +18,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
18{ 18{
19 do_timer(regs); 19 do_timer(regs);
20#ifndef CONFIG_SMP 20#ifndef CONFIG_SMP
21 update_process_times(user_mode(regs)); 21 update_process_times(user_mode_vm(regs));
22#endif 22#endif
23/* 23/*
24 * In the SMP case we use the local APIC timer interrupt to do the 24 * In the SMP case we use the local APIC timer interrupt to do the
diff --git a/include/asm-i386/mach-es7000/mach_mpparse.h b/include/asm-i386/mach-es7000/mach_mpparse.h
index 4a0637a3e208..99f66be240be 100644
--- a/include/asm-i386/mach-es7000/mach_mpparse.h
+++ b/include/asm-i386/mach-es7000/mach_mpparse.h
@@ -30,7 +30,8 @@ static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
30 return 0; 30 return 0;
31} 31}
32 32
33static inline int es7000_check_dsdt() 33#ifdef CONFIG_ACPI
34static inline int es7000_check_dsdt(void)
34{ 35{
35 struct acpi_table_header *header = NULL; 36 struct acpi_table_header *header = NULL;
36 if(!acpi_get_table_header_early(ACPI_DSDT, &header)) 37 if(!acpi_get_table_header_early(ACPI_DSDT, &header))
@@ -54,6 +55,11 @@ static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
54 } 55 }
55 return 0; 56 return 0;
56} 57}
57 58#else
59static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
60{
61 return 0;
62}
63#endif
58 64
59#endif /* __ASM_MACH_MPPARSE_H */ 65#endif /* __ASM_MACH_MPPARSE_H */
diff --git a/include/asm-i386/mach-visws/do_timer.h b/include/asm-i386/mach-visws/do_timer.h
index 92d638fc8b11..95568e6ca91c 100644
--- a/include/asm-i386/mach-visws/do_timer.h
+++ b/include/asm-i386/mach-visws/do_timer.h
@@ -11,7 +11,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
11 11
12 do_timer(regs); 12 do_timer(regs);
13#ifndef CONFIG_SMP 13#ifndef CONFIG_SMP
14 update_process_times(user_mode(regs)); 14 update_process_times(user_mode_vm(regs));
15#endif 15#endif
16/* 16/*
17 * In the SMP case we use the local APIC timer interrupt to do the 17 * In the SMP case we use the local APIC timer interrupt to do the
diff --git a/include/asm-i386/mach-voyager/do_timer.h b/include/asm-i386/mach-voyager/do_timer.h
index ae510e5d0d78..eaf518098981 100644
--- a/include/asm-i386/mach-voyager/do_timer.h
+++ b/include/asm-i386/mach-voyager/do_timer.h
@@ -5,7 +5,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
5{ 5{
6 do_timer(regs); 6 do_timer(regs);
7#ifndef CONFIG_SMP 7#ifndef CONFIG_SMP
8 update_process_times(user_mode(regs)); 8 update_process_times(user_mode_vm(regs));
9#endif 9#endif
10 10
11 voyager_timer_interrupt(regs); 11 voyager_timer_interrupt(regs);
diff --git a/include/asm-i386/mpspec.h b/include/asm-i386/mpspec.h
index 64a0b8e6afeb..62113d3bfdc2 100644
--- a/include/asm-i386/mpspec.h
+++ b/include/asm-i386/mpspec.h
@@ -22,7 +22,6 @@ extern int mp_bus_id_to_type [MAX_MP_BUSSES];
22extern int mp_irq_entries; 22extern int mp_irq_entries;
23extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES]; 23extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES];
24extern int mpc_default_type; 24extern int mpc_default_type;
25extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
26extern unsigned long mp_lapic_addr; 25extern unsigned long mp_lapic_addr;
27extern int pic_mode; 26extern int pic_mode;
28extern int using_apic_timer; 27extern int using_apic_timer;
diff --git a/include/asm-i386/mtrr.h b/include/asm-i386/mtrr.h
index 5b6ceda68c5f..64cf937c7e33 100644
--- a/include/asm-i386/mtrr.h
+++ b/include/asm-i386/mtrr.h
@@ -25,6 +25,7 @@
25 25
26#include <linux/config.h> 26#include <linux/config.h>
27#include <linux/ioctl.h> 27#include <linux/ioctl.h>
28#include <linux/errno.h>
28 29
29#define MTRR_IOCTL_BASE 'M' 30#define MTRR_IOCTL_BASE 'M'
30 31
diff --git a/include/asm-i386/mutex.h b/include/asm-i386/mutex.h
index 9b2199e829f3..05a538531229 100644
--- a/include/asm-i386/mutex.h
+++ b/include/asm-i386/mutex.h
@@ -9,6 +9,8 @@
9#ifndef _ASM_MUTEX_H 9#ifndef _ASM_MUTEX_H
10#define _ASM_MUTEX_H 10#define _ASM_MUTEX_H
11 11
12#include "asm/alternative.h"
13
12/** 14/**
13 * __mutex_fastpath_lock - try to take the lock by moving the count 15 * __mutex_fastpath_lock - try to take the lock by moving the count
14 * from 1 to a 0 value 16 * from 1 to a 0 value
@@ -27,7 +29,7 @@ do { \
27 typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \ 29 typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \
28 \ 30 \
29 __asm__ __volatile__( \ 31 __asm__ __volatile__( \
30 LOCK " decl (%%eax) \n" \ 32 LOCK_PREFIX " decl (%%eax) \n" \
31 " js 2f \n" \ 33 " js 2f \n" \
32 "1: \n" \ 34 "1: \n" \
33 \ 35 \
@@ -83,7 +85,7 @@ do { \
83 typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \ 85 typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \
84 \ 86 \
85 __asm__ __volatile__( \ 87 __asm__ __volatile__( \
86 LOCK " incl (%%eax) \n" \ 88 LOCK_PREFIX " incl (%%eax) \n" \
87 " jle 2f \n" \ 89 " jle 2f \n" \
88 "1: \n" \ 90 "1: \n" \
89 \ 91 \
diff --git a/include/asm-i386/pgtable-2level.h b/include/asm-i386/pgtable-2level.h
index 74ef721b534d..27bde973abc7 100644
--- a/include/asm-i386/pgtable-2level.h
+++ b/include/asm-i386/pgtable-2level.h
@@ -61,4 +61,6 @@ static inline int pte_exec_kernel(pte_t pte)
61#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) 61#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low })
62#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 62#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
63 63
64void vmalloc_sync_all(void);
65
64#endif /* _I386_PGTABLE_2LEVEL_H */ 66#endif /* _I386_PGTABLE_2LEVEL_H */
diff --git a/include/asm-i386/pgtable-3level.h b/include/asm-i386/pgtable-3level.h
index f1a8b454920a..36a5aa63cbbf 100644
--- a/include/asm-i386/pgtable-3level.h
+++ b/include/asm-i386/pgtable-3level.h
@@ -152,4 +152,6 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
152 152
153#define __pmd_free_tlb(tlb, x) do { } while (0) 153#define __pmd_free_tlb(tlb, x) do { } while (0)
154 154
155#define vmalloc_sync_all() ((void)0)
156
155#endif /* _I386_PGTABLE_3LEVEL_H */ 157#endif /* _I386_PGTABLE_3LEVEL_H */
diff --git a/include/asm-i386/rwlock.h b/include/asm-i386/rwlock.h
index b57cc7afdf7e..94f00195d543 100644
--- a/include/asm-i386/rwlock.h
+++ b/include/asm-i386/rwlock.h
@@ -21,21 +21,23 @@
21#define RW_LOCK_BIAS_STR "0x01000000" 21#define RW_LOCK_BIAS_STR "0x01000000"
22 22
23#define __build_read_lock_ptr(rw, helper) \ 23#define __build_read_lock_ptr(rw, helper) \
24 asm volatile(LOCK "subl $1,(%0)\n\t" \ 24 alternative_smp("lock; subl $1,(%0)\n\t" \
25 "jns 1f\n" \ 25 "jns 1f\n" \
26 "call " helper "\n\t" \ 26 "call " helper "\n\t" \
27 "1:\n" \ 27 "1:\n", \
28 ::"a" (rw) : "memory") 28 "subl $1,(%0)\n\t", \
29 :"a" (rw) : "memory")
29 30
30#define __build_read_lock_const(rw, helper) \ 31#define __build_read_lock_const(rw, helper) \
31 asm volatile(LOCK "subl $1,%0\n\t" \ 32 alternative_smp("lock; subl $1,%0\n\t" \
32 "jns 1f\n" \ 33 "jns 1f\n" \
33 "pushl %%eax\n\t" \ 34 "pushl %%eax\n\t" \
34 "leal %0,%%eax\n\t" \ 35 "leal %0,%%eax\n\t" \
35 "call " helper "\n\t" \ 36 "call " helper "\n\t" \
36 "popl %%eax\n\t" \ 37 "popl %%eax\n\t" \
37 "1:\n" \ 38 "1:\n", \
38 :"=m" (*(volatile int *)rw) : : "memory") 39 "subl $1,%0\n\t", \
40 "=m" (*(volatile int *)rw) : : "memory")
39 41
40#define __build_read_lock(rw, helper) do { \ 42#define __build_read_lock(rw, helper) do { \
41 if (__builtin_constant_p(rw)) \ 43 if (__builtin_constant_p(rw)) \
@@ -45,21 +47,23 @@
45 } while (0) 47 } while (0)
46 48
47#define __build_write_lock_ptr(rw, helper) \ 49#define __build_write_lock_ptr(rw, helper) \
48 asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \ 50 alternative_smp("lock; subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
49 "jz 1f\n" \ 51 "jz 1f\n" \
50 "call " helper "\n\t" \ 52 "call " helper "\n\t" \
51 "1:\n" \ 53 "1:\n", \
52 ::"a" (rw) : "memory") 54 "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t", \
55 :"a" (rw) : "memory")
53 56
54#define __build_write_lock_const(rw, helper) \ 57#define __build_write_lock_const(rw, helper) \
55 asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \ 58 alternative_smp("lock; subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
56 "jz 1f\n" \ 59 "jz 1f\n" \
57 "pushl %%eax\n\t" \ 60 "pushl %%eax\n\t" \
58 "leal %0,%%eax\n\t" \ 61 "leal %0,%%eax\n\t" \
59 "call " helper "\n\t" \ 62 "call " helper "\n\t" \
60 "popl %%eax\n\t" \ 63 "popl %%eax\n\t" \
61 "1:\n" \ 64 "1:\n", \
62 :"=m" (*(volatile int *)rw) : : "memory") 65 "subl $" RW_LOCK_BIAS_STR ",%0\n\t", \
66 "=m" (*(volatile int *)rw) : : "memory")
63 67
64#define __build_write_lock(rw, helper) do { \ 68#define __build_write_lock(rw, helper) do { \
65 if (__builtin_constant_p(rw)) \ 69 if (__builtin_constant_p(rw)) \
diff --git a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
index 6a42b2142fd6..f7a0f310c524 100644
--- a/include/asm-i386/semaphore.h
+++ b/include/asm-i386/semaphore.h
@@ -99,7 +99,7 @@ static inline void down(struct semaphore * sem)
99 might_sleep(); 99 might_sleep();
100 __asm__ __volatile__( 100 __asm__ __volatile__(
101 "# atomic down operation\n\t" 101 "# atomic down operation\n\t"
102 LOCK "decl %0\n\t" /* --sem->count */ 102 LOCK_PREFIX "decl %0\n\t" /* --sem->count */
103 "js 2f\n" 103 "js 2f\n"
104 "1:\n" 104 "1:\n"
105 LOCK_SECTION_START("") 105 LOCK_SECTION_START("")
@@ -123,7 +123,7 @@ static inline int down_interruptible(struct semaphore * sem)
123 might_sleep(); 123 might_sleep();
124 __asm__ __volatile__( 124 __asm__ __volatile__(
125 "# atomic interruptible down operation\n\t" 125 "# atomic interruptible down operation\n\t"
126 LOCK "decl %1\n\t" /* --sem->count */ 126 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
127 "js 2f\n\t" 127 "js 2f\n\t"
128 "xorl %0,%0\n" 128 "xorl %0,%0\n"
129 "1:\n" 129 "1:\n"
@@ -148,7 +148,7 @@ static inline int down_trylock(struct semaphore * sem)
148 148
149 __asm__ __volatile__( 149 __asm__ __volatile__(
150 "# atomic interruptible down operation\n\t" 150 "# atomic interruptible down operation\n\t"
151 LOCK "decl %1\n\t" /* --sem->count */ 151 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
152 "js 2f\n\t" 152 "js 2f\n\t"
153 "xorl %0,%0\n" 153 "xorl %0,%0\n"
154 "1:\n" 154 "1:\n"
@@ -173,7 +173,7 @@ static inline void up(struct semaphore * sem)
173{ 173{
174 __asm__ __volatile__( 174 __asm__ __volatile__(
175 "# atomic up operation\n\t" 175 "# atomic up operation\n\t"
176 LOCK "incl %0\n\t" /* ++sem->count */ 176 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
177 "jle 2f\n" 177 "jle 2f\n"
178 "1:\n" 178 "1:\n"
179 LOCK_SECTION_START("") 179 LOCK_SECTION_START("")
diff --git a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
index 23604350cdf4..d76b7693cf1d 100644
--- a/include/asm-i386/spinlock.h
+++ b/include/asm-i386/spinlock.h
@@ -35,31 +35,41 @@
35#define __raw_spin_lock_string_flags \ 35#define __raw_spin_lock_string_flags \
36 "\n1:\t" \ 36 "\n1:\t" \
37 "lock ; decb %0\n\t" \ 37 "lock ; decb %0\n\t" \
38 "jns 4f\n\t" \ 38 "jns 5f\n" \
39 "2:\t" \ 39 "2:\t" \
40 "testl $0x200, %1\n\t" \ 40 "testl $0x200, %1\n\t" \
41 "jz 3f\n\t" \ 41 "jz 4f\n\t" \
42 "sti\n\t" \ 42 "sti\n" \
43 "3:\t" \ 43 "3:\t" \
44 "rep;nop\n\t" \ 44 "rep;nop\n\t" \
45 "cmpb $0, %0\n\t" \ 45 "cmpb $0, %0\n\t" \
46 "jle 3b\n\t" \ 46 "jle 3b\n\t" \
47 "cli\n\t" \ 47 "cli\n\t" \
48 "jmp 1b\n" \ 48 "jmp 1b\n" \
49 "4:\n\t" 49 "4:\t" \
50 "rep;nop\n\t" \
51 "cmpb $0, %0\n\t" \
52 "jg 1b\n\t" \
53 "jmp 4b\n" \
54 "5:\n\t"
55
56#define __raw_spin_lock_string_up \
57 "\n\tdecb %0"
50 58
51static inline void __raw_spin_lock(raw_spinlock_t *lock) 59static inline void __raw_spin_lock(raw_spinlock_t *lock)
52{ 60{
53 __asm__ __volatile__( 61 alternative_smp(
54 __raw_spin_lock_string 62 __raw_spin_lock_string,
55 :"=m" (lock->slock) : : "memory"); 63 __raw_spin_lock_string_up,
64 "=m" (lock->slock) : : "memory");
56} 65}
57 66
58static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags) 67static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
59{ 68{
60 __asm__ __volatile__( 69 alternative_smp(
61 __raw_spin_lock_string_flags 70 __raw_spin_lock_string_flags,
62 :"=m" (lock->slock) : "r" (flags) : "memory"); 71 __raw_spin_lock_string_up,
72 "=m" (lock->slock) : "r" (flags) : "memory");
63} 73}
64 74
65static inline int __raw_spin_trylock(raw_spinlock_t *lock) 75static inline int __raw_spin_trylock(raw_spinlock_t *lock)
@@ -178,12 +188,12 @@ static inline int __raw_write_trylock(raw_rwlock_t *lock)
178 188
179static inline void __raw_read_unlock(raw_rwlock_t *rw) 189static inline void __raw_read_unlock(raw_rwlock_t *rw)
180{ 190{
181 asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory"); 191 asm volatile(LOCK_PREFIX "incl %0" :"=m" (rw->lock) : : "memory");
182} 192}
183 193
184static inline void __raw_write_unlock(raw_rwlock_t *rw) 194static inline void __raw_write_unlock(raw_rwlock_t *rw)
185{ 195{
186 asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0" 196 asm volatile(LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ", %0"
187 : "=m" (rw->lock) : : "memory"); 197 : "=m" (rw->lock) : : "memory");
188} 198}
189 199
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index 399145a247f2..d0d8d7448d88 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -352,67 +352,6 @@ static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long l
352 352
353#endif 353#endif
354 354
355#ifdef __KERNEL__
356struct alt_instr {
357 __u8 *instr; /* original instruction */
358 __u8 *replacement;
359 __u8 cpuid; /* cpuid bit set for replacement */
360 __u8 instrlen; /* length of original instruction */
361 __u8 replacementlen; /* length of new instruction, <= instrlen */
362 __u8 pad;
363};
364#endif
365
366/*
367 * Alternative instructions for different CPU types or capabilities.
368 *
369 * This allows to use optimized instructions even on generic binary
370 * kernels.
371 *
372 * length of oldinstr must be longer or equal the length of newinstr
373 * It can be padded with nops as needed.
374 *
375 * For non barrier like inlines please define new variants
376 * without volatile and memory clobber.
377 */
378#define alternative(oldinstr, newinstr, feature) \
379 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
380 ".section .altinstructions,\"a\"\n" \
381 " .align 4\n" \
382 " .long 661b\n" /* label */ \
383 " .long 663f\n" /* new instruction */ \
384 " .byte %c0\n" /* feature bit */ \
385 " .byte 662b-661b\n" /* sourcelen */ \
386 " .byte 664f-663f\n" /* replacementlen */ \
387 ".previous\n" \
388 ".section .altinstr_replacement,\"ax\"\n" \
389 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
390 ".previous" :: "i" (feature) : "memory")
391
392/*
393 * Alternative inline assembly with input.
394 *
395 * Pecularities:
396 * No memory clobber here.
397 * Argument numbers start with 1.
398 * Best is to use constraints that are fixed size (like (%1) ... "r")
399 * If you use variable sized constraints like "m" or "g" in the
400 * replacement maake sure to pad to the worst case length.
401 */
402#define alternative_input(oldinstr, newinstr, feature, input...) \
403 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
404 ".section .altinstructions,\"a\"\n" \
405 " .align 4\n" \
406 " .long 661b\n" /* label */ \
407 " .long 663f\n" /* new instruction */ \
408 " .byte %c0\n" /* feature bit */ \
409 " .byte 662b-661b\n" /* sourcelen */ \
410 " .byte 664f-663f\n" /* replacementlen */ \
411 ".previous\n" \
412 ".section .altinstr_replacement,\"ax\"\n" \
413 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
414 ".previous" :: "i" (feature), ##input)
415
416/* 355/*
417 * Force strict CPU ordering. 356 * Force strict CPU ordering.
418 * And yes, this is required on UP too when we're talking 357 * And yes, this is required on UP too when we're talking
@@ -558,5 +497,6 @@ static inline void sched_cacheflush(void)
558} 497}
559 498
560extern unsigned long arch_align_stack(unsigned long sp); 499extern unsigned long arch_align_stack(unsigned long sp);
500extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
561 501
562#endif 502#endif
diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h
index 3f1337c34208..371457b1ceb6 100644
--- a/include/asm-i386/uaccess.h
+++ b/include/asm-i386/uaccess.h
@@ -197,13 +197,15 @@ extern void __put_user_8(void);
197 197
198#define put_user(x,ptr) \ 198#define put_user(x,ptr) \
199({ int __ret_pu; \ 199({ int __ret_pu; \
200 __typeof__(*(ptr)) __pu_val; \
200 __chk_user_ptr(ptr); \ 201 __chk_user_ptr(ptr); \
202 __pu_val = x; \
201 switch(sizeof(*(ptr))) { \ 203 switch(sizeof(*(ptr))) { \
202 case 1: __put_user_1(x, ptr); break; \ 204 case 1: __put_user_1(__pu_val, ptr); break; \
203 case 2: __put_user_2(x, ptr); break; \ 205 case 2: __put_user_2(__pu_val, ptr); break; \
204 case 4: __put_user_4(x, ptr); break; \ 206 case 4: __put_user_4(__pu_val, ptr); break; \
205 case 8: __put_user_8(x, ptr); break; \ 207 case 8: __put_user_8(__pu_val, ptr); break; \
206 default:__put_user_X(x, ptr); break; \ 208 default:__put_user_X(__pu_val, ptr); break; \
207 } \ 209 } \
208 __ret_pu; \ 210 __ret_pu; \
209}) 211})
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index dc81a55dd94d..d8afd0e3b81a 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -347,9 +347,9 @@ __syscall_return(type,__res); \
347type name(type1 arg1) \ 347type name(type1 arg1) \
348{ \ 348{ \
349long __res; \ 349long __res; \
350__asm__ volatile ("int $0x80" \ 350__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
351 : "=a" (__res) \ 351 : "=a" (__res) \
352 : "0" (__NR_##name),"b" ((long)(arg1)) : "memory"); \ 352 : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
353__syscall_return(type,__res); \ 353__syscall_return(type,__res); \
354} 354}
355 355
@@ -357,9 +357,10 @@ __syscall_return(type,__res); \
357type name(type1 arg1,type2 arg2) \ 357type name(type1 arg1,type2 arg2) \
358{ \ 358{ \
359long __res; \ 359long __res; \
360__asm__ volatile ("int $0x80" \ 360__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
361 : "=a" (__res) \ 361 : "=a" (__res) \
362 : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)) : "memory"); \ 362 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
363 : "memory"); \
363__syscall_return(type,__res); \ 364__syscall_return(type,__res); \
364} 365}
365 366
@@ -367,9 +368,9 @@ __syscall_return(type,__res); \
367type name(type1 arg1,type2 arg2,type3 arg3) \ 368type name(type1 arg1,type2 arg2,type3 arg3) \
368{ \ 369{ \
369long __res; \ 370long __res; \
370__asm__ volatile ("int $0x80" \ 371__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
371 : "=a" (__res) \ 372 : "=a" (__res) \
372 : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ 373 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
373 "d" ((long)(arg3)) : "memory"); \ 374 "d" ((long)(arg3)) : "memory"); \
374__syscall_return(type,__res); \ 375__syscall_return(type,__res); \
375} 376}
@@ -378,9 +379,9 @@ __syscall_return(type,__res); \
378type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ 379type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
379{ \ 380{ \
380long __res; \ 381long __res; \
381__asm__ volatile ("int $0x80" \ 382__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
382 : "=a" (__res) \ 383 : "=a" (__res) \
383 : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ 384 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
384 "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \ 385 "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
385__syscall_return(type,__res); \ 386__syscall_return(type,__res); \
386} 387}
@@ -390,10 +391,12 @@ __syscall_return(type,__res); \
390type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ 391type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
391{ \ 392{ \
392long __res; \ 393long __res; \
393__asm__ volatile ("int $0x80" \ 394__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
395 "int $0x80 ; pop %%ebx" \
394 : "=a" (__res) \ 396 : "=a" (__res) \
395 : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ 397 : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
396 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) : "memory"); \ 398 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
399 : "memory"); \
397__syscall_return(type,__res); \ 400__syscall_return(type,__res); \
398} 401}
399 402
@@ -402,11 +405,14 @@ __syscall_return(type,__res); \
402type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ 405type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
403{ \ 406{ \
404long __res; \ 407long __res; \
405__asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; pop %%ebp" \ 408 struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
409__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
410 "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
411 "pop %%ebx ; pop %%ebp" \
406 : "=a" (__res) \ 412 : "=a" (__res) \
407 : "i" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ 413 : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
408 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \ 414 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
409 "0" ((long)(arg6)) : "memory"); \ 415 : "memory"); \
410__syscall_return(type,__res); \ 416__syscall_return(type,__res); \
411} 417}
412 418
diff --git a/include/asm-ia64/atomic.h b/include/asm-ia64/atomic.h
index d3e0dfa99e1f..569ec7574baf 100644
--- a/include/asm-ia64/atomic.h
+++ b/include/asm-ia64/atomic.h
@@ -95,8 +95,14 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
95({ \ 95({ \
96 int c, old; \ 96 int c, old; \
97 c = atomic_read(v); \ 97 c = atomic_read(v); \
98 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 98 for (;;) { \
99 if (unlikely(c == (u))) \
100 break; \
101 old = atomic_cmpxchg((v), c, c + (a)); \
102 if (likely(old == c)) \
103 break; \
99 c = old; \ 104 c = old; \
105 } \
100 c != (u); \ 106 c != (u); \
101}) 107})
102#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 108#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-ia64/cache.h b/include/asm-ia64/cache.h
index 40dd25195d65..f0a104db8f20 100644
--- a/include/asm-ia64/cache.h
+++ b/include/asm-ia64/cache.h
@@ -25,4 +25,6 @@
25# define SMP_CACHE_BYTES (1 << 3) 25# define SMP_CACHE_BYTES (1 << 3)
26#endif 26#endif
27 27
28#define __read_mostly __attribute__((__section__(".data.read_mostly")))
29
28#endif /* _ASM_IA64_CACHE_H */ 30#endif /* _ASM_IA64_CACHE_H */
diff --git a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h
index 862e497c2645..732d696d31a6 100644
--- a/include/asm-m68k/atomic.h
+++ b/include/asm-m68k/atomic.h
@@ -175,8 +175,14 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
175({ \ 175({ \
176 int c, old; \ 176 int c, old; \
177 c = atomic_read(v); \ 177 c = atomic_read(v); \
178 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 178 for (;;) { \
179 if (unlikely(c == (u))) \
180 break; \
181 old = atomic_cmpxchg((v), c, c + (a)); \
182 if (likely(old == c)) \
183 break; \
179 c = old; \ 184 c = old; \
185 } \
180 c != (u); \ 186 c != (u); \
181}) 187})
182#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 188#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-parisc/cache.h b/include/asm-parisc/cache.h
index 93f179f13ce8..ae50f8e12eed 100644
--- a/include/asm-parisc/cache.h
+++ b/include/asm-parisc/cache.h
@@ -29,6 +29,8 @@
29 29
30#define SMP_CACHE_BYTES L1_CACHE_BYTES 30#define SMP_CACHE_BYTES L1_CACHE_BYTES
31 31
32#define __read_mostly __attribute__((__section__(".data.read_mostly")))
33
32extern void flush_data_cache_local(void *); /* flushes local data-cache only */ 34extern void flush_data_cache_local(void *); /* flushes local data-cache only */
33extern void flush_instruction_cache_local(void *); /* flushes local code-cache only */ 35extern void flush_instruction_cache_local(void *); /* flushes local code-cache only */
34#ifdef CONFIG_SMP 36#ifdef CONFIG_SMP
diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h
index 147a38dcc766..bb3c0ab7e667 100644
--- a/include/asm-powerpc/atomic.h
+++ b/include/asm-powerpc/atomic.h
@@ -8,6 +8,7 @@
8typedef struct { volatile int counter; } atomic_t; 8typedef struct { volatile int counter; } atomic_t;
9 9
10#ifdef __KERNEL__ 10#ifdef __KERNEL__
11#include <linux/compiler.h>
11#include <asm/synch.h> 12#include <asm/synch.h>
12#include <asm/asm-compat.h> 13#include <asm/asm-compat.h>
13 14
@@ -176,20 +177,29 @@ static __inline__ int atomic_dec_return(atomic_t *v)
176 * Atomically adds @a to @v, so long as it was not @u. 177 * Atomically adds @a to @v, so long as it was not @u.
177 * Returns non-zero if @v was not @u, and zero otherwise. 178 * Returns non-zero if @v was not @u, and zero otherwise.
178 */ 179 */
179#define atomic_add_unless(v, a, u) \ 180static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
180({ \ 181{
181 int c, old; \ 182 int t;
182 c = atomic_read(v); \ 183
183 for (;;) { \ 184 __asm__ __volatile__ (
184 if (unlikely(c == (u))) \ 185 LWSYNC_ON_SMP
185 break; \ 186"1: lwarx %0,0,%1 # atomic_add_unless\n\
186 old = atomic_cmpxchg((v), c, c + (a)); \ 187 cmpw 0,%0,%3 \n\
187 if (likely(old == c)) \ 188 beq- 2f \n\
188 break; \ 189 add %0,%2,%0 \n"
189 c = old; \ 190 PPC405_ERR77(0,%2)
190 } \ 191" stwcx. %0,0,%1 \n\
191 c != (u); \ 192 bne- 1b \n"
192}) 193 ISYNC_ON_SMP
194" subf %0,%2,%0 \n\
1952:"
196 : "=&r" (t)
197 : "r" (&v->counter), "r" (a), "r" (u)
198 : "cc", "memory");
199
200 return t != u;
201}
202
193#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 203#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
194 204
195#define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) 205#define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0)
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 5638518968c3..fe45f6f3a4be 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -102,38 +102,40 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
102#define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000) 102#define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000)
103#define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000) 103#define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000)
104#define CPU_FTR_BIG_PHYS ASM_CONST(0x0000000000080000) 104#define CPU_FTR_BIG_PHYS ASM_CONST(0x0000000000080000)
105#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000) 105#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000)
106 106
107#ifdef __powerpc64__ 107#ifdef __powerpc64__
108/* Add the 64b processor unique features in the top half of the word */ 108/* Add the 64b processor unique features in the top half of the word */
109#define CPU_FTR_SLB ASM_CONST(0x0000000100000000) 109#define CPU_FTR_SLB ASM_CONST(0x0000000100000000)
110#define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000) 110#define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000)
111#define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000) 111#define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000)
112#define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000) 112#define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000)
113#define CPU_FTR_IABR ASM_CONST(0x0000002000000000) 113#define CPU_FTR_IABR ASM_CONST(0x0000002000000000)
114#define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000) 114#define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000)
115#define CPU_FTR_CTRL ASM_CONST(0x0000008000000000) 115#define CPU_FTR_CTRL ASM_CONST(0x0000008000000000)
116#define CPU_FTR_SMT ASM_CONST(0x0000010000000000) 116#define CPU_FTR_SMT ASM_CONST(0x0000010000000000)
117#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000) 117#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000)
118#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0000040000000000) 118#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0000040000000000)
119#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000) 119#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000)
120#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0000100000000000) 120#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0000100000000000)
121#define CPU_FTR_PAUSE_ZERO ASM_CONST(0x0000200000000000) 121#define CPU_FTR_PAUSE_ZERO ASM_CONST(0x0000200000000000)
122#define CPU_FTR_PURR ASM_CONST(0x0000400000000000)
122#else 123#else
123/* ensure on 32b processors the flags are available for compiling but 124/* ensure on 32b processors the flags are available for compiling but
124 * don't do anything */ 125 * don't do anything */
125#define CPU_FTR_SLB ASM_CONST(0x0) 126#define CPU_FTR_SLB ASM_CONST(0x0)
126#define CPU_FTR_16M_PAGE ASM_CONST(0x0) 127#define CPU_FTR_16M_PAGE ASM_CONST(0x0)
127#define CPU_FTR_TLBIEL ASM_CONST(0x0) 128#define CPU_FTR_TLBIEL ASM_CONST(0x0)
128#define CPU_FTR_NOEXECUTE ASM_CONST(0x0) 129#define CPU_FTR_NOEXECUTE ASM_CONST(0x0)
129#define CPU_FTR_IABR ASM_CONST(0x0) 130#define CPU_FTR_IABR ASM_CONST(0x0)
130#define CPU_FTR_MMCRA ASM_CONST(0x0) 131#define CPU_FTR_MMCRA ASM_CONST(0x0)
131#define CPU_FTR_CTRL ASM_CONST(0x0) 132#define CPU_FTR_CTRL ASM_CONST(0x0)
132#define CPU_FTR_SMT ASM_CONST(0x0) 133#define CPU_FTR_SMT ASM_CONST(0x0)
133#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0) 134#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0)
134#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0) 135#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0)
135#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0) 136#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0)
136#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0) 137#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0)
138#define CPU_FTR_PURR ASM_CONST(0x0)
137#endif 139#endif
138 140
139#ifndef __ASSEMBLY__ 141#ifndef __ASSEMBLY__
@@ -318,7 +320,7 @@ enum {
318 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | 320 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
319 CPU_FTR_MMCRA | CPU_FTR_SMT | 321 CPU_FTR_MMCRA | CPU_FTR_SMT |
320 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | 322 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE |
321 CPU_FTR_MMCRA_SIHV, 323 CPU_FTR_MMCRA_SIHV | CPU_FTR_PURR,
322 CPU_FTRS_CELL = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | 324 CPU_FTRS_CELL = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
323 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | 325 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
324 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | 326 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT |
diff --git a/include/asm-powerpc/cputime.h b/include/asm-powerpc/cputime.h
index 6d68ad7e0ea3..a21185d47883 100644
--- a/include/asm-powerpc/cputime.h
+++ b/include/asm-powerpc/cputime.h
@@ -1 +1,203 @@
1/*
2 * Definitions for measuring cputime on powerpc machines.
3 *
4 * Copyright (C) 2006 Paul Mackerras, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * If we have CONFIG_VIRT_CPU_ACCOUNTING, we measure cpu time in
12 * the same units as the timebase. Otherwise we measure cpu time
13 * in jiffies using the generic definitions.
14 */
15
16#ifndef __POWERPC_CPUTIME_H
17#define __POWERPC_CPUTIME_H
18
19#ifndef CONFIG_VIRT_CPU_ACCOUNTING
1#include <asm-generic/cputime.h> 20#include <asm-generic/cputime.h>
21#else
22
23#include <linux/types.h>
24#include <linux/time.h>
25#include <asm/div64.h>
26#include <asm/time.h>
27#include <asm/param.h>
28
29typedef u64 cputime_t;
30typedef u64 cputime64_t;
31
32#define cputime_zero ((cputime_t)0)
33#define cputime_max ((~((cputime_t)0) >> 1) - 1)
34#define cputime_add(__a, __b) ((__a) + (__b))
35#define cputime_sub(__a, __b) ((__a) - (__b))
36#define cputime_div(__a, __n) ((__a) / (__n))
37#define cputime_halve(__a) ((__a) >> 1)
38#define cputime_eq(__a, __b) ((__a) == (__b))
39#define cputime_gt(__a, __b) ((__a) > (__b))
40#define cputime_ge(__a, __b) ((__a) >= (__b))
41#define cputime_lt(__a, __b) ((__a) < (__b))
42#define cputime_le(__a, __b) ((__a) <= (__b))
43
44#define cputime64_zero ((cputime64_t)0)
45#define cputime64_add(__a, __b) ((__a) + (__b))
46#define cputime_to_cputime64(__ct) (__ct)
47
48#ifdef __KERNEL__
49
50/*
51 * Convert cputime <-> jiffies
52 */
53extern u64 __cputime_jiffies_factor;
54
55static inline unsigned long cputime_to_jiffies(const cputime_t ct)
56{
57 return mulhdu(ct, __cputime_jiffies_factor);
58}
59
60static inline cputime_t jiffies_to_cputime(const unsigned long jif)
61{
62 cputime_t ct;
63 unsigned long sec;
64
65 /* have to be a little careful about overflow */
66 ct = jif % HZ;
67 sec = jif / HZ;
68 if (ct) {
69 ct *= tb_ticks_per_sec;
70 do_div(ct, HZ);
71 }
72 if (sec)
73 ct += (cputime_t) sec * tb_ticks_per_sec;
74 return ct;
75}
76
77static inline u64 cputime64_to_jiffies64(const cputime_t ct)
78{
79 return mulhdu(ct, __cputime_jiffies_factor);
80}
81
82/*
83 * Convert cputime <-> milliseconds
84 */
85extern u64 __cputime_msec_factor;
86
87static inline unsigned long cputime_to_msecs(const cputime_t ct)
88{
89 return mulhdu(ct, __cputime_msec_factor);
90}
91
92static inline cputime_t msecs_to_cputime(const unsigned long ms)
93{
94 cputime_t ct;
95 unsigned long sec;
96
97 /* have to be a little careful about overflow */
98 ct = ms % 1000;
99 sec = ms / 1000;
100 if (ct) {
101 ct *= tb_ticks_per_sec;
102 do_div(ct, 1000);
103 }
104 if (sec)
105 ct += (cputime_t) sec * tb_ticks_per_sec;
106 return ct;
107}
108
109/*
110 * Convert cputime <-> seconds
111 */
112extern u64 __cputime_sec_factor;
113
114static inline unsigned long cputime_to_secs(const cputime_t ct)
115{
116 return mulhdu(ct, __cputime_sec_factor);
117}
118
119static inline cputime_t secs_to_cputime(const unsigned long sec)
120{
121 return (cputime_t) sec * tb_ticks_per_sec;
122}
123
124/*
125 * Convert cputime <-> timespec
126 */
127static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p)
128{
129 u64 x = ct;
130 unsigned int frac;
131
132 frac = do_div(x, tb_ticks_per_sec);
133 p->tv_sec = x;
134 x = (u64) frac * 1000000000;
135 do_div(x, tb_ticks_per_sec);
136 p->tv_nsec = x;
137}
138
139static inline cputime_t timespec_to_cputime(const struct timespec *p)
140{
141 cputime_t ct;
142
143 ct = (u64) p->tv_nsec * tb_ticks_per_sec;
144 do_div(ct, 1000000000);
145 return ct + (u64) p->tv_sec * tb_ticks_per_sec;
146}
147
148/*
149 * Convert cputime <-> timeval
150 */
151static inline void cputime_to_timeval(const cputime_t ct, struct timeval *p)
152{
153 u64 x = ct;
154 unsigned int frac;
155
156 frac = do_div(x, tb_ticks_per_sec);
157 p->tv_sec = x;
158 x = (u64) frac * 1000000;
159 do_div(x, tb_ticks_per_sec);
160 p->tv_usec = x;
161}
162
163static inline cputime_t timeval_to_cputime(const struct timeval *p)
164{
165 cputime_t ct;
166
167 ct = (u64) p->tv_usec * tb_ticks_per_sec;
168 do_div(ct, 1000000);
169 return ct + (u64) p->tv_sec * tb_ticks_per_sec;
170}
171
172/*
173 * Convert cputime <-> clock_t (units of 1/USER_HZ seconds)
174 */
175extern u64 __cputime_clockt_factor;
176
177static inline unsigned long cputime_to_clock_t(const cputime_t ct)
178{
179 return mulhdu(ct, __cputime_clockt_factor);
180}
181
182static inline cputime_t clock_t_to_cputime(const unsigned long clk)
183{
184 cputime_t ct;
185 unsigned long sec;
186
187 /* have to be a little careful about overflow */
188 ct = clk % USER_HZ;
189 sec = clk / USER_HZ;
190 if (ct) {
191 ct *= tb_ticks_per_sec;
192 do_div(ct, USER_HZ);
193 }
194 if (sec)
195 ct += (cputime_t) sec * tb_ticks_per_sec;
196 return ct;
197}
198
199#define cputime64_to_clock_t(ct) cputime_to_clock_t((cputime_t)(ct))
200
201#endif /* __KERNEL__ */
202#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
203#endif /* __POWERPC_CPUTIME_H */
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h
index f804b34cf06a..ce3788224ed0 100644
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -41,6 +41,7 @@
41#define FW_FEATURE_MULTITCE (1UL<<19) 41#define FW_FEATURE_MULTITCE (1UL<<19)
42#define FW_FEATURE_SPLPAR (1UL<<20) 42#define FW_FEATURE_SPLPAR (1UL<<20)
43#define FW_FEATURE_ISERIES (1UL<<21) 43#define FW_FEATURE_ISERIES (1UL<<21)
44#define FW_FEATURE_LPAR (1UL<<22)
44 45
45enum { 46enum {
46#ifdef CONFIG_PPC64 47#ifdef CONFIG_PPC64
@@ -51,10 +52,10 @@ enum {
51 FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ | 52 FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ |
52 FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN | 53 FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
53 FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE | 54 FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE |
54 FW_FEATURE_SPLPAR, 55 FW_FEATURE_SPLPAR | FW_FEATURE_LPAR,
55 FW_FEATURE_PSERIES_ALWAYS = 0, 56 FW_FEATURE_PSERIES_ALWAYS = 0,
56 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES, 57 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
57 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES, 58 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
58 FW_FEATURE_POSSIBLE = 59 FW_FEATURE_POSSIBLE =
59#ifdef CONFIG_PPC_PSERIES 60#ifdef CONFIG_PPC_PSERIES
60 FW_FEATURE_PSERIES_POSSIBLE | 61 FW_FEATURE_PSERIES_POSSIBLE |
@@ -89,15 +90,6 @@ static inline unsigned long firmware_has_feature(unsigned long feature)
89 (FW_FEATURE_POSSIBLE & ppc64_firmware_features & feature); 90 (FW_FEATURE_POSSIBLE & ppc64_firmware_features & feature);
90} 91}
91 92
92#ifdef CONFIG_PPC_PSERIES
93typedef struct {
94 unsigned long val;
95 char * name;
96} firmware_feature_t;
97
98extern firmware_feature_t firmware_features_table[];
99#endif
100
101extern void system_reset_fwnmi(void); 93extern void system_reset_fwnmi(void);
102extern void machine_check_fwnmi(void); 94extern void machine_check_fwnmi(void);
103 95
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index 8eb7e857ec4c..51f87d9993b6 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -479,6 +479,10 @@ extern int distribute_irqs;
479struct irqaction; 479struct irqaction;
480struct pt_regs; 480struct pt_regs;
481 481
482#define __ARCH_HAS_DO_SOFTIRQ
483
484extern void __do_softirq(void);
485
482#ifdef CONFIG_IRQSTACKS 486#ifdef CONFIG_IRQSTACKS
483/* 487/*
484 * Per-cpu stacks for handling hard and soft interrupts. 488 * Per-cpu stacks for handling hard and soft interrupts.
@@ -491,8 +495,6 @@ extern void call_do_softirq(struct thread_info *tp);
491extern int call___do_IRQ(int irq, struct pt_regs *regs, 495extern int call___do_IRQ(int irq, struct pt_regs *regs,
492 struct thread_info *tp); 496 struct thread_info *tp);
493 497
494#define __ARCH_HAS_DO_SOFTIRQ
495
496#else 498#else
497#define irq_ctx_init() 499#define irq_ctx_init()
498 500
diff --git a/include/asm-powerpc/iseries/mf.h b/include/asm-powerpc/iseries/mf.h
index 857e5202fc78..eb851a9c9e5c 100644
--- a/include/asm-powerpc/iseries/mf.h
+++ b/include/asm-powerpc/iseries/mf.h
@@ -41,16 +41,11 @@ extern void mf_deallocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type,
41 unsigned count, MFCompleteHandler hdlr, void *userToken); 41 unsigned count, MFCompleteHandler hdlr, void *userToken);
42 42
43extern void mf_power_off(void); 43extern void mf_power_off(void);
44extern void mf_reboot(void); 44extern void mf_reboot(char *cmd);
45 45
46extern void mf_display_src(u32 word); 46extern void mf_display_src(u32 word);
47extern void mf_display_progress(u16 value); 47extern void mf_display_progress(u16 value);
48extern void mf_clear_src(void);
49 48
50extern void mf_init(void); 49extern void mf_init(void);
51 50
52extern int mf_get_rtc(struct rtc_time *tm);
53extern int mf_get_boot_rtc(struct rtc_time *tm);
54extern int mf_set_rtc(struct rtc_time *tm);
55
56#endif /* _ASM_POWERPC_ISERIES_MF_H */ 51#endif /* _ASM_POWERPC_ISERIES_MF_H */
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h
index d3546c4c9f46..0c5880f70225 100644
--- a/include/asm-powerpc/lmb.h
+++ b/include/asm-powerpc/lmb.h
@@ -19,8 +19,6 @@
19 19
20#define MAX_LMB_REGIONS 128 20#define MAX_LMB_REGIONS 128
21 21
22#define LMB_ALLOC_ANYWHERE 0
23
24struct lmb_property { 22struct lmb_property {
25 unsigned long base; 23 unsigned long base;
26 unsigned long size; 24 unsigned long size;
@@ -43,20 +41,19 @@ extern struct lmb lmb;
43 41
44extern void __init lmb_init(void); 42extern void __init lmb_init(void);
45extern void __init lmb_analyze(void); 43extern void __init lmb_analyze(void);
46extern long __init lmb_add(unsigned long, unsigned long); 44extern long __init lmb_add(unsigned long base, unsigned long size);
47extern long __init lmb_reserve(unsigned long, unsigned long); 45extern long __init lmb_reserve(unsigned long base, unsigned long size);
48extern unsigned long __init lmb_alloc(unsigned long, unsigned long); 46extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
49extern unsigned long __init lmb_alloc_base(unsigned long, unsigned long, 47extern unsigned long __init lmb_alloc_base(unsigned long size,
50 unsigned long); 48 unsigned long align, unsigned long max_addr);
49extern unsigned long __init __lmb_alloc_base(unsigned long size,
50 unsigned long align, unsigned long max_addr);
51extern unsigned long __init lmb_phys_mem_size(void); 51extern unsigned long __init lmb_phys_mem_size(void);
52extern unsigned long __init lmb_end_of_DRAM(void); 52extern unsigned long __init lmb_end_of_DRAM(void);
53extern unsigned long __init lmb_abs_to_phys(unsigned long); 53extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
54extern void __init lmb_enforce_memory_limit(unsigned long);
55 54
56extern void lmb_dump_all(void); 55extern void lmb_dump_all(void);
57 56
58extern unsigned long io_hole_start;
59
60static inline unsigned long 57static inline unsigned long
61lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) 58lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
62{ 59{
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h
index b0b9a3f8cdc2..31f721994bd8 100644
--- a/include/asm-powerpc/mmu.h
+++ b/include/asm-powerpc/mmu.h
@@ -236,7 +236,6 @@ extern void htab_initialize_secondary(void);
236extern void hpte_init_native(void); 236extern void hpte_init_native(void);
237extern void hpte_init_lpar(void); 237extern void hpte_init_lpar(void);
238extern void hpte_init_iSeries(void); 238extern void hpte_init_iSeries(void);
239extern void mm_init_ppc64(void);
240 239
241extern long pSeries_lpar_hpte_insert(unsigned long hpte_group, 240extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
242 unsigned long va, unsigned long prpn, 241 unsigned long va, unsigned long prpn,
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index c9add8f1ad94..4465b95ebef0 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -54,7 +54,7 @@ struct paca_struct {
54#endif /* CONFIG_PPC_ISERIES */ 54#endif /* CONFIG_PPC_ISERIES */
55 55
56 /* 56 /*
57 * MAGIC: the spinlock functions in arch/ppc64/lib/locks.c 57 * MAGIC: the spinlock functions in arch/powerpc/lib/locks.c
58 * load lock_token and paca_index with a single lwz 58 * load lock_token and paca_index with a single lwz
59 * instruction. They must travel together and be properly 59 * instruction. They must travel together and be properly
60 * aligned. 60 * aligned.
@@ -96,6 +96,11 @@ struct paca_struct {
96 u64 saved_r1; /* r1 save for RTAS calls */ 96 u64 saved_r1; /* r1 save for RTAS calls */
97 u64 saved_msr; /* MSR saved here by enter_rtas */ 97 u64 saved_msr; /* MSR saved here by enter_rtas */
98 u8 proc_enabled; /* irq soft-enable flag */ 98 u8 proc_enabled; /* irq soft-enable flag */
99
100 /* Stuff for accurate time accounting */
101 u64 user_time; /* accumulated usermode TB ticks */
102 u64 system_time; /* accumulated system TB ticks */
103 u64 startpurr; /* PURR/TB value snapshot */
99}; 104};
100 105
101extern struct paca_struct paca[]; 106extern struct paca_struct paca[];
diff --git a/include/asm-powerpc/percpu.h b/include/asm-powerpc/percpu.h
index e31922c50e53..464301cd0d03 100644
--- a/include/asm-powerpc/percpu.h
+++ b/include/asm-powerpc/percpu.h
@@ -27,10 +27,9 @@
27#define percpu_modcopy(pcpudst, src, size) \ 27#define percpu_modcopy(pcpudst, src, size) \
28do { \ 28do { \
29 unsigned int __i; \ 29 unsigned int __i; \
30 for (__i = 0; __i < NR_CPUS; __i++) \ 30 for_each_cpu(__i) \
31 if (cpu_possible(__i)) \ 31 memcpy((pcpudst)+__per_cpu_offset(__i), \
32 memcpy((pcpudst)+__per_cpu_offset(__i), \ 32 (src), (size)); \
33 (src), (size)); \
34} while (0) 33} while (0)
35 34
36extern void setup_per_cpu_areas(void); 35extern void setup_per_cpu_areas(void);
diff --git a/include/asm-powerpc/pgtable-4k.h b/include/asm-powerpc/pgtable-4k.h
index 80a7832d2721..b2e18629932a 100644
--- a/include/asm-powerpc/pgtable-4k.h
+++ b/include/asm-powerpc/pgtable-4k.h
@@ -62,9 +62,14 @@
62/* shift to put page number into pte */ 62/* shift to put page number into pte */
63#define PTE_RPN_SHIFT (17) 63#define PTE_RPN_SHIFT (17)
64 64
65#define __real_pte(e,p) ((real_pte_t)(e)) 65#ifdef STRICT_MM_TYPECHECKS
66#define __rpte_to_pte(r) (r) 66#define __real_pte(e,p) ((real_pte_t){(e)})
67#define __rpte_to_hidx(r,index) (pte_val((r)) >> 12) 67#define __rpte_to_pte(r) ((r).pte)
68#else
69#define __real_pte(e,p) (e)
70#define __rpte_to_pte(r) (__pte(r))
71#endif
72#define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> 12)
68 73
69#define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \ 74#define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \
70 do { \ 75 do { \
diff --git a/include/asm-powerpc/pgtable.h b/include/asm-powerpc/pgtable.h
index 185ee15963a1..e9f1f4627e6b 100644
--- a/include/asm-powerpc/pgtable.h
+++ b/include/asm-powerpc/pgtable.h
@@ -188,9 +188,13 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
188#define pte_pfn(x) ((unsigned long)((pte_val(x)>>PTE_RPN_SHIFT))) 188#define pte_pfn(x) ((unsigned long)((pte_val(x)>>PTE_RPN_SHIFT)))
189#define pte_page(x) pfn_to_page(pte_pfn(x)) 189#define pte_page(x) pfn_to_page(pte_pfn(x))
190 190
191#define PMD_BAD_BITS (PTE_TABLE_SIZE-1)
192#define PUD_BAD_BITS (PMD_TABLE_SIZE-1)
193
191#define pmd_set(pmdp, pmdval) (pmd_val(*(pmdp)) = (pmdval)) 194#define pmd_set(pmdp, pmdval) (pmd_val(*(pmdp)) = (pmdval))
192#define pmd_none(pmd) (!pmd_val(pmd)) 195#define pmd_none(pmd) (!pmd_val(pmd))
193#define pmd_bad(pmd) (pmd_val(pmd) == 0) 196#define pmd_bad(pmd) (!is_kernel_addr(pmd_val(pmd)) \
197 || (pmd_val(pmd) & PMD_BAD_BITS))
194#define pmd_present(pmd) (pmd_val(pmd) != 0) 198#define pmd_present(pmd) (pmd_val(pmd) != 0)
195#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0) 199#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
196#define pmd_page_kernel(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS) 200#define pmd_page_kernel(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS)
@@ -198,7 +202,8 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
198 202
199#define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval)) 203#define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval))
200#define pud_none(pud) (!pud_val(pud)) 204#define pud_none(pud) (!pud_val(pud))
201#define pud_bad(pud) ((pud_val(pud)) == 0) 205#define pud_bad(pud) (!is_kernel_addr(pud_val(pud)) \
206 || (pud_val(pud) & PUD_BAD_BITS))
202#define pud_present(pud) (pud_val(pud) != 0) 207#define pud_present(pud) (pud_val(pud) != 0)
203#define pud_clear(pudp) (pud_val(*(pudp)) = 0) 208#define pud_clear(pudp) (pud_val(*(pudp)) = 0)
204#define pud_page(pud) (pud_val(pud) & ~PUD_MASKED_BITS) 209#define pud_page(pud) (pud_val(pud) & ~PUD_MASKED_BITS)
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h
index ab8688d39024..dd1c0a913d5f 100644
--- a/include/asm-powerpc/ppc_asm.h
+++ b/include/asm-powerpc/ppc_asm.h
@@ -15,6 +15,48 @@
15#define SZL (BITS_PER_LONG/8) 15#define SZL (BITS_PER_LONG/8)
16 16
17/* 17/*
18 * Stuff for accurate CPU time accounting.
19 * These macros handle transitions between user and system state
20 * in exception entry and exit and accumulate time to the
21 * user_time and system_time fields in the paca.
22 */
23
24#ifndef CONFIG_VIRT_CPU_ACCOUNTING
25#define ACCOUNT_CPU_USER_ENTRY(ra, rb)
26#define ACCOUNT_CPU_USER_EXIT(ra, rb)
27#else
28#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \
29 beq 2f; /* if from kernel mode */ \
30BEGIN_FTR_SECTION; \
31 mfspr ra,SPRN_PURR; /* get processor util. reg */ \
32END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
33BEGIN_FTR_SECTION; \
34 mftb ra; /* or get TB if no PURR */ \
35END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
36 ld rb,PACA_STARTPURR(r13); \
37 std ra,PACA_STARTPURR(r13); \
38 subf rb,rb,ra; /* subtract start value */ \
39 ld ra,PACA_USER_TIME(r13); \
40 add ra,ra,rb; /* add on to user time */ \
41 std ra,PACA_USER_TIME(r13); \
422:
43
44#define ACCOUNT_CPU_USER_EXIT(ra, rb) \
45BEGIN_FTR_SECTION; \
46 mfspr ra,SPRN_PURR; /* get processor util. reg */ \
47END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
48BEGIN_FTR_SECTION; \
49 mftb ra; /* or get TB if no PURR */ \
50END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
51 ld rb,PACA_STARTPURR(r13); \
52 std ra,PACA_STARTPURR(r13); \
53 subf rb,rb,ra; /* subtract start value */ \
54 ld ra,PACA_SYSTEM_TIME(r13); \
55 add ra,ra,rb; /* add on to user time */ \
56 std ra,PACA_SYSTEM_TIME(r13);
57#endif
58
59/*
18 * Macros for storing registers into and loading registers from 60 * Macros for storing registers into and loading registers from
19 * exception frames. 61 * exception frames.
20 */ 62 */
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
index 415fa393b00c..1c64a211cf19 100644
--- a/include/asm-powerpc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -52,7 +52,6 @@
52#ifdef __KERNEL__ 52#ifdef __KERNEL__
53#define platform_is_pseries() (_machine == PLATFORM_PSERIES || \ 53#define platform_is_pseries() (_machine == PLATFORM_PSERIES || \
54 _machine == PLATFORM_PSERIES_LPAR) 54 _machine == PLATFORM_PSERIES_LPAR)
55#define platform_is_lpar() (!!(_machine & PLATFORM_LPAR))
56 55
57#if defined(CONFIG_PPC_MULTIPLATFORM) 56#if defined(CONFIG_PPC_MULTIPLATFORM)
58extern int _machine; 57extern int _machine;
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index cbd297f44cce..782e13a070a1 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -126,8 +126,14 @@ extern struct device_node *find_all_nodes(void);
126/* New style node lookup */ 126/* New style node lookup */
127extern struct device_node *of_find_node_by_name(struct device_node *from, 127extern struct device_node *of_find_node_by_name(struct device_node *from,
128 const char *name); 128 const char *name);
129#define for_each_node_by_name(dn, name) \
130 for (dn = of_find_node_by_name(NULL, name); dn; \
131 dn = of_find_node_by_name(dn, name))
129extern struct device_node *of_find_node_by_type(struct device_node *from, 132extern struct device_node *of_find_node_by_type(struct device_node *from,
130 const char *type); 133 const char *type);
134#define for_each_node_by_type(dn, type) \
135 for (dn = of_find_node_by_type(NULL, type); dn; \
136 dn = of_find_node_by_type(dn, type))
131extern struct device_node *of_find_compatible_node(struct device_node *from, 137extern struct device_node *of_find_compatible_node(struct device_node *from,
132 const char *type, const char *compat); 138 const char *type, const char *compat);
133extern struct device_node *of_find_node_by_path(const char *path); 139extern struct device_node *of_find_node_by_path(const char *path);
diff --git a/include/asm-powerpc/rwsem.h b/include/asm-powerpc/rwsem.h
index 79bae4933b73..2c2fe9647595 100644
--- a/include/asm-powerpc/rwsem.h
+++ b/include/asm-powerpc/rwsem.h
@@ -4,7 +4,7 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6/* 6/*
7 * include/asm-ppc64/rwsem.h: R/W semaphores for PPC using the stuff 7 * include/asm-powerpc/rwsem.h: R/W semaphores for PPC using the stuff
8 * in lib/rwsem.c. Adapted largely from include/asm-i386/rwsem.h 8 * in lib/rwsem.c. Adapted largely from include/asm-i386/rwsem.h
9 * by Paul Mackerras <paulus@samba.org>. 9 * by Paul Mackerras <paulus@samba.org>.
10 */ 10 */
diff --git a/include/asm-powerpc/synch.h b/include/asm-powerpc/synch.h
index c90d9d9aae72..2cda3c38a9fa 100644
--- a/include/asm-powerpc/synch.h
+++ b/include/asm-powerpc/synch.h
@@ -15,7 +15,7 @@
15#endif 15#endif
16 16
17#ifdef CONFIG_SMP 17#ifdef CONFIG_SMP
18#define ISYNC_ON_SMP "\n\tisync" 18#define ISYNC_ON_SMP "\n\tisync\n"
19#define LWSYNC_ON_SMP __stringify(LWSYNC) "\n" 19#define LWSYNC_ON_SMP __stringify(LWSYNC) "\n"
20#else 20#else
21#define ISYNC_ON_SMP 21#define ISYNC_ON_SMP
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index d9bf53653b10..65f5a7b2646b 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -171,6 +171,8 @@ extern u32 booke_wdt_period;
171 171
172/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */ 172/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
173extern unsigned char e2a(unsigned char); 173extern unsigned char e2a(unsigned char);
174extern unsigned char* strne2a(unsigned char *dest,
175 const unsigned char *src, size_t n);
174 176
175struct device_node; 177struct device_node;
176extern void note_scsi_host(struct device_node *, void *); 178extern void note_scsi_host(struct device_node *, void *);
@@ -424,5 +426,9 @@ static inline void create_function_call(unsigned long addr, void * func)
424 create_branch(addr, func_addr, BRANCH_SET_LINK); 426 create_branch(addr, func_addr, BRANCH_SET_LINK);
425} 427}
426 428
429#ifdef CONFIG_VIRT_CPU_ACCOUNTING
430extern void account_system_vtime(struct task_struct *);
431#endif
432
427#endif /* __KERNEL__ */ 433#endif /* __KERNEL__ */
428#endif /* _ASM_POWERPC_SYSTEM_H */ 434#endif /* _ASM_POWERPC_SYSTEM_H */
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index baddc9ab57ad..912118db13ae 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -41,6 +41,7 @@ extern time_t last_rtc_update;
41 41
42extern void generic_calibrate_decr(void); 42extern void generic_calibrate_decr(void);
43extern void wakeup_decrementer(void); 43extern void wakeup_decrementer(void);
44extern void snapshot_timebase(void);
44 45
45/* Some sane defaults: 125 MHz timebase, 1GHz processor */ 46/* Some sane defaults: 125 MHz timebase, 1GHz processor */
46extern unsigned long ppc_proc_freq; 47extern unsigned long ppc_proc_freq;
@@ -221,5 +222,19 @@ struct cpu_usage {
221 222
222DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array); 223DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
223 224
225#ifdef CONFIG_VIRT_CPU_ACCOUNTING
226extern void account_process_vtime(struct task_struct *tsk);
227#else
228#define account_process_vtime(tsk) do { } while (0)
229#endif
230
231#if defined(CONFIG_VIRT_CPU_ACCOUNTING) && defined(CONFIG_PPC_SPLPAR)
232extern void calculate_steal_time(void);
233extern void snapshot_timebases(void);
234#else
235#define calculate_steal_time() do { } while (0)
236#define snapshot_timebases() do { } while (0)
237#endif
238
224#endif /* __KERNEL__ */ 239#endif /* __KERNEL__ */
225#endif /* __PPC64_TIME_H */ 240#endif /* __PPC64_TIME_H */
diff --git a/include/asm-ppc/harrier.h b/include/asm-ppc/harrier.h
index 36c73ab7e43e..7acd7fc126ec 100644
--- a/include/asm-ppc/harrier.h
+++ b/include/asm-ppc/harrier.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/harrier.h
3 *
4 * Definitions for Motorola MCG Harrier North Bridge & Memory controller 2 * Definitions for Motorola MCG Harrier North Bridge & Memory controller
5 * 3 *
6 * Author: Dale Farnsworth 4 * Author: Dale Farnsworth
diff --git a/include/asm-ppc/ibm44x.h b/include/asm-ppc/ibm44x.h
index f835066fb3ca..3acc382cc83f 100644
--- a/include/asm-ppc/ibm44x.h
+++ b/include/asm-ppc/ibm44x.h
@@ -29,7 +29,7 @@
29 29
30/* TLB entry offset/size used for pinning kernel lowmem */ 30/* TLB entry offset/size used for pinning kernel lowmem */
31#define PPC44x_PIN_SHIFT 28 31#define PPC44x_PIN_SHIFT 28
32#define PPC44x_PIN_SIZE (1 << PPC44x_PIN_SHIFT) 32#define PPC_PIN_SIZE (1 << PPC44x_PIN_SHIFT)
33 33
34/* Lowest TLB slot consumed by the default pinned TLBs */ 34/* Lowest TLB slot consumed by the default pinned TLBs */
35#define PPC44x_LOW_SLOT 63 35#define PPC44x_LOW_SLOT 63
diff --git a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
index 6c28ae7807f4..38f99710752b 100644
--- a/include/asm-ppc/ibm4xx.h
+++ b/include/asm-ppc/ibm4xx.h
@@ -51,6 +51,10 @@
51#include <platforms/4xx/xilinx_ml300.h> 51#include <platforms/4xx/xilinx_ml300.h>
52#endif 52#endif
53 53
54#if defined(CONFIG_XILINX_ML403)
55#include <platforms/4xx/xilinx_ml403.h>
56#endif
57
54#ifndef __ASSEMBLY__ 58#ifndef __ASSEMBLY__
55 59
56#ifdef CONFIG_40x 60#ifdef CONFIG_40x
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index df9cf6ed189d..b919d8fb7d98 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -575,4 +575,11 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
575 */ 575 */
576#define xlate_dev_kmem_ptr(p) p 576#define xlate_dev_kmem_ptr(p) p
577 577
578/* access ports */
579#define setbits32(_addr, _v) out_be32((_addr), in_be32(_addr) | (_v))
580#define clrbits32(_addr, _v) out_be32((_addr), in_be32(_addr) & ~(_v))
581
582#define setbits16(_addr, _v) out_be16((_addr), in_be16(_addr) | (_v))
583#define clrbits16(_addr, _v) out_be16((_addr), in_be16(_addr) & ~(_v))
584
578#endif /* __KERNEL__ */ 585#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mpc10x.h b/include/asm-ppc/mpc10x.h
index 77b1e092c206..b30a6a3b5bd2 100644
--- a/include/asm-ppc/mpc10x.h
+++ b/include/asm-ppc/mpc10x.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/ppc/kernel/mpc10x.h
3 *
4 * Common routines for the Motorola SPS MPC106/8240/107 Host bridge/Mem 2 * Common routines for the Motorola SPS MPC106/8240/107 Host bridge/Mem
5 * ctlr/EPIC/etc. 3 * ctlr/EPIC/etc.
6 * 4 *
@@ -165,6 +163,7 @@ enum ppc_sys_devices {
165 MPC10X_DMA1, 163 MPC10X_DMA1,
166 MPC10X_UART0, 164 MPC10X_UART0,
167 MPC10X_UART1, 165 MPC10X_UART1,
166 NUM_PPC_SYS_DEVS,
168}; 167};
169 168
170int mpc10x_bridge_init(struct pci_controller *hose, 169int mpc10x_bridge_init(struct pci_controller *hose,
diff --git a/include/asm-ppc/mpc52xx.h b/include/asm-ppc/mpc52xx.h
index a055e0756b9d..6167f74635f7 100644
--- a/include/asm-ppc/mpc52xx.h
+++ b/include/asm-ppc/mpc52xx.h
@@ -60,6 +60,7 @@ enum ppc_sys_devices {
60 MPC52xx_ATA, 60 MPC52xx_ATA,
61 MPC52xx_I2C1, 61 MPC52xx_I2C1,
62 MPC52xx_I2C2, 62 MPC52xx_I2C2,
63 NUM_PPC_SYS_DEVS,
63}; 64};
64 65
65 66
diff --git a/include/asm-ppc/mpc8260.h b/include/asm-ppc/mpc8260.h
index 321452695039..6ba69a86b9dd 100644
--- a/include/asm-ppc/mpc8260.h
+++ b/include/asm-ppc/mpc8260.h
@@ -83,6 +83,7 @@ enum ppc_sys_devices {
83 MPC82xx_CPM_SMC2, 83 MPC82xx_CPM_SMC2,
84 MPC82xx_CPM_USB, 84 MPC82xx_CPM_USB,
85 MPC82xx_SEC1, 85 MPC82xx_SEC1,
86 NUM_PPC_SYS_DEVS,
86}; 87};
87 88
88#ifndef __ASSEMBLY__ 89#ifndef __ASSEMBLY__
diff --git a/include/asm-ppc/mpc83xx.h b/include/asm-ppc/mpc83xx.h
index 7cdf60fa69b6..3c23fc43bfbc 100644
--- a/include/asm-ppc/mpc83xx.h
+++ b/include/asm-ppc/mpc83xx.h
@@ -108,6 +108,7 @@ enum ppc_sys_devices {
108 MPC83xx_USB2_DR, 108 MPC83xx_USB2_DR,
109 MPC83xx_USB2_MPH, 109 MPC83xx_USB2_MPH,
110 MPC83xx_MDIO, 110 MPC83xx_MDIO,
111 NUM_PPC_SYS_DEVS,
111}; 112};
112 113
113#endif /* CONFIG_83xx */ 114#endif /* CONFIG_83xx */
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
index c8a96aa44fb7..f47002a60edf 100644
--- a/include/asm-ppc/mpc85xx.h
+++ b/include/asm-ppc/mpc85xx.h
@@ -139,6 +139,7 @@ enum ppc_sys_devices {
139 MPC85xx_eTSEC4, 139 MPC85xx_eTSEC4,
140 MPC85xx_IIC2, 140 MPC85xx_IIC2,
141 MPC85xx_MDIO, 141 MPC85xx_MDIO,
142 NUM_PPC_SYS_DEVS,
142}; 143};
143 144
144/* Internal interrupts are all Level Sensitive, and Positive Polarity */ 145/* Internal interrupts are all Level Sensitive, and Positive Polarity */
diff --git a/include/asm-ppc/mpc8xx.h b/include/asm-ppc/mpc8xx.h
index 46f159cf589e..3515a7fa6c89 100644
--- a/include/asm-ppc/mpc8xx.h
+++ b/include/asm-ppc/mpc8xx.h
@@ -111,8 +111,11 @@ enum ppc_sys_devices {
111 MPC8xx_CPM_SMC1, 111 MPC8xx_CPM_SMC1,
112 MPC8xx_CPM_SMC2, 112 MPC8xx_CPM_SMC2,
113 MPC8xx_CPM_USB, 113 MPC8xx_CPM_USB,
114 NUM_PPC_SYS_DEVS,
114}; 115};
115 116
117#define PPC_PIN_SIZE (24 * 1024 * 1024) /* 24Mbytes of data pinned */
118
116#ifndef BOARD_CHIP_NAME 119#ifndef BOARD_CHIP_NAME
117#define BOARD_CHIP_NAME "" 120#define BOARD_CHIP_NAME ""
118#endif 121#endif
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index 6d1c39e8a6af..e1c62da12e74 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -12,6 +12,7 @@
12#include <asm/processor.h> /* For TASK_SIZE */ 12#include <asm/processor.h> /* For TASK_SIZE */
13#include <asm/mmu.h> 13#include <asm/mmu.h>
14#include <asm/page.h> 14#include <asm/page.h>
15#include <asm/io.h> /* For sub-arch specific PPC_PIN_SIZE */
15struct mm_struct; 16struct mm_struct;
16 17
17extern unsigned long va_to_phys(unsigned long address); 18extern unsigned long va_to_phys(unsigned long address);
@@ -127,9 +128,8 @@ extern unsigned long ioremap_bot, ioremap_base;
127 * of RAM. -- Cort 128 * of RAM. -- Cort
128 */ 129 */
129#define VMALLOC_OFFSET (0x1000000) /* 16M */ 130#define VMALLOC_OFFSET (0x1000000) /* 16M */
130#ifdef CONFIG_44x 131#ifdef PPC_PIN_SIZE
131#include <asm/ibm44x.h> 132#define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
132#define VMALLOC_START (((_ALIGN((long)high_memory, PPC44x_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
133#else 133#else
134#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))) 134#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
135#endif 135#endif
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index 83d8c77c124d..4b94f7059ebe 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -33,6 +33,8 @@
33#include <asm/mpc52xx.h> 33#include <asm/mpc52xx.h>
34#elif defined(CONFIG_MPC10X_BRIDGE) 34#elif defined(CONFIG_MPC10X_BRIDGE)
35#include <asm/mpc10x.h> 35#include <asm/mpc10x.h>
36#elif defined(CONFIG_XILINX_VIRTEX)
37#include <platforms/4xx/virtex.h>
36#else 38#else
37#error "need definition of ppc_sys_devices" 39#error "need definition of ppc_sys_devices"
38#endif 40#endif
@@ -44,9 +46,26 @@ struct ppc_sys_spec {
44 u32 value; 46 u32 value;
45 u32 num_devices; 47 u32 num_devices;
46 char *ppc_sys_name; 48 char *ppc_sys_name;
49 u8 config[NUM_PPC_SYS_DEVS];
47 enum ppc_sys_devices *device_list; 50 enum ppc_sys_devices *device_list;
48}; 51};
49 52
53struct platform_notify_dev_map {
54 const char *bus_id;
55 void (*rtn)(struct platform_device * pdev, int idx);
56};
57
58enum platform_device_func {
59 PPC_SYS_FUNC_DUMMY = 0,
60 PPC_SYS_FUNC_ETH = 1,
61 PPC_SYS_FUNC_UART = 2,
62 PPC_SYS_FUNC_HLDC = 3,
63 PPC_SYS_FUNC_USB = 4,
64 PPC_SYS_FUNC_IRDA = 5,
65};
66
67#define PPC_SYS_CONFIG_DISABLED 1
68
50/* describes all specific chips and which devices they have on them */ 69/* describes all specific chips and which devices they have on them */
51extern struct ppc_sys_spec ppc_sys_specs[]; 70extern struct ppc_sys_spec ppc_sys_specs[];
52extern struct ppc_sys_spec *cur_ppc_sys_spec; 71extern struct ppc_sys_spec *cur_ppc_sys_spec;
@@ -72,5 +91,20 @@ extern void *ppc_sys_get_pdata(enum ppc_sys_devices dev) __init;
72/* remove a device from the system */ 91/* remove a device from the system */
73extern void ppc_sys_device_remove(enum ppc_sys_devices dev); 92extern void ppc_sys_device_remove(enum ppc_sys_devices dev);
74 93
94/* Function assignment stuff */
95void ppc_sys_device_initfunc(void);
96void ppc_sys_device_setfunc(enum ppc_sys_devices dev,
97 enum platform_device_func func);
98void ppc_sys_device_set_func_all(enum platform_device_func func);
99
100void platform_notify_map(const struct platform_notify_dev_map *map,
101 struct device *dev);
102
103/* Enable / disable stuff */
104void ppc_sys_device_disable(enum ppc_sys_devices dev);
105void ppc_sys_device_enable(enum ppc_sys_devices dev);
106void ppc_sys_device_enable_all(void);
107void ppc_sys_device_disable_all(void);
108
75#endif /* __ASM_PPC_SYS_H */ 109#endif /* __ASM_PPC_SYS_H */
76#endif /* __KERNEL__ */ 110#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/time.h b/include/asm-ppc/time.h
index 321fb75b5f22..c86112323c9f 100644
--- a/include/asm-ppc/time.h
+++ b/include/asm-ppc/time.h
@@ -153,5 +153,10 @@ extern __inline__ unsigned binary_tbl(void) {
153({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;}) 153({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
154 154
155unsigned mulhwu_scale_factor(unsigned, unsigned); 155unsigned mulhwu_scale_factor(unsigned, unsigned);
156
157#define account_process_vtime(tsk) do { } while (0)
158#define calculate_steal_time() do { } while (0)
159#define snapshot_timebases() do { } while (0)
160
156#endif /* __ASM_TIME_H__ */ 161#endif /* __ASM_TIME_H__ */
157#endif /* __KERNEL__ */ 162#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/todc.h b/include/asm-ppc/todc.h
index 84bae7d76814..937c7dbe6e5c 100644
--- a/include/asm-ppc/todc.h
+++ b/include/asm-ppc/todc.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-ppc/todc.h
3 *
4 * Definitions for the M48Txx and mc146818 series of Time of day/Real Time 2 * Definitions for the M48Txx and mc146818 series of Time of day/Real Time
5 * Clock chips. 3 * Clock chips.
6 * 4 *
diff --git a/include/asm-ppc/xparameters.h b/include/asm-ppc/xparameters.h
deleted file mode 100644
index fe4eac629139..000000000000
--- a/include/asm-ppc/xparameters.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * include/asm-ppc/xparameters.h
3 *
4 * This file includes the correct xparameters.h for the CONFIG'ed board
5 *
6 * Author: MontaVista Software, Inc.
7 * source@mvista.com
8 *
9 * 2004 (c) MontaVista Software, Inc. This file is licensed under the terms
10 * of the GNU General Public License version 2. This program is licensed
11 * "as is" without any warranty of any kind, whether express or implied.
12 */
13
14#include <linux/config.h>
15
16#if defined(CONFIG_XILINX_ML300)
17#include <platforms/4xx/xparameters/xparameters_ml300.h>
18#endif
diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h
index be6fefe223d6..de1d9926aa60 100644
--- a/include/asm-s390/atomic.h
+++ b/include/asm-s390/atomic.h
@@ -89,10 +89,15 @@ static __inline__ int atomic_cmpxchg(atomic_t *v, int old, int new)
89static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) 89static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
90{ 90{
91 int c, old; 91 int c, old;
92
93 c = atomic_read(v); 92 c = atomic_read(v);
94 while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c) 93 for (;;) {
94 if (unlikely(c == u))
95 break;
96 old = atomic_cmpxchg(v, c, c + a);
97 if (likely(old == c))
98 break;
95 c = old; 99 c = old;
100 }
96 return c != u; 101 return c != u;
97} 102}
98 103
@@ -167,10 +172,15 @@ static __inline__ int atomic64_add_unless(atomic64_t *v,
167 long long a, long long u) 172 long long a, long long u)
168{ 173{
169 long long c, old; 174 long long c, old;
170
171 c = atomic64_read(v); 175 c = atomic64_read(v);
172 while (c != u && (old = atomic64_cmpxchg(v, c, c + a)) != c) 176 for (;;) {
177 if (unlikely(c == u))
178 break;
179 old = atomic64_cmpxchg(v, c, c + a);
180 if (likely(old == c))
181 break;
173 c = old; 182 c = old;
183 }
174 return c != u; 184 return c != u;
175} 185}
176 186
diff --git a/include/asm-s390/percpu.h b/include/asm-s390/percpu.h
index 123fcaca295e..e10ed87094f0 100644
--- a/include/asm-s390/percpu.h
+++ b/include/asm-s390/percpu.h
@@ -46,10 +46,9 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
46#define percpu_modcopy(pcpudst, src, size) \ 46#define percpu_modcopy(pcpudst, src, size) \
47do { \ 47do { \
48 unsigned int __i; \ 48 unsigned int __i; \
49 for (__i = 0; __i < NR_CPUS; __i++) \ 49 for_each_cpu(__i) \
50 if (cpu_possible(__i)) \ 50 memcpy((pcpudst)+__per_cpu_offset[__i], \
51 memcpy((pcpudst)+__per_cpu_offset[__i], \ 51 (src), (size)); \
52 (src), (size)); \
53} while (0) 52} while (0)
54 53
55#else /* ! SMP */ 54#else /* ! SMP */
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h
index 25256bdc8aae..468eb48d8142 100644
--- a/include/asm-sparc64/atomic.h
+++ b/include/asm-sparc64/atomic.h
@@ -78,9 +78,15 @@ extern int atomic64_sub_ret(int, atomic64_t *);
78({ \ 78({ \
79 int c, old; \ 79 int c, old; \
80 c = atomic_read(v); \ 80 c = atomic_read(v); \
81 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 81 for (;;) { \
82 if (unlikely(c == (u))) \
83 break; \
84 old = atomic_cmpxchg((v), c, c + (a)); \
85 if (likely(old == c)) \
86 break; \
82 c = old; \ 87 c = old; \
83 c != (u); \ 88 } \
89 likely(c != (u)); \
84}) 90})
85#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 91#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
86 92
diff --git a/include/asm-sparc64/cache.h b/include/asm-sparc64/cache.h
index f7d35a2ae9b8..e9df17acedde 100644
--- a/include/asm-sparc64/cache.h
+++ b/include/asm-sparc64/cache.h
@@ -13,4 +13,6 @@
13#define SMP_CACHE_BYTES_SHIFT 6 13#define SMP_CACHE_BYTES_SHIFT 6
14#define SMP_CACHE_BYTES (1 << SMP_CACHE_BYTES_SHIFT) /* L2 cache line size. */ 14#define SMP_CACHE_BYTES (1 << SMP_CACHE_BYTES_SHIFT) /* L2 cache line size. */
15 15
16#define __read_mostly __attribute__((__section__(".data.read_mostly")))
17
16#endif 18#endif
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
index aea4e51e7cd1..82032e159a76 100644
--- a/include/asm-sparc64/percpu.h
+++ b/include/asm-sparc64/percpu.h
@@ -26,10 +26,9 @@ register unsigned long __local_per_cpu_offset asm("g5");
26#define percpu_modcopy(pcpudst, src, size) \ 26#define percpu_modcopy(pcpudst, src, size) \
27do { \ 27do { \
28 unsigned int __i; \ 28 unsigned int __i; \
29 for (__i = 0; __i < NR_CPUS; __i++) \ 29 for_each_cpu(__i) \
30 if (cpu_possible(__i)) \ 30 memcpy((pcpudst)+__per_cpu_offset(__i), \
31 memcpy((pcpudst)+__per_cpu_offset(__i), \ 31 (src), (size)); \
32 (src), (size)); \
33} while (0) 32} while (0)
34#else /* ! SMP */ 33#else /* ! SMP */
35 34
diff --git a/include/asm-um/alternative.h b/include/asm-um/alternative.h
new file mode 100644
index 000000000000..b6434396bd42
--- /dev/null
+++ b/include/asm-um/alternative.h
@@ -0,0 +1,6 @@
1#ifndef __UM_ALTERNATIVE_H
2#define __UM_ALTERNATIVE_H
3
4#include "asm/arch/alternative.h"
5
6#endif
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index 4b5cd553e772..cecbf7baa6aa 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -405,8 +405,14 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
405({ \ 405({ \
406 int c, old; \ 406 int c, old; \
407 c = atomic_read(v); \ 407 c = atomic_read(v); \
408 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 408 for (;;) { \
409 if (unlikely(c == (u))) \
410 break; \
411 old = atomic_cmpxchg((v), c, c + (a)); \
412 if (likely(old == c)) \
413 break; \
409 c = old; \ 414 c = old; \
415 } \
410 c != (u); \ 416 c != (u); \
411}) 417})
412#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 418#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-x86_64/cache.h b/include/asm-x86_64/cache.h
index 263f0a211ed7..c8043a16152e 100644
--- a/include/asm-x86_64/cache.h
+++ b/include/asm-x86_64/cache.h
@@ -20,6 +20,8 @@
20 __attribute__((__section__(".data.page_aligned"))) 20 __attribute__((__section__(".data.page_aligned")))
21#endif 21#endif
22 22
23#define __read_mostly __attribute__((__section__(".data.read_mostly")))
24
23#endif 25#endif
24 26
25#endif 27#endif
diff --git a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
index 29a6b0408f75..4405b4adeaba 100644
--- a/include/asm-x86_64/percpu.h
+++ b/include/asm-x86_64/percpu.h
@@ -26,10 +26,9 @@
26#define percpu_modcopy(pcpudst, src, size) \ 26#define percpu_modcopy(pcpudst, src, size) \
27do { \ 27do { \
28 unsigned int __i; \ 28 unsigned int __i; \
29 for (__i = 0; __i < NR_CPUS; __i++) \ 29 for_each_cpu(__i) \
30 if (cpu_possible(__i)) \ 30 memcpy((pcpudst)+__per_cpu_offset(__i), \
31 memcpy((pcpudst)+__per_cpu_offset(__i), \ 31 (src), (size)); \
32 (src), (size)); \
33} while (0) 32} while (0)
34 33
35extern void setup_per_cpu_areas(void); 34extern void setup_per_cpu_areas(void);
diff --git a/include/linux/ata.h b/include/linux/ata.h
index b02a16c435e7..312a2c0c64e6 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -146,6 +146,8 @@ enum {
146 ATA_CMD_STANDBYNOW1 = 0xE0, 146 ATA_CMD_STANDBYNOW1 = 0xE0,
147 ATA_CMD_IDLEIMMEDIATE = 0xE1, 147 ATA_CMD_IDLEIMMEDIATE = 0xE1,
148 ATA_CMD_INIT_DEV_PARAMS = 0x91, 148 ATA_CMD_INIT_DEV_PARAMS = 0x91,
149 ATA_CMD_READ_NATIVE_MAX = 0xF8,
150 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
149 151
150 /* SETFEATURES stuff */ 152 /* SETFEATURES stuff */
151 SETFEATURES_XFER = 0x03, 153 SETFEATURES_XFER = 0x03,
@@ -204,7 +206,6 @@ enum ata_tf_protocols {
204 ATA_PROT_UNKNOWN, /* unknown/invalid */ 206 ATA_PROT_UNKNOWN, /* unknown/invalid */
205 ATA_PROT_NODATA, /* no data */ 207 ATA_PROT_NODATA, /* no data */
206 ATA_PROT_PIO, /* PIO single sector */ 208 ATA_PROT_PIO, /* PIO single sector */
207 ATA_PROT_PIO_MULT, /* PIO multiple sector */
208 ATA_PROT_DMA, /* DMA */ 209 ATA_PROT_DMA, /* DMA */
209 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ 210 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/
210 ATA_PROT_ATAPI_NODATA, /* packet command, no data */ 211 ATA_PROT_ATAPI_NODATA, /* packet command, no data */
@@ -247,18 +248,22 @@ struct ata_taskfile {
247}; 248};
248 249
249#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 250#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
251#define ata_id_is_cfa(id) ((id)[0] == 0x848A)
250#define ata_id_is_sata(id) ((id)[93] == 0) 252#define ata_id_is_sata(id) ((id)[93] == 0)
251#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) 253#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
252#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) 254#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
255#define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10))
253#define ata_id_has_fua(id) ((id)[84] & (1 << 6)) 256#define ata_id_has_fua(id) ((id)[84] & (1 << 6))
254#define ata_id_has_flush(id) ((id)[83] & (1 << 12)) 257#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
255#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13)) 258#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
256#define ata_id_has_lba48(id) ((id)[83] & (1 << 10)) 259#define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
260#define ata_id_has_hpa(id) ((id)[82] & (1 << 10))
257#define ata_id_has_wcache(id) ((id)[82] & (1 << 5)) 261#define ata_id_has_wcache(id) ((id)[82] & (1 << 5))
258#define ata_id_has_pm(id) ((id)[82] & (1 << 3)) 262#define ata_id_has_pm(id) ((id)[82] & (1 << 3))
259#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 263#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
260#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 264#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
261#define ata_id_removeable(id) ((id)[0] & (1 << 7)) 265#define ata_id_removeable(id) ((id)[0] & (1 << 7))
266#define ata_id_has_dword_io(id) ((id)[50] & (1 << 0))
262#define ata_id_u32(id,n) \ 267#define ata_id_u32(id,n) \
263 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) 268 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
264#define ata_id_u64(id,n) \ 269#define ata_id_u64(id,n) \
diff --git a/include/linux/cache.h b/include/linux/cache.h
index d22e632f41fb..cc4b3aafad9a 100644
--- a/include/linux/cache.h
+++ b/include/linux/cache.h
@@ -13,9 +13,7 @@
13#define SMP_CACHE_BYTES L1_CACHE_BYTES 13#define SMP_CACHE_BYTES L1_CACHE_BYTES
14#endif 14#endif
15 15
16#if defined(CONFIG_X86) || defined(CONFIG_SPARC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC) 16#ifndef __read_mostly
17#define __read_mostly __attribute__((__section__(".data.read_mostly")))
18#else
19#define __read_mostly 17#define __read_mostly
20#endif 18#endif
21 19
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index b68fdf1f3156..3c9b0bc05123 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -378,7 +378,6 @@ struct cdrom_generic_command
378#define CDC_MEDIA_CHANGED 0x80 /* media changed */ 378#define CDC_MEDIA_CHANGED 0x80 /* media changed */
379#define CDC_PLAY_AUDIO 0x100 /* audio functions */ 379#define CDC_PLAY_AUDIO 0x100 /* audio functions */
380#define CDC_RESET 0x200 /* hard reset device */ 380#define CDC_RESET 0x200 /* hard reset device */
381#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */
382#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ 381#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */
383#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ 382#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */
384#define CDC_CD_R 0x2000 /* drive is a CD-R */ 383#define CDC_CD_R 0x2000 /* drive is a CD-R */
@@ -974,9 +973,7 @@ struct cdrom_device_ops {
974 int (*reset) (struct cdrom_device_info *); 973 int (*reset) (struct cdrom_device_info *);
975 /* play stuff */ 974 /* play stuff */
976 int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *); 975 int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
977 /* dev-specific */ 976
978 int (*dev_ioctl) (struct cdrom_device_info *,
979 unsigned int, unsigned long);
980/* driver specifications */ 977/* driver specifications */
981 const int capability; /* capability flags */ 978 const int capability; /* capability flags */
982 int n_minors; /* number of active minor devices */ 979 int n_minors; /* number of active minor devices */
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index 1289f0ec4c00..1e4bdfcf83a2 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -52,7 +52,12 @@ struct file;
52#ifdef CONFIG_EPOLL 52#ifdef CONFIG_EPOLL
53 53
54/* Used to initialize the epoll bits inside the "struct file" */ 54/* Used to initialize the epoll bits inside the "struct file" */
55void eventpoll_init_file(struct file *file); 55static inline void eventpoll_init_file(struct file *file)
56{
57 INIT_LIST_HEAD(&file->f_ep_links);
58 spin_lock_init(&file->f_ep_lock);
59}
60
56 61
57/* Used to release the epoll bits inside the "struct file" */ 62/* Used to release the epoll bits inside the "struct file" */
58void eventpoll_release_file(struct file *file); 63void eventpoll_release_file(struct file *file);
@@ -85,7 +90,6 @@ static inline void eventpoll_release(struct file *file)
85 eventpoll_release_file(file); 90 eventpoll_release_file(file);
86} 91}
87 92
88
89#else 93#else
90 94
91static inline void eventpoll_init_file(struct file *file) {} 95static inline void eventpoll_init_file(struct file *file) {}
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index c0272d73ab20..e7239f2f97a1 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -772,9 +772,12 @@ extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
772 772
773 773
774/* inode.c */ 774/* inode.c */
775extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int); 775int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
776extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *); 776struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
777extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *); 777struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
778int ext3_get_block_handle(handle_t *handle, struct inode *inode,
779 sector_t iblock, struct buffer_head *bh_result, int create,
780 int extend_disksize);
778 781
779extern void ext3_read_inode (struct inode *); 782extern void ext3_read_inode (struct inode *);
780extern int ext3_write_inode (struct inode *, int); 783extern int ext3_write_inode (struct inode *, int);
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
index e71dd98dbcae..7abf90147180 100644
--- a/include/linux/ext3_fs_i.h
+++ b/include/linux/ext3_fs_i.h
@@ -19,6 +19,7 @@
19#include <linux/rwsem.h> 19#include <linux/rwsem.h>
20#include <linux/rbtree.h> 20#include <linux/rbtree.h>
21#include <linux/seqlock.h> 21#include <linux/seqlock.h>
22#include <linux/mutex.h>
22 23
23struct ext3_reserve_window { 24struct ext3_reserve_window {
24 __u32 _rsv_start; /* First byte reserved */ 25 __u32 _rsv_start; /* First byte reserved */
@@ -122,16 +123,16 @@ struct ext3_inode_info {
122 __u16 i_extra_isize; 123 __u16 i_extra_isize;
123 124
124 /* 125 /*
125 * truncate_sem is for serialising ext3_truncate() against 126 * truncate_mutex is for serialising ext3_truncate() against
126 * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's 127 * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's
127 * data tree are chopped off during truncate. We can't do that in 128 * data tree are chopped off during truncate. We can't do that in
128 * ext3 because whenever we perform intermediate commits during 129 * ext3 because whenever we perform intermediate commits during
129 * truncate, the inode and all the metadata blocks *must* be in a 130 * truncate, the inode and all the metadata blocks *must* be in a
130 * consistent state which allows truncation of the orphans to restart 131 * consistent state which allows truncation of the orphans to restart
131 * during recovery. Hence we must fix the get_block-vs-truncate race 132 * during recovery. Hence we must fix the get_block-vs-truncate race
132 * by other means, so we have truncate_sem. 133 * by other means, so we have truncate_mutex.
133 */ 134 */
134 struct semaphore truncate_sem; 135 struct mutex truncate_mutex;
135 struct inode vfs_inode; 136 struct inode vfs_inode;
136}; 137};
137 138
diff --git a/include/linux/file.h b/include/linux/file.h
index 9901b850f2e4..9f7c2513866f 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -10,6 +10,7 @@
10#include <linux/compiler.h> 10#include <linux/compiler.h>
11#include <linux/spinlock.h> 11#include <linux/spinlock.h>
12#include <linux/rcupdate.h> 12#include <linux/rcupdate.h>
13#include <linux/types.h>
13 14
14/* 15/*
15 * The default fd array needs to be at least BITS_PER_LONG, 16 * The default fd array needs to be at least BITS_PER_LONG,
@@ -17,10 +18,22 @@
17 */ 18 */
18#define NR_OPEN_DEFAULT BITS_PER_LONG 19#define NR_OPEN_DEFAULT BITS_PER_LONG
19 20
21/*
22 * The embedded_fd_set is a small fd_set,
23 * suitable for most tasks (which open <= BITS_PER_LONG files)
24 */
25struct embedded_fd_set {
26 unsigned long fds_bits[1];
27};
28
29/*
30 * More than this number of fds: we use a separately allocated fd_set
31 */
32#define EMBEDDED_FD_SET_SIZE (BITS_PER_BYTE * sizeof(struct embedded_fd_set))
33
20struct fdtable { 34struct fdtable {
21 unsigned int max_fds; 35 unsigned int max_fds;
22 int max_fdset; 36 int max_fdset;
23 int next_fd;
24 struct file ** fd; /* current fd array */ 37 struct file ** fd; /* current fd array */
25 fd_set *close_on_exec; 38 fd_set *close_on_exec;
26 fd_set *open_fds; 39 fd_set *open_fds;
@@ -33,13 +46,20 @@ struct fdtable {
33 * Open file table structure 46 * Open file table structure
34 */ 47 */
35struct files_struct { 48struct files_struct {
49 /*
50 * read mostly part
51 */
36 atomic_t count; 52 atomic_t count;
37 struct fdtable *fdt; 53 struct fdtable *fdt;
38 struct fdtable fdtab; 54 struct fdtable fdtab;
39 fd_set close_on_exec_init; 55 /*
40 fd_set open_fds_init; 56 * written part on a separate cache line in SMP
57 */
58 spinlock_t file_lock ____cacheline_aligned_in_smp;
59 int next_fd;
60 struct embedded_fd_set close_on_exec_init;
61 struct embedded_fd_set open_fds_init;
41 struct file * fd_array[NR_OPEN_DEFAULT]; 62 struct file * fd_array[NR_OPEN_DEFAULT];
42 spinlock_t file_lock; /* Protects concurrent writers. Nests inside tsk->alloc_lock */
43}; 63};
44 64
45#define files_fdtable(files) (rcu_dereference((files)->fdt)) 65#define files_fdtable(files) (rcu_dereference((files)->fdt))
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 128d0082522c..f9c9dea636d0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -397,8 +397,8 @@ struct block_device {
397 dev_t bd_dev; /* not a kdev_t - it's a search key */ 397 dev_t bd_dev; /* not a kdev_t - it's a search key */
398 struct inode * bd_inode; /* will die */ 398 struct inode * bd_inode; /* will die */
399 int bd_openers; 399 int bd_openers;
400 struct semaphore bd_sem; /* open/close mutex */ 400 struct mutex bd_mutex; /* open/close mutex */
401 struct semaphore bd_mount_sem; /* mount mutex */ 401 struct mutex bd_mount_mutex; /* mount mutex */
402 struct list_head bd_inodes; 402 struct list_head bd_inodes;
403 void * bd_holder; 403 void * bd_holder;
404 int bd_holders; 404 int bd_holders;
@@ -509,7 +509,7 @@ struct inode {
509 509
510#ifdef CONFIG_INOTIFY 510#ifdef CONFIG_INOTIFY
511 struct list_head inotify_watches; /* watches on this inode */ 511 struct list_head inotify_watches; /* watches on this inode */
512 struct semaphore inotify_sem; /* protects the watches list */ 512 struct mutex inotify_mutex; /* protects the watches list */
513#endif 513#endif
514 514
515 unsigned long i_state; 515 unsigned long i_state;
@@ -847,7 +847,7 @@ struct super_block {
847 * The next field is for VFS *only*. No filesystems have any business 847 * The next field is for VFS *only*. No filesystems have any business
848 * even looking at it. You had been warned. 848 * even looking at it. You had been warned.
849 */ 849 */
850 struct semaphore s_vfs_rename_sem; /* Kludge */ 850 struct mutex s_vfs_rename_mutex; /* Kludge */
851 851
852 /* Granuality of c/m/atime in ns. 852 /* Granuality of c/m/atime in ns.
853 Cannot be worse than a second */ 853 Cannot be worse than a second */
@@ -1115,6 +1115,18 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
1115 __mark_inode_dirty(inode, I_DIRTY_SYNC); 1115 __mark_inode_dirty(inode, I_DIRTY_SYNC);
1116} 1116}
1117 1117
1118static inline void inode_inc_link_count(struct inode *inode)
1119{
1120 inode->i_nlink++;
1121 mark_inode_dirty(inode);
1122}
1123
1124static inline void inode_dec_link_count(struct inode *inode)
1125{
1126 inode->i_nlink--;
1127 mark_inode_dirty(inode);
1128}
1129
1118extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry); 1130extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
1119static inline void file_accessed(struct file *file) 1131static inline void file_accessed(struct file *file)
1120{ 1132{
@@ -1534,7 +1546,7 @@ extern void destroy_inode(struct inode *);
1534extern struct inode *new_inode(struct super_block *); 1546extern struct inode *new_inode(struct super_block *);
1535extern int remove_suid(struct dentry *); 1547extern int remove_suid(struct dentry *);
1536extern void remove_dquot_ref(struct super_block *, int, struct list_head *); 1548extern void remove_dquot_ref(struct super_block *, int, struct list_head *);
1537extern struct semaphore iprune_sem; 1549extern struct mutex iprune_mutex;
1538 1550
1539extern void __insert_inode_hash(struct inode *, unsigned long hashval); 1551extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1540extern void remove_inode_hash(struct inode *); 1552extern void remove_inode_hash(struct inode *);
diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
index 0abe9d9a0069..652611a4bdcd 100644
--- a/include/linux/generic_serial.h
+++ b/include/linux/generic_serial.h
@@ -12,6 +12,8 @@
12#ifndef GENERIC_SERIAL_H 12#ifndef GENERIC_SERIAL_H
13#define GENERIC_SERIAL_H 13#define GENERIC_SERIAL_H
14 14
15#include <linux/mutex.h>
16
15struct real_driver { 17struct real_driver {
16 void (*disable_tx_interrupts) (void *); 18 void (*disable_tx_interrupts) (void *);
17 void (*enable_tx_interrupts) (void *); 19 void (*enable_tx_interrupts) (void *);
@@ -34,7 +36,7 @@ struct gs_port {
34 int xmit_head; 36 int xmit_head;
35 int xmit_tail; 37 int xmit_tail;
36 int xmit_cnt; 38 int xmit_cnt;
37 struct semaphore port_write_sem; 39 struct mutex port_write_mutex;
38 int flags; 40 int flags;
39 wait_queue_head_t open_wait; 41 wait_queue_head_t open_wait;
40 wait_queue_head_t close_wait; 42 wait_queue_head_t close_wait;
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index eef5ccdcd731..fd647fde5ec1 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -149,22 +149,16 @@ struct disk_attribute {
149({ \ 149({ \
150 typeof(gendiskp->dkstats->field) res = 0; \ 150 typeof(gendiskp->dkstats->field) res = 0; \
151 int i; \ 151 int i; \
152 for (i=0; i < NR_CPUS; i++) { \ 152 for_each_cpu(i) \
153 if (!cpu_possible(i)) \
154 continue; \
155 res += per_cpu_ptr(gendiskp->dkstats, i)->field; \ 153 res += per_cpu_ptr(gendiskp->dkstats, i)->field; \
156 } \
157 res; \ 154 res; \
158}) 155})
159 156
160static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { 157static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
161 int i; 158 int i;
162 for (i=0; i < NR_CPUS; i++) { 159 for_each_cpu(i)
163 if (cpu_possible(i)) { 160 memset(per_cpu_ptr(gendiskp->dkstats, i), value,
164 memset(per_cpu_ptr(gendiskp->dkstats, i), value, 161 sizeof (struct disk_stats));
165 sizeof (struct disk_stats));
166 }
167 }
168} 162}
169 163
170#else 164#else
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index dcfd2ecccb5d..92146f3b7423 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -7,11 +7,10 @@
7#define INIT_FDTABLE \ 7#define INIT_FDTABLE \
8{ \ 8{ \
9 .max_fds = NR_OPEN_DEFAULT, \ 9 .max_fds = NR_OPEN_DEFAULT, \
10 .max_fdset = __FD_SETSIZE, \ 10 .max_fdset = EMBEDDED_FD_SET_SIZE, \
11 .next_fd = 0, \
12 .fd = &init_files.fd_array[0], \ 11 .fd = &init_files.fd_array[0], \
13 .close_on_exec = &init_files.close_on_exec_init, \ 12 .close_on_exec = (fd_set *)&init_files.close_on_exec_init, \
14 .open_fds = &init_files.open_fds_init, \ 13 .open_fds = (fd_set *)&init_files.open_fds_init, \
15 .rcu = RCU_HEAD_INIT, \ 14 .rcu = RCU_HEAD_INIT, \
16 .free_files = NULL, \ 15 .free_files = NULL, \
17 .next = NULL, \ 16 .next = NULL, \
@@ -20,9 +19,10 @@
20#define INIT_FILES \ 19#define INIT_FILES \
21{ \ 20{ \
22 .count = ATOMIC_INIT(1), \ 21 .count = ATOMIC_INIT(1), \
23 .file_lock = SPIN_LOCK_UNLOCKED, \
24 .fdt = &init_files.fdtab, \ 22 .fdt = &init_files.fdtab, \
25 .fdtab = INIT_FDTABLE, \ 23 .fdtab = INIT_FDTABLE, \
24 .file_lock = SPIN_LOCK_UNLOCKED, \
25 .next_fd = 0, \
26 .close_on_exec_init = { { 0, } }, \ 26 .close_on_exec_init = { { 0, } }, \
27 .open_fds_init = { { 0, } }, \ 27 .open_fds_init = { { 0, } }, \
28 .fd_array = { NULL, } \ 28 .fd_array = { NULL, } \
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 41ee79962bb2..2ccbfb6340ba 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -28,6 +28,7 @@
28#include <linux/journal-head.h> 28#include <linux/journal-head.h>
29#include <linux/stddef.h> 29#include <linux/stddef.h>
30#include <linux/bit_spinlock.h> 30#include <linux/bit_spinlock.h>
31#include <linux/mutex.h>
31#include <asm/semaphore.h> 32#include <asm/semaphore.h>
32#endif 33#endif
33 34
@@ -575,7 +576,7 @@ struct transaction_s
575 * @j_wait_checkpoint: Wait queue to trigger checkpointing 576 * @j_wait_checkpoint: Wait queue to trigger checkpointing
576 * @j_wait_commit: Wait queue to trigger commit 577 * @j_wait_commit: Wait queue to trigger commit
577 * @j_wait_updates: Wait queue to wait for updates to complete 578 * @j_wait_updates: Wait queue to wait for updates to complete
578 * @j_checkpoint_sem: Semaphore for locking against concurrent checkpoints 579 * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints
579 * @j_head: Journal head - identifies the first unused block in the journal 580 * @j_head: Journal head - identifies the first unused block in the journal
580 * @j_tail: Journal tail - identifies the oldest still-used block in the 581 * @j_tail: Journal tail - identifies the oldest still-used block in the
581 * journal. 582 * journal.
@@ -645,7 +646,7 @@ struct journal_s
645 int j_barrier_count; 646 int j_barrier_count;
646 647
647 /* The barrier lock itself */ 648 /* The barrier lock itself */
648 struct semaphore j_barrier; 649 struct mutex j_barrier;
649 650
650 /* 651 /*
651 * Transactions: The current running transaction... 652 * Transactions: The current running transaction...
@@ -687,7 +688,7 @@ struct journal_s
687 wait_queue_head_t j_wait_updates; 688 wait_queue_head_t j_wait_updates;
688 689
689 /* Semaphore for locking against concurrent checkpoints */ 690 /* Semaphore for locking against concurrent checkpoints */
690 struct semaphore j_checkpoint_sem; 691 struct mutex j_checkpoint_mutex;
691 692
692 /* 693 /*
693 * Journal head: identifies the first unused block in the journal. 694 * Journal head: identifies the first unused block in the journal.
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3b507bf05d09..bb6e7ddee2fd 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -91,6 +91,9 @@ extern struct notifier_block *panic_notifier_list;
91extern long (*panic_blink)(long time); 91extern long (*panic_blink)(long time);
92NORET_TYPE void panic(const char * fmt, ...) 92NORET_TYPE void panic(const char * fmt, ...)
93 __attribute__ ((NORET_AND format (printf, 1, 2))); 93 __attribute__ ((NORET_AND format (printf, 1, 2)));
94extern void oops_enter(void);
95extern void oops_exit(void);
96extern int oops_may_print(void);
94fastcall NORET_TYPE void do_exit(long error_code) 97fastcall NORET_TYPE void do_exit(long error_code)
95 ATTRIB_NORET; 98 ATTRIB_NORET;
96NORET_TYPE void complete_and_exit(struct completion *, long) 99NORET_TYPE void complete_and_exit(struct completion *, long)
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 669756bc20a2..778adc0fa640 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -36,6 +36,7 @@
36#include <linux/percpu.h> 36#include <linux/percpu.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/rcupdate.h> 38#include <linux/rcupdate.h>
39#include <linux/mutex.h>
39 40
40#ifdef CONFIG_KPROBES 41#ifdef CONFIG_KPROBES
41#include <asm/kprobes.h> 42#include <asm/kprobes.h>
@@ -152,7 +153,7 @@ struct kretprobe_instance {
152}; 153};
153 154
154extern spinlock_t kretprobe_lock; 155extern spinlock_t kretprobe_lock;
155extern struct semaphore kprobe_mutex; 156extern struct mutex kprobe_mutex;
156extern int arch_prepare_kprobe(struct kprobe *p); 157extern int arch_prepare_kprobe(struct kprobe *p);
157extern void arch_arm_kprobe(struct kprobe *p); 158extern void arch_arm_kprobe(struct kprobe *p);
158extern void arch_disarm_kprobe(struct kprobe *p); 159extern void arch_disarm_kprobe(struct kprobe *p);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 204c37a55f06..7a54244d30aa 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -502,6 +502,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
502extern void ata_pci_remove_one (struct pci_dev *pdev); 502extern void ata_pci_remove_one (struct pci_dev *pdev);
503extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); 503extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state);
504extern int ata_pci_device_resume(struct pci_dev *pdev); 504extern int ata_pci_device_resume(struct pci_dev *pdev);
505extern int ata_pci_clear_simplex(struct pci_dev *pdev);
505#endif /* CONFIG_PCI */ 506#endif /* CONFIG_PCI */
506extern int ata_device_add(const struct ata_probe_ent *ent); 507extern int ata_device_add(const struct ata_probe_ent *ent);
507extern void ata_host_set_remove(struct ata_host_set *host_set); 508extern void ata_host_set_remove(struct ata_host_set *host_set);
@@ -542,6 +543,7 @@ extern void ata_port_stop (struct ata_port *ap);
542extern void ata_host_stop (struct ata_host_set *host_set); 543extern void ata_host_stop (struct ata_host_set *host_set);
543extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); 544extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
544extern void ata_qc_prep(struct ata_queued_cmd *qc); 545extern void ata_qc_prep(struct ata_queued_cmd *qc);
546extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
545extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); 547extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
546extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, 548extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
547 unsigned int buflen); 549 unsigned int buflen);
@@ -608,7 +610,7 @@ extern void ata_pci_host_stop (struct ata_host_set *host_set);
608extern struct ata_probe_ent * 610extern struct ata_probe_ent *
609ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); 611ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
610extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 612extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
611 613extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long);
612#endif /* CONFIG_PCI */ 614#endif /* CONFIG_PCI */
613 615
614 616
diff --git a/include/linux/loop.h b/include/linux/loop.h
index f96506782ebe..e76c7611d6cc 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -17,6 +17,7 @@
17#include <linux/bio.h> 17#include <linux/bio.h>
18#include <linux/blkdev.h> 18#include <linux/blkdev.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/mutex.h>
20 21
21/* Possible states of device */ 22/* Possible states of device */
22enum { 23enum {
@@ -60,7 +61,7 @@ struct loop_device {
60 int lo_state; 61 int lo_state;
61 struct completion lo_done; 62 struct completion lo_done;
62 struct completion lo_bh_done; 63 struct completion lo_bh_done;
63 struct semaphore lo_ctl_mutex; 64 struct mutex lo_ctl_mutex;
64 int lo_pending; 65 int lo_pending;
65 66
66 request_queue_t *lo_queue; 67 request_queue_t *lo_queue;
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index 8bcd9450d926..779e6a5744c7 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -184,6 +184,7 @@ struct fat_slot_info {
184#include <linux/string.h> 184#include <linux/string.h>
185#include <linux/nls.h> 185#include <linux/nls.h>
186#include <linux/fs.h> 186#include <linux/fs.h>
187#include <linux/mutex.h>
187 188
188struct fat_mount_options { 189struct fat_mount_options {
189 uid_t fs_uid; 190 uid_t fs_uid;
@@ -226,7 +227,7 @@ struct msdos_sb_info {
226 unsigned long max_cluster; /* maximum cluster number */ 227 unsigned long max_cluster; /* maximum cluster number */
227 unsigned long root_cluster; /* first cluster of the root directory */ 228 unsigned long root_cluster; /* first cluster of the root directory */
228 unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */ 229 unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
229 struct semaphore fat_lock; 230 struct mutex fat_lock;
230 unsigned int prev_free; /* previously allocated cluster number */ 231 unsigned int prev_free; /* previously allocated cluster number */
231 unsigned int free_clusters; /* -1 if undefined */ 232 unsigned int free_clusters; /* -1 if undefined */
232 struct fat_mount_options options; 233 struct fat_mount_options options;
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index f95d51fae733..a6ce409ec6fc 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -38,6 +38,7 @@ enum {
38#ifdef __KERNEL__ 38#ifdef __KERNEL__
39 39
40#include <linux/wait.h> 40#include <linux/wait.h>
41#include <linux/mutex.h>
41 42
42/* values for flags field */ 43/* values for flags field */
43#define NBD_READ_ONLY 0x0001 44#define NBD_READ_ONLY 0x0001
@@ -57,7 +58,7 @@ struct nbd_device {
57 struct request *active_req; 58 struct request *active_req;
58 wait_queue_head_t active_wq; 59 wait_queue_head_t active_wq;
59 60
60 struct semaphore tx_lock; 61 struct mutex tx_lock;
61 struct gendisk *disk; 62 struct gendisk *disk;
62 int blksize; 63 int blksize;
63 u64 bytesize; 64 u64 bytesize;
diff --git a/include/linux/ncp_fs_i.h b/include/linux/ncp_fs_i.h
index 415be1ec6f98..bdb4c8ae6924 100644
--- a/include/linux/ncp_fs_i.h
+++ b/include/linux/ncp_fs_i.h
@@ -19,7 +19,7 @@ struct ncp_inode_info {
19 __le32 DosDirNum; 19 __le32 DosDirNum;
20 __u8 volNumber; 20 __u8 volNumber;
21 __le32 nwattr; 21 __le32 nwattr;
22 struct semaphore open_sem; 22 struct mutex open_mutex;
23 atomic_t opened; 23 atomic_t opened;
24 int access; 24 int access;
25 int flags; 25 int flags;
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
index cf858eb80f0b..b089d9506283 100644
--- a/include/linux/ncp_fs_sb.h
+++ b/include/linux/ncp_fs_sb.h
@@ -11,6 +11,7 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/ncp_mount.h> 12#include <linux/ncp_mount.h>
13#include <linux/net.h> 13#include <linux/net.h>
14#include <linux/mutex.h>
14 15
15#ifdef __KERNEL__ 16#ifdef __KERNEL__
16 17
@@ -51,7 +52,7 @@ struct ncp_server {
51 receive replies */ 52 receive replies */
52 53
53 int lock; /* To prevent mismatch in protocols. */ 54 int lock; /* To prevent mismatch in protocols. */
54 struct semaphore sem; 55 struct mutex mutex;
55 56
56 int current_size; /* for packet preparation */ 57 int current_size; /* for packet preparation */
57 int has_subfunction; 58 int has_subfunction;
@@ -96,7 +97,7 @@ struct ncp_server {
96 struct { 97 struct {
97 struct work_struct tq; /* STREAM/DGRAM: data/error ready */ 98 struct work_struct tq; /* STREAM/DGRAM: data/error ready */
98 struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */ 99 struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
99 struct semaphore creq_sem; /* DGRAM only: lock accesses to rcv.creq */ 100 struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
100 101
101 unsigned int state; /* STREAM only: receiver state */ 102 unsigned int state; /* STREAM only: receiver state */
102 struct { 103 struct {
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 46a0f974f87c..1350e47b0234 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -4,6 +4,62 @@
4#define XT_FUNCTION_MAXNAMELEN 30 4#define XT_FUNCTION_MAXNAMELEN 30
5#define XT_TABLE_MAXNAMELEN 32 5#define XT_TABLE_MAXNAMELEN 32
6 6
7struct xt_entry_match
8{
9 union {
10 struct {
11 u_int16_t match_size;
12
13 /* Used by userspace */
14 char name[XT_FUNCTION_MAXNAMELEN-1];
15
16 u_int8_t revision;
17 } user;
18 struct {
19 u_int16_t match_size;
20
21 /* Used inside the kernel */
22 struct xt_match *match;
23 } kernel;
24
25 /* Total length */
26 u_int16_t match_size;
27 } u;
28
29 unsigned char data[0];
30};
31
32struct xt_entry_target
33{
34 union {
35 struct {
36 u_int16_t target_size;
37
38 /* Used by userspace */
39 char name[XT_FUNCTION_MAXNAMELEN-1];
40
41 u_int8_t revision;
42 } user;
43 struct {
44 u_int16_t target_size;
45
46 /* Used inside the kernel */
47 struct xt_target *target;
48 } kernel;
49
50 /* Total length */
51 u_int16_t target_size;
52 } u;
53
54 unsigned char data[0];
55};
56
57struct xt_standard_target
58{
59 struct xt_entry_target target;
60 int verdict;
61};
62
7/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision 63/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
8 * kernel supports, if >= revision. */ 64 * kernel supports, if >= revision. */
9struct xt_get_revision 65struct xt_get_revision
@@ -220,10 +276,10 @@ struct xt_table_info
220 char *entries[NR_CPUS]; 276 char *entries[NR_CPUS];
221}; 277};
222 278
223extern int xt_register_target(int af, struct xt_target *target); 279extern int xt_register_target(struct xt_target *target);
224extern void xt_unregister_target(int af, struct xt_target *target); 280extern void xt_unregister_target(struct xt_target *target);
225extern int xt_register_match(int af, struct xt_match *target); 281extern int xt_register_match(struct xt_match *target);
226extern void xt_unregister_match(int af, struct xt_match *target); 282extern void xt_unregister_match(struct xt_match *target);
227 283
228extern int xt_check_match(const struct xt_match *match, unsigned short family, 284extern int xt_check_match(const struct xt_match *match, unsigned short family,
229 unsigned int size, const char *table, unsigned int hook, 285 unsigned int size, const char *table, unsigned int hook,
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index fd21796e5131..62cc27daca4e 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -65,35 +65,8 @@ struct arpt_arp {
65 u_int16_t invflags; 65 u_int16_t invflags;
66}; 66};
67 67
68struct arpt_entry_target 68#define arpt_entry_target xt_entry_target
69{ 69#define arpt_standard_target xt_standard_target
70 union {
71 struct {
72 u_int16_t target_size;
73
74 /* Used by userspace */
75 char name[ARPT_FUNCTION_MAXNAMELEN-1];
76 u_int8_t revision;
77 } user;
78 struct {
79 u_int16_t target_size;
80
81 /* Used inside the kernel */
82 struct arpt_target *target;
83 } kernel;
84
85 /* Total length */
86 u_int16_t target_size;
87 } u;
88
89 unsigned char data[0];
90};
91
92struct arpt_standard_target
93{
94 struct arpt_entry_target target;
95 int verdict;
96};
97 70
98/* Values for "flag" field in struct arpt_ip (general arp structure). 71/* Values for "flag" field in struct arpt_ip (general arp structure).
99 * No flags defined yet. 72 * No flags defined yet.
@@ -263,8 +236,10 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
263 */ 236 */
264#ifdef __KERNEL__ 237#ifdef __KERNEL__
265 238
266#define arpt_register_target(tgt) xt_register_target(NF_ARP, tgt) 239#define arpt_register_target(tgt) \
267#define arpt_unregister_target(tgt) xt_unregister_target(NF_ARP, tgt) 240({ (tgt)->family = NF_ARP; \
241 xt_register_target(tgt); })
242#define arpt_unregister_target(tgt) xt_unregister_target(tgt)
268 243
269extern int arpt_register_table(struct arpt_table *table, 244extern int arpt_register_table(struct arpt_table *table,
270 const struct arpt_replace *repl); 245 const struct arpt_replace *repl);
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 76ba24b68515..d5b8c0d6a12b 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -52,61 +52,9 @@ struct ipt_ip {
52 u_int8_t invflags; 52 u_int8_t invflags;
53}; 53};
54 54
55struct ipt_entry_match 55#define ipt_entry_match xt_entry_match
56{ 56#define ipt_entry_target xt_entry_target
57 union { 57#define ipt_standard_target xt_standard_target
58 struct {
59 u_int16_t match_size;
60
61 /* Used by userspace */
62 char name[IPT_FUNCTION_MAXNAMELEN-1];
63
64 u_int8_t revision;
65 } user;
66 struct {
67 u_int16_t match_size;
68
69 /* Used inside the kernel */
70 struct ipt_match *match;
71 } kernel;
72
73 /* Total length */
74 u_int16_t match_size;
75 } u;
76
77 unsigned char data[0];
78};
79
80struct ipt_entry_target
81{
82 union {
83 struct {
84 u_int16_t target_size;
85
86 /* Used by userspace */
87 char name[IPT_FUNCTION_MAXNAMELEN-1];
88
89 u_int8_t revision;
90 } user;
91 struct {
92 u_int16_t target_size;
93
94 /* Used inside the kernel */
95 struct ipt_target *target;
96 } kernel;
97
98 /* Total length */
99 u_int16_t target_size;
100 } u;
101
102 unsigned char data[0];
103};
104
105struct ipt_standard_target
106{
107 struct ipt_entry_target target;
108 int verdict;
109};
110 58
111#define ipt_counters xt_counters 59#define ipt_counters xt_counters
112 60
@@ -321,11 +269,15 @@ ipt_get_target(struct ipt_entry *e)
321#include <linux/init.h> 269#include <linux/init.h>
322extern void ipt_init(void) __init; 270extern void ipt_init(void) __init;
323 271
324#define ipt_register_target(tgt) xt_register_target(AF_INET, tgt) 272#define ipt_register_target(tgt) \
325#define ipt_unregister_target(tgt) xt_unregister_target(AF_INET, tgt) 273({ (tgt)->family = AF_INET; \
274 xt_register_target(tgt); })
275#define ipt_unregister_target(tgt) xt_unregister_target(tgt)
326 276
327#define ipt_register_match(mtch) xt_register_match(AF_INET, mtch) 277#define ipt_register_match(mtch) \
328#define ipt_unregister_match(mtch) xt_unregister_match(AF_INET, mtch) 278({ (mtch)->family = AF_INET; \
279 xt_register_match(mtch); })
280#define ipt_unregister_match(mtch) xt_unregister_match(mtch)
329 281
330//#define ipt_register_table(tbl, repl) xt_register_table(AF_INET, tbl, repl) 282//#define ipt_register_table(tbl, repl) xt_register_table(AF_INET, tbl, repl)
331//#define ipt_unregister_table(tbl) xt_unregister_table(AF_INET, tbl) 283//#define ipt_unregister_table(tbl) xt_unregister_table(AF_INET, tbl)
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index f249b574f0fa..d0d5d1ee4be3 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -56,60 +56,9 @@ struct ip6t_ip6 {
56 u_int8_t invflags; 56 u_int8_t invflags;
57}; 57};
58 58
59/* FIXME: If alignment in kernel different from userspace? --RR */ 59#define ip6t_entry_match xt_entry_match
60struct ip6t_entry_match 60#define ip6t_entry_target xt_entry_target
61{ 61#define ip6t_standard_target xt_standard_target
62 union {
63 struct {
64 u_int16_t match_size;
65
66 /* Used by userspace */
67 char name[IP6T_FUNCTION_MAXNAMELEN-1];
68 u_int8_t revision;
69 } user;
70 struct {
71 u_int16_t match_size;
72
73 /* Used inside the kernel */
74 struct ip6t_match *match;
75 } kernel;
76
77 /* Total length */
78 u_int16_t match_size;
79 } u;
80
81 unsigned char data[0];
82};
83
84struct ip6t_entry_target
85{
86 union {
87 struct {
88 u_int16_t target_size;
89
90 /* Used by userspace */
91 char name[IP6T_FUNCTION_MAXNAMELEN-1];
92 u_int8_t revision;
93 } user;
94 struct {
95 u_int16_t target_size;
96
97 /* Used inside the kernel */
98 struct ip6t_target *target;
99 } kernel;
100
101 /* Total length */
102 u_int16_t target_size;
103 } u;
104
105 unsigned char data[0];
106};
107
108struct ip6t_standard_target
109{
110 struct ip6t_entry_target target;
111 int verdict;
112};
113 62
114#define ip6t_counters xt_counters 63#define ip6t_counters xt_counters
115 64
@@ -334,11 +283,15 @@ ip6t_get_target(struct ip6t_entry *e)
334#include <linux/init.h> 283#include <linux/init.h>
335extern void ip6t_init(void) __init; 284extern void ip6t_init(void) __init;
336 285
337#define ip6t_register_target(tgt) xt_register_target(AF_INET6, tgt) 286#define ip6t_register_target(tgt) \
338#define ip6t_unregister_target(tgt) xt_unregister_target(AF_INET6, tgt) 287({ (tgt)->family = AF_INET6; \
288 xt_register_target(tgt); })
289#define ip6t_unregister_target(tgt) xt_unregister_target(tgt)
339 290
340#define ip6t_register_match(match) xt_register_match(AF_INET6, match) 291#define ip6t_register_match(match) \
341#define ip6t_unregister_match(match) xt_unregister_match(AF_INET6, match) 292({ (match)->family = AF_INET6; \
293 xt_register_match(match); })
294#define ip6t_unregister_match(match) xt_unregister_match(match)
342 295
343extern int ip6t_register_table(struct ip6t_table *table, 296extern int ip6t_register_table(struct ip6t_table *table,
344 const struct ip6t_replace *repl); 297 const struct ip6t_replace *repl);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 5be87ba3b7ac..6df2585c0169 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -188,6 +188,8 @@ extern void device_power_up(void);
188extern void device_resume(void); 188extern void device_resume(void);
189 189
190#ifdef CONFIG_PM 190#ifdef CONFIG_PM
191extern suspend_disk_method_t pm_disk_mode;
192
191extern int device_suspend(pm_message_t state); 193extern int device_suspend(pm_message_t state);
192 194
193#define device_set_wakeup_enable(dev,val) \ 195#define device_set_wakeup_enable(dev,val) \
@@ -215,7 +217,6 @@ static inline int dpm_runtime_suspend(struct device * dev, pm_message_t state)
215 217
216static inline void dpm_runtime_resume(struct device * dev) 218static inline void dpm_runtime_resume(struct device * dev)
217{ 219{
218
219} 220}
220 221
221#endif 222#endif
diff --git a/include/linux/profile.h b/include/linux/profile.h
index 026969a5595c..1f2fea6640a4 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -14,6 +14,7 @@
14 14
15struct proc_dir_entry; 15struct proc_dir_entry;
16struct pt_regs; 16struct pt_regs;
17struct notifier_block;
17 18
18/* init basic kernel profiler */ 19/* init basic kernel profiler */
19void __init profile_init(void); 20void __init profile_init(void);
@@ -32,7 +33,6 @@ enum profile_type {
32 33
33#ifdef CONFIG_PROFILING 34#ifdef CONFIG_PROFILING
34 35
35struct notifier_block;
36struct task_struct; 36struct task_struct;
37struct mm_struct; 37struct mm_struct;
38 38
diff --git a/include/linux/quota.h b/include/linux/quota.h
index f33aeb22c26a..8dc2d04a103f 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -38,6 +38,7 @@
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/types.h> 39#include <linux/types.h>
40#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/mutex.h>
41 42
42#define __DQUOT_VERSION__ "dquot_6.5.1" 43#define __DQUOT_VERSION__ "dquot_6.5.1"
43#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1 44#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1
@@ -215,7 +216,7 @@ struct dquot {
215 struct list_head dq_inuse; /* List of all quotas */ 216 struct list_head dq_inuse; /* List of all quotas */
216 struct list_head dq_free; /* Free list element */ 217 struct list_head dq_free; /* Free list element */
217 struct list_head dq_dirty; /* List of dirty dquots */ 218 struct list_head dq_dirty; /* List of dirty dquots */
218 struct semaphore dq_lock; /* dquot IO lock */ 219 struct mutex dq_lock; /* dquot IO lock */
219 atomic_t dq_count; /* Use count */ 220 atomic_t dq_count; /* Use count */
220 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */ 221 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */
221 struct super_block *dq_sb; /* superblock this applies to */ 222 struct super_block *dq_sb; /* superblock this applies to */
@@ -285,8 +286,8 @@ struct quota_format_type {
285 286
286struct quota_info { 287struct quota_info {
287 unsigned int flags; /* Flags for diskquotas on this device */ 288 unsigned int flags; /* Flags for diskquotas on this device */
288 struct semaphore dqio_sem; /* lock device while I/O in progress */ 289 struct mutex dqio_mutex; /* lock device while I/O in progress */
289 struct semaphore dqonoff_sem; /* Serialize quotaon & quotaoff */ 290 struct mutex dqonoff_mutex; /* Serialize quotaon & quotaoff */
290 struct rw_semaphore dqptr_sem; /* serialize ops using quota_info struct, pointers from inode to dquots */ 291 struct rw_semaphore dqptr_sem; /* serialize ops using quota_info struct, pointers from inode to dquots */
291 struct inode *files[MAXQUOTAS]; /* inodes of quotafiles */ 292 struct inode *files[MAXQUOTAS]; /* inodes of quotafiles */
292 struct mem_dqinfo info[MAXQUOTAS]; /* Information for each quota type */ 293 struct mem_dqinfo info[MAXQUOTAS]; /* Information for each quota type */
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h
index 9d5494aaac0f..3009c813d83d 100644
--- a/include/linux/raid/raid1.h
+++ b/include/linux/raid/raid1.h
@@ -130,6 +130,6 @@ struct r1bio_s {
130 * with failure when last write completes (and all failed). 130 * with failure when last write completes (and all failed).
131 * Record that bi_end_io was called with this flag... 131 * Record that bi_end_io was called with this flag...
132 */ 132 */
133#define R1BIO_Returned 4 133#define R1BIO_Returned 6
134 134
135#endif 135#endif
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index c2ec6c77874e..5673008b61e1 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -113,8 +113,6 @@ struct rcu_data {
113 113
114DECLARE_PER_CPU(struct rcu_data, rcu_data); 114DECLARE_PER_CPU(struct rcu_data, rcu_data);
115DECLARE_PER_CPU(struct rcu_data, rcu_bh_data); 115DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
116extern struct rcu_ctrlblk rcu_ctrlblk;
117extern struct rcu_ctrlblk rcu_bh_ctrlblk;
118 116
119/* 117/*
120 * Increment the quiescent state counter. 118 * Increment the quiescent state counter.
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 850a974ee505..b95f6eb7254c 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -4,7 +4,7 @@
4 4
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <asm/semaphore.h> 7#include <linux/mutex.h>
8 8
9struct seq_operations; 9struct seq_operations;
10struct file; 10struct file;
@@ -19,7 +19,7 @@ struct seq_file {
19 size_t count; 19 size_t count;
20 loff_t index; 20 loff_t index;
21 loff_t version; 21 loff_t version;
22 struct semaphore sem; 22 struct mutex lock;
23 struct seq_operations *op; 23 struct seq_operations *op;
24 void *private; 24 void *private;
25}; 25};
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 57abcea1cb5d..c32e60e79dea 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -369,6 +369,9 @@ void uart_parse_options(char *options, int *baud, int *parity, int *bits,
369int uart_set_options(struct uart_port *port, struct console *co, int baud, 369int uart_set_options(struct uart_port *port, struct console *co, int baud,
370 int parity, int bits, int flow); 370 int parity, int bits, int flow);
371struct tty_driver *uart_console_device(struct console *co, int *index); 371struct tty_driver *uart_console_device(struct console *co, int *index);
372void uart_console_write(struct uart_port *port, const char *s,
373 unsigned int count,
374 void (*putchar)(struct uart_port *, int));
372 375
373/* 376/*
374 * Port/driver registration/removal 377 * Port/driver registration/removal
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 12415dd94451..54eac8a39a4c 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -234,14 +234,15 @@ extern struct page * read_swap_cache_async(swp_entry_t, struct vm_area_struct *v
234/* linux/mm/swapfile.c */ 234/* linux/mm/swapfile.c */
235extern long total_swap_pages; 235extern long total_swap_pages;
236extern unsigned int nr_swapfiles; 236extern unsigned int nr_swapfiles;
237extern struct swap_info_struct swap_info[];
238extern void si_swapinfo(struct sysinfo *); 237extern void si_swapinfo(struct sysinfo *);
239extern swp_entry_t get_swap_page(void); 238extern swp_entry_t get_swap_page(void);
240extern swp_entry_t get_swap_page_of_type(int type); 239extern swp_entry_t get_swap_page_of_type(int);
241extern int swap_duplicate(swp_entry_t); 240extern int swap_duplicate(swp_entry_t);
242extern int valid_swaphandles(swp_entry_t, unsigned long *); 241extern int valid_swaphandles(swp_entry_t, unsigned long *);
243extern void swap_free(swp_entry_t); 242extern void swap_free(swp_entry_t);
244extern void free_swap_and_cache(swp_entry_t); 243extern void free_swap_and_cache(swp_entry_t);
244extern int swap_type_of(dev_t);
245extern unsigned int count_swap_pages(int, int);
245extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); 246extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
246extern struct swap_info_struct *get_swap_info_struct(unsigned); 247extern struct swap_info_struct *get_swap_info_struct(unsigned);
247extern int can_share_swap_page(struct page *); 248extern int can_share_swap_page(struct page *);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index f45cd74e6f24..f13f49afe198 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -24,6 +24,7 @@
24#include <linux/tty_driver.h> 24#include <linux/tty_driver.h>
25#include <linux/tty_ldisc.h> 25#include <linux/tty_ldisc.h>
26#include <linux/screen_info.h> 26#include <linux/screen_info.h>
27#include <linux/mutex.h>
27 28
28#include <asm/system.h> 29#include <asm/system.h>
29 30
@@ -231,8 +232,8 @@ struct tty_struct {
231 int canon_data; 232 int canon_data;
232 unsigned long canon_head; 233 unsigned long canon_head;
233 unsigned int canon_column; 234 unsigned int canon_column;
234 struct semaphore atomic_read; 235 struct mutex atomic_read_lock;
235 struct semaphore atomic_write; 236 struct mutex atomic_write_lock;
236 unsigned char *write_buf; 237 unsigned char *write_buf;
237 int write_cnt; 238 int write_cnt;
238 spinlock_t read_lock; 239 spinlock_t read_lock;
@@ -319,8 +320,7 @@ extern void tty_ldisc_put(int);
319extern void tty_wakeup(struct tty_struct *tty); 320extern void tty_wakeup(struct tty_struct *tty);
320extern void tty_ldisc_flush(struct tty_struct *tty); 321extern void tty_ldisc_flush(struct tty_struct *tty);
321 322
322struct semaphore; 323extern struct mutex tty_mutex;
323extern struct semaphore tty_sem;
324 324
325/* n_tty.c */ 325/* n_tty.c */
326extern struct tty_ldisc tty_ldisc_N_TTY; 326extern struct tty_ldisc tty_ldisc_N_TTY;
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 222faf97d5f9..0c6169fff366 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -7,14 +7,8 @@ extern int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *c
7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); 7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);
8extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); 8extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size);
9 9
10#ifdef INCLUDE_INLINE_FUNCS 10static inline int tty_insert_flip_char(struct tty_struct *tty,
11#define _INLINE_ extern 11 unsigned char ch, char flag)
12#else
13#define _INLINE_ static __inline__
14#endif
15
16_INLINE_ int tty_insert_flip_char(struct tty_struct *tty,
17 unsigned char ch, char flag)
18{ 12{
19 struct tty_buffer *tb = tty->buf.tail; 13 struct tty_buffer *tb = tty->buf.tail;
20 if (tb && tb->active && tb->used < tb->size) { 14 if (tb && tb->active && tb->used < tb->size) {
@@ -25,7 +19,7 @@ _INLINE_ int tty_insert_flip_char(struct tty_struct *tty,
25 return tty_insert_flip_string_flags(tty, &ch, &flag, 1); 19 return tty_insert_flip_string_flags(tty, &ch, &flag, 1);
26} 20}
27 21
28_INLINE_ void tty_schedule_flip(struct tty_struct *tty) 22static inline void tty_schedule_flip(struct tty_struct *tty)
29{ 23{
30 unsigned long flags; 24 unsigned long flags;
31 spin_lock_irqsave(&tty->buf.lock, flags); 25 spin_lock_irqsave(&tty->buf.lock, flags);
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index b15ff2e99c91..80ae9ef940dc 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -13,7 +13,7 @@
13#ifndef _UDF_FS_SB_H 13#ifndef _UDF_FS_SB_H
14#define _UDF_FS_SB_H 1 14#define _UDF_FS_SB_H 1
15 15
16#include <asm/semaphore.h> 16#include <linux/mutex.h>
17 17
18#pragma pack(1) 18#pragma pack(1)
19 19
@@ -111,7 +111,7 @@ struct udf_sb_info
111 /* VAT inode */ 111 /* VAT inode */
112 struct inode *s_vat; 112 struct inode *s_vat;
113 113
114 struct semaphore s_alloc_sem; 114 struct mutex s_alloc_mutex;
115}; 115};
116 116
117#endif /* _UDF_FS_SB_H */ 117#endif /* _UDF_FS_SB_H */
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index fab5aed8ca31..530ae3f4248c 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -73,6 +73,11 @@ int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
73int vt_waitactive(int vt); 73int vt_waitactive(int vt);
74void change_console(struct vc_data *new_vc); 74void change_console(struct vc_data *new_vc);
75void reset_vc(struct vc_data *vc); 75void reset_vc(struct vc_data *vc);
76#ifdef CONFIG_VT
77int is_console_suspend_safe(void);
78#else
79static inline int is_console_suspend_safe(void) { return 1; }
80#endif
76 81
77/* 82/*
78 * vc_screen.c shares this temporary buffer with the console write code so that 83 * vc_screen.c shares this temporary buffer with the console write code so that
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 2743c156caa0..b6f0905a4ee2 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -195,6 +195,10 @@ static inline void nf_ct_put(struct nf_conn *ct)
195 nf_conntrack_put(&ct->ct_general); 195 nf_conntrack_put(&ct->ct_general);
196} 196}
197 197
198/* Protocol module loading */
199extern int nf_ct_l3proto_try_module_get(unsigned short l3proto);
200extern void nf_ct_l3proto_module_put(unsigned short l3proto);
201
198extern struct nf_conntrack_tuple_hash * 202extern struct nf_conntrack_tuple_hash *
199__nf_conntrack_find(const struct nf_conntrack_tuple *tuple, 203__nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
200 const struct nf_conn *ignored_conntrack); 204 const struct nf_conn *ignored_conntrack);
diff --git a/include/net/tc_act/tc_ipt.h b/include/net/tc_act/tc_ipt.h
index 02eccebd55ae..cb37ad08427f 100644
--- a/include/net/tc_act/tc_ipt.h
+++ b/include/net/tc_act/tc_ipt.h
@@ -3,14 +3,14 @@
3 3
4#include <net/act_api.h> 4#include <net/act_api.h>
5 5
6struct ipt_entry_target; 6struct xt_entry_target;
7 7
8struct tcf_ipt 8struct tcf_ipt
9{ 9{
10 tca_gen(ipt); 10 tca_gen(ipt);
11 u32 hook; 11 u32 hook;
12 char *tname; 12 char *tname;
13 struct ipt_entry_target *t; 13 struct xt_entry_target *t;
14}; 14};
15 15
16#endif 16#endif
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index a05cabd0fd10..405f9031af87 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -56,6 +56,7 @@ static void __init handle_initrd(void)
56 sys_chroot("."); 56 sys_chroot(".");
57 mount_devfs_fs (); 57 mount_devfs_fs ();
58 58
59 current->flags |= PF_NOFREEZE;
59 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); 60 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
60 if (pid > 0) { 61 if (pid > 0) {
61 while (pid != sys_wait4(-1, NULL, 0, NULL)) 62 while (pid != sys_wait4(-1, NULL, 0, NULL))
diff --git a/init/main.c b/init/main.c
index 4c194c47395f..2714e0e7cfec 100644
--- a/init/main.c
+++ b/init/main.c
@@ -325,7 +325,7 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
325#else 325#else
326 326
327#ifdef __GENERIC_PER_CPU 327#ifdef __GENERIC_PER_CPU
328unsigned long __per_cpu_offset[NR_CPUS]; 328unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
329 329
330EXPORT_SYMBOL(__per_cpu_offset); 330EXPORT_SYMBOL(__per_cpu_offset);
331 331
@@ -333,6 +333,7 @@ static void __init setup_per_cpu_areas(void)
333{ 333{
334 unsigned long size, i; 334 unsigned long size, i;
335 char *ptr; 335 char *ptr;
336 unsigned long nr_possible_cpus = num_possible_cpus();
336 337
337 /* Copy section for each CPU (we discard the original) */ 338 /* Copy section for each CPU (we discard the original) */
338 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES); 339 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
@@ -340,12 +341,12 @@ static void __init setup_per_cpu_areas(void)
340 if (size < PERCPU_ENOUGH_ROOM) 341 if (size < PERCPU_ENOUGH_ROOM)
341 size = PERCPU_ENOUGH_ROOM; 342 size = PERCPU_ENOUGH_ROOM;
342#endif 343#endif
344 ptr = alloc_bootmem(size * nr_possible_cpus);
343 345
344 ptr = alloc_bootmem(size * NR_CPUS); 346 for_each_cpu(i) {
345
346 for (i = 0; i < NR_CPUS; i++, ptr += size) {
347 __per_cpu_offset[i] = ptr - __per_cpu_start; 347 __per_cpu_offset[i] = ptr - __per_cpu_start;
348 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 348 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
349 ptr += size;
349 } 350 }
350} 351}
351#endif /* !__GENERIC_PER_CPU */ 352#endif /* !__GENERIC_PER_CPU */
@@ -438,6 +439,15 @@ void __init parse_early_param(void)
438 * Activate the first processor. 439 * Activate the first processor.
439 */ 440 */
440 441
442static void __init boot_cpu_init(void)
443{
444 int cpu = smp_processor_id();
445 /* Mark the boot cpu "present", "online" etc for SMP and UP case */
446 cpu_set(cpu, cpu_online_map);
447 cpu_set(cpu, cpu_present_map);
448 cpu_set(cpu, cpu_possible_map);
449}
450
441asmlinkage void __init start_kernel(void) 451asmlinkage void __init start_kernel(void)
442{ 452{
443 char * command_line; 453 char * command_line;
@@ -447,17 +457,13 @@ asmlinkage void __init start_kernel(void)
447 * enable them 457 * enable them
448 */ 458 */
449 lock_kernel(); 459 lock_kernel();
460 boot_cpu_init();
450 page_address_init(); 461 page_address_init();
451 printk(KERN_NOTICE); 462 printk(KERN_NOTICE);
452 printk(linux_banner); 463 printk(linux_banner);
453 setup_arch(&command_line); 464 setup_arch(&command_line);
454 setup_per_cpu_areas(); 465 setup_per_cpu_areas();
455 466 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
456 /*
457 * Mark the boot cpu "online" so that it can call console drivers in
458 * printk() and can access its per-cpu storage.
459 */
460 smp_prepare_boot_cpu();
461 467
462 /* 468 /*
463 * Set up the scheduler prior starting any interrupts (such as the 469 * Set up the scheduler prior starting any interrupts (such as the
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index d7e7e637b92a..c4394abcd5e6 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -958,7 +958,7 @@ void audit_syscall_entry(struct task_struct *tsk, int arch, int major,
958 * 958 *
959 * i386 no 959 * i386 no
960 * x86_64 no 960 * x86_64 no
961 * ppc64 yes (see arch/ppc64/kernel/misc.S) 961 * ppc64 yes (see arch/powerpc/platforms/iseries/misc.S)
962 * 962 *
963 * This also happens with vm86 emulation in a non-nested manner 963 * This also happens with vm86 emulation in a non-nested manner
964 * (entries without exits), so this case must be caught. 964 * (entries without exits), so this case must be caught.
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 12815d3f1a05..c86ee051b734 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -53,7 +53,7 @@
53 53
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/atomic.h> 55#include <asm/atomic.h>
56#include <asm/semaphore.h> 56#include <linux/mutex.h>
57 57
58#define CPUSET_SUPER_MAGIC 0x27e0eb 58#define CPUSET_SUPER_MAGIC 0x27e0eb
59 59
@@ -168,63 +168,57 @@ static struct vfsmount *cpuset_mount;
168static struct super_block *cpuset_sb; 168static struct super_block *cpuset_sb;
169 169
170/* 170/*
171 * We have two global cpuset semaphores below. They can nest. 171 * We have two global cpuset mutexes below. They can nest.
172 * It is ok to first take manage_sem, then nest callback_sem. We also 172 * It is ok to first take manage_mutex, then nest callback_mutex. We also
173 * require taking task_lock() when dereferencing a tasks cpuset pointer. 173 * require taking task_lock() when dereferencing a tasks cpuset pointer.
174 * See "The task_lock() exception", at the end of this comment. 174 * See "The task_lock() exception", at the end of this comment.
175 * 175 *
176 * A task must hold both semaphores to modify cpusets. If a task 176 * A task must hold both mutexes to modify cpusets. If a task
177 * holds manage_sem, then it blocks others wanting that semaphore, 177 * holds manage_mutex, then it blocks others wanting that mutex,
178 * ensuring that it is the only task able to also acquire callback_sem 178 * ensuring that it is the only task able to also acquire callback_mutex
179 * and be able to modify cpusets. It can perform various checks on 179 * and be able to modify cpusets. It can perform various checks on
180 * the cpuset structure first, knowing nothing will change. It can 180 * the cpuset structure first, knowing nothing will change. It can
181 * also allocate memory while just holding manage_sem. While it is 181 * also allocate memory while just holding manage_mutex. While it is
182 * performing these checks, various callback routines can briefly 182 * performing these checks, various callback routines can briefly
183 * acquire callback_sem to query cpusets. Once it is ready to make 183 * acquire callback_mutex to query cpusets. Once it is ready to make
184 * the changes, it takes callback_sem, blocking everyone else. 184 * the changes, it takes callback_mutex, blocking everyone else.
185 * 185 *
186 * Calls to the kernel memory allocator can not be made while holding 186 * Calls to the kernel memory allocator can not be made while holding
187 * callback_sem, as that would risk double tripping on callback_sem 187 * callback_mutex, as that would risk double tripping on callback_mutex
188 * from one of the callbacks into the cpuset code from within 188 * from one of the callbacks into the cpuset code from within
189 * __alloc_pages(). 189 * __alloc_pages().
190 * 190 *
191 * If a task is only holding callback_sem, then it has read-only 191 * If a task is only holding callback_mutex, then it has read-only
192 * access to cpusets. 192 * access to cpusets.
193 * 193 *
194 * The task_struct fields mems_allowed and mems_generation may only 194 * The task_struct fields mems_allowed and mems_generation may only
195 * be accessed in the context of that task, so require no locks. 195 * be accessed in the context of that task, so require no locks.
196 * 196 *
197 * Any task can increment and decrement the count field without lock. 197 * Any task can increment and decrement the count field without lock.
198 * So in general, code holding manage_sem or callback_sem can't rely 198 * So in general, code holding manage_mutex or callback_mutex can't rely
199 * on the count field not changing. However, if the count goes to 199 * on the count field not changing. However, if the count goes to
200 * zero, then only attach_task(), which holds both semaphores, can 200 * zero, then only attach_task(), which holds both mutexes, can
201 * increment it again. Because a count of zero means that no tasks 201 * increment it again. Because a count of zero means that no tasks
202 * are currently attached, therefore there is no way a task attached 202 * are currently attached, therefore there is no way a task attached
203 * to that cpuset can fork (the other way to increment the count). 203 * to that cpuset can fork (the other way to increment the count).
204 * So code holding manage_sem or callback_sem can safely assume that 204 * So code holding manage_mutex or callback_mutex can safely assume that
205 * if the count is zero, it will stay zero. Similarly, if a task 205 * if the count is zero, it will stay zero. Similarly, if a task
206 * holds manage_sem or callback_sem on a cpuset with zero count, it 206 * holds manage_mutex or callback_mutex on a cpuset with zero count, it
207 * knows that the cpuset won't be removed, as cpuset_rmdir() needs 207 * knows that the cpuset won't be removed, as cpuset_rmdir() needs
208 * both of those semaphores. 208 * both of those mutexes.
209 *
210 * A possible optimization to improve parallelism would be to make
211 * callback_sem a R/W semaphore (rwsem), allowing the callback routines
212 * to proceed in parallel, with read access, until the holder of
213 * manage_sem needed to take this rwsem for exclusive write access
214 * and modify some cpusets.
215 * 209 *
216 * The cpuset_common_file_write handler for operations that modify 210 * The cpuset_common_file_write handler for operations that modify
217 * the cpuset hierarchy holds manage_sem across the entire operation, 211 * the cpuset hierarchy holds manage_mutex across the entire operation,
218 * single threading all such cpuset modifications across the system. 212 * single threading all such cpuset modifications across the system.
219 * 213 *
220 * The cpuset_common_file_read() handlers only hold callback_sem across 214 * The cpuset_common_file_read() handlers only hold callback_mutex across
221 * small pieces of code, such as when reading out possibly multi-word 215 * small pieces of code, such as when reading out possibly multi-word
222 * cpumasks and nodemasks. 216 * cpumasks and nodemasks.
223 * 217 *
224 * The fork and exit callbacks cpuset_fork() and cpuset_exit(), don't 218 * The fork and exit callbacks cpuset_fork() and cpuset_exit(), don't
225 * (usually) take either semaphore. These are the two most performance 219 * (usually) take either mutex. These are the two most performance
226 * critical pieces of code here. The exception occurs on cpuset_exit(), 220 * critical pieces of code here. The exception occurs on cpuset_exit(),
227 * when a task in a notify_on_release cpuset exits. Then manage_sem 221 * when a task in a notify_on_release cpuset exits. Then manage_mutex
228 * is taken, and if the cpuset count is zero, a usermode call made 222 * is taken, and if the cpuset count is zero, a usermode call made
229 * to /sbin/cpuset_release_agent with the name of the cpuset (path 223 * to /sbin/cpuset_release_agent with the name of the cpuset (path
230 * relative to the root of cpuset file system) as the argument. 224 * relative to the root of cpuset file system) as the argument.
@@ -242,9 +236,9 @@ static struct super_block *cpuset_sb;
242 * 236 *
243 * The need for this exception arises from the action of attach_task(), 237 * The need for this exception arises from the action of attach_task(),
244 * which overwrites one tasks cpuset pointer with another. It does 238 * which overwrites one tasks cpuset pointer with another. It does
245 * so using both semaphores, however there are several performance 239 * so using both mutexes, however there are several performance
246 * critical places that need to reference task->cpuset without the 240 * critical places that need to reference task->cpuset without the
247 * expense of grabbing a system global semaphore. Therefore except as 241 * expense of grabbing a system global mutex. Therefore except as
248 * noted below, when dereferencing or, as in attach_task(), modifying 242 * noted below, when dereferencing or, as in attach_task(), modifying
249 * a tasks cpuset pointer we use task_lock(), which acts on a spinlock 243 * a tasks cpuset pointer we use task_lock(), which acts on a spinlock
250 * (task->alloc_lock) already in the task_struct routinely used for 244 * (task->alloc_lock) already in the task_struct routinely used for
@@ -256,8 +250,8 @@ static struct super_block *cpuset_sb;
256 * the routine cpuset_update_task_memory_state(). 250 * the routine cpuset_update_task_memory_state().
257 */ 251 */
258 252
259static DECLARE_MUTEX(manage_sem); 253static DEFINE_MUTEX(manage_mutex);
260static DECLARE_MUTEX(callback_sem); 254static DEFINE_MUTEX(callback_mutex);
261 255
262/* 256/*
263 * A couple of forward declarations required, due to cyclic reference loop: 257 * A couple of forward declarations required, due to cyclic reference loop:
@@ -432,7 +426,7 @@ static inline struct cftype *__d_cft(struct dentry *dentry)
432} 426}
433 427
434/* 428/*
435 * Call with manage_sem held. Writes path of cpuset into buf. 429 * Call with manage_mutex held. Writes path of cpuset into buf.
436 * Returns 0 on success, -errno on error. 430 * Returns 0 on success, -errno on error.
437 */ 431 */
438 432
@@ -484,11 +478,11 @@ static int cpuset_path(const struct cpuset *cs, char *buf, int buflen)
484 * status of the /sbin/cpuset_release_agent task, so no sense holding 478 * status of the /sbin/cpuset_release_agent task, so no sense holding
485 * our caller up for that. 479 * our caller up for that.
486 * 480 *
487 * When we had only one cpuset semaphore, we had to call this 481 * When we had only one cpuset mutex, we had to call this
488 * without holding it, to avoid deadlock when call_usermodehelper() 482 * without holding it, to avoid deadlock when call_usermodehelper()
489 * allocated memory. With two locks, we could now call this while 483 * allocated memory. With two locks, we could now call this while
490 * holding manage_sem, but we still don't, so as to minimize 484 * holding manage_mutex, but we still don't, so as to minimize
491 * the time manage_sem is held. 485 * the time manage_mutex is held.
492 */ 486 */
493 487
494static void cpuset_release_agent(const char *pathbuf) 488static void cpuset_release_agent(const char *pathbuf)
@@ -520,15 +514,15 @@ static void cpuset_release_agent(const char *pathbuf)
520 * cs is notify_on_release() and now both the user count is zero and 514 * cs is notify_on_release() and now both the user count is zero and
521 * the list of children is empty, prepare cpuset path in a kmalloc'd 515 * the list of children is empty, prepare cpuset path in a kmalloc'd
522 * buffer, to be returned via ppathbuf, so that the caller can invoke 516 * buffer, to be returned via ppathbuf, so that the caller can invoke
523 * cpuset_release_agent() with it later on, once manage_sem is dropped. 517 * cpuset_release_agent() with it later on, once manage_mutex is dropped.
524 * Call here with manage_sem held. 518 * Call here with manage_mutex held.
525 * 519 *
526 * This check_for_release() routine is responsible for kmalloc'ing 520 * This check_for_release() routine is responsible for kmalloc'ing
527 * pathbuf. The above cpuset_release_agent() is responsible for 521 * pathbuf. The above cpuset_release_agent() is responsible for
528 * kfree'ing pathbuf. The caller of these routines is responsible 522 * kfree'ing pathbuf. The caller of these routines is responsible
529 * for providing a pathbuf pointer, initialized to NULL, then 523 * for providing a pathbuf pointer, initialized to NULL, then
530 * calling check_for_release() with manage_sem held and the address 524 * calling check_for_release() with manage_mutex held and the address
531 * of the pathbuf pointer, then dropping manage_sem, then calling 525 * of the pathbuf pointer, then dropping manage_mutex, then calling
532 * cpuset_release_agent() with pathbuf, as set by check_for_release(). 526 * cpuset_release_agent() with pathbuf, as set by check_for_release().
533 */ 527 */
534 528
@@ -559,7 +553,7 @@ static void check_for_release(struct cpuset *cs, char **ppathbuf)
559 * One way or another, we guarantee to return some non-empty subset 553 * One way or another, we guarantee to return some non-empty subset
560 * of cpu_online_map. 554 * of cpu_online_map.
561 * 555 *
562 * Call with callback_sem held. 556 * Call with callback_mutex held.
563 */ 557 */
564 558
565static void guarantee_online_cpus(const struct cpuset *cs, cpumask_t *pmask) 559static void guarantee_online_cpus(const struct cpuset *cs, cpumask_t *pmask)
@@ -583,7 +577,7 @@ static void guarantee_online_cpus(const struct cpuset *cs, cpumask_t *pmask)
583 * One way or another, we guarantee to return some non-empty subset 577 * One way or another, we guarantee to return some non-empty subset
584 * of node_online_map. 578 * of node_online_map.
585 * 579 *
586 * Call with callback_sem held. 580 * Call with callback_mutex held.
587 */ 581 */
588 582
589static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask) 583static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
@@ -608,12 +602,12 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
608 * current->cpuset if a task has its memory placement changed. 602 * current->cpuset if a task has its memory placement changed.
609 * Do not call this routine if in_interrupt(). 603 * Do not call this routine if in_interrupt().
610 * 604 *
611 * Call without callback_sem or task_lock() held. May be called 605 * Call without callback_mutex or task_lock() held. May be called
612 * with or without manage_sem held. Doesn't need task_lock to guard 606 * with or without manage_mutex held. Doesn't need task_lock to guard
613 * against another task changing a non-NULL cpuset pointer to NULL, 607 * against another task changing a non-NULL cpuset pointer to NULL,
614 * as that is only done by a task on itself, and if the current task 608 * as that is only done by a task on itself, and if the current task
615 * is here, it is not simultaneously in the exit code NULL'ing its 609 * is here, it is not simultaneously in the exit code NULL'ing its
616 * cpuset pointer. This routine also might acquire callback_sem and 610 * cpuset pointer. This routine also might acquire callback_mutex and
617 * current->mm->mmap_sem during call. 611 * current->mm->mmap_sem during call.
618 * 612 *
619 * Reading current->cpuset->mems_generation doesn't need task_lock 613 * Reading current->cpuset->mems_generation doesn't need task_lock
@@ -658,13 +652,13 @@ void cpuset_update_task_memory_state(void)
658 } 652 }
659 653
660 if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) { 654 if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) {
661 down(&callback_sem); 655 mutex_lock(&callback_mutex);
662 task_lock(tsk); 656 task_lock(tsk);
663 cs = tsk->cpuset; /* Maybe changed when task not locked */ 657 cs = tsk->cpuset; /* Maybe changed when task not locked */
664 guarantee_online_mems(cs, &tsk->mems_allowed); 658 guarantee_online_mems(cs, &tsk->mems_allowed);
665 tsk->cpuset_mems_generation = cs->mems_generation; 659 tsk->cpuset_mems_generation = cs->mems_generation;
666 task_unlock(tsk); 660 task_unlock(tsk);
667 up(&callback_sem); 661 mutex_unlock(&callback_mutex);
668 mpol_rebind_task(tsk, &tsk->mems_allowed); 662 mpol_rebind_task(tsk, &tsk->mems_allowed);
669 } 663 }
670} 664}
@@ -674,7 +668,7 @@ void cpuset_update_task_memory_state(void)
674 * 668 *
675 * One cpuset is a subset of another if all its allowed CPUs and 669 * One cpuset is a subset of another if all its allowed CPUs and
676 * Memory Nodes are a subset of the other, and its exclusive flags 670 * Memory Nodes are a subset of the other, and its exclusive flags
677 * are only set if the other's are set. Call holding manage_sem. 671 * are only set if the other's are set. Call holding manage_mutex.
678 */ 672 */
679 673
680static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q) 674static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
@@ -692,7 +686,7 @@ static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
692 * If we replaced the flag and mask values of the current cpuset 686 * If we replaced the flag and mask values of the current cpuset
693 * (cur) with those values in the trial cpuset (trial), would 687 * (cur) with those values in the trial cpuset (trial), would
694 * our various subset and exclusive rules still be valid? Presumes 688 * our various subset and exclusive rules still be valid? Presumes
695 * manage_sem held. 689 * manage_mutex held.
696 * 690 *
697 * 'cur' is the address of an actual, in-use cpuset. Operations 691 * 'cur' is the address of an actual, in-use cpuset. Operations
698 * such as list traversal that depend on the actual address of the 692 * such as list traversal that depend on the actual address of the
@@ -746,7 +740,7 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
746 * exclusive child cpusets 740 * exclusive child cpusets
747 * Build these two partitions by calling partition_sched_domains 741 * Build these two partitions by calling partition_sched_domains
748 * 742 *
749 * Call with manage_sem held. May nest a call to the 743 * Call with manage_mutex held. May nest a call to the
750 * lock_cpu_hotplug()/unlock_cpu_hotplug() pair. 744 * lock_cpu_hotplug()/unlock_cpu_hotplug() pair.
751 */ 745 */
752 746
@@ -792,7 +786,7 @@ static void update_cpu_domains(struct cpuset *cur)
792} 786}
793 787
794/* 788/*
795 * Call with manage_sem held. May take callback_sem during call. 789 * Call with manage_mutex held. May take callback_mutex during call.
796 */ 790 */
797 791
798static int update_cpumask(struct cpuset *cs, char *buf) 792static int update_cpumask(struct cpuset *cs, char *buf)
@@ -811,9 +805,9 @@ static int update_cpumask(struct cpuset *cs, char *buf)
811 if (retval < 0) 805 if (retval < 0)
812 return retval; 806 return retval;
813 cpus_unchanged = cpus_equal(cs->cpus_allowed, trialcs.cpus_allowed); 807 cpus_unchanged = cpus_equal(cs->cpus_allowed, trialcs.cpus_allowed);
814 down(&callback_sem); 808 mutex_lock(&callback_mutex);
815 cs->cpus_allowed = trialcs.cpus_allowed; 809 cs->cpus_allowed = trialcs.cpus_allowed;
816 up(&callback_sem); 810 mutex_unlock(&callback_mutex);
817 if (is_cpu_exclusive(cs) && !cpus_unchanged) 811 if (is_cpu_exclusive(cs) && !cpus_unchanged)
818 update_cpu_domains(cs); 812 update_cpu_domains(cs);
819 return 0; 813 return 0;
@@ -827,7 +821,7 @@ static int update_cpumask(struct cpuset *cs, char *buf)
827 * the cpuset is marked 'memory_migrate', migrate the tasks 821 * the cpuset is marked 'memory_migrate', migrate the tasks
828 * pages to the new memory. 822 * pages to the new memory.
829 * 823 *
830 * Call with manage_sem held. May take callback_sem during call. 824 * Call with manage_mutex held. May take callback_mutex during call.
831 * Will take tasklist_lock, scan tasklist for tasks in cpuset cs, 825 * Will take tasklist_lock, scan tasklist for tasks in cpuset cs,
832 * lock each such tasks mm->mmap_sem, scan its vma's and rebind 826 * lock each such tasks mm->mmap_sem, scan its vma's and rebind
833 * their mempolicies to the cpusets new mems_allowed. 827 * their mempolicies to the cpusets new mems_allowed.
@@ -862,11 +856,11 @@ static int update_nodemask(struct cpuset *cs, char *buf)
862 if (retval < 0) 856 if (retval < 0)
863 goto done; 857 goto done;
864 858
865 down(&callback_sem); 859 mutex_lock(&callback_mutex);
866 cs->mems_allowed = trialcs.mems_allowed; 860 cs->mems_allowed = trialcs.mems_allowed;
867 atomic_inc(&cpuset_mems_generation); 861 atomic_inc(&cpuset_mems_generation);
868 cs->mems_generation = atomic_read(&cpuset_mems_generation); 862 cs->mems_generation = atomic_read(&cpuset_mems_generation);
869 up(&callback_sem); 863 mutex_unlock(&callback_mutex);
870 864
871 set_cpuset_being_rebound(cs); /* causes mpol_copy() rebind */ 865 set_cpuset_being_rebound(cs); /* causes mpol_copy() rebind */
872 866
@@ -922,7 +916,7 @@ static int update_nodemask(struct cpuset *cs, char *buf)
922 * tasklist_lock. Forks can happen again now - the mpol_copy() 916 * tasklist_lock. Forks can happen again now - the mpol_copy()
923 * cpuset_being_rebound check will catch such forks, and rebind 917 * cpuset_being_rebound check will catch such forks, and rebind
924 * their vma mempolicies too. Because we still hold the global 918 * their vma mempolicies too. Because we still hold the global
925 * cpuset manage_sem, we know that no other rebind effort will 919 * cpuset manage_mutex, we know that no other rebind effort will
926 * be contending for the global variable cpuset_being_rebound. 920 * be contending for the global variable cpuset_being_rebound.
927 * It's ok if we rebind the same mm twice; mpol_rebind_mm() 921 * It's ok if we rebind the same mm twice; mpol_rebind_mm()
928 * is idempotent. Also migrate pages in each mm to new nodes. 922 * is idempotent. Also migrate pages in each mm to new nodes.
@@ -948,7 +942,7 @@ done:
948} 942}
949 943
950/* 944/*
951 * Call with manage_sem held. 945 * Call with manage_mutex held.
952 */ 946 */
953 947
954static int update_memory_pressure_enabled(struct cpuset *cs, char *buf) 948static int update_memory_pressure_enabled(struct cpuset *cs, char *buf)
@@ -967,7 +961,7 @@ static int update_memory_pressure_enabled(struct cpuset *cs, char *buf)
967 * cs: the cpuset to update 961 * cs: the cpuset to update
968 * buf: the buffer where we read the 0 or 1 962 * buf: the buffer where we read the 0 or 1
969 * 963 *
970 * Call with manage_sem held. 964 * Call with manage_mutex held.
971 */ 965 */
972 966
973static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf) 967static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
@@ -989,12 +983,12 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
989 return err; 983 return err;
990 cpu_exclusive_changed = 984 cpu_exclusive_changed =
991 (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs)); 985 (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs));
992 down(&callback_sem); 986 mutex_lock(&callback_mutex);
993 if (turning_on) 987 if (turning_on)
994 set_bit(bit, &cs->flags); 988 set_bit(bit, &cs->flags);
995 else 989 else
996 clear_bit(bit, &cs->flags); 990 clear_bit(bit, &cs->flags);
997 up(&callback_sem); 991 mutex_unlock(&callback_mutex);
998 992
999 if (cpu_exclusive_changed) 993 if (cpu_exclusive_changed)
1000 update_cpu_domains(cs); 994 update_cpu_domains(cs);
@@ -1104,7 +1098,7 @@ static int fmeter_getrate(struct fmeter *fmp)
1104 * writing the path of the old cpuset in 'ppathbuf' if it needs to be 1098 * writing the path of the old cpuset in 'ppathbuf' if it needs to be
1105 * notified on release. 1099 * notified on release.
1106 * 1100 *
1107 * Call holding manage_sem. May take callback_sem and task_lock of 1101 * Call holding manage_mutex. May take callback_mutex and task_lock of
1108 * the task 'pid' during call. 1102 * the task 'pid' during call.
1109 */ 1103 */
1110 1104
@@ -1144,13 +1138,13 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf)
1144 get_task_struct(tsk); 1138 get_task_struct(tsk);
1145 } 1139 }
1146 1140
1147 down(&callback_sem); 1141 mutex_lock(&callback_mutex);
1148 1142
1149 task_lock(tsk); 1143 task_lock(tsk);
1150 oldcs = tsk->cpuset; 1144 oldcs = tsk->cpuset;
1151 if (!oldcs) { 1145 if (!oldcs) {
1152 task_unlock(tsk); 1146 task_unlock(tsk);
1153 up(&callback_sem); 1147 mutex_unlock(&callback_mutex);
1154 put_task_struct(tsk); 1148 put_task_struct(tsk);
1155 return -ESRCH; 1149 return -ESRCH;
1156 } 1150 }
@@ -1164,7 +1158,7 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf)
1164 from = oldcs->mems_allowed; 1158 from = oldcs->mems_allowed;
1165 to = cs->mems_allowed; 1159 to = cs->mems_allowed;
1166 1160
1167 up(&callback_sem); 1161 mutex_unlock(&callback_mutex);
1168 1162
1169 mm = get_task_mm(tsk); 1163 mm = get_task_mm(tsk);
1170 if (mm) { 1164 if (mm) {
@@ -1221,7 +1215,7 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
1221 } 1215 }
1222 buffer[nbytes] = 0; /* nul-terminate */ 1216 buffer[nbytes] = 0; /* nul-terminate */
1223 1217
1224 down(&manage_sem); 1218 mutex_lock(&manage_mutex);
1225 1219
1226 if (is_removed(cs)) { 1220 if (is_removed(cs)) {
1227 retval = -ENODEV; 1221 retval = -ENODEV;
@@ -1264,7 +1258,7 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
1264 if (retval == 0) 1258 if (retval == 0)
1265 retval = nbytes; 1259 retval = nbytes;
1266out2: 1260out2:
1267 up(&manage_sem); 1261 mutex_unlock(&manage_mutex);
1268 cpuset_release_agent(pathbuf); 1262 cpuset_release_agent(pathbuf);
1269out1: 1263out1:
1270 kfree(buffer); 1264 kfree(buffer);
@@ -1304,9 +1298,9 @@ static int cpuset_sprintf_cpulist(char *page, struct cpuset *cs)
1304{ 1298{
1305 cpumask_t mask; 1299 cpumask_t mask;
1306 1300
1307 down(&callback_sem); 1301 mutex_lock(&callback_mutex);
1308 mask = cs->cpus_allowed; 1302 mask = cs->cpus_allowed;
1309 up(&callback_sem); 1303 mutex_unlock(&callback_mutex);
1310 1304
1311 return cpulist_scnprintf(page, PAGE_SIZE, mask); 1305 return cpulist_scnprintf(page, PAGE_SIZE, mask);
1312} 1306}
@@ -1315,9 +1309,9 @@ static int cpuset_sprintf_memlist(char *page, struct cpuset *cs)
1315{ 1309{
1316 nodemask_t mask; 1310 nodemask_t mask;
1317 1311
1318 down(&callback_sem); 1312 mutex_lock(&callback_mutex);
1319 mask = cs->mems_allowed; 1313 mask = cs->mems_allowed;
1320 up(&callback_sem); 1314 mutex_unlock(&callback_mutex);
1321 1315
1322 return nodelist_scnprintf(page, PAGE_SIZE, mask); 1316 return nodelist_scnprintf(page, PAGE_SIZE, mask);
1323} 1317}
@@ -1598,7 +1592,7 @@ static int pid_array_to_buf(char *buf, int sz, pid_t *a, int npids)
1598 * Handle an open on 'tasks' file. Prepare a buffer listing the 1592 * Handle an open on 'tasks' file. Prepare a buffer listing the
1599 * process id's of tasks currently attached to the cpuset being opened. 1593 * process id's of tasks currently attached to the cpuset being opened.
1600 * 1594 *
1601 * Does not require any specific cpuset semaphores, and does not take any. 1595 * Does not require any specific cpuset mutexes, and does not take any.
1602 */ 1596 */
1603static int cpuset_tasks_open(struct inode *unused, struct file *file) 1597static int cpuset_tasks_open(struct inode *unused, struct file *file)
1604{ 1598{
@@ -1754,7 +1748,7 @@ static int cpuset_populate_dir(struct dentry *cs_dentry)
1754 * name: name of the new cpuset. Will be strcpy'ed. 1748 * name: name of the new cpuset. Will be strcpy'ed.
1755 * mode: mode to set on new inode 1749 * mode: mode to set on new inode
1756 * 1750 *
1757 * Must be called with the semaphore on the parent inode held 1751 * Must be called with the mutex on the parent inode held
1758 */ 1752 */
1759 1753
1760static long cpuset_create(struct cpuset *parent, const char *name, int mode) 1754static long cpuset_create(struct cpuset *parent, const char *name, int mode)
@@ -1766,7 +1760,7 @@ static long cpuset_create(struct cpuset *parent, const char *name, int mode)
1766 if (!cs) 1760 if (!cs)
1767 return -ENOMEM; 1761 return -ENOMEM;
1768 1762
1769 down(&manage_sem); 1763 mutex_lock(&manage_mutex);
1770 cpuset_update_task_memory_state(); 1764 cpuset_update_task_memory_state();
1771 cs->flags = 0; 1765 cs->flags = 0;
1772 if (notify_on_release(parent)) 1766 if (notify_on_release(parent))
@@ -1782,28 +1776,28 @@ static long cpuset_create(struct cpuset *parent, const char *name, int mode)
1782 1776
1783 cs->parent = parent; 1777 cs->parent = parent;
1784 1778
1785 down(&callback_sem); 1779 mutex_lock(&callback_mutex);
1786 list_add(&cs->sibling, &cs->parent->children); 1780 list_add(&cs->sibling, &cs->parent->children);
1787 number_of_cpusets++; 1781 number_of_cpusets++;
1788 up(&callback_sem); 1782 mutex_unlock(&callback_mutex);
1789 1783
1790 err = cpuset_create_dir(cs, name, mode); 1784 err = cpuset_create_dir(cs, name, mode);
1791 if (err < 0) 1785 if (err < 0)
1792 goto err; 1786 goto err;
1793 1787
1794 /* 1788 /*
1795 * Release manage_sem before cpuset_populate_dir() because it 1789 * Release manage_mutex before cpuset_populate_dir() because it
1796 * will down() this new directory's i_mutex and if we race with 1790 * will down() this new directory's i_mutex and if we race with
1797 * another mkdir, we might deadlock. 1791 * another mkdir, we might deadlock.
1798 */ 1792 */
1799 up(&manage_sem); 1793 mutex_unlock(&manage_mutex);
1800 1794
1801 err = cpuset_populate_dir(cs->dentry); 1795 err = cpuset_populate_dir(cs->dentry);
1802 /* If err < 0, we have a half-filled directory - oh well ;) */ 1796 /* If err < 0, we have a half-filled directory - oh well ;) */
1803 return 0; 1797 return 0;
1804err: 1798err:
1805 list_del(&cs->sibling); 1799 list_del(&cs->sibling);
1806 up(&manage_sem); 1800 mutex_unlock(&manage_mutex);
1807 kfree(cs); 1801 kfree(cs);
1808 return err; 1802 return err;
1809} 1803}
@@ -1825,18 +1819,18 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
1825 1819
1826 /* the vfs holds both inode->i_mutex already */ 1820 /* the vfs holds both inode->i_mutex already */
1827 1821
1828 down(&manage_sem); 1822 mutex_lock(&manage_mutex);
1829 cpuset_update_task_memory_state(); 1823 cpuset_update_task_memory_state();
1830 if (atomic_read(&cs->count) > 0) { 1824 if (atomic_read(&cs->count) > 0) {
1831 up(&manage_sem); 1825 mutex_unlock(&manage_mutex);
1832 return -EBUSY; 1826 return -EBUSY;
1833 } 1827 }
1834 if (!list_empty(&cs->children)) { 1828 if (!list_empty(&cs->children)) {
1835 up(&manage_sem); 1829 mutex_unlock(&manage_mutex);
1836 return -EBUSY; 1830 return -EBUSY;
1837 } 1831 }
1838 parent = cs->parent; 1832 parent = cs->parent;
1839 down(&callback_sem); 1833 mutex_lock(&callback_mutex);
1840 set_bit(CS_REMOVED, &cs->flags); 1834 set_bit(CS_REMOVED, &cs->flags);
1841 if (is_cpu_exclusive(cs)) 1835 if (is_cpu_exclusive(cs))
1842 update_cpu_domains(cs); 1836 update_cpu_domains(cs);
@@ -1848,10 +1842,10 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
1848 cpuset_d_remove_dir(d); 1842 cpuset_d_remove_dir(d);
1849 dput(d); 1843 dput(d);
1850 number_of_cpusets--; 1844 number_of_cpusets--;
1851 up(&callback_sem); 1845 mutex_unlock(&callback_mutex);
1852 if (list_empty(&parent->children)) 1846 if (list_empty(&parent->children))
1853 check_for_release(parent, &pathbuf); 1847 check_for_release(parent, &pathbuf);
1854 up(&manage_sem); 1848 mutex_unlock(&manage_mutex);
1855 cpuset_release_agent(pathbuf); 1849 cpuset_release_agent(pathbuf);
1856 return 0; 1850 return 0;
1857} 1851}
@@ -1960,19 +1954,19 @@ void cpuset_fork(struct task_struct *child)
1960 * Description: Detach cpuset from @tsk and release it. 1954 * Description: Detach cpuset from @tsk and release it.
1961 * 1955 *
1962 * Note that cpusets marked notify_on_release force every task in 1956 * Note that cpusets marked notify_on_release force every task in
1963 * them to take the global manage_sem semaphore when exiting. 1957 * them to take the global manage_mutex mutex when exiting.
1964 * This could impact scaling on very large systems. Be reluctant to 1958 * This could impact scaling on very large systems. Be reluctant to
1965 * use notify_on_release cpusets where very high task exit scaling 1959 * use notify_on_release cpusets where very high task exit scaling
1966 * is required on large systems. 1960 * is required on large systems.
1967 * 1961 *
1968 * Don't even think about derefencing 'cs' after the cpuset use count 1962 * Don't even think about derefencing 'cs' after the cpuset use count
1969 * goes to zero, except inside a critical section guarded by manage_sem 1963 * goes to zero, except inside a critical section guarded by manage_mutex
1970 * or callback_sem. Otherwise a zero cpuset use count is a license to 1964 * or callback_mutex. Otherwise a zero cpuset use count is a license to
1971 * any other task to nuke the cpuset immediately, via cpuset_rmdir(). 1965 * any other task to nuke the cpuset immediately, via cpuset_rmdir().
1972 * 1966 *
1973 * This routine has to take manage_sem, not callback_sem, because 1967 * This routine has to take manage_mutex, not callback_mutex, because
1974 * it is holding that semaphore while calling check_for_release(), 1968 * it is holding that mutex while calling check_for_release(),
1975 * which calls kmalloc(), so can't be called holding callback__sem(). 1969 * which calls kmalloc(), so can't be called holding callback_mutex().
1976 * 1970 *
1977 * We don't need to task_lock() this reference to tsk->cpuset, 1971 * We don't need to task_lock() this reference to tsk->cpuset,
1978 * because tsk is already marked PF_EXITING, so attach_task() won't 1972 * because tsk is already marked PF_EXITING, so attach_task() won't
@@ -2022,10 +2016,10 @@ void cpuset_exit(struct task_struct *tsk)
2022 if (notify_on_release(cs)) { 2016 if (notify_on_release(cs)) {
2023 char *pathbuf = NULL; 2017 char *pathbuf = NULL;
2024 2018
2025 down(&manage_sem); 2019 mutex_lock(&manage_mutex);
2026 if (atomic_dec_and_test(&cs->count)) 2020 if (atomic_dec_and_test(&cs->count))
2027 check_for_release(cs, &pathbuf); 2021 check_for_release(cs, &pathbuf);
2028 up(&manage_sem); 2022 mutex_unlock(&manage_mutex);
2029 cpuset_release_agent(pathbuf); 2023 cpuset_release_agent(pathbuf);
2030 } else { 2024 } else {
2031 atomic_dec(&cs->count); 2025 atomic_dec(&cs->count);
@@ -2046,11 +2040,11 @@ cpumask_t cpuset_cpus_allowed(struct task_struct *tsk)
2046{ 2040{
2047 cpumask_t mask; 2041 cpumask_t mask;
2048 2042
2049 down(&callback_sem); 2043 mutex_lock(&callback_mutex);
2050 task_lock(tsk); 2044 task_lock(tsk);
2051 guarantee_online_cpus(tsk->cpuset, &mask); 2045 guarantee_online_cpus(tsk->cpuset, &mask);
2052 task_unlock(tsk); 2046 task_unlock(tsk);
2053 up(&callback_sem); 2047 mutex_unlock(&callback_mutex);
2054 2048
2055 return mask; 2049 return mask;
2056} 2050}
@@ -2074,11 +2068,11 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)
2074{ 2068{
2075 nodemask_t mask; 2069 nodemask_t mask;
2076 2070
2077 down(&callback_sem); 2071 mutex_lock(&callback_mutex);
2078 task_lock(tsk); 2072 task_lock(tsk);
2079 guarantee_online_mems(tsk->cpuset, &mask); 2073 guarantee_online_mems(tsk->cpuset, &mask);
2080 task_unlock(tsk); 2074 task_unlock(tsk);
2081 up(&callback_sem); 2075 mutex_unlock(&callback_mutex);
2082 2076
2083 return mask; 2077 return mask;
2084} 2078}
@@ -2104,7 +2098,7 @@ int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
2104 2098
2105/* 2099/*
2106 * nearest_exclusive_ancestor() - Returns the nearest mem_exclusive 2100 * nearest_exclusive_ancestor() - Returns the nearest mem_exclusive
2107 * ancestor to the specified cpuset. Call holding callback_sem. 2101 * ancestor to the specified cpuset. Call holding callback_mutex.
2108 * If no ancestor is mem_exclusive (an unusual configuration), then 2102 * If no ancestor is mem_exclusive (an unusual configuration), then
2109 * returns the root cpuset. 2103 * returns the root cpuset.
2110 */ 2104 */
@@ -2131,12 +2125,12 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs)
2131 * GFP_KERNEL allocations are not so marked, so can escape to the 2125 * GFP_KERNEL allocations are not so marked, so can escape to the
2132 * nearest mem_exclusive ancestor cpuset. 2126 * nearest mem_exclusive ancestor cpuset.
2133 * 2127 *
2134 * Scanning up parent cpusets requires callback_sem. The __alloc_pages() 2128 * Scanning up parent cpusets requires callback_mutex. The __alloc_pages()
2135 * routine only calls here with __GFP_HARDWALL bit _not_ set if 2129 * routine only calls here with __GFP_HARDWALL bit _not_ set if
2136 * it's a GFP_KERNEL allocation, and all nodes in the current tasks 2130 * it's a GFP_KERNEL allocation, and all nodes in the current tasks
2137 * mems_allowed came up empty on the first pass over the zonelist. 2131 * mems_allowed came up empty on the first pass over the zonelist.
2138 * So only GFP_KERNEL allocations, if all nodes in the cpuset are 2132 * So only GFP_KERNEL allocations, if all nodes in the cpuset are
2139 * short of memory, might require taking the callback_sem semaphore. 2133 * short of memory, might require taking the callback_mutex mutex.
2140 * 2134 *
2141 * The first loop over the zonelist in mm/page_alloc.c:__alloc_pages() 2135 * The first loop over the zonelist in mm/page_alloc.c:__alloc_pages()
2142 * calls here with __GFP_HARDWALL always set in gfp_mask, enforcing 2136 * calls here with __GFP_HARDWALL always set in gfp_mask, enforcing
@@ -2171,31 +2165,31 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
2171 return 1; 2165 return 1;
2172 2166
2173 /* Not hardwall and node outside mems_allowed: scan up cpusets */ 2167 /* Not hardwall and node outside mems_allowed: scan up cpusets */
2174 down(&callback_sem); 2168 mutex_lock(&callback_mutex);
2175 2169
2176 task_lock(current); 2170 task_lock(current);
2177 cs = nearest_exclusive_ancestor(current->cpuset); 2171 cs = nearest_exclusive_ancestor(current->cpuset);
2178 task_unlock(current); 2172 task_unlock(current);
2179 2173
2180 allowed = node_isset(node, cs->mems_allowed); 2174 allowed = node_isset(node, cs->mems_allowed);
2181 up(&callback_sem); 2175 mutex_unlock(&callback_mutex);
2182 return allowed; 2176 return allowed;
2183} 2177}
2184 2178
2185/** 2179/**
2186 * cpuset_lock - lock out any changes to cpuset structures 2180 * cpuset_lock - lock out any changes to cpuset structures
2187 * 2181 *
2188 * The out of memory (oom) code needs to lock down cpusets 2182 * The out of memory (oom) code needs to mutex_lock cpusets
2189 * from being changed while it scans the tasklist looking for a 2183 * from being changed while it scans the tasklist looking for a
2190 * task in an overlapping cpuset. Expose callback_sem via this 2184 * task in an overlapping cpuset. Expose callback_mutex via this
2191 * cpuset_lock() routine, so the oom code can lock it, before 2185 * cpuset_lock() routine, so the oom code can lock it, before
2192 * locking the task list. The tasklist_lock is a spinlock, so 2186 * locking the task list. The tasklist_lock is a spinlock, so
2193 * must be taken inside callback_sem. 2187 * must be taken inside callback_mutex.
2194 */ 2188 */
2195 2189
2196void cpuset_lock(void) 2190void cpuset_lock(void)
2197{ 2191{
2198 down(&callback_sem); 2192 mutex_lock(&callback_mutex);
2199} 2193}
2200 2194
2201/** 2195/**
@@ -2206,7 +2200,7 @@ void cpuset_lock(void)
2206 2200
2207void cpuset_unlock(void) 2201void cpuset_unlock(void)
2208{ 2202{
2209 up(&callback_sem); 2203 mutex_unlock(&callback_mutex);
2210} 2204}
2211 2205
2212/** 2206/**
@@ -2218,7 +2212,7 @@ void cpuset_unlock(void)
2218 * determine if task @p's memory usage might impact the memory 2212 * determine if task @p's memory usage might impact the memory
2219 * available to the current task. 2213 * available to the current task.
2220 * 2214 *
2221 * Call while holding callback_sem. 2215 * Call while holding callback_mutex.
2222 **/ 2216 **/
2223 2217
2224int cpuset_excl_nodes_overlap(const struct task_struct *p) 2218int cpuset_excl_nodes_overlap(const struct task_struct *p)
@@ -2289,7 +2283,7 @@ void __cpuset_memory_pressure_bump(void)
2289 * - Used for /proc/<pid>/cpuset. 2283 * - Used for /proc/<pid>/cpuset.
2290 * - No need to task_lock(tsk) on this tsk->cpuset reference, as it 2284 * - No need to task_lock(tsk) on this tsk->cpuset reference, as it
2291 * doesn't really matter if tsk->cpuset changes after we read it, 2285 * doesn't really matter if tsk->cpuset changes after we read it,
2292 * and we take manage_sem, keeping attach_task() from changing it 2286 * and we take manage_mutex, keeping attach_task() from changing it
2293 * anyway. 2287 * anyway.
2294 */ 2288 */
2295 2289
@@ -2305,7 +2299,7 @@ static int proc_cpuset_show(struct seq_file *m, void *v)
2305 return -ENOMEM; 2299 return -ENOMEM;
2306 2300
2307 tsk = m->private; 2301 tsk = m->private;
2308 down(&manage_sem); 2302 mutex_lock(&manage_mutex);
2309 cs = tsk->cpuset; 2303 cs = tsk->cpuset;
2310 if (!cs) { 2304 if (!cs) {
2311 retval = -EINVAL; 2305 retval = -EINVAL;
@@ -2318,7 +2312,7 @@ static int proc_cpuset_show(struct seq_file *m, void *v)
2318 seq_puts(m, buf); 2312 seq_puts(m, buf);
2319 seq_putc(m, '\n'); 2313 seq_putc(m, '\n');
2320out: 2314out:
2321 up(&manage_sem); 2315 mutex_unlock(&manage_mutex);
2322 kfree(buf); 2316 kfree(buf);
2323 return retval; 2317 return retval;
2324} 2318}
diff --git a/kernel/exit.c b/kernel/exit.c
index d1e8d500a7e1..8037405e136e 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -345,9 +345,9 @@ void daemonize(const char *name, ...)
345 exit_mm(current); 345 exit_mm(current);
346 346
347 set_special_pids(1, 1); 347 set_special_pids(1, 1);
348 down(&tty_sem); 348 mutex_lock(&tty_mutex);
349 current->signal->tty = NULL; 349 current->signal->tty = NULL;
350 up(&tty_sem); 350 mutex_unlock(&tty_mutex);
351 351
352 /* Block and flush all signals */ 352 /* Block and flush all signals */
353 sigfillset(&blocked); 353 sigfillset(&blocked);
diff --git a/kernel/fork.c b/kernel/fork.c
index 9bd7b65ee418..c79ae0b19a49 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -607,12 +607,12 @@ static struct files_struct *alloc_files(void)
607 atomic_set(&newf->count, 1); 607 atomic_set(&newf->count, 1);
608 608
609 spin_lock_init(&newf->file_lock); 609 spin_lock_init(&newf->file_lock);
610 newf->next_fd = 0;
610 fdt = &newf->fdtab; 611 fdt = &newf->fdtab;
611 fdt->next_fd = 0;
612 fdt->max_fds = NR_OPEN_DEFAULT; 612 fdt->max_fds = NR_OPEN_DEFAULT;
613 fdt->max_fdset = __FD_SETSIZE; 613 fdt->max_fdset = EMBEDDED_FD_SET_SIZE;
614 fdt->close_on_exec = &newf->close_on_exec_init; 614 fdt->close_on_exec = (fd_set *)&newf->close_on_exec_init;
615 fdt->open_fds = &newf->open_fds_init; 615 fdt->open_fds = (fd_set *)&newf->open_fds_init;
616 fdt->fd = &newf->fd_array[0]; 616 fdt->fd = &newf->fd_array[0];
617 INIT_RCU_HEAD(&fdt->rcu); 617 INIT_RCU_HEAD(&fdt->rcu);
618 fdt->free_files = NULL; 618 fdt->free_files = NULL;
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index fef1af8a73ce..1fb9f753ef60 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -48,7 +48,7 @@
48static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; 48static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
49static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; 49static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
50 50
51DECLARE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ 51DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
52DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */ 52DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */
53static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; 53static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL;
54 54
@@ -460,7 +460,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
460 } 460 }
461 461
462 p->nmissed = 0; 462 p->nmissed = 0;
463 down(&kprobe_mutex); 463 mutex_lock(&kprobe_mutex);
464 old_p = get_kprobe(p->addr); 464 old_p = get_kprobe(p->addr);
465 if (old_p) { 465 if (old_p) {
466 ret = register_aggr_kprobe(old_p, p); 466 ret = register_aggr_kprobe(old_p, p);
@@ -477,7 +477,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
477 arch_arm_kprobe(p); 477 arch_arm_kprobe(p);
478 478
479out: 479out:
480 up(&kprobe_mutex); 480 mutex_unlock(&kprobe_mutex);
481 481
482 if (ret && probed_mod) 482 if (ret && probed_mod)
483 module_put(probed_mod); 483 module_put(probed_mod);
@@ -496,10 +496,10 @@ void __kprobes unregister_kprobe(struct kprobe *p)
496 struct kprobe *old_p, *list_p; 496 struct kprobe *old_p, *list_p;
497 int cleanup_p; 497 int cleanup_p;
498 498
499 down(&kprobe_mutex); 499 mutex_lock(&kprobe_mutex);
500 old_p = get_kprobe(p->addr); 500 old_p = get_kprobe(p->addr);
501 if (unlikely(!old_p)) { 501 if (unlikely(!old_p)) {
502 up(&kprobe_mutex); 502 mutex_unlock(&kprobe_mutex);
503 return; 503 return;
504 } 504 }
505 if (p != old_p) { 505 if (p != old_p) {
@@ -507,7 +507,7 @@ void __kprobes unregister_kprobe(struct kprobe *p)
507 if (list_p == p) 507 if (list_p == p)
508 /* kprobe p is a valid probe */ 508 /* kprobe p is a valid probe */
509 goto valid_p; 509 goto valid_p;
510 up(&kprobe_mutex); 510 mutex_unlock(&kprobe_mutex);
511 return; 511 return;
512 } 512 }
513valid_p: 513valid_p:
@@ -523,7 +523,7 @@ valid_p:
523 cleanup_p = 0; 523 cleanup_p = 0;
524 } 524 }
525 525
526 up(&kprobe_mutex); 526 mutex_unlock(&kprobe_mutex);
527 527
528 synchronize_sched(); 528 synchronize_sched();
529 if (p->mod_refcounted && 529 if (p->mod_refcounted &&
diff --git a/kernel/kthread.c b/kernel/kthread.c
index e75950a1092c..6a5373868a98 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -12,6 +12,7 @@
12#include <linux/unistd.h> 12#include <linux/unistd.h>
13#include <linux/file.h> 13#include <linux/file.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/mutex.h>
15#include <asm/semaphore.h> 16#include <asm/semaphore.h>
16 17
17/* 18/*
@@ -41,7 +42,7 @@ struct kthread_stop_info
41 42
42/* Thread stopping is done by setthing this var: lock serializes 43/* Thread stopping is done by setthing this var: lock serializes
43 * multiple kthread_stop calls. */ 44 * multiple kthread_stop calls. */
44static DECLARE_MUTEX(kthread_stop_lock); 45static DEFINE_MUTEX(kthread_stop_lock);
45static struct kthread_stop_info kthread_stop_info; 46static struct kthread_stop_info kthread_stop_info;
46 47
47int kthread_should_stop(void) 48int kthread_should_stop(void)
@@ -173,7 +174,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
173{ 174{
174 int ret; 175 int ret;
175 176
176 down(&kthread_stop_lock); 177 mutex_lock(&kthread_stop_lock);
177 178
178 /* It could exit after stop_info.k set, but before wake_up_process. */ 179 /* It could exit after stop_info.k set, but before wake_up_process. */
179 get_task_struct(k); 180 get_task_struct(k);
@@ -194,7 +195,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
194 wait_for_completion(&kthread_stop_info.done); 195 wait_for_completion(&kthread_stop_info.done);
195 kthread_stop_info.k = NULL; 196 kthread_stop_info.k = NULL;
196 ret = kthread_stop_info.err; 197 ret = kthread_stop_info.err;
197 up(&kthread_stop_lock); 198 mutex_unlock(&kthread_stop_lock);
198 199
199 return ret; 200 return ret;
200} 201}
diff --git a/kernel/module.c b/kernel/module.c
index 77764f22f021..fb404299082e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -39,6 +39,7 @@
39#include <linux/device.h> 39#include <linux/device.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/mutex.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <asm/semaphore.h> 44#include <asm/semaphore.h>
44#include <asm/cacheflush.h> 45#include <asm/cacheflush.h>
@@ -60,18 +61,18 @@
60static DEFINE_SPINLOCK(modlist_lock); 61static DEFINE_SPINLOCK(modlist_lock);
61 62
62/* List of modules, protected by module_mutex AND modlist_lock */ 63/* List of modules, protected by module_mutex AND modlist_lock */
63static DECLARE_MUTEX(module_mutex); 64static DEFINE_MUTEX(module_mutex);
64static LIST_HEAD(modules); 65static LIST_HEAD(modules);
65 66
66static DECLARE_MUTEX(notify_mutex); 67static DEFINE_MUTEX(notify_mutex);
67static struct notifier_block * module_notify_list; 68static struct notifier_block * module_notify_list;
68 69
69int register_module_notifier(struct notifier_block * nb) 70int register_module_notifier(struct notifier_block * nb)
70{ 71{
71 int err; 72 int err;
72 down(&notify_mutex); 73 mutex_lock(&notify_mutex);
73 err = notifier_chain_register(&module_notify_list, nb); 74 err = notifier_chain_register(&module_notify_list, nb);
74 up(&notify_mutex); 75 mutex_unlock(&notify_mutex);
75 return err; 76 return err;
76} 77}
77EXPORT_SYMBOL(register_module_notifier); 78EXPORT_SYMBOL(register_module_notifier);
@@ -79,9 +80,9 @@ EXPORT_SYMBOL(register_module_notifier);
79int unregister_module_notifier(struct notifier_block * nb) 80int unregister_module_notifier(struct notifier_block * nb)
80{ 81{
81 int err; 82 int err;
82 down(&notify_mutex); 83 mutex_lock(&notify_mutex);
83 err = notifier_chain_unregister(&module_notify_list, nb); 84 err = notifier_chain_unregister(&module_notify_list, nb);
84 up(&notify_mutex); 85 mutex_unlock(&notify_mutex);
85 return err; 86 return err;
86} 87}
87EXPORT_SYMBOL(unregister_module_notifier); 88EXPORT_SYMBOL(unregister_module_notifier);
@@ -601,7 +602,7 @@ static void free_module(struct module *mod);
601static void wait_for_zero_refcount(struct module *mod) 602static void wait_for_zero_refcount(struct module *mod)
602{ 603{
603 /* Since we might sleep for some time, drop the semaphore first */ 604 /* Since we might sleep for some time, drop the semaphore first */
604 up(&module_mutex); 605 mutex_unlock(&module_mutex);
605 for (;;) { 606 for (;;) {
606 DEBUGP("Looking at refcount...\n"); 607 DEBUGP("Looking at refcount...\n");
607 set_current_state(TASK_UNINTERRUPTIBLE); 608 set_current_state(TASK_UNINTERRUPTIBLE);
@@ -610,7 +611,7 @@ static void wait_for_zero_refcount(struct module *mod)
610 schedule(); 611 schedule();
611 } 612 }
612 current->state = TASK_RUNNING; 613 current->state = TASK_RUNNING;
613 down(&module_mutex); 614 mutex_lock(&module_mutex);
614} 615}
615 616
616asmlinkage long 617asmlinkage long
@@ -627,7 +628,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
627 return -EFAULT; 628 return -EFAULT;
628 name[MODULE_NAME_LEN-1] = '\0'; 629 name[MODULE_NAME_LEN-1] = '\0';
629 630
630 if (down_interruptible(&module_mutex) != 0) 631 if (mutex_lock_interruptible(&module_mutex) != 0)
631 return -EINTR; 632 return -EINTR;
632 633
633 mod = find_module(name); 634 mod = find_module(name);
@@ -676,14 +677,14 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
676 677
677 /* Final destruction now noone is using it. */ 678 /* Final destruction now noone is using it. */
678 if (mod->exit != NULL) { 679 if (mod->exit != NULL) {
679 up(&module_mutex); 680 mutex_unlock(&module_mutex);
680 mod->exit(); 681 mod->exit();
681 down(&module_mutex); 682 mutex_lock(&module_mutex);
682 } 683 }
683 free_module(mod); 684 free_module(mod);
684 685
685 out: 686 out:
686 up(&module_mutex); 687 mutex_unlock(&module_mutex);
687 return ret; 688 return ret;
688} 689}
689 690
@@ -1972,13 +1973,13 @@ sys_init_module(void __user *umod,
1972 return -EPERM; 1973 return -EPERM;
1973 1974
1974 /* Only one module load at a time, please */ 1975 /* Only one module load at a time, please */
1975 if (down_interruptible(&module_mutex) != 0) 1976 if (mutex_lock_interruptible(&module_mutex) != 0)
1976 return -EINTR; 1977 return -EINTR;
1977 1978
1978 /* Do all the hard work */ 1979 /* Do all the hard work */
1979 mod = load_module(umod, len, uargs); 1980 mod = load_module(umod, len, uargs);
1980 if (IS_ERR(mod)) { 1981 if (IS_ERR(mod)) {
1981 up(&module_mutex); 1982 mutex_unlock(&module_mutex);
1982 return PTR_ERR(mod); 1983 return PTR_ERR(mod);
1983 } 1984 }
1984 1985
@@ -1987,11 +1988,11 @@ sys_init_module(void __user *umod,
1987 stop_machine_run(__link_module, mod, NR_CPUS); 1988 stop_machine_run(__link_module, mod, NR_CPUS);
1988 1989
1989 /* Drop lock so they can recurse */ 1990 /* Drop lock so they can recurse */
1990 up(&module_mutex); 1991 mutex_unlock(&module_mutex);
1991 1992
1992 down(&notify_mutex); 1993 mutex_lock(&notify_mutex);
1993 notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod); 1994 notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
1994 up(&notify_mutex); 1995 mutex_unlock(&notify_mutex);
1995 1996
1996 /* Start the module */ 1997 /* Start the module */
1997 if (mod->init != NULL) 1998 if (mod->init != NULL)
@@ -2006,15 +2007,15 @@ sys_init_module(void __user *umod,
2006 mod->name); 2007 mod->name);
2007 else { 2008 else {
2008 module_put(mod); 2009 module_put(mod);
2009 down(&module_mutex); 2010 mutex_lock(&module_mutex);
2010 free_module(mod); 2011 free_module(mod);
2011 up(&module_mutex); 2012 mutex_unlock(&module_mutex);
2012 } 2013 }
2013 return ret; 2014 return ret;
2014 } 2015 }
2015 2016
2016 /* Now it's a first class citizen! */ 2017 /* Now it's a first class citizen! */
2017 down(&module_mutex); 2018 mutex_lock(&module_mutex);
2018 mod->state = MODULE_STATE_LIVE; 2019 mod->state = MODULE_STATE_LIVE;
2019 /* Drop initial reference. */ 2020 /* Drop initial reference. */
2020 module_put(mod); 2021 module_put(mod);
@@ -2022,7 +2023,7 @@ sys_init_module(void __user *umod,
2022 mod->module_init = NULL; 2023 mod->module_init = NULL;
2023 mod->init_size = 0; 2024 mod->init_size = 0;
2024 mod->init_text_size = 0; 2025 mod->init_text_size = 0;
2025 up(&module_mutex); 2026 mutex_unlock(&module_mutex);
2026 2027
2027 return 0; 2028 return 0;
2028} 2029}
@@ -2112,7 +2113,7 @@ struct module *module_get_kallsym(unsigned int symnum,
2112{ 2113{
2113 struct module *mod; 2114 struct module *mod;
2114 2115
2115 down(&module_mutex); 2116 mutex_lock(&module_mutex);
2116 list_for_each_entry(mod, &modules, list) { 2117 list_for_each_entry(mod, &modules, list) {
2117 if (symnum < mod->num_symtab) { 2118 if (symnum < mod->num_symtab) {
2118 *value = mod->symtab[symnum].st_value; 2119 *value = mod->symtab[symnum].st_value;
@@ -2120,12 +2121,12 @@ struct module *module_get_kallsym(unsigned int symnum,
2120 strncpy(namebuf, 2121 strncpy(namebuf,
2121 mod->strtab + mod->symtab[symnum].st_name, 2122 mod->strtab + mod->symtab[symnum].st_name,
2122 127); 2123 127);
2123 up(&module_mutex); 2124 mutex_unlock(&module_mutex);
2124 return mod; 2125 return mod;
2125 } 2126 }
2126 symnum -= mod->num_symtab; 2127 symnum -= mod->num_symtab;
2127 } 2128 }
2128 up(&module_mutex); 2129 mutex_unlock(&module_mutex);
2129 return NULL; 2130 return NULL;
2130} 2131}
2131 2132
@@ -2168,7 +2169,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
2168 struct list_head *i; 2169 struct list_head *i;
2169 loff_t n = 0; 2170 loff_t n = 0;
2170 2171
2171 down(&module_mutex); 2172 mutex_lock(&module_mutex);
2172 list_for_each(i, &modules) { 2173 list_for_each(i, &modules) {
2173 if (n++ == *pos) 2174 if (n++ == *pos)
2174 break; 2175 break;
@@ -2189,7 +2190,7 @@ static void *m_next(struct seq_file *m, void *p, loff_t *pos)
2189 2190
2190static void m_stop(struct seq_file *m, void *p) 2191static void m_stop(struct seq_file *m, void *p)
2191{ 2192{
2192 up(&module_mutex); 2193 mutex_unlock(&module_mutex);
2193} 2194}
2194 2195
2195static int m_show(struct seq_file *m, void *p) 2196static int m_show(struct seq_file *m, void *p)
diff --git a/kernel/panic.c b/kernel/panic.c
index 126dc43f1c74..acd95adddb93 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -20,10 +20,13 @@
20#include <linux/nmi.h> 20#include <linux/nmi.h>
21#include <linux/kexec.h> 21#include <linux/kexec.h>
22 22
23int panic_timeout;
24int panic_on_oops; 23int panic_on_oops;
25int tainted; 24int tainted;
25static int pause_on_oops;
26static int pause_on_oops_flag;
27static DEFINE_SPINLOCK(pause_on_oops_lock);
26 28
29int panic_timeout;
27EXPORT_SYMBOL(panic_timeout); 30EXPORT_SYMBOL(panic_timeout);
28 31
29struct notifier_block *panic_notifier_list; 32struct notifier_block *panic_notifier_list;
@@ -174,3 +177,95 @@ void add_taint(unsigned flag)
174 tainted |= flag; 177 tainted |= flag;
175} 178}
176EXPORT_SYMBOL(add_taint); 179EXPORT_SYMBOL(add_taint);
180
181static int __init pause_on_oops_setup(char *str)
182{
183 pause_on_oops = simple_strtoul(str, NULL, 0);
184 return 1;
185}
186__setup("pause_on_oops=", pause_on_oops_setup);
187
188static void spin_msec(int msecs)
189{
190 int i;
191
192 for (i = 0; i < msecs; i++) {
193 touch_nmi_watchdog();
194 mdelay(1);
195 }
196}
197
198/*
199 * It just happens that oops_enter() and oops_exit() are identically
200 * implemented...
201 */
202static void do_oops_enter_exit(void)
203{
204 unsigned long flags;
205 static int spin_counter;
206
207 if (!pause_on_oops)
208 return;
209
210 spin_lock_irqsave(&pause_on_oops_lock, flags);
211 if (pause_on_oops_flag == 0) {
212 /* This CPU may now print the oops message */
213 pause_on_oops_flag = 1;
214 } else {
215 /* We need to stall this CPU */
216 if (!spin_counter) {
217 /* This CPU gets to do the counting */
218 spin_counter = pause_on_oops;
219 do {
220 spin_unlock(&pause_on_oops_lock);
221 spin_msec(MSEC_PER_SEC);
222 spin_lock(&pause_on_oops_lock);
223 } while (--spin_counter);
224 pause_on_oops_flag = 0;
225 } else {
226 /* This CPU waits for a different one */
227 while (spin_counter) {
228 spin_unlock(&pause_on_oops_lock);
229 spin_msec(1);
230 spin_lock(&pause_on_oops_lock);
231 }
232 }
233 }
234 spin_unlock_irqrestore(&pause_on_oops_lock, flags);
235}
236
237/*
238 * Return true if the calling CPU is allowed to print oops-related info. This
239 * is a bit racy..
240 */
241int oops_may_print(void)
242{
243 return pause_on_oops_flag == 0;
244}
245
246/*
247 * Called when the architecture enters its oops handler, before it prints
248 * anything. If this is the first CPU to oops, and it's oopsing the first time
249 * then let it proceed.
250 *
251 * This is all enabled by the pause_on_oops kernel boot option. We do all this
252 * to ensure that oopses don't scroll off the screen. It has the side-effect
253 * of preventing later-oopsing CPUs from mucking up the display, too.
254 *
255 * It turns out that the CPU which is allowed to print ends up pausing for the
256 * right duration, whereas all the other CPUs pause for twice as long: once in
257 * oops_enter(), once in oops_exit().
258 */
259void oops_enter(void)
260{
261 do_oops_enter_exit();
262}
263
264/*
265 * Called when the architecture exits its oops handler, after printing
266 * everything.
267 */
268void oops_exit(void)
269{
270 do_oops_enter_exit();
271}
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index fa895fc2ecf5..9944379360b5 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/time.h> 37#include <linux/time.h>
38#include <linux/mutex.h>
38 39
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40#include <asm/semaphore.h> 41#include <asm/semaphore.h>
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index 04be7d0d96a7..8d0af3d37a4b 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -5,7 +5,7 @@ endif
5 5
6obj-y := main.o process.o console.o 6obj-y := main.o process.o console.o
7obj-$(CONFIG_PM_LEGACY) += pm.o 7obj-$(CONFIG_PM_LEGACY) += pm.o
8obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o disk.o snapshot.o 8obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o disk.o snapshot.o swap.o user.o
9 9
10obj-$(CONFIG_SUSPEND_SMP) += smp.o 10obj-$(CONFIG_SUSPEND_SMP) += smp.o
11 11
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 0b43847dc980..81d4d982f3f0 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -22,17 +22,6 @@
22#include "power.h" 22#include "power.h"
23 23
24 24
25extern suspend_disk_method_t pm_disk_mode;
26
27extern int swsusp_shrink_memory(void);
28extern int swsusp_suspend(void);
29extern int swsusp_write(struct pbe *pblist, unsigned int nr_pages);
30extern int swsusp_check(void);
31extern int swsusp_read(struct pbe **pblist_ptr);
32extern void swsusp_close(void);
33extern int swsusp_resume(void);
34
35
36static int noresume = 0; 25static int noresume = 0;
37char resume_file[256] = CONFIG_PM_STD_PARTITION; 26char resume_file[256] = CONFIG_PM_STD_PARTITION;
38dev_t swsusp_resume_device; 27dev_t swsusp_resume_device;
@@ -70,10 +59,6 @@ static void power_down(suspend_disk_method_t mode)
70 while(1); 59 while(1);
71} 60}
72 61
73
74static int in_suspend __nosavedata = 0;
75
76
77static inline void platform_finish(void) 62static inline void platform_finish(void)
78{ 63{
79 if (pm_disk_mode == PM_DISK_PLATFORM) { 64 if (pm_disk_mode == PM_DISK_PLATFORM) {
@@ -87,7 +72,6 @@ static int prepare_processes(void)
87 int error; 72 int error;
88 73
89 pm_prepare_console(); 74 pm_prepare_console();
90 sys_sync();
91 disable_nonboot_cpus(); 75 disable_nonboot_cpus();
92 76
93 if (freeze_processes()) { 77 if (freeze_processes()) {
@@ -145,7 +129,7 @@ int pm_suspend_disk(void)
145 if (in_suspend) { 129 if (in_suspend) {
146 device_resume(); 130 device_resume();
147 pr_debug("PM: writing image.\n"); 131 pr_debug("PM: writing image.\n");
148 error = swsusp_write(pagedir_nosave, nr_copy_pages); 132 error = swsusp_write();
149 if (!error) 133 if (!error)
150 power_down(pm_disk_mode); 134 power_down(pm_disk_mode);
151 else { 135 else {
@@ -216,7 +200,7 @@ static int software_resume(void)
216 200
217 pr_debug("PM: Reading swsusp image.\n"); 201 pr_debug("PM: Reading swsusp image.\n");
218 202
219 if ((error = swsusp_read(&pagedir_nosave))) { 203 if ((error = swsusp_read())) {
220 swsusp_free(); 204 swsusp_free();
221 goto Thaw; 205 goto Thaw;
222 } 206 }
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 9cb235cba4a9..ee371f50ccaa 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -103,7 +103,7 @@ static int suspend_prepare(suspend_state_t state)
103} 103}
104 104
105 105
106static int suspend_enter(suspend_state_t state) 106int suspend_enter(suspend_state_t state)
107{ 107{
108 int error = 0; 108 int error = 0;
109 unsigned long flags; 109 unsigned long flags;
diff --git a/kernel/power/pm.c b/kernel/power/pm.c
index 33c508e857dd..0f6908cce1dd 100644
--- a/kernel/power/pm.c
+++ b/kernel/power/pm.c
@@ -25,6 +25,7 @@
25#include <linux/pm.h> 25#include <linux/pm.h>
26#include <linux/pm_legacy.h> 26#include <linux/pm_legacy.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/mutex.h>
28 29
29int pm_active; 30int pm_active;
30 31
@@ -40,7 +41,7 @@ int pm_active;
40 * until a resume but that will be fine. 41 * until a resume but that will be fine.
41 */ 42 */
42 43
43static DECLARE_MUTEX(pm_devs_lock); 44static DEFINE_MUTEX(pm_devs_lock);
44static LIST_HEAD(pm_devs); 45static LIST_HEAD(pm_devs);
45 46
46/** 47/**
@@ -67,9 +68,9 @@ struct pm_dev *pm_register(pm_dev_t type,
67 dev->id = id; 68 dev->id = id;
68 dev->callback = callback; 69 dev->callback = callback;
69 70
70 down(&pm_devs_lock); 71 mutex_lock(&pm_devs_lock);
71 list_add(&dev->entry, &pm_devs); 72 list_add(&dev->entry, &pm_devs);
72 up(&pm_devs_lock); 73 mutex_unlock(&pm_devs_lock);
73 } 74 }
74 return dev; 75 return dev;
75} 76}
@@ -85,9 +86,9 @@ struct pm_dev *pm_register(pm_dev_t type,
85void pm_unregister(struct pm_dev *dev) 86void pm_unregister(struct pm_dev *dev)
86{ 87{
87 if (dev) { 88 if (dev) {
88 down(&pm_devs_lock); 89 mutex_lock(&pm_devs_lock);
89 list_del(&dev->entry); 90 list_del(&dev->entry);
90 up(&pm_devs_lock); 91 mutex_unlock(&pm_devs_lock);
91 92
92 kfree(dev); 93 kfree(dev);
93 } 94 }
@@ -118,7 +119,7 @@ void pm_unregister_all(pm_callback callback)
118 if (!callback) 119 if (!callback)
119 return; 120 return;
120 121
121 down(&pm_devs_lock); 122 mutex_lock(&pm_devs_lock);
122 entry = pm_devs.next; 123 entry = pm_devs.next;
123 while (entry != &pm_devs) { 124 while (entry != &pm_devs) {
124 struct pm_dev *dev = list_entry(entry, struct pm_dev, entry); 125 struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
@@ -126,7 +127,7 @@ void pm_unregister_all(pm_callback callback)
126 if (dev->callback == callback) 127 if (dev->callback == callback)
127 __pm_unregister(dev); 128 __pm_unregister(dev);
128 } 129 }
129 up(&pm_devs_lock); 130 mutex_unlock(&pm_devs_lock);
130} 131}
131 132
132/** 133/**
@@ -234,7 +235,7 @@ int pm_send_all(pm_request_t rqst, void *data)
234{ 235{
235 struct list_head *entry; 236 struct list_head *entry;
236 237
237 down(&pm_devs_lock); 238 mutex_lock(&pm_devs_lock);
238 entry = pm_devs.next; 239 entry = pm_devs.next;
239 while (entry != &pm_devs) { 240 while (entry != &pm_devs) {
240 struct pm_dev *dev = list_entry(entry, struct pm_dev, entry); 241 struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
@@ -246,13 +247,13 @@ int pm_send_all(pm_request_t rqst, void *data)
246 */ 247 */
247 if (rqst == PM_SUSPEND) 248 if (rqst == PM_SUSPEND)
248 pm_undo_all(dev); 249 pm_undo_all(dev);
249 up(&pm_devs_lock); 250 mutex_unlock(&pm_devs_lock);
250 return status; 251 return status;
251 } 252 }
252 } 253 }
253 entry = entry->next; 254 entry = entry->next;
254 } 255 }
255 up(&pm_devs_lock); 256 mutex_unlock(&pm_devs_lock);
256 return 0; 257 return 0;
257} 258}
258 259
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 388dba680841..f06f12f21767 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -8,6 +8,7 @@ struct swsusp_info {
8 int cpus; 8 int cpus;
9 unsigned long image_pages; 9 unsigned long image_pages;
10 unsigned long pages; 10 unsigned long pages;
11 unsigned long size;
11} __attribute__((aligned(PAGE_SIZE))); 12} __attribute__((aligned(PAGE_SIZE)));
12 13
13 14
@@ -37,21 +38,79 @@ extern struct subsystem power_subsys;
37/* References to section boundaries */ 38/* References to section boundaries */
38extern const void __nosave_begin, __nosave_end; 39extern const void __nosave_begin, __nosave_end;
39 40
40extern unsigned int nr_copy_pages;
41extern struct pbe *pagedir_nosave; 41extern struct pbe *pagedir_nosave;
42 42
43/* Preferred image size in bytes (default 500 MB) */ 43/* Preferred image size in bytes (default 500 MB) */
44extern unsigned long image_size; 44extern unsigned long image_size;
45extern int in_suspend;
46extern dev_t swsusp_resume_device;
45 47
46extern asmlinkage int swsusp_arch_suspend(void); 48extern asmlinkage int swsusp_arch_suspend(void);
47extern asmlinkage int swsusp_arch_resume(void); 49extern asmlinkage int swsusp_arch_resume(void);
48 50
49extern unsigned int count_data_pages(void); 51extern unsigned int count_data_pages(void);
50extern void free_pagedir(struct pbe *pblist); 52
51extern void release_eaten_pages(void); 53struct snapshot_handle {
52extern struct pbe *alloc_pagedir(unsigned nr_pages, gfp_t gfp_mask, int safe_needed); 54 loff_t offset;
55 unsigned int page;
56 unsigned int page_offset;
57 unsigned int prev;
58 struct pbe *pbe;
59 void *buffer;
60 unsigned int buf_offset;
61};
62
63#define data_of(handle) ((handle).buffer + (handle).buf_offset)
64
65extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
66extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
67int snapshot_image_loaded(struct snapshot_handle *handle);
68
69#define SNAPSHOT_IOC_MAGIC '3'
70#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
71#define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2)
72#define SNAPSHOT_ATOMIC_SNAPSHOT _IOW(SNAPSHOT_IOC_MAGIC, 3, void *)
73#define SNAPSHOT_ATOMIC_RESTORE _IO(SNAPSHOT_IOC_MAGIC, 4)
74#define SNAPSHOT_FREE _IO(SNAPSHOT_IOC_MAGIC, 5)
75#define SNAPSHOT_SET_IMAGE_SIZE _IOW(SNAPSHOT_IOC_MAGIC, 6, unsigned long)
76#define SNAPSHOT_AVAIL_SWAP _IOR(SNAPSHOT_IOC_MAGIC, 7, void *)
77#define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *)
78#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9)
79#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
80#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
81#define SNAPSHOT_IOC_MAXNR 11
82
83/**
84 * The bitmap is used for tracing allocated swap pages
85 *
86 * The entire bitmap consists of a number of bitmap_page
87 * structures linked with the help of the .next member.
88 * Thus each page can be allocated individually, so we only
89 * need to make 0-order memory allocations to create
90 * the bitmap.
91 */
92
93#define BITMAP_PAGE_SIZE (PAGE_SIZE - sizeof(void *))
94#define BITMAP_PAGE_CHUNKS (BITMAP_PAGE_SIZE / sizeof(long))
95#define BITS_PER_CHUNK (sizeof(long) * 8)
96#define BITMAP_PAGE_BITS (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK)
97
98struct bitmap_page {
99 unsigned long chunks[BITMAP_PAGE_CHUNKS];
100 struct bitmap_page *next;
101};
102
103extern void free_bitmap(struct bitmap_page *bitmap);
104extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
105extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap);
106extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
107
108extern int swsusp_check(void);
109extern int swsusp_shrink_memory(void);
53extern void swsusp_free(void); 110extern void swsusp_free(void);
54extern int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed); 111extern int swsusp_suspend(void);
55extern unsigned int snapshot_nr_pages(void); 112extern int swsusp_resume(void);
56extern struct pbe *snapshot_pblist(void); 113extern int swsusp_read(void);
57extern void snapshot_pblist_set(struct pbe *pblist); 114extern int swsusp_write(void);
115extern void swsusp_close(void);
116extern int suspend_enter(suspend_state_t state);
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 28de118f7a0b..8ac7c35fad77 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -12,11 +12,12 @@
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/suspend.h> 13#include <linux/suspend.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/syscalls.h>
15 16
16/* 17/*
17 * Timeout for stopping processes 18 * Timeout for stopping processes
18 */ 19 */
19#define TIMEOUT (6 * HZ) 20#define TIMEOUT (20 * HZ)
20 21
21 22
22static inline int freezeable(struct task_struct * p) 23static inline int freezeable(struct task_struct * p)
@@ -54,38 +55,62 @@ void refrigerator(void)
54 current->state = save; 55 current->state = save;
55} 56}
56 57
58static inline void freeze_process(struct task_struct *p)
59{
60 unsigned long flags;
61
62 if (!freezing(p)) {
63 freeze(p);
64 spin_lock_irqsave(&p->sighand->siglock, flags);
65 signal_wake_up(p, 0);
66 spin_unlock_irqrestore(&p->sighand->siglock, flags);
67 }
68}
69
57/* 0 = success, else # of processes that we failed to stop */ 70/* 0 = success, else # of processes that we failed to stop */
58int freeze_processes(void) 71int freeze_processes(void)
59{ 72{
60 int todo; 73 int todo, nr_user, user_frozen;
61 unsigned long start_time; 74 unsigned long start_time;
62 struct task_struct *g, *p; 75 struct task_struct *g, *p;
63 unsigned long flags; 76 unsigned long flags;
64 77
65 printk( "Stopping tasks: " ); 78 printk( "Stopping tasks: " );
66 start_time = jiffies; 79 start_time = jiffies;
80 user_frozen = 0;
67 do { 81 do {
68 todo = 0; 82 nr_user = todo = 0;
69 read_lock(&tasklist_lock); 83 read_lock(&tasklist_lock);
70 do_each_thread(g, p) { 84 do_each_thread(g, p) {
71 if (!freezeable(p)) 85 if (!freezeable(p))
72 continue; 86 continue;
73 if (frozen(p)) 87 if (frozen(p))
74 continue; 88 continue;
75 89 if (p->mm && !(p->flags & PF_BORROWED_MM)) {
76 freeze(p); 90 /* The task is a user-space one.
77 spin_lock_irqsave(&p->sighand->siglock, flags); 91 * Freeze it unless there's a vfork completion
78 signal_wake_up(p, 0); 92 * pending
79 spin_unlock_irqrestore(&p->sighand->siglock, flags); 93 */
80 todo++; 94 if (!p->vfork_done)
95 freeze_process(p);
96 nr_user++;
97 } else {
98 /* Freeze only if the user space is frozen */
99 if (user_frozen)
100 freeze_process(p);
101 todo++;
102 }
81 } while_each_thread(g, p); 103 } while_each_thread(g, p);
82 read_unlock(&tasklist_lock); 104 read_unlock(&tasklist_lock);
105 todo += nr_user;
106 if (!user_frozen && !nr_user) {
107 sys_sync();
108 start_time = jiffies;
109 }
110 user_frozen = !nr_user;
83 yield(); /* Yield is okay here */ 111 yield(); /* Yield is okay here */
84 if (todo && time_after(jiffies, start_time + TIMEOUT)) { 112 if (todo && time_after(jiffies, start_time + TIMEOUT))
85 printk( "\n" );
86 printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo );
87 break; 113 break;
88 }
89 } while(todo); 114 } while(todo);
90 115
91 /* This does not unfreeze processes that are already frozen 116 /* This does not unfreeze processes that are already frozen
@@ -94,8 +119,14 @@ int freeze_processes(void)
94 * but it cleans up leftover PF_FREEZE requests. 119 * but it cleans up leftover PF_FREEZE requests.
95 */ 120 */
96 if (todo) { 121 if (todo) {
122 printk( "\n" );
123 printk(KERN_ERR " stopping tasks timed out "
124 "after %d seconds (%d tasks remaining):\n",
125 TIMEOUT / HZ, todo);
97 read_lock(&tasklist_lock); 126 read_lock(&tasklist_lock);
98 do_each_thread(g, p) 127 do_each_thread(g, p) {
128 if (freezeable(p) && !frozen(p))
129 printk(KERN_ERR " %s\n", p->comm);
99 if (freezing(p)) { 130 if (freezing(p)) {
100 pr_debug(" clean up: %s\n", p->comm); 131 pr_debug(" clean up: %s\n", p->comm);
101 p->flags &= ~PF_FREEZE; 132 p->flags &= ~PF_FREEZE;
@@ -103,7 +134,7 @@ int freeze_processes(void)
103 recalc_sigpending_tsk(p); 134 recalc_sigpending_tsk(p);
104 spin_unlock_irqrestore(&p->sighand->siglock, flags); 135 spin_unlock_irqrestore(&p->sighand->siglock, flags);
105 } 136 }
106 while_each_thread(g, p); 137 } while_each_thread(g, p);
107 read_unlock(&tasklist_lock); 138 read_unlock(&tasklist_lock);
108 return todo; 139 return todo;
109 } 140 }
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 8d5a5986d621..c5863d02c89e 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12 12
13#include <linux/version.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/mm.h> 15#include <linux/mm.h>
15#include <linux/suspend.h> 16#include <linux/suspend.h>
@@ -34,7 +35,9 @@
34#include "power.h" 35#include "power.h"
35 36
36struct pbe *pagedir_nosave; 37struct pbe *pagedir_nosave;
37unsigned int nr_copy_pages; 38static unsigned int nr_copy_pages;
39static unsigned int nr_meta_pages;
40static unsigned long *buffer;
38 41
39#ifdef CONFIG_HIGHMEM 42#ifdef CONFIG_HIGHMEM
40unsigned int count_highmem_pages(void) 43unsigned int count_highmem_pages(void)
@@ -80,7 +83,7 @@ static int save_highmem_zone(struct zone *zone)
80 void *kaddr; 83 void *kaddr;
81 unsigned long pfn = zone_pfn + zone->zone_start_pfn; 84 unsigned long pfn = zone_pfn + zone->zone_start_pfn;
82 85
83 if (!(pfn%1000)) 86 if (!(pfn%10000))
84 printk("."); 87 printk(".");
85 if (!pfn_valid(pfn)) 88 if (!pfn_valid(pfn))
86 continue; 89 continue;
@@ -119,13 +122,15 @@ int save_highmem(void)
119 struct zone *zone; 122 struct zone *zone;
120 int res = 0; 123 int res = 0;
121 124
122 pr_debug("swsusp: Saving Highmem\n"); 125 pr_debug("swsusp: Saving Highmem");
126 drain_local_pages();
123 for_each_zone (zone) { 127 for_each_zone (zone) {
124 if (is_highmem(zone)) 128 if (is_highmem(zone))
125 res = save_highmem_zone(zone); 129 res = save_highmem_zone(zone);
126 if (res) 130 if (res)
127 return res; 131 return res;
128 } 132 }
133 printk("\n");
129 return 0; 134 return 0;
130} 135}
131 136
@@ -235,7 +240,7 @@ static void copy_data_pages(struct pbe *pblist)
235 * free_pagedir - free pages allocated with alloc_pagedir() 240 * free_pagedir - free pages allocated with alloc_pagedir()
236 */ 241 */
237 242
238void free_pagedir(struct pbe *pblist) 243static void free_pagedir(struct pbe *pblist)
239{ 244{
240 struct pbe *pbe; 245 struct pbe *pbe;
241 246
@@ -301,7 +306,7 @@ struct eaten_page {
301 306
302static struct eaten_page *eaten_pages = NULL; 307static struct eaten_page *eaten_pages = NULL;
303 308
304void release_eaten_pages(void) 309static void release_eaten_pages(void)
305{ 310{
306 struct eaten_page *p, *q; 311 struct eaten_page *p, *q;
307 312
@@ -376,7 +381,6 @@ struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, int safe_needed
376 if (!nr_pages) 381 if (!nr_pages)
377 return NULL; 382 return NULL;
378 383
379 pr_debug("alloc_pagedir(): nr_pages = %d\n", nr_pages);
380 pblist = alloc_image_page(gfp_mask, safe_needed); 384 pblist = alloc_image_page(gfp_mask, safe_needed);
381 /* FIXME: rewrite this ugly loop */ 385 /* FIXME: rewrite this ugly loop */
382 for (pbe = pblist, num = PBES_PER_PAGE; pbe && num < nr_pages; 386 for (pbe = pblist, num = PBES_PER_PAGE; pbe && num < nr_pages;
@@ -388,7 +392,7 @@ struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, int safe_needed
388 free_pagedir(pblist); 392 free_pagedir(pblist);
389 pblist = NULL; 393 pblist = NULL;
390 } else 394 } else
391 create_pbe_list(pblist, nr_pages); 395 create_pbe_list(pblist, nr_pages);
392 return pblist; 396 return pblist;
393} 397}
394 398
@@ -414,6 +418,10 @@ void swsusp_free(void)
414 } 418 }
415 } 419 }
416 } 420 }
421 nr_copy_pages = 0;
422 nr_meta_pages = 0;
423 pagedir_nosave = NULL;
424 buffer = NULL;
417} 425}
418 426
419 427
@@ -437,7 +445,7 @@ static int enough_free_mem(unsigned int nr_pages)
437 (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE); 445 (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
438} 446}
439 447
440int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed) 448static int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed)
441{ 449{
442 struct pbe *p; 450 struct pbe *p;
443 451
@@ -504,7 +512,318 @@ asmlinkage int swsusp_save(void)
504 */ 512 */
505 513
506 nr_copy_pages = nr_pages; 514 nr_copy_pages = nr_pages;
515 nr_meta_pages = (nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT;
507 516
508 printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages); 517 printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages);
509 return 0; 518 return 0;
510} 519}
520
521static void init_header(struct swsusp_info *info)
522{
523 memset(info, 0, sizeof(struct swsusp_info));
524 info->version_code = LINUX_VERSION_CODE;
525 info->num_physpages = num_physpages;
526 memcpy(&info->uts, &system_utsname, sizeof(system_utsname));
527 info->cpus = num_online_cpus();
528 info->image_pages = nr_copy_pages;
529 info->pages = nr_copy_pages + nr_meta_pages + 1;
530 info->size = info->pages;
531 info->size <<= PAGE_SHIFT;
532}
533
534/**
535 * pack_orig_addresses - the .orig_address fields of the PBEs from the
536 * list starting at @pbe are stored in the array @buf[] (1 page)
537 */
538
539static inline struct pbe *pack_orig_addresses(unsigned long *buf, struct pbe *pbe)
540{
541 int j;
542
543 for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
544 buf[j] = pbe->orig_address;
545 pbe = pbe->next;
546 }
547 if (!pbe)
548 for (; j < PAGE_SIZE / sizeof(long); j++)
549 buf[j] = 0;
550 return pbe;
551}
552
553/**
554 * snapshot_read_next - used for reading the system memory snapshot.
555 *
556 * On the first call to it @handle should point to a zeroed
557 * snapshot_handle structure. The structure gets updated and a pointer
558 * to it should be passed to this function every next time.
559 *
560 * The @count parameter should contain the number of bytes the caller
561 * wants to read from the snapshot. It must not be zero.
562 *
563 * On success the function returns a positive number. Then, the caller
564 * is allowed to read up to the returned number of bytes from the memory
565 * location computed by the data_of() macro. The number returned
566 * may be smaller than @count, but this only happens if the read would
567 * cross a page boundary otherwise.
568 *
569 * The function returns 0 to indicate the end of data stream condition,
570 * and a negative number is returned on error. In such cases the
571 * structure pointed to by @handle is not updated and should not be used
572 * any more.
573 */
574
575int snapshot_read_next(struct snapshot_handle *handle, size_t count)
576{
577 if (handle->page > nr_meta_pages + nr_copy_pages)
578 return 0;
579 if (!buffer) {
580 /* This makes the buffer be freed by swsusp_free() */
581 buffer = alloc_image_page(GFP_ATOMIC, 0);
582 if (!buffer)
583 return -ENOMEM;
584 }
585 if (!handle->offset) {
586 init_header((struct swsusp_info *)buffer);
587 handle->buffer = buffer;
588 handle->pbe = pagedir_nosave;
589 }
590 if (handle->prev < handle->page) {
591 if (handle->page <= nr_meta_pages) {
592 handle->pbe = pack_orig_addresses(buffer, handle->pbe);
593 if (!handle->pbe)
594 handle->pbe = pagedir_nosave;
595 } else {
596 handle->buffer = (void *)handle->pbe->address;
597 handle->pbe = handle->pbe->next;
598 }
599 handle->prev = handle->page;
600 }
601 handle->buf_offset = handle->page_offset;
602 if (handle->page_offset + count >= PAGE_SIZE) {
603 count = PAGE_SIZE - handle->page_offset;
604 handle->page_offset = 0;
605 handle->page++;
606 } else {
607 handle->page_offset += count;
608 }
609 handle->offset += count;
610 return count;
611}
612
613/**
614 * mark_unsafe_pages - mark the pages that cannot be used for storing
615 * the image during resume, because they conflict with the pages that
616 * had been used before suspend
617 */
618
619static int mark_unsafe_pages(struct pbe *pblist)
620{
621 struct zone *zone;
622 unsigned long zone_pfn;
623 struct pbe *p;
624
625 if (!pblist) /* a sanity check */
626 return -EINVAL;
627
628 /* Clear page flags */
629 for_each_zone (zone) {
630 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
631 if (pfn_valid(zone_pfn + zone->zone_start_pfn))
632 ClearPageNosaveFree(pfn_to_page(zone_pfn +
633 zone->zone_start_pfn));
634 }
635
636 /* Mark orig addresses */
637 for_each_pbe (p, pblist) {
638 if (virt_addr_valid(p->orig_address))
639 SetPageNosaveFree(virt_to_page(p->orig_address));
640 else
641 return -EFAULT;
642 }
643
644 return 0;
645}
646
647static void copy_page_backup_list(struct pbe *dst, struct pbe *src)
648{
649 /* We assume both lists contain the same number of elements */
650 while (src) {
651 dst->orig_address = src->orig_address;
652 dst = dst->next;
653 src = src->next;
654 }
655}
656
657static int check_header(struct swsusp_info *info)
658{
659 char *reason = NULL;
660
661 if (info->version_code != LINUX_VERSION_CODE)
662 reason = "kernel version";
663 if (info->num_physpages != num_physpages)
664 reason = "memory size";
665 if (strcmp(info->uts.sysname,system_utsname.sysname))
666 reason = "system type";
667 if (strcmp(info->uts.release,system_utsname.release))
668 reason = "kernel release";
669 if (strcmp(info->uts.version,system_utsname.version))
670 reason = "version";
671 if (strcmp(info->uts.machine,system_utsname.machine))
672 reason = "machine";
673 if (reason) {
674 printk(KERN_ERR "swsusp: Resume mismatch: %s\n", reason);
675 return -EPERM;
676 }
677 return 0;
678}
679
680/**
681 * load header - check the image header and copy data from it
682 */
683
684static int load_header(struct snapshot_handle *handle,
685 struct swsusp_info *info)
686{
687 int error;
688 struct pbe *pblist;
689
690 error = check_header(info);
691 if (!error) {
692 pblist = alloc_pagedir(info->image_pages, GFP_ATOMIC, 0);
693 if (!pblist)
694 return -ENOMEM;
695 pagedir_nosave = pblist;
696 handle->pbe = pblist;
697 nr_copy_pages = info->image_pages;
698 nr_meta_pages = info->pages - info->image_pages - 1;
699 }
700 return error;
701}
702
703/**
704 * unpack_orig_addresses - copy the elements of @buf[] (1 page) to
705 * the PBEs in the list starting at @pbe
706 */
707
708static inline struct pbe *unpack_orig_addresses(unsigned long *buf,
709 struct pbe *pbe)
710{
711 int j;
712
713 for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
714 pbe->orig_address = buf[j];
715 pbe = pbe->next;
716 }
717 return pbe;
718}
719
720/**
721 * create_image - use metadata contained in the PBE list
722 * pointed to by pagedir_nosave to mark the pages that will
723 * be overwritten in the process of restoring the system
724 * memory state from the image and allocate memory for
725 * the image avoiding these pages
726 */
727
728static int create_image(struct snapshot_handle *handle)
729{
730 int error = 0;
731 struct pbe *p, *pblist;
732
733 p = pagedir_nosave;
734 error = mark_unsafe_pages(p);
735 if (!error) {
736 pblist = alloc_pagedir(nr_copy_pages, GFP_ATOMIC, 1);
737 if (pblist)
738 copy_page_backup_list(pblist, p);
739 free_pagedir(p);
740 if (!pblist)
741 error = -ENOMEM;
742 }
743 if (!error)
744 error = alloc_data_pages(pblist, GFP_ATOMIC, 1);
745 if (!error) {
746 release_eaten_pages();
747 pagedir_nosave = pblist;
748 } else {
749 pagedir_nosave = NULL;
750 handle->pbe = NULL;
751 nr_copy_pages = 0;
752 nr_meta_pages = 0;
753 }
754 return error;
755}
756
757/**
758 * snapshot_write_next - used for writing the system memory snapshot.
759 *
760 * On the first call to it @handle should point to a zeroed
761 * snapshot_handle structure. The structure gets updated and a pointer
762 * to it should be passed to this function every next time.
763 *
764 * The @count parameter should contain the number of bytes the caller
765 * wants to write to the image. It must not be zero.
766 *
767 * On success the function returns a positive number. Then, the caller
768 * is allowed to write up to the returned number of bytes to the memory
769 * location computed by the data_of() macro. The number returned
770 * may be smaller than @count, but this only happens if the write would
771 * cross a page boundary otherwise.
772 *
773 * The function returns 0 to indicate the "end of file" condition,
774 * and a negative number is returned on error. In such cases the
775 * structure pointed to by @handle is not updated and should not be used
776 * any more.
777 */
778
779int snapshot_write_next(struct snapshot_handle *handle, size_t count)
780{
781 int error = 0;
782
783 if (handle->prev && handle->page > nr_meta_pages + nr_copy_pages)
784 return 0;
785 if (!buffer) {
786 /* This makes the buffer be freed by swsusp_free() */
787 buffer = alloc_image_page(GFP_ATOMIC, 0);
788 if (!buffer)
789 return -ENOMEM;
790 }
791 if (!handle->offset)
792 handle->buffer = buffer;
793 if (handle->prev < handle->page) {
794 if (!handle->prev) {
795 error = load_header(handle, (struct swsusp_info *)buffer);
796 if (error)
797 return error;
798 } else if (handle->prev <= nr_meta_pages) {
799 handle->pbe = unpack_orig_addresses(buffer, handle->pbe);
800 if (!handle->pbe) {
801 error = create_image(handle);
802 if (error)
803 return error;
804 handle->pbe = pagedir_nosave;
805 handle->buffer = (void *)handle->pbe->address;
806 }
807 } else {
808 handle->pbe = handle->pbe->next;
809 handle->buffer = (void *)handle->pbe->address;
810 }
811 handle->prev = handle->page;
812 }
813 handle->buf_offset = handle->page_offset;
814 if (handle->page_offset + count >= PAGE_SIZE) {
815 count = PAGE_SIZE - handle->page_offset;
816 handle->page_offset = 0;
817 handle->page++;
818 } else {
819 handle->page_offset += count;
820 }
821 handle->offset += count;
822 return count;
823}
824
825int snapshot_image_loaded(struct snapshot_handle *handle)
826{
827 return !(!handle->pbe || handle->pbe->next || !nr_copy_pages ||
828 handle->page <= nr_meta_pages + nr_copy_pages);
829}
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
new file mode 100644
index 000000000000..9177f3f73a6c
--- /dev/null
+++ b/kernel/power/swap.c
@@ -0,0 +1,544 @@
1/*
2 * linux/kernel/power/swap.c
3 *
4 * This file provides functions for reading the suspend image from
5 * and writing it to a swap partition.
6 *
7 * Copyright (C) 1998,2001-2005 Pavel Machek <pavel@suse.cz>
8 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
9 *
10 * This file is released under the GPLv2.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/smp_lock.h>
16#include <linux/file.h>
17#include <linux/utsname.h>
18#include <linux/version.h>
19#include <linux/delay.h>
20#include <linux/bitops.h>
21#include <linux/genhd.h>
22#include <linux/device.h>
23#include <linux/buffer_head.h>
24#include <linux/bio.h>
25#include <linux/swap.h>
26#include <linux/swapops.h>
27#include <linux/pm.h>
28
29#include "power.h"
30
31extern char resume_file[];
32
33#define SWSUSP_SIG "S1SUSPEND"
34
35static struct swsusp_header {
36 char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
37 swp_entry_t image;
38 char orig_sig[10];
39 char sig[10];
40} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
41
42/*
43 * Saving part...
44 */
45
46static unsigned short root_swap = 0xffff;
47
48static int mark_swapfiles(swp_entry_t start)
49{
50 int error;
51
52 rw_swap_page_sync(READ,
53 swp_entry(root_swap, 0),
54 virt_to_page((unsigned long)&swsusp_header));
55 if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
56 !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
57 memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
58 memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
59 swsusp_header.image = start;
60 error = rw_swap_page_sync(WRITE,
61 swp_entry(root_swap, 0),
62 virt_to_page((unsigned long)
63 &swsusp_header));
64 } else {
65 pr_debug("swsusp: Partition is not swap space.\n");
66 error = -ENODEV;
67 }
68 return error;
69}
70
71/**
72 * swsusp_swap_check - check if the resume device is a swap device
73 * and get its index (if so)
74 */
75
76static int swsusp_swap_check(void) /* This is called before saving image */
77{
78 int res = swap_type_of(swsusp_resume_device);
79
80 if (res >= 0) {
81 root_swap = res;
82 return 0;
83 }
84 return res;
85}
86
87/**
88 * write_page - Write one page to given swap location.
89 * @buf: Address we're writing.
90 * @offset: Offset of the swap page we're writing to.
91 */
92
93static int write_page(void *buf, unsigned long offset)
94{
95 swp_entry_t entry;
96 int error = -ENOSPC;
97
98 if (offset) {
99 entry = swp_entry(root_swap, offset);
100 error = rw_swap_page_sync(WRITE, entry, virt_to_page(buf));
101 }
102 return error;
103}
104
105/*
106 * The swap map is a data structure used for keeping track of each page
107 * written to a swap partition. It consists of many swap_map_page
108 * structures that contain each an array of MAP_PAGE_SIZE swap entries.
109 * These structures are stored on the swap and linked together with the
110 * help of the .next_swap member.
111 *
112 * The swap map is created during suspend. The swap map pages are
113 * allocated and populated one at a time, so we only need one memory
114 * page to set up the entire structure.
115 *
116 * During resume we also only need to use one swap_map_page structure
117 * at a time.
118 */
119
120#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(long) - 1)
121
122struct swap_map_page {
123 unsigned long entries[MAP_PAGE_ENTRIES];
124 unsigned long next_swap;
125};
126
127/**
128 * The swap_map_handle structure is used for handling swap in
129 * a file-alike way
130 */
131
132struct swap_map_handle {
133 struct swap_map_page *cur;
134 unsigned long cur_swap;
135 struct bitmap_page *bitmap;
136 unsigned int k;
137};
138
139static void release_swap_writer(struct swap_map_handle *handle)
140{
141 if (handle->cur)
142 free_page((unsigned long)handle->cur);
143 handle->cur = NULL;
144 if (handle->bitmap)
145 free_bitmap(handle->bitmap);
146 handle->bitmap = NULL;
147}
148
149static int get_swap_writer(struct swap_map_handle *handle)
150{
151 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
152 if (!handle->cur)
153 return -ENOMEM;
154 handle->bitmap = alloc_bitmap(count_swap_pages(root_swap, 0));
155 if (!handle->bitmap) {
156 release_swap_writer(handle);
157 return -ENOMEM;
158 }
159 handle->cur_swap = alloc_swap_page(root_swap, handle->bitmap);
160 if (!handle->cur_swap) {
161 release_swap_writer(handle);
162 return -ENOSPC;
163 }
164 handle->k = 0;
165 return 0;
166}
167
168static int swap_write_page(struct swap_map_handle *handle, void *buf)
169{
170 int error;
171 unsigned long offset;
172
173 if (!handle->cur)
174 return -EINVAL;
175 offset = alloc_swap_page(root_swap, handle->bitmap);
176 error = write_page(buf, offset);
177 if (error)
178 return error;
179 handle->cur->entries[handle->k++] = offset;
180 if (handle->k >= MAP_PAGE_ENTRIES) {
181 offset = alloc_swap_page(root_swap, handle->bitmap);
182 if (!offset)
183 return -ENOSPC;
184 handle->cur->next_swap = offset;
185 error = write_page(handle->cur, handle->cur_swap);
186 if (error)
187 return error;
188 memset(handle->cur, 0, PAGE_SIZE);
189 handle->cur_swap = offset;
190 handle->k = 0;
191 }
192 return 0;
193}
194
195static int flush_swap_writer(struct swap_map_handle *handle)
196{
197 if (handle->cur && handle->cur_swap)
198 return write_page(handle->cur, handle->cur_swap);
199 else
200 return -EINVAL;
201}
202
203/**
204 * save_image - save the suspend image data
205 */
206
207static int save_image(struct swap_map_handle *handle,
208 struct snapshot_handle *snapshot,
209 unsigned int nr_pages)
210{
211 unsigned int m;
212 int ret;
213 int error = 0;
214
215 printk("Saving image data pages (%u pages) ... ", nr_pages);
216 m = nr_pages / 100;
217 if (!m)
218 m = 1;
219 nr_pages = 0;
220 do {
221 ret = snapshot_read_next(snapshot, PAGE_SIZE);
222 if (ret > 0) {
223 error = swap_write_page(handle, data_of(*snapshot));
224 if (error)
225 break;
226 if (!(nr_pages % m))
227 printk("\b\b\b\b%3d%%", nr_pages / m);
228 nr_pages++;
229 }
230 } while (ret > 0);
231 if (!error)
232 printk("\b\b\b\bdone\n");
233 return error;
234}
235
236/**
237 * enough_swap - Make sure we have enough swap to save the image.
238 *
239 * Returns TRUE or FALSE after checking the total amount of swap
240 * space avaiable from the resume partition.
241 */
242
243static int enough_swap(unsigned int nr_pages)
244{
245 unsigned int free_swap = count_swap_pages(root_swap, 1);
246
247 pr_debug("swsusp: free swap pages: %u\n", free_swap);
248 return free_swap > (nr_pages + PAGES_FOR_IO +
249 (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
250}
251
252/**
253 * swsusp_write - Write entire image and metadata.
254 *
255 * It is important _NOT_ to umount filesystems at this point. We want
256 * them synced (in case something goes wrong) but we DO not want to mark
257 * filesystem clean: it is not. (And it does not matter, if we resume
258 * correctly, we'll mark system clean, anyway.)
259 */
260
261int swsusp_write(void)
262{
263 struct swap_map_handle handle;
264 struct snapshot_handle snapshot;
265 struct swsusp_info *header;
266 unsigned long start;
267 int error;
268
269 if ((error = swsusp_swap_check())) {
270 printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n");
271 return error;
272 }
273 memset(&snapshot, 0, sizeof(struct snapshot_handle));
274 error = snapshot_read_next(&snapshot, PAGE_SIZE);
275 if (error < PAGE_SIZE)
276 return error < 0 ? error : -EFAULT;
277 header = (struct swsusp_info *)data_of(snapshot);
278 if (!enough_swap(header->pages)) {
279 printk(KERN_ERR "swsusp: Not enough free swap\n");
280 return -ENOSPC;
281 }
282 error = get_swap_writer(&handle);
283 if (!error) {
284 start = handle.cur_swap;
285 error = swap_write_page(&handle, header);
286 }
287 if (!error)
288 error = save_image(&handle, &snapshot, header->pages - 1);
289 if (!error) {
290 flush_swap_writer(&handle);
291 printk("S");
292 error = mark_swapfiles(swp_entry(root_swap, start));
293 printk("|\n");
294 }
295 if (error)
296 free_all_swap_pages(root_swap, handle.bitmap);
297 release_swap_writer(&handle);
298 return error;
299}
300
301/*
302 * Using bio to read from swap.
303 * This code requires a bit more work than just using buffer heads
304 * but, it is the recommended way for 2.5/2.6.
305 * The following are to signal the beginning and end of I/O. Bios
306 * finish asynchronously, while we want them to happen synchronously.
307 * A simple atomic_t, and a wait loop take care of this problem.
308 */
309
310static atomic_t io_done = ATOMIC_INIT(0);
311
312static int end_io(struct bio *bio, unsigned int num, int err)
313{
314 if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
315 panic("I/O error reading memory image");
316 atomic_set(&io_done, 0);
317 return 0;
318}
319
320static struct block_device *resume_bdev;
321
322/**
323 * submit - submit BIO request.
324 * @rw: READ or WRITE.
325 * @off physical offset of page.
326 * @page: page we're reading or writing.
327 *
328 * Straight from the textbook - allocate and initialize the bio.
329 * If we're writing, make sure the page is marked as dirty.
330 * Then submit it and wait.
331 */
332
333static int submit(int rw, pgoff_t page_off, void *page)
334{
335 int error = 0;
336 struct bio *bio;
337
338 bio = bio_alloc(GFP_ATOMIC, 1);
339 if (!bio)
340 return -ENOMEM;
341 bio->bi_sector = page_off * (PAGE_SIZE >> 9);
342 bio->bi_bdev = resume_bdev;
343 bio->bi_end_io = end_io;
344
345 if (bio_add_page(bio, virt_to_page(page), PAGE_SIZE, 0) < PAGE_SIZE) {
346 printk("swsusp: ERROR: adding page to bio at %ld\n",page_off);
347 error = -EFAULT;
348 goto Done;
349 }
350
351 atomic_set(&io_done, 1);
352 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
353 while (atomic_read(&io_done))
354 yield();
355 if (rw == READ)
356 bio_set_pages_dirty(bio);
357 Done:
358 bio_put(bio);
359 return error;
360}
361
362static int bio_read_page(pgoff_t page_off, void *page)
363{
364 return submit(READ, page_off, page);
365}
366
367static int bio_write_page(pgoff_t page_off, void *page)
368{
369 return submit(WRITE, page_off, page);
370}
371
372/**
373 * The following functions allow us to read data using a swap map
374 * in a file-alike way
375 */
376
377static void release_swap_reader(struct swap_map_handle *handle)
378{
379 if (handle->cur)
380 free_page((unsigned long)handle->cur);
381 handle->cur = NULL;
382}
383
384static int get_swap_reader(struct swap_map_handle *handle,
385 swp_entry_t start)
386{
387 int error;
388
389 if (!swp_offset(start))
390 return -EINVAL;
391 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
392 if (!handle->cur)
393 return -ENOMEM;
394 error = bio_read_page(swp_offset(start), handle->cur);
395 if (error) {
396 release_swap_reader(handle);
397 return error;
398 }
399 handle->k = 0;
400 return 0;
401}
402
403static int swap_read_page(struct swap_map_handle *handle, void *buf)
404{
405 unsigned long offset;
406 int error;
407
408 if (!handle->cur)
409 return -EINVAL;
410 offset = handle->cur->entries[handle->k];
411 if (!offset)
412 return -EFAULT;
413 error = bio_read_page(offset, buf);
414 if (error)
415 return error;
416 if (++handle->k >= MAP_PAGE_ENTRIES) {
417 handle->k = 0;
418 offset = handle->cur->next_swap;
419 if (!offset)
420 release_swap_reader(handle);
421 else
422 error = bio_read_page(offset, handle->cur);
423 }
424 return error;
425}
426
427/**
428 * load_image - load the image using the swap map handle
429 * @handle and the snapshot handle @snapshot
430 * (assume there are @nr_pages pages to load)
431 */
432
433static int load_image(struct swap_map_handle *handle,
434 struct snapshot_handle *snapshot,
435 unsigned int nr_pages)
436{
437 unsigned int m;
438 int ret;
439 int error = 0;
440
441 printk("Loading image data pages (%u pages) ... ", nr_pages);
442 m = nr_pages / 100;
443 if (!m)
444 m = 1;
445 nr_pages = 0;
446 do {
447 ret = snapshot_write_next(snapshot, PAGE_SIZE);
448 if (ret > 0) {
449 error = swap_read_page(handle, data_of(*snapshot));
450 if (error)
451 break;
452 if (!(nr_pages % m))
453 printk("\b\b\b\b%3d%%", nr_pages / m);
454 nr_pages++;
455 }
456 } while (ret > 0);
457 if (!error)
458 printk("\b\b\b\bdone\n");
459 if (!snapshot_image_loaded(snapshot))
460 error = -ENODATA;
461 return error;
462}
463
464int swsusp_read(void)
465{
466 int error;
467 struct swap_map_handle handle;
468 struct snapshot_handle snapshot;
469 struct swsusp_info *header;
470
471 if (IS_ERR(resume_bdev)) {
472 pr_debug("swsusp: block device not initialised\n");
473 return PTR_ERR(resume_bdev);
474 }
475
476 memset(&snapshot, 0, sizeof(struct snapshot_handle));
477 error = snapshot_write_next(&snapshot, PAGE_SIZE);
478 if (error < PAGE_SIZE)
479 return error < 0 ? error : -EFAULT;
480 header = (struct swsusp_info *)data_of(snapshot);
481 error = get_swap_reader(&handle, swsusp_header.image);
482 if (!error)
483 error = swap_read_page(&handle, header);
484 if (!error)
485 error = load_image(&handle, &snapshot, header->pages - 1);
486 release_swap_reader(&handle);
487
488 blkdev_put(resume_bdev);
489
490 if (!error)
491 pr_debug("swsusp: Reading resume file was successful\n");
492 else
493 pr_debug("swsusp: Error %d resuming\n", error);
494 return error;
495}
496
497/**
498 * swsusp_check - Check for swsusp signature in the resume device
499 */
500
501int swsusp_check(void)
502{
503 int error;
504
505 resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
506 if (!IS_ERR(resume_bdev)) {
507 set_blocksize(resume_bdev, PAGE_SIZE);
508 memset(&swsusp_header, 0, sizeof(swsusp_header));
509 if ((error = bio_read_page(0, &swsusp_header)))
510 return error;
511 if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
512 memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
513 /* Reset swap signature now */
514 error = bio_write_page(0, &swsusp_header);
515 } else {
516 return -EINVAL;
517 }
518 if (error)
519 blkdev_put(resume_bdev);
520 else
521 pr_debug("swsusp: Signature found, resuming\n");
522 } else {
523 error = PTR_ERR(resume_bdev);
524 }
525
526 if (error)
527 pr_debug("swsusp: Error %d check for resume file\n", error);
528
529 return error;
530}
531
532/**
533 * swsusp_close - close swap device.
534 */
535
536void swsusp_close(void)
537{
538 if (IS_ERR(resume_bdev)) {
539 pr_debug("swsusp: block device not initialised\n");
540 return;
541 }
542
543 blkdev_put(resume_bdev);
544}
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 2d9d08f72f76..c4016cbbd3e0 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -31,41 +31,24 @@
31 * Fixed runaway init 31 * Fixed runaway init
32 * 32 *
33 * Rafael J. Wysocki <rjw@sisk.pl> 33 * Rafael J. Wysocki <rjw@sisk.pl>
34 * Added the swap map data structure and reworked the handling of swap 34 * Reworked the freeing of memory and the handling of swap
35 * 35 *
36 * More state savers are welcome. Especially for the scsi layer... 36 * More state savers are welcome. Especially for the scsi layer...
37 * 37 *
38 * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt 38 * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt
39 */ 39 */
40 40
41#include <linux/module.h>
42#include <linux/mm.h> 41#include <linux/mm.h>
43#include <linux/suspend.h> 42#include <linux/suspend.h>
44#include <linux/smp_lock.h>
45#include <linux/file.h>
46#include <linux/utsname.h>
47#include <linux/version.h>
48#include <linux/delay.h>
49#include <linux/bitops.h>
50#include <linux/spinlock.h> 43#include <linux/spinlock.h>
51#include <linux/genhd.h>
52#include <linux/kernel.h> 44#include <linux/kernel.h>
53#include <linux/major.h> 45#include <linux/major.h>
54#include <linux/swap.h> 46#include <linux/swap.h>
55#include <linux/pm.h> 47#include <linux/pm.h>
56#include <linux/device.h>
57#include <linux/buffer_head.h>
58#include <linux/swapops.h> 48#include <linux/swapops.h>
59#include <linux/bootmem.h> 49#include <linux/bootmem.h>
60#include <linux/syscalls.h> 50#include <linux/syscalls.h>
61#include <linux/highmem.h> 51#include <linux/highmem.h>
62#include <linux/bio.h>
63
64#include <asm/uaccess.h>
65#include <asm/mmu_context.h>
66#include <asm/pgtable.h>
67#include <asm/tlbflush.h>
68#include <asm/io.h>
69 52
70#include "power.h" 53#include "power.h"
71 54
@@ -77,6 +60,8 @@
77 */ 60 */
78unsigned long image_size = 500 * 1024 * 1024; 61unsigned long image_size = 500 * 1024 * 1024;
79 62
63int in_suspend __nosavedata = 0;
64
80#ifdef CONFIG_HIGHMEM 65#ifdef CONFIG_HIGHMEM
81unsigned int count_highmem_pages(void); 66unsigned int count_highmem_pages(void);
82int save_highmem(void); 67int save_highmem(void);
@@ -87,471 +72,97 @@ static int restore_highmem(void) { return 0; }
87static unsigned int count_highmem_pages(void) { return 0; } 72static unsigned int count_highmem_pages(void) { return 0; }
88#endif 73#endif
89 74
90extern char resume_file[];
91
92#define SWSUSP_SIG "S1SUSPEND"
93
94static struct swsusp_header {
95 char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
96 swp_entry_t image;
97 char orig_sig[10];
98 char sig[10];
99} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
100
101static struct swsusp_info swsusp_info;
102
103/*
104 * Saving part...
105 */
106
107static unsigned short root_swap = 0xffff;
108
109static int mark_swapfiles(swp_entry_t start)
110{
111 int error;
112
113 rw_swap_page_sync(READ,
114 swp_entry(root_swap, 0),
115 virt_to_page((unsigned long)&swsusp_header));
116 if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
117 !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
118 memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
119 memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
120 swsusp_header.image = start;
121 error = rw_swap_page_sync(WRITE,
122 swp_entry(root_swap, 0),
123 virt_to_page((unsigned long)
124 &swsusp_header));
125 } else {
126 pr_debug("swsusp: Partition is not swap space.\n");
127 error = -ENODEV;
128 }
129 return error;
130}
131
132/*
133 * Check whether the swap device is the specified resume
134 * device, irrespective of whether they are specified by
135 * identical names.
136 *
137 * (Thus, device inode aliasing is allowed. You can say /dev/hda4
138 * instead of /dev/ide/host0/bus0/target0/lun0/part4 [if using devfs]
139 * and they'll be considered the same device. This is *necessary* for
140 * devfs, since the resume code can only recognize the form /dev/hda4,
141 * but the suspend code would see the long name.)
142 */
143static inline int is_resume_device(const struct swap_info_struct *swap_info)
144{
145 struct file *file = swap_info->swap_file;
146 struct inode *inode = file->f_dentry->d_inode;
147
148 return S_ISBLK(inode->i_mode) &&
149 swsusp_resume_device == MKDEV(imajor(inode), iminor(inode));
150}
151
152static int swsusp_swap_check(void) /* This is called before saving image */
153{
154 int i;
155
156 spin_lock(&swap_lock);
157 for (i = 0; i < MAX_SWAPFILES; i++) {
158 if (!(swap_info[i].flags & SWP_WRITEOK))
159 continue;
160 if (!swsusp_resume_device || is_resume_device(swap_info + i)) {
161 spin_unlock(&swap_lock);
162 root_swap = i;
163 return 0;
164 }
165 }
166 spin_unlock(&swap_lock);
167 return -ENODEV;
168}
169
170/**
171 * write_page - Write one page to a fresh swap location.
172 * @addr: Address we're writing.
173 * @loc: Place to store the entry we used.
174 *
175 * Allocate a new swap entry and 'sync' it. Note we discard -EIO
176 * errors. That is an artifact left over from swsusp. It did not
177 * check the return of rw_swap_page_sync() at all, since most pages
178 * written back to swap would return -EIO.
179 * This is a partial improvement, since we will at least return other
180 * errors, though we need to eventually fix the damn code.
181 */
182static int write_page(unsigned long addr, swp_entry_t *loc)
183{
184 swp_entry_t entry;
185 int error = -ENOSPC;
186
187 entry = get_swap_page_of_type(root_swap);
188 if (swp_offset(entry)) {
189 error = rw_swap_page_sync(WRITE, entry, virt_to_page(addr));
190 if (!error || error == -EIO)
191 *loc = entry;
192 }
193 return error;
194}
195
196/** 75/**
197 * Swap map-handling functions 76 * The following functions are used for tracing the allocated
198 * 77 * swap pages, so that they can be freed in case of an error.
199 * The swap map is a data structure used for keeping track of each page
200 * written to the swap. It consists of many swap_map_page structures
201 * that contain each an array of MAP_PAGE_SIZE swap entries.
202 * These structures are linked together with the help of either the
203 * .next (in memory) or the .next_swap (in swap) member.
204 * 78 *
205 * The swap map is created during suspend. At that time we need to keep 79 * The functions operate on a linked bitmap structure defined
206 * it in memory, because we have to free all of the allocated swap 80 * in power.h
207 * entries if an error occurs. The memory needed is preallocated
208 * so that we know in advance if there's enough of it.
209 *
210 * The first swap_map_page structure is filled with the swap entries that
211 * correspond to the first MAP_PAGE_SIZE data pages written to swap and
212 * so on. After the all of the data pages have been written, the order
213 * of the swap_map_page structures in the map is reversed so that they
214 * can be read from swap in the original order. This causes the data
215 * pages to be loaded in exactly the same order in which they have been
216 * saved.
217 *
218 * During resume we only need to use one swap_map_page structure
219 * at a time, which means that we only need to use two memory pages for
220 * reading the image - one for reading the swap_map_page structures
221 * and the second for reading the data pages from swap.
222 */ 81 */
223 82
224#define MAP_PAGE_SIZE ((PAGE_SIZE - sizeof(swp_entry_t) - sizeof(void *)) \ 83void free_bitmap(struct bitmap_page *bitmap)
225 / sizeof(swp_entry_t))
226
227struct swap_map_page {
228 swp_entry_t entries[MAP_PAGE_SIZE];
229 swp_entry_t next_swap;
230 struct swap_map_page *next;
231};
232
233static inline void free_swap_map(struct swap_map_page *swap_map)
234{ 84{
235 struct swap_map_page *swp; 85 struct bitmap_page *bp;
236 86
237 while (swap_map) { 87 while (bitmap) {
238 swp = swap_map->next; 88 bp = bitmap->next;
239 free_page((unsigned long)swap_map); 89 free_page((unsigned long)bitmap);
240 swap_map = swp; 90 bitmap = bp;
241 } 91 }
242} 92}
243 93
244static struct swap_map_page *alloc_swap_map(unsigned int nr_pages) 94struct bitmap_page *alloc_bitmap(unsigned int nr_bits)
245{ 95{
246 struct swap_map_page *swap_map, *swp; 96 struct bitmap_page *bitmap, *bp;
247 unsigned n = 0; 97 unsigned int n;
248 98
249 if (!nr_pages) 99 if (!nr_bits)
250 return NULL; 100 return NULL;
251 101
252 pr_debug("alloc_swap_map(): nr_pages = %d\n", nr_pages); 102 bitmap = (struct bitmap_page *)get_zeroed_page(GFP_KERNEL);
253 swap_map = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); 103 bp = bitmap;
254 swp = swap_map; 104 for (n = BITMAP_PAGE_BITS; n < nr_bits; n += BITMAP_PAGE_BITS) {
255 for (n = MAP_PAGE_SIZE; n < nr_pages; n += MAP_PAGE_SIZE) { 105 bp->next = (struct bitmap_page *)get_zeroed_page(GFP_KERNEL);
256 swp->next = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); 106 bp = bp->next;
257 swp = swp->next; 107 if (!bp) {
258 if (!swp) { 108 free_bitmap(bitmap);
259 free_swap_map(swap_map);
260 return NULL; 109 return NULL;
261 } 110 }
262 } 111 }
263 return swap_map; 112 return bitmap;
264} 113}
265 114
266/** 115static int bitmap_set(struct bitmap_page *bitmap, unsigned long bit)
267 * reverse_swap_map - reverse the order of pages in the swap map
268 * @swap_map
269 */
270
271static inline struct swap_map_page *reverse_swap_map(struct swap_map_page *swap_map)
272{
273 struct swap_map_page *prev, *next;
274
275 prev = NULL;
276 while (swap_map) {
277 next = swap_map->next;
278 swap_map->next = prev;
279 prev = swap_map;
280 swap_map = next;
281 }
282 return prev;
283}
284
285/**
286 * free_swap_map_entries - free the swap entries allocated to store
287 * the swap map @swap_map (this is only called in case of an error)
288 */
289static inline void free_swap_map_entries(struct swap_map_page *swap_map)
290{
291 while (swap_map) {
292 if (swap_map->next_swap.val)
293 swap_free(swap_map->next_swap);
294 swap_map = swap_map->next;
295 }
296}
297
298/**
299 * save_swap_map - save the swap map used for tracing the data pages
300 * stored in the swap
301 */
302
303static int save_swap_map(struct swap_map_page *swap_map, swp_entry_t *start)
304{
305 swp_entry_t entry = (swp_entry_t){0};
306 int error;
307
308 while (swap_map) {
309 swap_map->next_swap = entry;
310 if ((error = write_page((unsigned long)swap_map, &entry)))
311 return error;
312 swap_map = swap_map->next;
313 }
314 *start = entry;
315 return 0;
316}
317
318/**
319 * free_image_entries - free the swap entries allocated to store
320 * the image data pages (this is only called in case of an error)
321 */
322
323static inline void free_image_entries(struct swap_map_page *swp)
324{ 116{
325 unsigned k; 117 unsigned int n;
326 118
327 while (swp) { 119 n = BITMAP_PAGE_BITS;
328 for (k = 0; k < MAP_PAGE_SIZE; k++) 120 while (bitmap && n <= bit) {
329 if (swp->entries[k].val) 121 n += BITMAP_PAGE_BITS;
330 swap_free(swp->entries[k]); 122 bitmap = bitmap->next;
331 swp = swp->next;
332 } 123 }
333} 124 if (!bitmap)
334 125 return -EINVAL;
335/** 126 n -= BITMAP_PAGE_BITS;
336 * The swap_map_handle structure is used for handling the swap map in 127 bit -= n;
337 * a file-alike way 128 n = 0;
338 */ 129 while (bit >= BITS_PER_CHUNK) {
339 130 bit -= BITS_PER_CHUNK;
340struct swap_map_handle { 131 n++;
341 struct swap_map_page *cur;
342 unsigned int k;
343};
344
345static inline void init_swap_map_handle(struct swap_map_handle *handle,
346 struct swap_map_page *map)
347{
348 handle->cur = map;
349 handle->k = 0;
350}
351
352static inline int swap_map_write_page(struct swap_map_handle *handle,
353 unsigned long addr)
354{
355 int error;
356
357 error = write_page(addr, handle->cur->entries + handle->k);
358 if (error)
359 return error;
360 if (++handle->k >= MAP_PAGE_SIZE) {
361 handle->cur = handle->cur->next;
362 handle->k = 0;
363 } 132 }
133 bitmap->chunks[n] |= (1UL << bit);
364 return 0; 134 return 0;
365} 135}
366 136
367/** 137unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap)
368 * save_image_data - save the data pages pointed to by the PBEs
369 * from the list @pblist using the swap map handle @handle
370 * (assume there are @nr_pages data pages to save)
371 */
372
373static int save_image_data(struct pbe *pblist,
374 struct swap_map_handle *handle,
375 unsigned int nr_pages)
376{
377 unsigned int m;
378 struct pbe *p;
379 int error = 0;
380
381 printk("Saving image data pages (%u pages) ... ", nr_pages);
382 m = nr_pages / 100;
383 if (!m)
384 m = 1;
385 nr_pages = 0;
386 for_each_pbe (p, pblist) {
387 error = swap_map_write_page(handle, p->address);
388 if (error)
389 break;
390 if (!(nr_pages % m))
391 printk("\b\b\b\b%3d%%", nr_pages / m);
392 nr_pages++;
393 }
394 if (!error)
395 printk("\b\b\b\bdone\n");
396 return error;
397}
398
399static void dump_info(void)
400{
401 pr_debug(" swsusp: Version: %u\n",swsusp_info.version_code);
402 pr_debug(" swsusp: Num Pages: %ld\n",swsusp_info.num_physpages);
403 pr_debug(" swsusp: UTS Sys: %s\n",swsusp_info.uts.sysname);
404 pr_debug(" swsusp: UTS Node: %s\n",swsusp_info.uts.nodename);
405 pr_debug(" swsusp: UTS Release: %s\n",swsusp_info.uts.release);
406 pr_debug(" swsusp: UTS Version: %s\n",swsusp_info.uts.version);
407 pr_debug(" swsusp: UTS Machine: %s\n",swsusp_info.uts.machine);
408 pr_debug(" swsusp: UTS Domain: %s\n",swsusp_info.uts.domainname);
409 pr_debug(" swsusp: CPUs: %d\n",swsusp_info.cpus);
410 pr_debug(" swsusp: Image: %ld Pages\n",swsusp_info.image_pages);
411 pr_debug(" swsusp: Total: %ld Pages\n", swsusp_info.pages);
412}
413
414static void init_header(unsigned int nr_pages)
415{
416 memset(&swsusp_info, 0, sizeof(swsusp_info));
417 swsusp_info.version_code = LINUX_VERSION_CODE;
418 swsusp_info.num_physpages = num_physpages;
419 memcpy(&swsusp_info.uts, &system_utsname, sizeof(system_utsname));
420
421 swsusp_info.cpus = num_online_cpus();
422 swsusp_info.image_pages = nr_pages;
423 swsusp_info.pages = nr_pages +
424 ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
425}
426
427/**
428 * pack_orig_addresses - the .orig_address fields of the PBEs from the
429 * list starting at @pbe are stored in the array @buf[] (1 page)
430 */
431
432static inline struct pbe *pack_orig_addresses(unsigned long *buf,
433 struct pbe *pbe)
434{
435 int j;
436
437 for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
438 buf[j] = pbe->orig_address;
439 pbe = pbe->next;
440 }
441 if (!pbe)
442 for (; j < PAGE_SIZE / sizeof(long); j++)
443 buf[j] = 0;
444 return pbe;
445}
446
447/**
448 * save_image_metadata - save the .orig_address fields of the PBEs
449 * from the list @pblist using the swap map handle @handle
450 */
451
452static int save_image_metadata(struct pbe *pblist,
453 struct swap_map_handle *handle)
454{ 138{
455 unsigned long *buf; 139 unsigned long offset;
456 unsigned int n = 0;
457 struct pbe *p;
458 int error = 0;
459 140
460 printk("Saving image metadata ... "); 141 offset = swp_offset(get_swap_page_of_type(swap));
461 buf = (unsigned long *)get_zeroed_page(GFP_ATOMIC); 142 if (offset) {
462 if (!buf) 143 if (bitmap_set(bitmap, offset)) {
463 return -ENOMEM; 144 swap_free(swp_entry(swap, offset));
464 p = pblist; 145 offset = 0;
465 while (p) { 146 }
466 p = pack_orig_addresses(buf, p);
467 error = swap_map_write_page(handle, (unsigned long)buf);
468 if (error)
469 break;
470 n++;
471 } 147 }
472 free_page((unsigned long)buf); 148 return offset;
473 if (!error)
474 printk("done (%u pages saved)\n", n);
475 return error;
476} 149}
477 150
478/** 151void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
479 * enough_swap - Make sure we have enough swap to save the image.
480 *
481 * Returns TRUE or FALSE after checking the total amount of swap
482 * space avaiable from the resume partition.
483 */
484
485static int enough_swap(unsigned int nr_pages)
486{ 152{
487 unsigned int free_swap = swap_info[root_swap].pages - 153 unsigned int bit, n;
488 swap_info[root_swap].inuse_pages; 154 unsigned long test;
489
490 pr_debug("swsusp: free swap pages: %u\n", free_swap);
491 return free_swap > (nr_pages + PAGES_FOR_IO +
492 (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
493}
494 155
495/** 156 bit = 0;
496 * swsusp_write - Write entire image and metadata. 157 while (bitmap) {
497 * 158 for (n = 0; n < BITMAP_PAGE_CHUNKS; n++)
498 * It is important _NOT_ to umount filesystems at this point. We want 159 for (test = 1UL; test; test <<= 1) {
499 * them synced (in case something goes wrong) but we DO not want to mark 160 if (bitmap->chunks[n] & test)
500 * filesystem clean: it is not. (And it does not matter, if we resume 161 swap_free(swp_entry(swap, bit));
501 * correctly, we'll mark system clean, anyway.) 162 bit++;
502 */ 163 }
503 164 bitmap = bitmap->next;
504int swsusp_write(struct pbe *pblist, unsigned int nr_pages)
505{
506 struct swap_map_page *swap_map;
507 struct swap_map_handle handle;
508 swp_entry_t start;
509 int error;
510
511 if ((error = swsusp_swap_check())) {
512 printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n");
513 return error;
514 }
515 if (!enough_swap(nr_pages)) {
516 printk(KERN_ERR "swsusp: Not enough free swap\n");
517 return -ENOSPC;
518 } 165 }
519
520 init_header(nr_pages);
521 swap_map = alloc_swap_map(swsusp_info.pages);
522 if (!swap_map)
523 return -ENOMEM;
524 init_swap_map_handle(&handle, swap_map);
525
526 error = swap_map_write_page(&handle, (unsigned long)&swsusp_info);
527 if (!error)
528 error = save_image_metadata(pblist, &handle);
529 if (!error)
530 error = save_image_data(pblist, &handle, nr_pages);
531 if (error)
532 goto Free_image_entries;
533
534 swap_map = reverse_swap_map(swap_map);
535 error = save_swap_map(swap_map, &start);
536 if (error)
537 goto Free_map_entries;
538
539 dump_info();
540 printk( "S" );
541 error = mark_swapfiles(start);
542 printk( "|\n" );
543 if (error)
544 goto Free_map_entries;
545
546Free_swap_map:
547 free_swap_map(swap_map);
548 return error;
549
550Free_map_entries:
551 free_swap_map_entries(swap_map);
552Free_image_entries:
553 free_image_entries(swap_map);
554 goto Free_swap_map;
555} 166}
556 167
557/** 168/**
@@ -660,379 +271,3 @@ int swsusp_resume(void)
660 local_irq_enable(); 271 local_irq_enable();
661 return error; 272 return error;
662} 273}
663
664/**
665 * mark_unsafe_pages - mark the pages that cannot be used for storing
666 * the image during resume, because they conflict with the pages that
667 * had been used before suspend
668 */
669
670static void mark_unsafe_pages(struct pbe *pblist)
671{
672 struct zone *zone;
673 unsigned long zone_pfn;
674 struct pbe *p;
675
676 if (!pblist) /* a sanity check */
677 return;
678
679 /* Clear page flags */
680 for_each_zone (zone) {
681 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
682 if (pfn_valid(zone_pfn + zone->zone_start_pfn))
683 ClearPageNosaveFree(pfn_to_page(zone_pfn +
684 zone->zone_start_pfn));
685 }
686
687 /* Mark orig addresses */
688 for_each_pbe (p, pblist)
689 SetPageNosaveFree(virt_to_page(p->orig_address));
690
691}
692
693static void copy_page_backup_list(struct pbe *dst, struct pbe *src)
694{
695 /* We assume both lists contain the same number of elements */
696 while (src) {
697 dst->orig_address = src->orig_address;
698 dst = dst->next;
699 src = src->next;
700 }
701}
702
703/*
704 * Using bio to read from swap.
705 * This code requires a bit more work than just using buffer heads
706 * but, it is the recommended way for 2.5/2.6.
707 * The following are to signal the beginning and end of I/O. Bios
708 * finish asynchronously, while we want them to happen synchronously.
709 * A simple atomic_t, and a wait loop take care of this problem.
710 */
711
712static atomic_t io_done = ATOMIC_INIT(0);
713
714static int end_io(struct bio *bio, unsigned int num, int err)
715{
716 if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
717 panic("I/O error reading memory image");
718 atomic_set(&io_done, 0);
719 return 0;
720}
721
722static struct block_device *resume_bdev;
723
724/**
725 * submit - submit BIO request.
726 * @rw: READ or WRITE.
727 * @off physical offset of page.
728 * @page: page we're reading or writing.
729 *
730 * Straight from the textbook - allocate and initialize the bio.
731 * If we're writing, make sure the page is marked as dirty.
732 * Then submit it and wait.
733 */
734
735static int submit(int rw, pgoff_t page_off, void *page)
736{
737 int error = 0;
738 struct bio *bio;
739
740 bio = bio_alloc(GFP_ATOMIC, 1);
741 if (!bio)
742 return -ENOMEM;
743 bio->bi_sector = page_off * (PAGE_SIZE >> 9);
744 bio->bi_bdev = resume_bdev;
745 bio->bi_end_io = end_io;
746
747 if (bio_add_page(bio, virt_to_page(page), PAGE_SIZE, 0) < PAGE_SIZE) {
748 printk("swsusp: ERROR: adding page to bio at %ld\n",page_off);
749 error = -EFAULT;
750 goto Done;
751 }
752
753
754 atomic_set(&io_done, 1);
755 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
756 while (atomic_read(&io_done))
757 yield();
758 if (rw == READ)
759 bio_set_pages_dirty(bio);
760 Done:
761 bio_put(bio);
762 return error;
763}
764
765static int bio_read_page(pgoff_t page_off, void *page)
766{
767 return submit(READ, page_off, page);
768}
769
770static int bio_write_page(pgoff_t page_off, void *page)
771{
772 return submit(WRITE, page_off, page);
773}
774
775/**
776 * The following functions allow us to read data using a swap map
777 * in a file-alike way
778 */
779
780static inline void release_swap_map_reader(struct swap_map_handle *handle)
781{
782 if (handle->cur)
783 free_page((unsigned long)handle->cur);
784 handle->cur = NULL;
785}
786
787static inline int get_swap_map_reader(struct swap_map_handle *handle,
788 swp_entry_t start)
789{
790 int error;
791
792 if (!swp_offset(start))
793 return -EINVAL;
794 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
795 if (!handle->cur)
796 return -ENOMEM;
797 error = bio_read_page(swp_offset(start), handle->cur);
798 if (error) {
799 release_swap_map_reader(handle);
800 return error;
801 }
802 handle->k = 0;
803 return 0;
804}
805
806static inline int swap_map_read_page(struct swap_map_handle *handle, void *buf)
807{
808 unsigned long offset;
809 int error;
810
811 if (!handle->cur)
812 return -EINVAL;
813 offset = swp_offset(handle->cur->entries[handle->k]);
814 if (!offset)
815 return -EINVAL;
816 error = bio_read_page(offset, buf);
817 if (error)
818 return error;
819 if (++handle->k >= MAP_PAGE_SIZE) {
820 handle->k = 0;
821 offset = swp_offset(handle->cur->next_swap);
822 if (!offset)
823 release_swap_map_reader(handle);
824 else
825 error = bio_read_page(offset, handle->cur);
826 }
827 return error;
828}
829
830static int check_header(void)
831{
832 char *reason = NULL;
833
834 dump_info();
835 if (swsusp_info.version_code != LINUX_VERSION_CODE)
836 reason = "kernel version";
837 if (swsusp_info.num_physpages != num_physpages)
838 reason = "memory size";
839 if (strcmp(swsusp_info.uts.sysname,system_utsname.sysname))
840 reason = "system type";
841 if (strcmp(swsusp_info.uts.release,system_utsname.release))
842 reason = "kernel release";
843 if (strcmp(swsusp_info.uts.version,system_utsname.version))
844 reason = "version";
845 if (strcmp(swsusp_info.uts.machine,system_utsname.machine))
846 reason = "machine";
847 if (reason) {
848 printk(KERN_ERR "swsusp: Resume mismatch: %s\n", reason);
849 return -EPERM;
850 }
851 return 0;
852}
853
854/**
855 * load_image_data - load the image data using the swap map handle
856 * @handle and store them using the page backup list @pblist
857 * (assume there are @nr_pages pages to load)
858 */
859
860static int load_image_data(struct pbe *pblist,
861 struct swap_map_handle *handle,
862 unsigned int nr_pages)
863{
864 int error;
865 unsigned int m;
866 struct pbe *p;
867
868 if (!pblist)
869 return -EINVAL;
870 printk("Loading image data pages (%u pages) ... ", nr_pages);
871 m = nr_pages / 100;
872 if (!m)
873 m = 1;
874 nr_pages = 0;
875 p = pblist;
876 while (p) {
877 error = swap_map_read_page(handle, (void *)p->address);
878 if (error)
879 break;
880 p = p->next;
881 if (!(nr_pages % m))
882 printk("\b\b\b\b%3d%%", nr_pages / m);
883 nr_pages++;
884 }
885 if (!error)
886 printk("\b\b\b\bdone\n");
887 return error;
888}
889
890/**
891 * unpack_orig_addresses - copy the elements of @buf[] (1 page) to
892 * the PBEs in the list starting at @pbe
893 */
894
895static inline struct pbe *unpack_orig_addresses(unsigned long *buf,
896 struct pbe *pbe)
897{
898 int j;
899
900 for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
901 pbe->orig_address = buf[j];
902 pbe = pbe->next;
903 }
904 return pbe;
905}
906
907/**
908 * load_image_metadata - load the image metadata using the swap map
909 * handle @handle and put them into the PBEs in the list @pblist
910 */
911
912static int load_image_metadata(struct pbe *pblist, struct swap_map_handle *handle)
913{
914 struct pbe *p;
915 unsigned long *buf;
916 unsigned int n = 0;
917 int error = 0;
918
919 printk("Loading image metadata ... ");
920 buf = (unsigned long *)get_zeroed_page(GFP_ATOMIC);
921 if (!buf)
922 return -ENOMEM;
923 p = pblist;
924 while (p) {
925 error = swap_map_read_page(handle, buf);
926 if (error)
927 break;
928 p = unpack_orig_addresses(buf, p);
929 n++;
930 }
931 free_page((unsigned long)buf);
932 if (!error)
933 printk("done (%u pages loaded)\n", n);
934 return error;
935}
936
937int swsusp_read(struct pbe **pblist_ptr)
938{
939 int error;
940 struct pbe *p, *pblist;
941 struct swap_map_handle handle;
942 unsigned int nr_pages;
943
944 if (IS_ERR(resume_bdev)) {
945 pr_debug("swsusp: block device not initialised\n");
946 return PTR_ERR(resume_bdev);
947 }
948
949 error = get_swap_map_reader(&handle, swsusp_header.image);
950 if (!error)
951 error = swap_map_read_page(&handle, &swsusp_info);
952 if (!error)
953 error = check_header();
954 if (error)
955 return error;
956 nr_pages = swsusp_info.image_pages;
957 p = alloc_pagedir(nr_pages, GFP_ATOMIC, 0);
958 if (!p)
959 return -ENOMEM;
960 error = load_image_metadata(p, &handle);
961 if (!error) {
962 mark_unsafe_pages(p);
963 pblist = alloc_pagedir(nr_pages, GFP_ATOMIC, 1);
964 if (pblist)
965 copy_page_backup_list(pblist, p);
966 free_pagedir(p);
967 if (!pblist)
968 error = -ENOMEM;
969
970 /* Allocate memory for the image and read the data from swap */
971 if (!error)
972 error = alloc_data_pages(pblist, GFP_ATOMIC, 1);
973 if (!error) {
974 release_eaten_pages();
975 error = load_image_data(pblist, &handle, nr_pages);
976 }
977 if (!error)
978 *pblist_ptr = pblist;
979 }
980 release_swap_map_reader(&handle);
981
982 blkdev_put(resume_bdev);
983
984 if (!error)
985 pr_debug("swsusp: Reading resume file was successful\n");
986 else
987 pr_debug("swsusp: Error %d resuming\n", error);
988 return error;
989}
990
991/**
992 * swsusp_check - Check for swsusp signature in the resume device
993 */
994
995int swsusp_check(void)
996{
997 int error;
998
999 resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
1000 if (!IS_ERR(resume_bdev)) {
1001 set_blocksize(resume_bdev, PAGE_SIZE);
1002 memset(&swsusp_header, 0, sizeof(swsusp_header));
1003 if ((error = bio_read_page(0, &swsusp_header)))
1004 return error;
1005 if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
1006 memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
1007 /* Reset swap signature now */
1008 error = bio_write_page(0, &swsusp_header);
1009 } else {
1010 return -EINVAL;
1011 }
1012 if (error)
1013 blkdev_put(resume_bdev);
1014 else
1015 pr_debug("swsusp: Signature found, resuming\n");
1016 } else {
1017 error = PTR_ERR(resume_bdev);
1018 }
1019
1020 if (error)
1021 pr_debug("swsusp: Error %d check for resume file\n", error);
1022
1023 return error;
1024}
1025
1026/**
1027 * swsusp_close - close swap device.
1028 */
1029
1030void swsusp_close(void)
1031{
1032 if (IS_ERR(resume_bdev)) {
1033 pr_debug("swsusp: block device not initialised\n");
1034 return;
1035 }
1036
1037 blkdev_put(resume_bdev);
1038}
diff --git a/kernel/power/user.c b/kernel/power/user.c
new file mode 100644
index 000000000000..3f1539fbe48a
--- /dev/null
+++ b/kernel/power/user.c
@@ -0,0 +1,333 @@
1/*
2 * linux/kernel/power/user.c
3 *
4 * This file provides the user space interface for software suspend/resume.
5 *
6 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 *
8 * This file is released under the GPLv2.
9 *
10 */
11
12#include <linux/suspend.h>
13#include <linux/syscalls.h>
14#include <linux/string.h>
15#include <linux/device.h>
16#include <linux/miscdevice.h>
17#include <linux/mm.h>
18#include <linux/swap.h>
19#include <linux/swapops.h>
20#include <linux/pm.h>
21#include <linux/fs.h>
22
23#include <asm/uaccess.h>
24
25#include "power.h"
26
27#define SNAPSHOT_MINOR 231
28
29static struct snapshot_data {
30 struct snapshot_handle handle;
31 int swap;
32 struct bitmap_page *bitmap;
33 int mode;
34 char frozen;
35 char ready;
36} snapshot_state;
37
38static atomic_t device_available = ATOMIC_INIT(1);
39
40static int snapshot_open(struct inode *inode, struct file *filp)
41{
42 struct snapshot_data *data;
43
44 if (!atomic_add_unless(&device_available, -1, 0))
45 return -EBUSY;
46
47 if ((filp->f_flags & O_ACCMODE) == O_RDWR)
48 return -ENOSYS;
49
50 nonseekable_open(inode, filp);
51 data = &snapshot_state;
52 filp->private_data = data;
53 memset(&data->handle, 0, sizeof(struct snapshot_handle));
54 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
55 data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1;
56 data->mode = O_RDONLY;
57 } else {
58 data->swap = -1;
59 data->mode = O_WRONLY;
60 }
61 data->bitmap = NULL;
62 data->frozen = 0;
63 data->ready = 0;
64
65 return 0;
66}
67
68static int snapshot_release(struct inode *inode, struct file *filp)
69{
70 struct snapshot_data *data;
71
72 swsusp_free();
73 data = filp->private_data;
74 free_all_swap_pages(data->swap, data->bitmap);
75 free_bitmap(data->bitmap);
76 if (data->frozen) {
77 down(&pm_sem);
78 thaw_processes();
79 enable_nonboot_cpus();
80 up(&pm_sem);
81 }
82 atomic_inc(&device_available);
83 return 0;
84}
85
86static ssize_t snapshot_read(struct file *filp, char __user *buf,
87 size_t count, loff_t *offp)
88{
89 struct snapshot_data *data;
90 ssize_t res;
91
92 data = filp->private_data;
93 res = snapshot_read_next(&data->handle, count);
94 if (res > 0) {
95 if (copy_to_user(buf, data_of(data->handle), res))
96 res = -EFAULT;
97 else
98 *offp = data->handle.offset;
99 }
100 return res;
101}
102
103static ssize_t snapshot_write(struct file *filp, const char __user *buf,
104 size_t count, loff_t *offp)
105{
106 struct snapshot_data *data;
107 ssize_t res;
108
109 data = filp->private_data;
110 res = snapshot_write_next(&data->handle, count);
111 if (res > 0) {
112 if (copy_from_user(data_of(data->handle), buf, res))
113 res = -EFAULT;
114 else
115 *offp = data->handle.offset;
116 }
117 return res;
118}
119
120static int snapshot_ioctl(struct inode *inode, struct file *filp,
121 unsigned int cmd, unsigned long arg)
122{
123 int error = 0;
124 struct snapshot_data *data;
125 loff_t offset, avail;
126
127 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
128 return -ENOTTY;
129 if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR)
130 return -ENOTTY;
131 if (!capable(CAP_SYS_ADMIN))
132 return -EPERM;
133
134 data = filp->private_data;
135
136 switch (cmd) {
137
138 case SNAPSHOT_FREEZE:
139 if (data->frozen)
140 break;
141 down(&pm_sem);
142 disable_nonboot_cpus();
143 if (freeze_processes()) {
144 thaw_processes();
145 enable_nonboot_cpus();
146 error = -EBUSY;
147 }
148 up(&pm_sem);
149 if (!error)
150 data->frozen = 1;
151 break;
152
153 case SNAPSHOT_UNFREEZE:
154 if (!data->frozen)
155 break;
156 down(&pm_sem);
157 thaw_processes();
158 enable_nonboot_cpus();
159 up(&pm_sem);
160 data->frozen = 0;
161 break;
162
163 case SNAPSHOT_ATOMIC_SNAPSHOT:
164 if (data->mode != O_RDONLY || !data->frozen || data->ready) {
165 error = -EPERM;
166 break;
167 }
168 down(&pm_sem);
169 /* Free memory before shutting down devices. */
170 error = swsusp_shrink_memory();
171 if (!error) {
172 error = device_suspend(PMSG_FREEZE);
173 if (!error) {
174 in_suspend = 1;
175 error = swsusp_suspend();
176 device_resume();
177 }
178 }
179 up(&pm_sem);
180 if (!error)
181 error = put_user(in_suspend, (unsigned int __user *)arg);
182 if (!error)
183 data->ready = 1;
184 break;
185
186 case SNAPSHOT_ATOMIC_RESTORE:
187 if (data->mode != O_WRONLY || !data->frozen ||
188 !snapshot_image_loaded(&data->handle)) {
189 error = -EPERM;
190 break;
191 }
192 down(&pm_sem);
193 pm_prepare_console();
194 error = device_suspend(PMSG_FREEZE);
195 if (!error) {
196 error = swsusp_resume();
197 device_resume();
198 }
199 pm_restore_console();
200 up(&pm_sem);
201 break;
202
203 case SNAPSHOT_FREE:
204 swsusp_free();
205 memset(&data->handle, 0, sizeof(struct snapshot_handle));
206 data->ready = 0;
207 break;
208
209 case SNAPSHOT_SET_IMAGE_SIZE:
210 image_size = arg;
211 break;
212
213 case SNAPSHOT_AVAIL_SWAP:
214 avail = count_swap_pages(data->swap, 1);
215 avail <<= PAGE_SHIFT;
216 error = put_user(avail, (loff_t __user *)arg);
217 break;
218
219 case SNAPSHOT_GET_SWAP_PAGE:
220 if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
221 error = -ENODEV;
222 break;
223 }
224 if (!data->bitmap) {
225 data->bitmap = alloc_bitmap(count_swap_pages(data->swap, 0));
226 if (!data->bitmap) {
227 error = -ENOMEM;
228 break;
229 }
230 }
231 offset = alloc_swap_page(data->swap, data->bitmap);
232 if (offset) {
233 offset <<= PAGE_SHIFT;
234 error = put_user(offset, (loff_t __user *)arg);
235 } else {
236 error = -ENOSPC;
237 }
238 break;
239
240 case SNAPSHOT_FREE_SWAP_PAGES:
241 if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
242 error = -ENODEV;
243 break;
244 }
245 free_all_swap_pages(data->swap, data->bitmap);
246 free_bitmap(data->bitmap);
247 data->bitmap = NULL;
248 break;
249
250 case SNAPSHOT_SET_SWAP_FILE:
251 if (!data->bitmap) {
252 /*
253 * User space encodes device types as two-byte values,
254 * so we need to recode them
255 */
256 if (old_decode_dev(arg)) {
257 data->swap = swap_type_of(old_decode_dev(arg));
258 if (data->swap < 0)
259 error = -ENODEV;
260 } else {
261 data->swap = -1;
262 error = -EINVAL;
263 }
264 } else {
265 error = -EPERM;
266 }
267 break;
268
269 case SNAPSHOT_S2RAM:
270 if (!data->frozen) {
271 error = -EPERM;
272 break;
273 }
274
275 if (down_trylock(&pm_sem)) {
276 error = -EBUSY;
277 break;
278 }
279
280 if (pm_ops->prepare) {
281 error = pm_ops->prepare(PM_SUSPEND_MEM);
282 if (error)
283 goto OutS3;
284 }
285
286 /* Put devices to sleep */
287 error = device_suspend(PMSG_SUSPEND);
288 if (error) {
289 printk(KERN_ERR "Failed to suspend some devices.\n");
290 } else {
291 /* Enter S3, system is already frozen */
292 suspend_enter(PM_SUSPEND_MEM);
293
294 /* Wake up devices */
295 device_resume();
296 }
297
298 if (pm_ops->finish)
299 pm_ops->finish(PM_SUSPEND_MEM);
300
301OutS3:
302 up(&pm_sem);
303 break;
304
305 default:
306 error = -ENOTTY;
307
308 }
309
310 return error;
311}
312
313static struct file_operations snapshot_fops = {
314 .open = snapshot_open,
315 .release = snapshot_release,
316 .read = snapshot_read,
317 .write = snapshot_write,
318 .llseek = no_llseek,
319 .ioctl = snapshot_ioctl,
320};
321
322static struct miscdevice snapshot_device = {
323 .minor = SNAPSHOT_MINOR,
324 .name = "snapshot",
325 .fops = &snapshot_fops,
326};
327
328static int __init snapshot_device_init(void)
329{
330 return misc_register(&snapshot_device);
331};
332
333device_initcall(snapshot_device_init);
diff --git a/kernel/profile.c b/kernel/profile.c
index f89248e6d704..ad81f799a9b4 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -23,6 +23,7 @@
23#include <linux/cpu.h> 23#include <linux/cpu.h>
24#include <linux/profile.h> 24#include <linux/profile.h>
25#include <linux/highmem.h> 25#include <linux/highmem.h>
26#include <linux/mutex.h>
26#include <asm/sections.h> 27#include <asm/sections.h>
27#include <asm/semaphore.h> 28#include <asm/semaphore.h>
28 29
@@ -44,7 +45,7 @@ static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
44#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
45static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); 46static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
46static DEFINE_PER_CPU(int, cpu_profile_flip); 47static DEFINE_PER_CPU(int, cpu_profile_flip);
47static DECLARE_MUTEX(profile_flip_mutex); 48static DEFINE_MUTEX(profile_flip_mutex);
48#endif /* CONFIG_SMP */ 49#endif /* CONFIG_SMP */
49 50
50static int __init profile_setup(char * str) 51static int __init profile_setup(char * str)
@@ -243,7 +244,7 @@ static void profile_flip_buffers(void)
243{ 244{
244 int i, j, cpu; 245 int i, j, cpu;
245 246
246 down(&profile_flip_mutex); 247 mutex_lock(&profile_flip_mutex);
247 j = per_cpu(cpu_profile_flip, get_cpu()); 248 j = per_cpu(cpu_profile_flip, get_cpu());
248 put_cpu(); 249 put_cpu();
249 on_each_cpu(__profile_flip_buffers, NULL, 0, 1); 250 on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
@@ -259,14 +260,14 @@ static void profile_flip_buffers(void)
259 hits[i].hits = hits[i].pc = 0; 260 hits[i].hits = hits[i].pc = 0;
260 } 261 }
261 } 262 }
262 up(&profile_flip_mutex); 263 mutex_unlock(&profile_flip_mutex);
263} 264}
264 265
265static void profile_discard_flip_buffers(void) 266static void profile_discard_flip_buffers(void)
266{ 267{
267 int i, cpu; 268 int i, cpu;
268 269
269 down(&profile_flip_mutex); 270 mutex_lock(&profile_flip_mutex);
270 i = per_cpu(cpu_profile_flip, get_cpu()); 271 i = per_cpu(cpu_profile_flip, get_cpu());
271 put_cpu(); 272 put_cpu();
272 on_each_cpu(__profile_flip_buffers, NULL, 0, 1); 273 on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
@@ -274,7 +275,7 @@ static void profile_discard_flip_buffers(void)
274 struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i]; 275 struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
275 memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit)); 276 memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
276 } 277 }
277 up(&profile_flip_mutex); 278 mutex_unlock(&profile_flip_mutex);
278} 279}
279 280
280void profile_hit(int type, void *__pc) 281void profile_hit(int type, void *__pc)
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index fedf5e369755..6df1559b1c02 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -47,15 +47,16 @@
47#include <linux/notifier.h> 47#include <linux/notifier.h>
48#include <linux/rcupdate.h> 48#include <linux/rcupdate.h>
49#include <linux/cpu.h> 49#include <linux/cpu.h>
50#include <linux/mutex.h>
50 51
51/* Definition for rcupdate control block. */ 52/* Definition for rcupdate control block. */
52struct rcu_ctrlblk rcu_ctrlblk = { 53static struct rcu_ctrlblk rcu_ctrlblk = {
53 .cur = -300, 54 .cur = -300,
54 .completed = -300, 55 .completed = -300,
55 .lock = SPIN_LOCK_UNLOCKED, 56 .lock = SPIN_LOCK_UNLOCKED,
56 .cpumask = CPU_MASK_NONE, 57 .cpumask = CPU_MASK_NONE,
57}; 58};
58struct rcu_ctrlblk rcu_bh_ctrlblk = { 59static struct rcu_ctrlblk rcu_bh_ctrlblk = {
59 .cur = -300, 60 .cur = -300,
60 .completed = -300, 61 .completed = -300,
61 .lock = SPIN_LOCK_UNLOCKED, 62 .lock = SPIN_LOCK_UNLOCKED,
@@ -75,7 +76,7 @@ static int rsinterval = 1000;
75#endif 76#endif
76 77
77static atomic_t rcu_barrier_cpu_count; 78static atomic_t rcu_barrier_cpu_count;
78static struct semaphore rcu_barrier_sema; 79static DEFINE_MUTEX(rcu_barrier_mutex);
79static struct completion rcu_barrier_completion; 80static struct completion rcu_barrier_completion;
80 81
81#ifdef CONFIG_SMP 82#ifdef CONFIG_SMP
@@ -207,13 +208,13 @@ static void rcu_barrier_func(void *notused)
207void rcu_barrier(void) 208void rcu_barrier(void)
208{ 209{
209 BUG_ON(in_interrupt()); 210 BUG_ON(in_interrupt());
210 /* Take cpucontrol semaphore to protect against CPU hotplug */ 211 /* Take cpucontrol mutex to protect against CPU hotplug */
211 down(&rcu_barrier_sema); 212 mutex_lock(&rcu_barrier_mutex);
212 init_completion(&rcu_barrier_completion); 213 init_completion(&rcu_barrier_completion);
213 atomic_set(&rcu_barrier_cpu_count, 0); 214 atomic_set(&rcu_barrier_cpu_count, 0);
214 on_each_cpu(rcu_barrier_func, NULL, 0, 1); 215 on_each_cpu(rcu_barrier_func, NULL, 0, 1);
215 wait_for_completion(&rcu_barrier_completion); 216 wait_for_completion(&rcu_barrier_completion);
216 up(&rcu_barrier_sema); 217 mutex_unlock(&rcu_barrier_mutex);
217} 218}
218EXPORT_SYMBOL_GPL(rcu_barrier); 219EXPORT_SYMBOL_GPL(rcu_barrier);
219 220
@@ -549,7 +550,6 @@ static struct notifier_block __devinitdata rcu_nb = {
549 */ 550 */
550void __init rcu_init(void) 551void __init rcu_init(void)
551{ 552{
552 sema_init(&rcu_barrier_sema, 1);
553 rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE, 553 rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE,
554 (void *)(long)smp_processor_id()); 554 (void *)(long)smp_processor_id());
555 /* Register notifier for non-boot CPUs */ 555 /* Register notifier for non-boot CPUs */
diff --git a/kernel/sched.c b/kernel/sched.c
index 6b6e0d70eb30..7ffaabd64f89 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -237,6 +237,7 @@ struct runqueue {
237 237
238 task_t *migration_thread; 238 task_t *migration_thread;
239 struct list_head migration_queue; 239 struct list_head migration_queue;
240 int cpu;
240#endif 241#endif
241 242
242#ifdef CONFIG_SCHEDSTATS 243#ifdef CONFIG_SCHEDSTATS
@@ -1654,6 +1655,9 @@ unsigned long nr_iowait(void)
1654/* 1655/*
1655 * double_rq_lock - safely lock two runqueues 1656 * double_rq_lock - safely lock two runqueues
1656 * 1657 *
1658 * We must take them in cpu order to match code in
1659 * dependent_sleeper and wake_dependent_sleeper.
1660 *
1657 * Note this does not disable interrupts like task_rq_lock, 1661 * Note this does not disable interrupts like task_rq_lock,
1658 * you need to do so manually before calling. 1662 * you need to do so manually before calling.
1659 */ 1663 */
@@ -1665,7 +1669,7 @@ static void double_rq_lock(runqueue_t *rq1, runqueue_t *rq2)
1665 spin_lock(&rq1->lock); 1669 spin_lock(&rq1->lock);
1666 __acquire(rq2->lock); /* Fake it out ;) */ 1670 __acquire(rq2->lock); /* Fake it out ;) */
1667 } else { 1671 } else {
1668 if (rq1 < rq2) { 1672 if (rq1->cpu < rq2->cpu) {
1669 spin_lock(&rq1->lock); 1673 spin_lock(&rq1->lock);
1670 spin_lock(&rq2->lock); 1674 spin_lock(&rq2->lock);
1671 } else { 1675 } else {
@@ -1701,7 +1705,7 @@ static void double_lock_balance(runqueue_t *this_rq, runqueue_t *busiest)
1701 __acquires(this_rq->lock) 1705 __acquires(this_rq->lock)
1702{ 1706{
1703 if (unlikely(!spin_trylock(&busiest->lock))) { 1707 if (unlikely(!spin_trylock(&busiest->lock))) {
1704 if (busiest < this_rq) { 1708 if (busiest->cpu < this_rq->cpu) {
1705 spin_unlock(&this_rq->lock); 1709 spin_unlock(&this_rq->lock);
1706 spin_lock(&busiest->lock); 1710 spin_lock(&busiest->lock);
1707 spin_lock(&this_rq->lock); 1711 spin_lock(&this_rq->lock);
@@ -2869,7 +2873,7 @@ asmlinkage void __sched schedule(void)
2869 */ 2873 */
2870 if (likely(!current->exit_state)) { 2874 if (likely(!current->exit_state)) {
2871 if (unlikely(in_atomic())) { 2875 if (unlikely(in_atomic())) {
2872 printk(KERN_ERR "scheduling while atomic: " 2876 printk(KERN_ERR "BUG: scheduling while atomic: "
2873 "%s/0x%08x/%d\n", 2877 "%s/0x%08x/%d\n",
2874 current->comm, preempt_count(), current->pid); 2878 current->comm, preempt_count(), current->pid);
2875 dump_stack(); 2879 dump_stack();
@@ -6029,6 +6033,7 @@ void __init sched_init(void)
6029 rq->push_cpu = 0; 6033 rq->push_cpu = 0;
6030 rq->migration_thread = NULL; 6034 rq->migration_thread = NULL;
6031 INIT_LIST_HEAD(&rq->migration_queue); 6035 INIT_LIST_HEAD(&rq->migration_queue);
6036 rq->cpu = i;
6032#endif 6037#endif
6033 atomic_set(&rq->nr_iowait, 0); 6038 atomic_set(&rq->nr_iowait, 0);
6034 6039
@@ -6069,7 +6074,7 @@ void __might_sleep(char *file, int line)
6069 if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy) 6074 if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
6070 return; 6075 return;
6071 prev_jiffy = jiffies; 6076 prev_jiffy = jiffies;
6072 printk(KERN_ERR "Debug: sleeping function called from invalid" 6077 printk(KERN_ERR "BUG: sleeping function called from invalid"
6073 " context at %s:%d\n", file, line); 6078 " context at %s:%d\n", file, line);
6074 printk("in_atomic():%d, irqs_disabled():%d\n", 6079 printk("in_atomic():%d, irqs_disabled():%d\n",
6075 in_atomic(), irqs_disabled()); 6080 in_atomic(), irqs_disabled());
diff --git a/kernel/signal.c b/kernel/signal.c
index ea154104a00b..75f7341b0c39 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1922,6 +1922,8 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
1922 sigset_t *mask = &current->blocked; 1922 sigset_t *mask = &current->blocked;
1923 int signr = 0; 1923 int signr = 0;
1924 1924
1925 try_to_freeze();
1926
1925relock: 1927relock:
1926 spin_lock_irq(&current->sighand->siglock); 1928 spin_lock_irq(&current->sighand->siglock);
1927 for (;;) { 1929 for (;;) {
@@ -2099,10 +2101,11 @@ long do_no_restart_syscall(struct restart_block *param)
2099int sigprocmask(int how, sigset_t *set, sigset_t *oldset) 2101int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
2100{ 2102{
2101 int error; 2103 int error;
2102 sigset_t old_block;
2103 2104
2104 spin_lock_irq(&current->sighand->siglock); 2105 spin_lock_irq(&current->sighand->siglock);
2105 old_block = current->blocked; 2106 if (oldset)
2107 *oldset = current->blocked;
2108
2106 error = 0; 2109 error = 0;
2107 switch (how) { 2110 switch (how) {
2108 case SIG_BLOCK: 2111 case SIG_BLOCK:
@@ -2119,8 +2122,7 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
2119 } 2122 }
2120 recalc_sigpending(); 2123 recalc_sigpending();
2121 spin_unlock_irq(&current->sighand->siglock); 2124 spin_unlock_irq(&current->sighand->siglock);
2122 if (oldset) 2125
2123 *oldset = old_block;
2124 return error; 2126 return error;
2125} 2127}
2126 2128
@@ -2307,7 +2309,6 @@ sys_rt_sigtimedwait(const sigset_t __user *uthese,
2307 2309
2308 timeout = schedule_timeout_interruptible(timeout); 2310 timeout = schedule_timeout_interruptible(timeout);
2309 2311
2310 try_to_freeze();
2311 spin_lock_irq(&current->sighand->siglock); 2312 spin_lock_irq(&current->sighand->siglock);
2312 sig = dequeue_signal(current, &these, &info); 2313 sig = dequeue_signal(current, &these, &info);
2313 current->blocked = current->real_blocked; 2314 current->blocked = current->real_blocked;
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 0375fcd5921d..d1b810782bc4 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -179,16 +179,16 @@ EXPORT_SYMBOL(_write_lock);
179#define BUILD_LOCK_OPS(op, locktype) \ 179#define BUILD_LOCK_OPS(op, locktype) \
180void __lockfunc _##op##_lock(locktype##_t *lock) \ 180void __lockfunc _##op##_lock(locktype##_t *lock) \
181{ \ 181{ \
182 preempt_disable(); \
183 for (;;) { \ 182 for (;;) { \
183 preempt_disable(); \
184 if (likely(_raw_##op##_trylock(lock))) \ 184 if (likely(_raw_##op##_trylock(lock))) \
185 break; \ 185 break; \
186 preempt_enable(); \ 186 preempt_enable(); \
187 \
187 if (!(lock)->break_lock) \ 188 if (!(lock)->break_lock) \
188 (lock)->break_lock = 1; \ 189 (lock)->break_lock = 1; \
189 while (!op##_can_lock(lock) && (lock)->break_lock) \ 190 while (!op##_can_lock(lock) && (lock)->break_lock) \
190 cpu_relax(); \ 191 cpu_relax(); \
191 preempt_disable(); \
192 } \ 192 } \
193 (lock)->break_lock = 0; \ 193 (lock)->break_lock = 0; \
194} \ 194} \
@@ -199,19 +199,18 @@ unsigned long __lockfunc _##op##_lock_irqsave(locktype##_t *lock) \
199{ \ 199{ \
200 unsigned long flags; \ 200 unsigned long flags; \
201 \ 201 \
202 preempt_disable(); \
203 for (;;) { \ 202 for (;;) { \
203 preempt_disable(); \
204 local_irq_save(flags); \ 204 local_irq_save(flags); \
205 if (likely(_raw_##op##_trylock(lock))) \ 205 if (likely(_raw_##op##_trylock(lock))) \
206 break; \ 206 break; \
207 local_irq_restore(flags); \ 207 local_irq_restore(flags); \
208 \
209 preempt_enable(); \ 208 preempt_enable(); \
209 \
210 if (!(lock)->break_lock) \ 210 if (!(lock)->break_lock) \
211 (lock)->break_lock = 1; \ 211 (lock)->break_lock = 1; \
212 while (!op##_can_lock(lock) && (lock)->break_lock) \ 212 while (!op##_can_lock(lock) && (lock)->break_lock) \
213 cpu_relax(); \ 213 cpu_relax(); \
214 preempt_disable(); \
215 } \ 214 } \
216 (lock)->break_lock = 0; \ 215 (lock)->break_lock = 0; \
217 return flags; \ 216 return flags; \
diff --git a/kernel/sys.c b/kernel/sys.c
index f91218a5463e..c0fcad9f826c 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1227,7 +1227,7 @@ asmlinkage long sys_setsid(void)
1227 struct pid *pid; 1227 struct pid *pid;
1228 int err = -EPERM; 1228 int err = -EPERM;
1229 1229
1230 down(&tty_sem); 1230 mutex_lock(&tty_mutex);
1231 write_lock_irq(&tasklist_lock); 1231 write_lock_irq(&tasklist_lock);
1232 1232
1233 pid = find_pid(PIDTYPE_PGID, group_leader->pid); 1233 pid = find_pid(PIDTYPE_PGID, group_leader->pid);
@@ -1241,7 +1241,7 @@ asmlinkage long sys_setsid(void)
1241 err = process_group(group_leader); 1241 err = process_group(group_leader);
1242out: 1242out:
1243 write_unlock_irq(&tasklist_lock); 1243 write_unlock_irq(&tasklist_lock);
1244 up(&tty_sem); 1244 mutex_unlock(&tty_mutex);
1245 return err; 1245 return err;
1246} 1246}
1247 1247
@@ -1677,9 +1677,6 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
1677 * a lot simpler! (Which we're not doing right now because we're not 1677 * a lot simpler! (Which we're not doing right now because we're not
1678 * measuring them yet). 1678 * measuring them yet).
1679 * 1679 *
1680 * This expects to be called with tasklist_lock read-locked or better,
1681 * and the siglock not locked. It may momentarily take the siglock.
1682 *
1683 * When sampling multiple threads for RUSAGE_SELF, under SMP we might have 1680 * When sampling multiple threads for RUSAGE_SELF, under SMP we might have
1684 * races with threads incrementing their own counters. But since word 1681 * races with threads incrementing their own counters. But since word
1685 * reads are atomic, we either get new values or old values and we don't 1682 * reads are atomic, we either get new values or old values and we don't
@@ -1687,6 +1684,25 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
1687 * the c* fields from p->signal from races with exit.c updating those 1684 * the c* fields from p->signal from races with exit.c updating those
1688 * fields when reaping, so a sample either gets all the additions of a 1685 * fields when reaping, so a sample either gets all the additions of a
1689 * given child after it's reaped, or none so this sample is before reaping. 1686 * given child after it's reaped, or none so this sample is before reaping.
1687 *
1688 * tasklist_lock locking optimisation:
1689 * If we are current and single threaded, we do not need to take the tasklist
1690 * lock or the siglock. No one else can take our signal_struct away,
1691 * no one else can reap the children to update signal->c* counters, and
1692 * no one else can race with the signal-> fields.
1693 * If we do not take the tasklist_lock, the signal-> fields could be read
1694 * out of order while another thread was just exiting. So we place a
1695 * read memory barrier when we avoid the lock. On the writer side,
1696 * write memory barrier is implied in __exit_signal as __exit_signal releases
1697 * the siglock spinlock after updating the signal-> fields.
1698 *
1699 * We don't really need the siglock when we access the non c* fields
1700 * of the signal_struct (for RUSAGE_SELF) even in multithreaded
1701 * case, since we take the tasklist lock for read and the non c* signal->
1702 * fields are updated only in __exit_signal, which is called with
1703 * tasklist_lock taken for write, hence these two threads cannot execute
1704 * concurrently.
1705 *
1690 */ 1706 */
1691 1707
1692static void k_getrusage(struct task_struct *p, int who, struct rusage *r) 1708static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
@@ -1694,13 +1710,23 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
1694 struct task_struct *t; 1710 struct task_struct *t;
1695 unsigned long flags; 1711 unsigned long flags;
1696 cputime_t utime, stime; 1712 cputime_t utime, stime;
1713 int need_lock = 0;
1697 1714
1698 memset((char *) r, 0, sizeof *r); 1715 memset((char *) r, 0, sizeof *r);
1716 utime = stime = cputime_zero;
1699 1717
1700 if (unlikely(!p->signal)) 1718 if (p != current || !thread_group_empty(p))
1701 return; 1719 need_lock = 1;
1702 1720
1703 utime = stime = cputime_zero; 1721 if (need_lock) {
1722 read_lock(&tasklist_lock);
1723 if (unlikely(!p->signal)) {
1724 read_unlock(&tasklist_lock);
1725 return;
1726 }
1727 } else
1728 /* See locking comments above */
1729 smp_rmb();
1704 1730
1705 switch (who) { 1731 switch (who) {
1706 case RUSAGE_BOTH: 1732 case RUSAGE_BOTH:
@@ -1740,6 +1766,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
1740 BUG(); 1766 BUG();
1741 } 1767 }
1742 1768
1769 if (need_lock)
1770 read_unlock(&tasklist_lock);
1743 cputime_to_timeval(utime, &r->ru_utime); 1771 cputime_to_timeval(utime, &r->ru_utime);
1744 cputime_to_timeval(stime, &r->ru_stime); 1772 cputime_to_timeval(stime, &r->ru_stime);
1745} 1773}
@@ -1747,9 +1775,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
1747int getrusage(struct task_struct *p, int who, struct rusage __user *ru) 1775int getrusage(struct task_struct *p, int who, struct rusage __user *ru)
1748{ 1776{
1749 struct rusage r; 1777 struct rusage r;
1750 read_lock(&tasklist_lock);
1751 k_getrusage(p, who, &r); 1778 k_getrusage(p, who, &r);
1752 read_unlock(&tasklist_lock);
1753 return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0; 1779 return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
1754} 1780}
1755 1781
diff --git a/lib/extable.c b/lib/extable.c
index 18df57c029df..01c08b5836f5 100644
--- a/lib/extable.c
+++ b/lib/extable.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * lib/extable.c
3 * Derived from arch/ppc/mm/extable.c and arch/i386/mm/extable.c. 2 * Derived from arch/ppc/mm/extable.c and arch/i386/mm/extable.c.
4 * 3 *
5 * Copyright (C) 2004 Paul Mackerras, IBM Corp. 4 * Copyright (C) 2004 Paul Mackerras, IBM Corp.
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index f5fef948a415..f8ac9fa95de1 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -44,12 +44,13 @@
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/rslib.h> 45#include <linux/rslib.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/mutex.h>
47#include <asm/semaphore.h> 48#include <asm/semaphore.h>
48 49
49/* This list holds all currently allocated rs control structures */ 50/* This list holds all currently allocated rs control structures */
50static LIST_HEAD (rslist); 51static LIST_HEAD (rslist);
51/* Protection for the list */ 52/* Protection for the list */
52static DECLARE_MUTEX(rslistlock); 53static DEFINE_MUTEX(rslistlock);
53 54
54/** 55/**
55 * rs_init - Initialize a Reed-Solomon codec 56 * rs_init - Initialize a Reed-Solomon codec
@@ -161,7 +162,7 @@ errrs:
161 */ 162 */
162void free_rs(struct rs_control *rs) 163void free_rs(struct rs_control *rs)
163{ 164{
164 down(&rslistlock); 165 mutex_lock(&rslistlock);
165 rs->users--; 166 rs->users--;
166 if(!rs->users) { 167 if(!rs->users) {
167 list_del(&rs->list); 168 list_del(&rs->list);
@@ -170,7 +171,7 @@ void free_rs(struct rs_control *rs)
170 kfree(rs->genpoly); 171 kfree(rs->genpoly);
171 kfree(rs); 172 kfree(rs);
172 } 173 }
173 up(&rslistlock); 174 mutex_unlock(&rslistlock);
174} 175}
175 176
176/** 177/**
@@ -201,7 +202,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
201 if (nroots < 0 || nroots >= (1<<symsize)) 202 if (nroots < 0 || nroots >= (1<<symsize))
202 return NULL; 203 return NULL;
203 204
204 down(&rslistlock); 205 mutex_lock(&rslistlock);
205 206
206 /* Walk through the list and look for a matching entry */ 207 /* Walk through the list and look for a matching entry */
207 list_for_each(tmp, &rslist) { 208 list_for_each(tmp, &rslist) {
@@ -228,7 +229,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
228 list_add(&rs->list, &rslist); 229 list_add(&rs->list, &rslist);
229 } 230 }
230out: 231out:
231 up(&rslistlock); 232 mutex_unlock(&rslistlock);
232 return rs; 233 return rs;
233} 234}
234 235
diff --git a/mm/readahead.c b/mm/readahead.c
index 301b36c4a0ce..0f142a40984b 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -555,6 +555,7 @@ recheck:
555out: 555out:
556 return ra->prev_page + 1; 556 return ra->prev_page + 1;
557} 557}
558EXPORT_SYMBOL_GPL(page_cache_readahead);
558 559
559/* 560/*
560 * handle_ra_miss() is called when it is known that a page which should have 561 * handle_ra_miss() is called when it is known that a page which should have
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 365ed6ff182d..39aa9d129612 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -45,7 +45,7 @@ static const char Unused_offset[] = "Unused swap offset entry ";
45 45
46struct swap_list_t swap_list = {-1, -1}; 46struct swap_list_t swap_list = {-1, -1};
47 47
48struct swap_info_struct swap_info[MAX_SWAPFILES]; 48static struct swap_info_struct swap_info[MAX_SWAPFILES];
49 49
50static DEFINE_MUTEX(swapon_mutex); 50static DEFINE_MUTEX(swapon_mutex);
51 51
@@ -417,6 +417,61 @@ void free_swap_and_cache(swp_entry_t entry)
417 } 417 }
418} 418}
419 419
420#ifdef CONFIG_SOFTWARE_SUSPEND
421/*
422 * Find the swap type that corresponds to given device (if any)
423 *
424 * This is needed for software suspend and is done in such a way that inode
425 * aliasing is allowed.
426 */
427int swap_type_of(dev_t device)
428{
429 int i;
430
431 spin_lock(&swap_lock);
432 for (i = 0; i < nr_swapfiles; i++) {
433 struct inode *inode;
434
435 if (!(swap_info[i].flags & SWP_WRITEOK))
436 continue;
437 if (!device) {
438 spin_unlock(&swap_lock);
439 return i;
440 }
441 inode = swap_info->swap_file->f_dentry->d_inode;
442 if (S_ISBLK(inode->i_mode) &&
443 device == MKDEV(imajor(inode), iminor(inode))) {
444 spin_unlock(&swap_lock);
445 return i;
446 }
447 }
448 spin_unlock(&swap_lock);
449 return -ENODEV;
450}
451
452/*
453 * Return either the total number of swap pages of given type, or the number
454 * of free pages of that type (depending on @free)
455 *
456 * This is needed for software suspend
457 */
458unsigned int count_swap_pages(int type, int free)
459{
460 unsigned int n = 0;
461
462 if (type < nr_swapfiles) {
463 spin_lock(&swap_lock);
464 if (swap_info[type].flags & SWP_WRITEOK) {
465 n = swap_info[type].pages;
466 if (free)
467 n -= swap_info[type].inuse_pages;
468 }
469 spin_unlock(&swap_lock);
470 }
471 return n;
472}
473#endif
474
420/* 475/*
421 * No need to decide whether this PTE shares the swap entry with others, 476 * No need to decide whether this PTE shares the swap entry with others,
422 * just let do_wp_page work it out if a write is requested later - to 477 * just let do_wp_page work it out if a write is requested later - to
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 8ee4d016740d..f75ff1d96551 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1249,11 +1249,7 @@ int ip_push_pending_frames(struct sock *sk)
1249 iph->tos = inet->tos; 1249 iph->tos = inet->tos;
1250 iph->tot_len = htons(skb->len); 1250 iph->tot_len = htons(skb->len);
1251 iph->frag_off = df; 1251 iph->frag_off = df;
1252 if (!df) { 1252 ip_select_ident(iph, &rt->u.dst, sk);
1253 __ip_select_ident(iph, &rt->u.dst, 0);
1254 } else {
1255 iph->id = htons(inet->id++);
1256 }
1257 iph->ttl = ttl; 1253 iph->ttl = ttl;
1258 iph->protocol = sk->sk_protocol; 1254 iph->protocol = sk->sk_protocol;
1259 iph->saddr = rt->rt_src; 1255 iph->saddr = rt->rt_src;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index f7efb3f27bf5..ff0c594a4198 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -1146,12 +1146,14 @@ void arpt_unregister_table(struct arpt_table *table)
1146static struct arpt_target arpt_standard_target = { 1146static struct arpt_target arpt_standard_target = {
1147 .name = ARPT_STANDARD_TARGET, 1147 .name = ARPT_STANDARD_TARGET,
1148 .targetsize = sizeof(int), 1148 .targetsize = sizeof(int),
1149 .family = NF_ARP,
1149}; 1150};
1150 1151
1151static struct arpt_target arpt_error_target = { 1152static struct arpt_target arpt_error_target = {
1152 .name = ARPT_ERROR_TARGET, 1153 .name = ARPT_ERROR_TARGET,
1153 .target = arpt_error, 1154 .target = arpt_error,
1154 .targetsize = ARPT_FUNCTION_MAXNAMELEN, 1155 .targetsize = ARPT_FUNCTION_MAXNAMELEN,
1156 .family = NF_ARP,
1155}; 1157};
1156 1158
1157static struct nf_sockopt_ops arpt_sockopts = { 1159static struct nf_sockopt_ops arpt_sockopts = {
@@ -1171,8 +1173,8 @@ static int __init init(void)
1171 xt_proto_init(NF_ARP); 1173 xt_proto_init(NF_ARP);
1172 1174
1173 /* Noone else will be downing sem now, so we won't sleep */ 1175 /* Noone else will be downing sem now, so we won't sleep */
1174 xt_register_target(NF_ARP, &arpt_standard_target); 1176 xt_register_target(&arpt_standard_target);
1175 xt_register_target(NF_ARP, &arpt_error_target); 1177 xt_register_target(&arpt_error_target);
1176 1178
1177 /* Register setsockopt */ 1179 /* Register setsockopt */
1178 ret = nf_register_sockopt(&arpt_sockopts); 1180 ret = nf_register_sockopt(&arpt_sockopts);
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 84c66dbfedaf..9e34034729a6 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -77,8 +77,8 @@ unsigned int ip_ct_log_invalid;
77static LIST_HEAD(unconfirmed); 77static LIST_HEAD(unconfirmed);
78static int ip_conntrack_vmalloc; 78static int ip_conntrack_vmalloc;
79 79
80static unsigned int ip_conntrack_next_id = 1; 80static unsigned int ip_conntrack_next_id;
81static unsigned int ip_conntrack_expect_next_id = 1; 81static unsigned int ip_conntrack_expect_next_id;
82#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS 82#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
83struct notifier_block *ip_conntrack_chain; 83struct notifier_block *ip_conntrack_chain;
84struct notifier_block *ip_conntrack_expect_chain; 84struct notifier_block *ip_conntrack_expect_chain;
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 20da6730b860..daeb1395faa4 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -639,8 +639,8 @@ void ip_conntrack_h245_expect(struct ip_conntrack *new,
639} 639}
640 640
641/****************************************************************************/ 641/****************************************************************************/
642static int get_h225_addr(unsigned char *data, TransportAddress * addr, 642int get_h225_addr(unsigned char *data, TransportAddress * addr,
643 u_int32_t * ip, u_int16_t * port) 643 u_int32_t * ip, u_int16_t * port)
644{ 644{
645 unsigned char *p; 645 unsigned char *p;
646 646
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 5ce2e3fc2c7f..9b6e19bae90f 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -4,7 +4,7 @@
4 * (C) 2001 by Jay Schulist <jschlst@samba.org> 4 * (C) 2001 by Jay Schulist <jschlst@samba.org>
5 * (C) 2002-2005 by Harald Welte <laforge@gnumonks.org> 5 * (C) 2002-2005 by Harald Welte <laforge@gnumonks.org>
6 * (C) 2003 by Patrick Mchardy <kaber@trash.net> 6 * (C) 2003 by Patrick Mchardy <kaber@trash.net>
7 * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net> 7 * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
8 * 8 *
9 * I've reworked this stuff to use attributes instead of conntrack 9 * I've reworked this stuff to use attributes instead of conntrack
10 * structures. 5.44 am. I need more tea. --pablo 05/07/11. 10 * structures. 5.44 am. I need more tea. --pablo 05/07/11.
@@ -53,20 +53,18 @@ static char __initdata version[] = "0.90";
53 53
54static inline int 54static inline int
55ctnetlink_dump_tuples_proto(struct sk_buff *skb, 55ctnetlink_dump_tuples_proto(struct sk_buff *skb,
56 const struct ip_conntrack_tuple *tuple) 56 const struct ip_conntrack_tuple *tuple,
57 struct ip_conntrack_protocol *proto)
57{ 58{
58 struct ip_conntrack_protocol *proto;
59 int ret = 0; 59 int ret = 0;
60 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
60 61
61 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum); 62 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
62 63
63 /* If no protocol helper is found, this function will return the
64 * generic protocol helper, so proto won't *ever* be NULL */
65 proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
66 if (likely(proto->tuple_to_nfattr)) 64 if (likely(proto->tuple_to_nfattr))
67 ret = proto->tuple_to_nfattr(skb, tuple); 65 ret = proto->tuple_to_nfattr(skb, tuple);
68 66
69 ip_conntrack_proto_put(proto); 67 NFA_NEST_END(skb, nest_parms);
70 68
71 return ret; 69 return ret;
72 70
@@ -75,28 +73,41 @@ nfattr_failure:
75} 73}
76 74
77static inline int 75static inline int
78ctnetlink_dump_tuples(struct sk_buff *skb, 76ctnetlink_dump_tuples_ip(struct sk_buff *skb,
79 const struct ip_conntrack_tuple *tuple) 77 const struct ip_conntrack_tuple *tuple)
80{ 78{
81 struct nfattr *nest_parms; 79 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
82 int ret;
83 80
84 nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
85 NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip); 81 NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip);
86 NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip); 82 NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip);
87 NFA_NEST_END(skb, nest_parms);
88 83
89 nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
90 ret = ctnetlink_dump_tuples_proto(skb, tuple);
91 NFA_NEST_END(skb, nest_parms); 84 NFA_NEST_END(skb, nest_parms);
92 85
93 return ret; 86 return 0;
94 87
95nfattr_failure: 88nfattr_failure:
96 return -1; 89 return -1;
97} 90}
98 91
99static inline int 92static inline int
93ctnetlink_dump_tuples(struct sk_buff *skb,
94 const struct ip_conntrack_tuple *tuple)
95{
96 int ret;
97 struct ip_conntrack_protocol *proto;
98
99 ret = ctnetlink_dump_tuples_ip(skb, tuple);
100 if (unlikely(ret < 0))
101 return ret;
102
103 proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
104 ret = ctnetlink_dump_tuples_proto(skb, tuple, proto);
105 ip_conntrack_proto_put(proto);
106
107 return ret;
108}
109
110static inline int
100ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct) 111ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct)
101{ 112{
102 u_int32_t status = htonl((u_int32_t) ct->status); 113 u_int32_t status = htonl((u_int32_t) ct->status);
@@ -1135,6 +1146,33 @@ nfattr_failure:
1135} 1146}
1136 1147
1137static inline int 1148static inline int
1149ctnetlink_exp_dump_mask(struct sk_buff *skb,
1150 const struct ip_conntrack_tuple *tuple,
1151 const struct ip_conntrack_tuple *mask)
1152{
1153 int ret;
1154 struct ip_conntrack_protocol *proto;
1155 struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
1156
1157 ret = ctnetlink_dump_tuples_ip(skb, mask);
1158 if (unlikely(ret < 0))
1159 goto nfattr_failure;
1160
1161 proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
1162 ret = ctnetlink_dump_tuples_proto(skb, mask, proto);
1163 ip_conntrack_proto_put(proto);
1164 if (unlikely(ret < 0))
1165 goto nfattr_failure;
1166
1167 NFA_NEST_END(skb, nest_parms);
1168
1169 return 0;
1170
1171nfattr_failure:
1172 return -1;
1173}
1174
1175static inline int
1138ctnetlink_exp_dump_expect(struct sk_buff *skb, 1176ctnetlink_exp_dump_expect(struct sk_buff *skb,
1139 const struct ip_conntrack_expect *exp) 1177 const struct ip_conntrack_expect *exp)
1140{ 1178{
@@ -1144,7 +1182,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1144 1182
1145 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) 1183 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
1146 goto nfattr_failure; 1184 goto nfattr_failure;
1147 if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0) 1185 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
1148 goto nfattr_failure; 1186 goto nfattr_failure;
1149 if (ctnetlink_exp_dump_tuple(skb, 1187 if (ctnetlink_exp_dump_tuple(skb,
1150 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 1188 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 39705f9bc154..a7b194c4d79d 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -1335,12 +1335,14 @@ icmp_checkentry(const char *tablename,
1335static struct ipt_target ipt_standard_target = { 1335static struct ipt_target ipt_standard_target = {
1336 .name = IPT_STANDARD_TARGET, 1336 .name = IPT_STANDARD_TARGET,
1337 .targetsize = sizeof(int), 1337 .targetsize = sizeof(int),
1338 .family = AF_INET,
1338}; 1339};
1339 1340
1340static struct ipt_target ipt_error_target = { 1341static struct ipt_target ipt_error_target = {
1341 .name = IPT_ERROR_TARGET, 1342 .name = IPT_ERROR_TARGET,
1342 .target = ipt_error, 1343 .target = ipt_error,
1343 .targetsize = IPT_FUNCTION_MAXNAMELEN, 1344 .targetsize = IPT_FUNCTION_MAXNAMELEN,
1345 .family = AF_INET,
1344}; 1346};
1345 1347
1346static struct nf_sockopt_ops ipt_sockopts = { 1348static struct nf_sockopt_ops ipt_sockopts = {
@@ -1358,6 +1360,7 @@ static struct ipt_match icmp_matchstruct = {
1358 .match = icmp_match, 1360 .match = icmp_match,
1359 .matchsize = sizeof(struct ipt_icmp), 1361 .matchsize = sizeof(struct ipt_icmp),
1360 .proto = IPPROTO_ICMP, 1362 .proto = IPPROTO_ICMP,
1363 .family = AF_INET,
1361 .checkentry = icmp_checkentry, 1364 .checkentry = icmp_checkentry,
1362}; 1365};
1363 1366
@@ -1368,9 +1371,9 @@ static int __init init(void)
1368 xt_proto_init(AF_INET); 1371 xt_proto_init(AF_INET);
1369 1372
1370 /* Noone else will be downing sem now, so we won't sleep */ 1373 /* Noone else will be downing sem now, so we won't sleep */
1371 xt_register_target(AF_INET, &ipt_standard_target); 1374 xt_register_target(&ipt_standard_target);
1372 xt_register_target(AF_INET, &ipt_error_target); 1375 xt_register_target(&ipt_error_target);
1373 xt_register_match(AF_INET, &icmp_matchstruct); 1376 xt_register_match(&icmp_matchstruct);
1374 1377
1375 /* Register setsockopt */ 1378 /* Register setsockopt */
1376 ret = nf_register_sockopt(&ipt_sockopts); 1379 ret = nf_register_sockopt(&ipt_sockopts);
@@ -1387,9 +1390,9 @@ static void __exit fini(void)
1387{ 1390{
1388 nf_unregister_sockopt(&ipt_sockopts); 1391 nf_unregister_sockopt(&ipt_sockopts);
1389 1392
1390 xt_unregister_match(AF_INET, &icmp_matchstruct); 1393 xt_unregister_match(&icmp_matchstruct);
1391 xt_unregister_target(AF_INET, &ipt_error_target); 1394 xt_unregister_target(&ipt_error_target);
1392 xt_unregister_target(AF_INET, &ipt_standard_target); 1395 xt_unregister_target(&ipt_standard_target);
1393 1396
1394 xt_proto_fini(AF_INET); 1397 xt_proto_fini(AF_INET);
1395} 1398}
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index cb9c661f3f33..c8abc9d859b9 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -568,6 +568,7 @@ static int init_or_cleanup(int init)
568 return ret; 568 return ret;
569} 569}
570 570
571MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
571MODULE_LICENSE("GPL"); 572MODULE_LICENSE("GPL");
572 573
573static int __init init(void) 574static int __init init(void)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 602feec47738..4c20eeb3d568 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -907,7 +907,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
907 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 907 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
908#ifdef CONFIG_NETFILTER 908#ifdef CONFIG_NETFILTER
909 /* we need to exclude all possible EINVALs except default case */ 909 /* we need to exclude all possible EINVALs except default case */
910 if (err == -ENOPROTOOPT && optname != IPV6_ADDRFORM && 910 if (err == -EINVAL && optname != IPV6_ADDRFORM &&
911 optname != MCAST_MSFILTER) { 911 optname != MCAST_MSFILTER) {
912 int len; 912 int len;
913 913
@@ -944,7 +944,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
944 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 944 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
945#ifdef CONFIG_NETFILTER 945#ifdef CONFIG_NETFILTER
946 /* we need to exclude all possible EINVALs except default case */ 946 /* we need to exclude all possible EINVALs except default case */
947 if (err == -ENOPROTOOPT && optname != IPV6_ADDRFORM && 947 if (err == -EINVAL && optname != IPV6_ADDRFORM &&
948 optname != MCAST_MSFILTER) { 948 optname != MCAST_MSFILTER) {
949 int len; 949 int len;
950 950
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 5a2063bda676..db3c9ae98e95 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1377,12 +1377,14 @@ icmp6_checkentry(const char *tablename,
1377static struct ip6t_target ip6t_standard_target = { 1377static struct ip6t_target ip6t_standard_target = {
1378 .name = IP6T_STANDARD_TARGET, 1378 .name = IP6T_STANDARD_TARGET,
1379 .targetsize = sizeof(int), 1379 .targetsize = sizeof(int),
1380 .family = AF_INET6,
1380}; 1381};
1381 1382
1382static struct ip6t_target ip6t_error_target = { 1383static struct ip6t_target ip6t_error_target = {
1383 .name = IP6T_ERROR_TARGET, 1384 .name = IP6T_ERROR_TARGET,
1384 .target = ip6t_error, 1385 .target = ip6t_error,
1385 .targetsize = IP6T_FUNCTION_MAXNAMELEN, 1386 .targetsize = IP6T_FUNCTION_MAXNAMELEN,
1387 .family = AF_INET6,
1386}; 1388};
1387 1389
1388static struct nf_sockopt_ops ip6t_sockopts = { 1390static struct nf_sockopt_ops ip6t_sockopts = {
@@ -1401,6 +1403,7 @@ static struct ip6t_match icmp6_matchstruct = {
1401 .matchsize = sizeof(struct ip6t_icmp), 1403 .matchsize = sizeof(struct ip6t_icmp),
1402 .checkentry = icmp6_checkentry, 1404 .checkentry = icmp6_checkentry,
1403 .proto = IPPROTO_ICMPV6, 1405 .proto = IPPROTO_ICMPV6,
1406 .family = AF_INET6,
1404}; 1407};
1405 1408
1406static int __init init(void) 1409static int __init init(void)
@@ -1410,9 +1413,9 @@ static int __init init(void)
1410 xt_proto_init(AF_INET6); 1413 xt_proto_init(AF_INET6);
1411 1414
1412 /* Noone else will be downing sem now, so we won't sleep */ 1415 /* Noone else will be downing sem now, so we won't sleep */
1413 xt_register_target(AF_INET6, &ip6t_standard_target); 1416 xt_register_target(&ip6t_standard_target);
1414 xt_register_target(AF_INET6, &ip6t_error_target); 1417 xt_register_target(&ip6t_error_target);
1415 xt_register_match(AF_INET6, &icmp6_matchstruct); 1418 xt_register_match(&icmp6_matchstruct);
1416 1419
1417 /* Register setsockopt */ 1420 /* Register setsockopt */
1418 ret = nf_register_sockopt(&ip6t_sockopts); 1421 ret = nf_register_sockopt(&ip6t_sockopts);
@@ -1429,9 +1432,9 @@ static int __init init(void)
1429static void __exit fini(void) 1432static void __exit fini(void)
1430{ 1433{
1431 nf_unregister_sockopt(&ip6t_sockopts); 1434 nf_unregister_sockopt(&ip6t_sockopts);
1432 xt_unregister_match(AF_INET6, &icmp6_matchstruct); 1435 xt_unregister_match(&icmp6_matchstruct);
1433 xt_unregister_target(AF_INET6, &ip6t_error_target); 1436 xt_unregister_target(&ip6t_error_target);
1434 xt_unregister_target(AF_INET6, &ip6t_standard_target); 1437 xt_unregister_target(&ip6t_standard_target);
1435 xt_proto_fini(AF_INET6); 1438 xt_proto_fini(AF_INET6);
1436} 1439}
1437 1440
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index ac35f9526368..c16f62934bd9 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -584,6 +584,7 @@ static int init_or_cleanup(int init)
584 return ret; 584 return ret;
585} 585}
586 586
587MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6));
587MODULE_LICENSE("GPL"); 588MODULE_LICENSE("GPL");
588MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>"); 589MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>");
589 590
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 174027809148..332acb37b385 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -11,7 +11,7 @@ config NETFILTER_NETLINK_QUEUE
11 tristate "Netfilter NFQUEUE over NFNETLINK interface" 11 tristate "Netfilter NFQUEUE over NFNETLINK interface"
12 depends on NETFILTER_NETLINK 12 depends on NETFILTER_NETLINK
13 help 13 help
14 If this option isenabled, the kernel will include support 14 If this option is enabled, the kernel will include support
15 for queueing packets via NFNETLINK. 15 for queueing packets via NFNETLINK.
16 16
17config NETFILTER_NETLINK_LOG 17config NETFILTER_NETLINK_LOG
@@ -66,7 +66,7 @@ config NF_CONNTRACK_EVENTS
66 help 66 help
67 If this option is enabled, the connection tracking code will 67 If this option is enabled, the connection tracking code will
68 provide a notifier chain that can be used by other kernel code 68 provide a notifier chain that can be used by other kernel code
69 to get notified aboutchanges in the connection tracking state. 69 to get notified about changes in the connection tracking state.
70 70
71 If unsure, say `N'. 71 If unsure, say `N'.
72 72
@@ -153,7 +153,7 @@ config NETFILTER_XT_TARGET_NFQUEUE
153 tristate '"NFQUEUE" target Support' 153 tristate '"NFQUEUE" target Support'
154 depends on NETFILTER_XTABLES 154 depends on NETFILTER_XTABLES
155 help 155 help
156 This Target replaced the old obsolete QUEUE target. 156 This target replaced the old obsolete QUEUE target.
157 157
158 As opposed to QUEUE, it supports 65535 different queues, 158 As opposed to QUEUE, it supports 65535 different queues,
159 not just one. 159 not just one.
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index f6498234e264..0ae281d9bfc3 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -23,6 +23,8 @@
23 * 26 Jan 2006: Harald Welte <laforge@netfilter.org> 23 * 26 Jan 2006: Harald Welte <laforge@netfilter.org>
24 * - restructure nf_conn (introduce nf_conn_help) 24 * - restructure nf_conn (introduce nf_conn_help)
25 * - redesign 'features' how they were originally intended 25 * - redesign 'features' how they were originally intended
26 * 26 Feb 2006: Pablo Neira Ayuso <pablo@eurodev.net>
27 * - add support for L3 protocol module load on demand.
26 * 28 *
27 * Derived from net/ipv4/netfilter/ip_conntrack_core.c 29 * Derived from net/ipv4/netfilter/ip_conntrack_core.c
28 */ 30 */
@@ -85,8 +87,8 @@ unsigned int nf_ct_log_invalid;
85static LIST_HEAD(unconfirmed); 87static LIST_HEAD(unconfirmed);
86static int nf_conntrack_vmalloc; 88static int nf_conntrack_vmalloc;
87 89
88static unsigned int nf_conntrack_next_id = 1; 90static unsigned int nf_conntrack_next_id;
89static unsigned int nf_conntrack_expect_next_id = 1; 91static unsigned int nf_conntrack_expect_next_id;
90#ifdef CONFIG_NF_CONNTRACK_EVENTS 92#ifdef CONFIG_NF_CONNTRACK_EVENTS
91struct notifier_block *nf_conntrack_chain; 93struct notifier_block *nf_conntrack_chain;
92struct notifier_block *nf_conntrack_expect_chain; 94struct notifier_block *nf_conntrack_expect_chain;
@@ -241,6 +243,35 @@ void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p)
241 module_put(p->me); 243 module_put(p->me);
242} 244}
243 245
246int
247nf_ct_l3proto_try_module_get(unsigned short l3proto)
248{
249 int ret;
250 struct nf_conntrack_l3proto *p;
251
252retry: p = nf_ct_l3proto_find_get(l3proto);
253 if (p == &nf_conntrack_generic_l3proto) {
254 ret = request_module("nf_conntrack-%d", l3proto);
255 if (!ret)
256 goto retry;
257
258 return -EPROTOTYPE;
259 }
260
261 return 0;
262}
263
264void nf_ct_l3proto_module_put(unsigned short l3proto)
265{
266 struct nf_conntrack_l3proto *p;
267
268 preempt_disable();
269 p = __nf_ct_l3proto_find(l3proto);
270 preempt_enable();
271
272 module_put(p->me);
273}
274
244static int nf_conntrack_hash_rnd_initted; 275static int nf_conntrack_hash_rnd_initted;
245static unsigned int nf_conntrack_hash_rnd; 276static unsigned int nf_conntrack_hash_rnd;
246 277
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 5eadf009bb15..0e0e9d7b34c8 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -4,7 +4,7 @@
4 * (C) 2001 by Jay Schulist <jschlst@samba.org> 4 * (C) 2001 by Jay Schulist <jschlst@samba.org>
5 * (C) 2002-2006 by Harald Welte <laforge@gnumonks.org> 5 * (C) 2002-2006 by Harald Welte <laforge@gnumonks.org>
6 * (C) 2003 by Patrick Mchardy <kaber@trash.net> 6 * (C) 2003 by Patrick Mchardy <kaber@trash.net>
7 * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net> 7 * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
8 * 8 *
9 * I've reworked this stuff to use attributes instead of conntrack 9 * I've reworked this stuff to use attributes instead of conntrack
10 * structures. 5.44 am. I need more tea. --pablo 05/07/11. 10 * structures. 5.44 am. I need more tea. --pablo 05/07/11.
@@ -55,20 +55,18 @@ static char __initdata version[] = "0.93";
55 55
56static inline int 56static inline int
57ctnetlink_dump_tuples_proto(struct sk_buff *skb, 57ctnetlink_dump_tuples_proto(struct sk_buff *skb,
58 const struct nf_conntrack_tuple *tuple) 58 const struct nf_conntrack_tuple *tuple,
59 struct nf_conntrack_protocol *proto)
59{ 60{
60 struct nf_conntrack_protocol *proto;
61 int ret = 0; 61 int ret = 0;
62 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
62 63
63 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum); 64 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
64 65
65 /* If no protocol helper is found, this function will return the
66 * generic protocol helper, so proto won't *ever* be NULL */
67 proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
68 if (likely(proto->tuple_to_nfattr)) 66 if (likely(proto->tuple_to_nfattr))
69 ret = proto->tuple_to_nfattr(skb, tuple); 67 ret = proto->tuple_to_nfattr(skb, tuple);
70 68
71 nf_ct_proto_put(proto); 69 NFA_NEST_END(skb, nest_parms);
72 70
73 return ret; 71 return ret;
74 72
@@ -77,33 +75,44 @@ nfattr_failure:
77} 75}
78 76
79static inline int 77static inline int
80ctnetlink_dump_tuples(struct sk_buff *skb, 78ctnetlink_dump_tuples_ip(struct sk_buff *skb,
81 const struct nf_conntrack_tuple *tuple) 79 const struct nf_conntrack_tuple *tuple,
80 struct nf_conntrack_l3proto *l3proto)
82{ 81{
83 struct nfattr *nest_parms;
84 struct nf_conntrack_l3proto *l3proto;
85 int ret = 0; 82 int ret = 0;
86 83 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
87 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num); 84
88
89 nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
90 if (likely(l3proto->tuple_to_nfattr)) 85 if (likely(l3proto->tuple_to_nfattr))
91 ret = l3proto->tuple_to_nfattr(skb, tuple); 86 ret = l3proto->tuple_to_nfattr(skb, tuple);
87
92 NFA_NEST_END(skb, nest_parms); 88 NFA_NEST_END(skb, nest_parms);
93 89
90 return ret;
91
92nfattr_failure:
93 return -1;
94}
95
96static inline int
97ctnetlink_dump_tuples(struct sk_buff *skb,
98 const struct nf_conntrack_tuple *tuple)
99{
100 int ret;
101 struct nf_conntrack_l3proto *l3proto;
102 struct nf_conntrack_protocol *proto;
103
104 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
105 ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
94 nf_ct_l3proto_put(l3proto); 106 nf_ct_l3proto_put(l3proto);
95 107
96 if (unlikely(ret < 0)) 108 if (unlikely(ret < 0))
97 return ret; 109 return ret;
98 110
99 nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO); 111 proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
100 ret = ctnetlink_dump_tuples_proto(skb, tuple); 112 ret = ctnetlink_dump_tuples_proto(skb, tuple, proto);
101 NFA_NEST_END(skb, nest_parms); 113 nf_ct_proto_put(proto);
102 114
103 return ret; 115 return ret;
104
105nfattr_failure:
106 return -1;
107} 116}
108 117
109static inline int 118static inline int
@@ -1153,6 +1162,37 @@ nfattr_failure:
1153} 1162}
1154 1163
1155static inline int 1164static inline int
1165ctnetlink_exp_dump_mask(struct sk_buff *skb,
1166 const struct nf_conntrack_tuple *tuple,
1167 const struct nf_conntrack_tuple *mask)
1168{
1169 int ret;
1170 struct nf_conntrack_l3proto *l3proto;
1171 struct nf_conntrack_protocol *proto;
1172 struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
1173
1174 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
1175 ret = ctnetlink_dump_tuples_ip(skb, mask, l3proto);
1176 nf_ct_l3proto_put(l3proto);
1177
1178 if (unlikely(ret < 0))
1179 goto nfattr_failure;
1180
1181 proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
1182 ret = ctnetlink_dump_tuples_proto(skb, mask, proto);
1183 nf_ct_proto_put(proto);
1184 if (unlikely(ret < 0))
1185 goto nfattr_failure;
1186
1187 NFA_NEST_END(skb, nest_parms);
1188
1189 return 0;
1190
1191nfattr_failure:
1192 return -1;
1193}
1194
1195static inline int
1156ctnetlink_exp_dump_expect(struct sk_buff *skb, 1196ctnetlink_exp_dump_expect(struct sk_buff *skb,
1157 const struct nf_conntrack_expect *exp) 1197 const struct nf_conntrack_expect *exp)
1158{ 1198{
@@ -1162,7 +1202,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1162 1202
1163 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) 1203 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
1164 goto nfattr_failure; 1204 goto nfattr_failure;
1165 if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0) 1205 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
1166 goto nfattr_failure; 1206 goto nfattr_failure;
1167 if (ctnetlink_exp_dump_tuple(skb, 1207 if (ctnetlink_exp_dump_tuple(skb,
1168 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 1208 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 290d5a0c559b..75577e175b35 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -834,6 +834,8 @@ EXPORT_SYMBOL_GPL(__nf_ct_event_cache_init);
834EXPORT_PER_CPU_SYMBOL_GPL(nf_conntrack_ecache); 834EXPORT_PER_CPU_SYMBOL_GPL(nf_conntrack_ecache);
835EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events); 835EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);
836#endif 836#endif
837EXPORT_SYMBOL(nf_ct_l3proto_try_module_get);
838EXPORT_SYMBOL(nf_ct_l3proto_module_put);
837EXPORT_SYMBOL(nf_conntrack_l3proto_register); 839EXPORT_SYMBOL(nf_conntrack_l3proto_register);
838EXPORT_SYMBOL(nf_conntrack_l3proto_unregister); 840EXPORT_SYMBOL(nf_conntrack_l3proto_unregister);
839EXPORT_SYMBOL(nf_conntrack_protocol_register); 841EXPORT_SYMBOL(nf_conntrack_protocol_register);
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 2cf5fb8322c4..b5701662182e 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -354,16 +354,17 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
354 QDEBUG("entered\n"); 354 QDEBUG("entered\n");
355 355
356 /* all macros expand to constant values at compile time */ 356 /* all macros expand to constant values at compile time */
357 size = NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hdr)) 357 size = NLMSG_SPACE(sizeof(struct nfgenmsg)) +
358 + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */ 358 + NFA_SPACE(sizeof(struct nfqnl_msg_packet_hdr))
359 + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */ 359 + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
360 + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
360#ifdef CONFIG_BRIDGE_NETFILTER 361#ifdef CONFIG_BRIDGE_NETFILTER
361 + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */ 362 + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
362 + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */ 363 + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
363#endif 364#endif
364 + NLMSG_SPACE(sizeof(u_int32_t)) /* mark */ 365 + NFA_SPACE(sizeof(u_int32_t)) /* mark */
365 + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hw)) 366 + NFA_SPACE(sizeof(struct nfqnl_msg_packet_hw))
366 + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_timestamp)); 367 + NFA_SPACE(sizeof(struct nfqnl_msg_packet_timestamp));
367 368
368 outdev = entinf->outdev; 369 outdev = entinf->outdev;
369 370
@@ -388,7 +389,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
388 else 389 else
389 data_len = queue->copy_range; 390 data_len = queue->copy_range;
390 391
391 size += NLMSG_SPACE(data_len); 392 size += NFA_SPACE(data_len);
392 break; 393 break;
393 394
394 default: 395 default:
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 750b92829766..0a29a24d9a72 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -60,9 +60,9 @@ static const char *xt_prefix[NPROTO] = {
60 60
61/* Registration hooks for targets. */ 61/* Registration hooks for targets. */
62int 62int
63xt_register_target(int af, struct xt_target *target) 63xt_register_target(struct xt_target *target)
64{ 64{
65 int ret; 65 int ret, af = target->family;
66 66
67 ret = down_interruptible(&xt[af].mutex); 67 ret = down_interruptible(&xt[af].mutex);
68 if (ret != 0) 68 if (ret != 0)
@@ -74,8 +74,10 @@ xt_register_target(int af, struct xt_target *target)
74EXPORT_SYMBOL(xt_register_target); 74EXPORT_SYMBOL(xt_register_target);
75 75
76void 76void
77xt_unregister_target(int af, struct xt_target *target) 77xt_unregister_target(struct xt_target *target)
78{ 78{
79 int af = target->family;
80
79 down(&xt[af].mutex); 81 down(&xt[af].mutex);
80 LIST_DELETE(&xt[af].target, target); 82 LIST_DELETE(&xt[af].target, target);
81 up(&xt[af].mutex); 83 up(&xt[af].mutex);
@@ -83,9 +85,9 @@ xt_unregister_target(int af, struct xt_target *target)
83EXPORT_SYMBOL(xt_unregister_target); 85EXPORT_SYMBOL(xt_unregister_target);
84 86
85int 87int
86xt_register_match(int af, struct xt_match *match) 88xt_register_match(struct xt_match *match)
87{ 89{
88 int ret; 90 int ret, af = match->family;
89 91
90 ret = down_interruptible(&xt[af].mutex); 92 ret = down_interruptible(&xt[af].mutex);
91 if (ret != 0) 93 if (ret != 0)
@@ -99,8 +101,10 @@ xt_register_match(int af, struct xt_match *match)
99EXPORT_SYMBOL(xt_register_match); 101EXPORT_SYMBOL(xt_register_match);
100 102
101void 103void
102xt_unregister_match(int af, struct xt_match *match) 104xt_unregister_match(struct xt_match *match)
103{ 105{
106 int af = match->family;
107
104 down(&xt[af].mutex); 108 down(&xt[af].mutex);
105 LIST_DELETE(&xt[af].match, match); 109 LIST_DELETE(&xt[af].match, match);
106 up(&xt[af].mutex); 110 up(&xt[af].mutex);
diff --git a/net/netfilter/xt_CLASSIFY.c b/net/netfilter/xt_CLASSIFY.c
index 3224ed87d4c7..3cd2ac90a25b 100644
--- a/net/netfilter/xt_CLASSIFY.c
+++ b/net/netfilter/xt_CLASSIFY.c
@@ -47,6 +47,7 @@ static struct xt_target classify_reg = {
47 .table = "mangle", 47 .table = "mangle",
48 .hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) | 48 .hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
49 (1 << NF_IP_POST_ROUTING), 49 (1 << NF_IP_POST_ROUTING),
50 .family = AF_INET,
50 .me = THIS_MODULE, 51 .me = THIS_MODULE,
51}; 52};
52static struct xt_target classify6_reg = { 53static struct xt_target classify6_reg = {
@@ -56,6 +57,7 @@ static struct xt_target classify6_reg = {
56 .table = "mangle", 57 .table = "mangle",
57 .hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) | 58 .hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
58 (1 << NF_IP_POST_ROUTING), 59 (1 << NF_IP_POST_ROUTING),
60 .family = AF_INET6,
59 .me = THIS_MODULE, 61 .me = THIS_MODULE,
60}; 62};
61 63
@@ -64,21 +66,21 @@ static int __init init(void)
64{ 66{
65 int ret; 67 int ret;
66 68
67 ret = xt_register_target(AF_INET, &classify_reg); 69 ret = xt_register_target(&classify_reg);
68 if (ret) 70 if (ret)
69 return ret; 71 return ret;
70 72
71 ret = xt_register_target(AF_INET6, &classify6_reg); 73 ret = xt_register_target(&classify6_reg);
72 if (ret) 74 if (ret)
73 xt_unregister_target(AF_INET, &classify_reg); 75 xt_unregister_target(&classify_reg);
74 76
75 return ret; 77 return ret;
76} 78}
77 79
78static void __exit fini(void) 80static void __exit fini(void)
79{ 81{
80 xt_unregister_target(AF_INET, &classify_reg); 82 xt_unregister_target(&classify_reg);
81 xt_unregister_target(AF_INET6, &classify6_reg); 83 xt_unregister_target(&classify6_reg);
82} 84}
83 85
84module_init(init); 86module_init(init);
diff --git a/net/netfilter/xt_CONNMARK.c b/net/netfilter/xt_CONNMARK.c
index df2486a3efd5..35448b8e6883 100644
--- a/net/netfilter/xt_CONNMARK.c
+++ b/net/netfilter/xt_CONNMARK.c
@@ -102,6 +102,7 @@ static struct xt_target connmark_reg = {
102 .target = target, 102 .target = target,
103 .targetsize = sizeof(struct xt_connmark_target_info), 103 .targetsize = sizeof(struct xt_connmark_target_info),
104 .checkentry = checkentry, 104 .checkentry = checkentry,
105 .family = AF_INET,
105 .me = THIS_MODULE 106 .me = THIS_MODULE
106}; 107};
107 108
@@ -110,6 +111,7 @@ static struct xt_target connmark6_reg = {
110 .target = target, 111 .target = target,
111 .targetsize = sizeof(struct xt_connmark_target_info), 112 .targetsize = sizeof(struct xt_connmark_target_info),
112 .checkentry = checkentry, 113 .checkentry = checkentry,
114 .family = AF_INET6,
113 .me = THIS_MODULE 115 .me = THIS_MODULE
114}; 116};
115 117
@@ -119,21 +121,21 @@ static int __init init(void)
119 121
120 need_conntrack(); 122 need_conntrack();
121 123
122 ret = xt_register_target(AF_INET, &connmark_reg); 124 ret = xt_register_target(&connmark_reg);
123 if (ret) 125 if (ret)
124 return ret; 126 return ret;
125 127
126 ret = xt_register_target(AF_INET6, &connmark6_reg); 128 ret = xt_register_target(&connmark6_reg);
127 if (ret) 129 if (ret)
128 xt_unregister_target(AF_INET, &connmark_reg); 130 xt_unregister_target(&connmark_reg);
129 131
130 return ret; 132 return ret;
131} 133}
132 134
133static void __exit fini(void) 135static void __exit fini(void)
134{ 136{
135 xt_unregister_target(AF_INET, &connmark_reg); 137 xt_unregister_target(&connmark_reg);
136 xt_unregister_target(AF_INET6, &connmark6_reg); 138 xt_unregister_target(&connmark6_reg);
137} 139}
138 140
139module_init(init); 141module_init(init);
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c
index dcb5266efae0..73bdd5c80e17 100644
--- a/net/netfilter/xt_MARK.c
+++ b/net/netfilter/xt_MARK.c
@@ -119,6 +119,7 @@ static struct xt_target ipt_mark_reg_v0 = {
119 .table = "mangle", 119 .table = "mangle",
120 .checkentry = checkentry_v0, 120 .checkentry = checkentry_v0,
121 .me = THIS_MODULE, 121 .me = THIS_MODULE,
122 .family = AF_INET,
122 .revision = 0, 123 .revision = 0,
123}; 124};
124 125
@@ -129,6 +130,7 @@ static struct xt_target ipt_mark_reg_v1 = {
129 .table = "mangle", 130 .table = "mangle",
130 .checkentry = checkentry_v1, 131 .checkentry = checkentry_v1,
131 .me = THIS_MODULE, 132 .me = THIS_MODULE,
133 .family = AF_INET,
132 .revision = 1, 134 .revision = 1,
133}; 135};
134 136
@@ -139,6 +141,7 @@ static struct xt_target ip6t_mark_reg_v0 = {
139 .table = "mangle", 141 .table = "mangle",
140 .checkentry = checkentry_v0, 142 .checkentry = checkentry_v0,
141 .me = THIS_MODULE, 143 .me = THIS_MODULE,
144 .family = AF_INET6,
142 .revision = 0, 145 .revision = 0,
143}; 146};
144 147
@@ -146,18 +149,18 @@ static int __init init(void)
146{ 149{
147 int err; 150 int err;
148 151
149 err = xt_register_target(AF_INET, &ipt_mark_reg_v0); 152 err = xt_register_target(&ipt_mark_reg_v0);
150 if (err) 153 if (err)
151 return err; 154 return err;
152 155
153 err = xt_register_target(AF_INET, &ipt_mark_reg_v1); 156 err = xt_register_target(&ipt_mark_reg_v1);
154 if (err) 157 if (err)
155 xt_unregister_target(AF_INET, &ipt_mark_reg_v0); 158 xt_unregister_target(&ipt_mark_reg_v0);
156 159
157 err = xt_register_target(AF_INET6, &ip6t_mark_reg_v0); 160 err = xt_register_target(&ip6t_mark_reg_v0);
158 if (err) { 161 if (err) {
159 xt_unregister_target(AF_INET, &ipt_mark_reg_v0); 162 xt_unregister_target(&ipt_mark_reg_v0);
160 xt_unregister_target(AF_INET, &ipt_mark_reg_v1); 163 xt_unregister_target(&ipt_mark_reg_v1);
161 } 164 }
162 165
163 return err; 166 return err;
@@ -165,9 +168,9 @@ static int __init init(void)
165 168
166static void __exit fini(void) 169static void __exit fini(void)
167{ 170{
168 xt_unregister_target(AF_INET, &ipt_mark_reg_v0); 171 xt_unregister_target(&ipt_mark_reg_v0);
169 xt_unregister_target(AF_INET, &ipt_mark_reg_v1); 172 xt_unregister_target(&ipt_mark_reg_v1);
170 xt_unregister_target(AF_INET6, &ip6t_mark_reg_v0); 173 xt_unregister_target(&ip6t_mark_reg_v0);
171} 174}
172 175
173module_init(init); 176module_init(init);
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
index 39a963edf16b..2873e1c60f68 100644
--- a/net/netfilter/xt_NFQUEUE.c
+++ b/net/netfilter/xt_NFQUEUE.c
@@ -41,6 +41,7 @@ static struct xt_target ipt_NFQ_reg = {
41 .name = "NFQUEUE", 41 .name = "NFQUEUE",
42 .target = target, 42 .target = target,
43 .targetsize = sizeof(struct xt_NFQ_info), 43 .targetsize = sizeof(struct xt_NFQ_info),
44 .family = AF_INET,
44 .me = THIS_MODULE, 45 .me = THIS_MODULE,
45}; 46};
46 47
@@ -48,6 +49,7 @@ static struct xt_target ip6t_NFQ_reg = {
48 .name = "NFQUEUE", 49 .name = "NFQUEUE",
49 .target = target, 50 .target = target,
50 .targetsize = sizeof(struct xt_NFQ_info), 51 .targetsize = sizeof(struct xt_NFQ_info),
52 .family = AF_INET6,
51 .me = THIS_MODULE, 53 .me = THIS_MODULE,
52}; 54};
53 55
@@ -55,36 +57,37 @@ static struct xt_target arpt_NFQ_reg = {
55 .name = "NFQUEUE", 57 .name = "NFQUEUE",
56 .target = target, 58 .target = target,
57 .targetsize = sizeof(struct xt_NFQ_info), 59 .targetsize = sizeof(struct xt_NFQ_info),
60 .family = NF_ARP,
58 .me = THIS_MODULE, 61 .me = THIS_MODULE,
59}; 62};
60 63
61static int __init init(void) 64static int __init init(void)
62{ 65{
63 int ret; 66 int ret;
64 ret = xt_register_target(AF_INET, &ipt_NFQ_reg); 67 ret = xt_register_target(&ipt_NFQ_reg);
65 if (ret) 68 if (ret)
66 return ret; 69 return ret;
67 ret = xt_register_target(AF_INET6, &ip6t_NFQ_reg); 70 ret = xt_register_target(&ip6t_NFQ_reg);
68 if (ret) 71 if (ret)
69 goto out_ip; 72 goto out_ip;
70 ret = xt_register_target(NF_ARP, &arpt_NFQ_reg); 73 ret = xt_register_target(&arpt_NFQ_reg);
71 if (ret) 74 if (ret)
72 goto out_ip6; 75 goto out_ip6;
73 76
74 return ret; 77 return ret;
75out_ip6: 78out_ip6:
76 xt_unregister_target(AF_INET6, &ip6t_NFQ_reg); 79 xt_unregister_target(&ip6t_NFQ_reg);
77out_ip: 80out_ip:
78 xt_unregister_target(AF_INET, &ipt_NFQ_reg); 81 xt_unregister_target(&ipt_NFQ_reg);
79 82
80 return ret; 83 return ret;
81} 84}
82 85
83static void __exit fini(void) 86static void __exit fini(void)
84{ 87{
85 xt_unregister_target(NF_ARP, &arpt_NFQ_reg); 88 xt_unregister_target(&arpt_NFQ_reg);
86 xt_unregister_target(AF_INET6, &ip6t_NFQ_reg); 89 xt_unregister_target(&ip6t_NFQ_reg);
87 xt_unregister_target(AF_INET, &ipt_NFQ_reg); 90 xt_unregister_target(&ipt_NFQ_reg);
88} 91}
89 92
90module_init(init); 93module_init(init);
diff --git a/net/netfilter/xt_NOTRACK.c b/net/netfilter/xt_NOTRACK.c
index b8634e3f6169..cf2ebd76fd6f 100644
--- a/net/netfilter/xt_NOTRACK.c
+++ b/net/netfilter/xt_NOTRACK.c
@@ -39,6 +39,7 @@ static struct xt_target notrack_reg = {
39 .target = target, 39 .target = target,
40 .targetsize = 0, 40 .targetsize = 0,
41 .table = "raw", 41 .table = "raw",
42 .family = AF_INET,
42 .me = THIS_MODULE, 43 .me = THIS_MODULE,
43}; 44};
44 45
@@ -47,6 +48,7 @@ static struct xt_target notrack6_reg = {
47 .target = target, 48 .target = target,
48 .targetsize = 0, 49 .targetsize = 0,
49 .table = "raw", 50 .table = "raw",
51 .family = AF_INET6,
50 .me = THIS_MODULE, 52 .me = THIS_MODULE,
51}; 53};
52 54
@@ -54,21 +56,21 @@ static int __init init(void)
54{ 56{
55 int ret; 57 int ret;
56 58
57 ret = xt_register_target(AF_INET, &notrack_reg); 59 ret = xt_register_target(&notrack_reg);
58 if (ret) 60 if (ret)
59 return ret; 61 return ret;
60 62
61 ret = xt_register_target(AF_INET6, &notrack6_reg); 63 ret = xt_register_target(&notrack6_reg);
62 if (ret) 64 if (ret)
63 xt_unregister_target(AF_INET, &notrack_reg); 65 xt_unregister_target(&notrack_reg);
64 66
65 return ret; 67 return ret;
66} 68}
67 69
68static void __exit fini(void) 70static void __exit fini(void)
69{ 71{
70 xt_unregister_target(AF_INET6, &notrack6_reg); 72 xt_unregister_target(&notrack6_reg);
71 xt_unregister_target(AF_INET, &notrack_reg); 73 xt_unregister_target(&notrack_reg);
72} 74}
73 75
74module_init(init); 76module_init(init);
diff --git a/net/netfilter/xt_comment.c b/net/netfilter/xt_comment.c
index 03d9d741231c..2637724b498d 100644
--- a/net/netfilter/xt_comment.c
+++ b/net/netfilter/xt_comment.c
@@ -33,6 +33,7 @@ static struct xt_match comment_match = {
33 .name = "comment", 33 .name = "comment",
34 .match = match, 34 .match = match,
35 .matchsize = sizeof(struct xt_comment_info), 35 .matchsize = sizeof(struct xt_comment_info),
36 .family = AF_INET,
36 .me = THIS_MODULE 37 .me = THIS_MODULE
37}; 38};
38 39
@@ -40,6 +41,7 @@ static struct xt_match comment6_match = {
40 .name = "comment", 41 .name = "comment",
41 .match = match, 42 .match = match,
42 .matchsize = sizeof(struct xt_comment_info), 43 .matchsize = sizeof(struct xt_comment_info),
44 .family = AF_INET6,
43 .me = THIS_MODULE 45 .me = THIS_MODULE
44}; 46};
45 47
@@ -47,21 +49,21 @@ static int __init init(void)
47{ 49{
48 int ret; 50 int ret;
49 51
50 ret = xt_register_match(AF_INET, &comment_match); 52 ret = xt_register_match(&comment_match);
51 if (ret) 53 if (ret)
52 return ret; 54 return ret;
53 55
54 ret = xt_register_match(AF_INET6, &comment6_match); 56 ret = xt_register_match(&comment6_match);
55 if (ret) 57 if (ret)
56 xt_unregister_match(AF_INET, &comment_match); 58 xt_unregister_match(&comment_match);
57 59
58 return ret; 60 return ret;
59} 61}
60 62
61static void __exit fini(void) 63static void __exit fini(void)
62{ 64{
63 xt_unregister_match(AF_INET, &comment_match); 65 xt_unregister_match(&comment_match);
64 xt_unregister_match(AF_INET6, &comment6_match); 66 xt_unregister_match(&comment6_match);
65} 67}
66 68
67module_init(init); 69module_init(init);
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index f34ecb9485c7..4985f5ec58ca 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -148,6 +148,7 @@ static struct xt_match connbytes_match = {
148 .match = match, 148 .match = match,
149 .checkentry = check, 149 .checkentry = check,
150 .matchsize = sizeof(struct xt_connbytes_info), 150 .matchsize = sizeof(struct xt_connbytes_info),
151 .family = AF_INET,
151 .me = THIS_MODULE 152 .me = THIS_MODULE
152}; 153};
153static struct xt_match connbytes6_match = { 154static struct xt_match connbytes6_match = {
@@ -155,26 +156,27 @@ static struct xt_match connbytes6_match = {
155 .match = match, 156 .match = match,
156 .checkentry = check, 157 .checkentry = check,
157 .matchsize = sizeof(struct xt_connbytes_info), 158 .matchsize = sizeof(struct xt_connbytes_info),
159 .family = AF_INET6,
158 .me = THIS_MODULE 160 .me = THIS_MODULE
159}; 161};
160 162
161static int __init init(void) 163static int __init init(void)
162{ 164{
163 int ret; 165 int ret;
164 ret = xt_register_match(AF_INET, &connbytes_match); 166 ret = xt_register_match(&connbytes_match);
165 if (ret) 167 if (ret)
166 return ret; 168 return ret;
167 169
168 ret = xt_register_match(AF_INET6, &connbytes6_match); 170 ret = xt_register_match(&connbytes6_match);
169 if (ret) 171 if (ret)
170 xt_unregister_match(AF_INET, &connbytes_match); 172 xt_unregister_match(&connbytes_match);
171 return ret; 173 return ret;
172} 174}
173 175
174static void __exit fini(void) 176static void __exit fini(void)
175{ 177{
176 xt_unregister_match(AF_INET, &connbytes_match); 178 xt_unregister_match(&connbytes_match);
177 xt_unregister_match(AF_INET6, &connbytes6_match); 179 xt_unregister_match(&connbytes6_match);
178} 180}
179 181
180module_init(init); 182module_init(init);
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index 51822471e919..7b16f1ee16b4 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -64,14 +64,31 @@ checkentry(const char *tablename,
64 printk(KERN_WARNING "connmark: only support 32bit mark\n"); 64 printk(KERN_WARNING "connmark: only support 32bit mark\n");
65 return 0; 65 return 0;
66 } 66 }
67#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
68 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
69 printk(KERN_WARNING "can't load nf_conntrack support for "
70 "proto=%d\n", match->family);
71 return 0;
72 }
73#endif
67 return 1; 74 return 1;
68} 75}
69 76
77static void
78destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
79{
80#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
81 nf_ct_l3proto_module_put(match->family);
82#endif
83}
84
70static struct xt_match connmark_match = { 85static struct xt_match connmark_match = {
71 .name = "connmark", 86 .name = "connmark",
72 .match = match, 87 .match = match,
73 .matchsize = sizeof(struct xt_connmark_info), 88 .matchsize = sizeof(struct xt_connmark_info),
74 .checkentry = checkentry, 89 .checkentry = checkentry,
90 .destroy = destroy,
91 .family = AF_INET,
75 .me = THIS_MODULE 92 .me = THIS_MODULE
76}; 93};
77 94
@@ -80,6 +97,8 @@ static struct xt_match connmark6_match = {
80 .match = match, 97 .match = match,
81 .matchsize = sizeof(struct xt_connmark_info), 98 .matchsize = sizeof(struct xt_connmark_info),
82 .checkentry = checkentry, 99 .checkentry = checkentry,
100 .destroy = destroy,
101 .family = AF_INET6,
83 .me = THIS_MODULE 102 .me = THIS_MODULE
84}; 103};
85 104
@@ -89,20 +108,20 @@ static int __init init(void)
89 108
90 need_conntrack(); 109 need_conntrack();
91 110
92 ret = xt_register_match(AF_INET, &connmark_match); 111 ret = xt_register_match(&connmark_match);
93 if (ret) 112 if (ret)
94 return ret; 113 return ret;
95 114
96 ret = xt_register_match(AF_INET6, &connmark6_match); 115 ret = xt_register_match(&connmark6_match);
97 if (ret) 116 if (ret)
98 xt_unregister_match(AF_INET, &connmark_match); 117 xt_unregister_match(&connmark_match);
99 return ret; 118 return ret;
100} 119}
101 120
102static void __exit fini(void) 121static void __exit fini(void)
103{ 122{
104 xt_unregister_match(AF_INET6, &connmark6_match); 123 xt_unregister_match(&connmark6_match);
105 xt_unregister_match(AF_INET, &connmark_match); 124 xt_unregister_match(&connmark_match);
106} 125}
107 126
108module_init(init); 127module_init(init);
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 39fc29496e00..65a84809fd30 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -203,10 +203,39 @@ match(const struct sk_buff *skb,
203 203
204#endif /* CONFIG_NF_IP_CONNTRACK */ 204#endif /* CONFIG_NF_IP_CONNTRACK */
205 205
206static int
207checkentry(const char *tablename,
208 const void *ip,
209 const struct xt_match *match,
210 void *matchinfo,
211 unsigned int matchsize,
212 unsigned int hook_mask)
213{
214#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
215 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
216 printk(KERN_WARNING "can't load nf_conntrack support for "
217 "proto=%d\n", match->family);
218 return 0;
219 }
220#endif
221 return 1;
222}
223
224static void
225destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
226{
227#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
228 nf_ct_l3proto_module_put(match->family);
229#endif
230}
231
206static struct xt_match conntrack_match = { 232static struct xt_match conntrack_match = {
207 .name = "conntrack", 233 .name = "conntrack",
208 .match = match, 234 .match = match,
235 .checkentry = checkentry,
236 .destroy = destroy,
209 .matchsize = sizeof(struct xt_conntrack_info), 237 .matchsize = sizeof(struct xt_conntrack_info),
238 .family = AF_INET,
210 .me = THIS_MODULE, 239 .me = THIS_MODULE,
211}; 240};
212 241
@@ -214,14 +243,14 @@ static int __init init(void)
214{ 243{
215 int ret; 244 int ret;
216 need_conntrack(); 245 need_conntrack();
217 ret = xt_register_match(AF_INET, &conntrack_match); 246 ret = xt_register_match(&conntrack_match);
218 247
219 return ret; 248 return ret;
220} 249}
221 250
222static void __exit fini(void) 251static void __exit fini(void)
223{ 252{
224 xt_unregister_match(AF_INET, &conntrack_match); 253 xt_unregister_match(&conntrack_match);
225} 254}
226 255
227module_init(init); 256module_init(init);
diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index db6b70cdc770..2f331decd151 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -149,6 +149,7 @@ static struct xt_match dccp_match =
149 .matchsize = sizeof(struct xt_dccp_info), 149 .matchsize = sizeof(struct xt_dccp_info),
150 .proto = IPPROTO_DCCP, 150 .proto = IPPROTO_DCCP,
151 .checkentry = checkentry, 151 .checkentry = checkentry,
152 .family = AF_INET,
152 .me = THIS_MODULE, 153 .me = THIS_MODULE,
153}; 154};
154static struct xt_match dccp6_match = 155static struct xt_match dccp6_match =
@@ -158,6 +159,7 @@ static struct xt_match dccp6_match =
158 .matchsize = sizeof(struct xt_dccp_info), 159 .matchsize = sizeof(struct xt_dccp_info),
159 .proto = IPPROTO_DCCP, 160 .proto = IPPROTO_DCCP,
160 .checkentry = checkentry, 161 .checkentry = checkentry,
162 .family = AF_INET6,
161 .me = THIS_MODULE, 163 .me = THIS_MODULE,
162}; 164};
163 165
@@ -172,17 +174,17 @@ static int __init init(void)
172 dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL); 174 dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL);
173 if (!dccp_optbuf) 175 if (!dccp_optbuf)
174 return -ENOMEM; 176 return -ENOMEM;
175 ret = xt_register_match(AF_INET, &dccp_match); 177 ret = xt_register_match(&dccp_match);
176 if (ret) 178 if (ret)
177 goto out_kfree; 179 goto out_kfree;
178 ret = xt_register_match(AF_INET6, &dccp6_match); 180 ret = xt_register_match(&dccp6_match);
179 if (ret) 181 if (ret)
180 goto out_unreg; 182 goto out_unreg;
181 183
182 return ret; 184 return ret;
183 185
184out_unreg: 186out_unreg:
185 xt_unregister_match(AF_INET, &dccp_match); 187 xt_unregister_match(&dccp_match);
186out_kfree: 188out_kfree:
187 kfree(dccp_optbuf); 189 kfree(dccp_optbuf);
188 190
@@ -191,8 +193,8 @@ out_kfree:
191 193
192static void __exit fini(void) 194static void __exit fini(void)
193{ 195{
194 xt_unregister_match(AF_INET6, &dccp6_match); 196 xt_unregister_match(&dccp6_match);
195 xt_unregister_match(AF_INET, &dccp_match); 197 xt_unregister_match(&dccp_match);
196 kfree(dccp_optbuf); 198 kfree(dccp_optbuf);
197} 199}
198 200
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index ef8e54d40c92..101f0005e987 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -144,15 +144,32 @@ static int check(const char *tablename,
144{ 144{
145 struct xt_helper_info *info = matchinfo; 145 struct xt_helper_info *info = matchinfo;
146 146
147#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
148 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
149 printk(KERN_WARNING "can't load nf_conntrack support for "
150 "proto=%d\n", match->family);
151 return 0;
152 }
153#endif
147 info->name[29] = '\0'; 154 info->name[29] = '\0';
148 return 1; 155 return 1;
149} 156}
150 157
158static void
159destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
160{
161#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
162 nf_ct_l3proto_module_put(match->family);
163#endif
164}
165
151static struct xt_match helper_match = { 166static struct xt_match helper_match = {
152 .name = "helper", 167 .name = "helper",
153 .match = match, 168 .match = match,
154 .matchsize = sizeof(struct xt_helper_info), 169 .matchsize = sizeof(struct xt_helper_info),
155 .checkentry = check, 170 .checkentry = check,
171 .destroy = destroy,
172 .family = AF_INET,
156 .me = THIS_MODULE, 173 .me = THIS_MODULE,
157}; 174};
158static struct xt_match helper6_match = { 175static struct xt_match helper6_match = {
@@ -160,6 +177,8 @@ static struct xt_match helper6_match = {
160 .match = match, 177 .match = match,
161 .matchsize = sizeof(struct xt_helper_info), 178 .matchsize = sizeof(struct xt_helper_info),
162 .checkentry = check, 179 .checkentry = check,
180 .destroy = destroy,
181 .family = AF_INET6,
163 .me = THIS_MODULE, 182 .me = THIS_MODULE,
164}; 183};
165 184
@@ -168,21 +187,21 @@ static int __init init(void)
168 int ret; 187 int ret;
169 need_conntrack(); 188 need_conntrack();
170 189
171 ret = xt_register_match(AF_INET, &helper_match); 190 ret = xt_register_match(&helper_match);
172 if (ret < 0) 191 if (ret < 0)
173 return ret; 192 return ret;
174 193
175 ret = xt_register_match(AF_INET6, &helper6_match); 194 ret = xt_register_match(&helper6_match);
176 if (ret < 0) 195 if (ret < 0)
177 xt_unregister_match(AF_INET, &helper_match); 196 xt_unregister_match(&helper_match);
178 197
179 return ret; 198 return ret;
180} 199}
181 200
182static void __exit fini(void) 201static void __exit fini(void)
183{ 202{
184 xt_unregister_match(AF_INET, &helper_match); 203 xt_unregister_match(&helper_match);
185 xt_unregister_match(AF_INET6, &helper6_match); 204 xt_unregister_match(&helper6_match);
186} 205}
187 206
188module_init(init); 207module_init(init);
diff --git a/net/netfilter/xt_length.c b/net/netfilter/xt_length.c
index b9e60f041a64..38560caef757 100644
--- a/net/netfilter/xt_length.c
+++ b/net/netfilter/xt_length.c
@@ -56,6 +56,7 @@ static struct xt_match length_match = {
56 .name = "length", 56 .name = "length",
57 .match = match, 57 .match = match,
58 .matchsize = sizeof(struct xt_length_info), 58 .matchsize = sizeof(struct xt_length_info),
59 .family = AF_INET,
59 .me = THIS_MODULE, 60 .me = THIS_MODULE,
60}; 61};
61 62
@@ -63,26 +64,27 @@ static struct xt_match length6_match = {
63 .name = "length", 64 .name = "length",
64 .match = match6, 65 .match = match6,
65 .matchsize = sizeof(struct xt_length_info), 66 .matchsize = sizeof(struct xt_length_info),
67 .family = AF_INET6,
66 .me = THIS_MODULE, 68 .me = THIS_MODULE,
67}; 69};
68 70
69static int __init init(void) 71static int __init init(void)
70{ 72{
71 int ret; 73 int ret;
72 ret = xt_register_match(AF_INET, &length_match); 74 ret = xt_register_match(&length_match);
73 if (ret) 75 if (ret)
74 return ret; 76 return ret;
75 ret = xt_register_match(AF_INET6, &length6_match); 77 ret = xt_register_match(&length6_match);
76 if (ret) 78 if (ret)
77 xt_unregister_match(AF_INET, &length_match); 79 xt_unregister_match(&length_match);
78 80
79 return ret; 81 return ret;
80} 82}
81 83
82static void __exit fini(void) 84static void __exit fini(void)
83{ 85{
84 xt_unregister_match(AF_INET, &length_match); 86 xt_unregister_match(&length_match);
85 xt_unregister_match(AF_INET6, &length6_match); 87 xt_unregister_match(&length6_match);
86} 88}
87 89
88module_init(init); 90module_init(init);
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index 3049e6f8889e..e91c1a444e77 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -141,6 +141,7 @@ static struct xt_match ipt_limit_reg = {
141 .match = ipt_limit_match, 141 .match = ipt_limit_match,
142 .matchsize = sizeof(struct xt_rateinfo), 142 .matchsize = sizeof(struct xt_rateinfo),
143 .checkentry = ipt_limit_checkentry, 143 .checkentry = ipt_limit_checkentry,
144 .family = AF_INET,
144 .me = THIS_MODULE, 145 .me = THIS_MODULE,
145}; 146};
146static struct xt_match limit6_reg = { 147static struct xt_match limit6_reg = {
@@ -148,6 +149,7 @@ static struct xt_match limit6_reg = {
148 .match = ipt_limit_match, 149 .match = ipt_limit_match,
149 .matchsize = sizeof(struct xt_rateinfo), 150 .matchsize = sizeof(struct xt_rateinfo),
150 .checkentry = ipt_limit_checkentry, 151 .checkentry = ipt_limit_checkentry,
152 .family = AF_INET6,
151 .me = THIS_MODULE, 153 .me = THIS_MODULE,
152}; 154};
153 155
@@ -155,21 +157,21 @@ static int __init init(void)
155{ 157{
156 int ret; 158 int ret;
157 159
158 ret = xt_register_match(AF_INET, &ipt_limit_reg); 160 ret = xt_register_match(&ipt_limit_reg);
159 if (ret) 161 if (ret)
160 return ret; 162 return ret;
161 163
162 ret = xt_register_match(AF_INET6, &limit6_reg); 164 ret = xt_register_match(&limit6_reg);
163 if (ret) 165 if (ret)
164 xt_unregister_match(AF_INET, &ipt_limit_reg); 166 xt_unregister_match(&ipt_limit_reg);
165 167
166 return ret; 168 return ret;
167} 169}
168 170
169static void __exit fini(void) 171static void __exit fini(void)
170{ 172{
171 xt_unregister_match(AF_INET, &ipt_limit_reg); 173 xt_unregister_match(&ipt_limit_reg);
172 xt_unregister_match(AF_INET6, &limit6_reg); 174 xt_unregister_match(&limit6_reg);
173} 175}
174 176
175module_init(init); 177module_init(init);
diff --git a/net/netfilter/xt_mac.c b/net/netfilter/xt_mac.c
index b4559a46dce8..f4defa28a6ec 100644
--- a/net/netfilter/xt_mac.c
+++ b/net/netfilter/xt_mac.c
@@ -49,6 +49,7 @@ static struct xt_match mac_match = {
49 .matchsize = sizeof(struct xt_mac_info), 49 .matchsize = sizeof(struct xt_mac_info),
50 .hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) | 50 .hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
51 (1 << NF_IP_FORWARD), 51 (1 << NF_IP_FORWARD),
52 .family = AF_INET,
52 .me = THIS_MODULE, 53 .me = THIS_MODULE,
53}; 54};
54static struct xt_match mac6_match = { 55static struct xt_match mac6_match = {
@@ -57,27 +58,28 @@ static struct xt_match mac6_match = {
57 .matchsize = sizeof(struct xt_mac_info), 58 .matchsize = sizeof(struct xt_mac_info),
58 .hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) | 59 .hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
59 (1 << NF_IP_FORWARD), 60 (1 << NF_IP_FORWARD),
61 .family = AF_INET6,
60 .me = THIS_MODULE, 62 .me = THIS_MODULE,
61}; 63};
62 64
63static int __init init(void) 65static int __init init(void)
64{ 66{
65 int ret; 67 int ret;
66 ret = xt_register_match(AF_INET, &mac_match); 68 ret = xt_register_match(&mac_match);
67 if (ret) 69 if (ret)
68 return ret; 70 return ret;
69 71
70 ret = xt_register_match(AF_INET6, &mac6_match); 72 ret = xt_register_match(&mac6_match);
71 if (ret) 73 if (ret)
72 xt_unregister_match(AF_INET, &mac_match); 74 xt_unregister_match(&mac_match);
73 75
74 return ret; 76 return ret;
75} 77}
76 78
77static void __exit fini(void) 79static void __exit fini(void)
78{ 80{
79 xt_unregister_match(AF_INET, &mac_match); 81 xt_unregister_match(&mac_match);
80 xt_unregister_match(AF_INET6, &mac6_match); 82 xt_unregister_match(&mac6_match);
81} 83}
82 84
83module_init(init); 85module_init(init);
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index c1a8f0f587f0..ce0badfeef9a 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -56,6 +56,7 @@ static struct xt_match mark_match = {
56 .match = match, 56 .match = match,
57 .matchsize = sizeof(struct xt_mark_info), 57 .matchsize = sizeof(struct xt_mark_info),
58 .checkentry = checkentry, 58 .checkentry = checkentry,
59 .family = AF_INET,
59 .me = THIS_MODULE, 60 .me = THIS_MODULE,
60}; 61};
61 62
@@ -64,27 +65,28 @@ static struct xt_match mark6_match = {
64 .match = match, 65 .match = match,
65 .matchsize = sizeof(struct xt_mark_info), 66 .matchsize = sizeof(struct xt_mark_info),
66 .checkentry = checkentry, 67 .checkentry = checkentry,
68 .family = AF_INET6,
67 .me = THIS_MODULE, 69 .me = THIS_MODULE,
68}; 70};
69 71
70static int __init init(void) 72static int __init init(void)
71{ 73{
72 int ret; 74 int ret;
73 ret = xt_register_match(AF_INET, &mark_match); 75 ret = xt_register_match(&mark_match);
74 if (ret) 76 if (ret)
75 return ret; 77 return ret;
76 78
77 ret = xt_register_match(AF_INET6, &mark6_match); 79 ret = xt_register_match(&mark6_match);
78 if (ret) 80 if (ret)
79 xt_unregister_match(AF_INET, &mark_match); 81 xt_unregister_match(&mark_match);
80 82
81 return ret; 83 return ret;
82} 84}
83 85
84static void __exit fini(void) 86static void __exit fini(void)
85{ 87{
86 xt_unregister_match(AF_INET, &mark_match); 88 xt_unregister_match(&mark_match);
87 xt_unregister_match(AF_INET6, &mark6_match); 89 xt_unregister_match(&mark6_match);
88} 90}
89 91
90module_init(init); 92module_init(init);
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
index f788e8e76254..089f4f7e8636 100644
--- a/net/netfilter/xt_physdev.c
+++ b/net/netfilter/xt_physdev.c
@@ -121,6 +121,7 @@ static struct xt_match physdev_match = {
121 .match = match, 121 .match = match,
122 .matchsize = sizeof(struct xt_physdev_info), 122 .matchsize = sizeof(struct xt_physdev_info),
123 .checkentry = checkentry, 123 .checkentry = checkentry,
124 .family = AF_INET,
124 .me = THIS_MODULE, 125 .me = THIS_MODULE,
125}; 126};
126 127
@@ -129,6 +130,7 @@ static struct xt_match physdev6_match = {
129 .match = match, 130 .match = match,
130 .matchsize = sizeof(struct xt_physdev_info), 131 .matchsize = sizeof(struct xt_physdev_info),
131 .checkentry = checkentry, 132 .checkentry = checkentry,
133 .family = AF_INET6,
132 .me = THIS_MODULE, 134 .me = THIS_MODULE,
133}; 135};
134 136
@@ -136,21 +138,21 @@ static int __init init(void)
136{ 138{
137 int ret; 139 int ret;
138 140
139 ret = xt_register_match(AF_INET, &physdev_match); 141 ret = xt_register_match(&physdev_match);
140 if (ret < 0) 142 if (ret < 0)
141 return ret; 143 return ret;
142 144
143 ret = xt_register_match(AF_INET6, &physdev6_match); 145 ret = xt_register_match(&physdev6_match);
144 if (ret < 0) 146 if (ret < 0)
145 xt_unregister_match(AF_INET, &physdev_match); 147 xt_unregister_match(&physdev_match);
146 148
147 return ret; 149 return ret;
148} 150}
149 151
150static void __exit fini(void) 152static void __exit fini(void)
151{ 153{
152 xt_unregister_match(AF_INET, &physdev_match); 154 xt_unregister_match(&physdev_match);
153 xt_unregister_match(AF_INET6, &physdev6_match); 155 xt_unregister_match(&physdev6_match);
154} 156}
155 157
156module_init(init); 158module_init(init);
diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index f38638dfd139..8b8bca988ac6 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -37,6 +37,7 @@ static struct xt_match pkttype_match = {
37 .name = "pkttype", 37 .name = "pkttype",
38 .match = match, 38 .match = match,
39 .matchsize = sizeof(struct xt_pkttype_info), 39 .matchsize = sizeof(struct xt_pkttype_info),
40 .family = AF_INET,
40 .me = THIS_MODULE, 41 .me = THIS_MODULE,
41}; 42};
42 43
@@ -44,27 +45,28 @@ static struct xt_match pkttype6_match = {
44 .name = "pkttype", 45 .name = "pkttype",
45 .match = match, 46 .match = match,
46 .matchsize = sizeof(struct xt_pkttype_info), 47 .matchsize = sizeof(struct xt_pkttype_info),
48 .family = AF_INET6,
47 .me = THIS_MODULE, 49 .me = THIS_MODULE,
48}; 50};
49 51
50static int __init init(void) 52static int __init init(void)
51{ 53{
52 int ret; 54 int ret;
53 ret = xt_register_match(AF_INET, &pkttype_match); 55 ret = xt_register_match(&pkttype_match);
54 if (ret) 56 if (ret)
55 return ret; 57 return ret;
56 58
57 ret = xt_register_match(AF_INET6, &pkttype6_match); 59 ret = xt_register_match(&pkttype6_match);
58 if (ret) 60 if (ret)
59 xt_unregister_match(AF_INET, &pkttype_match); 61 xt_unregister_match(&pkttype_match);
60 62
61 return ret; 63 return ret;
62} 64}
63 65
64static void __exit fini(void) 66static void __exit fini(void)
65{ 67{
66 xt_unregister_match(AF_INET, &pkttype_match); 68 xt_unregister_match(&pkttype_match);
67 xt_unregister_match(AF_INET6, &pkttype6_match); 69 xt_unregister_match(&pkttype6_match);
68} 70}
69 71
70module_init(init); 72module_init(init);
diff --git a/net/netfilter/xt_policy.c b/net/netfilter/xt_policy.c
index 1ec22082f04d..1099cb005fcc 100644
--- a/net/netfilter/xt_policy.c
+++ b/net/netfilter/xt_policy.c
@@ -27,9 +27,9 @@ xt_addr_cmp(const union xt_policy_addr *a1, const union xt_policy_addr *m,
27{ 27{
28 switch (family) { 28 switch (family) {
29 case AF_INET: 29 case AF_INET:
30 return (a1->a4.s_addr ^ a2->a4.s_addr) & m->a4.s_addr; 30 return !((a1->a4.s_addr ^ a2->a4.s_addr) & m->a4.s_addr);
31 case AF_INET6: 31 case AF_INET6:
32 return ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6); 32 return !ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6);
33 } 33 }
34 return 0; 34 return 0;
35} 35}
@@ -44,7 +44,7 @@ match_xfrm_state(struct xfrm_state *x, const struct xt_policy_elem *e,
44#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x)) 44#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x))
45 45
46 return MATCH_ADDR(saddr, smask, (union xt_policy_addr *)&x->props.saddr) && 46 return MATCH_ADDR(saddr, smask, (union xt_policy_addr *)&x->props.saddr) &&
47 MATCH_ADDR(daddr, dmask, (union xt_policy_addr *)&x->id.daddr.a4) && 47 MATCH_ADDR(daddr, dmask, (union xt_policy_addr *)&x->id.daddr) &&
48 MATCH(proto, x->id.proto) && 48 MATCH(proto, x->id.proto) &&
49 MATCH(mode, x->props.mode) && 49 MATCH(mode, x->props.mode) &&
50 MATCH(spi, x->id.spi) && 50 MATCH(spi, x->id.spi) &&
@@ -172,6 +172,7 @@ static struct xt_match policy_match = {
172 .match = match, 172 .match = match,
173 .matchsize = sizeof(struct xt_policy_info), 173 .matchsize = sizeof(struct xt_policy_info),
174 .checkentry = checkentry, 174 .checkentry = checkentry,
175 .family = AF_INET,
175 .me = THIS_MODULE, 176 .me = THIS_MODULE,
176}; 177};
177 178
@@ -181,6 +182,7 @@ static struct xt_match policy6_match = {
181 .match = match, 182 .match = match,
182 .matchsize = sizeof(struct xt_policy_info), 183 .matchsize = sizeof(struct xt_policy_info),
183 .checkentry = checkentry, 184 .checkentry = checkentry,
185 .family = AF_INET6,
184 .me = THIS_MODULE, 186 .me = THIS_MODULE,
185}; 187};
186 188
@@ -188,19 +190,19 @@ static int __init init(void)
188{ 190{
189 int ret; 191 int ret;
190 192
191 ret = xt_register_match(AF_INET, &policy_match); 193 ret = xt_register_match(&policy_match);
192 if (ret) 194 if (ret)
193 return ret; 195 return ret;
194 ret = xt_register_match(AF_INET6, &policy6_match); 196 ret = xt_register_match(&policy6_match);
195 if (ret) 197 if (ret)
196 xt_unregister_match(AF_INET, &policy_match); 198 xt_unregister_match(&policy_match);
197 return ret; 199 return ret;
198} 200}
199 201
200static void __exit fini(void) 202static void __exit fini(void)
201{ 203{
202 xt_unregister_match(AF_INET6, &policy6_match); 204 xt_unregister_match(&policy6_match);
203 xt_unregister_match(AF_INET, &policy_match); 205 xt_unregister_match(&policy_match);
204} 206}
205 207
206module_init(init); 208module_init(init);
diff --git a/net/netfilter/xt_realm.c b/net/netfilter/xt_realm.c
index 57815a07db67..5e31a4a835bf 100644
--- a/net/netfilter/xt_realm.c
+++ b/net/netfilter/xt_realm.c
@@ -45,17 +45,18 @@ static struct xt_match realm_match = {
45 .matchsize = sizeof(struct xt_realm_info), 45 .matchsize = sizeof(struct xt_realm_info),
46 .hooks = (1 << NF_IP_POST_ROUTING) | (1 << NF_IP_FORWARD) | 46 .hooks = (1 << NF_IP_POST_ROUTING) | (1 << NF_IP_FORWARD) |
47 (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_LOCAL_IN), 47 (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_LOCAL_IN),
48 .family = AF_INET,
48 .me = THIS_MODULE 49 .me = THIS_MODULE
49}; 50};
50 51
51static int __init init(void) 52static int __init init(void)
52{ 53{
53 return xt_register_match(AF_INET, &realm_match); 54 return xt_register_match(&realm_match);
54} 55}
55 56
56static void __exit fini(void) 57static void __exit fini(void)
57{ 58{
58 xt_unregister_match(AF_INET, &realm_match); 59 xt_unregister_match(&realm_match);
59} 60}
60 61
61module_init(init); 62module_init(init);
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index f5d698ba03ca..c6eb24a2fe13 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -186,6 +186,7 @@ static struct xt_match sctp_match = {
186 .matchsize = sizeof(struct xt_sctp_info), 186 .matchsize = sizeof(struct xt_sctp_info),
187 .proto = IPPROTO_SCTP, 187 .proto = IPPROTO_SCTP,
188 .checkentry = checkentry, 188 .checkentry = checkentry,
189 .family = AF_INET,
189 .me = THIS_MODULE 190 .me = THIS_MODULE
190}; 191};
191 192
@@ -195,27 +196,28 @@ static struct xt_match sctp6_match = {
195 .matchsize = sizeof(struct xt_sctp_info), 196 .matchsize = sizeof(struct xt_sctp_info),
196 .proto = IPPROTO_SCTP, 197 .proto = IPPROTO_SCTP,
197 .checkentry = checkentry, 198 .checkentry = checkentry,
199 .family = AF_INET6,
198 .me = THIS_MODULE 200 .me = THIS_MODULE
199}; 201};
200 202
201static int __init init(void) 203static int __init init(void)
202{ 204{
203 int ret; 205 int ret;
204 ret = xt_register_match(AF_INET, &sctp_match); 206 ret = xt_register_match(&sctp_match);
205 if (ret) 207 if (ret)
206 return ret; 208 return ret;
207 209
208 ret = xt_register_match(AF_INET6, &sctp6_match); 210 ret = xt_register_match(&sctp6_match);
209 if (ret) 211 if (ret)
210 xt_unregister_match(AF_INET, &sctp_match); 212 xt_unregister_match(&sctp_match);
211 213
212 return ret; 214 return ret;
213} 215}
214 216
215static void __exit fini(void) 217static void __exit fini(void)
216{ 218{
217 xt_unregister_match(AF_INET6, &sctp6_match); 219 xt_unregister_match(&sctp6_match);
218 xt_unregister_match(AF_INET, &sctp_match); 220 xt_unregister_match(&sctp_match);
219} 221}
220 222
221module_init(init); 223module_init(init);
diff --git a/net/netfilter/xt_state.c b/net/netfilter/xt_state.c
index b8ec00cd51fc..e6c0be9d94d2 100644
--- a/net/netfilter/xt_state.c
+++ b/net/netfilter/xt_state.c
@@ -44,17 +44,48 @@ match(const struct sk_buff *skb,
44 return (sinfo->statemask & statebit); 44 return (sinfo->statemask & statebit);
45} 45}
46 46
47static int check(const char *tablename,
48 const void *inf,
49 const struct xt_match *match,
50 void *matchinfo,
51 unsigned int matchsize,
52 unsigned int hook_mask)
53{
54#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
55 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
56 printk(KERN_WARNING "can't load nf_conntrack support for "
57 "proto=%d\n", match->family);
58 return 0;
59 }
60#endif
61 return 1;
62}
63
64static void
65destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
66{
67#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
68 nf_ct_l3proto_module_put(match->family);
69#endif
70}
71
47static struct xt_match state_match = { 72static struct xt_match state_match = {
48 .name = "state", 73 .name = "state",
49 .match = match, 74 .match = match,
75 .checkentry = check,
76 .destroy = destroy,
50 .matchsize = sizeof(struct xt_state_info), 77 .matchsize = sizeof(struct xt_state_info),
78 .family = AF_INET,
51 .me = THIS_MODULE, 79 .me = THIS_MODULE,
52}; 80};
53 81
54static struct xt_match state6_match = { 82static struct xt_match state6_match = {
55 .name = "state", 83 .name = "state",
56 .match = match, 84 .match = match,
85 .checkentry = check,
86 .destroy = destroy,
57 .matchsize = sizeof(struct xt_state_info), 87 .matchsize = sizeof(struct xt_state_info),
88 .family = AF_INET6,
58 .me = THIS_MODULE, 89 .me = THIS_MODULE,
59}; 90};
60 91
@@ -64,21 +95,21 @@ static int __init init(void)
64 95
65 need_conntrack(); 96 need_conntrack();
66 97
67 ret = xt_register_match(AF_INET, &state_match); 98 ret = xt_register_match(&state_match);
68 if (ret < 0) 99 if (ret < 0)
69 return ret; 100 return ret;
70 101
71 ret = xt_register_match(AF_INET6, &state6_match); 102 ret = xt_register_match(&state6_match);
72 if (ret < 0) 103 if (ret < 0)
73 xt_unregister_match(AF_INET,&state_match); 104 xt_unregister_match(&state_match);
74 105
75 return ret; 106 return ret;
76} 107}
77 108
78static void __exit fini(void) 109static void __exit fini(void)
79{ 110{
80 xt_unregister_match(AF_INET, &state_match); 111 xt_unregister_match(&state_match);
81 xt_unregister_match(AF_INET6, &state6_match); 112 xt_unregister_match(&state6_match);
82} 113}
83 114
84module_init(init); 115module_init(init);
diff --git a/net/netfilter/xt_string.c b/net/netfilter/xt_string.c
index fccbad6a7f40..703d80fccacf 100644
--- a/net/netfilter/xt_string.c
+++ b/net/netfilter/xt_string.c
@@ -78,6 +78,7 @@ static struct xt_match string_match = {
78 .matchsize = sizeof(struct xt_string_info), 78 .matchsize = sizeof(struct xt_string_info),
79 .checkentry = checkentry, 79 .checkentry = checkentry,
80 .destroy = destroy, 80 .destroy = destroy,
81 .family = AF_INET,
81 .me = THIS_MODULE 82 .me = THIS_MODULE
82}; 83};
83static struct xt_match string6_match = { 84static struct xt_match string6_match = {
@@ -86,6 +87,7 @@ static struct xt_match string6_match = {
86 .matchsize = sizeof(struct xt_string_info), 87 .matchsize = sizeof(struct xt_string_info),
87 .checkentry = checkentry, 88 .checkentry = checkentry,
88 .destroy = destroy, 89 .destroy = destroy,
90 .family = AF_INET6,
89 .me = THIS_MODULE 91 .me = THIS_MODULE
90}; 92};
91 93
@@ -93,20 +95,20 @@ static int __init init(void)
93{ 95{
94 int ret; 96 int ret;
95 97
96 ret = xt_register_match(AF_INET, &string_match); 98 ret = xt_register_match(&string_match);
97 if (ret) 99 if (ret)
98 return ret; 100 return ret;
99 ret = xt_register_match(AF_INET6, &string6_match); 101 ret = xt_register_match(&string6_match);
100 if (ret) 102 if (ret)
101 xt_unregister_match(AF_INET, &string_match); 103 xt_unregister_match(&string_match);
102 104
103 return ret; 105 return ret;
104} 106}
105 107
106static void __exit fini(void) 108static void __exit fini(void)
107{ 109{
108 xt_unregister_match(AF_INET, &string_match); 110 xt_unregister_match(&string_match);
109 xt_unregister_match(AF_INET6, &string6_match); 111 xt_unregister_match(&string6_match);
110} 112}
111 113
112module_init(init); 114module_init(init);
diff --git a/net/netfilter/xt_tcpmss.c b/net/netfilter/xt_tcpmss.c
index 4925fc98f4ae..70a8858ae3f1 100644
--- a/net/netfilter/xt_tcpmss.c
+++ b/net/netfilter/xt_tcpmss.c
@@ -98,6 +98,7 @@ static struct xt_match tcpmss_match = {
98 .match = match, 98 .match = match,
99 .matchsize = sizeof(struct xt_tcpmss_match_info), 99 .matchsize = sizeof(struct xt_tcpmss_match_info),
100 .proto = IPPROTO_TCP, 100 .proto = IPPROTO_TCP,
101 .family = AF_INET,
101 .me = THIS_MODULE, 102 .me = THIS_MODULE,
102}; 103};
103 104
@@ -106,6 +107,7 @@ static struct xt_match tcpmss6_match = {
106 .match = match, 107 .match = match,
107 .matchsize = sizeof(struct xt_tcpmss_match_info), 108 .matchsize = sizeof(struct xt_tcpmss_match_info),
108 .proto = IPPROTO_TCP, 109 .proto = IPPROTO_TCP,
110 .family = AF_INET6,
109 .me = THIS_MODULE, 111 .me = THIS_MODULE,
110}; 112};
111 113
@@ -113,21 +115,21 @@ static struct xt_match tcpmss6_match = {
113static int __init init(void) 115static int __init init(void)
114{ 116{
115 int ret; 117 int ret;
116 ret = xt_register_match(AF_INET, &tcpmss_match); 118 ret = xt_register_match(&tcpmss_match);
117 if (ret) 119 if (ret)
118 return ret; 120 return ret;
119 121
120 ret = xt_register_match(AF_INET6, &tcpmss6_match); 122 ret = xt_register_match(&tcpmss6_match);
121 if (ret) 123 if (ret)
122 xt_unregister_match(AF_INET, &tcpmss_match); 124 xt_unregister_match(&tcpmss_match);
123 125
124 return ret; 126 return ret;
125} 127}
126 128
127static void __exit fini(void) 129static void __exit fini(void)
128{ 130{
129 xt_unregister_match(AF_INET6, &tcpmss6_match); 131 xt_unregister_match(&tcpmss6_match);
130 xt_unregister_match(AF_INET, &tcpmss_match); 132 xt_unregister_match(&tcpmss_match);
131} 133}
132 134
133module_init(init); 135module_init(init);
diff --git a/net/netfilter/xt_tcpudp.c b/net/netfilter/xt_tcpudp.c
index b5cd0dd4e41f..14a990eb666a 100644
--- a/net/netfilter/xt_tcpudp.c
+++ b/net/netfilter/xt_tcpudp.c
@@ -204,6 +204,7 @@ static struct xt_match tcp_matchstruct = {
204 .match = tcp_match, 204 .match = tcp_match,
205 .matchsize = sizeof(struct xt_tcp), 205 .matchsize = sizeof(struct xt_tcp),
206 .proto = IPPROTO_TCP, 206 .proto = IPPROTO_TCP,
207 .family = AF_INET,
207 .checkentry = tcp_checkentry, 208 .checkentry = tcp_checkentry,
208 .me = THIS_MODULE, 209 .me = THIS_MODULE,
209}; 210};
@@ -213,6 +214,7 @@ static struct xt_match tcp6_matchstruct = {
213 .match = tcp_match, 214 .match = tcp_match,
214 .matchsize = sizeof(struct xt_tcp), 215 .matchsize = sizeof(struct xt_tcp),
215 .proto = IPPROTO_TCP, 216 .proto = IPPROTO_TCP,
217 .family = AF_INET6,
216 .checkentry = tcp_checkentry, 218 .checkentry = tcp_checkentry,
217 .me = THIS_MODULE, 219 .me = THIS_MODULE,
218}; 220};
@@ -222,6 +224,7 @@ static struct xt_match udp_matchstruct = {
222 .match = udp_match, 224 .match = udp_match,
223 .matchsize = sizeof(struct xt_udp), 225 .matchsize = sizeof(struct xt_udp),
224 .proto = IPPROTO_UDP, 226 .proto = IPPROTO_UDP,
227 .family = AF_INET,
225 .checkentry = udp_checkentry, 228 .checkentry = udp_checkentry,
226 .me = THIS_MODULE, 229 .me = THIS_MODULE,
227}; 230};
@@ -230,6 +233,7 @@ static struct xt_match udp6_matchstruct = {
230 .match = udp_match, 233 .match = udp_match,
231 .matchsize = sizeof(struct xt_udp), 234 .matchsize = sizeof(struct xt_udp),
232 .proto = IPPROTO_UDP, 235 .proto = IPPROTO_UDP,
236 .family = AF_INET6,
233 .checkentry = udp_checkentry, 237 .checkentry = udp_checkentry,
234 .me = THIS_MODULE, 238 .me = THIS_MODULE,
235}; 239};
@@ -237,39 +241,39 @@ static struct xt_match udp6_matchstruct = {
237static int __init init(void) 241static int __init init(void)
238{ 242{
239 int ret; 243 int ret;
240 ret = xt_register_match(AF_INET, &tcp_matchstruct); 244 ret = xt_register_match(&tcp_matchstruct);
241 if (ret) 245 if (ret)
242 return ret; 246 return ret;
243 247
244 ret = xt_register_match(AF_INET6, &tcp6_matchstruct); 248 ret = xt_register_match(&tcp6_matchstruct);
245 if (ret) 249 if (ret)
246 goto out_unreg_tcp; 250 goto out_unreg_tcp;
247 251
248 ret = xt_register_match(AF_INET, &udp_matchstruct); 252 ret = xt_register_match(&udp_matchstruct);
249 if (ret) 253 if (ret)
250 goto out_unreg_tcp6; 254 goto out_unreg_tcp6;
251 255
252 ret = xt_register_match(AF_INET6, &udp6_matchstruct); 256 ret = xt_register_match(&udp6_matchstruct);
253 if (ret) 257 if (ret)
254 goto out_unreg_udp; 258 goto out_unreg_udp;
255 259
256 return ret; 260 return ret;
257 261
258out_unreg_udp: 262out_unreg_udp:
259 xt_unregister_match(AF_INET, &tcp_matchstruct); 263 xt_unregister_match(&tcp_matchstruct);
260out_unreg_tcp6: 264out_unreg_tcp6:
261 xt_unregister_match(AF_INET6, &tcp6_matchstruct); 265 xt_unregister_match(&tcp6_matchstruct);
262out_unreg_tcp: 266out_unreg_tcp:
263 xt_unregister_match(AF_INET, &tcp_matchstruct); 267 xt_unregister_match(&tcp_matchstruct);
264 return ret; 268 return ret;
265} 269}
266 270
267static void __exit fini(void) 271static void __exit fini(void)
268{ 272{
269 xt_unregister_match(AF_INET6, &udp6_matchstruct); 273 xt_unregister_match(&udp6_matchstruct);
270 xt_unregister_match(AF_INET, &udp_matchstruct); 274 xt_unregister_match(&udp_matchstruct);
271 xt_unregister_match(AF_INET6, &tcp6_matchstruct); 275 xt_unregister_match(&tcp6_matchstruct);
272 xt_unregister_match(AF_INET, &tcp_matchstruct); 276 xt_unregister_match(&tcp_matchstruct);
273} 277}
274 278
275module_init(init); 279module_init(init);
diff --git a/security/seclvl.c b/security/seclvl.c
index 8529ea6f7aa8..441beaf1bbc1 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -8,6 +8,7 @@
8 * Copyright (c) 2001 WireX Communications, Inc <chris@wirex.com> 8 * Copyright (c) 2001 WireX Communications, Inc <chris@wirex.com>
9 * Copyright (c) 2001 Greg Kroah-Hartman <greg@kroah.com> 9 * Copyright (c) 2001 Greg Kroah-Hartman <greg@kroah.com>
10 * Copyright (c) 2002 International Business Machines <robb@austin.ibm.com> 10 * Copyright (c) 2002 International Business Machines <robb@austin.ibm.com>
11 * Copyright (c) 2006 Davi E. M. Arnaut <davi.arnaut@gmail.com>
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
@@ -31,6 +32,7 @@
31#include <linux/kobject.h> 32#include <linux/kobject.h>
32#include <linux/crypto.h> 33#include <linux/crypto.h>
33#include <asm/scatterlist.h> 34#include <asm/scatterlist.h>
35#include <linux/scatterlist.h>
34#include <linux/gfp.h> 36#include <linux/gfp.h>
35#include <linux/sysfs.h> 37#include <linux/sysfs.h>
36 38
@@ -194,35 +196,27 @@ static unsigned char hashedPassword[SHA1_DIGEST_SIZE];
194 * people... 196 * people...
195 */ 197 */
196static int 198static int
197plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len) 199plaintext_to_sha1(unsigned char *hash, const char *plaintext, unsigned int len)
198{ 200{
199 char *pgVirtAddr;
200 struct crypto_tfm *tfm; 201 struct crypto_tfm *tfm;
201 struct scatterlist sg[1]; 202 struct scatterlist sg;
202 if (len > PAGE_SIZE) { 203 if (len > PAGE_SIZE) {
203 seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d " 204 seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d "
204 "characters). Largest possible is %lu " 205 "characters). Largest possible is %lu "
205 "bytes.\n", len, PAGE_SIZE); 206 "bytes.\n", len, PAGE_SIZE);
206 return -ENOMEM; 207 return -EINVAL;
207 } 208 }
208 tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP); 209 tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP);
209 if (tfm == NULL) { 210 if (tfm == NULL) {
210 seclvl_printk(0, KERN_ERR, 211 seclvl_printk(0, KERN_ERR,
211 "Failed to load transform for SHA1\n"); 212 "Failed to load transform for SHA1\n");
212 return -ENOSYS; 213 return -EINVAL;
213 } 214 }
214 // Just get a new page; don't play around with page boundaries 215 sg_init_one(&sg, (u8 *)plaintext, len);
215 // and scatterlists.
216 pgVirtAddr = (char *)__get_free_page(GFP_KERNEL);
217 sg[0].page = virt_to_page(pgVirtAddr);
218 sg[0].offset = 0;
219 sg[0].length = len;
220 strncpy(pgVirtAddr, plaintext, len);
221 crypto_digest_init(tfm); 216 crypto_digest_init(tfm);
222 crypto_digest_update(tfm, sg, 1); 217 crypto_digest_update(tfm, &sg, 1);
223 crypto_digest_final(tfm, hash); 218 crypto_digest_final(tfm, hash);
224 crypto_free_tfm(tfm); 219 crypto_free_tfm(tfm);
225 free_page((unsigned long)pgVirtAddr);
226 return 0; 220 return 0;
227} 221}
228 222
@@ -234,11 +228,9 @@ static ssize_t
234passwd_write_file(struct file * file, const char __user * buf, 228passwd_write_file(struct file * file, const char __user * buf,
235 size_t count, loff_t *ppos) 229 size_t count, loff_t *ppos)
236{ 230{
237 int i; 231 char *p;
238 unsigned char tmp[SHA1_DIGEST_SIZE];
239 char *page;
240 int rc;
241 int len; 232 int len;
233 unsigned char tmp[SHA1_DIGEST_SIZE];
242 234
243 if (!*passwd && !*sha1_passwd) { 235 if (!*passwd && !*sha1_passwd) {
244 seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the " 236 seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the "
@@ -251,38 +243,39 @@ passwd_write_file(struct file * file, const char __user * buf,
251 return -EINVAL; 243 return -EINVAL;
252 } 244 }
253 245
254 if (count < 0 || count >= PAGE_SIZE) 246 if (count >= PAGE_SIZE)
255 return -EINVAL; 247 return -EINVAL;
256 if (*ppos != 0) 248 if (*ppos != 0)
257 return -EINVAL; 249 return -EINVAL;
258 page = (char *)get_zeroed_page(GFP_KERNEL); 250 p = kmalloc(count, GFP_KERNEL);
259 if (!page) 251 if (!p)
260 return -ENOMEM; 252 return -ENOMEM;
261 len = -EFAULT; 253 len = -EFAULT;
262 if (copy_from_user(page, buf, count)) 254 if (copy_from_user(p, buf, count))
263 goto out; 255 goto out;
264 256
265 len = strlen(page); 257 len = count;
266 /* ``echo "secret" > seclvl/passwd'' includes a newline */ 258 /* ``echo "secret" > seclvl/passwd'' includes a newline */
267 if (page[len - 1] == '\n') 259 if (p[len - 1] == '\n')
268 len--; 260 len--;
269 /* Hash the password, then compare the hashed values */ 261 /* Hash the password, then compare the hashed values */
270 if ((rc = plaintext_to_sha1(tmp, page, len))) { 262 if ((len = plaintext_to_sha1(tmp, p, len))) {
271 seclvl_printk(0, KERN_ERR, "Error hashing password: rc = " 263 seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
272 "[%d]\n", rc); 264 "[%d]\n", len);
273 return rc; 265 goto out;
274 }
275 for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
276 if (hashedPassword[i] != tmp[i])
277 return -EPERM;
278 } 266 }
267
268 len = -EPERM;
269 if (memcmp(hashedPassword, tmp, SHA1_DIGEST_SIZE))
270 goto out;
271
279 seclvl_printk(0, KERN_INFO, 272 seclvl_printk(0, KERN_INFO,
280 "Password accepted; seclvl reduced to 0.\n"); 273 "Password accepted; seclvl reduced to 0.\n");
281 seclvl = 0; 274 seclvl = 0;
282 len = count; 275 len = count;
283 276
284out: 277out:
285 free_page((unsigned long)page); 278 kfree (p);
286 return len; 279 return len;
287} 280}
288 281
@@ -295,13 +288,11 @@ static struct file_operations passwd_file_ops = {
295 */ 288 */
296static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child) 289static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
297{ 290{
298 if (seclvl >= 0) { 291 if (seclvl >= 0 && child->pid == 1) {
299 if (child->pid == 1) { 292 seclvl_printk(1, KERN_WARNING, "Attempt to ptrace "
300 seclvl_printk(1, KERN_WARNING, "Attempt to ptrace " 293 "the init process dissallowed in "
301 "the init process dissallowed in " 294 "secure level %d\n", seclvl);
302 "secure level %d\n", seclvl); 295 return -EPERM;
303 return -EPERM;
304 }
305 } 296 }
306 return 0; 297 return 0;
307} 298}
@@ -312,55 +303,54 @@ static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
312 */ 303 */
313static int seclvl_capable(struct task_struct *tsk, int cap) 304static int seclvl_capable(struct task_struct *tsk, int cap)
314{ 305{
306 int rc = 0;
307
315 /* init can do anything it wants */ 308 /* init can do anything it wants */
316 if (tsk->pid == 1) 309 if (tsk->pid == 1)
317 return 0; 310 return 0;
318 311
319 switch (seclvl) { 312 if (seclvl > 0) {
320 case 2: 313 rc = -EPERM;
321 /* fall through */ 314
322 case 1: 315 if (cap == CAP_LINUX_IMMUTABLE)
323 if (cap == CAP_LINUX_IMMUTABLE) {
324 seclvl_printk(1, KERN_WARNING, "Attempt to modify " 316 seclvl_printk(1, KERN_WARNING, "Attempt to modify "
325 "the IMMUTABLE and/or APPEND extended " 317 "the IMMUTABLE and/or APPEND extended "
326 "attribute on a file with the IMMUTABLE " 318 "attribute on a file with the IMMUTABLE "
327 "and/or APPEND extended attribute set " 319 "and/or APPEND extended attribute set "
328 "denied in seclvl [%d]\n", seclvl); 320 "denied in seclvl [%d]\n", seclvl);
329 return -EPERM; 321 else if (cap == CAP_SYS_RAWIO)
330 } else if (cap == CAP_SYS_RAWIO) { // Somewhat broad...
331 seclvl_printk(1, KERN_WARNING, "Attempt to perform " 322 seclvl_printk(1, KERN_WARNING, "Attempt to perform "
332 "raw I/O while in secure level [%d] " 323 "raw I/O while in secure level [%d] "
333 "denied\n", seclvl); 324 "denied\n", seclvl);
334 return -EPERM; 325 else if (cap == CAP_NET_ADMIN)
335 } else if (cap == CAP_NET_ADMIN) {
336 seclvl_printk(1, KERN_WARNING, "Attempt to perform " 326 seclvl_printk(1, KERN_WARNING, "Attempt to perform "
337 "network administrative task while " 327 "network administrative task while "
338 "in secure level [%d] denied\n", seclvl); 328 "in secure level [%d] denied\n", seclvl);
339 return -EPERM; 329 else if (cap == CAP_SETUID)
340 } else if (cap == CAP_SETUID) {
341 seclvl_printk(1, KERN_WARNING, "Attempt to setuid " 330 seclvl_printk(1, KERN_WARNING, "Attempt to setuid "
342 "while in secure level [%d] denied\n", 331 "while in secure level [%d] denied\n",
343 seclvl); 332 seclvl);
344 return -EPERM; 333 else if (cap == CAP_SETGID)
345 } else if (cap == CAP_SETGID) {
346 seclvl_printk(1, KERN_WARNING, "Attempt to setgid " 334 seclvl_printk(1, KERN_WARNING, "Attempt to setgid "
347 "while in secure level [%d] denied\n", 335 "while in secure level [%d] denied\n",
348 seclvl); 336 seclvl);
349 } else if (cap == CAP_SYS_MODULE) { 337 else if (cap == CAP_SYS_MODULE)
350 seclvl_printk(1, KERN_WARNING, "Attempt to perform " 338 seclvl_printk(1, KERN_WARNING, "Attempt to perform "
351 "a module operation while in secure " 339 "a module operation while in secure "
352 "level [%d] denied\n", seclvl); 340 "level [%d] denied\n", seclvl);
353 return -EPERM; 341 else
354 } 342 rc = 0;
355 break;
356 default:
357 break;
358 } 343 }
359 /* from dummy.c */ 344
360 if (cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0) 345 if (!rc) {
361 return 0; /* capability granted */ 346 if (!(cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0))
362 seclvl_printk(1, KERN_WARNING, "Capability denied\n"); 347 rc = -EPERM;
363 return -EPERM; /* capability denied */ 348 }
349
350 if (rc)
351 seclvl_printk(1, KERN_WARNING, "Capability denied\n");
352
353 return rc;
364} 354}
365 355
366/** 356/**
@@ -466,12 +456,9 @@ static int seclvl_inode_setattr(struct dentry *dentry, struct iattr *iattr)
466static void seclvl_file_free_security(struct file *filp) 456static void seclvl_file_free_security(struct file *filp)
467{ 457{
468 struct dentry *dentry = filp->f_dentry; 458 struct dentry *dentry = filp->f_dentry;
469 struct inode *inode = NULL;
470 459
471 if (dentry) { 460 if (dentry)
472 inode = dentry->d_inode; 461 seclvl_bd_release(dentry->d_inode);
473 seclvl_bd_release(inode);
474 }
475} 462}
476 463
477/** 464/**
@@ -479,9 +466,7 @@ static void seclvl_file_free_security(struct file *filp)
479 */ 466 */
480static int seclvl_umount(struct vfsmount *mnt, int flags) 467static int seclvl_umount(struct vfsmount *mnt, int flags)
481{ 468{
482 if (current->pid == 1) 469 if (current->pid != 1 && seclvl == 2) {
483 return 0;
484 if (seclvl == 2) {
485 seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure " 470 seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure "
486 "level %d\n", seclvl); 471 "level %d\n", seclvl);
487 return -EPERM; 472 return -EPERM;
@@ -505,8 +490,9 @@ static struct security_operations seclvl_ops = {
505static int processPassword(void) 490static int processPassword(void)
506{ 491{
507 int rc = 0; 492 int rc = 0;
508 hashedPassword[0] = '\0';
509 if (*passwd) { 493 if (*passwd) {
494 char *p;
495
510 if (*sha1_passwd) { 496 if (*sha1_passwd) {
511 seclvl_printk(0, KERN_ERR, "Error: Both " 497 seclvl_printk(0, KERN_ERR, "Error: Both "
512 "passwd and sha1_passwd " 498 "passwd and sha1_passwd "
@@ -514,12 +500,16 @@ static int processPassword(void)
514 "exclusive.\n"); 500 "exclusive.\n");
515 return -EINVAL; 501 return -EINVAL;
516 } 502 }
517 if ((rc = plaintext_to_sha1(hashedPassword, passwd, 503
518 strlen(passwd)))) { 504 p = kstrdup(passwd, GFP_KERNEL);
505 if (p == NULL)
506 return -ENOMEM;
507
508 if ((rc = plaintext_to_sha1(hashedPassword, p, strlen(p))))
519 seclvl_printk(0, KERN_ERR, "Error: SHA1 support not " 509 seclvl_printk(0, KERN_ERR, "Error: SHA1 support not "
520 "in kernel\n"); 510 "in kernel\n");
521 return rc; 511
522 } 512 kfree (p);
523 /* All static data goes to the BSS, which zero's the 513 /* All static data goes to the BSS, which zero's the
524 * plaintext password out for us. */ 514 * plaintext password out for us. */
525 } else if (*sha1_passwd) { // Base 16 515 } else if (*sha1_passwd) { // Base 16
@@ -542,7 +532,7 @@ static int processPassword(void)
542 sha1_passwd[i + 2] = tmp; 532 sha1_passwd[i + 2] = tmp;
543 } 533 }
544 } 534 }
545 return 0; 535 return rc;
546} 536}
547 537
548/** 538/**
@@ -552,28 +542,46 @@ struct dentry *dir_ino, *seclvl_ino, *passwd_ino;
552 542
553static int seclvlfs_register(void) 543static int seclvlfs_register(void)
554{ 544{
545 int rc = 0;
546
555 dir_ino = securityfs_create_dir("seclvl", NULL); 547 dir_ino = securityfs_create_dir("seclvl", NULL);
556 if (!dir_ino) 548
557 return -EFAULT; 549 if (IS_ERR(dir_ino))
550 return PTR_ERR(dir_ino);
558 551
559 seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR, 552 seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR,
560 dir_ino, &seclvl, &seclvl_file_ops); 553 dir_ino, &seclvl, &seclvl_file_ops);
561 if (!seclvl_ino) 554 if (IS_ERR(seclvl_ino)) {
555 rc = PTR_ERR(seclvl_ino);
562 goto out_deldir; 556 goto out_deldir;
557 }
563 if (*passwd || *sha1_passwd) { 558 if (*passwd || *sha1_passwd) {
564 passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR, 559 passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR,
565 dir_ino, NULL, &passwd_file_ops); 560 dir_ino, NULL, &passwd_file_ops);
566 if (!passwd_ino) 561 if (IS_ERR(passwd_ino)) {
562 rc = PTR_ERR(passwd_ino);
567 goto out_delf; 563 goto out_delf;
564 }
568 } 565 }
569 return 0; 566 return rc;
567
568out_delf:
569 securityfs_remove(seclvl_ino);
570 570
571out_deldir: 571out_deldir:
572 securityfs_remove(dir_ino); 572 securityfs_remove(dir_ino);
573out_delf: 573
574 return rc;
575}
576
577static void seclvlfs_unregister(void)
578{
574 securityfs_remove(seclvl_ino); 579 securityfs_remove(seclvl_ino);
575 580
576 return -EFAULT; 581 if (*passwd || *sha1_passwd)
582 securityfs_remove(passwd_ino);
583
584 securityfs_remove(dir_ino);
577} 585}
578 586
579/** 587/**
@@ -582,6 +590,8 @@ out_delf:
582static int __init seclvl_init(void) 590static int __init seclvl_init(void)
583{ 591{
584 int rc = 0; 592 int rc = 0;
593 static char once;
594
585 if (verbosity < 0 || verbosity > 1) { 595 if (verbosity < 0 || verbosity > 1) {
586 printk(KERN_ERR "Error: bad verbosity [%d]; only 0 or 1 " 596 printk(KERN_ERR "Error: bad verbosity [%d]; only 0 or 1 "
587 "are valid values\n", verbosity); 597 "are valid values\n", verbosity);
@@ -600,6 +610,11 @@ static int __init seclvl_init(void)
600 "module parameter(s): rc = [%d]\n", rc); 610 "module parameter(s): rc = [%d]\n", rc);
601 goto exit; 611 goto exit;
602 } 612 }
613
614 if ((rc = seclvlfs_register())) {
615 seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
616 goto exit;
617 }
603 /* register ourselves with the security framework */ 618 /* register ourselves with the security framework */
604 if (register_security(&seclvl_ops)) { 619 if (register_security(&seclvl_ops)) {
605 seclvl_printk(0, KERN_ERR, 620 seclvl_printk(0, KERN_ERR,
@@ -611,20 +626,24 @@ static int __init seclvl_init(void)
611 seclvl_printk(0, KERN_ERR, "seclvl: Failure " 626 seclvl_printk(0, KERN_ERR, "seclvl: Failure "
612 "registering with primary security " 627 "registering with primary security "
613 "module.\n"); 628 "module.\n");
629 seclvlfs_unregister();
614 goto exit; 630 goto exit;
615 } /* if primary module registered */ 631 } /* if primary module registered */
616 secondary = 1; 632 secondary = 1;
617 } /* if we registered ourselves with the security framework */ 633 } /* if we registered ourselves with the security framework */
618 if ((rc = seclvlfs_register())) { 634
619 seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
620 goto exit;
621 }
622 seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n"); 635 seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n");
636
637 if (once) {
638 once = 1;
639 seclvl_printk(0, KERN_INFO, "seclvl is going away. It has been "
640 "buggy for ages. Also, be warned that "
641 "Securelevels are useless.");
642 }
623 exit: 643 exit:
624 if (rc) { 644 if (rc)
625 printk(KERN_ERR "seclvl: Error during initialization: rc = " 645 printk(KERN_ERR "seclvl: Error during initialization: rc = "
626 "[%d]\n", rc); 646 "[%d]\n", rc);
627 }
628 return rc; 647 return rc;
629} 648}
630 649
@@ -633,17 +652,14 @@ static int __init seclvl_init(void)
633 */ 652 */
634static void __exit seclvl_exit(void) 653static void __exit seclvl_exit(void)
635{ 654{
636 securityfs_remove(seclvl_ino); 655 seclvlfs_unregister();
637 if (*passwd || *sha1_passwd) 656
638 securityfs_remove(passwd_ino); 657 if (secondary)
639 securityfs_remove(dir_ino);
640 if (secondary == 1) {
641 mod_unreg_security(MY_NAME, &seclvl_ops); 658 mod_unreg_security(MY_NAME, &seclvl_ops);
642 } else if (unregister_security(&seclvl_ops)) { 659 else if (unregister_security(&seclvl_ops))
643 seclvl_printk(0, KERN_INFO, 660 seclvl_printk(0, KERN_INFO,
644 "seclvl: Failure unregistering with the " 661 "seclvl: Failure unregistering with the "
645 "kernel\n"); 662 "kernel\n");
646 }
647} 663}
648 664
649module_init(seclvl_init); 665module_init(seclvl_init);
diff --git a/sound/oss/ac97_codec.c b/sound/oss/ac97_codec.c
index fd25aca25120..972327c97644 100644
--- a/sound/oss/ac97_codec.c
+++ b/sound/oss/ac97_codec.c
@@ -55,7 +55,7 @@
55#include <linux/pci.h> 55#include <linux/pci.h>
56#include <linux/ac97_codec.h> 56#include <linux/ac97_codec.h>
57#include <asm/uaccess.h> 57#include <asm/uaccess.h>
58#include <asm/semaphore.h> 58#include <linux/mutex.h>
59 59
60#define CODEC_ID_BUFSZ 14 60#define CODEC_ID_BUFSZ 14
61 61
@@ -304,7 +304,7 @@ static const unsigned int ac97_oss_rm[] = {
304 304
305static LIST_HEAD(codecs); 305static LIST_HEAD(codecs);
306static LIST_HEAD(codec_drivers); 306static LIST_HEAD(codec_drivers);
307static DECLARE_MUTEX(codec_sem); 307static DEFINE_MUTEX(codec_mutex);
308 308
309/* reads the given OSS mixer from the ac97 the caller must have insured that the ac97 knows 309/* reads the given OSS mixer from the ac97 the caller must have insured that the ac97 knows
310 about that given mixer, and should be holding a spinlock for the card */ 310 about that given mixer, and should be holding a spinlock for the card */
@@ -769,9 +769,9 @@ void ac97_release_codec(struct ac97_codec *codec)
769{ 769{
770 /* Remove from the list first, we don't want to be 770 /* Remove from the list first, we don't want to be
771 "rediscovered" */ 771 "rediscovered" */
772 down(&codec_sem); 772 mutex_lock(&codec_mutex);
773 list_del(&codec->list); 773 list_del(&codec->list);
774 up(&codec_sem); 774 mutex_unlock(&codec_mutex);
775 /* 775 /*
776 * The driver needs to deal with internal 776 * The driver needs to deal with internal
777 * locking to avoid accidents here. 777 * locking to avoid accidents here.
@@ -889,7 +889,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
889 * callbacks. 889 * callbacks.
890 */ 890 */
891 891
892 down(&codec_sem); 892 mutex_lock(&codec_mutex);
893 list_add(&codec->list, &codecs); 893 list_add(&codec->list, &codecs);
894 894
895 list_for_each(l, &codec_drivers) { 895 list_for_each(l, &codec_drivers) {
@@ -903,7 +903,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
903 } 903 }
904 } 904 }
905 905
906 up(&codec_sem); 906 mutex_unlock(&codec_mutex);
907 return 1; 907 return 1;
908} 908}
909 909
@@ -1439,7 +1439,7 @@ int ac97_register_driver(struct ac97_driver *driver)
1439 struct list_head *l; 1439 struct list_head *l;
1440 struct ac97_codec *c; 1440 struct ac97_codec *c;
1441 1441
1442 down(&codec_sem); 1442 mutex_lock(&codec_mutex);
1443 INIT_LIST_HEAD(&driver->list); 1443 INIT_LIST_HEAD(&driver->list);
1444 list_add(&driver->list, &codec_drivers); 1444 list_add(&driver->list, &codec_drivers);
1445 1445
@@ -1452,7 +1452,7 @@ int ac97_register_driver(struct ac97_driver *driver)
1452 continue; 1452 continue;
1453 c->driver = driver; 1453 c->driver = driver;
1454 } 1454 }
1455 up(&codec_sem); 1455 mutex_unlock(&codec_mutex);
1456 return 0; 1456 return 0;
1457} 1457}
1458 1458
@@ -1471,7 +1471,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
1471 struct list_head *l; 1471 struct list_head *l;
1472 struct ac97_codec *c; 1472 struct ac97_codec *c;
1473 1473
1474 down(&codec_sem); 1474 mutex_lock(&codec_mutex);
1475 list_del_init(&driver->list); 1475 list_del_init(&driver->list);
1476 1476
1477 list_for_each(l, &codecs) 1477 list_for_each(l, &codecs)
@@ -1483,7 +1483,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
1483 } 1483 }
1484 } 1484 }
1485 1485
1486 up(&codec_sem); 1486 mutex_unlock(&codec_mutex);
1487} 1487}
1488 1488
1489EXPORT_SYMBOL_GPL(ac97_unregister_driver); 1489EXPORT_SYMBOL_GPL(ac97_unregister_driver);
@@ -1494,14 +1494,14 @@ static int swap_headphone(int remove_master)
1494 struct ac97_codec *c; 1494 struct ac97_codec *c;
1495 1495
1496 if (remove_master) { 1496 if (remove_master) {
1497 down(&codec_sem); 1497 mutex_lock(&codec_mutex);
1498 list_for_each(l, &codecs) 1498 list_for_each(l, &codecs)
1499 { 1499 {
1500 c = list_entry(l, struct ac97_codec, list); 1500 c = list_entry(l, struct ac97_codec, list);
1501 if (supported_mixer(c, SOUND_MIXER_PHONEOUT)) 1501 if (supported_mixer(c, SOUND_MIXER_PHONEOUT))
1502 c->supported_mixers &= ~SOUND_MASK_PHONEOUT; 1502 c->supported_mixers &= ~SOUND_MASK_PHONEOUT;
1503 } 1503 }
1504 up(&codec_sem); 1504 mutex_unlock(&codec_mutex);
1505 } else 1505 } else
1506 ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO; 1506 ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO;
1507 1507
diff --git a/sound/oss/aci.c b/sound/oss/aci.c
index 3928c2802cc4..3bfac375dbdb 100644
--- a/sound/oss/aci.c
+++ b/sound/oss/aci.c
@@ -56,7 +56,8 @@
56#include <linux/module.h> 56#include <linux/module.h>
57#include <linux/proc_fs.h> 57#include <linux/proc_fs.h>
58#include <linux/slab.h> 58#include <linux/slab.h>
59#include <asm/semaphore.h> 59#include <linux/mutex.h>
60
60#include <asm/io.h> 61#include <asm/io.h>
61#include <asm/uaccess.h> 62#include <asm/uaccess.h>
62#include "sound_config.h" 63#include "sound_config.h"
@@ -79,7 +80,7 @@ static int aci_micpreamp=3; /* microphone preamp-level that can't be *
79 * checked with ACI versions prior to 0xb0 */ 80 * checked with ACI versions prior to 0xb0 */
80 81
81static int mixer_device; 82static int mixer_device;
82static struct semaphore aci_sem; 83static struct mutex aci_mutex;
83 84
84#ifdef MODULE 85#ifdef MODULE
85static int reset; 86static int reset;
@@ -212,7 +213,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
212 int write[] = {write1, write2, write3}; 213 int write[] = {write1, write2, write3};
213 int read = -EINTR, i; 214 int read = -EINTR, i;
214 215
215 if (down_interruptible(&aci_sem)) 216 if (mutex_lock_interruptible(&aci_mutex))
216 goto out; 217 goto out;
217 218
218 for (i=0; i<3; i++) { 219 for (i=0; i<3; i++) {
@@ -227,7 +228,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
227 } 228 }
228 229
229 read = aci_rawread(); 230 read = aci_rawread();
230out_up: up(&aci_sem); 231out_up: mutex_unlock(&aci_mutex);
231out: return read; 232out: return read;
232} 233}
233 234
@@ -603,7 +604,7 @@ static int __init attach_aci(void)
603 char *boardname; 604 char *boardname;
604 int i, rc = -EBUSY; 605 int i, rc = -EBUSY;
605 606
606 init_MUTEX(&aci_sem); 607 mutex_init(&aci_mutex);
607 608
608 outb(0xE3, 0xf8f); /* Write MAD16 password */ 609 outb(0xE3, 0xf8f); /* Write MAD16 password */
609 aci_port = (inb(0xf90) & 0x10) ? 610 aci_port = (inb(0xf90) & 0x10) ?
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c
index a0d73f343100..54dabf862802 100644
--- a/sound/oss/ad1889.c
+++ b/sound/oss/ad1889.c
@@ -38,6 +38,7 @@
38#include <linux/ac97_codec.h> 38#include <linux/ac97_codec.h>
39#include <linux/sound.h> 39#include <linux/sound.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/mutex.h>
41 42
42#include <asm/delay.h> 43#include <asm/delay.h>
43#include <asm/io.h> 44#include <asm/io.h>
@@ -238,7 +239,7 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
238 239
239 for (i = 0; i < AD_MAX_STATES; i++) { 240 for (i = 0; i < AD_MAX_STATES; i++) {
240 dev->state[i].card = dev; 241 dev->state[i].card = dev;
241 init_MUTEX(&dev->state[i].sem); 242 mutex_init(&dev->state[i].mutex);
242 init_waitqueue_head(&dev->state[i].dmabuf.wait); 243 init_waitqueue_head(&dev->state[i].dmabuf.wait);
243 } 244 }
244 245
@@ -461,7 +462,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
461 ssize_t ret = 0; 462 ssize_t ret = 0;
462 DECLARE_WAITQUEUE(wait, current); 463 DECLARE_WAITQUEUE(wait, current);
463 464
464 down(&state->sem); 465 mutex_lock(&state->mutex);
465#if 0 466#if 0
466 if (dmabuf->mapped) { 467 if (dmabuf->mapped) {
467 ret = -ENXIO; 468 ret = -ENXIO;
@@ -546,7 +547,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
546err2: 547err2:
547 remove_wait_queue(&state->dmabuf.wait, &wait); 548 remove_wait_queue(&state->dmabuf.wait, &wait);
548err1: 549err1:
549 up(&state->sem); 550 mutex_unlock(&state->mutex);
550 return ret; 551 return ret;
551} 552}
552 553
diff --git a/sound/oss/ad1889.h b/sound/oss/ad1889.h
index e04affce1dd1..861b3213f30b 100644
--- a/sound/oss/ad1889.h
+++ b/sound/oss/ad1889.h
@@ -100,7 +100,7 @@ typedef struct ad1889_state {
100 unsigned int subdivision; 100 unsigned int subdivision;
101 } dmabuf; 101 } dmabuf;
102 102
103 struct semaphore sem; 103 struct mutex mutex;
104} ad1889_state_t; 104} ad1889_state_t;
105 105
106typedef struct ad1889_dev { 106typedef struct ad1889_dev {
diff --git a/sound/oss/ali5455.c b/sound/oss/ali5455.c
index 9c9e6c0410f2..62bb936b1f3d 100644
--- a/sound/oss/ali5455.c
+++ b/sound/oss/ali5455.c
@@ -64,6 +64,8 @@
64#include <linux/smp_lock.h> 64#include <linux/smp_lock.h>
65#include <linux/ac97_codec.h> 65#include <linux/ac97_codec.h>
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <linux/mutex.h>
68
67#include <asm/uaccess.h> 69#include <asm/uaccess.h>
68 70
69#ifndef PCI_DEVICE_ID_ALI_5455 71#ifndef PCI_DEVICE_ID_ALI_5455
@@ -234,7 +236,7 @@ struct ali_state {
234 struct ali_card *card; /* Card info */ 236 struct ali_card *card; /* Card info */
235 237
236 /* single open lock mechanism, only used for recording */ 238 /* single open lock mechanism, only used for recording */
237 struct semaphore open_sem; 239 struct mutex open_mutex;
238 wait_queue_head_t open_wait; 240 wait_queue_head_t open_wait;
239 241
240 /* file mode */ 242 /* file mode */
@@ -2807,7 +2809,7 @@ found_virt:
2807 state->card = card; 2809 state->card = card;
2808 state->magic = ALI5455_STATE_MAGIC; 2810 state->magic = ALI5455_STATE_MAGIC;
2809 init_waitqueue_head(&dmabuf->wait); 2811 init_waitqueue_head(&dmabuf->wait);
2810 init_MUTEX(&state->open_sem); 2812 mutex_init(&state->open_mutex);
2811 file->private_data = state; 2813 file->private_data = state;
2812 dmabuf->trigger = 0; 2814 dmabuf->trigger = 0;
2813 /* allocate hardware channels */ 2815 /* allocate hardware channels */
@@ -3359,7 +3361,7 @@ static void __devinit ali_configure_clocking(void)
3359 state->card = card; 3361 state->card = card;
3360 state->magic = ALI5455_STATE_MAGIC; 3362 state->magic = ALI5455_STATE_MAGIC;
3361 init_waitqueue_head(&dmabuf->wait); 3363 init_waitqueue_head(&dmabuf->wait);
3362 init_MUTEX(&state->open_sem); 3364 mutex_init(&state->open_mutex);
3363 dmabuf->fmt = ALI5455_FMT_STEREO | ALI5455_FMT_16BIT; 3365 dmabuf->fmt = ALI5455_FMT_STEREO | ALI5455_FMT_16BIT;
3364 dmabuf->trigger = PCM_ENABLE_OUTPUT; 3366 dmabuf->trigger = PCM_ENABLE_OUTPUT;
3365 ali_set_dac_rate(state, 48000); 3367 ali_set_dac_rate(state, 48000);
diff --git a/sound/oss/au1000.c b/sound/oss/au1000.c
index c407de86cbb6..fe54de25aafc 100644
--- a/sound/oss/au1000.c
+++ b/sound/oss/au1000.c
@@ -68,6 +68,8 @@
68#include <linux/smp_lock.h> 68#include <linux/smp_lock.h>
69#include <linux/ac97_codec.h> 69#include <linux/ac97_codec.h>
70#include <linux/interrupt.h> 70#include <linux/interrupt.h>
71#include <linux/mutex.h>
72
71#include <asm/io.h> 73#include <asm/io.h>
72#include <asm/uaccess.h> 74#include <asm/uaccess.h>
73#include <asm/mach-au1x00/au1000.h> 75#include <asm/mach-au1x00/au1000.h>
@@ -120,8 +122,8 @@ struct au1000_state {
120 int no_vra; // do not use VRA 122 int no_vra; // do not use VRA
121 123
122 spinlock_t lock; 124 spinlock_t lock;
123 struct semaphore open_sem; 125 struct mutex open_mutex;
124 struct semaphore sem; 126 struct mutex sem;
125 mode_t open_mode; 127 mode_t open_mode;
126 wait_queue_head_t open_wait; 128 wait_queue_head_t open_wait;
127 129
@@ -1106,7 +1108,7 @@ static ssize_t au1000_read(struct file *file, char *buffer,
1106 1108
1107 count *= db->cnt_factor; 1109 count *= db->cnt_factor;
1108 1110
1109 down(&s->sem); 1111 mutex_lock(&s->sem);
1110 add_wait_queue(&db->wait, &wait); 1112 add_wait_queue(&db->wait, &wait);
1111 1113
1112 while (count > 0) { 1114 while (count > 0) {
@@ -1125,14 +1127,14 @@ static ssize_t au1000_read(struct file *file, char *buffer,
1125 ret = -EAGAIN; 1127 ret = -EAGAIN;
1126 goto out; 1128 goto out;
1127 } 1129 }
1128 up(&s->sem); 1130 mutex_unlock(&s->sem);
1129 schedule(); 1131 schedule();
1130 if (signal_pending(current)) { 1132 if (signal_pending(current)) {
1131 if (!ret) 1133 if (!ret)
1132 ret = -ERESTARTSYS; 1134 ret = -ERESTARTSYS;
1133 goto out2; 1135 goto out2;
1134 } 1136 }
1135 down(&s->sem); 1137 mutex_lock(&s->sem);
1136 } 1138 }
1137 } while (avail <= 0); 1139 } while (avail <= 0);
1138 1140
@@ -1159,7 +1161,7 @@ static ssize_t au1000_read(struct file *file, char *buffer,
1159 } // while (count > 0) 1161 } // while (count > 0)
1160 1162
1161out: 1163out:
1162 up(&s->sem); 1164 mutex_unlock(&s->sem);
1163out2: 1165out2:
1164 remove_wait_queue(&db->wait, &wait); 1166 remove_wait_queue(&db->wait, &wait);
1165 set_current_state(TASK_RUNNING); 1167 set_current_state(TASK_RUNNING);
@@ -1187,7 +1189,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
1187 1189
1188 count *= db->cnt_factor; 1190 count *= db->cnt_factor;
1189 1191
1190 down(&s->sem); 1192 mutex_lock(&s->sem);
1191 add_wait_queue(&db->wait, &wait); 1193 add_wait_queue(&db->wait, &wait);
1192 1194
1193 while (count > 0) { 1195 while (count > 0) {
@@ -1204,14 +1206,14 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
1204 ret = -EAGAIN; 1206 ret = -EAGAIN;
1205 goto out; 1207 goto out;
1206 } 1208 }
1207 up(&s->sem); 1209 mutex_unlock(&s->sem);
1208 schedule(); 1210 schedule();
1209 if (signal_pending(current)) { 1211 if (signal_pending(current)) {
1210 if (!ret) 1212 if (!ret)
1211 ret = -ERESTARTSYS; 1213 ret = -ERESTARTSYS;
1212 goto out2; 1214 goto out2;
1213 } 1215 }
1214 down(&s->sem); 1216 mutex_lock(&s->sem);
1215 } 1217 }
1216 } while (avail <= 0); 1218 } while (avail <= 0);
1217 1219
@@ -1240,7 +1242,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
1240 } // while (count > 0) 1242 } // while (count > 0)
1241 1243
1242out: 1244out:
1243 up(&s->sem); 1245 mutex_unlock(&s->sem);
1244out2: 1246out2:
1245 remove_wait_queue(&db->wait, &wait); 1247 remove_wait_queue(&db->wait, &wait);
1246 set_current_state(TASK_RUNNING); 1248 set_current_state(TASK_RUNNING);
@@ -1298,7 +1300,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
1298 dbg("%s", __FUNCTION__); 1300 dbg("%s", __FUNCTION__);
1299 1301
1300 lock_kernel(); 1302 lock_kernel();
1301 down(&s->sem); 1303 mutex_lock(&s->sem);
1302 if (vma->vm_flags & VM_WRITE) 1304 if (vma->vm_flags & VM_WRITE)
1303 db = &s->dma_dac; 1305 db = &s->dma_dac;
1304 else if (vma->vm_flags & VM_READ) 1306 else if (vma->vm_flags & VM_READ)
@@ -1324,7 +1326,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
1324 vma->vm_flags &= ~VM_IO; 1326 vma->vm_flags &= ~VM_IO;
1325 db->mapped = 1; 1327 db->mapped = 1;
1326out: 1328out:
1327 up(&s->sem); 1329 mutex_unlock(&s->sem);
1328 unlock_kernel(); 1330 unlock_kernel();
1329 return ret; 1331 return ret;
1330} 1332}
@@ -1829,21 +1831,21 @@ static int au1000_open(struct inode *inode, struct file *file)
1829 1831
1830 file->private_data = s; 1832 file->private_data = s;
1831 /* wait for device to become free */ 1833 /* wait for device to become free */
1832 down(&s->open_sem); 1834 mutex_lock(&s->open_mutex);
1833 while (s->open_mode & file->f_mode) { 1835 while (s->open_mode & file->f_mode) {
1834 if (file->f_flags & O_NONBLOCK) { 1836 if (file->f_flags & O_NONBLOCK) {
1835 up(&s->open_sem); 1837 mutex_unlock(&s->open_mutex);
1836 return -EBUSY; 1838 return -EBUSY;
1837 } 1839 }
1838 add_wait_queue(&s->open_wait, &wait); 1840 add_wait_queue(&s->open_wait, &wait);
1839 __set_current_state(TASK_INTERRUPTIBLE); 1841 __set_current_state(TASK_INTERRUPTIBLE);
1840 up(&s->open_sem); 1842 mutex_unlock(&s->open_mutex);
1841 schedule(); 1843 schedule();
1842 remove_wait_queue(&s->open_wait, &wait); 1844 remove_wait_queue(&s->open_wait, &wait);
1843 set_current_state(TASK_RUNNING); 1845 set_current_state(TASK_RUNNING);
1844 if (signal_pending(current)) 1846 if (signal_pending(current))
1845 return -ERESTARTSYS; 1847 return -ERESTARTSYS;
1846 down(&s->open_sem); 1848 mutex_lock(&s->open_mutex);
1847 } 1849 }
1848 1850
1849 stop_dac(s); 1851 stop_dac(s);
@@ -1879,8 +1881,8 @@ static int au1000_open(struct inode *inode, struct file *file)
1879 } 1881 }
1880 1882
1881 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1883 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1882 up(&s->open_sem); 1884 mutex_unlock(&s->open_mutex);
1883 init_MUTEX(&s->sem); 1885 mutex_init(&s->sem);
1884 return nonseekable_open(inode, file); 1886 return nonseekable_open(inode, file);
1885} 1887}
1886 1888
@@ -1896,7 +1898,7 @@ static int au1000_release(struct inode *inode, struct file *file)
1896 lock_kernel(); 1898 lock_kernel();
1897 } 1899 }
1898 1900
1899 down(&s->open_sem); 1901 mutex_lock(&s->open_mutex);
1900 if (file->f_mode & FMODE_WRITE) { 1902 if (file->f_mode & FMODE_WRITE) {
1901 stop_dac(s); 1903 stop_dac(s);
1902 dealloc_dmabuf(s, &s->dma_dac); 1904 dealloc_dmabuf(s, &s->dma_dac);
@@ -1906,7 +1908,7 @@ static int au1000_release(struct inode *inode, struct file *file)
1906 dealloc_dmabuf(s, &s->dma_adc); 1908 dealloc_dmabuf(s, &s->dma_adc);
1907 } 1909 }
1908 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); 1910 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
1909 up(&s->open_sem); 1911 mutex_unlock(&s->open_mutex);
1910 wake_up(&s->open_wait); 1912 wake_up(&s->open_wait);
1911 unlock_kernel(); 1913 unlock_kernel();
1912 return 0; 1914 return 0;
@@ -1996,7 +1998,7 @@ static int __devinit au1000_probe(void)
1996 init_waitqueue_head(&s->dma_adc.wait); 1998 init_waitqueue_head(&s->dma_adc.wait);
1997 init_waitqueue_head(&s->dma_dac.wait); 1999 init_waitqueue_head(&s->dma_dac.wait);
1998 init_waitqueue_head(&s->open_wait); 2000 init_waitqueue_head(&s->open_wait);
1999 init_MUTEX(&s->open_sem); 2001 mutex_init(&s->open_mutex);
2000 spin_lock_init(&s->lock); 2002 spin_lock_init(&s->lock);
2001 s->codec.private_data = s; 2003 s->codec.private_data = s;
2002 s->codec.id = 0; 2004 s->codec.id = 0;
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index bdee0502f3e2..6a4956b8025d 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -52,6 +52,8 @@
52#include <linux/spinlock.h> 52#include <linux/spinlock.h>
53#include <linux/smp_lock.h> 53#include <linux/smp_lock.h>
54#include <linux/ac97_codec.h> 54#include <linux/ac97_codec.h>
55#include <linux/mutex.h>
56
55#include <asm/io.h> 57#include <asm/io.h>
56#include <asm/uaccess.h> 58#include <asm/uaccess.h>
57#include <asm/hardirq.h> 59#include <asm/hardirq.h>
@@ -90,8 +92,8 @@ static struct au1550_state {
90 int no_vra; /* do not use VRA */ 92 int no_vra; /* do not use VRA */
91 93
92 spinlock_t lock; 94 spinlock_t lock;
93 struct semaphore open_sem; 95 struct mutex open_mutex;
94 struct semaphore sem; 96 struct mutex sem;
95 mode_t open_mode; 97 mode_t open_mode;
96 wait_queue_head_t open_wait; 98 wait_queue_head_t open_wait;
97 99
@@ -1044,7 +1046,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
1044 1046
1045 count *= db->cnt_factor; 1047 count *= db->cnt_factor;
1046 1048
1047 down(&s->sem); 1049 mutex_lock(&s->sem);
1048 add_wait_queue(&db->wait, &wait); 1050 add_wait_queue(&db->wait, &wait);
1049 1051
1050 while (count > 0) { 1052 while (count > 0) {
@@ -1064,14 +1066,14 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
1064 ret = -EAGAIN; 1066 ret = -EAGAIN;
1065 goto out; 1067 goto out;
1066 } 1068 }
1067 up(&s->sem); 1069 mutex_unlock(&s->sem);
1068 schedule(); 1070 schedule();
1069 if (signal_pending(current)) { 1071 if (signal_pending(current)) {
1070 if (!ret) 1072 if (!ret)
1071 ret = -ERESTARTSYS; 1073 ret = -ERESTARTSYS;
1072 goto out2; 1074 goto out2;
1073 } 1075 }
1074 down(&s->sem); 1076 mutex_lock(&s->sem);
1075 } 1077 }
1076 } while (avail <= 0); 1078 } while (avail <= 0);
1077 1079
@@ -1099,7 +1101,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
1099 } /* while (count > 0) */ 1101 } /* while (count > 0) */
1100 1102
1101out: 1103out:
1102 up(&s->sem); 1104 mutex_unlock(&s->sem);
1103out2: 1105out2:
1104 remove_wait_queue(&db->wait, &wait); 1106 remove_wait_queue(&db->wait, &wait);
1105 set_current_state(TASK_RUNNING); 1107 set_current_state(TASK_RUNNING);
@@ -1125,7 +1127,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
1125 1127
1126 count *= db->cnt_factor; 1128 count *= db->cnt_factor;
1127 1129
1128 down(&s->sem); 1130 mutex_lock(&s->sem);
1129 add_wait_queue(&db->wait, &wait); 1131 add_wait_queue(&db->wait, &wait);
1130 1132
1131 while (count > 0) { 1133 while (count > 0) {
@@ -1143,14 +1145,14 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
1143 ret = -EAGAIN; 1145 ret = -EAGAIN;
1144 goto out; 1146 goto out;
1145 } 1147 }
1146 up(&s->sem); 1148 mutex_unlock(&s->sem);
1147 schedule(); 1149 schedule();
1148 if (signal_pending(current)) { 1150 if (signal_pending(current)) {
1149 if (!ret) 1151 if (!ret)
1150 ret = -ERESTARTSYS; 1152 ret = -ERESTARTSYS;
1151 goto out2; 1153 goto out2;
1152 } 1154 }
1153 down(&s->sem); 1155 mutex_lock(&s->sem);
1154 } 1156 }
1155 } while (avail <= 0); 1157 } while (avail <= 0);
1156 1158
@@ -1196,7 +1198,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
1196 } /* while (count > 0) */ 1198 } /* while (count > 0) */
1197 1199
1198out: 1200out:
1199 up(&s->sem); 1201 mutex_unlock(&s->sem);
1200out2: 1202out2:
1201 remove_wait_queue(&db->wait, &wait); 1203 remove_wait_queue(&db->wait, &wait);
1202 set_current_state(TASK_RUNNING); 1204 set_current_state(TASK_RUNNING);
@@ -1253,7 +1255,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
1253 int ret = 0; 1255 int ret = 0;
1254 1256
1255 lock_kernel(); 1257 lock_kernel();
1256 down(&s->sem); 1258 mutex_lock(&s->sem);
1257 if (vma->vm_flags & VM_WRITE) 1259 if (vma->vm_flags & VM_WRITE)
1258 db = &s->dma_dac; 1260 db = &s->dma_dac;
1259 else if (vma->vm_flags & VM_READ) 1261 else if (vma->vm_flags & VM_READ)
@@ -1279,7 +1281,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
1279 vma->vm_flags &= ~VM_IO; 1281 vma->vm_flags &= ~VM_IO;
1280 db->mapped = 1; 1282 db->mapped = 1;
1281out: 1283out:
1282 up(&s->sem); 1284 mutex_unlock(&s->sem);
1283 unlock_kernel(); 1285 unlock_kernel();
1284 return ret; 1286 return ret;
1285} 1287}
@@ -1790,21 +1792,21 @@ au1550_open(struct inode *inode, struct file *file)
1790 1792
1791 file->private_data = s; 1793 file->private_data = s;
1792 /* wait for device to become free */ 1794 /* wait for device to become free */
1793 down(&s->open_sem); 1795 mutex_lock(&s->open_mutex);
1794 while (s->open_mode & file->f_mode) { 1796 while (s->open_mode & file->f_mode) {
1795 if (file->f_flags & O_NONBLOCK) { 1797 if (file->f_flags & O_NONBLOCK) {
1796 up(&s->open_sem); 1798 mutex_unlock(&s->open_mutex);
1797 return -EBUSY; 1799 return -EBUSY;
1798 } 1800 }
1799 add_wait_queue(&s->open_wait, &wait); 1801 add_wait_queue(&s->open_wait, &wait);
1800 __set_current_state(TASK_INTERRUPTIBLE); 1802 __set_current_state(TASK_INTERRUPTIBLE);
1801 up(&s->open_sem); 1803 mutex_unlock(&s->open_mutex);
1802 schedule(); 1804 schedule();
1803 remove_wait_queue(&s->open_wait, &wait); 1805 remove_wait_queue(&s->open_wait, &wait);
1804 set_current_state(TASK_RUNNING); 1806 set_current_state(TASK_RUNNING);
1805 if (signal_pending(current)) 1807 if (signal_pending(current))
1806 return -ERESTARTSYS; 1808 return -ERESTARTSYS;
1807 down(&s->open_sem); 1809 mutex_lock(&s->open_mutex);
1808 } 1810 }
1809 1811
1810 stop_dac(s); 1812 stop_dac(s);
@@ -1840,8 +1842,8 @@ au1550_open(struct inode *inode, struct file *file)
1840 } 1842 }
1841 1843
1842 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1844 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1843 up(&s->open_sem); 1845 mutex_unlock(&s->open_mutex);
1844 init_MUTEX(&s->sem); 1846 mutex_init(&s->sem);
1845 return 0; 1847 return 0;
1846} 1848}
1847 1849
@@ -1858,7 +1860,7 @@ au1550_release(struct inode *inode, struct file *file)
1858 lock_kernel(); 1860 lock_kernel();
1859 } 1861 }
1860 1862
1861 down(&s->open_sem); 1863 mutex_lock(&s->open_mutex);
1862 if (file->f_mode & FMODE_WRITE) { 1864 if (file->f_mode & FMODE_WRITE) {
1863 stop_dac(s); 1865 stop_dac(s);
1864 kfree(s->dma_dac.rawbuf); 1866 kfree(s->dma_dac.rawbuf);
@@ -1870,7 +1872,7 @@ au1550_release(struct inode *inode, struct file *file)
1870 s->dma_adc.rawbuf = NULL; 1872 s->dma_adc.rawbuf = NULL;
1871 } 1873 }
1872 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); 1874 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
1873 up(&s->open_sem); 1875 mutex_unlock(&s->open_mutex);
1874 wake_up(&s->open_wait); 1876 wake_up(&s->open_wait);
1875 unlock_kernel(); 1877 unlock_kernel();
1876 return 0; 1878 return 0;
@@ -1902,7 +1904,7 @@ au1550_probe(void)
1902 init_waitqueue_head(&s->dma_adc.wait); 1904 init_waitqueue_head(&s->dma_adc.wait);
1903 init_waitqueue_head(&s->dma_dac.wait); 1905 init_waitqueue_head(&s->dma_dac.wait);
1904 init_waitqueue_head(&s->open_wait); 1906 init_waitqueue_head(&s->open_wait);
1905 init_MUTEX(&s->open_sem); 1907 mutex_init(&s->open_mutex);
1906 spin_lock_init(&s->lock); 1908 spin_lock_init(&s->lock);
1907 1909
1908 s->codec = ac97_alloc_codec(); 1910 s->codec = ac97_alloc_codec();
diff --git a/sound/oss/btaudio.c b/sound/oss/btaudio.c
index 4007a5680acb..bfe3b534ef30 100644
--- a/sound/oss/btaudio.c
+++ b/sound/oss/btaudio.c
@@ -32,6 +32,8 @@
32#include <linux/soundcard.h> 32#include <linux/soundcard.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/kdev_t.h> 34#include <linux/kdev_t.h>
35#include <linux/mutex.h>
36
35#include <asm/uaccess.h> 37#include <asm/uaccess.h>
36#include <asm/io.h> 38#include <asm/io.h>
37 39
@@ -108,7 +110,7 @@ struct btaudio {
108 110
109 /* locking */ 111 /* locking */
110 int users; 112 int users;
111 struct semaphore lock; 113 struct mutex lock;
112 114
113 /* risc instructions */ 115 /* risc instructions */
114 unsigned int risc_size; 116 unsigned int risc_size;
@@ -440,7 +442,7 @@ static struct file_operations btaudio_mixer_fops = {
440static int btaudio_dsp_open(struct inode *inode, struct file *file, 442static int btaudio_dsp_open(struct inode *inode, struct file *file,
441 struct btaudio *bta, int analog) 443 struct btaudio *bta, int analog)
442{ 444{
443 down(&bta->lock); 445 mutex_lock(&bta->lock);
444 if (bta->users) 446 if (bta->users)
445 goto busy; 447 goto busy;
446 bta->users++; 448 bta->users++;
@@ -452,11 +454,11 @@ static int btaudio_dsp_open(struct inode *inode, struct file *file,
452 bta->read_count = 0; 454 bta->read_count = 0;
453 bta->sampleshift = 0; 455 bta->sampleshift = 0;
454 456
455 up(&bta->lock); 457 mutex_unlock(&bta->lock);
456 return 0; 458 return 0;
457 459
458 busy: 460 busy:
459 up(&bta->lock); 461 mutex_unlock(&bta->lock);
460 return -EBUSY; 462 return -EBUSY;
461} 463}
462 464
@@ -496,11 +498,11 @@ static int btaudio_dsp_release(struct inode *inode, struct file *file)
496{ 498{
497 struct btaudio *bta = file->private_data; 499 struct btaudio *bta = file->private_data;
498 500
499 down(&bta->lock); 501 mutex_lock(&bta->lock);
500 if (bta->recording) 502 if (bta->recording)
501 stop_recording(bta); 503 stop_recording(bta);
502 bta->users--; 504 bta->users--;
503 up(&bta->lock); 505 mutex_unlock(&bta->lock);
504 return 0; 506 return 0;
505} 507}
506 508
@@ -513,7 +515,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
513 DECLARE_WAITQUEUE(wait, current); 515 DECLARE_WAITQUEUE(wait, current);
514 516
515 add_wait_queue(&bta->readq, &wait); 517 add_wait_queue(&bta->readq, &wait);
516 down(&bta->lock); 518 mutex_lock(&bta->lock);
517 while (swcount > 0) { 519 while (swcount > 0) {
518 if (0 == bta->read_count) { 520 if (0 == bta->read_count) {
519 if (!bta->recording) { 521 if (!bta->recording) {
@@ -528,10 +530,10 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
528 ret = -EAGAIN; 530 ret = -EAGAIN;
529 break; 531 break;
530 } 532 }
531 up(&bta->lock); 533 mutex_unlock(&bta->lock);
532 current->state = TASK_INTERRUPTIBLE; 534 current->state = TASK_INTERRUPTIBLE;
533 schedule(); 535 schedule();
534 down(&bta->lock); 536 mutex_lock(&bta->lock);
535 if(signal_pending(current)) { 537 if(signal_pending(current)) {
536 if (0 == ret) 538 if (0 == ret)
537 ret = -EINTR; 539 ret = -EINTR;
@@ -604,7 +606,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
604 if (bta->read_offset == bta->buf_size) 606 if (bta->read_offset == bta->buf_size)
605 bta->read_offset = 0; 607 bta->read_offset = 0;
606 } 608 }
607 up(&bta->lock); 609 mutex_unlock(&bta->lock);
608 remove_wait_queue(&bta->readq, &wait); 610 remove_wait_queue(&bta->readq, &wait);
609 current->state = TASK_RUNNING; 611 current->state = TASK_RUNNING;
610 return ret; 612 return ret;
@@ -651,10 +653,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
651 bta->decimation = 0; 653 bta->decimation = 0;
652 } 654 }
653 if (bta->recording) { 655 if (bta->recording) {
654 down(&bta->lock); 656 mutex_lock(&bta->lock);
655 stop_recording(bta); 657 stop_recording(bta);
656 start_recording(bta); 658 start_recording(bta);
657 up(&bta->lock); 659 mutex_unlock(&bta->lock);
658 } 660 }
659 /* fall through */ 661 /* fall through */
660 case SOUND_PCM_READ_RATE: 662 case SOUND_PCM_READ_RATE:
@@ -716,10 +718,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
716 else 718 else
717 bta->bits = 16; 719 bta->bits = 16;
718 if (bta->recording) { 720 if (bta->recording) {
719 down(&bta->lock); 721 mutex_lock(&bta->lock);
720 stop_recording(bta); 722 stop_recording(bta);
721 start_recording(bta); 723 start_recording(bta);
722 up(&bta->lock); 724 mutex_unlock(&bta->lock);
723 } 725 }
724 } 726 }
725 if (debug) 727 if (debug)
@@ -736,9 +738,9 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
736 738
737 case SNDCTL_DSP_RESET: 739 case SNDCTL_DSP_RESET:
738 if (bta->recording) { 740 if (bta->recording) {
739 down(&bta->lock); 741 mutex_lock(&bta->lock);
740 stop_recording(bta); 742 stop_recording(bta);
741 up(&bta->lock); 743 mutex_unlock(&bta->lock);
742 } 744 }
743 return 0; 745 return 0;
744 case SNDCTL_DSP_GETBLKSIZE: 746 case SNDCTL_DSP_GETBLKSIZE:
@@ -941,7 +943,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
941 if (rate) 943 if (rate)
942 bta->rate = rate; 944 bta->rate = rate;
943 945
944 init_MUTEX(&bta->lock); 946 mutex_init(&bta->lock);
945 init_waitqueue_head(&bta->readq); 947 init_waitqueue_head(&bta->readq);
946 948
947 if (-1 != latency) { 949 if (-1 != latency) {
diff --git a/sound/oss/cmpci.c b/sound/oss/cmpci.c
index 7cfbb08db537..1fbd5137f6d7 100644
--- a/sound/oss/cmpci.c
+++ b/sound/oss/cmpci.c
@@ -138,6 +138,8 @@
138#endif 138#endif
139#ifdef CONFIG_SOUND_CMPCI_JOYSTICK 139#ifdef CONFIG_SOUND_CMPCI_JOYSTICK
140#include <linux/gameport.h> 140#include <linux/gameport.h>
141#include <linux/mutex.h>
142
141#endif 143#endif
142 144
143/* --------------------------------------------------------------------- */ 145/* --------------------------------------------------------------------- */
@@ -392,7 +394,7 @@ struct cm_state {
392 unsigned char fmt, enable; 394 unsigned char fmt, enable;
393 395
394 spinlock_t lock; 396 spinlock_t lock;
395 struct semaphore open_sem; 397 struct mutex open_mutex;
396 mode_t open_mode; 398 mode_t open_mode;
397 wait_queue_head_t open_wait; 399 wait_queue_head_t open_wait;
398 400
@@ -2825,21 +2827,21 @@ static int cm_open(struct inode *inode, struct file *file)
2825 VALIDATE_STATE(s); 2827 VALIDATE_STATE(s);
2826 file->private_data = s; 2828 file->private_data = s;
2827 /* wait for device to become free */ 2829 /* wait for device to become free */
2828 down(&s->open_sem); 2830 mutex_lock(&s->open_mutex);
2829 while (s->open_mode & file->f_mode) { 2831 while (s->open_mode & file->f_mode) {
2830 if (file->f_flags & O_NONBLOCK) { 2832 if (file->f_flags & O_NONBLOCK) {
2831 up(&s->open_sem); 2833 mutex_unlock(&s->open_mutex);
2832 return -EBUSY; 2834 return -EBUSY;
2833 } 2835 }
2834 add_wait_queue(&s->open_wait, &wait); 2836 add_wait_queue(&s->open_wait, &wait);
2835 __set_current_state(TASK_INTERRUPTIBLE); 2837 __set_current_state(TASK_INTERRUPTIBLE);
2836 up(&s->open_sem); 2838 mutex_unlock(&s->open_mutex);
2837 schedule(); 2839 schedule();
2838 remove_wait_queue(&s->open_wait, &wait); 2840 remove_wait_queue(&s->open_wait, &wait);
2839 set_current_state(TASK_RUNNING); 2841 set_current_state(TASK_RUNNING);
2840 if (signal_pending(current)) 2842 if (signal_pending(current))
2841 return -ERESTARTSYS; 2843 return -ERESTARTSYS;
2842 down(&s->open_sem); 2844 mutex_lock(&s->open_mutex);
2843 } 2845 }
2844 if (file->f_mode & FMODE_READ) { 2846 if (file->f_mode & FMODE_READ) {
2845 s->status &= ~DO_BIGENDIAN_R; 2847 s->status &= ~DO_BIGENDIAN_R;
@@ -2867,7 +2869,7 @@ static int cm_open(struct inode *inode, struct file *file)
2867 } 2869 }
2868 set_fmt(s, fmtm, fmts); 2870 set_fmt(s, fmtm, fmts);
2869 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2871 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2870 up(&s->open_sem); 2872 mutex_unlock(&s->open_mutex);
2871 return nonseekable_open(inode, file); 2873 return nonseekable_open(inode, file);
2872} 2874}
2873 2875
@@ -2879,7 +2881,7 @@ static int cm_release(struct inode *inode, struct file *file)
2879 lock_kernel(); 2881 lock_kernel();
2880 if (file->f_mode & FMODE_WRITE) 2882 if (file->f_mode & FMODE_WRITE)
2881 drain_dac(s, file->f_flags & O_NONBLOCK); 2883 drain_dac(s, file->f_flags & O_NONBLOCK);
2882 down(&s->open_sem); 2884 mutex_lock(&s->open_mutex);
2883 if (file->f_mode & FMODE_WRITE) { 2885 if (file->f_mode & FMODE_WRITE) {
2884 stop_dac(s); 2886 stop_dac(s);
2885 2887
@@ -2903,7 +2905,7 @@ static int cm_release(struct inode *inode, struct file *file)
2903 s->status &= ~DO_BIGENDIAN_R; 2905 s->status &= ~DO_BIGENDIAN_R;
2904 } 2906 }
2905 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 2907 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
2906 up(&s->open_sem); 2908 mutex_unlock(&s->open_mutex);
2907 wake_up(&s->open_wait); 2909 wake_up(&s->open_wait);
2908 unlock_kernel(); 2910 unlock_kernel();
2909 return 0; 2911 return 0;
@@ -3080,7 +3082,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id
3080 init_waitqueue_head(&s->dma_adc.wait); 3082 init_waitqueue_head(&s->dma_adc.wait);
3081 init_waitqueue_head(&s->dma_dac.wait); 3083 init_waitqueue_head(&s->dma_dac.wait);
3082 init_waitqueue_head(&s->open_wait); 3084 init_waitqueue_head(&s->open_wait);
3083 init_MUTEX(&s->open_sem); 3085 mutex_init(&s->open_mutex);
3084 spin_lock_init(&s->lock); 3086 spin_lock_init(&s->lock);
3085 s->magic = CM_MAGIC; 3087 s->magic = CM_MAGIC;
3086 s->dev = pcidev; 3088 s->dev = pcidev;
diff --git a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
index 0720365f6438..0004442f9b7e 100644
--- a/sound/oss/cs4281/cs4281m.c
+++ b/sound/oss/cs4281/cs4281m.c
@@ -245,9 +245,9 @@ struct cs4281_state {
245 void *tmpbuff; // tmp buffer for sample conversions 245 void *tmpbuff; // tmp buffer for sample conversions
246 unsigned ena; 246 unsigned ena;
247 spinlock_t lock; 247 spinlock_t lock;
248 struct semaphore open_sem; 248 struct mutex open_sem;
249 struct semaphore open_sem_adc; 249 struct mutex open_sem_adc;
250 struct semaphore open_sem_dac; 250 struct mutex open_sem_dac;
251 mode_t open_mode; 251 mode_t open_mode;
252 wait_queue_head_t open_wait; 252 wait_queue_head_t open_wait;
253 wait_queue_head_t open_wait_adc; 253 wait_queue_head_t open_wait_adc;
@@ -3598,20 +3598,20 @@ static int cs4281_release(struct inode *inode, struct file *file)
3598 3598
3599 if (file->f_mode & FMODE_WRITE) { 3599 if (file->f_mode & FMODE_WRITE) {
3600 drain_dac(s, file->f_flags & O_NONBLOCK); 3600 drain_dac(s, file->f_flags & O_NONBLOCK);
3601 down(&s->open_sem_dac); 3601 mutex_lock(&s->open_sem_dac);
3602 stop_dac(s); 3602 stop_dac(s);
3603 dealloc_dmabuf(s, &s->dma_dac); 3603 dealloc_dmabuf(s, &s->dma_dac);
3604 s->open_mode &= ~FMODE_WRITE; 3604 s->open_mode &= ~FMODE_WRITE;
3605 up(&s->open_sem_dac); 3605 mutex_unlock(&s->open_sem_dac);
3606 wake_up(&s->open_wait_dac); 3606 wake_up(&s->open_wait_dac);
3607 } 3607 }
3608 if (file->f_mode & FMODE_READ) { 3608 if (file->f_mode & FMODE_READ) {
3609 drain_adc(s, file->f_flags & O_NONBLOCK); 3609 drain_adc(s, file->f_flags & O_NONBLOCK);
3610 down(&s->open_sem_adc); 3610 mutex_lock(&s->open_sem_adc);
3611 stop_adc(s); 3611 stop_adc(s);
3612 dealloc_dmabuf(s, &s->dma_adc); 3612 dealloc_dmabuf(s, &s->dma_adc);
3613 s->open_mode &= ~FMODE_READ; 3613 s->open_mode &= ~FMODE_READ;
3614 up(&s->open_sem_adc); 3614 mutex_unlock(&s->open_sem_adc);
3615 wake_up(&s->open_wait_adc); 3615 wake_up(&s->open_wait_adc);
3616 } 3616 }
3617 return 0; 3617 return 0;
@@ -3651,33 +3651,33 @@ static int cs4281_open(struct inode *inode, struct file *file)
3651 return -ENODEV; 3651 return -ENODEV;
3652 } 3652 }
3653 if (file->f_mode & FMODE_WRITE) { 3653 if (file->f_mode & FMODE_WRITE) {
3654 down(&s->open_sem_dac); 3654 mutex_lock(&s->open_sem_dac);
3655 while (s->open_mode & FMODE_WRITE) { 3655 while (s->open_mode & FMODE_WRITE) {
3656 if (file->f_flags & O_NONBLOCK) { 3656 if (file->f_flags & O_NONBLOCK) {
3657 up(&s->open_sem_dac); 3657 mutex_unlock(&s->open_sem_dac);
3658 return -EBUSY; 3658 return -EBUSY;
3659 } 3659 }
3660 up(&s->open_sem_dac); 3660 mutex_unlock(&s->open_sem_dac);
3661 interruptible_sleep_on(&s->open_wait_dac); 3661 interruptible_sleep_on(&s->open_wait_dac);
3662 3662
3663 if (signal_pending(current)) 3663 if (signal_pending(current))
3664 return -ERESTARTSYS; 3664 return -ERESTARTSYS;
3665 down(&s->open_sem_dac); 3665 mutex_lock(&s->open_sem_dac);
3666 } 3666 }
3667 } 3667 }
3668 if (file->f_mode & FMODE_READ) { 3668 if (file->f_mode & FMODE_READ) {
3669 down(&s->open_sem_adc); 3669 mutex_lock(&s->open_sem_adc);
3670 while (s->open_mode & FMODE_READ) { 3670 while (s->open_mode & FMODE_READ) {
3671 if (file->f_flags & O_NONBLOCK) { 3671 if (file->f_flags & O_NONBLOCK) {
3672 up(&s->open_sem_adc); 3672 mutex_unlock(&s->open_sem_adc);
3673 return -EBUSY; 3673 return -EBUSY;
3674 } 3674 }
3675 up(&s->open_sem_adc); 3675 mutex_unlock(&s->open_sem_adc);
3676 interruptible_sleep_on(&s->open_wait_adc); 3676 interruptible_sleep_on(&s->open_wait_adc);
3677 3677
3678 if (signal_pending(current)) 3678 if (signal_pending(current))
3679 return -ERESTARTSYS; 3679 return -ERESTARTSYS;
3680 down(&s->open_sem_adc); 3680 mutex_lock(&s->open_sem_adc);
3681 } 3681 }
3682 } 3682 }
3683 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 3683 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
@@ -3691,7 +3691,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
3691 s->ena &= ~FMODE_READ; 3691 s->ena &= ~FMODE_READ;
3692 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = 3692 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
3693 s->dma_adc.subdivision = 0; 3693 s->dma_adc.subdivision = 0;
3694 up(&s->open_sem_adc); 3694 mutex_unlock(&s->open_sem_adc);
3695 3695
3696 if (prog_dmabuf_adc(s)) { 3696 if (prog_dmabuf_adc(s)) {
3697 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR 3697 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -3711,7 +3711,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
3711 s->ena &= ~FMODE_WRITE; 3711 s->ena &= ~FMODE_WRITE;
3712 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = 3712 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
3713 s->dma_dac.subdivision = 0; 3713 s->dma_dac.subdivision = 0;
3714 up(&s->open_sem_dac); 3714 mutex_unlock(&s->open_sem_dac);
3715 3715
3716 if (prog_dmabuf_dac(s)) { 3716 if (prog_dmabuf_dac(s)) {
3717 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR 3717 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -3978,17 +3978,17 @@ static int cs4281_midi_open(struct inode *inode, struct file *file)
3978 VALIDATE_STATE(s); 3978 VALIDATE_STATE(s);
3979 file->private_data = s; 3979 file->private_data = s;
3980 // wait for device to become free 3980 // wait for device to become free
3981 down(&s->open_sem); 3981 mutex_lock(&s->open_sem);
3982 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 3982 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
3983 if (file->f_flags & O_NONBLOCK) { 3983 if (file->f_flags & O_NONBLOCK) {
3984 up(&s->open_sem); 3984 mutex_unlock(&s->open_sem);
3985 return -EBUSY; 3985 return -EBUSY;
3986 } 3986 }
3987 up(&s->open_sem); 3987 mutex_unlock(&s->open_sem);
3988 interruptible_sleep_on(&s->open_wait); 3988 interruptible_sleep_on(&s->open_wait);
3989 if (signal_pending(current)) 3989 if (signal_pending(current))
3990 return -ERESTARTSYS; 3990 return -ERESTARTSYS;
3991 down(&s->open_sem); 3991 mutex_lock(&s->open_sem);
3992 } 3992 }
3993 spin_lock_irqsave(&s->lock, flags); 3993 spin_lock_irqsave(&s->lock, flags);
3994 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 3994 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -4018,7 +4018,7 @@ static int cs4281_midi_open(struct inode *inode, struct file *file)
4018 (file-> 4018 (file->
4019 f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | 4019 f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ |
4020 FMODE_MIDI_WRITE); 4020 FMODE_MIDI_WRITE);
4021 up(&s->open_sem); 4021 mutex_unlock(&s->open_sem);
4022 return nonseekable_open(inode, file); 4022 return nonseekable_open(inode, file);
4023} 4023}
4024 4024
@@ -4057,7 +4057,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
4057 remove_wait_queue(&s->midi.owait, &wait); 4057 remove_wait_queue(&s->midi.owait, &wait);
4058 current->state = TASK_RUNNING; 4058 current->state = TASK_RUNNING;
4059 } 4059 }
4060 down(&s->open_sem); 4060 mutex_lock(&s->open_sem);
4061 s->open_mode &= 4061 s->open_mode &=
4062 (~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ | 4062 (~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ |
4063 FMODE_MIDI_WRITE); 4063 FMODE_MIDI_WRITE);
@@ -4067,7 +4067,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
4067 del_timer(&s->midi.timer); 4067 del_timer(&s->midi.timer);
4068 } 4068 }
4069 spin_unlock_irqrestore(&s->lock, flags); 4069 spin_unlock_irqrestore(&s->lock, flags);
4070 up(&s->open_sem); 4070 mutex_unlock(&s->open_sem);
4071 wake_up(&s->open_wait); 4071 wake_up(&s->open_wait);
4072 return 0; 4072 return 0;
4073} 4073}
@@ -4300,9 +4300,9 @@ static int __devinit cs4281_probe(struct pci_dev *pcidev,
4300 init_waitqueue_head(&s->open_wait_dac); 4300 init_waitqueue_head(&s->open_wait_dac);
4301 init_waitqueue_head(&s->midi.iwait); 4301 init_waitqueue_head(&s->midi.iwait);
4302 init_waitqueue_head(&s->midi.owait); 4302 init_waitqueue_head(&s->midi.owait);
4303 init_MUTEX(&s->open_sem); 4303 mutex_init(&s->open_sem);
4304 init_MUTEX(&s->open_sem_adc); 4304 mutex_init(&s->open_sem_adc);
4305 init_MUTEX(&s->open_sem_dac); 4305 mutex_init(&s->open_sem_dac);
4306 spin_lock_init(&s->lock); 4306 spin_lock_init(&s->lock);
4307 s->pBA0phys = pci_resource_start(pcidev, 0); 4307 s->pBA0phys = pci_resource_start(pcidev, 0);
4308 s->pBA1phys = pci_resource_start(pcidev, 1); 4308 s->pBA1phys = pci_resource_start(pcidev, 1);
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
index 58e25c82eaf2..53881bc91bba 100644
--- a/sound/oss/cs46xx.c
+++ b/sound/oss/cs46xx.c
@@ -90,6 +90,7 @@
90#include <linux/init.h> 90#include <linux/init.h>
91#include <linux/poll.h> 91#include <linux/poll.h>
92#include <linux/ac97_codec.h> 92#include <linux/ac97_codec.h>
93#include <linux/mutex.h>
93 94
94#include <asm/io.h> 95#include <asm/io.h>
95#include <asm/dma.h> 96#include <asm/dma.h>
@@ -238,7 +239,7 @@ struct cs_state {
238 struct cs_card *card; /* Card info */ 239 struct cs_card *card; /* Card info */
239 240
240 /* single open lock mechanism, only used for recording */ 241 /* single open lock mechanism, only used for recording */
241 struct semaphore open_sem; 242 struct mutex open_mutex;
242 wait_queue_head_t open_wait; 243 wait_queue_head_t open_wait;
243 244
244 /* file mode */ 245 /* file mode */
@@ -297,7 +298,7 @@ struct cs_state {
297 unsigned subdivision; 298 unsigned subdivision;
298 } dmabuf; 299 } dmabuf;
299 /* Guard against mmap/write/read races */ 300 /* Guard against mmap/write/read races */
300 struct semaphore sem; 301 struct mutex sem;
301}; 302};
302 303
303struct cs_card { 304struct cs_card {
@@ -375,7 +376,7 @@ struct cs_card {
375 unsigned char ibuf[CS_MIDIINBUF]; 376 unsigned char ibuf[CS_MIDIINBUF];
376 unsigned char obuf[CS_MIDIOUTBUF]; 377 unsigned char obuf[CS_MIDIOUTBUF];
377 mode_t open_mode; 378 mode_t open_mode;
378 struct semaphore open_sem; 379 struct mutex open_mutex;
379 } midi; 380 } midi;
380 struct cs46xx_pm pm; 381 struct cs46xx_pm pm;
381}; 382};
@@ -1428,9 +1429,9 @@ static int prog_dmabuf(struct cs_state *state)
1428{ 1429{
1429 int ret; 1430 int ret;
1430 1431
1431 down(&state->sem); 1432 mutex_lock(&state->sem);
1432 ret = __prog_dmabuf(state); 1433 ret = __prog_dmabuf(state);
1433 up(&state->sem); 1434 mutex_unlock(&state->sem);
1434 1435
1435 return ret; 1436 return ret;
1436} 1437}
@@ -1831,17 +1832,17 @@ static int cs_midi_open(struct inode *inode, struct file *file)
1831 1832
1832 file->private_data = card; 1833 file->private_data = card;
1833 /* wait for device to become free */ 1834 /* wait for device to become free */
1834 down(&card->midi.open_sem); 1835 mutex_lock(&card->midi.open_mutex);
1835 while (card->midi.open_mode & file->f_mode) { 1836 while (card->midi.open_mode & file->f_mode) {
1836 if (file->f_flags & O_NONBLOCK) { 1837 if (file->f_flags & O_NONBLOCK) {
1837 up(&card->midi.open_sem); 1838 mutex_unlock(&card->midi.open_mutex);
1838 return -EBUSY; 1839 return -EBUSY;
1839 } 1840 }
1840 up(&card->midi.open_sem); 1841 mutex_unlock(&card->midi.open_mutex);
1841 interruptible_sleep_on(&card->midi.open_wait); 1842 interruptible_sleep_on(&card->midi.open_wait);
1842 if (signal_pending(current)) 1843 if (signal_pending(current))
1843 return -ERESTARTSYS; 1844 return -ERESTARTSYS;
1844 down(&card->midi.open_sem); 1845 mutex_lock(&card->midi.open_mutex);
1845 } 1846 }
1846 spin_lock_irqsave(&card->midi.lock, flags); 1847 spin_lock_irqsave(&card->midi.lock, flags);
1847 if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) { 1848 if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) {
@@ -1859,7 +1860,7 @@ static int cs_midi_open(struct inode *inode, struct file *file)
1859 } 1860 }
1860 spin_unlock_irqrestore(&card->midi.lock, flags); 1861 spin_unlock_irqrestore(&card->midi.lock, flags);
1861 card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); 1862 card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
1862 up(&card->midi.open_sem); 1863 mutex_unlock(&card->midi.open_mutex);
1863 return 0; 1864 return 0;
1864} 1865}
1865 1866
@@ -1891,9 +1892,9 @@ static int cs_midi_release(struct inode *inode, struct file *file)
1891 remove_wait_queue(&card->midi.owait, &wait); 1892 remove_wait_queue(&card->midi.owait, &wait);
1892 current->state = TASK_RUNNING; 1893 current->state = TASK_RUNNING;
1893 } 1894 }
1894 down(&card->midi.open_sem); 1895 mutex_lock(&card->midi.open_mutex);
1895 card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE))); 1896 card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE)));
1896 up(&card->midi.open_sem); 1897 mutex_unlock(&card->midi.open_mutex);
1897 wake_up(&card->midi.open_wait); 1898 wake_up(&card->midi.open_wait);
1898 return 0; 1899 return 0;
1899} 1900}
@@ -2081,7 +2082,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
2081 if (!access_ok(VERIFY_WRITE, buffer, count)) 2082 if (!access_ok(VERIFY_WRITE, buffer, count))
2082 return -EFAULT; 2083 return -EFAULT;
2083 2084
2084 down(&state->sem); 2085 mutex_lock(&state->sem);
2085 if (!dmabuf->ready && (ret = __prog_dmabuf(state))) 2086 if (!dmabuf->ready && (ret = __prog_dmabuf(state)))
2086 goto out2; 2087 goto out2;
2087 2088
@@ -2114,13 +2115,13 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
2114 if (!ret) ret = -EAGAIN; 2115 if (!ret) ret = -EAGAIN;
2115 goto out; 2116 goto out;
2116 } 2117 }
2117 up(&state->sem); 2118 mutex_unlock(&state->sem);
2118 schedule(); 2119 schedule();
2119 if (signal_pending(current)) { 2120 if (signal_pending(current)) {
2120 if(!ret) ret = -ERESTARTSYS; 2121 if(!ret) ret = -ERESTARTSYS;
2121 goto out; 2122 goto out;
2122 } 2123 }
2123 down(&state->sem); 2124 mutex_lock(&state->sem);
2124 if (dmabuf->mapped) 2125 if (dmabuf->mapped)
2125 { 2126 {
2126 if(!ret) 2127 if(!ret)
@@ -2155,7 +2156,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
2155out: 2156out:
2156 remove_wait_queue(&state->dmabuf.wait, &wait); 2157 remove_wait_queue(&state->dmabuf.wait, &wait);
2157out2: 2158out2:
2158 up(&state->sem); 2159 mutex_unlock(&state->sem);
2159 set_current_state(TASK_RUNNING); 2160 set_current_state(TASK_RUNNING);
2160 CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4, 2161 CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4,
2161 printk("cs46xx: cs_read()- %zd\n",ret) ); 2162 printk("cs46xx: cs_read()- %zd\n",ret) );
@@ -2184,7 +2185,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
2184 return -EFAULT; 2185 return -EFAULT;
2185 dmabuf = &state->dmabuf; 2186 dmabuf = &state->dmabuf;
2186 2187
2187 down(&state->sem); 2188 mutex_lock(&state->sem);
2188 if (dmabuf->mapped) 2189 if (dmabuf->mapped)
2189 { 2190 {
2190 ret = -ENXIO; 2191 ret = -ENXIO;
@@ -2240,13 +2241,13 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
2240 if (!ret) ret = -EAGAIN; 2241 if (!ret) ret = -EAGAIN;
2241 goto out; 2242 goto out;
2242 } 2243 }
2243 up(&state->sem); 2244 mutex_unlock(&state->sem);
2244 schedule(); 2245 schedule();
2245 if (signal_pending(current)) { 2246 if (signal_pending(current)) {
2246 if(!ret) ret = -ERESTARTSYS; 2247 if(!ret) ret = -ERESTARTSYS;
2247 goto out; 2248 goto out;
2248 } 2249 }
2249 down(&state->sem); 2250 mutex_lock(&state->sem);
2250 if (dmabuf->mapped) 2251 if (dmabuf->mapped)
2251 { 2252 {
2252 if(!ret) 2253 if(!ret)
@@ -2278,7 +2279,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
2278 start_dac(state); 2279 start_dac(state);
2279 } 2280 }
2280out: 2281out:
2281 up(&state->sem); 2282 mutex_unlock(&state->sem);
2282 remove_wait_queue(&state->dmabuf.wait, &wait); 2283 remove_wait_queue(&state->dmabuf.wait, &wait);
2283 set_current_state(TASK_RUNNING); 2284 set_current_state(TASK_RUNNING);
2284 2285
@@ -2411,7 +2412,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma)
2411 goto out; 2412 goto out;
2412 } 2413 }
2413 2414
2414 down(&state->sem); 2415 mutex_lock(&state->sem);
2415 dmabuf = &state->dmabuf; 2416 dmabuf = &state->dmabuf;
2416 if (cs4x_pgoff(vma) != 0) 2417 if (cs4x_pgoff(vma) != 0)
2417 { 2418 {
@@ -2438,7 +2439,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma)
2438 2439
2439 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") ); 2440 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") );
2440out: 2441out:
2441 up(&state->sem); 2442 mutex_unlock(&state->sem);
2442 return ret; 2443 return ret;
2443} 2444}
2444 2445
@@ -3200,7 +3201,7 @@ static int cs_open(struct inode *inode, struct file *file)
3200 if (state == NULL) 3201 if (state == NULL)
3201 return -ENOMEM; 3202 return -ENOMEM;
3202 memset(state, 0, sizeof(struct cs_state)); 3203 memset(state, 0, sizeof(struct cs_state));
3203 init_MUTEX(&state->sem); 3204 mutex_init(&state->sem);
3204 dmabuf = &state->dmabuf; 3205 dmabuf = &state->dmabuf;
3205 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 3206 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
3206 if(dmabuf->pbuf==NULL) 3207 if(dmabuf->pbuf==NULL)
@@ -3241,10 +3242,10 @@ static int cs_open(struct inode *inode, struct file *file)
3241 state->virt = 0; 3242 state->virt = 0;
3242 state->magic = CS_STATE_MAGIC; 3243 state->magic = CS_STATE_MAGIC;
3243 init_waitqueue_head(&dmabuf->wait); 3244 init_waitqueue_head(&dmabuf->wait);
3244 init_MUTEX(&state->open_sem); 3245 mutex_init(&state->open_mutex);
3245 file->private_data = card; 3246 file->private_data = card;
3246 3247
3247 down(&state->open_sem); 3248 mutex_lock(&state->open_mutex);
3248 3249
3249 /* set default sample format. According to OSS Programmer's Guide /dev/dsp 3250 /* set default sample format. According to OSS Programmer's Guide /dev/dsp
3250 should be default to unsigned 8-bits, mono, with sample rate 8kHz and 3251 should be default to unsigned 8-bits, mono, with sample rate 8kHz and
@@ -3260,7 +3261,7 @@ static int cs_open(struct inode *inode, struct file *file)
3260 cs_set_divisor(dmabuf); 3261 cs_set_divisor(dmabuf);
3261 3262
3262 state->open_mode |= FMODE_READ; 3263 state->open_mode |= FMODE_READ;
3263 up(&state->open_sem); 3264 mutex_unlock(&state->open_mutex);
3264 } 3265 }
3265 if(file->f_mode & FMODE_WRITE) 3266 if(file->f_mode & FMODE_WRITE)
3266 { 3267 {
@@ -3271,7 +3272,7 @@ static int cs_open(struct inode *inode, struct file *file)
3271 if (state == NULL) 3272 if (state == NULL)
3272 return -ENOMEM; 3273 return -ENOMEM;
3273 memset(state, 0, sizeof(struct cs_state)); 3274 memset(state, 0, sizeof(struct cs_state));
3274 init_MUTEX(&state->sem); 3275 mutex_init(&state->sem);
3275 dmabuf = &state->dmabuf; 3276 dmabuf = &state->dmabuf;
3276 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 3277 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
3277 if(dmabuf->pbuf==NULL) 3278 if(dmabuf->pbuf==NULL)
@@ -3312,10 +3313,10 @@ static int cs_open(struct inode *inode, struct file *file)
3312 state->virt = 1; 3313 state->virt = 1;
3313 state->magic = CS_STATE_MAGIC; 3314 state->magic = CS_STATE_MAGIC;
3314 init_waitqueue_head(&dmabuf->wait); 3315 init_waitqueue_head(&dmabuf->wait);
3315 init_MUTEX(&state->open_sem); 3316 mutex_init(&state->open_mutex);
3316 file->private_data = card; 3317 file->private_data = card;
3317 3318
3318 down(&state->open_sem); 3319 mutex_lock(&state->open_mutex);
3319 3320
3320 /* set default sample format. According to OSS Programmer's Guide /dev/dsp 3321 /* set default sample format. According to OSS Programmer's Guide /dev/dsp
3321 should be default to unsigned 8-bits, mono, with sample rate 8kHz and 3322 should be default to unsigned 8-bits, mono, with sample rate 8kHz and
@@ -3331,7 +3332,7 @@ static int cs_open(struct inode *inode, struct file *file)
3331 cs_set_divisor(dmabuf); 3332 cs_set_divisor(dmabuf);
3332 3333
3333 state->open_mode |= FMODE_WRITE; 3334 state->open_mode |= FMODE_WRITE;
3334 up(&state->open_sem); 3335 mutex_unlock(&state->open_mutex);
3335 if((ret = prog_dmabuf(state))) 3336 if((ret = prog_dmabuf(state)))
3336 return ret; 3337 return ret;
3337 } 3338 }
@@ -3363,14 +3364,14 @@ static int cs_release(struct inode *inode, struct file *file)
3363 cs_clear_tail(state); 3364 cs_clear_tail(state);
3364 drain_dac(state, file->f_flags & O_NONBLOCK); 3365 drain_dac(state, file->f_flags & O_NONBLOCK);
3365 /* stop DMA state machine and free DMA buffers/channels */ 3366 /* stop DMA state machine and free DMA buffers/channels */
3366 down(&state->open_sem); 3367 mutex_lock(&state->open_mutex);
3367 stop_dac(state); 3368 stop_dac(state);
3368 dealloc_dmabuf(state); 3369 dealloc_dmabuf(state);
3369 state->card->free_pcm_channel(state->card, dmabuf->channel->num); 3370 state->card->free_pcm_channel(state->card, dmabuf->channel->num);
3370 free_page((unsigned long)state->dmabuf.pbuf); 3371 free_page((unsigned long)state->dmabuf.pbuf);
3371 3372
3372 /* we're covered by the open_sem */ 3373 /* we're covered by the open_mutex */
3373 up(&state->open_sem); 3374 mutex_unlock(&state->open_mutex);
3374 state->card->states[state->virt] = NULL; 3375 state->card->states[state->virt] = NULL;
3375 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 3376 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3376 3377
@@ -3395,14 +3396,14 @@ static int cs_release(struct inode *inode, struct file *file)
3395 { 3396 {
3396 CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n") ); 3397 CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n") );
3397 dmabuf = &state->dmabuf; 3398 dmabuf = &state->dmabuf;
3398 down(&state->open_sem); 3399 mutex_lock(&state->open_mutex);
3399 stop_adc(state); 3400 stop_adc(state);
3400 dealloc_dmabuf(state); 3401 dealloc_dmabuf(state);
3401 state->card->free_pcm_channel(state->card, dmabuf->channel->num); 3402 state->card->free_pcm_channel(state->card, dmabuf->channel->num);
3402 free_page((unsigned long)state->dmabuf.pbuf); 3403 free_page((unsigned long)state->dmabuf.pbuf);
3403 3404
3404 /* we're covered by the open_sem */ 3405 /* we're covered by the open_mutex */
3405 up(&state->open_sem); 3406 mutex_unlock(&state->open_mutex);
3406 state->card->states[state->virt] = NULL; 3407 state->card->states[state->virt] = NULL;
3407 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 3408 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3408 3409
@@ -5507,7 +5508,7 @@ static int __devinit cs46xx_probe(struct pci_dev *pci_dev,
5507 } 5508 }
5508 5509
5509 init_waitqueue_head(&card->midi.open_wait); 5510 init_waitqueue_head(&card->midi.open_wait);
5510 init_MUTEX(&card->midi.open_sem); 5511 mutex_init(&card->midi.open_mutex);
5511 init_waitqueue_head(&card->midi.iwait); 5512 init_waitqueue_head(&card->midi.iwait);
5512 init_waitqueue_head(&card->midi.owait); 5513 init_waitqueue_head(&card->midi.owait);
5513 cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST); 5514 cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST);
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 74f975676ccb..a17375141c3a 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -80,7 +80,7 @@
80#include <linux/kmod.h> 80#include <linux/kmod.h>
81#include <linux/interrupt.h> 81#include <linux/interrupt.h>
82#include <linux/input.h> 82#include <linux/input.h>
83#include <asm/semaphore.h> 83#include <linux/mutex.h>
84#ifdef CONFIG_ADB_CUDA 84#ifdef CONFIG_ADB_CUDA
85#include <linux/cuda.h> 85#include <linux/cuda.h>
86#endif 86#endif
@@ -130,7 +130,7 @@ static struct resource awacs_rsrc[3];
130static char awacs_name[64]; 130static char awacs_name[64];
131static int awacs_revision; 131static int awacs_revision;
132static int awacs_sleeping; 132static int awacs_sleeping;
133static DECLARE_MUTEX(dmasound_sem); 133static DEFINE_MUTEX(dmasound_mutex);
134 134
135static int sound_device_id; /* exists after iMac revA */ 135static int sound_device_id; /* exists after iMac revA */
136static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */ 136static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */
@@ -312,11 +312,11 @@ extern int daca_enter_sleep(void);
312extern int daca_leave_sleep(void); 312extern int daca_leave_sleep(void);
313 313
314#define TRY_LOCK() \ 314#define TRY_LOCK() \
315 if ((rc = down_interruptible(&dmasound_sem)) != 0) \ 315 if ((rc = mutex_lock_interruptible(&dmasound_mutex)) != 0) \
316 return rc; 316 return rc;
317#define LOCK() down(&dmasound_sem); 317#define LOCK() mutex_lock(&dmasound_mutex);
318 318
319#define UNLOCK() up(&dmasound_sem); 319#define UNLOCK() mutex_unlock(&dmasound_mutex);
320 320
321/* We use different versions that the ones provided in dmasound.h 321/* We use different versions that the ones provided in dmasound.h
322 * 322 *
diff --git a/sound/oss/emu10k1/hwaccess.h b/sound/oss/emu10k1/hwaccess.h
index 104223a192aa..85e27bda694b 100644
--- a/sound/oss/emu10k1/hwaccess.h
+++ b/sound/oss/emu10k1/hwaccess.h
@@ -181,7 +181,7 @@ struct emu10k1_card
181 struct emu10k1_mpuout *mpuout; 181 struct emu10k1_mpuout *mpuout;
182 struct emu10k1_mpuin *mpuin; 182 struct emu10k1_mpuin *mpuin;
183 183
184 struct semaphore open_sem; 184 struct mutex open_sem;
185 mode_t open_mode; 185 mode_t open_mode;
186 wait_queue_head_t open_wait; 186 wait_queue_head_t open_wait;
187 187
diff --git a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
index 23241cbdd90f..0cd44a6f7ac0 100644
--- a/sound/oss/emu10k1/main.c
+++ b/sound/oss/emu10k1/main.c
@@ -1320,7 +1320,7 @@ static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_dev
1320 card->is_aps = (subsysvid == EMU_APS_SUBID); 1320 card->is_aps = (subsysvid == EMU_APS_SUBID);
1321 1321
1322 spin_lock_init(&card->lock); 1322 spin_lock_init(&card->lock);
1323 init_MUTEX(&card->open_sem); 1323 mutex_init(&card->open_sem);
1324 card->open_mode = 0; 1324 card->open_mode = 0;
1325 init_waitqueue_head(&card->open_wait); 1325 init_waitqueue_head(&card->open_wait);
1326 1326
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
index b40b5f97aace..959a96794dba 100644
--- a/sound/oss/emu10k1/midi.c
+++ b/sound/oss/emu10k1/midi.c
@@ -110,21 +110,21 @@ match:
110#endif 110#endif
111 111
112 /* Wait for device to become free */ 112 /* Wait for device to become free */
113 down(&card->open_sem); 113 mutex_lock(&card->open_sem);
114 while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 114 while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
115 if (file->f_flags & O_NONBLOCK) { 115 if (file->f_flags & O_NONBLOCK) {
116 up(&card->open_sem); 116 mutex_unlock(&card->open_sem);
117 return -EBUSY; 117 return -EBUSY;
118 } 118 }
119 119
120 up(&card->open_sem); 120 mutex_unlock(&card->open_sem);
121 interruptible_sleep_on(&card->open_wait); 121 interruptible_sleep_on(&card->open_wait);
122 122
123 if (signal_pending(current)) { 123 if (signal_pending(current)) {
124 return -ERESTARTSYS; 124 return -ERESTARTSYS;
125 } 125 }
126 126
127 down(&card->open_sem); 127 mutex_lock(&card->open_sem);
128 } 128 }
129 129
130 if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL) 130 if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
@@ -183,7 +183,7 @@ match:
183 183
184 card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 184 card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
185 185
186 up(&card->open_sem); 186 mutex_unlock(&card->open_sem);
187 187
188 return nonseekable_open(inode, file); 188 return nonseekable_open(inode, file);
189} 189}
@@ -234,9 +234,9 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file)
234 234
235 kfree(midi_dev); 235 kfree(midi_dev);
236 236
237 down(&card->open_sem); 237 mutex_lock(&card->open_sem);
238 card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE)); 238 card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE));
239 up(&card->open_sem); 239 mutex_unlock(&card->open_sem);
240 wake_up_interruptible(&card->open_wait); 240 wake_up_interruptible(&card->open_wait);
241 241
242 unlock_kernel(); 242 unlock_kernel();
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c
index ae55c536613a..094f569cc6e0 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -157,6 +157,7 @@
157#include <linux/gameport.h> 157#include <linux/gameport.h>
158#include <linux/wait.h> 158#include <linux/wait.h>
159#include <linux/dma-mapping.h> 159#include <linux/dma-mapping.h>
160#include <linux/mutex.h>
160 161
161#include <asm/io.h> 162#include <asm/io.h>
162#include <asm/page.h> 163#include <asm/page.h>
@@ -346,7 +347,7 @@ struct es1370_state {
346 unsigned sctrl; 347 unsigned sctrl;
347 348
348 spinlock_t lock; 349 spinlock_t lock;
349 struct semaphore open_sem; 350 struct mutex open_mutex;
350 mode_t open_mode; 351 mode_t open_mode;
351 wait_queue_head_t open_wait; 352 wait_queue_head_t open_wait;
352 353
@@ -393,7 +394,7 @@ struct es1370_state {
393 struct gameport *gameport; 394 struct gameport *gameport;
394#endif 395#endif
395 396
396 struct semaphore sem; 397 struct mutex mutex;
397}; 398};
398 399
399/* --------------------------------------------------------------------- */ 400/* --------------------------------------------------------------------- */
@@ -1159,7 +1160,7 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
1159 return -ENXIO; 1160 return -ENXIO;
1160 if (!access_ok(VERIFY_WRITE, buffer, count)) 1161 if (!access_ok(VERIFY_WRITE, buffer, count))
1161 return -EFAULT; 1162 return -EFAULT;
1162 down(&s->sem); 1163 mutex_lock(&s->mutex);
1163 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) 1164 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
1164 goto out; 1165 goto out;
1165 1166
@@ -1183,14 +1184,14 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
1183 ret = -EAGAIN; 1184 ret = -EAGAIN;
1184 goto out; 1185 goto out;
1185 } 1186 }
1186 up(&s->sem); 1187 mutex_unlock(&s->mutex);
1187 schedule(); 1188 schedule();
1188 if (signal_pending(current)) { 1189 if (signal_pending(current)) {
1189 if (!ret) 1190 if (!ret)
1190 ret = -ERESTARTSYS; 1191 ret = -ERESTARTSYS;
1191 goto out; 1192 goto out;
1192 } 1193 }
1193 down(&s->sem); 1194 mutex_lock(&s->mutex);
1194 if (s->dma_adc.mapped) 1195 if (s->dma_adc.mapped)
1195 { 1196 {
1196 ret = -ENXIO; 1197 ret = -ENXIO;
@@ -1215,7 +1216,7 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
1215 start_adc(s); 1216 start_adc(s);
1216 } 1217 }
1217out: 1218out:
1218 up(&s->sem); 1219 mutex_unlock(&s->mutex);
1219 remove_wait_queue(&s->dma_adc.wait, &wait); 1220 remove_wait_queue(&s->dma_adc.wait, &wait);
1220 set_current_state(TASK_RUNNING); 1221 set_current_state(TASK_RUNNING);
1221 return ret; 1222 return ret;
@@ -1235,7 +1236,7 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
1235 return -ENXIO; 1236 return -ENXIO;
1236 if (!access_ok(VERIFY_READ, buffer, count)) 1237 if (!access_ok(VERIFY_READ, buffer, count))
1237 return -EFAULT; 1238 return -EFAULT;
1238 down(&s->sem); 1239 mutex_lock(&s->mutex);
1239 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) 1240 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s)))
1240 goto out; 1241 goto out;
1241 ret = 0; 1242 ret = 0;
@@ -1263,14 +1264,14 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
1263 ret = -EAGAIN; 1264 ret = -EAGAIN;
1264 goto out; 1265 goto out;
1265 } 1266 }
1266 up(&s->sem); 1267 mutex_unlock(&s->mutex);
1267 schedule(); 1268 schedule();
1268 if (signal_pending(current)) { 1269 if (signal_pending(current)) {
1269 if (!ret) 1270 if (!ret)
1270 ret = -ERESTARTSYS; 1271 ret = -ERESTARTSYS;
1271 goto out; 1272 goto out;
1272 } 1273 }
1273 down(&s->sem); 1274 mutex_lock(&s->mutex);
1274 if (s->dma_dac2.mapped) 1275 if (s->dma_dac2.mapped)
1275 { 1276 {
1276 ret = -ENXIO; 1277 ret = -ENXIO;
@@ -1296,7 +1297,7 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
1296 start_dac2(s); 1297 start_dac2(s);
1297 } 1298 }
1298out: 1299out:
1299 up(&s->sem); 1300 mutex_unlock(&s->mutex);
1300 remove_wait_queue(&s->dma_dac2.wait, &wait); 1301 remove_wait_queue(&s->dma_dac2.wait, &wait);
1301 set_current_state(TASK_RUNNING); 1302 set_current_state(TASK_RUNNING);
1302 return ret; 1303 return ret;
@@ -1348,7 +1349,7 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
1348 1349
1349 VALIDATE_STATE(s); 1350 VALIDATE_STATE(s);
1350 lock_kernel(); 1351 lock_kernel();
1351 down(&s->sem); 1352 mutex_lock(&s->mutex);
1352 if (vma->vm_flags & VM_WRITE) { 1353 if (vma->vm_flags & VM_WRITE) {
1353 if ((ret = prog_dmabuf_dac2(s)) != 0) { 1354 if ((ret = prog_dmabuf_dac2(s)) != 0) {
1354 goto out; 1355 goto out;
@@ -1380,7 +1381,7 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
1380 } 1381 }
1381 db->mapped = 1; 1382 db->mapped = 1;
1382out: 1383out:
1383 up(&s->sem); 1384 mutex_unlock(&s->mutex);
1384 unlock_kernel(); 1385 unlock_kernel();
1385 return ret; 1386 return ret;
1386} 1387}
@@ -1752,21 +1753,21 @@ static int es1370_open(struct inode *inode, struct file *file)
1752 VALIDATE_STATE(s); 1753 VALIDATE_STATE(s);
1753 file->private_data = s; 1754 file->private_data = s;
1754 /* wait for device to become free */ 1755 /* wait for device to become free */
1755 down(&s->open_sem); 1756 mutex_lock(&s->open_mutex);
1756 while (s->open_mode & file->f_mode) { 1757 while (s->open_mode & file->f_mode) {
1757 if (file->f_flags & O_NONBLOCK) { 1758 if (file->f_flags & O_NONBLOCK) {
1758 up(&s->open_sem); 1759 mutex_unlock(&s->open_mutex);
1759 return -EBUSY; 1760 return -EBUSY;
1760 } 1761 }
1761 add_wait_queue(&s->open_wait, &wait); 1762 add_wait_queue(&s->open_wait, &wait);
1762 __set_current_state(TASK_INTERRUPTIBLE); 1763 __set_current_state(TASK_INTERRUPTIBLE);
1763 up(&s->open_sem); 1764 mutex_unlock(&s->open_mutex);
1764 schedule(); 1765 schedule();
1765 remove_wait_queue(&s->open_wait, &wait); 1766 remove_wait_queue(&s->open_wait, &wait);
1766 set_current_state(TASK_RUNNING); 1767 set_current_state(TASK_RUNNING);
1767 if (signal_pending(current)) 1768 if (signal_pending(current))
1768 return -ERESTARTSYS; 1769 return -ERESTARTSYS;
1769 down(&s->open_sem); 1770 mutex_lock(&s->open_mutex);
1770 } 1771 }
1771 spin_lock_irqsave(&s->lock, flags); 1772 spin_lock_irqsave(&s->lock, flags);
1772 if (!(s->open_mode & (FMODE_READ|FMODE_WRITE))) 1773 if (!(s->open_mode & (FMODE_READ|FMODE_WRITE)))
@@ -1793,8 +1794,8 @@ static int es1370_open(struct inode *inode, struct file *file)
1793 outl(s->ctrl, s->io+ES1370_REG_CONTROL); 1794 outl(s->ctrl, s->io+ES1370_REG_CONTROL);
1794 spin_unlock_irqrestore(&s->lock, flags); 1795 spin_unlock_irqrestore(&s->lock, flags);
1795 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1796 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1796 up(&s->open_sem); 1797 mutex_unlock(&s->open_mutex);
1797 init_MUTEX(&s->sem); 1798 mutex_init(&s->mutex);
1798 return nonseekable_open(inode, file); 1799 return nonseekable_open(inode, file);
1799} 1800}
1800 1801
@@ -1806,7 +1807,7 @@ static int es1370_release(struct inode *inode, struct file *file)
1806 lock_kernel(); 1807 lock_kernel();
1807 if (file->f_mode & FMODE_WRITE) 1808 if (file->f_mode & FMODE_WRITE)
1808 drain_dac2(s, file->f_flags & O_NONBLOCK); 1809 drain_dac2(s, file->f_flags & O_NONBLOCK);
1809 down(&s->open_sem); 1810 mutex_lock(&s->open_mutex);
1810 if (file->f_mode & FMODE_WRITE) { 1811 if (file->f_mode & FMODE_WRITE) {
1811 stop_dac2(s); 1812 stop_dac2(s);
1812 synchronize_irq(s->irq); 1813 synchronize_irq(s->irq);
@@ -1818,7 +1819,7 @@ static int es1370_release(struct inode *inode, struct file *file)
1818 } 1819 }
1819 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 1820 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
1820 wake_up(&s->open_wait); 1821 wake_up(&s->open_wait);
1821 up(&s->open_sem); 1822 mutex_unlock(&s->open_mutex);
1822 unlock_kernel(); 1823 unlock_kernel();
1823 return 0; 1824 return 0;
1824} 1825}
@@ -2198,21 +2199,21 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
2198 return -EINVAL; 2199 return -EINVAL;
2199 file->private_data = s; 2200 file->private_data = s;
2200 /* wait for device to become free */ 2201 /* wait for device to become free */
2201 down(&s->open_sem); 2202 mutex_lock(&s->open_mutex);
2202 while (s->open_mode & FMODE_DAC) { 2203 while (s->open_mode & FMODE_DAC) {
2203 if (file->f_flags & O_NONBLOCK) { 2204 if (file->f_flags & O_NONBLOCK) {
2204 up(&s->open_sem); 2205 mutex_unlock(&s->open_mutex);
2205 return -EBUSY; 2206 return -EBUSY;
2206 } 2207 }
2207 add_wait_queue(&s->open_wait, &wait); 2208 add_wait_queue(&s->open_wait, &wait);
2208 __set_current_state(TASK_INTERRUPTIBLE); 2209 __set_current_state(TASK_INTERRUPTIBLE);
2209 up(&s->open_sem); 2210 mutex_unlock(&s->open_mutex);
2210 schedule(); 2211 schedule();
2211 remove_wait_queue(&s->open_wait, &wait); 2212 remove_wait_queue(&s->open_wait, &wait);
2212 set_current_state(TASK_RUNNING); 2213 set_current_state(TASK_RUNNING);
2213 if (signal_pending(current)) 2214 if (signal_pending(current))
2214 return -ERESTARTSYS; 2215 return -ERESTARTSYS;
2215 down(&s->open_sem); 2216 mutex_lock(&s->open_mutex);
2216 } 2217 }
2217 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0; 2218 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0;
2218 s->dma_dac1.enabled = 1; 2219 s->dma_dac1.enabled = 1;
@@ -2227,7 +2228,7 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
2227 outl(s->ctrl, s->io+ES1370_REG_CONTROL); 2228 outl(s->ctrl, s->io+ES1370_REG_CONTROL);
2228 spin_unlock_irqrestore(&s->lock, flags); 2229 spin_unlock_irqrestore(&s->lock, flags);
2229 s->open_mode |= FMODE_DAC; 2230 s->open_mode |= FMODE_DAC;
2230 up(&s->open_sem); 2231 mutex_unlock(&s->open_mutex);
2231 return nonseekable_open(inode, file); 2232 return nonseekable_open(inode, file);
2232} 2233}
2233 2234
@@ -2238,12 +2239,12 @@ static int es1370_release_dac(struct inode *inode, struct file *file)
2238 VALIDATE_STATE(s); 2239 VALIDATE_STATE(s);
2239 lock_kernel(); 2240 lock_kernel();
2240 drain_dac1(s, file->f_flags & O_NONBLOCK); 2241 drain_dac1(s, file->f_flags & O_NONBLOCK);
2241 down(&s->open_sem); 2242 mutex_lock(&s->open_mutex);
2242 stop_dac1(s); 2243 stop_dac1(s);
2243 dealloc_dmabuf(s, &s->dma_dac1); 2244 dealloc_dmabuf(s, &s->dma_dac1);
2244 s->open_mode &= ~FMODE_DAC; 2245 s->open_mode &= ~FMODE_DAC;
2245 wake_up(&s->open_wait); 2246 wake_up(&s->open_wait);
2246 up(&s->open_sem); 2247 mutex_unlock(&s->open_mutex);
2247 unlock_kernel(); 2248 unlock_kernel();
2248 return 0; 2249 return 0;
2249} 2250}
@@ -2430,21 +2431,21 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
2430 VALIDATE_STATE(s); 2431 VALIDATE_STATE(s);
2431 file->private_data = s; 2432 file->private_data = s;
2432 /* wait for device to become free */ 2433 /* wait for device to become free */
2433 down(&s->open_sem); 2434 mutex_lock(&s->open_mutex);
2434 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 2435 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
2435 if (file->f_flags & O_NONBLOCK) { 2436 if (file->f_flags & O_NONBLOCK) {
2436 up(&s->open_sem); 2437 mutex_unlock(&s->open_mutex);
2437 return -EBUSY; 2438 return -EBUSY;
2438 } 2439 }
2439 add_wait_queue(&s->open_wait, &wait); 2440 add_wait_queue(&s->open_wait, &wait);
2440 __set_current_state(TASK_INTERRUPTIBLE); 2441 __set_current_state(TASK_INTERRUPTIBLE);
2441 up(&s->open_sem); 2442 mutex_unlock(&s->open_mutex);
2442 schedule(); 2443 schedule();
2443 remove_wait_queue(&s->open_wait, &wait); 2444 remove_wait_queue(&s->open_wait, &wait);
2444 set_current_state(TASK_RUNNING); 2445 set_current_state(TASK_RUNNING);
2445 if (signal_pending(current)) 2446 if (signal_pending(current))
2446 return -ERESTARTSYS; 2447 return -ERESTARTSYS;
2447 down(&s->open_sem); 2448 mutex_lock(&s->open_mutex);
2448 } 2449 }
2449 spin_lock_irqsave(&s->lock, flags); 2450 spin_lock_irqsave(&s->lock, flags);
2450 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2451 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2465,7 +2466,7 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
2465 es1370_handle_midi(s); 2466 es1370_handle_midi(s);
2466 spin_unlock_irqrestore(&s->lock, flags); 2467 spin_unlock_irqrestore(&s->lock, flags);
2467 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 2468 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
2468 up(&s->open_sem); 2469 mutex_unlock(&s->open_mutex);
2469 return nonseekable_open(inode, file); 2470 return nonseekable_open(inode, file);
2470} 2471}
2471 2472
@@ -2499,7 +2500,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file)
2499 remove_wait_queue(&s->midi.owait, &wait); 2500 remove_wait_queue(&s->midi.owait, &wait);
2500 set_current_state(TASK_RUNNING); 2501 set_current_state(TASK_RUNNING);
2501 } 2502 }
2502 down(&s->open_sem); 2503 mutex_lock(&s->open_mutex);
2503 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 2504 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
2504 spin_lock_irqsave(&s->lock, flags); 2505 spin_lock_irqsave(&s->lock, flags);
2505 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2506 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2508,7 +2509,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file)
2508 } 2509 }
2509 spin_unlock_irqrestore(&s->lock, flags); 2510 spin_unlock_irqrestore(&s->lock, flags);
2510 wake_up(&s->open_wait); 2511 wake_up(&s->open_wait);
2511 up(&s->open_sem); 2512 mutex_unlock(&s->open_mutex);
2512 unlock_kernel(); 2513 unlock_kernel();
2513 return 0; 2514 return 0;
2514} 2515}
@@ -2638,7 +2639,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2638 init_waitqueue_head(&s->open_wait); 2639 init_waitqueue_head(&s->open_wait);
2639 init_waitqueue_head(&s->midi.iwait); 2640 init_waitqueue_head(&s->midi.iwait);
2640 init_waitqueue_head(&s->midi.owait); 2641 init_waitqueue_head(&s->midi.owait);
2641 init_MUTEX(&s->open_sem); 2642 mutex_init(&s->open_mutex);
2642 spin_lock_init(&s->lock); 2643 spin_lock_init(&s->lock);
2643 s->magic = ES1370_MAGIC; 2644 s->magic = ES1370_MAGIC;
2644 s->dev = pcidev; 2645 s->dev = pcidev;
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index 5c697f162579..4400c8538686 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -129,6 +129,7 @@
129#include <linux/gameport.h> 129#include <linux/gameport.h>
130#include <linux/wait.h> 130#include <linux/wait.h>
131#include <linux/dma-mapping.h> 131#include <linux/dma-mapping.h>
132#include <linux/mutex.h>
132 133
133#include <asm/io.h> 134#include <asm/io.h>
134#include <asm/page.h> 135#include <asm/page.h>
@@ -419,7 +420,7 @@ struct es1371_state {
419 unsigned dac1rate, dac2rate, adcrate; 420 unsigned dac1rate, dac2rate, adcrate;
420 421
421 spinlock_t lock; 422 spinlock_t lock;
422 struct semaphore open_sem; 423 struct mutex open_mutex;
423 mode_t open_mode; 424 mode_t open_mode;
424 wait_queue_head_t open_wait; 425 wait_queue_head_t open_wait;
425 426
@@ -462,7 +463,7 @@ struct es1371_state {
462 struct gameport *gameport; 463 struct gameport *gameport;
463#endif 464#endif
464 465
465 struct semaphore sem; 466 struct mutex sem;
466}; 467};
467 468
468/* --------------------------------------------------------------------- */ 469/* --------------------------------------------------------------------- */
@@ -1346,7 +1347,7 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
1346 return -ENXIO; 1347 return -ENXIO;
1347 if (!access_ok(VERIFY_WRITE, buffer, count)) 1348 if (!access_ok(VERIFY_WRITE, buffer, count))
1348 return -EFAULT; 1349 return -EFAULT;
1349 down(&s->sem); 1350 mutex_lock(&s->sem);
1350 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) 1351 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
1351 goto out2; 1352 goto out2;
1352 1353
@@ -1370,14 +1371,14 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
1370 ret = -EAGAIN; 1371 ret = -EAGAIN;
1371 goto out; 1372 goto out;
1372 } 1373 }
1373 up(&s->sem); 1374 mutex_unlock(&s->sem);
1374 schedule(); 1375 schedule();
1375 if (signal_pending(current)) { 1376 if (signal_pending(current)) {
1376 if (!ret) 1377 if (!ret)
1377 ret = -ERESTARTSYS; 1378 ret = -ERESTARTSYS;
1378 goto out2; 1379 goto out2;
1379 } 1380 }
1380 down(&s->sem); 1381 mutex_lock(&s->sem);
1381 if (s->dma_adc.mapped) 1382 if (s->dma_adc.mapped)
1382 { 1383 {
1383 ret = -ENXIO; 1384 ret = -ENXIO;
@@ -1402,7 +1403,7 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
1402 start_adc(s); 1403 start_adc(s);
1403 } 1404 }
1404out: 1405out:
1405 up(&s->sem); 1406 mutex_unlock(&s->sem);
1406out2: 1407out2:
1407 remove_wait_queue(&s->dma_adc.wait, &wait); 1408 remove_wait_queue(&s->dma_adc.wait, &wait);
1408 set_current_state(TASK_RUNNING); 1409 set_current_state(TASK_RUNNING);
@@ -1423,7 +1424,7 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
1423 return -ENXIO; 1424 return -ENXIO;
1424 if (!access_ok(VERIFY_READ, buffer, count)) 1425 if (!access_ok(VERIFY_READ, buffer, count))
1425 return -EFAULT; 1426 return -EFAULT;
1426 down(&s->sem); 1427 mutex_lock(&s->sem);
1427 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) 1428 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s)))
1428 goto out3; 1429 goto out3;
1429 ret = 0; 1430 ret = 0;
@@ -1451,14 +1452,14 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
1451 ret = -EAGAIN; 1452 ret = -EAGAIN;
1452 goto out; 1453 goto out;
1453 } 1454 }
1454 up(&s->sem); 1455 mutex_unlock(&s->sem);
1455 schedule(); 1456 schedule();
1456 if (signal_pending(current)) { 1457 if (signal_pending(current)) {
1457 if (!ret) 1458 if (!ret)
1458 ret = -ERESTARTSYS; 1459 ret = -ERESTARTSYS;
1459 goto out2; 1460 goto out2;
1460 } 1461 }
1461 down(&s->sem); 1462 mutex_lock(&s->sem);
1462 if (s->dma_dac2.mapped) 1463 if (s->dma_dac2.mapped)
1463 { 1464 {
1464 ret = -ENXIO; 1465 ret = -ENXIO;
@@ -1484,7 +1485,7 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
1484 start_dac2(s); 1485 start_dac2(s);
1485 } 1486 }
1486out: 1487out:
1487 up(&s->sem); 1488 mutex_unlock(&s->sem);
1488out2: 1489out2:
1489 remove_wait_queue(&s->dma_dac2.wait, &wait); 1490 remove_wait_queue(&s->dma_dac2.wait, &wait);
1490out3: 1491out3:
@@ -1538,7 +1539,7 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma)
1538 1539
1539 VALIDATE_STATE(s); 1540 VALIDATE_STATE(s);
1540 lock_kernel(); 1541 lock_kernel();
1541 down(&s->sem); 1542 mutex_lock(&s->sem);
1542 1543
1543 if (vma->vm_flags & VM_WRITE) { 1544 if (vma->vm_flags & VM_WRITE) {
1544 if ((ret = prog_dmabuf_dac2(s)) != 0) { 1545 if ((ret = prog_dmabuf_dac2(s)) != 0) {
@@ -1571,7 +1572,7 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma)
1571 } 1572 }
1572 db->mapped = 1; 1573 db->mapped = 1;
1573out: 1574out:
1574 up(&s->sem); 1575 mutex_unlock(&s->sem);
1575 unlock_kernel(); 1576 unlock_kernel();
1576 return ret; 1577 return ret;
1577} 1578}
@@ -1938,21 +1939,21 @@ static int es1371_open(struct inode *inode, struct file *file)
1938 VALIDATE_STATE(s); 1939 VALIDATE_STATE(s);
1939 file->private_data = s; 1940 file->private_data = s;
1940 /* wait for device to become free */ 1941 /* wait for device to become free */
1941 down(&s->open_sem); 1942 mutex_lock(&s->open_mutex);
1942 while (s->open_mode & file->f_mode) { 1943 while (s->open_mode & file->f_mode) {
1943 if (file->f_flags & O_NONBLOCK) { 1944 if (file->f_flags & O_NONBLOCK) {
1944 up(&s->open_sem); 1945 mutex_unlock(&s->open_mutex);
1945 return -EBUSY; 1946 return -EBUSY;
1946 } 1947 }
1947 add_wait_queue(&s->open_wait, &wait); 1948 add_wait_queue(&s->open_wait, &wait);
1948 __set_current_state(TASK_INTERRUPTIBLE); 1949 __set_current_state(TASK_INTERRUPTIBLE);
1949 up(&s->open_sem); 1950 mutex_unlock(&s->open_mutex);
1950 schedule(); 1951 schedule();
1951 remove_wait_queue(&s->open_wait, &wait); 1952 remove_wait_queue(&s->open_wait, &wait);
1952 set_current_state(TASK_RUNNING); 1953 set_current_state(TASK_RUNNING);
1953 if (signal_pending(current)) 1954 if (signal_pending(current))
1954 return -ERESTARTSYS; 1955 return -ERESTARTSYS;
1955 down(&s->open_sem); 1956 mutex_lock(&s->open_mutex);
1956 } 1957 }
1957 if (file->f_mode & FMODE_READ) { 1958 if (file->f_mode & FMODE_READ) {
1958 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.subdivision = 0; 1959 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.subdivision = 0;
@@ -1982,8 +1983,8 @@ static int es1371_open(struct inode *inode, struct file *file)
1982 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); 1983 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
1983 spin_unlock_irqrestore(&s->lock, flags); 1984 spin_unlock_irqrestore(&s->lock, flags);
1984 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1985 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1985 up(&s->open_sem); 1986 mutex_unlock(&s->open_mutex);
1986 init_MUTEX(&s->sem); 1987 mutex_init(&s->sem);
1987 return nonseekable_open(inode, file); 1988 return nonseekable_open(inode, file);
1988} 1989}
1989 1990
@@ -1995,7 +1996,7 @@ static int es1371_release(struct inode *inode, struct file *file)
1995 lock_kernel(); 1996 lock_kernel();
1996 if (file->f_mode & FMODE_WRITE) 1997 if (file->f_mode & FMODE_WRITE)
1997 drain_dac2(s, file->f_flags & O_NONBLOCK); 1998 drain_dac2(s, file->f_flags & O_NONBLOCK);
1998 down(&s->open_sem); 1999 mutex_lock(&s->open_mutex);
1999 if (file->f_mode & FMODE_WRITE) { 2000 if (file->f_mode & FMODE_WRITE) {
2000 stop_dac2(s); 2001 stop_dac2(s);
2001 dealloc_dmabuf(s, &s->dma_dac2); 2002 dealloc_dmabuf(s, &s->dma_dac2);
@@ -2005,7 +2006,7 @@ static int es1371_release(struct inode *inode, struct file *file)
2005 dealloc_dmabuf(s, &s->dma_adc); 2006 dealloc_dmabuf(s, &s->dma_adc);
2006 } 2007 }
2007 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 2008 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
2008 up(&s->open_sem); 2009 mutex_unlock(&s->open_mutex);
2009 wake_up(&s->open_wait); 2010 wake_up(&s->open_wait);
2010 unlock_kernel(); 2011 unlock_kernel();
2011 return 0; 2012 return 0;
@@ -2377,21 +2378,21 @@ static int es1371_open_dac(struct inode *inode, struct file *file)
2377 return -EINVAL; 2378 return -EINVAL;
2378 file->private_data = s; 2379 file->private_data = s;
2379 /* wait for device to become free */ 2380 /* wait for device to become free */
2380 down(&s->open_sem); 2381 mutex_lock(&s->open_mutex);
2381 while (s->open_mode & FMODE_DAC) { 2382 while (s->open_mode & FMODE_DAC) {
2382 if (file->f_flags & O_NONBLOCK) { 2383 if (file->f_flags & O_NONBLOCK) {
2383 up(&s->open_sem); 2384 mutex_unlock(&s->open_mutex);
2384 return -EBUSY; 2385 return -EBUSY;
2385 } 2386 }
2386 add_wait_queue(&s->open_wait, &wait); 2387 add_wait_queue(&s->open_wait, &wait);
2387 __set_current_state(TASK_INTERRUPTIBLE); 2388 __set_current_state(TASK_INTERRUPTIBLE);
2388 up(&s->open_sem); 2389 mutex_unlock(&s->open_mutex);
2389 schedule(); 2390 schedule();
2390 remove_wait_queue(&s->open_wait, &wait); 2391 remove_wait_queue(&s->open_wait, &wait);
2391 set_current_state(TASK_RUNNING); 2392 set_current_state(TASK_RUNNING);
2392 if (signal_pending(current)) 2393 if (signal_pending(current))
2393 return -ERESTARTSYS; 2394 return -ERESTARTSYS;
2394 down(&s->open_sem); 2395 mutex_lock(&s->open_mutex);
2395 } 2396 }
2396 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0; 2397 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0;
2397 s->dma_dac1.enabled = 1; 2398 s->dma_dac1.enabled = 1;
@@ -2405,7 +2406,7 @@ static int es1371_open_dac(struct inode *inode, struct file *file)
2405 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); 2406 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
2406 spin_unlock_irqrestore(&s->lock, flags); 2407 spin_unlock_irqrestore(&s->lock, flags);
2407 s->open_mode |= FMODE_DAC; 2408 s->open_mode |= FMODE_DAC;
2408 up(&s->open_sem); 2409 mutex_unlock(&s->open_mutex);
2409 return nonseekable_open(inode, file); 2410 return nonseekable_open(inode, file);
2410} 2411}
2411 2412
@@ -2416,11 +2417,11 @@ static int es1371_release_dac(struct inode *inode, struct file *file)
2416 VALIDATE_STATE(s); 2417 VALIDATE_STATE(s);
2417 lock_kernel(); 2418 lock_kernel();
2418 drain_dac1(s, file->f_flags & O_NONBLOCK); 2419 drain_dac1(s, file->f_flags & O_NONBLOCK);
2419 down(&s->open_sem); 2420 mutex_lock(&s->open_mutex);
2420 stop_dac1(s); 2421 stop_dac1(s);
2421 dealloc_dmabuf(s, &s->dma_dac1); 2422 dealloc_dmabuf(s, &s->dma_dac1);
2422 s->open_mode &= ~FMODE_DAC; 2423 s->open_mode &= ~FMODE_DAC;
2423 up(&s->open_sem); 2424 mutex_unlock(&s->open_mutex);
2424 wake_up(&s->open_wait); 2425 wake_up(&s->open_wait);
2425 unlock_kernel(); 2426 unlock_kernel();
2426 return 0; 2427 return 0;
@@ -2608,21 +2609,21 @@ static int es1371_midi_open(struct inode *inode, struct file *file)
2608 VALIDATE_STATE(s); 2609 VALIDATE_STATE(s);
2609 file->private_data = s; 2610 file->private_data = s;
2610 /* wait for device to become free */ 2611 /* wait for device to become free */
2611 down(&s->open_sem); 2612 mutex_lock(&s->open_mutex);
2612 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 2613 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
2613 if (file->f_flags & O_NONBLOCK) { 2614 if (file->f_flags & O_NONBLOCK) {
2614 up(&s->open_sem); 2615 mutex_unlock(&s->open_mutex);
2615 return -EBUSY; 2616 return -EBUSY;
2616 } 2617 }
2617 add_wait_queue(&s->open_wait, &wait); 2618 add_wait_queue(&s->open_wait, &wait);
2618 __set_current_state(TASK_INTERRUPTIBLE); 2619 __set_current_state(TASK_INTERRUPTIBLE);
2619 up(&s->open_sem); 2620 mutex_unlock(&s->open_mutex);
2620 schedule(); 2621 schedule();
2621 remove_wait_queue(&s->open_wait, &wait); 2622 remove_wait_queue(&s->open_wait, &wait);
2622 set_current_state(TASK_RUNNING); 2623 set_current_state(TASK_RUNNING);
2623 if (signal_pending(current)) 2624 if (signal_pending(current))
2624 return -ERESTARTSYS; 2625 return -ERESTARTSYS;
2625 down(&s->open_sem); 2626 mutex_lock(&s->open_mutex);
2626 } 2627 }
2627 spin_lock_irqsave(&s->lock, flags); 2628 spin_lock_irqsave(&s->lock, flags);
2628 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2629 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2643,7 +2644,7 @@ static int es1371_midi_open(struct inode *inode, struct file *file)
2643 es1371_handle_midi(s); 2644 es1371_handle_midi(s);
2644 spin_unlock_irqrestore(&s->lock, flags); 2645 spin_unlock_irqrestore(&s->lock, flags);
2645 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 2646 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
2646 up(&s->open_sem); 2647 mutex_unlock(&s->open_mutex);
2647 return nonseekable_open(inode, file); 2648 return nonseekable_open(inode, file);
2648} 2649}
2649 2650
@@ -2676,7 +2677,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file)
2676 remove_wait_queue(&s->midi.owait, &wait); 2677 remove_wait_queue(&s->midi.owait, &wait);
2677 set_current_state(TASK_RUNNING); 2678 set_current_state(TASK_RUNNING);
2678 } 2679 }
2679 down(&s->open_sem); 2680 mutex_lock(&s->open_mutex);
2680 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 2681 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
2681 spin_lock_irqsave(&s->lock, flags); 2682 spin_lock_irqsave(&s->lock, flags);
2682 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2683 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2684,7 +2685,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file)
2684 outl(s->ctrl, s->io+ES1371_REG_CONTROL); 2685 outl(s->ctrl, s->io+ES1371_REG_CONTROL);
2685 } 2686 }
2686 spin_unlock_irqrestore(&s->lock, flags); 2687 spin_unlock_irqrestore(&s->lock, flags);
2687 up(&s->open_sem); 2688 mutex_unlock(&s->open_mutex);
2688 wake_up(&s->open_wait); 2689 wake_up(&s->open_wait);
2689 unlock_kernel(); 2690 unlock_kernel();
2690 return 0; 2691 return 0;
@@ -2884,7 +2885,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
2884 init_waitqueue_head(&s->open_wait); 2885 init_waitqueue_head(&s->open_wait);
2885 init_waitqueue_head(&s->midi.iwait); 2886 init_waitqueue_head(&s->midi.iwait);
2886 init_waitqueue_head(&s->midi.owait); 2887 init_waitqueue_head(&s->midi.owait);
2887 init_MUTEX(&s->open_sem); 2888 mutex_init(&s->open_mutex);
2888 spin_lock_init(&s->lock); 2889 spin_lock_init(&s->lock);
2889 s->magic = ES1371_MAGIC; 2890 s->magic = ES1371_MAGIC;
2890 s->dev = pcidev; 2891 s->dev = pcidev;
diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
index 849b59f67ef5..78d3e29ce968 100644
--- a/sound/oss/esssolo1.c
+++ b/sound/oss/esssolo1.c
@@ -105,6 +105,8 @@
105#include <linux/gameport.h> 105#include <linux/gameport.h>
106#include <linux/wait.h> 106#include <linux/wait.h>
107#include <linux/dma-mapping.h> 107#include <linux/dma-mapping.h>
108#include <linux/mutex.h>
109
108 110
109#include <asm/io.h> 111#include <asm/io.h>
110#include <asm/page.h> 112#include <asm/page.h>
@@ -191,7 +193,7 @@ struct solo1_state {
191 unsigned ena; 193 unsigned ena;
192 194
193 spinlock_t lock; 195 spinlock_t lock;
194 struct semaphore open_sem; 196 struct mutex open_mutex;
195 mode_t open_mode; 197 mode_t open_mode;
196 wait_queue_head_t open_wait; 198 wait_queue_head_t open_wait;
197 199
@@ -1581,7 +1583,7 @@ static int solo1_release(struct inode *inode, struct file *file)
1581 lock_kernel(); 1583 lock_kernel();
1582 if (file->f_mode & FMODE_WRITE) 1584 if (file->f_mode & FMODE_WRITE)
1583 drain_dac(s, file->f_flags & O_NONBLOCK); 1585 drain_dac(s, file->f_flags & O_NONBLOCK);
1584 down(&s->open_sem); 1586 mutex_lock(&s->open_mutex);
1585 if (file->f_mode & FMODE_WRITE) { 1587 if (file->f_mode & FMODE_WRITE) {
1586 stop_dac(s); 1588 stop_dac(s);
1587 outb(0, s->iobase+6); /* disable DMA */ 1589 outb(0, s->iobase+6); /* disable DMA */
@@ -1595,7 +1597,7 @@ static int solo1_release(struct inode *inode, struct file *file)
1595 } 1597 }
1596 s->open_mode &= ~(FMODE_READ | FMODE_WRITE); 1598 s->open_mode &= ~(FMODE_READ | FMODE_WRITE);
1597 wake_up(&s->open_wait); 1599 wake_up(&s->open_wait);
1598 up(&s->open_sem); 1600 mutex_unlock(&s->open_mutex);
1599 unlock_kernel(); 1601 unlock_kernel();
1600 return 0; 1602 return 0;
1601} 1603}
@@ -1624,21 +1626,21 @@ static int solo1_open(struct inode *inode, struct file *file)
1624 VALIDATE_STATE(s); 1626 VALIDATE_STATE(s);
1625 file->private_data = s; 1627 file->private_data = s;
1626 /* wait for device to become free */ 1628 /* wait for device to become free */
1627 down(&s->open_sem); 1629 mutex_lock(&s->open_mutex);
1628 while (s->open_mode & (FMODE_READ | FMODE_WRITE)) { 1630 while (s->open_mode & (FMODE_READ | FMODE_WRITE)) {
1629 if (file->f_flags & O_NONBLOCK) { 1631 if (file->f_flags & O_NONBLOCK) {
1630 up(&s->open_sem); 1632 mutex_unlock(&s->open_mutex);
1631 return -EBUSY; 1633 return -EBUSY;
1632 } 1634 }
1633 add_wait_queue(&s->open_wait, &wait); 1635 add_wait_queue(&s->open_wait, &wait);
1634 __set_current_state(TASK_INTERRUPTIBLE); 1636 __set_current_state(TASK_INTERRUPTIBLE);
1635 up(&s->open_sem); 1637 mutex_unlock(&s->open_mutex);
1636 schedule(); 1638 schedule();
1637 remove_wait_queue(&s->open_wait, &wait); 1639 remove_wait_queue(&s->open_wait, &wait);
1638 set_current_state(TASK_RUNNING); 1640 set_current_state(TASK_RUNNING);
1639 if (signal_pending(current)) 1641 if (signal_pending(current))
1640 return -ERESTARTSYS; 1642 return -ERESTARTSYS;
1641 down(&s->open_sem); 1643 mutex_lock(&s->open_mutex);
1642 } 1644 }
1643 s->fmt = AFMT_U8; 1645 s->fmt = AFMT_U8;
1644 s->channels = 1; 1646 s->channels = 1;
@@ -1650,7 +1652,7 @@ static int solo1_open(struct inode *inode, struct file *file)
1650 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = s->dma_dac.subdivision = 0; 1652 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = s->dma_dac.subdivision = 0;
1651 s->dma_dac.enabled = 1; 1653 s->dma_dac.enabled = 1;
1652 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1654 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1653 up(&s->open_sem); 1655 mutex_unlock(&s->open_mutex);
1654 prog_codec(s); 1656 prog_codec(s);
1655 return nonseekable_open(inode, file); 1657 return nonseekable_open(inode, file);
1656} 1658}
@@ -1911,21 +1913,21 @@ static int solo1_midi_open(struct inode *inode, struct file *file)
1911 VALIDATE_STATE(s); 1913 VALIDATE_STATE(s);
1912 file->private_data = s; 1914 file->private_data = s;
1913 /* wait for device to become free */ 1915 /* wait for device to become free */
1914 down(&s->open_sem); 1916 mutex_lock(&s->open_mutex);
1915 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 1917 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
1916 if (file->f_flags & O_NONBLOCK) { 1918 if (file->f_flags & O_NONBLOCK) {
1917 up(&s->open_sem); 1919 mutex_unlock(&s->open_mutex);
1918 return -EBUSY; 1920 return -EBUSY;
1919 } 1921 }
1920 add_wait_queue(&s->open_wait, &wait); 1922 add_wait_queue(&s->open_wait, &wait);
1921 __set_current_state(TASK_INTERRUPTIBLE); 1923 __set_current_state(TASK_INTERRUPTIBLE);
1922 up(&s->open_sem); 1924 mutex_unlock(&s->open_mutex);
1923 schedule(); 1925 schedule();
1924 remove_wait_queue(&s->open_wait, &wait); 1926 remove_wait_queue(&s->open_wait, &wait);
1925 set_current_state(TASK_RUNNING); 1927 set_current_state(TASK_RUNNING);
1926 if (signal_pending(current)) 1928 if (signal_pending(current))
1927 return -ERESTARTSYS; 1929 return -ERESTARTSYS;
1928 down(&s->open_sem); 1930 mutex_lock(&s->open_mutex);
1929 } 1931 }
1930 spin_lock_irqsave(&s->lock, flags); 1932 spin_lock_irqsave(&s->lock, flags);
1931 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 1933 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -1951,7 +1953,7 @@ static int solo1_midi_open(struct inode *inode, struct file *file)
1951 } 1953 }
1952 spin_unlock_irqrestore(&s->lock, flags); 1954 spin_unlock_irqrestore(&s->lock, flags);
1953 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 1955 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
1954 up(&s->open_sem); 1956 mutex_unlock(&s->open_mutex);
1955 return nonseekable_open(inode, file); 1957 return nonseekable_open(inode, file);
1956} 1958}
1957 1959
@@ -1985,7 +1987,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file)
1985 remove_wait_queue(&s->midi.owait, &wait); 1987 remove_wait_queue(&s->midi.owait, &wait);
1986 set_current_state(TASK_RUNNING); 1988 set_current_state(TASK_RUNNING);
1987 } 1989 }
1988 down(&s->open_sem); 1990 mutex_lock(&s->open_mutex);
1989 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 1991 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
1990 spin_lock_irqsave(&s->lock, flags); 1992 spin_lock_irqsave(&s->lock, flags);
1991 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 1993 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -1994,7 +1996,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file)
1994 } 1996 }
1995 spin_unlock_irqrestore(&s->lock, flags); 1997 spin_unlock_irqrestore(&s->lock, flags);
1996 wake_up(&s->open_wait); 1998 wake_up(&s->open_wait);
1997 up(&s->open_sem); 1999 mutex_unlock(&s->open_mutex);
1998 unlock_kernel(); 2000 unlock_kernel();
1999 return 0; 2001 return 0;
2000} 2002}
@@ -2132,24 +2134,24 @@ static int solo1_dmfm_open(struct inode *inode, struct file *file)
2132 VALIDATE_STATE(s); 2134 VALIDATE_STATE(s);
2133 file->private_data = s; 2135 file->private_data = s;
2134 /* wait for device to become free */ 2136 /* wait for device to become free */
2135 down(&s->open_sem); 2137 mutex_lock(&s->open_mutex);
2136 while (s->open_mode & FMODE_DMFM) { 2138 while (s->open_mode & FMODE_DMFM) {
2137 if (file->f_flags & O_NONBLOCK) { 2139 if (file->f_flags & O_NONBLOCK) {
2138 up(&s->open_sem); 2140 mutex_unlock(&s->open_mutex);
2139 return -EBUSY; 2141 return -EBUSY;
2140 } 2142 }
2141 add_wait_queue(&s->open_wait, &wait); 2143 add_wait_queue(&s->open_wait, &wait);
2142 __set_current_state(TASK_INTERRUPTIBLE); 2144 __set_current_state(TASK_INTERRUPTIBLE);
2143 up(&s->open_sem); 2145 mutex_unlock(&s->open_mutex);
2144 schedule(); 2146 schedule();
2145 remove_wait_queue(&s->open_wait, &wait); 2147 remove_wait_queue(&s->open_wait, &wait);
2146 set_current_state(TASK_RUNNING); 2148 set_current_state(TASK_RUNNING);
2147 if (signal_pending(current)) 2149 if (signal_pending(current))
2148 return -ERESTARTSYS; 2150 return -ERESTARTSYS;
2149 down(&s->open_sem); 2151 mutex_lock(&s->open_mutex);
2150 } 2152 }
2151 if (!request_region(s->sbbase, FMSYNTH_EXTENT, "ESS Solo1")) { 2153 if (!request_region(s->sbbase, FMSYNTH_EXTENT, "ESS Solo1")) {
2152 up(&s->open_sem); 2154 mutex_unlock(&s->open_mutex);
2153 printk(KERN_ERR "solo1: FM synth io ports in use, opl3 loaded?\n"); 2155 printk(KERN_ERR "solo1: FM synth io ports in use, opl3 loaded?\n");
2154 return -EBUSY; 2156 return -EBUSY;
2155 } 2157 }
@@ -2161,7 +2163,7 @@ static int solo1_dmfm_open(struct inode *inode, struct file *file)
2161 outb(5, s->sbbase+2); 2163 outb(5, s->sbbase+2);
2162 outb(1, s->sbbase+3); /* enable OPL3 */ 2164 outb(1, s->sbbase+3); /* enable OPL3 */
2163 s->open_mode |= FMODE_DMFM; 2165 s->open_mode |= FMODE_DMFM;
2164 up(&s->open_sem); 2166 mutex_unlock(&s->open_mutex);
2165 return nonseekable_open(inode, file); 2167 return nonseekable_open(inode, file);
2166} 2168}
2167 2169
@@ -2172,7 +2174,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file)
2172 2174
2173 VALIDATE_STATE(s); 2175 VALIDATE_STATE(s);
2174 lock_kernel(); 2176 lock_kernel();
2175 down(&s->open_sem); 2177 mutex_lock(&s->open_mutex);
2176 s->open_mode &= ~FMODE_DMFM; 2178 s->open_mode &= ~FMODE_DMFM;
2177 for (regb = 0xb0; regb < 0xb9; regb++) { 2179 for (regb = 0xb0; regb < 0xb9; regb++) {
2178 outb(regb, s->sbbase); 2180 outb(regb, s->sbbase);
@@ -2182,7 +2184,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file)
2182 } 2184 }
2183 release_region(s->sbbase, FMSYNTH_EXTENT); 2185 release_region(s->sbbase, FMSYNTH_EXTENT);
2184 wake_up(&s->open_wait); 2186 wake_up(&s->open_wait);
2185 up(&s->open_sem); 2187 mutex_unlock(&s->open_mutex);
2186 unlock_kernel(); 2188 unlock_kernel();
2187 return 0; 2189 return 0;
2188} 2190}
@@ -2362,7 +2364,7 @@ static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device
2362 init_waitqueue_head(&s->open_wait); 2364 init_waitqueue_head(&s->open_wait);
2363 init_waitqueue_head(&s->midi.iwait); 2365 init_waitqueue_head(&s->midi.iwait);
2364 init_waitqueue_head(&s->midi.owait); 2366 init_waitqueue_head(&s->midi.owait);
2365 init_MUTEX(&s->open_sem); 2367 mutex_init(&s->open_mutex);
2366 spin_lock_init(&s->lock); 2368 spin_lock_init(&s->lock);
2367 s->magic = SOLO1_MAGIC; 2369 s->magic = SOLO1_MAGIC;
2368 s->dev = pcidev; 2370 s->dev = pcidev;
diff --git a/sound/oss/forte.c b/sound/oss/forte.c
index 8406bc90c4ff..0294eec8ad90 100644
--- a/sound/oss/forte.c
+++ b/sound/oss/forte.c
@@ -43,6 +43,7 @@
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44 44
45#include <linux/proc_fs.h> 45#include <linux/proc_fs.h>
46#include <linux/mutex.h>
46 47
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48#include <asm/io.h> 49#include <asm/io.h>
@@ -185,7 +186,7 @@ struct forte_chip {
185 unsigned long iobase; 186 unsigned long iobase;
186 int irq; 187 int irq;
187 188
188 struct semaphore open_sem; /* Device access */ 189 struct mutex open_mutex; /* Device access */
189 spinlock_t lock; /* State */ 190 spinlock_t lock; /* State */
190 191
191 spinlock_t ac97_lock; 192 spinlock_t ac97_lock;
@@ -1242,13 +1243,13 @@ forte_dsp_open (struct inode *inode, struct file *file)
1242 struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */ 1243 struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */
1243 1244
1244 if (file->f_flags & O_NONBLOCK) { 1245 if (file->f_flags & O_NONBLOCK) {
1245 if (down_trylock (&chip->open_sem)) { 1246 if (!mutex_trylock(&chip->open_mutex)) {
1246 DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__); 1247 DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__);
1247 return -EAGAIN; 1248 return -EAGAIN;
1248 } 1249 }
1249 } 1250 }
1250 else { 1251 else {
1251 if (down_interruptible (&chip->open_sem)) { 1252 if (mutex_lock_interruptible(&chip->open_mutex)) {
1252 DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__); 1253 DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__);
1253 return -ERESTARTSYS; 1254 return -ERESTARTSYS;
1254 } 1255 }
@@ -1302,7 +1303,7 @@ forte_dsp_release (struct inode *inode, struct file *file)
1302 spin_unlock_irq (&chip->lock); 1303 spin_unlock_irq (&chip->lock);
1303 } 1304 }
1304 1305
1305 up (&chip->open_sem); 1306 mutex_unlock(&chip->open_mutex);
1306 1307
1307 return ret; 1308 return ret;
1308} 1309}
@@ -2011,7 +2012,7 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
2011 memset (chip, 0, sizeof (struct forte_chip)); 2012 memset (chip, 0, sizeof (struct forte_chip));
2012 chip->pci_dev = pci_dev; 2013 chip->pci_dev = pci_dev;
2013 2014
2014 init_MUTEX(&chip->open_sem); 2015 mutex_init(&chip->open_mutex);
2015 spin_lock_init (&chip->lock); 2016 spin_lock_init (&chip->lock);
2016 spin_lock_init (&chip->ac97_lock); 2017 spin_lock_init (&chip->ac97_lock);
2017 2018
diff --git a/sound/oss/hal2.c b/sound/oss/hal2.c
index afe97c4ce069..dd4f59d30a3a 100644
--- a/sound/oss/hal2.c
+++ b/sound/oss/hal2.c
@@ -32,6 +32,8 @@
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/sound.h> 33#include <linux/sound.h>
34#include <linux/soundcard.h> 34#include <linux/soundcard.h>
35#include <linux/mutex.h>
36
35 37
36#include <asm/io.h> 38#include <asm/io.h>
37#include <asm/sgi/hpc3.h> 39#include <asm/sgi/hpc3.h>
@@ -92,7 +94,7 @@ struct hal2_codec {
92 94
93 wait_queue_head_t dma_wait; 95 wait_queue_head_t dma_wait;
94 spinlock_t lock; 96 spinlock_t lock;
95 struct semaphore sem; 97 struct mutex sem;
96 98
97 int usecount; /* recording and playback are 99 int usecount; /* recording and playback are
98 * independent */ 100 * independent */
@@ -1178,7 +1180,7 @@ static ssize_t hal2_read(struct file *file, char *buffer,
1178 1180
1179 if (!count) 1181 if (!count)
1180 return 0; 1182 return 0;
1181 if (down_interruptible(&adc->sem)) 1183 if (mutex_lock_interruptible(&adc->sem))
1182 return -EINTR; 1184 return -EINTR;
1183 if (file->f_flags & O_NONBLOCK) { 1185 if (file->f_flags & O_NONBLOCK) {
1184 err = hal2_get_buffer(hal2, buffer, count); 1186 err = hal2_get_buffer(hal2, buffer, count);
@@ -1217,7 +1219,7 @@ static ssize_t hal2_read(struct file *file, char *buffer,
1217 } 1219 }
1218 } while (count > 0 && err >= 0); 1220 } while (count > 0 && err >= 0);
1219 } 1221 }
1220 up(&adc->sem); 1222 mutex_unlock(&adc->sem);
1221 1223
1222 return err; 1224 return err;
1223} 1225}
@@ -1232,7 +1234,7 @@ static ssize_t hal2_write(struct file *file, const char *buffer,
1232 1234
1233 if (!count) 1235 if (!count)
1234 return 0; 1236 return 0;
1235 if (down_interruptible(&dac->sem)) 1237 if (mutex_lock_interruptible(&dac->sem))
1236 return -EINTR; 1238 return -EINTR;
1237 if (file->f_flags & O_NONBLOCK) { 1239 if (file->f_flags & O_NONBLOCK) {
1238 err = hal2_add_buffer(hal2, buf, count); 1240 err = hal2_add_buffer(hal2, buf, count);
@@ -1271,7 +1273,7 @@ static ssize_t hal2_write(struct file *file, const char *buffer,
1271 } 1273 }
1272 } while (count > 0 && err >= 0); 1274 } while (count > 0 && err >= 0);
1273 } 1275 }
1274 up(&dac->sem); 1276 mutex_unlock(&dac->sem);
1275 1277
1276 return err; 1278 return err;
1277} 1279}
@@ -1356,20 +1358,20 @@ static int hal2_release(struct inode *inode, struct file *file)
1356 if (file->f_mode & FMODE_READ) { 1358 if (file->f_mode & FMODE_READ) {
1357 struct hal2_codec *adc = &hal2->adc; 1359 struct hal2_codec *adc = &hal2->adc;
1358 1360
1359 down(&adc->sem); 1361 mutex_lock(&adc->sem);
1360 hal2_stop_adc(hal2); 1362 hal2_stop_adc(hal2);
1361 hal2_free_adc_dmabuf(adc); 1363 hal2_free_adc_dmabuf(adc);
1362 adc->usecount--; 1364 adc->usecount--;
1363 up(&adc->sem); 1365 mutex_unlock(&adc->sem);
1364 } 1366 }
1365 if (file->f_mode & FMODE_WRITE) { 1367 if (file->f_mode & FMODE_WRITE) {
1366 struct hal2_codec *dac = &hal2->dac; 1368 struct hal2_codec *dac = &hal2->dac;
1367 1369
1368 down(&dac->sem); 1370 mutex_lock(&dac->sem);
1369 hal2_sync_dac(hal2); 1371 hal2_sync_dac(hal2);
1370 hal2_free_dac_dmabuf(dac); 1372 hal2_free_dac_dmabuf(dac);
1371 dac->usecount--; 1373 dac->usecount--;
1372 up(&dac->sem); 1374 mutex_unlock(&dac->sem);
1373 } 1375 }
1374 1376
1375 return 0; 1377 return 0;
@@ -1400,7 +1402,7 @@ static void hal2_init_codec(struct hal2_codec *codec, struct hpc3_regs *hpc3,
1400 codec->pbus.pbusnr = index; 1402 codec->pbus.pbusnr = index;
1401 codec->pbus.pbus = &hpc3->pbdma[index]; 1403 codec->pbus.pbus = &hpc3->pbdma[index];
1402 init_waitqueue_head(&codec->dma_wait); 1404 init_waitqueue_head(&codec->dma_wait);
1403 init_MUTEX(&codec->sem); 1405 mutex_init(&codec->sem);
1404 spin_lock_init(&codec->lock); 1406 spin_lock_init(&codec->lock);
1405} 1407}
1406 1408
diff --git a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
index abc242abd5b1..dd2b871cdac5 100644
--- a/sound/oss/i810_audio.c
+++ b/sound/oss/i810_audio.c
@@ -100,6 +100,8 @@
100#include <linux/smp_lock.h> 100#include <linux/smp_lock.h>
101#include <linux/ac97_codec.h> 101#include <linux/ac97_codec.h>
102#include <linux/bitops.h> 102#include <linux/bitops.h>
103#include <linux/mutex.h>
104
103#include <asm/uaccess.h> 105#include <asm/uaccess.h>
104 106
105#define DRIVER_VERSION "1.01" 107#define DRIVER_VERSION "1.01"
@@ -331,7 +333,7 @@ struct i810_state {
331 struct i810_card *card; /* Card info */ 333 struct i810_card *card; /* Card info */
332 334
333 /* single open lock mechanism, only used for recording */ 335 /* single open lock mechanism, only used for recording */
334 struct semaphore open_sem; 336 struct mutex open_mutex;
335 wait_queue_head_t open_wait; 337 wait_queue_head_t open_wait;
336 338
337 /* file mode */ 339 /* file mode */
@@ -2597,7 +2599,7 @@ found_virt:
2597 state->card = card; 2599 state->card = card;
2598 state->magic = I810_STATE_MAGIC; 2600 state->magic = I810_STATE_MAGIC;
2599 init_waitqueue_head(&dmabuf->wait); 2601 init_waitqueue_head(&dmabuf->wait);
2600 init_MUTEX(&state->open_sem); 2602 mutex_init(&state->open_mutex);
2601 file->private_data = state; 2603 file->private_data = state;
2602 dmabuf->trigger = 0; 2604 dmabuf->trigger = 0;
2603 2605
@@ -3213,7 +3215,7 @@ static void __devinit i810_configure_clocking (void)
3213 state->card = card; 3215 state->card = card;
3214 state->magic = I810_STATE_MAGIC; 3216 state->magic = I810_STATE_MAGIC;
3215 init_waitqueue_head(&dmabuf->wait); 3217 init_waitqueue_head(&dmabuf->wait);
3216 init_MUTEX(&state->open_sem); 3218 mutex_init(&state->open_mutex);
3217 dmabuf->fmt = I810_FMT_STEREO | I810_FMT_16BIT; 3219 dmabuf->fmt = I810_FMT_STEREO | I810_FMT_16BIT;
3218 dmabuf->trigger = PCM_ENABLE_OUTPUT; 3220 dmabuf->trigger = PCM_ENABLE_OUTPUT;
3219 i810_set_spdif_output(state, -1, 0); 3221 i810_set_spdif_output(state, -1, 0);
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c
index 8fd2f9a9e668..ffcb910f5c3e 100644
--- a/sound/oss/ite8172.c
+++ b/sound/oss/ite8172.c
@@ -71,6 +71,8 @@
71#include <linux/smp_lock.h> 71#include <linux/smp_lock.h>
72#include <linux/ac97_codec.h> 72#include <linux/ac97_codec.h>
73#include <linux/interrupt.h> 73#include <linux/interrupt.h>
74#include <linux/mutex.h>
75
74#include <asm/io.h> 76#include <asm/io.h>
75#include <asm/dma.h> 77#include <asm/dma.h>
76#include <asm/uaccess.h> 78#include <asm/uaccess.h>
@@ -304,7 +306,7 @@ struct it8172_state {
304 unsigned dacrate, adcrate; 306 unsigned dacrate, adcrate;
305 307
306 spinlock_t lock; 308 spinlock_t lock;
307 struct semaphore open_sem; 309 struct mutex open_mutex;
308 mode_t open_mode; 310 mode_t open_mode;
309 wait_queue_head_t open_wait; 311 wait_queue_head_t open_wait;
310 312
@@ -1801,21 +1803,21 @@ static int it8172_open(struct inode *inode, struct file *file)
1801 } 1803 }
1802 file->private_data = s; 1804 file->private_data = s;
1803 /* wait for device to become free */ 1805 /* wait for device to become free */
1804 down(&s->open_sem); 1806 mutex_lock(&s->open_mutex);
1805 while (s->open_mode & file->f_mode) { 1807 while (s->open_mode & file->f_mode) {
1806 if (file->f_flags & O_NONBLOCK) { 1808 if (file->f_flags & O_NONBLOCK) {
1807 up(&s->open_sem); 1809 mutex_unlock(&s->open_mutex);
1808 return -EBUSY; 1810 return -EBUSY;
1809 } 1811 }
1810 add_wait_queue(&s->open_wait, &wait); 1812 add_wait_queue(&s->open_wait, &wait);
1811 __set_current_state(TASK_INTERRUPTIBLE); 1813 __set_current_state(TASK_INTERRUPTIBLE);
1812 up(&s->open_sem); 1814 mutex_unlock(&s->open_mutex);
1813 schedule(); 1815 schedule();
1814 remove_wait_queue(&s->open_wait, &wait); 1816 remove_wait_queue(&s->open_wait, &wait);
1815 set_current_state(TASK_RUNNING); 1817 set_current_state(TASK_RUNNING);
1816 if (signal_pending(current)) 1818 if (signal_pending(current))
1817 return -ERESTARTSYS; 1819 return -ERESTARTSYS;
1818 down(&s->open_sem); 1820 mutex_lock(&s->open_mutex);
1819 } 1821 }
1820 1822
1821 spin_lock_irqsave(&s->lock, flags); 1823 spin_lock_irqsave(&s->lock, flags);
@@ -1850,7 +1852,7 @@ static int it8172_open(struct inode *inode, struct file *file)
1850 spin_unlock_irqrestore(&s->lock, flags); 1852 spin_unlock_irqrestore(&s->lock, flags);
1851 1853
1852 s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); 1854 s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
1853 up(&s->open_sem); 1855 mutex_unlock(&s->open_mutex);
1854 return nonseekable_open(inode, file); 1856 return nonseekable_open(inode, file);
1855} 1857}
1856 1858
@@ -1864,7 +1866,7 @@ static int it8172_release(struct inode *inode, struct file *file)
1864 lock_kernel(); 1866 lock_kernel();
1865 if (file->f_mode & FMODE_WRITE) 1867 if (file->f_mode & FMODE_WRITE)
1866 drain_dac(s, file->f_flags & O_NONBLOCK); 1868 drain_dac(s, file->f_flags & O_NONBLOCK);
1867 down(&s->open_sem); 1869 mutex_lock(&s->open_mutex);
1868 if (file->f_mode & FMODE_WRITE) { 1870 if (file->f_mode & FMODE_WRITE) {
1869 stop_dac(s); 1871 stop_dac(s);
1870 dealloc_dmabuf(s, &s->dma_dac); 1872 dealloc_dmabuf(s, &s->dma_dac);
@@ -1874,7 +1876,7 @@ static int it8172_release(struct inode *inode, struct file *file)
1874 dealloc_dmabuf(s, &s->dma_adc); 1876 dealloc_dmabuf(s, &s->dma_adc);
1875 } 1877 }
1876 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); 1878 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
1877 up(&s->open_sem); 1879 mutex_unlock(&s->open_mutex);
1878 wake_up(&s->open_wait); 1880 wake_up(&s->open_wait);
1879 unlock_kernel(); 1881 unlock_kernel();
1880 return 0; 1882 return 0;
@@ -1997,7 +1999,7 @@ static int __devinit it8172_probe(struct pci_dev *pcidev,
1997 init_waitqueue_head(&s->dma_adc.wait); 1999 init_waitqueue_head(&s->dma_adc.wait);
1998 init_waitqueue_head(&s->dma_dac.wait); 2000 init_waitqueue_head(&s->dma_dac.wait);
1999 init_waitqueue_head(&s->open_wait); 2001 init_waitqueue_head(&s->open_wait);
2000 init_MUTEX(&s->open_sem); 2002 mutex_init(&s->open_mutex);
2001 spin_lock_init(&s->lock); 2003 spin_lock_init(&s->lock);
2002 s->dev = pcidev; 2004 s->dev = pcidev;
2003 s->io = pci_resource_start(pcidev, 0); 2005 s->io = pci_resource_start(pcidev, 0);
diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c
index d4b569acf764..e647f2f86279 100644
--- a/sound/oss/maestro.c
+++ b/sound/oss/maestro.c
@@ -223,6 +223,8 @@
223#include <linux/reboot.h> 223#include <linux/reboot.h>
224#include <linux/bitops.h> 224#include <linux/bitops.h>
225#include <linux/wait.h> 225#include <linux/wait.h>
226#include <linux/mutex.h>
227
226 228
227#include <asm/current.h> 229#include <asm/current.h>
228#include <asm/dma.h> 230#include <asm/dma.h>
@@ -397,7 +399,7 @@ struct ess_state {
397 /* this locks around the oss state in the driver */ 399 /* this locks around the oss state in the driver */
398 spinlock_t lock; 400 spinlock_t lock;
399 /* only let 1 be opening at a time */ 401 /* only let 1 be opening at a time */
400 struct semaphore open_sem; 402 struct mutex open_mutex;
401 wait_queue_head_t open_wait; 403 wait_queue_head_t open_wait;
402 mode_t open_mode; 404 mode_t open_mode;
403 405
@@ -3020,26 +3022,26 @@ ess_open(struct inode *inode, struct file *file)
3020 VALIDATE_STATE(s); 3022 VALIDATE_STATE(s);
3021 file->private_data = s; 3023 file->private_data = s;
3022 /* wait for device to become free */ 3024 /* wait for device to become free */
3023 down(&s->open_sem); 3025 mutex_lock(&s->open_mutex);
3024 while (s->open_mode & file->f_mode) { 3026 while (s->open_mode & file->f_mode) {
3025 if (file->f_flags & O_NONBLOCK) { 3027 if (file->f_flags & O_NONBLOCK) {
3026 up(&s->open_sem); 3028 mutex_unlock(&s->open_mutex);
3027 return -EWOULDBLOCK; 3029 return -EWOULDBLOCK;
3028 } 3030 }
3029 up(&s->open_sem); 3031 mutex_unlock(&s->open_mutex);
3030 interruptible_sleep_on(&s->open_wait); 3032 interruptible_sleep_on(&s->open_wait);
3031 if (signal_pending(current)) 3033 if (signal_pending(current))
3032 return -ERESTARTSYS; 3034 return -ERESTARTSYS;
3033 down(&s->open_sem); 3035 mutex_lock(&s->open_mutex);
3034 } 3036 }
3035 3037
3036 /* under semaphore.. */ 3038 /* under semaphore.. */
3037 if ((s->card->dmapages==NULL) && allocate_buffers(s)) { 3039 if ((s->card->dmapages==NULL) && allocate_buffers(s)) {
3038 up(&s->open_sem); 3040 mutex_unlock(&s->open_mutex);
3039 return -ENOMEM; 3041 return -ENOMEM;
3040 } 3042 }
3041 3043
3042 /* we're covered by the open_sem */ 3044 /* we're covered by the open_mutex */
3043 if( ! s->card->dsps_open ) { 3045 if( ! s->card->dsps_open ) {
3044 maestro_power(s->card,ACPI_D0); 3046 maestro_power(s->card,ACPI_D0);
3045 start_bob(s); 3047 start_bob(s);
@@ -3076,7 +3078,7 @@ ess_open(struct inode *inode, struct file *file)
3076 set_fmt(s, fmtm, fmts); 3078 set_fmt(s, fmtm, fmts);
3077 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 3079 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
3078 3080
3079 up(&s->open_sem); 3081 mutex_unlock(&s->open_mutex);
3080 return nonseekable_open(inode, file); 3082 return nonseekable_open(inode, file);
3081} 3083}
3082 3084
@@ -3089,7 +3091,7 @@ ess_release(struct inode *inode, struct file *file)
3089 lock_kernel(); 3091 lock_kernel();
3090 if (file->f_mode & FMODE_WRITE) 3092 if (file->f_mode & FMODE_WRITE)
3091 drain_dac(s, file->f_flags & O_NONBLOCK); 3093 drain_dac(s, file->f_flags & O_NONBLOCK);
3092 down(&s->open_sem); 3094 mutex_lock(&s->open_mutex);
3093 if (file->f_mode & FMODE_WRITE) { 3095 if (file->f_mode & FMODE_WRITE) {
3094 stop_dac(s); 3096 stop_dac(s);
3095 } 3097 }
@@ -3098,7 +3100,7 @@ ess_release(struct inode *inode, struct file *file)
3098 } 3100 }
3099 3101
3100 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 3102 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3101 /* we're covered by the open_sem */ 3103 /* we're covered by the open_mutex */
3102 M_printk("maestro: %d dsps now alive\n",s->card->dsps_open-1); 3104 M_printk("maestro: %d dsps now alive\n",s->card->dsps_open-1);
3103 if( --s->card->dsps_open <= 0) { 3105 if( --s->card->dsps_open <= 0) {
3104 s->card->dsps_open = 0; 3106 s->card->dsps_open = 0;
@@ -3106,7 +3108,7 @@ ess_release(struct inode *inode, struct file *file)
3106 free_buffers(s); 3108 free_buffers(s);
3107 maestro_power(s->card,ACPI_D2); 3109 maestro_power(s->card,ACPI_D2);
3108 } 3110 }
3109 up(&s->open_sem); 3111 mutex_unlock(&s->open_mutex);
3110 wake_up(&s->open_wait); 3112 wake_up(&s->open_wait);
3111 unlock_kernel(); 3113 unlock_kernel();
3112 return 0; 3114 return 0;
@@ -3466,7 +3468,7 @@ maestro_probe(struct pci_dev *pcidev,const struct pci_device_id *pdid)
3466 init_waitqueue_head(&s->dma_dac.wait); 3468 init_waitqueue_head(&s->dma_dac.wait);
3467 init_waitqueue_head(&s->open_wait); 3469 init_waitqueue_head(&s->open_wait);
3468 spin_lock_init(&s->lock); 3470 spin_lock_init(&s->lock);
3469 init_MUTEX(&s->open_sem); 3471 mutex_init(&s->open_mutex);
3470 s->magic = ESS_STATE_MAGIC; 3472 s->magic = ESS_STATE_MAGIC;
3471 3473
3472 s->apu[0] = 6*i; 3474 s->apu[0] = 6*i;
diff --git a/sound/oss/maestro3.c b/sound/oss/maestro3.c
index f3dec70fcb9b..66044aff2586 100644
--- a/sound/oss/maestro3.c
+++ b/sound/oss/maestro3.c
@@ -144,6 +144,8 @@
144#include <linux/spinlock.h> 144#include <linux/spinlock.h>
145#include <linux/ac97_codec.h> 145#include <linux/ac97_codec.h>
146#include <linux/wait.h> 146#include <linux/wait.h>
147#include <linux/mutex.h>
148
147 149
148#include <asm/io.h> 150#include <asm/io.h>
149#include <asm/dma.h> 151#include <asm/dma.h>
@@ -205,7 +207,7 @@ struct m3_state {
205 when irqhandler uses s->lock 207 when irqhandler uses s->lock
206 and m3_assp_read uses card->lock ? 208 and m3_assp_read uses card->lock ?
207 */ 209 */
208 struct semaphore open_sem; 210 struct mutex open_mutex;
209 wait_queue_head_t open_wait; 211 wait_queue_head_t open_wait;
210 mode_t open_mode; 212 mode_t open_mode;
211 213
@@ -2013,17 +2015,17 @@ static int m3_open(struct inode *inode, struct file *file)
2013 file->private_data = s; 2015 file->private_data = s;
2014 2016
2015 /* wait for device to become free */ 2017 /* wait for device to become free */
2016 down(&s->open_sem); 2018 mutex_lock(&s->open_mutex);
2017 while (s->open_mode & file->f_mode) { 2019 while (s->open_mode & file->f_mode) {
2018 if (file->f_flags & O_NONBLOCK) { 2020 if (file->f_flags & O_NONBLOCK) {
2019 up(&s->open_sem); 2021 mutex_unlock(&s->open_mutex);
2020 return -EWOULDBLOCK; 2022 return -EWOULDBLOCK;
2021 } 2023 }
2022 up(&s->open_sem); 2024 mutex_unlock(&s->open_mutex);
2023 interruptible_sleep_on(&s->open_wait); 2025 interruptible_sleep_on(&s->open_wait);
2024 if (signal_pending(current)) 2026 if (signal_pending(current))
2025 return -ERESTARTSYS; 2027 return -ERESTARTSYS;
2026 down(&s->open_sem); 2028 mutex_lock(&s->open_mutex);
2027 } 2029 }
2028 2030
2029 spin_lock_irqsave(&c->lock, flags); 2031 spin_lock_irqsave(&c->lock, flags);
@@ -2047,7 +2049,7 @@ static int m3_open(struct inode *inode, struct file *file)
2047 set_fmt(s, fmtm, fmts); 2049 set_fmt(s, fmtm, fmts);
2048 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2050 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2049 2051
2050 up(&s->open_sem); 2052 mutex_unlock(&s->open_mutex);
2051 spin_unlock_irqrestore(&c->lock, flags); 2053 spin_unlock_irqrestore(&c->lock, flags);
2052 return nonseekable_open(inode, file); 2054 return nonseekable_open(inode, file);
2053} 2055}
@@ -2062,7 +2064,7 @@ static int m3_release(struct inode *inode, struct file *file)
2062 if (file->f_mode & FMODE_WRITE) 2064 if (file->f_mode & FMODE_WRITE)
2063 drain_dac(s, file->f_flags & O_NONBLOCK); 2065 drain_dac(s, file->f_flags & O_NONBLOCK);
2064 2066
2065 down(&s->open_sem); 2067 mutex_lock(&s->open_mutex);
2066 spin_lock_irqsave(&card->lock, flags); 2068 spin_lock_irqsave(&card->lock, flags);
2067 2069
2068 if (file->f_mode & FMODE_WRITE) { 2070 if (file->f_mode & FMODE_WRITE) {
@@ -2083,7 +2085,7 @@ static int m3_release(struct inode *inode, struct file *file)
2083 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 2085 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
2084 2086
2085 spin_unlock_irqrestore(&card->lock, flags); 2087 spin_unlock_irqrestore(&card->lock, flags);
2086 up(&s->open_sem); 2088 mutex_unlock(&s->open_mutex);
2087 wake_up(&s->open_wait); 2089 wake_up(&s->open_wait);
2088 2090
2089 return 0; 2091 return 0;
@@ -2679,7 +2681,7 @@ static int __devinit m3_probe(struct pci_dev *pci_dev, const struct pci_device_i
2679 init_waitqueue_head(&s->dma_adc.wait); 2681 init_waitqueue_head(&s->dma_adc.wait);
2680 init_waitqueue_head(&s->dma_dac.wait); 2682 init_waitqueue_head(&s->dma_dac.wait);
2681 init_waitqueue_head(&s->open_wait); 2683 init_waitqueue_head(&s->open_wait);
2682 init_MUTEX(&(s->open_sem)); 2684 mutex_init(&(s->open_mutex));
2683 s->magic = M3_STATE_MAGIC; 2685 s->magic = M3_STATE_MAGIC;
2684 2686
2685 m3_assp_client_init(s); 2687 m3_assp_client_init(s);
diff --git a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
index fbb9170e8e0a..21c1954d9108 100644
--- a/sound/oss/nec_vrc5477.c
+++ b/sound/oss/nec_vrc5477.c
@@ -78,6 +78,8 @@
78#include <linux/spinlock.h> 78#include <linux/spinlock.h>
79#include <linux/smp_lock.h> 79#include <linux/smp_lock.h>
80#include <linux/ac97_codec.h> 80#include <linux/ac97_codec.h>
81#include <linux/mutex.h>
82
81#include <asm/io.h> 83#include <asm/io.h>
82#include <asm/dma.h> 84#include <asm/dma.h>
83#include <asm/uaccess.h> 85#include <asm/uaccess.h>
@@ -198,7 +200,7 @@ struct vrc5477_ac97_state {
198 unsigned short extended_status; 200 unsigned short extended_status;
199 201
200 spinlock_t lock; 202 spinlock_t lock;
201 struct semaphore open_sem; 203 struct mutex open_mutex;
202 mode_t open_mode; 204 mode_t open_mode;
203 wait_queue_head_t open_wait; 205 wait_queue_head_t open_wait;
204 206
@@ -1617,22 +1619,22 @@ static int vrc5477_ac97_open(struct inode *inode, struct file *file)
1617 file->private_data = s; 1619 file->private_data = s;
1618 1620
1619 /* wait for device to become free */ 1621 /* wait for device to become free */
1620 down(&s->open_sem); 1622 mutex_lock(&s->open_mutex);
1621 while (s->open_mode & file->f_mode) { 1623 while (s->open_mode & file->f_mode) {
1622 1624
1623 if (file->f_flags & O_NONBLOCK) { 1625 if (file->f_flags & O_NONBLOCK) {
1624 up(&s->open_sem); 1626 mutex_unlock(&s->open_mutex);
1625 return -EBUSY; 1627 return -EBUSY;
1626 } 1628 }
1627 add_wait_queue(&s->open_wait, &wait); 1629 add_wait_queue(&s->open_wait, &wait);
1628 __set_current_state(TASK_INTERRUPTIBLE); 1630 __set_current_state(TASK_INTERRUPTIBLE);
1629 up(&s->open_sem); 1631 mutex_unlock(&s->open_mutex);
1630 schedule(); 1632 schedule();
1631 remove_wait_queue(&s->open_wait, &wait); 1633 remove_wait_queue(&s->open_wait, &wait);
1632 set_current_state(TASK_RUNNING); 1634 set_current_state(TASK_RUNNING);
1633 if (signal_pending(current)) 1635 if (signal_pending(current))
1634 return -ERESTARTSYS; 1636 return -ERESTARTSYS;
1635 down(&s->open_sem); 1637 mutex_lock(&s->open_mutex);
1636 } 1638 }
1637 1639
1638 spin_lock_irqsave(&s->lock, flags); 1640 spin_lock_irqsave(&s->lock, flags);
@@ -1659,7 +1661,7 @@ static int vrc5477_ac97_open(struct inode *inode, struct file *file)
1659 bailout: 1661 bailout:
1660 spin_unlock_irqrestore(&s->lock, flags); 1662 spin_unlock_irqrestore(&s->lock, flags);
1661 1663
1662 up(&s->open_sem); 1664 mutex_unlock(&s->open_mutex);
1663 return ret; 1665 return ret;
1664} 1666}
1665 1667
@@ -1671,7 +1673,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
1671 lock_kernel(); 1673 lock_kernel();
1672 if (file->f_mode & FMODE_WRITE) 1674 if (file->f_mode & FMODE_WRITE)
1673 drain_dac(s, file->f_flags & O_NONBLOCK); 1675 drain_dac(s, file->f_flags & O_NONBLOCK);
1674 down(&s->open_sem); 1676 mutex_lock(&s->open_mutex);
1675 if (file->f_mode & FMODE_WRITE) { 1677 if (file->f_mode & FMODE_WRITE) {
1676 stop_dac(s); 1678 stop_dac(s);
1677 dealloc_dmabuf(s, &s->dma_dac); 1679 dealloc_dmabuf(s, &s->dma_dac);
@@ -1681,7 +1683,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
1681 dealloc_dmabuf(s, &s->dma_adc); 1683 dealloc_dmabuf(s, &s->dma_adc);
1682 } 1684 }
1683 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 1685 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
1684 up(&s->open_sem); 1686 mutex_unlock(&s->open_mutex);
1685 wake_up(&s->open_wait); 1687 wake_up(&s->open_wait);
1686 unlock_kernel(); 1688 unlock_kernel();
1687 return 0; 1689 return 0;
@@ -1867,7 +1869,7 @@ static int __devinit vrc5477_ac97_probe(struct pci_dev *pcidev,
1867 init_waitqueue_head(&s->dma_adc.wait); 1869 init_waitqueue_head(&s->dma_adc.wait);
1868 init_waitqueue_head(&s->dma_dac.wait); 1870 init_waitqueue_head(&s->dma_dac.wait);
1869 init_waitqueue_head(&s->open_wait); 1871 init_waitqueue_head(&s->open_wait);
1870 init_MUTEX(&s->open_sem); 1872 mutex_init(&s->open_mutex);
1871 spin_lock_init(&s->lock); 1873 spin_lock_init(&s->lock);
1872 1874
1873 s->dev = pcidev; 1875 s->dev = pcidev;
diff --git a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
index faa0b7919b65..a1ec9d131ab3 100644
--- a/sound/oss/rme96xx.c
+++ b/sound/oss/rme96xx.c
@@ -58,6 +58,7 @@ TODO:
58#include <linux/interrupt.h> 58#include <linux/interrupt.h>
59#include <linux/poll.h> 59#include <linux/poll.h>
60#include <linux/wait.h> 60#include <linux/wait.h>
61#include <linux/mutex.h>
61 62
62#include <asm/dma.h> 63#include <asm/dma.h>
63#include <asm/page.h> 64#include <asm/page.h>
@@ -326,7 +327,7 @@ typedef struct _rme96xx_info {
326 327
327 /* waiting and locking */ 328 /* waiting and locking */
328 wait_queue_head_t wait; 329 wait_queue_head_t wait;
329 struct semaphore open_sem; 330 struct mutex open_mutex;
330 wait_queue_head_t open_wait; 331 wait_queue_head_t open_wait;
331 332
332 } dma[RME96xx_MAX_DEVS]; 333 } dma[RME96xx_MAX_DEVS];
@@ -842,7 +843,7 @@ static void busmaster_free(void* ptr,int size) {
842 843
843static int rme96xx_dmabuf_init(rme96xx_info * s,struct dmabuf* dma,int ioffset,int ooffset) { 844static int rme96xx_dmabuf_init(rme96xx_info * s,struct dmabuf* dma,int ioffset,int ooffset) {
844 845
845 init_MUTEX(&dma->open_sem); 846 mutex_init(&dma->open_mutex);
846 init_waitqueue_head(&dma->open_wait); 847 init_waitqueue_head(&dma->open_wait);
847 init_waitqueue_head(&dma->wait); 848 init_waitqueue_head(&dma->wait);
848 dma->s = s; 849 dma->s = s;
@@ -1469,21 +1470,21 @@ static int rme96xx_open(struct inode *in, struct file *f)
1469 dma = &s->dma[devnum]; 1470 dma = &s->dma[devnum];
1470 f->private_data = dma; 1471 f->private_data = dma;
1471 /* wait for device to become free */ 1472 /* wait for device to become free */
1472 down(&dma->open_sem); 1473 mutex_lock(&dma->open_mutex);
1473 while (dma->open_mode & f->f_mode) { 1474 while (dma->open_mode & f->f_mode) {
1474 if (f->f_flags & O_NONBLOCK) { 1475 if (f->f_flags & O_NONBLOCK) {
1475 up(&dma->open_sem); 1476 mutex_unlock(&dma->open_mutex);
1476 return -EBUSY; 1477 return -EBUSY;
1477 } 1478 }
1478 add_wait_queue(&dma->open_wait, &wait); 1479 add_wait_queue(&dma->open_wait, &wait);
1479 __set_current_state(TASK_INTERRUPTIBLE); 1480 __set_current_state(TASK_INTERRUPTIBLE);
1480 up(&dma->open_sem); 1481 mutex_unlock(&dma->open_mutex);
1481 schedule(); 1482 schedule();
1482 remove_wait_queue(&dma->open_wait, &wait); 1483 remove_wait_queue(&dma->open_wait, &wait);
1483 set_current_state(TASK_RUNNING); 1484 set_current_state(TASK_RUNNING);
1484 if (signal_pending(current)) 1485 if (signal_pending(current))
1485 return -ERESTARTSYS; 1486 return -ERESTARTSYS;
1486 down(&dma->open_sem); 1487 mutex_lock(&dma->open_mutex);
1487 } 1488 }
1488 1489
1489 COMM ("hardware open") 1490 COMM ("hardware open")
@@ -1492,7 +1493,7 @@ static int rme96xx_open(struct inode *in, struct file *f)
1492 1493
1493 dma->open_mode |= (f->f_mode & (FMODE_READ | FMODE_WRITE)); 1494 dma->open_mode |= (f->f_mode & (FMODE_READ | FMODE_WRITE));
1494 dma->opened = 1; 1495 dma->opened = 1;
1495 up(&dma->open_sem); 1496 mutex_unlock(&dma->open_mutex);
1496 1497
1497 DBG(printk("device num %d open finished\n",devnum)); 1498 DBG(printk("device num %d open finished\n",devnum));
1498 return 0; 1499 return 0;
@@ -1524,7 +1525,7 @@ static int rme96xx_release(struct inode *in, struct file *file)
1524 } 1525 }
1525 1526
1526 wake_up(&dma->open_wait); 1527 wake_up(&dma->open_wait);
1527 up(&dma->open_sem); 1528 mutex_unlock(&dma->open_mutex);
1528 1529
1529 return 0; 1530 return 0;
1530} 1531}
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index 71b05e2f6977..69a4b8778b51 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -116,6 +116,8 @@
116#include <linux/spinlock.h> 116#include <linux/spinlock.h>
117#include <linux/smp_lock.h> 117#include <linux/smp_lock.h>
118#include <linux/gameport.h> 118#include <linux/gameport.h>
119#include <linux/mutex.h>
120
119 121
120#include <asm/io.h> 122#include <asm/io.h>
121#include <asm/uaccess.h> 123#include <asm/uaccess.h>
@@ -328,7 +330,7 @@ struct sv_state {
328 unsigned char fmt, enable; 330 unsigned char fmt, enable;
329 331
330 spinlock_t lock; 332 spinlock_t lock;
331 struct semaphore open_sem; 333 struct mutex open_mutex;
332 mode_t open_mode; 334 mode_t open_mode;
333 wait_queue_head_t open_wait; 335 wait_queue_head_t open_wait;
334 336
@@ -1922,21 +1924,21 @@ static int sv_open(struct inode *inode, struct file *file)
1922 VALIDATE_STATE(s); 1924 VALIDATE_STATE(s);
1923 file->private_data = s; 1925 file->private_data = s;
1924 /* wait for device to become free */ 1926 /* wait for device to become free */
1925 down(&s->open_sem); 1927 mutex_lock(&s->open_mutex);
1926 while (s->open_mode & file->f_mode) { 1928 while (s->open_mode & file->f_mode) {
1927 if (file->f_flags & O_NONBLOCK) { 1929 if (file->f_flags & O_NONBLOCK) {
1928 up(&s->open_sem); 1930 mutex_unlock(&s->open_mutex);
1929 return -EBUSY; 1931 return -EBUSY;
1930 } 1932 }
1931 add_wait_queue(&s->open_wait, &wait); 1933 add_wait_queue(&s->open_wait, &wait);
1932 __set_current_state(TASK_INTERRUPTIBLE); 1934 __set_current_state(TASK_INTERRUPTIBLE);
1933 up(&s->open_sem); 1935 mutex_unlock(&s->open_mutex);
1934 schedule(); 1936 schedule();
1935 remove_wait_queue(&s->open_wait, &wait); 1937 remove_wait_queue(&s->open_wait, &wait);
1936 set_current_state(TASK_RUNNING); 1938 set_current_state(TASK_RUNNING);
1937 if (signal_pending(current)) 1939 if (signal_pending(current))
1938 return -ERESTARTSYS; 1940 return -ERESTARTSYS;
1939 down(&s->open_sem); 1941 mutex_lock(&s->open_mutex);
1940 } 1942 }
1941 if (file->f_mode & FMODE_READ) { 1943 if (file->f_mode & FMODE_READ) {
1942 fmtm &= ~((SV_CFMT_STEREO | SV_CFMT_16BIT) << SV_CFMT_CSHIFT); 1944 fmtm &= ~((SV_CFMT_STEREO | SV_CFMT_16BIT) << SV_CFMT_CSHIFT);
@@ -1956,7 +1958,7 @@ static int sv_open(struct inode *inode, struct file *file)
1956 } 1958 }
1957 set_fmt(s, fmtm, fmts); 1959 set_fmt(s, fmtm, fmts);
1958 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1960 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1959 up(&s->open_sem); 1961 mutex_unlock(&s->open_mutex);
1960 return nonseekable_open(inode, file); 1962 return nonseekable_open(inode, file);
1961} 1963}
1962 1964
@@ -1968,7 +1970,7 @@ static int sv_release(struct inode *inode, struct file *file)
1968 lock_kernel(); 1970 lock_kernel();
1969 if (file->f_mode & FMODE_WRITE) 1971 if (file->f_mode & FMODE_WRITE)
1970 drain_dac(s, file->f_flags & O_NONBLOCK); 1972 drain_dac(s, file->f_flags & O_NONBLOCK);
1971 down(&s->open_sem); 1973 mutex_lock(&s->open_mutex);
1972 if (file->f_mode & FMODE_WRITE) { 1974 if (file->f_mode & FMODE_WRITE) {
1973 stop_dac(s); 1975 stop_dac(s);
1974 dealloc_dmabuf(s, &s->dma_dac); 1976 dealloc_dmabuf(s, &s->dma_dac);
@@ -1979,7 +1981,7 @@ static int sv_release(struct inode *inode, struct file *file)
1979 } 1981 }
1980 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 1982 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
1981 wake_up(&s->open_wait); 1983 wake_up(&s->open_wait);
1982 up(&s->open_sem); 1984 mutex_unlock(&s->open_mutex);
1983 unlock_kernel(); 1985 unlock_kernel();
1984 return 0; 1986 return 0;
1985} 1987}
@@ -2167,21 +2169,21 @@ static int sv_midi_open(struct inode *inode, struct file *file)
2167 VALIDATE_STATE(s); 2169 VALIDATE_STATE(s);
2168 file->private_data = s; 2170 file->private_data = s;
2169 /* wait for device to become free */ 2171 /* wait for device to become free */
2170 down(&s->open_sem); 2172 mutex_lock(&s->open_mutex);
2171 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 2173 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
2172 if (file->f_flags & O_NONBLOCK) { 2174 if (file->f_flags & O_NONBLOCK) {
2173 up(&s->open_sem); 2175 mutex_unlock(&s->open_mutex);
2174 return -EBUSY; 2176 return -EBUSY;
2175 } 2177 }
2176 add_wait_queue(&s->open_wait, &wait); 2178 add_wait_queue(&s->open_wait, &wait);
2177 __set_current_state(TASK_INTERRUPTIBLE); 2179 __set_current_state(TASK_INTERRUPTIBLE);
2178 up(&s->open_sem); 2180 mutex_unlock(&s->open_mutex);
2179 schedule(); 2181 schedule();
2180 remove_wait_queue(&s->open_wait, &wait); 2182 remove_wait_queue(&s->open_wait, &wait);
2181 set_current_state(TASK_RUNNING); 2183 set_current_state(TASK_RUNNING);
2182 if (signal_pending(current)) 2184 if (signal_pending(current))
2183 return -ERESTARTSYS; 2185 return -ERESTARTSYS;
2184 down(&s->open_sem); 2186 mutex_lock(&s->open_mutex);
2185 } 2187 }
2186 spin_lock_irqsave(&s->lock, flags); 2188 spin_lock_irqsave(&s->lock, flags);
2187 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2189 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2210,7 +2212,7 @@ static int sv_midi_open(struct inode *inode, struct file *file)
2210 } 2212 }
2211 spin_unlock_irqrestore(&s->lock, flags); 2213 spin_unlock_irqrestore(&s->lock, flags);
2212 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 2214 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
2213 up(&s->open_sem); 2215 mutex_unlock(&s->open_mutex);
2214 return nonseekable_open(inode, file); 2216 return nonseekable_open(inode, file);
2215} 2217}
2216 2218
@@ -2248,7 +2250,7 @@ static int sv_midi_release(struct inode *inode, struct file *file)
2248 remove_wait_queue(&s->midi.owait, &wait); 2250 remove_wait_queue(&s->midi.owait, &wait);
2249 set_current_state(TASK_RUNNING); 2251 set_current_state(TASK_RUNNING);
2250 } 2252 }
2251 down(&s->open_sem); 2253 mutex_lock(&s->open_mutex);
2252 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 2254 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
2253 spin_lock_irqsave(&s->lock, flags); 2255 spin_lock_irqsave(&s->lock, flags);
2254 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2256 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2257,7 +2259,7 @@ static int sv_midi_release(struct inode *inode, struct file *file)
2257 } 2259 }
2258 spin_unlock_irqrestore(&s->lock, flags); 2260 spin_unlock_irqrestore(&s->lock, flags);
2259 wake_up(&s->open_wait); 2261 wake_up(&s->open_wait);
2260 up(&s->open_sem); 2262 mutex_unlock(&s->open_mutex);
2261 unlock_kernel(); 2263 unlock_kernel();
2262 return 0; 2264 return 0;
2263} 2265}
@@ -2388,21 +2390,21 @@ static int sv_dmfm_open(struct inode *inode, struct file *file)
2388 VALIDATE_STATE(s); 2390 VALIDATE_STATE(s);
2389 file->private_data = s; 2391 file->private_data = s;
2390 /* wait for device to become free */ 2392 /* wait for device to become free */
2391 down(&s->open_sem); 2393 mutex_lock(&s->open_mutex);
2392 while (s->open_mode & FMODE_DMFM) { 2394 while (s->open_mode & FMODE_DMFM) {
2393 if (file->f_flags & O_NONBLOCK) { 2395 if (file->f_flags & O_NONBLOCK) {
2394 up(&s->open_sem); 2396 mutex_unlock(&s->open_mutex);
2395 return -EBUSY; 2397 return -EBUSY;
2396 } 2398 }
2397 add_wait_queue(&s->open_wait, &wait); 2399 add_wait_queue(&s->open_wait, &wait);
2398 __set_current_state(TASK_INTERRUPTIBLE); 2400 __set_current_state(TASK_INTERRUPTIBLE);
2399 up(&s->open_sem); 2401 mutex_unlock(&s->open_mutex);
2400 schedule(); 2402 schedule();
2401 remove_wait_queue(&s->open_wait, &wait); 2403 remove_wait_queue(&s->open_wait, &wait);
2402 set_current_state(TASK_RUNNING); 2404 set_current_state(TASK_RUNNING);
2403 if (signal_pending(current)) 2405 if (signal_pending(current))
2404 return -ERESTARTSYS; 2406 return -ERESTARTSYS;
2405 down(&s->open_sem); 2407 mutex_lock(&s->open_mutex);
2406 } 2408 }
2407 /* init the stuff */ 2409 /* init the stuff */
2408 outb(1, s->iosynth); 2410 outb(1, s->iosynth);
@@ -2412,7 +2414,7 @@ static int sv_dmfm_open(struct inode *inode, struct file *file)
2412 outb(5, s->iosynth+2); 2414 outb(5, s->iosynth+2);
2413 outb(1, s->iosynth+3); /* enable OPL3 */ 2415 outb(1, s->iosynth+3); /* enable OPL3 */
2414 s->open_mode |= FMODE_DMFM; 2416 s->open_mode |= FMODE_DMFM;
2415 up(&s->open_sem); 2417 mutex_unlock(&s->open_mutex);
2416 return nonseekable_open(inode, file); 2418 return nonseekable_open(inode, file);
2417} 2419}
2418 2420
@@ -2423,7 +2425,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file)
2423 2425
2424 VALIDATE_STATE(s); 2426 VALIDATE_STATE(s);
2425 lock_kernel(); 2427 lock_kernel();
2426 down(&s->open_sem); 2428 mutex_lock(&s->open_mutex);
2427 s->open_mode &= ~FMODE_DMFM; 2429 s->open_mode &= ~FMODE_DMFM;
2428 for (regb = 0xb0; regb < 0xb9; regb++) { 2430 for (regb = 0xb0; regb < 0xb9; regb++) {
2429 outb(regb, s->iosynth); 2431 outb(regb, s->iosynth);
@@ -2432,7 +2434,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file)
2432 outb(0, s->iosynth+3); 2434 outb(0, s->iosynth+3);
2433 } 2435 }
2434 wake_up(&s->open_wait); 2436 wake_up(&s->open_wait);
2435 up(&s->open_sem); 2437 mutex_unlock(&s->open_mutex);
2436 unlock_kernel(); 2438 unlock_kernel();
2437 return 0; 2439 return 0;
2438} 2440}
@@ -2582,7 +2584,7 @@ static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id
2582 init_waitqueue_head(&s->open_wait); 2584 init_waitqueue_head(&s->open_wait);
2583 init_waitqueue_head(&s->midi.iwait); 2585 init_waitqueue_head(&s->midi.iwait);
2584 init_waitqueue_head(&s->midi.owait); 2586 init_waitqueue_head(&s->midi.owait);
2585 init_MUTEX(&s->open_sem); 2587 mutex_init(&s->open_mutex);
2586 spin_lock_init(&s->lock); 2588 spin_lock_init(&s->lock);
2587 s->magic = SV_MAGIC; 2589 s->magic = SV_MAGIC;
2588 s->dev = pcidev; 2590 s->dev = pcidev;
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index df4d3771fa84..dce9016cbcfd 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -76,6 +76,7 @@
76#include <linux/init.h> 76#include <linux/init.h>
77#include <linux/poll.h> 77#include <linux/poll.h>
78#include <linux/smp_lock.h> 78#include <linux/smp_lock.h>
79#include <linux/mutex.h>
79 80
80#include <asm/byteorder.h> 81#include <asm/byteorder.h>
81#include <asm/dma.h> 82#include <asm/dma.h>
@@ -291,9 +292,9 @@ struct cs4297a_state {
291 unsigned conversion:1; // conversion from 16 to 8 bit in progress 292 unsigned conversion:1; // conversion from 16 to 8 bit in progress
292 unsigned ena; 293 unsigned ena;
293 spinlock_t lock; 294 spinlock_t lock;
294 struct semaphore open_sem; 295 struct mutex open_mutex;
295 struct semaphore open_sem_adc; 296 struct mutex open_sem_adc;
296 struct semaphore open_sem_dac; 297 struct mutex open_sem_dac;
297 mode_t open_mode; 298 mode_t open_mode;
298 wait_queue_head_t open_wait; 299 wait_queue_head_t open_wait;
299 wait_queue_head_t open_wait_adc; 300 wait_queue_head_t open_wait_adc;
@@ -2352,20 +2353,20 @@ static int cs4297a_release(struct inode *inode, struct file *file)
2352 2353
2353 if (file->f_mode & FMODE_WRITE) { 2354 if (file->f_mode & FMODE_WRITE) {
2354 drain_dac(s, file->f_flags & O_NONBLOCK); 2355 drain_dac(s, file->f_flags & O_NONBLOCK);
2355 down(&s->open_sem_dac); 2356 mutex_lock(&s->open_sem_dac);
2356 stop_dac(s); 2357 stop_dac(s);
2357 dealloc_dmabuf(s, &s->dma_dac); 2358 dealloc_dmabuf(s, &s->dma_dac);
2358 s->open_mode &= ~FMODE_WRITE; 2359 s->open_mode &= ~FMODE_WRITE;
2359 up(&s->open_sem_dac); 2360 mutex_unlock(&s->open_sem_dac);
2360 wake_up(&s->open_wait_dac); 2361 wake_up(&s->open_wait_dac);
2361 } 2362 }
2362 if (file->f_mode & FMODE_READ) { 2363 if (file->f_mode & FMODE_READ) {
2363 drain_adc(s, file->f_flags & O_NONBLOCK); 2364 drain_adc(s, file->f_flags & O_NONBLOCK);
2364 down(&s->open_sem_adc); 2365 mutex_lock(&s->open_sem_adc);
2365 stop_adc(s); 2366 stop_adc(s);
2366 dealloc_dmabuf(s, &s->dma_adc); 2367 dealloc_dmabuf(s, &s->dma_adc);
2367 s->open_mode &= ~FMODE_READ; 2368 s->open_mode &= ~FMODE_READ;
2368 up(&s->open_sem_adc); 2369 mutex_unlock(&s->open_sem_adc);
2369 wake_up(&s->open_wait_adc); 2370 wake_up(&s->open_wait_adc);
2370 } 2371 }
2371 return 0; 2372 return 0;
@@ -2413,37 +2414,37 @@ static int cs4297a_open(struct inode *inode, struct file *file)
2413 ; 2414 ;
2414 } 2415 }
2415 2416
2416 down(&s->open_sem_dac); 2417 mutex_lock(&s->open_sem_dac);
2417 while (s->open_mode & FMODE_WRITE) { 2418 while (s->open_mode & FMODE_WRITE) {
2418 if (file->f_flags & O_NONBLOCK) { 2419 if (file->f_flags & O_NONBLOCK) {
2419 up(&s->open_sem_dac); 2420 mutex_unlock(&s->open_sem_dac);
2420 return -EBUSY; 2421 return -EBUSY;
2421 } 2422 }
2422 up(&s->open_sem_dac); 2423 mutex_unlock(&s->open_sem_dac);
2423 interruptible_sleep_on(&s->open_wait_dac); 2424 interruptible_sleep_on(&s->open_wait_dac);
2424 2425
2425 if (signal_pending(current)) { 2426 if (signal_pending(current)) {
2426 printk("open - sig pending\n"); 2427 printk("open - sig pending\n");
2427 return -ERESTARTSYS; 2428 return -ERESTARTSYS;
2428 } 2429 }
2429 down(&s->open_sem_dac); 2430 mutex_lock(&s->open_sem_dac);
2430 } 2431 }
2431 } 2432 }
2432 if (file->f_mode & FMODE_READ) { 2433 if (file->f_mode & FMODE_READ) {
2433 down(&s->open_sem_adc); 2434 mutex_lock(&s->open_sem_adc);
2434 while (s->open_mode & FMODE_READ) { 2435 while (s->open_mode & FMODE_READ) {
2435 if (file->f_flags & O_NONBLOCK) { 2436 if (file->f_flags & O_NONBLOCK) {
2436 up(&s->open_sem_adc); 2437 mutex_unlock(&s->open_sem_adc);
2437 return -EBUSY; 2438 return -EBUSY;
2438 } 2439 }
2439 up(&s->open_sem_adc); 2440 mutex_unlock(&s->open_sem_adc);
2440 interruptible_sleep_on(&s->open_wait_adc); 2441 interruptible_sleep_on(&s->open_wait_adc);
2441 2442
2442 if (signal_pending(current)) { 2443 if (signal_pending(current)) {
2443 printk("open - sig pending\n"); 2444 printk("open - sig pending\n");
2444 return -ERESTARTSYS; 2445 return -ERESTARTSYS;
2445 } 2446 }
2446 down(&s->open_sem_adc); 2447 mutex_lock(&s->open_sem_adc);
2447 } 2448 }
2448 } 2449 }
2449 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2450 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
@@ -2456,7 +2457,7 @@ static int cs4297a_open(struct inode *inode, struct file *file)
2456 s->ena &= ~FMODE_READ; 2457 s->ena &= ~FMODE_READ;
2457 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = 2458 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
2458 s->dma_adc.subdivision = 0; 2459 s->dma_adc.subdivision = 0;
2459 up(&s->open_sem_adc); 2460 mutex_unlock(&s->open_sem_adc);
2460 2461
2461 if (prog_dmabuf_adc(s)) { 2462 if (prog_dmabuf_adc(s)) {
2462 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR 2463 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -2474,7 +2475,7 @@ static int cs4297a_open(struct inode *inode, struct file *file)
2474 s->ena &= ~FMODE_WRITE; 2475 s->ena &= ~FMODE_WRITE;
2475 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = 2476 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
2476 s->dma_dac.subdivision = 0; 2477 s->dma_dac.subdivision = 0;
2477 up(&s->open_sem_dac); 2478 mutex_unlock(&s->open_sem_dac);
2478 2479
2479 if (prog_dmabuf_dac(s)) { 2480 if (prog_dmabuf_dac(s)) {
2480 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR 2481 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -2631,8 +2632,8 @@ static int __init cs4297a_init(void)
2631 init_waitqueue_head(&s->open_wait); 2632 init_waitqueue_head(&s->open_wait);
2632 init_waitqueue_head(&s->open_wait_adc); 2633 init_waitqueue_head(&s->open_wait_adc);
2633 init_waitqueue_head(&s->open_wait_dac); 2634 init_waitqueue_head(&s->open_wait_dac);
2634 init_MUTEX(&s->open_sem_adc); 2635 mutex_init(&s->open_sem_adc);
2635 init_MUTEX(&s->open_sem_dac); 2636 mutex_init(&s->open_sem_dac);
2636 spin_lock_init(&s->lock); 2637 spin_lock_init(&s->lock);
2637 2638
2638 s->irq = K_INT_SER_1; 2639 s->irq = K_INT_SER_1;
diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index a21c663e7e12..e61a454a8150 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -190,7 +190,7 @@
190 * 190 *
191 * Lock order (high->low) 191 * Lock order (high->low)
192 * lock - hardware lock 192 * lock - hardware lock
193 * open_sem - guard opens 193 * open_mutex - guard opens
194 * sem - guard dmabuf, write re-entry etc 194 * sem - guard dmabuf, write re-entry etc
195 */ 195 */
196 196
@@ -216,6 +216,8 @@
216#include <linux/pm.h> 216#include <linux/pm.h>
217#include <linux/gameport.h> 217#include <linux/gameport.h>
218#include <linux/kernel.h> 218#include <linux/kernel.h>
219#include <linux/mutex.h>
220
219#include <asm/uaccess.h> 221#include <asm/uaccess.h>
220#include <asm/io.h> 222#include <asm/io.h>
221#include <asm/dma.h> 223#include <asm/dma.h>
@@ -349,7 +351,7 @@ struct trident_state {
349 unsigned chans_num; 351 unsigned chans_num;
350 unsigned long fmt_flag; 352 unsigned long fmt_flag;
351 /* Guard against mmap/write/read races */ 353 /* Guard against mmap/write/read races */
352 struct semaphore sem; 354 struct mutex sem;
353 355
354}; 356};
355 357
@@ -402,7 +404,7 @@ struct trident_card {
402 struct trident_card *next; 404 struct trident_card *next;
403 405
404 /* single open lock mechanism, only used for recording */ 406 /* single open lock mechanism, only used for recording */
405 struct semaphore open_sem; 407 struct mutex open_mutex;
406 408
407 /* The trident has a certain amount of cross channel interaction 409 /* The trident has a certain amount of cross channel interaction
408 so we use a single per card lock */ 410 so we use a single per card lock */
@@ -1881,7 +1883,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1881 if (!access_ok(VERIFY_WRITE, buffer, count)) 1883 if (!access_ok(VERIFY_WRITE, buffer, count))
1882 return -EFAULT; 1884 return -EFAULT;
1883 1885
1884 down(&state->sem); 1886 mutex_lock(&state->sem);
1885 if (!dmabuf->ready && (ret = prog_dmabuf_record(state))) 1887 if (!dmabuf->ready && (ret = prog_dmabuf_record(state)))
1886 goto out; 1888 goto out;
1887 1889
@@ -1913,7 +1915,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1913 goto out; 1915 goto out;
1914 } 1916 }
1915 1917
1916 up(&state->sem); 1918 mutex_unlock(&state->sem);
1917 /* No matter how much space left in the buffer, */ 1919 /* No matter how much space left in the buffer, */
1918 /* we have to wait until CSO == ESO/2 or CSO == ESO */ 1920 /* we have to wait until CSO == ESO/2 or CSO == ESO */
1919 /* when address engine interrupts */ 1921 /* when address engine interrupts */
@@ -1940,7 +1942,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1940 ret = -ERESTARTSYS; 1942 ret = -ERESTARTSYS;
1941 goto out; 1943 goto out;
1942 } 1944 }
1943 down(&state->sem); 1945 mutex_lock(&state->sem);
1944 if (dmabuf->mapped) { 1946 if (dmabuf->mapped) {
1945 if (!ret) 1947 if (!ret)
1946 ret = -ENXIO; 1948 ret = -ENXIO;
@@ -1968,7 +1970,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1968 start_adc(state); 1970 start_adc(state);
1969 } 1971 }
1970out: 1972out:
1971 up(&state->sem); 1973 mutex_unlock(&state->sem);
1972 return ret; 1974 return ret;
1973} 1975}
1974 1976
@@ -1996,7 +1998,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
1996 * Guard against an mmap or ioctl while writing 1998 * Guard against an mmap or ioctl while writing
1997 */ 1999 */
1998 2000
1999 down(&state->sem); 2001 mutex_lock(&state->sem);
2000 2002
2001 if (dmabuf->mapped) { 2003 if (dmabuf->mapped) {
2002 ret = -ENXIO; 2004 ret = -ENXIO;
@@ -2045,7 +2047,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2045 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2); 2047 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
2046 tmo >>= sample_shift[dmabuf->fmt]; 2048 tmo >>= sample_shift[dmabuf->fmt];
2047 unlock_set_fmt(state); 2049 unlock_set_fmt(state);
2048 up(&state->sem); 2050 mutex_unlock(&state->sem);
2049 2051
2050 /* There are two situations when sleep_on_timeout */ 2052 /* There are two situations when sleep_on_timeout */
2051 /* returns, one is when the interrupt is serviced */ 2053 /* returns, one is when the interrupt is serviced */
@@ -2073,7 +2075,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2073 ret = -ERESTARTSYS; 2075 ret = -ERESTARTSYS;
2074 goto out_nolock; 2076 goto out_nolock;
2075 } 2077 }
2076 down(&state->sem); 2078 mutex_lock(&state->sem);
2077 if (dmabuf->mapped) { 2079 if (dmabuf->mapped) {
2078 if (!ret) 2080 if (!ret)
2079 ret = -ENXIO; 2081 ret = -ENXIO;
@@ -2131,7 +2133,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2131 start_dac(state); 2133 start_dac(state);
2132 } 2134 }
2133out: 2135out:
2134 up(&state->sem); 2136 mutex_unlock(&state->sem);
2135out_nolock: 2137out_nolock:
2136 return ret; 2138 return ret;
2137} 2139}
@@ -2152,24 +2154,24 @@ trident_poll(struct file *file, struct poll_table_struct *wait)
2152 * prog_dmabuf events 2154 * prog_dmabuf events
2153 */ 2155 */
2154 2156
2155 down(&state->sem); 2157 mutex_lock(&state->sem);
2156 2158
2157 if (file->f_mode & FMODE_WRITE) { 2159 if (file->f_mode & FMODE_WRITE) {
2158 if (!dmabuf->ready && prog_dmabuf_playback(state)) { 2160 if (!dmabuf->ready && prog_dmabuf_playback(state)) {
2159 up(&state->sem); 2161 mutex_unlock(&state->sem);
2160 return 0; 2162 return 0;
2161 } 2163 }
2162 poll_wait(file, &dmabuf->wait, wait); 2164 poll_wait(file, &dmabuf->wait, wait);
2163 } 2165 }
2164 if (file->f_mode & FMODE_READ) { 2166 if (file->f_mode & FMODE_READ) {
2165 if (!dmabuf->ready && prog_dmabuf_record(state)) { 2167 if (!dmabuf->ready && prog_dmabuf_record(state)) {
2166 up(&state->sem); 2168 mutex_unlock(&state->sem);
2167 return 0; 2169 return 0;
2168 } 2170 }
2169 poll_wait(file, &dmabuf->wait, wait); 2171 poll_wait(file, &dmabuf->wait, wait);
2170 } 2172 }
2171 2173
2172 up(&state->sem); 2174 mutex_unlock(&state->sem);
2173 2175
2174 spin_lock_irqsave(&state->card->lock, flags); 2176 spin_lock_irqsave(&state->card->lock, flags);
2175 trident_update_ptr(state); 2177 trident_update_ptr(state);
@@ -2207,7 +2209,7 @@ trident_mmap(struct file *file, struct vm_area_struct *vma)
2207 * a read or write against an mmap. 2209 * a read or write against an mmap.
2208 */ 2210 */
2209 2211
2210 down(&state->sem); 2212 mutex_lock(&state->sem);
2211 2213
2212 if (vma->vm_flags & VM_WRITE) { 2214 if (vma->vm_flags & VM_WRITE) {
2213 if ((ret = prog_dmabuf_playback(state)) != 0) 2215 if ((ret = prog_dmabuf_playback(state)) != 0)
@@ -2232,7 +2234,7 @@ trident_mmap(struct file *file, struct vm_area_struct *vma)
2232 dmabuf->mapped = 1; 2234 dmabuf->mapped = 1;
2233 ret = 0; 2235 ret = 0;
2234out: 2236out:
2235 up(&state->sem); 2237 mutex_unlock(&state->sem);
2236 return ret; 2238 return ret;
2237} 2239}
2238 2240
@@ -2429,15 +2431,15 @@ trident_ioctl(struct inode *inode, struct file *file,
2429 unlock_set_fmt(state); 2431 unlock_set_fmt(state);
2430 break; 2432 break;
2431 } 2433 }
2432 down(&state->card->open_sem); 2434 mutex_lock(&state->card->open_mutex);
2433 ret = ali_allocate_other_states_resources(state, 6); 2435 ret = ali_allocate_other_states_resources(state, 6);
2434 if (ret < 0) { 2436 if (ret < 0) {
2435 up(&state->card->open_sem); 2437 mutex_unlock(&state->card->open_mutex);
2436 unlock_set_fmt(state); 2438 unlock_set_fmt(state);
2437 break; 2439 break;
2438 } 2440 }
2439 state->card->multi_channel_use_count++; 2441 state->card->multi_channel_use_count++;
2440 up(&state->card->open_sem); 2442 mutex_unlock(&state->card->open_mutex);
2441 } else 2443 } else
2442 val = 2; /*yield to 2-channels */ 2444 val = 2; /*yield to 2-channels */
2443 } else 2445 } else
@@ -2727,11 +2729,11 @@ trident_open(struct inode *inode, struct file *file)
2727 2729
2728 /* find an available virtual channel (instance of /dev/dsp) */ 2730 /* find an available virtual channel (instance of /dev/dsp) */
2729 while (card != NULL) { 2731 while (card != NULL) {
2730 down(&card->open_sem); 2732 mutex_lock(&card->open_mutex);
2731 if (file->f_mode & FMODE_READ) { 2733 if (file->f_mode & FMODE_READ) {
2732 /* Skip opens on cards that are in 6 channel mode */ 2734 /* Skip opens on cards that are in 6 channel mode */
2733 if (card->multi_channel_use_count > 0) { 2735 if (card->multi_channel_use_count > 0) {
2734 up(&card->open_sem); 2736 mutex_unlock(&card->open_mutex);
2735 card = card->next; 2737 card = card->next;
2736 continue; 2738 continue;
2737 } 2739 }
@@ -2740,16 +2742,16 @@ trident_open(struct inode *inode, struct file *file)
2740 if (card->states[i] == NULL) { 2742 if (card->states[i] == NULL) {
2741 state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL); 2743 state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
2742 if (state == NULL) { 2744 if (state == NULL) {
2743 up(&card->open_sem); 2745 mutex_unlock(&card->open_mutex);
2744 return -ENOMEM; 2746 return -ENOMEM;
2745 } 2747 }
2746 memset(state, 0, sizeof(*state)); 2748 memset(state, 0, sizeof(*state));
2747 init_MUTEX(&state->sem); 2749 mutex_init(&state->sem);
2748 dmabuf = &state->dmabuf; 2750 dmabuf = &state->dmabuf;
2749 goto found_virt; 2751 goto found_virt;
2750 } 2752 }
2751 } 2753 }
2752 up(&card->open_sem); 2754 mutex_unlock(&card->open_mutex);
2753 card = card->next; 2755 card = card->next;
2754 } 2756 }
2755 /* no more virtual channel avaiable */ 2757 /* no more virtual channel avaiable */
@@ -2816,7 +2818,7 @@ trident_open(struct inode *inode, struct file *file)
2816 } 2818 }
2817 2819
2818 state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2820 state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2819 up(&card->open_sem); 2821 mutex_unlock(&card->open_mutex);
2820 2822
2821 pr_debug("trident: open virtual channel %d, hard channel %d\n", 2823 pr_debug("trident: open virtual channel %d, hard channel %d\n",
2822 state->virt, dmabuf->channel->num); 2824 state->virt, dmabuf->channel->num);
@@ -2845,7 +2847,7 @@ trident_release(struct inode *inode, struct file *file)
2845 state->virt, dmabuf->channel->num); 2847 state->virt, dmabuf->channel->num);
2846 2848
2847 /* stop DMA state machine and free DMA buffers/channels */ 2849 /* stop DMA state machine and free DMA buffers/channels */
2848 down(&card->open_sem); 2850 mutex_lock(&card->open_mutex);
2849 2851
2850 if (file->f_mode & FMODE_WRITE) { 2852 if (file->f_mode & FMODE_WRITE) {
2851 stop_dac(state); 2853 stop_dac(state);
@@ -2878,8 +2880,8 @@ trident_release(struct inode *inode, struct file *file)
2878 card->states[state->virt] = NULL; 2880 card->states[state->virt] = NULL;
2879 kfree(state); 2881 kfree(state);
2880 2882
2881 /* we're covered by the open_sem */ 2883 /* we're covered by the open_mutex */
2882 up(&card->open_sem); 2884 mutex_unlock(&card->open_mutex);
2883 2885
2884 return 0; 2886 return 0;
2885} 2887}
@@ -4405,7 +4407,7 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4405 card->banks[BANK_B].addresses = &bank_b_addrs; 4407 card->banks[BANK_B].addresses = &bank_b_addrs;
4406 card->banks[BANK_B].bitmap = 0UL; 4408 card->banks[BANK_B].bitmap = 0UL;
4407 4409
4408 init_MUTEX(&card->open_sem); 4410 mutex_init(&card->open_mutex);
4409 spin_lock_init(&card->lock); 4411 spin_lock_init(&card->lock);
4410 init_timer(&card->timer); 4412 init_timer(&card->timer);
4411 4413
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
index 83edda93f0b4..1a921ee71aba 100644
--- a/sound/oss/via82cxxx_audio.c
+++ b/sound/oss/via82cxxx_audio.c
@@ -38,7 +38,8 @@
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <asm/semaphore.h> 41#include <linux/mutex.h>
42
42#include "sound_config.h" 43#include "sound_config.h"
43#include "dev_table.h" 44#include "dev_table.h"
44#include "mpu401.h" 45#include "mpu401.h"
@@ -311,8 +312,8 @@ struct via_info {
311 312
312 int mixer_vol; /* 8233/35 volume - not yet implemented */ 313 int mixer_vol; /* 8233/35 volume - not yet implemented */
313 314
314 struct semaphore syscall_sem; 315 struct mutex syscall_mutex;
315 struct semaphore open_sem; 316 struct mutex open_mutex;
316 317
317 /* The 8233/8235 have 4 DX audio channels, two record and 318 /* The 8233/8235 have 4 DX audio channels, two record and
318 one six channel out. We bind ch_in to DX 1, ch_out to multichannel 319 one six channel out. We bind ch_in to DX 1, ch_out to multichannel
@@ -505,10 +506,10 @@ static inline int via_syscall_down (struct via_info *card, int nonblock)
505 nonblock = 0; 506 nonblock = 0;
506 507
507 if (nonblock) { 508 if (nonblock) {
508 if (down_trylock (&card->syscall_sem)) 509 if (!mutex_trylock(&card->syscall_mutex))
509 return -EAGAIN; 510 return -EAGAIN;
510 } else { 511 } else {
511 if (down_interruptible (&card->syscall_sem)) 512 if (mutex_lock_interruptible(&card->syscall_mutex))
512 return -ERESTARTSYS; 513 return -ERESTARTSYS;
513 } 514 }
514 515
@@ -1609,7 +1610,7 @@ static int via_mixer_ioctl (struct inode *inode, struct file *file, unsigned int
1609#endif 1610#endif
1610 rc = codec->mixer_ioctl(codec, cmd, arg); 1611 rc = codec->mixer_ioctl(codec, cmd, arg);
1611 1612
1612 up (&card->syscall_sem); 1613 mutex_unlock(&card->syscall_mutex);
1613 1614
1614out: 1615out:
1615 DPRINTK ("EXIT, returning %d\n", rc); 1616 DPRINTK ("EXIT, returning %d\n", rc);
@@ -2228,7 +2229,7 @@ static int via_dsp_mmap(struct file *file, struct vm_area_struct *vma)
2228 if (wr) 2229 if (wr)
2229 card->ch_out.is_mapped = 1; 2230 card->ch_out.is_mapped = 1;
2230 2231
2231 up (&card->syscall_sem); 2232 mutex_unlock(&card->syscall_mutex);
2232 rc = 0; 2233 rc = 0;
2233 2234
2234out: 2235out:
@@ -2256,7 +2257,7 @@ handle_one_block:
2256 /* Thomas Sailer: 2257 /* Thomas Sailer:
2257 * But also to ourselves, release semaphore if we do so */ 2258 * But also to ourselves, release semaphore if we do so */
2258 if (need_resched()) { 2259 if (need_resched()) {
2259 up(&card->syscall_sem); 2260 mutex_unlock(&card->syscall_mutex);
2260 schedule (); 2261 schedule ();
2261 ret = via_syscall_down (card, nonblock); 2262 ret = via_syscall_down (card, nonblock);
2262 if (ret) 2263 if (ret)
@@ -2286,7 +2287,7 @@ handle_one_block:
2286 break; 2287 break;
2287 } 2288 }
2288 2289
2289 up(&card->syscall_sem); 2290 mutex_unlock(&card->syscall_mutex);
2290 2291
2291 DPRINTK ("Sleeping on block %d\n", n); 2292 DPRINTK ("Sleeping on block %d\n", n);
2292 schedule(); 2293 schedule();
@@ -2402,7 +2403,7 @@ static ssize_t via_dsp_read(struct file *file, char __user *buffer, size_t count
2402 rc = via_dsp_do_read (card, buffer, count, nonblock); 2403 rc = via_dsp_do_read (card, buffer, count, nonblock);
2403 2404
2404out_up: 2405out_up:
2405 up (&card->syscall_sem); 2406 mutex_unlock(&card->syscall_mutex);
2406out: 2407out:
2407 DPRINTK ("EXIT, returning %ld\n",(long) rc); 2408 DPRINTK ("EXIT, returning %ld\n",(long) rc);
2408 return rc; 2409 return rc;
@@ -2426,7 +2427,7 @@ handle_one_block:
2426 /* Thomas Sailer: 2427 /* Thomas Sailer:
2427 * But also to ourselves, release semaphore if we do so */ 2428 * But also to ourselves, release semaphore if we do so */
2428 if (need_resched()) { 2429 if (need_resched()) {
2429 up(&card->syscall_sem); 2430 mutex_unlock(&card->syscall_mutex);
2430 schedule (); 2431 schedule ();
2431 ret = via_syscall_down (card, nonblock); 2432 ret = via_syscall_down (card, nonblock);
2432 if (ret) 2433 if (ret)
@@ -2456,7 +2457,7 @@ handle_one_block:
2456 break; 2457 break;
2457 } 2458 }
2458 2459
2459 up(&card->syscall_sem); 2460 mutex_unlock(&card->syscall_mutex);
2460 2461
2461 DPRINTK ("Sleeping on page %d, tmp==%d, ir==%d\n", n, tmp, chan->is_record); 2462 DPRINTK ("Sleeping on page %d, tmp==%d, ir==%d\n", n, tmp, chan->is_record);
2462 schedule(); 2463 schedule();
@@ -2585,7 +2586,7 @@ static ssize_t via_dsp_write(struct file *file, const char __user *buffer, size_
2585 rc = via_dsp_do_write (card, buffer, count, nonblock); 2586 rc = via_dsp_do_write (card, buffer, count, nonblock);
2586 2587
2587out_up: 2588out_up:
2588 up (&card->syscall_sem); 2589 mutex_unlock(&card->syscall_mutex);
2589out: 2590out:
2590 DPRINTK ("EXIT, returning %ld\n",(long) rc); 2591 DPRINTK ("EXIT, returning %ld\n",(long) rc);
2591 return rc; 2592 return rc;
@@ -2634,7 +2635,7 @@ static unsigned int via_dsp_poll(struct file *file, struct poll_table_struct *wa
2634 * Sleeps until all playback has been flushed to the audio 2635 * Sleeps until all playback has been flushed to the audio
2635 * hardware. 2636 * hardware.
2636 * 2637 *
2637 * Locking: inside card->syscall_sem 2638 * Locking: inside card->syscall_mutex
2638 */ 2639 */
2639 2640
2640static int via_dsp_drain_playback (struct via_info *card, 2641static int via_dsp_drain_playback (struct via_info *card,
@@ -2692,7 +2693,7 @@ static int via_dsp_drain_playback (struct via_info *card,
2692 printk (KERN_ERR "sleeping but not active\n"); 2693 printk (KERN_ERR "sleeping but not active\n");
2693#endif 2694#endif
2694 2695
2695 up(&card->syscall_sem); 2696 mutex_unlock(&card->syscall_mutex);
2696 2697
2697 DPRINTK ("sleeping, nbufs=%d\n", atomic_read (&chan->n_frags)); 2698 DPRINTK ("sleeping, nbufs=%d\n", atomic_read (&chan->n_frags));
2698 schedule(); 2699 schedule();
@@ -2748,7 +2749,7 @@ out:
2748 * 2749 *
2749 * Handles SNDCTL_DSP_GETISPACE and SNDCTL_DSP_GETOSPACE. 2750 * Handles SNDCTL_DSP_GETISPACE and SNDCTL_DSP_GETOSPACE.
2750 * 2751 *
2751 * Locking: inside card->syscall_sem 2752 * Locking: inside card->syscall_mutex
2752 */ 2753 */
2753 2754
2754static int via_dsp_ioctl_space (struct via_info *card, 2755static int via_dsp_ioctl_space (struct via_info *card,
@@ -2793,7 +2794,7 @@ static int via_dsp_ioctl_space (struct via_info *card,
2793 * 2794 *
2794 * Handles SNDCTL_DSP_GETIPTR and SNDCTL_DSP_GETOPTR. 2795 * Handles SNDCTL_DSP_GETIPTR and SNDCTL_DSP_GETOPTR.
2795 * 2796 *
2796 * Locking: inside card->syscall_sem 2797 * Locking: inside card->syscall_mutex
2797 */ 2798 */
2798 2799
2799static int via_dsp_ioctl_ptr (struct via_info *card, 2800static int via_dsp_ioctl_ptr (struct via_info *card,
@@ -3221,7 +3222,7 @@ static int via_dsp_ioctl (struct inode *inode, struct file *file,
3221 break; 3222 break;
3222 } 3223 }
3223 3224
3224 up (&card->syscall_sem); 3225 mutex_unlock(&card->syscall_mutex);
3225 DPRINTK ("EXIT, returning %d\n", rc); 3226 DPRINTK ("EXIT, returning %d\n", rc);
3226 return rc; 3227 return rc;
3227} 3228}
@@ -3264,12 +3265,12 @@ static int via_dsp_open (struct inode *inode, struct file *file)
3264 3265
3265match: 3266match:
3266 if (nonblock) { 3267 if (nonblock) {
3267 if (down_trylock (&card->open_sem)) { 3268 if (!mutex_trylock(&card->open_mutex)) {
3268 DPRINTK ("EXIT, returning -EAGAIN\n"); 3269 DPRINTK ("EXIT, returning -EAGAIN\n");
3269 return -EAGAIN; 3270 return -EAGAIN;
3270 } 3271 }
3271 } else { 3272 } else {
3272 if (down_interruptible (&card->open_sem)) { 3273 if (mutex_lock_interruptible(&card->open_mutex)) {
3273 DPRINTK ("EXIT, returning -ERESTARTSYS\n"); 3274 DPRINTK ("EXIT, returning -ERESTARTSYS\n");
3274 return -ERESTARTSYS; 3275 return -ERESTARTSYS;
3275 } 3276 }
@@ -3355,8 +3356,8 @@ static int via_dsp_release(struct inode *inode, struct file *file)
3355 via_chan_buffer_free (card, &card->ch_in); 3356 via_chan_buffer_free (card, &card->ch_in);
3356 } 3357 }
3357 3358
3358 up (&card->syscall_sem); 3359 mutex_unlock(&card->syscall_mutex);
3359 up (&card->open_sem); 3360 mutex_unlock(&card->open_mutex);
3360 3361
3361 DPRINTK ("EXIT, returning 0\n"); 3362 DPRINTK ("EXIT, returning 0\n");
3362 return 0; 3363 return 0;
@@ -3414,8 +3415,8 @@ static int __devinit via_init_one (struct pci_dev *pdev, const struct pci_device
3414 card->card_num = via_num_cards++; 3415 card->card_num = via_num_cards++;
3415 spin_lock_init (&card->lock); 3416 spin_lock_init (&card->lock);
3416 spin_lock_init (&card->ac97_lock); 3417 spin_lock_init (&card->ac97_lock);
3417 init_MUTEX (&card->syscall_sem); 3418 mutex_init(&card->syscall_mutex);
3418 init_MUTEX (&card->open_sem); 3419 mutex_init(&card->open_mutex);
3419 3420
3420 /* we must init these now, in case the intr handler needs them */ 3421 /* we must init these now, in case the intr handler needs them */
3421 via_chan_init_defaults (card, &card->ch_out); 3422 via_chan_init_defaults (card, &card->ch_out);
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 265423054caf..b372e88e857f 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -94,7 +94,7 @@
94 * Open will block until the previous client has closed the 94 * Open will block until the previous client has closed the
95 * device, unless O_NONBLOCK is specified. 95 * device, unless O_NONBLOCK is specified.
96 * 96 *
97 * The semaphore devc->io_sema serializes PCM I/O syscalls. This 97 * The semaphore devc->io_mutex serializes PCM I/O syscalls. This
98 * is unnecessary in Linux 2.2, because the kernel lock 98 * is unnecessary in Linux 2.2, because the kernel lock
99 * serializes read, write, and ioctl globally, but it's there, 99 * serializes read, write, and ioctl globally, but it's there,
100 * ready for the brave, new post-kernel-lock world. 100 * ready for the brave, new post-kernel-lock world.
@@ -105,7 +105,7 @@
105 * area it owns and update its pointers. See pcm_output() and 105 * area it owns and update its pointers. See pcm_output() and
106 * pcm_input() for most of the gory stuff. 106 * pcm_input() for most of the gory stuff.
107 * 107 *
108 * devc->mix_sema serializes all mixer ioctls. This is also 108 * devc->mix_mutex serializes all mixer ioctls. This is also
109 * redundant because of the kernel lock. 109 * redundant because of the kernel lock.
110 * 110 *
111 * The lowest level lock is lith->lithium_lock. It is a 111 * The lowest level lock is lith->lithium_lock. It is a
@@ -148,7 +148,8 @@
148#include <linux/smp_lock.h> 148#include <linux/smp_lock.h>
149#include <linux/wait.h> 149#include <linux/wait.h>
150#include <linux/interrupt.h> 150#include <linux/interrupt.h>
151#include <asm/semaphore.h> 151#include <linux/mutex.h>
152
152#include <asm/mach-visws/cobalt.h> 153#include <asm/mach-visws/cobalt.h>
153 154
154#include "sound_config.h" 155#include "sound_config.h"
@@ -1447,11 +1448,11 @@ typedef enum vwsnd_port_flags {
1447 * 1448 *
1448 * port->lock protects: hwstate, flags, swb_[iu]_avail. 1449 * port->lock protects: hwstate, flags, swb_[iu]_avail.
1449 * 1450 *
1450 * devc->io_sema protects: swstate, sw_*, swb_[iu]_idx. 1451 * devc->io_mutex protects: swstate, sw_*, swb_[iu]_idx.
1451 * 1452 *
1452 * everything else is only written by open/release or 1453 * everything else is only written by open/release or
1453 * pcm_{setup,shutdown}(), which are serialized by a 1454 * pcm_{setup,shutdown}(), which are serialized by a
1454 * combination of devc->open_sema and devc->io_sema. 1455 * combination of devc->open_mutex and devc->io_mutex.
1455 */ 1456 */
1456 1457
1457typedef struct vwsnd_port { 1458typedef struct vwsnd_port {
@@ -1507,9 +1508,9 @@ typedef struct vwsnd_dev {
1507 int audio_minor; /* minor number of audio device */ 1508 int audio_minor; /* minor number of audio device */
1508 int mixer_minor; /* minor number of mixer device */ 1509 int mixer_minor; /* minor number of mixer device */
1509 1510
1510 struct semaphore open_sema; 1511 struct mutex open_mutex;
1511 struct semaphore io_sema; 1512 struct mutex io_mutex;
1512 struct semaphore mix_sema; 1513 struct mutex mix_mutex;
1513 mode_t open_mode; 1514 mode_t open_mode;
1514 wait_queue_head_t open_wait; 1515 wait_queue_head_t open_wait;
1515 1516
@@ -1633,7 +1634,7 @@ static __inline__ unsigned int swb_inc_i(vwsnd_port_t *port, int inc)
1633 * mode-setting ioctls have been done, but before the first I/O is 1634 * mode-setting ioctls have been done, but before the first I/O is
1634 * done. 1635 * done.
1635 * 1636 *
1636 * Locking: called with devc->io_sema held. 1637 * Locking: called with devc->io_mutex held.
1637 * 1638 *
1638 * Returns 0 on success, -errno on failure. 1639 * Returns 0 on success, -errno on failure.
1639 */ 1640 */
@@ -2319,9 +2320,9 @@ static ssize_t vwsnd_audio_read(struct file *file,
2319 vwsnd_dev_t *devc = file->private_data; 2320 vwsnd_dev_t *devc = file->private_data;
2320 ssize_t ret; 2321 ssize_t ret;
2321 2322
2322 down(&devc->io_sema); 2323 mutex_lock(&devc->io_mutex);
2323 ret = vwsnd_audio_do_read(file, buffer, count, ppos); 2324 ret = vwsnd_audio_do_read(file, buffer, count, ppos);
2324 up(&devc->io_sema); 2325 mutex_unlock(&devc->io_mutex);
2325 return ret; 2326 return ret;
2326} 2327}
2327 2328
@@ -2394,9 +2395,9 @@ static ssize_t vwsnd_audio_write(struct file *file,
2394 vwsnd_dev_t *devc = file->private_data; 2395 vwsnd_dev_t *devc = file->private_data;
2395 ssize_t ret; 2396 ssize_t ret;
2396 2397
2397 down(&devc->io_sema); 2398 mutex_lock(&devc->io_mutex);
2398 ret = vwsnd_audio_do_write(file, buffer, count, ppos); 2399 ret = vwsnd_audio_do_write(file, buffer, count, ppos);
2399 up(&devc->io_sema); 2400 mutex_unlock(&devc->io_mutex);
2400 return ret; 2401 return ret;
2401} 2402}
2402 2403
@@ -2891,9 +2892,9 @@ static int vwsnd_audio_ioctl(struct inode *inode,
2891 vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; 2892 vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data;
2892 int ret; 2893 int ret;
2893 2894
2894 down(&devc->io_sema); 2895 mutex_lock(&devc->io_mutex);
2895 ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg); 2896 ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg);
2896 up(&devc->io_sema); 2897 mutex_unlock(&devc->io_mutex);
2897 return ret; 2898 return ret;
2898} 2899}
2899 2900
@@ -2929,9 +2930,9 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2929 return -ENODEV; 2930 return -ENODEV;
2930 } 2931 }
2931 2932
2932 down(&devc->open_sema); 2933 mutex_lock(&devc->open_mutex);
2933 while (devc->open_mode & file->f_mode) { 2934 while (devc->open_mode & file->f_mode) {
2934 up(&devc->open_sema); 2935 mutex_unlock(&devc->open_mutex);
2935 if (file->f_flags & O_NONBLOCK) { 2936 if (file->f_flags & O_NONBLOCK) {
2936 DEC_USE_COUNT; 2937 DEC_USE_COUNT;
2937 return -EBUSY; 2938 return -EBUSY;
@@ -2941,10 +2942,10 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2941 DEC_USE_COUNT; 2942 DEC_USE_COUNT;
2942 return -ERESTARTSYS; 2943 return -ERESTARTSYS;
2943 } 2944 }
2944 down(&devc->open_sema); 2945 mutex_lock(&devc->open_mutex);
2945 } 2946 }
2946 devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2947 devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2947 up(&devc->open_sema); 2948 mutex_unlock(&devc->open_mutex);
2948 2949
2949 /* get default sample format from minor number. */ 2950 /* get default sample format from minor number. */
2950 2951
@@ -2960,7 +2961,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2960 2961
2961 /* Initialize vwsnd_ports. */ 2962 /* Initialize vwsnd_ports. */
2962 2963
2963 down(&devc->io_sema); 2964 mutex_lock(&devc->io_mutex);
2964 { 2965 {
2965 if (file->f_mode & FMODE_READ) { 2966 if (file->f_mode & FMODE_READ) {
2966 devc->rport.swstate = SW_INITIAL; 2967 devc->rport.swstate = SW_INITIAL;
@@ -2987,7 +2988,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2987 devc->wport.frag_count = 0; 2988 devc->wport.frag_count = 0;
2988 } 2989 }
2989 } 2990 }
2990 up(&devc->io_sema); 2991 mutex_unlock(&devc->io_mutex);
2991 2992
2992 file->private_data = devc; 2993 file->private_data = devc;
2993 DBGRV(); 2994 DBGRV();
@@ -3005,7 +3006,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file)
3005 int err = 0; 3006 int err = 0;
3006 3007
3007 lock_kernel(); 3008 lock_kernel();
3008 down(&devc->io_sema); 3009 mutex_lock(&devc->io_mutex);
3009 { 3010 {
3010 DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); 3011 DBGEV("(inode=0x%p, file=0x%p)\n", inode, file);
3011 3012
@@ -3022,13 +3023,13 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file)
3022 if (wport) 3023 if (wport)
3023 wport->swstate = SW_OFF; 3024 wport->swstate = SW_OFF;
3024 } 3025 }
3025 up(&devc->io_sema); 3026 mutex_unlock(&devc->io_mutex);
3026 3027
3027 down(&devc->open_sema); 3028 mutex_lock(&devc->open_mutex);
3028 { 3029 {
3029 devc->open_mode &= ~file->f_mode; 3030 devc->open_mode &= ~file->f_mode;
3030 } 3031 }
3031 up(&devc->open_sema); 3032 mutex_unlock(&devc->open_mutex);
3032 wake_up(&devc->open_wait); 3033 wake_up(&devc->open_wait);
3033 DEC_USE_COUNT; 3034 DEC_USE_COUNT;
3034 DBGR(); 3035 DBGR();
@@ -3213,7 +3214,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
3213 3214
3214 DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); 3215 DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg);
3215 3216
3216 down(&devc->mix_sema); 3217 mutex_lock(&devc->mix_mutex);
3217 { 3218 {
3218 if ((cmd & ~nrmask) == MIXER_READ(0)) 3219 if ((cmd & ~nrmask) == MIXER_READ(0))
3219 retval = mixer_read_ioctl(devc, nr, (void __user *) arg); 3220 retval = mixer_read_ioctl(devc, nr, (void __user *) arg);
@@ -3222,7 +3223,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
3222 else 3223 else
3223 retval = -EINVAL; 3224 retval = -EINVAL;
3224 } 3225 }
3225 up(&devc->mix_sema); 3226 mutex_unlock(&devc->mix_mutex);
3226 return retval; 3227 return retval;
3227} 3228}
3228 3229
@@ -3376,9 +3377,9 @@ static int __init attach_vwsnd(struct address_info *hw_config)
3376 3377
3377 /* Initialize as much of *devc as possible */ 3378 /* Initialize as much of *devc as possible */
3378 3379
3379 init_MUTEX(&devc->open_sema); 3380 mutex_init(&devc->open_mutex);
3380 init_MUTEX(&devc->io_sema); 3381 mutex_init(&devc->io_mutex);
3381 init_MUTEX(&devc->mix_sema); 3382 mutex_init(&devc->mix_mutex);
3382 devc->open_mode = 0; 3383 devc->open_mode = 0;
3383 spin_lock_init(&devc->rport.lock); 3384 spin_lock_init(&devc->rport.lock);
3384 init_waitqueue_head(&devc->rport.queue); 3385 init_waitqueue_head(&devc->rport.queue);
diff --git a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
index f8bd72e46f57..bf90c124a7e6 100644
--- a/sound/oss/ymfpci.c
+++ b/sound/oss/ymfpci.c
@@ -1918,10 +1918,10 @@ static int ymf_open(struct inode *inode, struct file *file)
1918 if (unit == NULL) 1918 if (unit == NULL)
1919 return -ENODEV; 1919 return -ENODEV;
1920 1920
1921 down(&unit->open_sem); 1921 mutex_lock(&unit->open_mutex);
1922 1922
1923 if ((state = ymf_state_alloc(unit)) == NULL) { 1923 if ((state = ymf_state_alloc(unit)) == NULL) {
1924 up(&unit->open_sem); 1924 mutex_unlock(&unit->open_mutex);
1925 return -ENOMEM; 1925 return -ENOMEM;
1926 } 1926 }
1927 list_add_tail(&state->chain, &unit->states); 1927 list_add_tail(&state->chain, &unit->states);
@@ -1956,7 +1956,7 @@ static int ymf_open(struct inode *inode, struct file *file)
1956 ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 1956 ymfpci_writeb(unit, YDSXGR_TIMERCTRL,
1957 (YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN)); 1957 (YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN));
1958#endif 1958#endif
1959 up(&unit->open_sem); 1959 mutex_unlock(&unit->open_mutex);
1960 1960
1961 return nonseekable_open(inode, file); 1961 return nonseekable_open(inode, file);
1962 1962
@@ -1974,7 +1974,7 @@ out_nodma:
1974 list_del(&state->chain); 1974 list_del(&state->chain);
1975 kfree(state); 1975 kfree(state);
1976 1976
1977 up(&unit->open_sem); 1977 mutex_unlock(&unit->open_mutex);
1978 return err; 1978 return err;
1979} 1979}
1980 1980
@@ -1987,7 +1987,7 @@ static int ymf_release(struct inode *inode, struct file *file)
1987 ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0); 1987 ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0);
1988#endif 1988#endif
1989 1989
1990 down(&unit->open_sem); 1990 mutex_lock(&unit->open_mutex);
1991 1991
1992 /* 1992 /*
1993 * XXX Solve the case of O_NONBLOCK close - don't deallocate here. 1993 * XXX Solve the case of O_NONBLOCK close - don't deallocate here.
@@ -2004,7 +2004,7 @@ static int ymf_release(struct inode *inode, struct file *file)
2004 file->private_data = NULL; /* Can you tell I programmed Solaris */ 2004 file->private_data = NULL; /* Can you tell I programmed Solaris */
2005 kfree(state); 2005 kfree(state);
2006 2006
2007 up(&unit->open_sem); 2007 mutex_unlock(&unit->open_mutex);
2008 2008
2009 return 0; 2009 return 0;
2010} 2010}
@@ -2532,7 +2532,7 @@ static int __devinit ymf_probe_one(struct pci_dev *pcidev, const struct pci_devi
2532 spin_lock_init(&codec->reg_lock); 2532 spin_lock_init(&codec->reg_lock);
2533 spin_lock_init(&codec->voice_lock); 2533 spin_lock_init(&codec->voice_lock);
2534 spin_lock_init(&codec->ac97_lock); 2534 spin_lock_init(&codec->ac97_lock);
2535 init_MUTEX(&codec->open_sem); 2535 mutex_init(&codec->open_mutex);
2536 INIT_LIST_HEAD(&codec->states); 2536 INIT_LIST_HEAD(&codec->states);
2537 codec->pci = pcidev; 2537 codec->pci = pcidev;
2538 2538
diff --git a/sound/oss/ymfpci.h b/sound/oss/ymfpci.h
index f810a100c641..ac1785f2b7e7 100644
--- a/sound/oss/ymfpci.h
+++ b/sound/oss/ymfpci.h
@@ -22,6 +22,7 @@
22 * 22 *
23 */ 23 */
24#include <linux/config.h> 24#include <linux/config.h>
25#include <linux/mutex.h>
25 26
26/* 27/*
27 * Direct registers 28 * Direct registers
@@ -279,7 +280,7 @@ struct ymf_unit {
279 280
280 /* soundcore stuff */ 281 /* soundcore stuff */
281 int dev_audio; 282 int dev_audio;
282 struct semaphore open_sem; 283 struct mutex open_mutex;
283 284
284 struct list_head ymf_devs; 285 struct list_head ymf_devs;
285 struct list_head states; /* List of states for this unit */ 286 struct list_head states; /* List of states for this unit */