aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2006-06-29 19:57:46 -0400
committerLen Brown <len.brown@intel.com>2006-06-29 19:57:46 -0400
commitd120cfb544ed6161b9d32fb6c4648c471807ee6b (patch)
tree7757ad0198d8df76ff5c60f939a687687c41da00
parent9dce0e950dbfab4148f35ac6f297d8638cdc63c4 (diff)
parentbf7e8511088963078484132636839b59e25cf14f (diff)
merge linus into release branch
Conflicts: drivers/acpi/acpi_memhotplug.c
-rw-r--r--CREDITS4
-rw-r--r--Documentation/Changes15
-rw-r--r--Documentation/DocBook/Makefile3
-rw-r--r--Documentation/DocBook/genericirq.tmpl474
-rw-r--r--Documentation/DocBook/kernel-api.tmpl5
-rw-r--r--Documentation/IRQ.txt22
-rw-r--r--Documentation/RCU/torture.txt34
-rw-r--r--Documentation/README.DAC9606
-rw-r--r--Documentation/feature-removal-schedule.txt75
-rw-r--r--Documentation/filesystems/devfs/ChangeLog1977
-rw-r--r--Documentation/filesystems/devfs/README1959
-rw-r--r--Documentation/filesystems/devfs/ToDo40
-rw-r--r--Documentation/filesystems/devfs/boot-options65
-rw-r--r--Documentation/initrd.txt24
-rw-r--r--Documentation/ioctl-number.txt1
-rw-r--r--Documentation/kernel-parameters.txt17
-rw-r--r--Documentation/keys-request-key.txt54
-rw-r--r--Documentation/keys.txt29
-rw-r--r--Documentation/pi-futex.txt121
-rw-r--r--Documentation/robust-futexes.txt2
-rw-r--r--Documentation/rt-mutex-design.txt781
-rw-r--r--Documentation/rt-mutex.txt79
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt106
-rw-r--r--Documentation/video4linux/README.pvrusb2212
-rw-r--r--Documentation/watchdog/pcwd-watchdog.txt75
-rw-r--r--Documentation/watchdog/src/watchdog-simple.c15
-rw-r--r--Documentation/watchdog/src/watchdog-test.c68
-rw-r--r--Documentation/watchdog/watchdog-api.txt56
-rw-r--r--Documentation/watchdog/watchdog.txt23
-rw-r--r--arch/alpha/kernel/irq.c8
-rw-r--r--arch/alpha/kernel/irq_alpha.c2
-rw-r--r--arch/alpha/kernel/irq_i8259.c2
-rw-r--r--arch/alpha/kernel/irq_pyxis.c2
-rw-r--r--arch/alpha/kernel/irq_srm.c2
-rw-r--r--arch/alpha/kernel/pci.c4
-rw-r--r--arch/alpha/kernel/setup.c2
-rw-r--r--arch/alpha/kernel/sys_alcor.c2
-rw-r--r--arch/alpha/kernel/sys_cabriolet.c2
-rw-r--r--arch/alpha/kernel/sys_dp264.c2
-rw-r--r--arch/alpha/kernel/sys_eb64p.c2
-rw-r--r--arch/alpha/kernel/sys_eiger.c2
-rw-r--r--arch/alpha/kernel/sys_jensen.c10
-rw-r--r--arch/alpha/kernel/sys_marvel.c6
-rw-r--r--arch/alpha/kernel/sys_mikasa.c2
-rw-r--r--arch/alpha/kernel/sys_noritake.c2
-rw-r--r--arch/alpha/kernel/sys_rawhide.c2
-rw-r--r--arch/alpha/kernel/sys_rx164.c2
-rw-r--r--arch/alpha/kernel/sys_sable.c2
-rw-r--r--arch/alpha/kernel/sys_takara.c2
-rw-r--r--arch/alpha/kernel/sys_titan.c2
-rw-r--r--arch/alpha/kernel/sys_wildfire.c6
-rw-r--r--arch/arm/Kconfig9
-rw-r--r--arch/arm/kernel/Makefile3
-rw-r--r--arch/arm/kernel/armksyms.c13
-rw-r--r--arch/arm/kernel/asm-offsets.c3
-rw-r--r--arch/arm/kernel/bios32.c6
-rw-r--r--arch/arm/kernel/crunch-bits.S305
-rw-r--r--arch/arm/kernel/crunch.c83
-rw-r--r--arch/arm/kernel/entry-armv.S6
-rw-r--r--arch/arm/kernel/ptrace.c36
-rw-r--r--arch/arm/kernel/setup.c44
-rw-r--r--arch/arm/kernel/signal.c39
-rw-r--r--arch/arm/kernel/vmlinux.lds.S8
-rw-r--r--arch/arm/lib/Makefile13
-rw-r--r--arch/arm/lib/backtrace.S5
-rw-r--r--arch/arm/lib/clear_user.S4
-rw-r--r--arch/arm/lib/copy_from_user.S4
-rw-r--r--arch/arm/lib/copy_to_user.S4
-rw-r--r--arch/arm/lib/strncpy_from_user.S2
-rw-r--r--arch/arm/lib/strnlen_user.S4
-rw-r--r--arch/arm/lib/uaccess.S8
-rw-r--r--arch/arm/mach-ep93xx/Kconfig11
-rw-r--r--arch/arm/mach-ep93xx/Makefile1
-rw-r--r--arch/arm/mach-ep93xx/edb9315.c62
-rw-r--r--arch/arm/mach-ep93xx/gesbc9312.c2
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c2
-rw-r--r--arch/arm/mach-ixp23xx/espresso.c2
-rw-r--r--arch/arm/mach-ixp23xx/ixdp2351.c2
-rw-r--r--arch/arm/mach-ixp23xx/roadrunner.c2
-rw-r--r--arch/arm/mach-pxa/irq.c4
-rw-r--r--arch/arm/mach-s3c2410/s3c244x.c1
-rw-r--r--arch/arm/mm/Kconfig67
-rw-r--r--arch/arm/mm/Makefile10
-rw-r--r--arch/arm/mm/init.c2
-rw-r--r--arch/arm/mm/iomap.c55
-rw-r--r--arch/arm/mm/ioremap.c47
-rw-r--r--arch/arm/mm/nommu.c39
-rw-r--r--arch/arm/mm/proc-arm1020.S9
-rw-r--r--arch/arm/mm/proc-arm1020e.S9
-rw-r--r--arch/arm/mm/proc-arm1022.S9
-rw-r--r--arch/arm/mm/proc-arm1026.S9
-rw-r--r--arch/arm/mm/proc-arm6_7.S15
-rw-r--r--arch/arm/mm/proc-arm720.S12
-rw-r--r--arch/arm/mm/proc-arm920.S9
-rw-r--r--arch/arm/mm/proc-arm922.S9
-rw-r--r--arch/arm/mm/proc-arm925.S10
-rw-r--r--arch/arm/mm/proc-arm926.S9
-rw-r--r--arch/arm/mm/proc-sa110.S11
-rw-r--r--arch/arm/mm/proc-sa1100.S11
-rw-r--r--arch/arm/mm/proc-v6.S7
-rw-r--r--arch/cris/Kconfig4
-rw-r--r--arch/cris/arch-v10/kernel/debugport.c2
-rw-r--r--arch/cris/arch-v10/kernel/irq.c2
-rw-r--r--arch/cris/arch-v32/drivers/pci/bios.c4
-rw-r--r--arch/cris/arch-v32/kernel/debugport.c2
-rw-r--r--arch/cris/arch-v32/kernel/irq.c2
-rw-r--r--arch/cris/kernel/irq.c2
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.c4
-rw-r--r--arch/i386/Kconfig21
-rw-r--r--arch/i386/kernel/asm-offsets.c4
-rw-r--r--arch/i386/kernel/cpu/amd.c6
-rw-r--r--arch/i386/kernel/cpu/common.c25
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c16
-rw-r--r--arch/i386/kernel/cpu/proc.c8
-rw-r--r--arch/i386/kernel/cpuid.c2
-rw-r--r--arch/i386/kernel/efi.c6
-rw-r--r--arch/i386/kernel/entry.S22
-rw-r--r--arch/i386/kernel/i8259.c6
-rw-r--r--arch/i386/kernel/io_apic.c27
-rw-r--r--arch/i386/kernel/irq.c27
-rw-r--r--arch/i386/kernel/microcode.c1
-rw-r--r--arch/i386/kernel/msr.c2
-rw-r--r--arch/i386/kernel/scx200.c66
-rw-r--r--arch/i386/kernel/setup.c2
-rw-r--r--arch/i386/kernel/signal.c4
-rw-r--r--arch/i386/kernel/smpboot.c37
-rw-r--r--arch/i386/kernel/sysenter.c126
-rw-r--r--arch/i386/kernel/topology.c28
-rw-r--r--arch/i386/kernel/vsyscall-sysenter.S4
-rw-r--r--arch/i386/kernel/vsyscall.lds.S4
-rw-r--r--arch/i386/mach-visws/setup.c8
-rw-r--r--arch/i386/mach-visws/visws_apic.c12
-rw-r--r--arch/i386/mach-voyager/setup.c5
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c4
-rw-r--r--arch/i386/mm/init.c5
-rw-r--r--arch/i386/mm/pageattr.c4
-rw-r--r--arch/i386/pci/i386.c4
-rw-r--r--arch/ia64/Kconfig11
-rw-r--r--arch/ia64/configs/tiger_defconfig2
-rw-r--r--arch/ia64/hp/sim/hpsim_irq.c6
-rw-r--r--arch/ia64/kernel/iosapic.c24
-rw-r--r--arch/ia64/kernel/irq.c24
-rw-r--r--arch/ia64/kernel/irq_ia64.c4
-rw-r--r--arch/ia64/kernel/irq_lsapic.c10
-rw-r--r--arch/ia64/kernel/mca.c2
-rw-r--r--arch/ia64/kernel/palinfo.c6
-rw-r--r--arch/ia64/kernel/perfmon.c4
-rw-r--r--arch/ia64/kernel/salinfo.c6
-rw-r--r--arch/ia64/kernel/smpboot.c8
-rw-r--r--arch/ia64/kernel/topology.c32
-rw-r--r--arch/ia64/mm/discontig.c57
-rw-r--r--arch/ia64/mm/init.c5
-rw-r--r--arch/ia64/pci/pci.c2
-rw-r--r--arch/ia64/sn/kernel/irq.c6
-rw-r--r--arch/ia64/sn/kernel/setup.c12
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c2
-rw-r--r--arch/m32r/kernel/irq.c2
-rw-r--r--arch/m32r/kernel/setup.c2
-rw-r--r--arch/m32r/kernel/setup_m32104ut.c8
-rw-r--r--arch/m32r/kernel/setup_m32700ut.c28
-rw-r--r--arch/m32r/kernel/setup_mappi.c16
-rw-r--r--arch/m32r/kernel/setup_mappi2.c20
-rw-r--r--arch/m32r/kernel/setup_mappi3.c20
-rw-r--r--arch/m32r/kernel/setup_oaks32r.c12
-rw-r--r--arch/m32r/kernel/setup_opsput.c28
-rw-r--r--arch/m32r/kernel/setup_usrv.c18
-rw-r--r--arch/m68knommu/Kconfig53
-rw-r--r--arch/m68knommu/Makefile24
-rw-r--r--arch/m68knommu/defconfig207
-rw-r--r--arch/m68knommu/kernel/comempci.c3
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S66
-rw-r--r--arch/m68knommu/platform/68328/Makefile1
-rw-r--r--arch/m68knommu/platform/68328/head-rom.S18
-rw-r--r--arch/m68knommu/platform/68328/ints.c20
-rw-r--r--arch/m68knommu/platform/68328/romvec.S37
-rw-r--r--arch/m68knommu/platform/68360/config.c14
-rw-r--r--arch/m68knommu/platform/68360/head-ram.S19
-rw-r--r--arch/m68knommu/platform/68360/head-rom.S17
-rw-r--r--arch/m68knommu/platform/68360/ints.c1
-rw-r--r--arch/m68knommu/platform/68EZ328/config.c14
-rw-r--r--arch/m68knommu/platform/68VZ328/config.c14
-rw-r--r--arch/mips/Kconfig101
-rw-r--r--arch/mips/Makefile1
-rw-r--r--arch/mips/au1000/common/dbdma.c6
-rw-r--r--arch/mips/au1000/common/irq.c34
-rw-r--r--arch/mips/au1000/common/power.c22
-rw-r--r--arch/mips/au1000/csb250/init.c6
-rw-r--r--arch/mips/au1000/pb1200/irqmap.c2
-rw-r--r--arch/mips/basler/excite/excite_setup.c2
-rw-r--r--arch/mips/ddb5xxx/common/prom.c2
-rw-r--r--arch/mips/ddb5xxx/ddb5477/irq_5477.c2
-rw-r--r--arch/mips/dec/ioasic-irq.c4
-rw-r--r--arch/mips/dec/kn02-irq.c2
-rw-r--r--arch/mips/gt64120/common/Makefile1
-rw-r--r--arch/mips/gt64120/common/pci.c147
-rw-r--r--arch/mips/gt64120/ev64120/irq.c2
-rw-r--r--arch/mips/gt64120/momenco_ocelot/setup.c4
-rw-r--r--arch/mips/gt64120/wrppmc/Makefile2
-rw-r--r--arch/mips/gt64120/wrppmc/int-handler.S59
-rw-r--r--arch/mips/gt64120/wrppmc/irq.c20
-rw-r--r--arch/mips/gt64120/wrppmc/setup.c2
-rw-r--r--arch/mips/gt64120/wrppmc/time.c4
-rw-r--r--arch/mips/ite-boards/generic/irq.c4
-rw-r--r--arch/mips/jazz/irq.c2
-rw-r--r--arch/mips/jmr3927/rbhma3100/irq.c2
-rw-r--r--arch/mips/kernel/apm.c2
-rw-r--r--arch/mips/kernel/cpu-probe.c2
-rw-r--r--arch/mips/kernel/entry.S6
-rw-r--r--arch/mips/kernel/gdb-low.S4
-rw-r--r--arch/mips/kernel/genex.S2
-rw-r--r--arch/mips/kernel/head.S2
-rw-r--r--arch/mips/kernel/i8259.c4
-rw-r--r--arch/mips/kernel/irq-msc01.c4
-rw-r--r--arch/mips/kernel/irq-mv6434x.c2
-rw-r--r--arch/mips/kernel/irq-rm7000.c2
-rw-r--r--arch/mips/kernel/irq-rm9000.c4
-rw-r--r--arch/mips/kernel/irq.c4
-rw-r--r--arch/mips/kernel/irq_cpu.c4
-rw-r--r--arch/mips/kernel/r4k_switch.S6
-rw-r--r--arch/mips/kernel/scall32-o32.S1
-rw-r--r--arch/mips/kernel/scall64-64.S1
-rw-r--r--arch/mips/kernel/scall64-n32.S1
-rw-r--r--arch/mips/kernel/scall64-o32.S1
-rw-r--r--arch/mips/kernel/setup.c3
-rw-r--r--arch/mips/kernel/smp.c2
-rw-r--r--arch/mips/kernel/smtc-asm.S10
-rw-r--r--arch/mips/kernel/smtc.c4
-rw-r--r--arch/mips/kernel/syscall.c8
-rw-r--r--arch/mips/kernel/traps.c15
-rw-r--r--arch/mips/lasat/interrupt.c2
-rw-r--r--arch/mips/mips-boards/atlas/atlas_int.c2
-rw-r--r--arch/mips/mm/Makefile1
-rw-r--r--arch/mips/mm/c-r4k.c99
-rw-r--r--arch/mips/mm/sc-mips.c112
-rw-r--r--arch/mips/momentum/jaguar_atx/setup.c4
-rw-r--r--arch/mips/momentum/ocelot_c/cpci-irq.c2
-rw-r--r--arch/mips/momentum/ocelot_c/setup.c4
-rw-r--r--arch/mips/momentum/ocelot_c/uart-irq.c4
-rw-r--r--arch/mips/momentum/ocelot_g/setup.c4
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c148
-rw-r--r--arch/mips/pci/Makefile2
-rw-r--r--arch/mips/pci/ops-tx4927.c8
-rw-r--r--arch/mips/pci/ops-tx4938.c8
-rw-r--r--arch/mips/pci/pci.c4
-rw-r--r--arch/mips/philips/pnx8550/common/int.c10
-rw-r--r--arch/mips/pmc-sierra/yosemite/ht.c4
-rw-r--r--arch/mips/sgi-ip22/ip22-eisa.c4
-rw-r--r--arch/mips/sgi-ip22/ip22-int.c2
-rw-r--r--arch/mips/sgi-ip27/Kconfig3
-rw-r--r--arch/mips/sgi-ip27/Makefile11
-rw-r--r--arch/mips/sgi-ip27/ip27-console.c40
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c2
-rw-r--r--arch/mips/sgi-ip32/ip32-irq.c2
-rw-r--r--arch/mips/sibyte/Kconfig3
-rw-r--r--arch/mips/sibyte/bcm1480/irq.c4
-rw-r--r--arch/mips/sibyte/sb1250/irq.c4
-rw-r--r--arch/mips/sni/irq.c2
-rw-r--r--arch/mips/tx4927/common/tx4927_irq.c4
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c14
-rw-r--r--arch/mips/tx4938/common/irq.c4
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/irq.c2
-rw-r--r--arch/mips/vr41xx/common/icu.c4
-rw-r--r--arch/mips/vr41xx/common/irq.c4
-rw-r--r--arch/mips/vr41xx/common/vrc4173.c2
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/irq.c2
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/parisc/kernel/cache.c28
-rw-r--r--arch/parisc/kernel/entry.S6
-rw-r--r--arch/parisc/kernel/firmware.c46
-rw-r--r--arch/parisc/kernel/irq.c29
-rw-r--r--arch/parisc/kernel/module.c63
-rw-r--r--arch/parisc/kernel/pci.c2
-rw-r--r--arch/parisc/kernel/pdc_chassis.c109
-rw-r--r--arch/parisc/kernel/ptrace.c8
-rw-r--r--arch/parisc/kernel/real2.S9
-rw-r--r--arch/parisc/kernel/setup.c5
-rw-r--r--arch/parisc/kernel/signal.c20
-rw-r--r--arch/parisc/kernel/syscall.S14
-rw-r--r--arch/parisc/kernel/time.c18
-rw-r--r--arch/parisc/kernel/topology.c3
-rw-r--r--arch/parisc/kernel/traps.c84
-rw-r--r--arch/parisc/kernel/unaligned.c18
-rw-r--r--arch/powerpc/Kconfig34
-rw-r--r--arch/powerpc/Kconfig.debug9
-rw-r--r--arch/powerpc/configs/cell_defconfig7
-rw-r--r--arch/powerpc/configs/mpc7448_hpc2_defconfig923
-rw-r--r--arch/powerpc/kernel/Makefile3
-rw-r--r--arch/powerpc/kernel/cpu_setup_power4.S14
-rw-r--r--arch/powerpc/kernel/cputable.c12
-rw-r--r--arch/powerpc/kernel/crash.c153
-rw-r--r--arch/powerpc/kernel/head_64.S62
-rw-r--r--arch/powerpc/kernel/iommu.c30
-rw-r--r--arch/powerpc/kernel/irq.c10
-rw-r--r--arch/powerpc/kernel/legacy_serial.c11
-rw-r--r--arch/powerpc/kernel/lparcfg.c147
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c4
-rw-r--r--arch/powerpc/kernel/misc.S203
-rw-r--r--arch/powerpc/kernel/misc_32.S156
-rw-r--r--arch/powerpc/kernel/misc_64.S223
-rw-r--r--arch/powerpc/kernel/paca.c1
-rw-r--r--arch/powerpc/kernel/pci_32.c47
-rw-r--r--arch/powerpc/kernel/pci_64.c4
-rw-r--r--arch/powerpc/kernel/prom.c49
-rw-r--r--arch/powerpc/kernel/rtas.c119
-rw-r--r--arch/powerpc/kernel/setup_32.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c22
-rw-r--r--arch/powerpc/kernel/sysfs.c31
-rw-r--r--arch/powerpc/kernel/traps.c27
-rw-r--r--arch/powerpc/kernel/udbg.c7
-rw-r--r--arch/powerpc/mm/hash_native_64.c3
-rw-r--r--arch/powerpc/mm/hash_utils_64.c106
-rw-r--r--arch/powerpc/mm/init_64.c3
-rw-r--r--arch/powerpc/mm/mem.c11
-rw-r--r--arch/powerpc/mm/mmu_context_64.c2
-rw-r--r--arch/powerpc/mm/numa.c11
-rw-r--r--arch/powerpc/platforms/83xx/pci.c5
-rw-r--r--arch/powerpc/platforms/85xx/pci.c5
-rw-r--r--arch/powerpc/platforms/86xx/Kconfig6
-rw-r--r--arch/powerpc/platforms/86xx/Makefile3
-rw-r--r--arch/powerpc/platforms/86xx/mpc8641_hpcn.h1
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx.h8
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c129
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_smp.c10
-rw-r--r--arch/powerpc/platforms/86xx/pci.c137
-rw-r--r--arch/powerpc/platforms/Makefile1
-rw-r--r--arch/powerpc/platforms/cell/Kconfig2
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c4
-rw-r--r--arch/powerpc/platforms/cell/setup.c16
-rw-r--r--arch/powerpc/platforms/cell/spider-pic.c4
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c8
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c10
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c8
-rw-r--r--arch/powerpc/platforms/chrp/pci.c4
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig15
-rw-r--r--arch/powerpc/platforms/embedded6xx/Makefile4
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c335
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.h26
-rw-r--r--arch/powerpc/platforms/iseries/dt.c2
-rw-r--r--arch/powerpc/platforms/iseries/htab.c4
-rw-r--r--arch/powerpc/platforms/iseries/irq.c6
-rw-r--r--arch/powerpc/platforms/iseries/lpevents.c55
-rw-r--r--arch/powerpc/platforms/iseries/proc.c1
-rw-r--r--arch/powerpc/platforms/iseries/setup.c19
-rw-r--r--arch/powerpc/platforms/maple/pci.c5
-rw-r--r--arch/powerpc/platforms/maple/setup.c7
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c14
-rw-r--r--arch/powerpc/platforms/powermac/pci.c5
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_core.c2
-rw-r--r--arch/powerpc/platforms/powermac/pic.c4
-rw-r--r--arch/powerpc/platforms/powermac/setup.c9
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c2
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c33
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c4
-rw-r--r--arch/powerpc/platforms/pseries/setup.c10
-rw-r--r--arch/powerpc/platforms/pseries/xics.c12
-rw-r--r--arch/powerpc/sysdev/Makefile2
-rw-r--r--arch/powerpc/sysdev/dart.h6
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c49
-rw-r--r--arch/powerpc/sysdev/i8259.c2
-rw-r--r--arch/powerpc/sysdev/ipic.c2
-rw-r--r--arch/powerpc/sysdev/mmio_nvram.c2
-rw-r--r--arch/powerpc/sysdev/mpic.c10
-rw-r--r--arch/powerpc/sysdev/todc.c392
-rw-r--r--arch/powerpc/sysdev/tsi108_dev.c145
-rw-r--r--arch/powerpc/sysdev/tsi108_pci.c412
-rw-r--r--arch/ppc/4xx_io/serial_sicc.c2
-rw-r--r--arch/ppc/8xx_io/commproc.c2
-rw-r--r--arch/ppc/Kconfig4
-rw-r--r--arch/ppc/kernel/pci.c52
-rw-r--r--arch/ppc/kernel/setup.c2
-rw-r--r--arch/ppc/platforms/apus_setup.c4
-rw-r--r--arch/ppc/platforms/sbc82xx.c2
-rw-r--r--arch/ppc/syslib/cpc700_pic.c4
-rw-r--r--arch/ppc/syslib/cpm2_pic.c2
-rw-r--r--arch/ppc/syslib/gt64260_pic.c2
-rw-r--r--arch/ppc/syslib/m82xx_pci.c2
-rw-r--r--arch/ppc/syslib/m8xx_setup.c4
-rw-r--r--arch/ppc/syslib/mpc52xx_pic.c4
-rw-r--r--arch/ppc/syslib/mv64360_pic.c2
-rw-r--r--arch/ppc/syslib/open_pic.c8
-rw-r--r--arch/ppc/syslib/open_pic2.c2
-rw-r--r--arch/ppc/syslib/ppc403_pic.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_pic.c2
-rw-r--r--arch/ppc/syslib/xilinx_pic.c2
-rw-r--r--arch/s390/appldata/appldata.h24
-rw-r--r--arch/s390/appldata/appldata_base.c44
-rw-r--r--arch/s390/appldata/appldata_mem.c5
-rw-r--r--arch/s390/appldata/appldata_net_sum.c5
-rw-r--r--arch/s390/appldata/appldata_os.c98
-rw-r--r--arch/s390/kernel/binfmt_elf32.c5
-rw-r--r--arch/s390/kernel/entry.S80
-rw-r--r--arch/s390/kernel/entry64.S80
-rw-r--r--arch/s390/kernel/head.S22
-rw-r--r--arch/s390/kernel/head31.S77
-rw-r--r--arch/s390/kernel/head64.S79
-rw-r--r--arch/s390/kernel/s390_ksyms.c2
-rw-r--r--arch/s390/kernel/setup.c55
-rw-r--r--arch/s390/kernel/smp.c2
-rw-r--r--arch/s390/kernel/traps.c8
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sh/boards/adx/irq_maskreg.c2
-rw-r--r--arch/sh/boards/bigsur/irq.c4
-rw-r--r--arch/sh/boards/cqreek/irq.c4
-rw-r--r--arch/sh/boards/dreamcast/setup.c2
-rw-r--r--arch/sh/boards/ec3104/setup.c2
-rw-r--r--arch/sh/boards/harp/irq.c2
-rw-r--r--arch/sh/boards/mpc1211/pci.c4
-rw-r--r--arch/sh/boards/mpc1211/setup.c2
-rw-r--r--arch/sh/boards/overdrive/galileo.c2
-rw-r--r--arch/sh/boards/overdrive/irq.c2
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/irq.c2
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/irq.c2
-rw-r--r--arch/sh/boards/renesas/systemh/irq.c2
-rw-r--r--arch/sh/boards/se/73180/irq.c2
-rw-r--r--arch/sh/boards/superh/microdev/irq.c2
-rw-r--r--arch/sh/cchips/hd6446x/hd64461/setup.c2
-rw-r--r--arch/sh/cchips/hd6446x/hd64465/setup.c2
-rw-r--r--arch/sh/cchips/voyagergx/irq.c2
-rw-r--r--arch/sh/drivers/pci/pci.c6
-rw-r--r--arch/sh/kernel/cpu/irq/imask.c2
-rw-r--r--arch/sh/kernel/cpu/irq/intc2.c2
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c2
-rw-r--r--arch/sh/kernel/cpu/irq/pint.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c1
-rw-r--r--arch/sh/kernel/irq.c2
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh64/kernel/irq.c2
-rw-r--r--arch/sh64/kernel/irq_intc.c4
-rw-r--r--arch/sh64/kernel/pcibios.c4
-rw-r--r--arch/sh64/kernel/setup.c2
-rw-r--r--arch/sh64/mach-cayman/irq.c2
-rw-r--r--arch/sparc/kernel/ioport.c8
-rw-r--r--arch/sparc/kernel/pcic.c2
-rw-r--r--arch/sparc/kernel/setup.c2
-rw-r--r--arch/sparc64/kernel/irq.c12
-rw-r--r--arch/sparc64/kernel/pci.c2
-rw-r--r--arch/sparc64/kernel/setup.c2
-rw-r--r--arch/sparc64/mm/init.c3
-rw-r--r--arch/sparc64/solaris/socksys.c4
-rw-r--r--arch/um/drivers/line.c2
-rw-r--r--arch/um/drivers/ssl.c1
-rw-r--r--arch/um/drivers/stdio_console.c1
-rw-r--r--arch/um/drivers/ubd_kern.c18
-rw-r--r--arch/um/include/line.h1
-rw-r--r--arch/um/kernel/irq.c6
-rw-r--r--arch/v850/kernel/irq.c6
-rw-r--r--arch/v850/kernel/rte_mb_a_pci.c2
-rw-r--r--arch/x86_64/Kconfig6
-rw-r--r--arch/x86_64/kernel/entry.S2
-rw-r--r--arch/x86_64/kernel/i8259.c6
-rw-r--r--arch/x86_64/kernel/io_apic.c25
-rw-r--r--arch/x86_64/kernel/irq.c18
-rw-r--r--arch/x86_64/kernel/mce.c4
-rw-r--r--arch/x86_64/kernel/nmi.c2
-rw-r--r--arch/x86_64/kernel/smp.c4
-rw-r--r--arch/x86_64/kernel/smpboot.c8
-rw-r--r--arch/x86_64/mm/init.c73
-rw-r--r--arch/xtensa/kernel/irq.c4
-rw-r--r--arch/xtensa/kernel/pci.c6
-rw-r--r--arch/xtensa/kernel/time.c2
-rw-r--r--arch/xtensa/kernel/traps.c2
-rw-r--r--block/ll_rw_blk.c6
-rw-r--r--drivers/acpi/Kconfig2
-rw-r--r--drivers/acpi/acpi_memhotplug.c142
-rw-r--r--drivers/acpi/numa.c15
-rw-r--r--drivers/amba/bus.c5
-rw-r--r--drivers/atm/ambassador.c3
-rw-r--r--drivers/atm/firestream.c8
-rw-r--r--drivers/base/cpu.c28
-rw-r--r--drivers/base/dmapool.c3
-rw-r--r--drivers/base/memory.c4
-rw-r--r--drivers/base/node.c61
-rw-r--r--drivers/base/topology.c4
-rw-r--r--drivers/block/DAC960.c1
-rw-r--r--drivers/block/acsi.c5
-rw-r--r--drivers/block/acsi_slm.c10
-rw-r--r--drivers/block/cciss.c1
-rw-r--r--drivers/block/cpqarray.c5
-rw-r--r--drivers/block/floppy.c55
-rw-r--r--drivers/block/loop.c10
-rw-r--r--drivers/block/nbd.c5
-rw-r--r--drivers/block/paride/pf.c2
-rw-r--r--drivers/block/paride/pg.c18
-rw-r--r--drivers/block/paride/pt.c21
-rw-r--r--drivers/block/pktcdvd.c1
-rw-r--r--drivers/block/ps2esdi.c1
-rw-r--r--drivers/block/rd.c7
-rw-r--r--drivers/block/swim3.c4
-rw-r--r--drivers/block/sx8.c10
-rw-r--r--drivers/block/ub.c6
-rw-r--r--drivers/block/umem.c1
-rw-r--r--drivers/block/viodasd.c3
-rw-r--r--drivers/block/xd.c1
-rw-r--r--drivers/block/z2ram.c1
-rw-r--r--drivers/cdrom/aztcd.c1
-rw-r--r--drivers/cdrom/cdu31a.c1
-rw-r--r--drivers/cdrom/cm206.c1
-rw-r--r--drivers/cdrom/gscd.c1
-rw-r--r--drivers/cdrom/mcdx.c1
-rw-r--r--drivers/cdrom/optcd.c1
-rw-r--r--drivers/cdrom/sbpcd.c6
-rw-r--r--drivers/cdrom/sjcd.c1
-rw-r--r--drivers/cdrom/sonycd535.c1
-rw-r--r--drivers/cdrom/viocd.c3
-rw-r--r--drivers/char/Kconfig24
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/agp/Kconfig1
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/agp/ati-agp.c33
-rw-r--r--drivers/char/agp/nvidia-agp.c27
-rw-r--r--drivers/char/agp/sgi-agp.c5
-rw-r--r--drivers/char/applicom.c9
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/drm/drm_memory_debug.h2
-rw-r--r--drivers/char/drm/via_dmablit.c2
-rw-r--r--drivers/char/dsp56k.c10
-rw-r--r--drivers/char/dtlk.c5
-rw-r--r--drivers/char/epca.c3
-rw-r--r--drivers/char/esp.c1
-rw-r--r--drivers/char/ftape/zftape/zftape-init.c25
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/char/hvcs.c12
-rw-r--r--drivers/char/hvsi.c1
-rw-r--r--drivers/char/ip2/ip2main.c24
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c8
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c10
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c69
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c18
-rw-r--r--drivers/char/isicom.c1
-rw-r--r--drivers/char/istallion.c1832
-rw-r--r--drivers/char/lp.c7
-rw-r--r--drivers/char/mem.c6
-rw-r--r--drivers/char/misc.c15
-rw-r--r--drivers/char/mmtimer.c2
-rw-r--r--drivers/char/moxa.c3
-rw-r--r--drivers/char/mxser.c1
-rw-r--r--drivers/char/n_tty.c6
-rw-r--r--drivers/char/nsc_gpio.c142
-rw-r--r--drivers/char/pc8736x_gpio.c340
-rw-r--r--drivers/char/ppdev.c15
-rw-r--r--drivers/char/pty.c10
-rw-r--r--drivers/char/raw.c15
-rw-r--r--drivers/char/riscom8.c1
-rw-r--r--drivers/char/rocket.c5
-rw-r--r--drivers/char/scx200_gpio.c162
-rw-r--r--drivers/char/serial167.c1
-rw-r--r--drivers/char/specialix.c2
-rw-r--r--drivers/char/stallion.c225
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/tipar.c17
-rw-r--r--drivers/char/tty_io.c92
-rw-r--r--drivers/char/vc_screen.c11
-rw-r--r--drivers/char/viocons.c1
-rw-r--r--drivers/char/viotape.c10
-rw-r--r--drivers/char/vme_scc.c1
-rw-r--r--drivers/char/vr41xx_giu.c4
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/char/watchdog/at91_wdt.c82
-rw-r--r--drivers/char/watchdog/i8xx_tco.c28
-rw-r--r--drivers/char/watchdog/pcwd_pci.c30
-rw-r--r--drivers/char/watchdog/pcwd_usb.c23
-rw-r--r--drivers/cpufreq/cpufreq.c8
-rw-r--r--drivers/cpufreq/cpufreq_stats.c4
-rw-r--r--drivers/i2c/busses/i2c-i801.c16
-rw-r--r--drivers/ide/Kconfig9
-rw-r--r--drivers/ide/ide-cd.c2
-rw-r--r--drivers/ide/ide-disk.c2
-rw-r--r--drivers/ide/ide-floppy.c1
-rw-r--r--drivers/ide/ide-io.c2
-rw-r--r--drivers/ide/ide-iops.c4
-rw-r--r--drivers/ide/ide-probe.c11
-rw-r--r--drivers/ide/ide-tape.c12
-rw-r--r--drivers/ide/ide.c10
-rw-r--r--drivers/ide/pci/aec62xx.c19
-rw-r--r--drivers/ide/pci/amd74xx.c7
-rw-r--r--drivers/ide/pci/cmd64x.c15
-rw-r--r--drivers/ide/pci/hpt34x.c2
-rw-r--r--drivers/ide/pci/pdc202xx_new.c6
-rw-r--r--drivers/ide/pci/pdc202xx_old.c119
-rw-r--r--drivers/ide/pci/sc1200.c4
-rw-r--r--drivers/ide/pci/serverworks.c53
-rw-r--r--drivers/ide/pci/siimage.c62
-rw-r--r--drivers/ide/pci/sl82c105.c4
-rw-r--r--drivers/ide/pci/slc90e66.c11
-rw-r--r--drivers/ide/ppc/pmac.c125
-rw-r--r--drivers/ieee1394/ohci1394.c17
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c8
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c5
-rw-r--r--drivers/input/input.c3
-rw-r--r--drivers/input/joystick/db9.c2
-rw-r--r--drivers/input/keyboard/atkbd.c2
-rw-r--r--drivers/input/misc/wistron_btns.c19
-rw-r--r--drivers/input/serio/ct82c710.c6
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/isdn/capi/capi.c5
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c4
-rw-r--r--drivers/isdn/gigaset/common.c6
-rw-r--r--drivers/isdn/gigaset/gigaset.h3
-rw-r--r--drivers/isdn/gigaset/interface.c6
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c4
-rw-r--r--drivers/isdn/hardware/avm/b1pcmcia.c2
-rw-r--r--drivers/isdn/hardware/eicon/divamnt.c3
-rw-r--r--drivers/isdn/hardware/eicon/divasi.c3
-rw-r--r--drivers/isdn/hardware/eicon/divasmain.c3
-rw-r--r--drivers/isdn/hisax/hfc_pci.c2
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c2
-rw-r--r--drivers/isdn/hisax/teles3.c1
-rw-r--r--drivers/isdn/hisax/telespci.c5
-rw-r--r--drivers/isdn/i4l/isdn_common.c18
-rw-r--r--drivers/isdn/i4l/isdn_tty.c5
-rw-r--r--drivers/isdn/i4l/isdn_x25iface.c4
-rw-r--r--drivers/leds/led-core.c2
-rw-r--r--drivers/leds/led-triggers.c2
-rw-r--r--drivers/macintosh/Kconfig12
-rw-r--r--drivers/macintosh/Makefile1
-rw-r--r--drivers/macintosh/adb.c3
-rw-r--r--drivers/macintosh/macio_asic.c4
-rw-r--r--drivers/macintosh/via-pmu-led.c144
-rw-r--r--drivers/md/dm-ioctl.c30
-rw-r--r--drivers/md/dm.c2
-rw-r--r--drivers/md/md.c30
-rw-r--r--drivers/md/raid5.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c13
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h1
-rw-r--r--drivers/media/dvb/ttpci/av7110.h4
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c11
-rw-r--r--drivers/media/radio/miropcm20-rds.c1
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/Makefile1
-rw-r--r--drivers/media/video/arv.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c10
-rw-r--r--drivers/media/video/cx2341x.c40
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c8
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c13
-rw-r--r--drivers/media/video/cx88/cx88-core.c4
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c4
-rw-r--r--drivers/media/video/cx88/cx88-video.c4
-rw-r--r--drivers/media/video/pvrusb2/Kconfig62
-rw-r--r--drivers/media/video/pvrusb2/Makefile18
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-audio.c204
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-audio.h40
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c230
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.h92
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c593
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.h123
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c279
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.h53
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debug.h67
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debugifc.c478
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debugifc.h53
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-demod.c126
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-demod.h38
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-eeprom.c164
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-eeprom.h40
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c418
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.h42
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h384
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c3120
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h335
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c115
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c232
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h47
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c937
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.h96
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c695
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.h102
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.c513
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.h50
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-main.c172
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-std.c408
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-std.h60
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c865
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.h47
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-tuner.c122
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-tuner.h38
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-util.h63
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c1126
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.h40
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-video-v4l.c253
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-video-v4l.h52
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-wm8775.c170
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-wm8775.h53
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2.h43
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c8
-rw-r--r--drivers/media/video/stradis.c4
-rw-r--r--drivers/media/video/tda9887.c31
-rw-r--r--drivers/media/video/tuner-core.c8
-rw-r--r--drivers/media/video/v4l2-common.c2
-rw-r--r--drivers/media/video/videodev.c8
-rw-r--r--drivers/message/fusion/mptfc.c6
-rw-r--r--drivers/message/fusion/mptsas.c3
-rw-r--r--drivers/message/i2o/i2o_block.c1
-rw-r--r--drivers/message/i2o/iop.c15
-rw-r--r--drivers/misc/ibmasm/module.c2
-rw-r--r--drivers/mmc/mmc_block.c4
-rw-r--r--drivers/mmc/mmci.c4
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c1
-rw-r--r--drivers/mtd/chips/jedec.c1
-rw-r--r--drivers/mtd/chips/map_absent.c3
-rw-r--r--drivers/mtd/chips/map_ram.c1
-rw-r--r--drivers/mtd/chips/map_rom.c1
-rw-r--r--drivers/mtd/devices/block2mtd.c1
-rw-r--r--drivers/mtd/devices/ms02-nv.c1
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c1
-rw-r--r--drivers/mtd/devices/phram.c1
-rw-r--r--drivers/mtd/devices/pmc551.c11
-rw-r--r--drivers/mtd/devices/slram.c1
-rw-r--r--drivers/mtd/maps/amd76xrom.c5
-rw-r--r--drivers/mtd/maps/ichxrom.c5
-rw-r--r--drivers/mtd/maps/ixp2000.c2
-rw-r--r--drivers/mtd/maps/physmap.c2
-rw-r--r--drivers/mtd/maps/scx200_docflash.c5
-rw-r--r--drivers/mtd/maps/sun_uflash.c5
-rw-r--r--drivers/mtd/mtdchar.c2
-rw-r--r--drivers/mtd/nand/nand_base.c16
-rw-r--r--drivers/mtd/nand/ndfc.c6
-rw-r--r--drivers/mtd/nand/s3c2410.c164
-rw-r--r--drivers/mtd/nand/ts7250.c2
-rw-r--r--drivers/net/3c59x.c85
-rw-r--r--drivers/net/8139cp.c11
-rw-r--r--drivers/net/8139too.c6
-rw-r--r--drivers/net/dl2k.h12
-rw-r--r--drivers/net/dm9000.c34
-rw-r--r--drivers/net/e100.c4
-rw-r--r--drivers/net/eepro100.c5
-rw-r--r--drivers/net/epic100.c20
-rw-r--r--drivers/net/fealnx.c10
-rw-r--r--drivers/net/fec.c310
-rw-r--r--drivers/net/fs_enet/fs_enet-mii.c3
-rw-r--r--drivers/net/hamradio/dmascc.c2
-rw-r--r--drivers/net/natsemi.c100
-rw-r--r--drivers/net/pcnet32.c6
-rw-r--r--drivers/net/phy/lxt.c8
-rw-r--r--drivers/net/ppp_generic.c9
-rw-r--r--drivers/net/skge.c4
-rw-r--r--drivers/net/sky2.c6
-rw-r--r--drivers/net/tulip/de2104x.c9
-rw-r--r--drivers/net/tulip/tulip_core.c6
-rw-r--r--drivers/net/tulip/winbond-840.c26
-rw-r--r--drivers/net/tun.c1
-rw-r--r--drivers/net/typhoon.c5
-rw-r--r--drivers/net/wan/c101.c2
-rw-r--r--drivers/net/wan/cosa.c14
-rw-r--r--drivers/net/wan/dscc4.c12
-rw-r--r--drivers/net/wan/n2.c2
-rw-r--r--drivers/net/wan/pc300_drv.c4
-rw-r--r--drivers/net/wan/pci200syn.c2
-rw-r--r--drivers/net/wireless/ipw2200.c22
-rw-r--r--drivers/net/yellowfin.c24
-rw-r--r--drivers/parisc/Kconfig33
-rw-r--r--drivers/parisc/dino.c4
-rw-r--r--drivers/parisc/eisa.c2
-rw-r--r--drivers/parisc/gsc.c8
-rw-r--r--drivers/parisc/iosapic.c2
-rw-r--r--drivers/parisc/pdc_stable.c223
-rw-r--r--drivers/parisc/sba_iommu.c17
-rw-r--r--drivers/parisc/superio.c2
-rw-r--r--drivers/pci/bus.c10
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c9
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c10
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c5
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c18
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/pci-sysfs.c4
-rw-r--r--drivers/pci/pci.c6
-rw-r--r--drivers/pci/pci.h6
-rw-r--r--drivers/pci/proc.c20
-rw-r--r--drivers/pci/rom.c10
-rw-r--r--drivers/pci/setup-bus.c6
-rw-r--r--drivers/pci/setup-res.c34
-rw-r--r--drivers/pcmcia/hd64465_ss.c6
-rw-r--r--drivers/pcmcia/i82365.c5
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c4
-rw-r--r--drivers/pcmcia/pd6729.c3
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c26
-rw-r--r--drivers/pcmcia/tcic.c5
-rw-r--r--drivers/pnp/interface.c8
-rw-r--r--drivers/pnp/manager.c15
-rw-r--r--drivers/pnp/resource.c8
-rw-r--r--drivers/rapidio/rio-access.c4
-rw-r--r--drivers/rtc/Kconfig10
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/class.c2
-rw-r--r--drivers/rtc/rtc-ds1553.c2
-rw-r--r--drivers/rtc/rtc-rs5c348.c246
-rw-r--r--drivers/rtc/rtc-sa1100.c2
-rw-r--r--drivers/rtc/rtc-vr41xx.c2
-rw-r--r--drivers/s390/block/dasd.c109
-rw-r--r--drivers/s390/block/dasd_3370_erp.c27
-rw-r--r--drivers/s390/block/dasd_3990_erp.c189
-rw-r--r--drivers/s390/block/dasd_9336_erp.c27
-rw-r--r--drivers/s390/block/dasd_9343_erp.c2
-rw-r--r--drivers/s390/block/dasd_devmap.c102
-rw-r--r--drivers/s390/block/dasd_diag.c6
-rw-r--r--drivers/s390/block/dasd_diag.h2
-rw-r--r--drivers/s390/block/dasd_eckd.c337
-rw-r--r--drivers/s390/block/dasd_eckd.h24
-rw-r--r--drivers/s390/block/dasd_eer.c6
-rw-r--r--drivers/s390/block/dasd_erp.c8
-rw-r--r--drivers/s390/block/dasd_fba.c49
-rw-r--r--drivers/s390/block/dasd_fba.h2
-rw-r--r--drivers/s390/block/dasd_genhd.c2
-rw-r--r--drivers/s390/block/dasd_int.h40
-rw-r--r--drivers/s390/block/dasd_ioctl.c12
-rw-r--r--drivers/s390/block/xpram.c6
-rw-r--r--drivers/s390/char/monreader.c1
-rw-r--r--drivers/s390/char/raw3270.c67
-rw-r--r--drivers/s390/char/tty3270.c3
-rw-r--r--drivers/s390/cio/blacklist.c35
-rw-r--r--drivers/s390/cio/ccwgroup.c17
-rw-r--r--drivers/s390/cio/chsc.c6
-rw-r--r--drivers/s390/cio/cmf.c623
-rw-r--r--drivers/s390/cio/css.c63
-rw-r--r--drivers/s390/cio/device.c4
-rw-r--r--drivers/s390/cio/device.h10
-rw-r--r--drivers/s390/cio/device_fsm.c20
-rw-r--r--drivers/s390/cio/device_ops.c10
-rw-r--r--drivers/s390/crypto/z90main.c1
-rw-r--r--drivers/s390/s390mach.c5
-rw-r--r--drivers/sbus/char/bpp.c9
-rw-r--r--drivers/sbus/char/vfc.h2
-rw-r--r--drivers/sbus/char/vfc_dev.c7
-rw-r--r--drivers/scsi/Kconfig2
-rw-r--r--drivers/scsi/ahci.c2
-rw-r--r--drivers/scsi/ata_piix.c2
-rw-r--r--drivers/scsi/libata-core.c153
-rw-r--r--drivers/scsi/libata-eh.c63
-rw-r--r--drivers/scsi/libata-scsi.c4
-rw-r--r--drivers/scsi/libata.h4
-rw-r--r--drivers/scsi/sata_nv.c2
-rw-r--r--drivers/scsi/sata_sil.c31
-rw-r--r--drivers/scsi/sata_sil24.c2
-rw-r--r--drivers/scsi/sata_svw.c2
-rw-r--r--drivers/scsi/sata_uli.c2
-rw-r--r--drivers/scsi/sata_via.c10
-rw-r--r--drivers/scsi/sata_vsc.c12
-rw-r--r--drivers/serial/21285.c1
-rw-r--r--drivers/serial/68328serial.c102
-rw-r--r--drivers/serial/8250.c1
-rw-r--r--drivers/serial/8250_pci.c4
-rw-r--r--drivers/serial/at91_serial.c1
-rw-r--r--drivers/serial/crisv10.c8
-rw-r--r--drivers/serial/dz.c4
-rw-r--r--drivers/serial/imx.c1
-rw-r--r--drivers/serial/ip22zilog.c1
-rw-r--r--drivers/serial/jsm/jsm_tty.c7
-rw-r--r--drivers/serial/m32r_sio.c1
-rw-r--r--drivers/serial/mcfserial.c1
-rw-r--r--drivers/serial/mpc52xx_uart.c1
-rw-r--r--drivers/serial/mpsc.c2
-rw-r--r--drivers/serial/pmac_zilog.c1
-rw-r--r--drivers/serial/pxa.c1
-rw-r--r--drivers/serial/s3c2410.c2
-rw-r--r--drivers/serial/sa1100.c1
-rw-r--r--drivers/serial/serial_core.c5
-rw-r--r--drivers/serial/serial_txx9.c3
-rw-r--r--drivers/serial/sh-sci.c3
-rw-r--r--drivers/serial/sunhv.c1
-rw-r--r--drivers/serial/sunsab.c1
-rw-r--r--drivers/serial/sunsu.c1
-rw-r--r--drivers/serial/sunzilog.c1
-rw-r--r--drivers/serial/v850e_uart.c1
-rw-r--r--drivers/serial/vr41xx_siu.c1
-rw-r--r--drivers/sn/ioc3.c2
-rw-r--r--drivers/sn/ioc4.c2
-rw-r--r--drivers/spi/spi.c1
-rw-r--r--drivers/tc/zs.c3
-rw-r--r--drivers/telephony/phonedev.c4
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/gadget/serial.c3
-rw-r--r--drivers/usb/host/sl811-hcd.c10
-rw-r--r--drivers/usb/serial/ir-usb.c3
-rw-r--r--drivers/usb/serial/usb-serial.c3
-rw-r--r--drivers/video/aty/radeon_backlight.c6
-rw-r--r--drivers/video/au1100fb.c3
-rw-r--r--drivers/video/backlight/hp680_bl.c2
-rw-r--r--drivers/video/console/vgacon.c12
-rw-r--r--drivers/video/fbmem.c5
-rw-r--r--drivers/video/sgivwfb.c6
-rw-r--r--fs/9p/mux.c2
-rw-r--r--fs/9p/v9fs_vfs.h2
-rw-r--r--fs/9p/vfs_addr.c2
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/Kconfig42
-rw-r--r--fs/Makefile1
-rw-r--r--fs/adfs/inode.c2
-rw-r--r--fs/affs/affs.h6
-rw-r--r--fs/affs/file.c4
-rw-r--r--fs/affs/symlink.c2
-rw-r--r--fs/afs/file.c2
-rw-r--r--fs/afs/internal.h2
-rw-r--r--fs/befs/linuxvfs.c2
-rw-r--r--fs/bfs/bfs.h2
-rw-r--r--fs/bfs/file.c2
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/buffer.c5
-rw-r--r--fs/char_dev.c1
-rw-r--r--fs/cifs/CHANGES17
-rw-r--r--fs/cifs/Makefile2
-rw-r--r--fs/cifs/README39
-rw-r--r--fs/cifs/asn1.c10
-rw-r--r--fs/cifs/cifs_debug.c134
-rw-r--r--fs/cifs/cifs_debug.h4
-rw-r--r--fs/cifs/cifs_unicode.c1
-rw-r--r--fs/cifs/cifsencrypt.c140
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/cifsfs.h5
-rw-r--r--fs/cifs/cifsglob.h71
-rw-r--r--fs/cifs/cifspdu.h98
-rw-r--r--fs/cifs/cifsproto.h14
-rw-r--r--fs/cifs/cifssmb.c287
-rw-r--r--fs/cifs/connect.c498
-rw-r--r--fs/cifs/dir.c15
-rw-r--r--fs/cifs/fcntl.c4
-rw-r--r--fs/cifs/file.c54
-rw-r--r--fs/cifs/inode.c39
-rw-r--r--fs/cifs/link.c7
-rw-r--r--fs/cifs/misc.c10
-rw-r--r--fs/cifs/netmisc.c4
-rw-r--r--fs/cifs/ntlmssp.c143
-rw-r--r--fs/cifs/readdir.c184
-rw-r--r--fs/cifs/sess.c538
-rw-r--r--fs/cifs/smbencrypt.c1
-rw-r--r--fs/cifs/transport.c3
-rw-r--r--fs/coda/psdev.c23
-rw-r--r--fs/coda/symlink.c2
-rw-r--r--fs/compat_ioctl.c1
-rw-r--r--fs/configfs/inode.c2
-rw-r--r--fs/cramfs/inode.c4
-rw-r--r--fs/devfs/Makefile8
-rw-r--r--fs/devfs/base.c2836
-rw-r--r--fs/devfs/util.c97
-rw-r--r--fs/efs/inode.c2
-rw-r--r--fs/efs/symlink.c2
-rw-r--r--fs/ext2/ext2.h6
-rw-r--r--fs/ext2/inode.c6
-rw-r--r--fs/ext3/inode.c6
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/freevxfs/vxfs_immed.c2
-rw-r--r--fs/freevxfs/vxfs_inode.c6
-rw-r--r--fs/freevxfs/vxfs_subr.c2
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/hfs/hfs_fs.h4
-rw-r--r--fs/hfs/inode.c4
-rw-r--r--fs/hfsplus/hfsplus_fs.h4
-rw-r--r--fs/hfsplus/inode.c4
-rw-r--r--fs/hostfs/hostfs_kern.c6
-rw-r--r--fs/hpfs/file.c2
-rw-r--r--fs/hpfs/hpfs_fn.h4
-rw-r--r--fs/hpfs/namei.c2
-rw-r--r--fs/hugetlbfs/inode.c4
-rw-r--r--fs/inode.c2
-rw-r--r--fs/isofs/compress.c2
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/isofs/isofs.h2
-rw-r--r--fs/isofs/rock.c2
-rw-r--r--fs/isofs/zisofs.h2
-rw-r--r--fs/jbd/journal.c3
-rw-r--r--fs/jffs/inode-v23.c4
-rw-r--r--fs/jffs2/acl.c2
-rw-r--r--fs/jffs2/erase.c19
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/jffs2/fs.c2
-rw-r--r--fs/jffs2/gc.c6
-rw-r--r--fs/jffs2/jffs2_fs_sb.h3
-rw-r--r--fs/jffs2/malloc.c2
-rw-r--r--fs/jffs2/nodelist.c3
-rw-r--r--fs/jffs2/nodemgmt.c21
-rw-r--r--fs/jffs2/os-linux.h2
-rw-r--r--fs/jffs2/readinode.c1
-rw-r--r--fs/jffs2/scan.c55
-rw-r--r--fs/jffs2/summary.c41
-rw-r--r--fs/jffs2/xattr.c632
-rw-r--r--fs/jffs2/xattr.h21
-rw-r--r--fs/jfs/inode.c2
-rw-r--r--fs/jfs/jfs_inode.h2
-rw-r--r--fs/jfs/jfs_metapage.c2
-rw-r--r--fs/jfs/jfs_metapage.h2
-rw-r--r--fs/minix/inode.c2
-rw-r--r--fs/ncpfs/inode.c2
-rw-r--r--fs/ncpfs/symlink.c2
-rw-r--r--fs/nfs/direct.c2
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/internal.h8
-rw-r--r--fs/nfs/pagelist.c2
-rw-r--r--fs/nfs/read.c2
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/nfsd/nfs4state.c2
-rw-r--r--fs/ntfs/aops.c4
-rw-r--r--fs/ntfs/ntfs.h4
-rw-r--r--fs/ocfs2/aops.c2
-rw-r--r--fs/ocfs2/cluster/heartbeat.c2
-rw-r--r--fs/ocfs2/cluster/tcp.c2
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c2
-rw-r--r--fs/ocfs2/dlm/dlmlock.c2
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c4
-rw-r--r--fs/ocfs2/dlmglue.c2
-rw-r--r--fs/ocfs2/inode.h2
-rw-r--r--fs/ocfs2/journal.c2
-rw-r--r--fs/ocfs2/vote.c8
-rw-r--r--fs/partitions/Makefile1
-rw-r--r--fs/partitions/check.c32
-rw-r--r--fs/partitions/devfs.c130
-rw-r--r--fs/partitions/devfs.h10
-rw-r--r--fs/proc/task_mmu.c30
-rw-r--r--fs/qnx4/inode.c2
-rw-r--r--fs/ramfs/file-mmu.c2
-rw-r--r--fs/ramfs/file-nommu.c2
-rw-r--r--fs/ramfs/internal.h2
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/romfs/inode.c2
-rw-r--r--fs/smbfs/file.c2
-rw-r--r--fs/smbfs/proto.h2
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysv/itree.c2
-rw-r--r--fs/sysv/sysv.h2
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/udf/inode.c2
-rw-r--r--fs/udf/symlink.c2
-rw-r--r--fs/udf/udfdecl.h6
-rw-r--r--fs/ufs/inode.c119
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c9
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h2
-rw-r--r--fs/xfs/xfs_behavior.h3
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_log.c4
-rw-r--r--fs/xfs/xfs_log_recover.c2
-rw-r--r--fs/xfs/xfs_mount.c21
-rw-r--r--fs/xfs/xfs_rtalloc.c2
-rw-r--r--fs/xfs/xfs_trans.h4
-rw-r--r--fs/xfs/xfs_vnodeops.c11
-rw-r--r--include/asm-alpha/core_t2.h2
-rw-r--r--include/asm-alpha/hw_irq.h2
-rw-r--r--include/asm-arm/arch-at91rm9200/memory.h2
-rw-r--r--include/asm-arm/arch-h720x/memory.h2
-rw-r--r--include/asm-arm/arch-imx/memory.h6
-rw-r--r--include/asm-arm/arch-ixp23xx/ixp23xx.h11
-rw-r--r--include/asm-arm/arch-ixp23xx/platform.h10
-rw-r--r--include/asm-arm/arch-ixp23xx/uncompress.h2
-rw-r--r--include/asm-arm/arch-s3c2410/regs-dsc.h16
-rw-r--r--include/asm-arm/arch-s3c2410/regs-nand.h48
-rw-r--r--include/asm-arm/bugs.h4
-rw-r--r--include/asm-arm/domain.h7
-rw-r--r--include/asm-arm/fpstate.h8
-rw-r--r--include/asm-arm/mach/map.h9
-rw-r--r--include/asm-arm/mach/pci.h2
-rw-r--r--include/asm-arm/memory.h75
-rw-r--r--include/asm-arm/mmu.h16
-rw-r--r--include/asm-arm/mmu_context.h2
-rw-r--r--include/asm-arm/page-nommu.h51
-rw-r--r--include/asm-arm/page.h8
-rw-r--r--include/asm-arm/pgalloc.h8
-rw-r--r--include/asm-arm/pgtable-nommu.h123
-rw-r--r--include/asm-arm/pgtable.h10
-rw-r--r--include/asm-arm/proc-fns.h4
-rw-r--r--include/asm-arm/ptrace.h5
-rw-r--r--include/asm-arm/thread_info.h6
-rw-r--r--include/asm-arm/uaccess.h184
-rw-r--r--include/asm-arm/ucontext.h14
-rw-r--r--include/asm-cris/hw_irq.h2
-rw-r--r--include/asm-cris/irq.h5
-rw-r--r--include/asm-generic/bug.h6
-rw-r--r--include/asm-generic/vmlinux.lds.h28
-rw-r--r--include/asm-i386/cpu.h2
-rw-r--r--include/asm-i386/elf.h53
-rw-r--r--include/asm-i386/fixmap.h10
-rw-r--r--include/asm-i386/hw_irq.h10
-rw-r--r--include/asm-i386/mach-visws/setup_arch.h3
-rw-r--r--include/asm-i386/mmu.h1
-rw-r--r--include/asm-i386/node.h29
-rw-r--r--include/asm-i386/page.h3
-rw-r--r--include/asm-i386/processor.h8
-rw-r--r--include/asm-i386/thread_info.h11
-rw-r--r--include/asm-i386/topology.h11
-rw-r--r--include/asm-i386/unwind.h4
-rw-r--r--include/asm-ia64/hw_irq.h3
-rw-r--r--include/asm-ia64/irq.h5
-rw-r--r--include/asm-ia64/nodedata.h12
-rw-r--r--include/asm-ia64/sn/sn_sal.h10
-rw-r--r--include/asm-ia64/topology.h1
-rw-r--r--include/asm-m32r/hw_irq.h5
-rw-r--r--include/asm-m68knommu/bootstd.h12
-rw-r--r--include/asm-m68knommu/ptrace.h2
-rw-r--r--include/asm-mips/asmmacro.h4
-rw-r--r--include/asm-mips/cpu-features.h20
-rw-r--r--include/asm-mips/fixmap.h4
-rw-r--r--include/asm-mips/hazards.h4
-rw-r--r--include/asm-mips/hw_irq.h8
-rw-r--r--include/asm-mips/irq.h4
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_psc.h2
-rw-r--r--include/asm-mips/mach-mips/irq.h6
-rw-r--r--include/asm-mips/mipsregs.h3
-rw-r--r--include/asm-mips/sn/ioc3.h2
-rw-r--r--include/asm-mips/sn/klconfig.h10
-rw-r--r--include/asm-mips/stackframe.h16
-rw-r--r--include/asm-mips/unistd.h15
-rw-r--r--include/asm-parisc/assembly.h2
-rw-r--r--include/asm-parisc/compat.h11
-rw-r--r--include/asm-parisc/hw_irq.h9
-rw-r--r--include/asm-parisc/irq.h5
-rw-r--r--include/asm-parisc/pdc.h21
-rw-r--r--include/asm-parisc/pgtable.h8
-rw-r--r--include/asm-parisc/processor.h14
-rw-r--r--include/asm-parisc/system.h26
-rw-r--r--include/asm-parisc/uaccess.h9
-rw-r--r--include/asm-parisc/unistd.h5
-rw-r--r--include/asm-powerpc/cputable.h48
-rw-r--r--include/asm-powerpc/hw_irq.h18
-rw-r--r--include/asm-powerpc/irq.h5
-rw-r--r--include/asm-powerpc/iseries/it_lp_queue.h40
-rw-r--r--include/asm-powerpc/kdump.h2
-rw-r--r--include/asm-powerpc/kexec.h9
-rw-r--r--include/asm-powerpc/machdep.h2
-rw-r--r--include/asm-powerpc/mmu.h1
-rw-r--r--include/asm-powerpc/mmu_context.h7
-rw-r--r--include/asm-powerpc/mpc86xx.h5
-rw-r--r--include/asm-powerpc/pci.h2
-rw-r--r--include/asm-powerpc/rtas.h3
-rw-r--r--include/asm-powerpc/time.h6
-rw-r--r--include/asm-powerpc/todc.h487
-rw-r--r--include/asm-powerpc/topology.h5
-rw-r--r--include/asm-powerpc/tsi108.h109
-rw-r--r--include/asm-powerpc/udbg.h3
-rw-r--r--include/asm-ppc/ocp.h1
-rw-r--r--include/asm-ppc/pci.h2
-rw-r--r--include/asm-s390/bitops.h42
-rw-r--r--include/asm-s390/cio.h2
-rw-r--r--include/asm-s390/cmb.h4
-rw-r--r--include/asm-s390/dasd.h8
-rw-r--r--include/asm-s390/thread_info.h1
-rw-r--r--include/asm-s390/unistd.h4
-rw-r--r--include/asm-sh/hw_irq.h5
-rw-r--r--include/asm-sh64/hw_irq.h1
-rw-r--r--include/asm-sparc64/topology.h3
-rw-r--r--include/asm-um/hw_irq.h3
-rw-r--r--include/asm-v850/hw_irq.h4
-rw-r--r--include/asm-x86_64/hw_irq.h11
-rw-r--r--include/asm-x86_64/topology.h2
-rw-r--r--include/asm-xtensa/hw_irq.h4
-rw-r--r--include/linux/ac97_codec.h2
-rw-r--r--include/linux/acpi.h6
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/coda_linux.h4
-rw-r--r--include/linux/compat_ioctl.h5
-rw-r--r--include/linux/cpu.h14
-rw-r--r--include/linux/devfs_fs.h41
-rw-r--r--include/linux/devfs_fs_kernel.h57
-rw-r--r--include/linux/dmaengine.h2
-rw-r--r--include/linux/efs_fs.h2
-rw-r--r--include/linux/elf-em.h5
-rw-r--r--include/linux/fb.h1
-rw-r--r--include/linux/fs.h4
-rw-r--r--include/linux/futex.h12
-rw-r--r--include/linux/genhd.h2
-rw-r--r--include/linux/ide.h2
-rw-r--r--include/linux/init_task.h3
-rw-r--r--include/linux/interrupt.h14
-rw-r--r--include/linux/ioport.h30
-rw-r--r--include/linux/ipmi.h4
-rw-r--r--include/linux/irq.h346
-rw-r--r--include/linux/isdn/tpam.h55
-rw-r--r--include/linux/jffs2.h1
-rw-r--r--include/linux/kbd_kern.h4
-rw-r--r--include/linux/key.h8
-rw-r--r--include/linux/libata.h15
-rw-r--r--include/linux/list.h9
-rw-r--r--include/linux/memory_hotplug.h73
-rw-r--r--include/linux/miscdevice.h1
-rw-r--r--include/linux/mm.h13
-rw-r--r--include/linux/module.h20
-rw-r--r--include/linux/nfs_fs.h2
-rw-r--r--include/linux/node.h17
-rw-r--r--include/linux/nsc_gpio.h42
-rw-r--r--include/linux/pci.h13
-rw-r--r--include/linux/pci_ids.h2
-rw-r--r--include/linux/plist.h248
-rw-r--r--include/linux/pnp.h7
-rw-r--r--include/linux/poison.h58
-rw-r--r--include/linux/rcupdate.h1
-rw-r--r--include/linux/reiserfs_fs.h2
-rw-r--r--include/linux/rtmutex.h117
-rw-r--r--include/linux/sched.h59
-rw-r--r--include/linux/scx200.h7
-rw-r--r--include/linux/scx200_gpio.h21
-rw-r--r--include/linux/serial_core.h1
-rw-r--r--include/linux/spi/spi.h6
-rw-r--r--include/linux/swap.h2
-rw-r--r--include/linux/syscalls.h4
-rw-r--r--include/linux/sysctl.h2
-rw-r--r--include/linux/topology.h3
-rw-r--r--include/linux/tty.h2
-rw-r--r--include/linux/tty_driver.h14
-rw-r--r--include/linux/tty_flip.h2
-rw-r--r--include/linux/types.h7
-rw-r--r--include/linux/ufs_fs.h2
-rw-r--r--include/linux/watchdog.h10
-rw-r--r--include/media/cx2341x.h4
-rw-r--r--include/media/v4l2-dev.h1
-rw-r--r--include/sound/ac97_codec.h1
-rw-r--r--include/sound/ak4xxx-adda.h35
-rw-r--r--include/sound/initval.h3
-rw-r--r--init/Kconfig5
-rw-r--r--init/Makefile1
-rw-r--r--init/do_mounts.c8
-rw-r--r--init/do_mounts.h16
-rw-r--r--init/do_mounts_devfs.c137
-rw-r--r--init/do_mounts_initrd.c6
-rw-r--r--init/do_mounts_md.c7
-rw-r--r--init/do_mounts_rd.c4
-rw-r--r--init/main.c3
-rw-r--r--kernel/Makefile3
-rw-r--r--kernel/acct.c3
-rw-r--r--kernel/audit.c2
-rw-r--r--kernel/auditsc.c10
-rw-r--r--kernel/cpu.c8
-rw-r--r--kernel/exit.c9
-rw-r--r--kernel/fork.c19
-rw-r--r--kernel/futex.c1067
-rw-r--r--kernel/futex_compat.c14
-rw-r--r--kernel/hrtimer.c4
-rw-r--r--kernel/irq/Makefile2
-rw-r--r--kernel/irq/autoprobe.c56
-rw-r--r--kernel/irq/chip.c525
-rw-r--r--kernel/irq/handle.c118
-rw-r--r--kernel/irq/internals.h46
-rw-r--r--kernel/irq/manage.c156
-rw-r--r--kernel/irq/migration.c20
-rw-r--r--kernel/irq/proc.c30
-rw-r--r--kernel/irq/resend.c78
-rw-r--r--kernel/irq/spurious.c33
-rw-r--r--kernel/kexec.c6
-rw-r--r--kernel/module.c101
-rw-r--r--kernel/mutex-debug.c5
-rw-r--r--kernel/power/Kconfig13
-rw-r--r--kernel/profile.c2
-rw-r--r--kernel/rcupdate.c14
-rw-r--r--kernel/rcutorture.c201
-rw-r--r--kernel/resource.c90
-rw-r--r--kernel/rtmutex-debug.c513
-rw-r--r--kernel/rtmutex-debug.h37
-rw-r--r--kernel/rtmutex-tester.c440
-rw-r--r--kernel/rtmutex.c990
-rw-r--r--kernel/rtmutex.h29
-rw-r--r--kernel/rtmutex_common.h123
-rw-r--r--kernel/sched.c1199
-rw-r--r--kernel/softirq.c4
-rw-r--r--kernel/softlockup.c4
-rw-r--r--kernel/sysctl.c27
-rw-r--r--kernel/timer.c4
-rw-r--r--kernel/workqueue.c2
-rw-r--r--lib/Kconfig6
-rw-r--r--lib/Kconfig.debug34
-rw-r--r--lib/Makefile1
-rw-r--r--lib/plist.c118
-rw-r--r--lib/vsprintf.c2
-rw-r--r--lib/zlib_inflate/inffast.c6
-rw-r--r--lib/zlib_inflate/inftrees.c9
-rw-r--r--mm/Kconfig9
-rw-r--r--mm/filemap.c31
-rw-r--r--mm/filemap.h4
-rw-r--r--mm/filemap_xip.c2
-rw-r--r--mm/memory_hotplug.c126
-rw-r--r--mm/page-writeback.c4
-rw-r--r--mm/page_alloc.c8
-rw-r--r--mm/shmem.c9
-rw-r--r--mm/slab.c21
-rw-r--r--mm/sparse.c2
-rw-r--r--mm/swap_state.c2
-rw-r--r--mm/tiny-shmem.c4
-rw-r--r--mm/vmscan.c39
-rw-r--r--net/bluetooth/rfcomm/tty.c11
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/irda/ircomm/ircomm_tty.c1
-rw-r--r--net/irda/irnet/irnet.h1
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seal.c2
-rw-r--r--net/tipc/bcast.c4
-rw-r--r--net/tipc/bearer.c2
-rw-r--r--net/tipc/config.c2
-rw-r--r--net/tipc/dbg.c2
-rw-r--r--net/tipc/handler.c2
-rw-r--r--net/tipc/name_table.c4
-rw-r--r--net/tipc/net.c2
-rw-r--r--net/tipc/node.c2
-rw-r--r--net/tipc/port.c4
-rw-r--r--net/tipc/ref.c4
-rw-r--r--net/tipc/subscr.c2
-rw-r--r--net/tipc/user_reg.c2
-rw-r--r--scripts/Kbuild.include5
-rw-r--r--scripts/Makefile.build2
-rw-r--r--scripts/Makefile.host6
-rw-r--r--scripts/Makefile.lib6
-rw-r--r--scripts/Makefile.modpost2
-rw-r--r--scripts/rt-tester/check-all.sh22
-rw-r--r--scripts/rt-tester/rt-tester.py222
-rw-r--r--scripts/rt-tester/t2-l1-2rt-sameprio.tst99
-rw-r--r--scripts/rt-tester/t2-l1-pi.tst82
-rw-r--r--scripts/rt-tester/t2-l1-signal.tst77
-rw-r--r--scripts/rt-tester/t2-l2-2rt-deadlock.tst89
-rw-r--r--scripts/rt-tester/t3-l1-pi-1rt.tst92
-rw-r--r--scripts/rt-tester/t3-l1-pi-2rt.tst93
-rw-r--r--scripts/rt-tester/t3-l1-pi-3rt.tst92
-rw-r--r--scripts/rt-tester/t3-l1-pi-signal.tst98
-rw-r--r--scripts/rt-tester/t3-l1-pi-steal.tst96
-rw-r--r--scripts/rt-tester/t3-l2-pi.tst92
-rw-r--r--scripts/rt-tester/t4-l2-pi-deboost.tst123
-rw-r--r--scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst183
-rw-r--r--scripts/rt-tester/t5-l4-pi-boost-deboost.tst143
-rw-r--r--security/keys/internal.h1
-rw-r--r--security/keys/key.c3
-rw-r--r--security/keys/keyctl.c2
-rw-r--r--security/keys/request_key.c44
-rw-r--r--security/selinux/hooks.c6
-rw-r--r--sound/Makefile3
-rw-r--r--sound/aoa/Kconfig3
-rw-r--r--sound/aoa/core/snd-aoa-gpio-feature.c15
-rw-r--r--sound/aoa/fabrics/snd-aoa-fabric-layout.c14
-rw-r--r--sound/aoa/soundbus/Kconfig3
-rw-r--r--sound/arm/aaci.c5
-rw-r--r--sound/core/Kconfig4
-rw-r--r--sound/core/info.c1
-rw-r--r--sound/core/seq/seq_ports.c6
-rw-r--r--sound/core/sound.c24
-rw-r--r--sound/drivers/mpu401/mpu401.c5
-rw-r--r--sound/i2c/other/ak4xxx-adda.c284
-rw-r--r--sound/isa/es18xx.c3
-rw-r--r--sound/isa/gus/interwave.c8
-rw-r--r--sound/isa/sb/sb16.c3
-rw-r--r--sound/oss/Kconfig13
-rw-r--r--sound/oss/cs4232.c2
-rw-r--r--sound/oss/forte.c5
-rw-r--r--sound/oss/soundcard.c16
-rw-r--r--sound/oss/via82cxxx_audio.c7
-rw-r--r--sound/pci/Kconfig141
-rw-r--r--sound/pci/Makefile1
-rw-r--r--sound/pci/ac97/ac97_patch.c2
-rw-r--r--sound/pci/bt87x.c5
-rw-r--r--sound/pci/echoaudio/Makefile30
-rw-r--r--sound/pci/echoaudio/darla20.c99
-rw-r--r--sound/pci/echoaudio/darla20_dsp.c125
-rw-r--r--sound/pci/echoaudio/darla24.c106
-rw-r--r--sound/pci/echoaudio/darla24_dsp.c156
-rw-r--r--sound/pci/echoaudio/echo3g.c118
-rw-r--r--sound/pci/echoaudio/echo3g_dsp.c131
-rw-r--r--sound/pci/echoaudio/echoaudio.c2196
-rw-r--r--sound/pci/echoaudio/echoaudio.h590
-rw-r--r--sound/pci/echoaudio/echoaudio_3g.c431
-rw-r--r--sound/pci/echoaudio/echoaudio_dsp.c1125
-rw-r--r--sound/pci/echoaudio/echoaudio_dsp.h694
-rw-r--r--sound/pci/echoaudio/echoaudio_gml.c198
-rw-r--r--sound/pci/echoaudio/gina20.c103
-rw-r--r--sound/pci/echoaudio/gina20_dsp.c215
-rw-r--r--sound/pci/echoaudio/gina24.c123
-rw-r--r--sound/pci/echoaudio/gina24_dsp.c346
-rw-r--r--sound/pci/echoaudio/indigo.c104
-rw-r--r--sound/pci/echoaudio/indigo_dsp.c170
-rw-r--r--sound/pci/echoaudio/indigodj.c104
-rw-r--r--sound/pci/echoaudio/indigodj_dsp.c170
-rw-r--r--sound/pci/echoaudio/indigoio.c105
-rw-r--r--sound/pci/echoaudio/indigoio_dsp.c141
-rw-r--r--sound/pci/echoaudio/layla20.c112
-rw-r--r--sound/pci/echoaudio/layla20_dsp.c290
-rw-r--r--sound/pci/echoaudio/layla24.c121
-rw-r--r--sound/pci/echoaudio/layla24_dsp.c394
-rw-r--r--sound/pci/echoaudio/mia.c117
-rw-r--r--sound/pci/echoaudio/mia_dsp.c229
-rw-r--r--sound/pci/echoaudio/midi.c327
-rw-r--r--sound/pci/echoaudio/mona.c129
-rw-r--r--sound/pci/echoaudio/mona_dsp.c428
-rw-r--r--sound/pci/hda/hda_codec.c4
-rw-r--r--sound/pci/hda/patch_analog.c2
-rw-r--r--sound/pci/hda/patch_realtek.c1084
-rw-r--r--sound/pci/hda/patch_sigmatel.c110
-rw-r--r--sound/pci/ice1712/revo.c23
-rw-r--r--sound/pci/sonicvibes.c4
-rw-r--r--sound/ppc/pmac.c14
-rw-r--r--sound/ppc/toonie.c0
-rw-r--r--sound/sound_core.c6
-rw-r--r--sound/sparc/cs4231.c4
-rw-r--r--sound/sparc/dbri.c4
-rw-r--r--sound/usb/usbaudio.c32
1387 files changed, 50164 insertions, 18063 deletions
diff --git a/CREDITS b/CREDITS
index 85c7c70b7044..66b9e7a9abff 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3401,10 +3401,10 @@ S: Czech Republic
3401 3401
3402N: Thibaut Varene 3402N: Thibaut Varene
3403E: T-Bone@parisc-linux.org 3403E: T-Bone@parisc-linux.org
3404W: http://www.parisc-linux.org/ 3404W: http://www.parisc-linux.org/~varenet/
3405P: 1024D/B7D2F063 E67C 0D43 A75E 12A5 BB1C FA2F 1E32 C3DA B7D2 F063 3405P: 1024D/B7D2F063 E67C 0D43 A75E 12A5 BB1C FA2F 1E32 C3DA B7D2 F063
3406D: PA-RISC port minion, PDC and GSCPS2 drivers, debuglocks and other bits 3406D: PA-RISC port minion, PDC and GSCPS2 drivers, debuglocks and other bits
3407D: Some bits in an ARM port, S1D13XXX FB driver, random patches here and there 3407D: Some ARM at91rm9200 bits, S1D13XXX FB driver, random patches here and there
3408D: AD1889 sound driver 3408D: AD1889 sound driver
3409S: Paris, France 3409S: Paris, France
3410 3410
diff --git a/Documentation/Changes b/Documentation/Changes
index b02f476c2973..488272074c36 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -181,8 +181,8 @@ Intel IA32 microcode
181-------------------- 181--------------------
182 182
183A driver has been added to allow updating of Intel IA32 microcode, 183A driver has been added to allow updating of Intel IA32 microcode,
184accessible as both a devfs regular file and as a normal (misc) 184accessible as a normal (misc) character device. If you are not using
185character device. If you are not using devfs you may need to: 185udev you may need to:
186 186
187mkdir /dev/cpu 187mkdir /dev/cpu
188mknod /dev/cpu/microcode c 10 184 188mknod /dev/cpu/microcode c 10 184
@@ -201,7 +201,9 @@ with programs using shared memory.
201udev 201udev
202---- 202----
203udev is a userspace application for populating /dev dynamically with 203udev is a userspace application for populating /dev dynamically with
204only entries for devices actually present. udev replaces devfs. 204only entries for devices actually present. udev replaces the basic
205functionality of devfs, while allowing persistant device naming for
206devices.
205 207
206FUSE 208FUSE
207---- 209----
@@ -231,18 +233,13 @@ The PPP driver has been restructured to support multilink and to
231enable it to operate over diverse media layers. If you use PPP, 233enable it to operate over diverse media layers. If you use PPP,
232upgrade pppd to at least 2.4.0. 234upgrade pppd to at least 2.4.0.
233 235
234If you are not using devfs, you must have the device file /dev/ppp 236If you are not using udev, you must have the device file /dev/ppp
235which can be made by: 237which can be made by:
236 238
237mknod /dev/ppp c 108 0 239mknod /dev/ppp c 108 0
238 240
239as root. 241as root.
240 242
241If you use devfsd and build ppp support as modules, you will need
242the following in your /etc/devfsd.conf file:
243
244LOOKUP PPP MODLOAD
245
246Isdn4k-utils 243Isdn4k-utils
247------------ 244------------
248 245
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 5a2882d275ba..66e1cf733571 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -10,7 +10,8 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 procfs-guide.xml writing_usb_driver.xml \ 11 procfs-guide.xml writing_usb_driver.xml \
12 kernel-api.xml journal-api.xml lsm.xml usb.xml \ 12 kernel-api.xml journal-api.xml lsm.xml usb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml
14 15
15### 16###
16# The build process is as follows (targets): 17# The build process is as follows (targets):
diff --git a/Documentation/DocBook/genericirq.tmpl b/Documentation/DocBook/genericirq.tmpl
new file mode 100644
index 000000000000..0f4a4b6321e4
--- /dev/null
+++ b/Documentation/DocBook/genericirq.tmpl
@@ -0,0 +1,474 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="Generic-IRQ-Guide">
6 <bookinfo>
7 <title>Linux generic IRQ handling</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Thomas</firstname>
12 <surname>Gleixner</surname>
13 <affiliation>
14 <address>
15 <email>tglx@linutronix.de</email>
16 </address>
17 </affiliation>
18 </author>
19 <author>
20 <firstname>Ingo</firstname>
21 <surname>Molnar</surname>
22 <affiliation>
23 <address>
24 <email>mingo@elte.hu</email>
25 </address>
26 </affiliation>
27 </author>
28 </authorgroup>
29
30 <copyright>
31 <year>2005-2006</year>
32 <holder>Thomas Gleixner</holder>
33 </copyright>
34 <copyright>
35 <year>2005-2006</year>
36 <holder>Ingo Molnar</holder>
37 </copyright>
38
39 <legalnotice>
40 <para>
41 This documentation is free software; you can redistribute
42 it and/or modify it under the terms of the GNU General Public
43 License version 2 as published by the Free Software Foundation.
44 </para>
45
46 <para>
47 This program is distributed in the hope that it will be
48 useful, but WITHOUT ANY WARRANTY; without even the implied
49 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
50 See the GNU General Public License for more details.
51 </para>
52
53 <para>
54 You should have received a copy of the GNU General Public
55 License along with this program; if not, write to the Free
56 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
57 MA 02111-1307 USA
58 </para>
59
60 <para>
61 For more details see the file COPYING in the source
62 distribution of Linux.
63 </para>
64 </legalnotice>
65 </bookinfo>
66
67<toc></toc>
68
69 <chapter id="intro">
70 <title>Introduction</title>
71 <para>
72 The generic interrupt handling layer is designed to provide a
73 complete abstraction of interrupt handling for device drivers.
74 It is able to handle all the different types of interrupt controller
75 hardware. Device drivers use generic API functions to request, enable,
76 disable and free interrupts. The drivers do not have to know anything
77 about interrupt hardware details, so they can be used on different
78 platforms without code changes.
79 </para>
80 <para>
81 This documentation is provided to developers who want to implement
82 an interrupt subsystem based for their architecture, with the help
83 of the generic IRQ handling layer.
84 </para>
85 </chapter>
86
87 <chapter id="rationale">
88 <title>Rationale</title>
89 <para>
90 The original implementation of interrupt handling in Linux is using
91 the __do_IRQ() super-handler, which is able to deal with every
92 type of interrupt logic.
93 </para>
94 <para>
95 Originally, Russell King identified different types of handlers to
96 build a quite universal set for the ARM interrupt handler
97 implementation in Linux 2.5/2.6. He distinguished between:
98 <itemizedlist>
99 <listitem><para>Level type</para></listitem>
100 <listitem><para>Edge type</para></listitem>
101 <listitem><para>Simple type</para></listitem>
102 </itemizedlist>
103 In the SMP world of the __do_IRQ() super-handler another type
104 was identified:
105 <itemizedlist>
106 <listitem><para>Per CPU type</para></listitem>
107 </itemizedlist>
108 </para>
109 <para>
110 This split implementation of highlevel IRQ handlers allows us to
111 optimize the flow of the interrupt handling for each specific
112 interrupt type. This reduces complexity in that particular codepath
113 and allows the optimized handling of a given type.
114 </para>
115 <para>
116 The original general IRQ implementation used hw_interrupt_type
117 structures and their ->ack(), ->end() [etc.] callbacks to
118 differentiate the flow control in the super-handler. This leads to
119 a mix of flow logic and lowlevel hardware logic, and it also leads
120 to unnecessary code duplication: for example in i386, there is a
121 ioapic_level_irq and a ioapic_edge_irq irq-type which share many
122 of the lowlevel details but have different flow handling.
123 </para>
124 <para>
125 A more natural abstraction is the clean separation of the
126 'irq flow' and the 'chip details'.
127 </para>
128 <para>
129 Analysing a couple of architecture's IRQ subsystem implementations
130 reveals that most of them can use a generic set of 'irq flow'
131 methods and only need to add the chip level specific code.
132 The separation is also valuable for (sub)architectures
133 which need specific quirks in the irq flow itself but not in the
134 chip-details - and thus provides a more transparent IRQ subsystem
135 design.
136 </para>
137 <para>
138 Each interrupt descriptor is assigned its own highlevel flow
139 handler, which is normally one of the generic
140 implementations. (This highlevel flow handler implementation also
141 makes it simple to provide demultiplexing handlers which can be
142 found in embedded platforms on various architectures.)
143 </para>
144 <para>
145 The separation makes the generic interrupt handling layer more
146 flexible and extensible. For example, an (sub)architecture can
147 use a generic irq-flow implementation for 'level type' interrupts
148 and add a (sub)architecture specific 'edge type' implementation.
149 </para>
150 <para>
151 To make the transition to the new model easier and prevent the
152 breakage of existing implementations, the __do_IRQ() super-handler
153 is still available. This leads to a kind of duality for the time
154 being. Over time the new model should be used in more and more
155 architectures, as it enables smaller and cleaner IRQ subsystems.
156 </para>
157 </chapter>
158 <chapter id="bugs">
159 <title>Known Bugs And Assumptions</title>
160 <para>
161 None (knock on wood).
162 </para>
163 </chapter>
164
165 <chapter id="Abstraction">
166 <title>Abstraction layers</title>
167 <para>
168 There are three main levels of abstraction in the interrupt code:
169 <orderedlist>
170 <listitem><para>Highlevel driver API</para></listitem>
171 <listitem><para>Highlevel IRQ flow handlers</para></listitem>
172 <listitem><para>Chiplevel hardware encapsulation</para></listitem>
173 </orderedlist>
174 </para>
175 <sect1>
176 <title>Interrupt control flow</title>
177 <para>
178 Each interrupt is described by an interrupt descriptor structure
179 irq_desc. The interrupt is referenced by an 'unsigned int' numeric
180 value which selects the corresponding interrupt decription structure
181 in the descriptor structures array.
182 The descriptor structure contains status information and pointers
183 to the interrupt flow method and the interrupt chip structure
184 which are assigned to this interrupt.
185 </para>
186 <para>
187 Whenever an interrupt triggers, the lowlevel arch code calls into
188 the generic interrupt code by calling desc->handle_irq().
189 This highlevel IRQ handling function only uses desc->chip primitives
190 referenced by the assigned chip descriptor structure.
191 </para>
192 </sect1>
193 <sect1>
194 <title>Highlevel Driver API</title>
195 <para>
196 The highlevel Driver API consists of following functions:
197 <itemizedlist>
198 <listitem><para>request_irq()</para></listitem>
199 <listitem><para>free_irq()</para></listitem>
200 <listitem><para>disable_irq()</para></listitem>
201 <listitem><para>enable_irq()</para></listitem>
202 <listitem><para>disable_irq_nosync() (SMP only)</para></listitem>
203 <listitem><para>synchronize_irq() (SMP only)</para></listitem>
204 <listitem><para>set_irq_type()</para></listitem>
205 <listitem><para>set_irq_wake()</para></listitem>
206 <listitem><para>set_irq_data()</para></listitem>
207 <listitem><para>set_irq_chip()</para></listitem>
208 <listitem><para>set_irq_chip_data()</para></listitem>
209 </itemizedlist>
210 See the autogenerated function documentation for details.
211 </para>
212 </sect1>
213 <sect1>
214 <title>Highlevel IRQ flow handlers</title>
215 <para>
216 The generic layer provides a set of pre-defined irq-flow methods:
217 <itemizedlist>
218 <listitem><para>handle_level_irq</para></listitem>
219 <listitem><para>handle_edge_irq</para></listitem>
220 <listitem><para>handle_simple_irq</para></listitem>
221 <listitem><para>handle_percpu_irq</para></listitem>
222 </itemizedlist>
223 The interrupt flow handlers (either predefined or architecture
224 specific) are assigned to specific interrupts by the architecture
225 either during bootup or during device initialization.
226 </para>
227 <sect2>
228 <title>Default flow implementations</title>
229 <sect3>
230 <title>Helper functions</title>
231 <para>
232 The helper functions call the chip primitives and
233 are used by the default flow implementations.
234 The following helper functions are implemented (simplified excerpt):
235 <programlisting>
236default_enable(irq)
237{
238 desc->chip->unmask(irq);
239}
240
241default_disable(irq)
242{
243 if (!delay_disable(irq))
244 desc->chip->mask(irq);
245}
246
247default_ack(irq)
248{
249 chip->ack(irq);
250}
251
252default_mask_ack(irq)
253{
254 if (chip->mask_ack) {
255 chip->mask_ack(irq);
256 } else {
257 chip->mask(irq);
258 chip->ack(irq);
259 }
260}
261
262noop(irq)
263{
264}
265
266 </programlisting>
267 </para>
268 </sect3>
269 </sect2>
270 <sect2>
271 <title>Default flow handler implementations</title>
272 <sect3>
273 <title>Default Level IRQ flow handler</title>
274 <para>
275 handle_level_irq provides a generic implementation
276 for level-triggered interrupts.
277 </para>
278 <para>
279 The following control flow is implemented (simplified excerpt):
280 <programlisting>
281desc->chip->start();
282handle_IRQ_event(desc->action);
283desc->chip->end();
284 </programlisting>
285 </para>
286 </sect3>
287 <sect3>
288 <title>Default Edge IRQ flow handler</title>
289 <para>
290 handle_edge_irq provides a generic implementation
291 for edge-triggered interrupts.
292 </para>
293 <para>
294 The following control flow is implemented (simplified excerpt):
295 <programlisting>
296if (desc->status &amp; running) {
297 desc->chip->hold();
298 desc->status |= pending | masked;
299 return;
300}
301desc->chip->start();
302desc->status |= running;
303do {
304 if (desc->status &amp; masked)
305 desc->chip->enable();
306 desc-status &amp;= ~pending;
307 handle_IRQ_event(desc->action);
308} while (status &amp; pending);
309desc-status &amp;= ~running;
310desc->chip->end();
311 </programlisting>
312 </para>
313 </sect3>
314 <sect3>
315 <title>Default simple IRQ flow handler</title>
316 <para>
317 handle_simple_irq provides a generic implementation
318 for simple interrupts.
319 </para>
320 <para>
321 Note: The simple flow handler does not call any
322 handler/chip primitives.
323 </para>
324 <para>
325 The following control flow is implemented (simplified excerpt):
326 <programlisting>
327handle_IRQ_event(desc->action);
328 </programlisting>
329 </para>
330 </sect3>
331 <sect3>
332 <title>Default per CPU flow handler</title>
333 <para>
334 handle_percpu_irq provides a generic implementation
335 for per CPU interrupts.
336 </para>
337 <para>
338 Per CPU interrupts are only available on SMP and
339 the handler provides a simplified version without
340 locking.
341 </para>
342 <para>
343 The following control flow is implemented (simplified excerpt):
344 <programlisting>
345desc->chip->start();
346handle_IRQ_event(desc->action);
347desc->chip->end();
348 </programlisting>
349 </para>
350 </sect3>
351 </sect2>
352 <sect2>
353 <title>Quirks and optimizations</title>
354 <para>
355 The generic functions are intended for 'clean' architectures and chips,
356 which have no platform-specific IRQ handling quirks. If an architecture
357 needs to implement quirks on the 'flow' level then it can do so by
358 overriding the highlevel irq-flow handler.
359 </para>
360 </sect2>
361 <sect2>
362 <title>Delayed interrupt disable</title>
363 <para>
364 This per interrupt selectable feature, which was introduced by Russell
365 King in the ARM interrupt implementation, does not mask an interrupt
366 at the hardware level when disable_irq() is called. The interrupt is
367 kept enabled and is masked in the flow handler when an interrupt event
368 happens. This prevents losing edge interrupts on hardware which does
369 not store an edge interrupt event while the interrupt is disabled at
370 the hardware level. When an interrupt arrives while the IRQ_DISABLED
371 flag is set, then the interrupt is masked at the hardware level and
372 the IRQ_PENDING bit is set. When the interrupt is re-enabled by
373 enable_irq() the pending bit is checked and if it is set, the
374 interrupt is resent either via hardware or by a software resend
375 mechanism. (It's necessary to enable CONFIG_HARDIRQS_SW_RESEND when
376 you want to use the delayed interrupt disable feature and your
377 hardware is not capable of retriggering an interrupt.)
378 The delayed interrupt disable can be runtime enabled, per interrupt,
379 by setting the IRQ_DELAYED_DISABLE flag in the irq_desc status field.
380 </para>
381 </sect2>
382 </sect1>
383 <sect1>
384 <title>Chiplevel hardware encapsulation</title>
385 <para>
386 The chip level hardware descriptor structure irq_chip
387 contains all the direct chip relevant functions, which
388 can be utilized by the irq flow implementations.
389 <itemizedlist>
390 <listitem><para>ack()</para></listitem>
391 <listitem><para>mask_ack() - Optional, recommended for performance</para></listitem>
392 <listitem><para>mask()</para></listitem>
393 <listitem><para>unmask()</para></listitem>
394 <listitem><para>retrigger() - Optional</para></listitem>
395 <listitem><para>set_type() - Optional</para></listitem>
396 <listitem><para>set_wake() - Optional</para></listitem>
397 </itemizedlist>
398 These primitives are strictly intended to mean what they say: ack means
399 ACK, masking means masking of an IRQ line, etc. It is up to the flow
400 handler(s) to use these basic units of lowlevel functionality.
401 </para>
402 </sect1>
403 </chapter>
404
405 <chapter id="doirq">
406 <title>__do_IRQ entry point</title>
407 <para>
408 The original implementation __do_IRQ() is an alternative entry
409 point for all types of interrupts.
410 </para>
411 <para>
412 This handler turned out to be not suitable for all
413 interrupt hardware and was therefore reimplemented with split
414 functionality for egde/level/simple/percpu interrupts. This is not
415 only a functional optimization. It also shortens code paths for
416 interrupts.
417 </para>
418 <para>
419 To make use of the split implementation, replace the call to
420 __do_IRQ by a call to desc->chip->handle_irq() and associate
421 the appropriate handler function to desc->chip->handle_irq().
422 In most cases the generic handler implementations should
423 be sufficient.
424 </para>
425 </chapter>
426
427 <chapter id="locking">
428 <title>Locking on SMP</title>
429 <para>
430 The locking of chip registers is up to the architecture that
431 defines the chip primitives. There is a chip->lock field that can be used
432 for serialization, but the generic layer does not touch it. The per-irq
433 structure is protected via desc->lock, by the generic layer.
434 </para>
435 </chapter>
436 <chapter id="structs">
437 <title>Structures</title>
438 <para>
439 This chapter contains the autogenerated documentation of the structures which are
440 used in the generic IRQ layer.
441 </para>
442!Iinclude/linux/irq.h
443 </chapter>
444
445 <chapter id="pubfunctions">
446 <title>Public Functions Provided</title>
447 <para>
448 This chapter contains the autogenerated documentation of the kernel API functions
449 which are exported.
450 </para>
451!Ekernel/irq/manage.c
452!Ekernel/irq/chip.c
453 </chapter>
454
455 <chapter id="intfunctions">
456 <title>Internal Functions Provided</title>
457 <para>
458 This chapter contains the autogenerated documentation of the internal functions.
459 </para>
460!Ikernel/irq/handle.c
461!Ikernel/irq/chip.c
462 </chapter>
463
464 <chapter id="credits">
465 <title>Credits</title>
466 <para>
467 The following people have contributed to this document:
468 <orderedlist>
469 <listitem><para>Thomas Gleixner<email>tglx@linutronix.de</email></para></listitem>
470 <listitem><para>Ingo Molnar<email>mingo@elte.hu</email></para></listitem>
471 </orderedlist>
472 </para>
473 </chapter>
474</book>
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 3630a0d7695f..1ae4dc0fd856 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -348,11 +348,6 @@ X!Earch/i386/kernel/mca.c
348 </sect1> 348 </sect1>
349 </chapter> 349 </chapter>
350 350
351 <chapter id="devfs">
352 <title>The Device File System</title>
353!Efs/devfs/base.c
354 </chapter>
355
356 <chapter id="sysfs"> 351 <chapter id="sysfs">
357 <title>The Filesystem for Exporting Kernel Objects</title> 352 <title>The Filesystem for Exporting Kernel Objects</title>
358!Efs/sysfs/file.c 353!Efs/sysfs/file.c
diff --git a/Documentation/IRQ.txt b/Documentation/IRQ.txt
new file mode 100644
index 000000000000..1011e7175021
--- /dev/null
+++ b/Documentation/IRQ.txt
@@ -0,0 +1,22 @@
1What is an IRQ?
2
3An IRQ is an interrupt request from a device.
4Currently they can come in over a pin, or over a packet.
5Several devices may be connected to the same pin thus
6sharing an IRQ.
7
8An IRQ number is a kernel identifier used to talk about a hardware
9interrupt source. Typically this is an index into the global irq_desc
10array, but except for what linux/interrupt.h implements the details
11are architecture specific.
12
13An IRQ number is an enumeration of the possible interrupt sources on a
14machine. Typically what is enumerated is the number of input pins on
15all of the interrupt controller in the system. In the case of ISA
16what is enumerated are the 16 input pins on the two i8259 interrupt
17controllers.
18
19Architectures can assign additional meaning to the IRQ numbers, and
20are encouraged to in the case where there is any manual configuration
21of the hardware involved. The ISA IRQs are a classic example of
22assigning this kind of additional meaning.
diff --git a/Documentation/RCU/torture.txt b/Documentation/RCU/torture.txt
index e4c38152f7f7..a4948591607d 100644
--- a/Documentation/RCU/torture.txt
+++ b/Documentation/RCU/torture.txt
@@ -7,7 +7,7 @@ The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
7implementations. It creates an rcutorture kernel module that can 7implementations. It creates an rcutorture kernel module that can
8be loaded to run a torture test. The test periodically outputs 8be loaded to run a torture test. The test periodically outputs
9status messages via printk(), which can be examined via the dmesg 9status messages via printk(), which can be examined via the dmesg
10command (perhaps grepping for "rcutorture"). The test is started 10command (perhaps grepping for "torture"). The test is started
11when the module is loaded, and stops when the module is unloaded. 11when the module is loaded, and stops when the module is unloaded.
12 12
13However, actually setting this config option to "y" results in the system 13However, actually setting this config option to "y" results in the system
@@ -35,6 +35,19 @@ stat_interval The number of seconds between output of torture
35 be printed -only- when the module is unloaded, and this 35 be printed -only- when the module is unloaded, and this
36 is the default. 36 is the default.
37 37
38shuffle_interval
39 The number of seconds to keep the test threads affinitied
40 to a particular subset of the CPUs. Used in conjunction
41 with test_no_idle_hz.
42
43test_no_idle_hz Whether or not to test the ability of RCU to operate in
44 a kernel that disables the scheduling-clock interrupt to
45 idle CPUs. Boolean parameter, "1" to test, "0" otherwise.
46
47torture_type The type of RCU to test: "rcu" for the rcu_read_lock()
48 API, "rcu_bh" for the rcu_read_lock_bh() API, and "srcu"
49 for the "srcu_read_lock()" API.
50
38verbose Enable debug printk()s. Default is disabled. 51verbose Enable debug printk()s. Default is disabled.
39 52
40 53
@@ -42,14 +55,14 @@ OUTPUT
42 55
43The statistics output is as follows: 56The statistics output is as follows:
44 57
45 rcutorture: --- Start of test: nreaders=16 stat_interval=0 verbose=0 58 rcu-torture: --- Start of test: nreaders=16 stat_interval=0 verbose=0
46 rcutorture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915 59 rcu-torture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915
47 rcutorture: Reader Pipe: 1466408 9747 0 0 0 0 0 0 0 0 0 60 rcu-torture: Reader Pipe: 1466408 9747 0 0 0 0 0 0 0 0 0
48 rcutorture: Reader Batch: 1464477 11678 0 0 0 0 0 0 0 0 61 rcu-torture: Reader Batch: 1464477 11678 0 0 0 0 0 0 0 0
49 rcutorture: Free-Block Circulation: 1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0 62 rcu-torture: Free-Block Circulation: 1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0
50 rcutorture: --- End of test 63 rcu-torture: --- End of test
51 64
52The command "dmesg | grep rcutorture:" will extract this information on 65The command "dmesg | grep torture:" will extract this information on
53most systems. On more esoteric configurations, it may be necessary to 66most systems. On more esoteric configurations, it may be necessary to
54use other commands to access the output of the printk()s used by 67use other commands to access the output of the printk()s used by
55the RCU torture test. The printk()s use KERN_ALERT, so they should 68the RCU torture test. The printk()s use KERN_ALERT, so they should
@@ -115,8 +128,9 @@ The following script may be used to torture RCU:
115 modprobe rcutorture 128 modprobe rcutorture
116 sleep 100 129 sleep 100
117 rmmod rcutorture 130 rmmod rcutorture
118 dmesg | grep rcutorture: 131 dmesg | grep torture:
119 132
120The output can be manually inspected for the error flag of "!!!". 133The output can be manually inspected for the error flag of "!!!".
121One could of course create a more elaborate script that automatically 134One could of course create a more elaborate script that automatically
122checked for such errors. 135checked for such errors. The "rmmod" command forces a "SUCCESS" or
136"FAILURE" indication to be printk()ed.
diff --git a/Documentation/README.DAC960 b/Documentation/README.DAC960
index 98ea617a0dd6..0e8f618ab534 100644
--- a/Documentation/README.DAC960
+++ b/Documentation/README.DAC960
@@ -78,9 +78,9 @@ also known as "System Drives", and Drive Groups are also called "Packs". Both
78terms are in use in the Mylex documentation; I have chosen to standardize on 78terms are in use in the Mylex documentation; I have chosen to standardize on
79the more generic "Logical Drive" and "Drive Group". 79the more generic "Logical Drive" and "Drive Group".
80 80
81DAC960 RAID disk devices are named in the style of the Device File System 81DAC960 RAID disk devices are named in the style of the obsolete Device File
82(DEVFS). The device corresponding to Logical Drive D on Controller C is 82System (DEVFS). The device corresponding to Logical Drive D on Controller C
83referred to as /dev/rd/cCdD, and the partitions are called /dev/rd/cCdDp1 83is referred to as /dev/rd/cCdD, and the partitions are called /dev/rd/cCdDp1
84through /dev/rd/cCdDp7. For example, partition 3 of Logical Drive 5 on 84through /dev/rd/cCdDp7. For example, partition 3 of Logical Drive 5 on
85Controller 2 is referred to as /dev/rd/c2d5p3. Note that unlike with SCSI 85Controller 2 is referred to as /dev/rd/c2d5p3. Note that unlike with SCSI
86disks the device names will not change in the event of a disk drive failure. 86disks the device names will not change in the event of a disk drive failure.
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 027285d0c26c..1cbbb8e28999 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -6,17 +6,6 @@ be removed from this file.
6 6
7--------------------------- 7---------------------------
8 8
9What: devfs
10When: July 2005
11Files: fs/devfs/*, include/linux/devfs_fs*.h and assorted devfs
12 function calls throughout the kernel tree
13Why: It has been unmaintained for a number of years, has unfixable
14 races, contains a naming policy within the kernel that is
15 against the LSB, and can be replaced by using udev.
16Who: Greg Kroah-Hartman <greg@kroah.com>
17
18---------------------------
19
20What: RAW driver (CONFIG_RAW_DRIVER) 9What: RAW driver (CONFIG_RAW_DRIVER)
21When: December 2005 10When: December 2005
22Why: declared obsolete since kernel 2.6.3 11Why: declared obsolete since kernel 2.6.3
@@ -132,16 +121,6 @@ Who: NeilBrown <neilb@suse.de>
132 121
133--------------------------- 122---------------------------
134 123
135What: au1x00_uart driver
136When: January 2006
137Why: The 8250 serial driver now has the ability to deal with the differences
138 between the standard 8250 family of UARTs and their slightly strange
139 brother on Alchemy SOCs. The loss of features is not considered an
140 issue.
141Who: Ralf Baechle <ralf@linux-mips.org>
142
143---------------------------
144
145What: eepro100 network driver 124What: eepro100 network driver
146When: January 2007 125When: January 2007
147Why: replaced by the e100 driver 126Why: replaced by the e100 driver
@@ -177,6 +156,16 @@ Who: Jean Delvare <khali@linux-fr.org>
177 156
178--------------------------- 157---------------------------
179 158
159What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
160 (temporary transition config option provided until then)
161 The transition config option will also be removed at the same time.
162When: before 2.6.19
163Why: Unused symbols are both increasing the size of the kernel binary
164 and are often a sign of "wrong API"
165Who: Arjan van de Ven <arjan@linux.intel.com>
166
167---------------------------
168
180What: remove EXPORT_SYMBOL(tasklist_lock) 169What: remove EXPORT_SYMBOL(tasklist_lock)
181When: August 2006 170When: August 2006
182Files: kernel/fork.c 171Files: kernel/fork.c
@@ -224,3 +213,47 @@ Why: The interface no longer has any callers left in the kernel. It
224Who: Nick Piggin <npiggin@suse.de> 213Who: Nick Piggin <npiggin@suse.de>
225 214
226--------------------------- 215---------------------------
216
217What: Support for the MIPS EV96100 evaluation board
218When: September 2006
219Why: Does no longer build since at least November 15, 2003, apparently
220 no userbase left.
221Who: Ralf Baechle <ralf@linux-mips.org>
222
223---------------------------
224
225What: Support for the Momentum / PMC-Sierra Jaguar ATX evaluation board
226When: September 2006
227Why: Does no longer build since quite some time, and was never popular,
228 due to the platform being replaced by successor models. Apparently
229 no user base left. It also is one of the last users of
230 WANT_PAGE_VIRTUAL.
231Who: Ralf Baechle <ralf@linux-mips.org>
232
233---------------------------
234
235What: Support for the Momentum Ocelot, Ocelot 3, Ocelot C and Ocelot G
236When: September 2006
237Why: Some do no longer build and apparently there is no user base left
238 for these platforms.
239Who: Ralf Baechle <ralf@linux-mips.org>
240
241---------------------------
242
243What: Support for MIPS Technologies' Altas and SEAD evaluation board
244When: September 2006
245Why: Some do no longer build and apparently there is no user base left
246 for these platforms. Hardware out of production since several years.
247Who: Ralf Baechle <ralf@linux-mips.org>
248
249---------------------------
250
251What: Support for the IT8172-based platforms, ITE 8172G and Globespan IVR
252When: September 2006
253Why: Code does no longer build since at least 2.6.0, apparently there is
254 no user base left for these platforms. Hardware out of production
255 since several years and hardly a trace of the manufacturer left on
256 the net.
257Who: Ralf Baechle <ralf@linux-mips.org>
258
259---------------------------
diff --git a/Documentation/filesystems/devfs/ChangeLog b/Documentation/filesystems/devfs/ChangeLog
deleted file mode 100644
index e5aba5246d7c..000000000000
--- a/Documentation/filesystems/devfs/ChangeLog
+++ /dev/null
@@ -1,1977 +0,0 @@
1/* -*- auto-fill -*- */
2===============================================================================
3Changes for patch v1
4
5- creation of devfs
6
7- modified miscellaneous character devices to support devfs
8===============================================================================
9Changes for patch v2
10
11- bug fix with manual inode creation
12===============================================================================
13Changes for patch v3
14
15- bugfixes
16
17- documentation improvements
18
19- created a couple of scripts (one to save&restore a devfs and the
20 other to set up compatibility symlinks)
21
22- devfs support for SCSI discs. New name format is: sd_hHcCiIlL
23===============================================================================
24Changes for patch v4
25
26- bugfix for the directory reading code
27
28- bugfix for compilation with kerneld
29
30- devfs support for generic hard discs
31
32- rationalisation of the various watchdog drivers
33===============================================================================
34Changes for patch v5
35
36- support for mounting directly from entries in the devfs (it doesn't
37 need to be mounted to do this), including the root filesystem.
38 Mounting of swap partitions also works. Hence, now if you set
39 CONFIG_DEVFS_ONLY to 'Y' then you won't be able to access your discs
40 via ordinary device nodes. Naturally, the default is 'N' so that you
41 can still use your old device nodes. If you want to mount from devfs
42 entries, make sure you use: append = "root=/dev/sd_..." in your
43 lilo.conf. It seems LILO looks for the device number (major&minor)
44 and writes that into the kernel image :-(
45
46- support for character memory devices (/dev/null, /dev/zero, /dev/full
47 and so on). Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
48===============================================================================
49Changes for patch v6
50
51- support for subdirectories
52
53- support for symbolic links (created by devfs_mk_symlink(), no
54 support yet for creation via symlink(2))
55
56- SCSI disc naming now cast in stone, with the format:
57 /dev/sd/c0b1t2u3 controller=0, bus=1, ID=2, LUN=3, whole disc
58 /dev/sd/c0b1t2u3p4 controller=0, bus=1, ID=2, LUN=3, 4th partition
59
60- loop devices now appear in devfs
61
62- tty devices, console, serial ports, etc. now appear in devfs
63 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
64
65- bugs with mounting devfs-only devices now fixed
66===============================================================================
67Changes for patch v7
68
69- SCSI CD-ROMS, tapes and generic devices now appear in devfs
70===============================================================================
71Changes for patch v8
72
73- bugfix with no-rewind SCSI tapes
74
75- RAMDISCs now appear in devfs
76
77- better cleaning up of devfs entries created by various modules
78
79- interface change to <devfs_register>
80===============================================================================
81Changes for patch v9
82
83- the v8 patch was corrupted somehow, which would affect the patch for
84 linux/fs/filesystems.c
85 I've also fixed the v8 patch file on the WWW
86
87- MetaDevices (/dev/md*) should now appear in devfs
88===============================================================================
89Changes for patch v10
90
91- bugfix in meta device support for devfs
92
93- created this ChangeLog file
94
95- added devfs support to the floppy driver
96
97- added support for creating sockets in a devfs
98===============================================================================
99Changes for patch v11
100
101- added DEVFS_FL_HIDE_UNREG flag
102
103- incorporated better patch for ttyname() in libc 5.4.43 from H.J. Lu.
104
105- interface change to <devfs_mk_symlink>
106
107- support for creating symlinks with symlink(2)
108
109- parallel port printer (/dev/lp*) now appears in devfs
110===============================================================================
111Changes for patch v12
112
113- added inode check to <devfs_fill_file> function
114
115- improved devfs support when mounting from devfs
116
117- added call to <<release>> operation when removing swap areas on
118 devfs devices
119
120- increased NR_SUPER to 128 to support large numbers of devfs mounts
121 (for chroot(2) gaols)
122
123- fixed bug in SCSI disc support: was generating incorrect minors if
124 SCSI ID's did not start at 0 and increase by 1
125
126- support symlink traversal when mounting root
127===============================================================================
128Changes for patch v13
129
130- added devfs support to soundcard driver
131 Thanks to Eric Dumas <dumas@linux.eu.org> and
132 C. Scott Ananian <cananian@alumni.princeton.edu>
133
134- added devfs support to the joystick driver
135
136- loop driver now has it's own subdirectory "/dev/loop/"
137
138- created <devfs_get_flags> and <devfs_set_flags> functions
139
140- fix problem with SCSI disc compatibility names (sd{a,b,c,d,e,f})
141 which assumes ID's start at 0 and increase by 1. Also only create
142 devfs entries for SCSI disc partitions which actually exist
143 Show new names in partition check
144 Thanks to Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>
145===============================================================================
146Changes for patch v14
147
148- bug fix in floppy driver: would not compile without
149 CONFIG_DEVFS_FS='Y'
150 Thanks to Jurgen Botz <jbotz@nova.botz.org>
151
152- bug fix in loop driver
153 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
154
155- do not create devfs entries for printers not configured
156 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
157
158- do not create devfs entries for serial ports not present
159 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
160
161- ensure <tty_register_devfs> is exported from tty_io.c
162 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
163
164- allow unregistering of devfs symlink entries
165
166- fixed bug in SCSI disc naming introduced in last patch version
167===============================================================================
168Changes for patch v15
169
170- ported to kernel 2.1.81
171===============================================================================
172Changes for patch v16
173
174- created <devfs_set_symlink_destination> function
175
176- moved DEVFS_SUPER_MAGIC into header file
177
178- added DEVFS_FL_HIDE flag
179
180- created <devfs_get_maj_min>
181
182- created <devfs_get_handle_from_inode>
183
184- fixed bugs in searching by major&minor
185
186- changed interface to <devfs_unregister>, <devfs_fill_file> and
187 <devfs_find_handle>
188
189- fixed inode times when symlink created with symlink(2)
190
191- change tty driver to do auto-creation of devfs entries
192 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
193
194- fixed bug in genhd.c: whole disc (non-SCSI) was not registered to
195 devfs
196
197- updated libc 5.4.43 patch for ttyname()
198===============================================================================
199Changes for patch v17
200
201- added CONFIG_DEVFS_TTY_COMPAT
202 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
203
204- bugfix in devfs support for drivers/char/lp.c
205 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
206
207- clean up serial driver so that PCMCIA devices unregister correctly
208 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
209
210- fixed bug in genhd.c: whole disc (non-SCSI) was not registered to
211 devfs [was missing in patch v16]
212
213- updated libc 5.4.43 patch for ttyname() [was missing in patch v16]
214
215- all SCSI devices now registered in /dev/sg
216
217- support removal of devfs entries via unlink(2)
218===============================================================================
219Changes for patch v18
220
221- added floppy/?u720 floppy entry
222
223- fixed kerneld support for entries in devfs subdirectories
224
225- incorporated latest patch for ttyname() in libc 5.4.43 from H.J. Lu.
226===============================================================================
227Changes for patch v19
228
229- bug fix when looking up unregistered entries: kerneld was not called
230
231- fixes for kernel 2.1.86 (now requires 2.1.86)
232===============================================================================
233Changes for patch v20
234
235- only create available floppy entries
236 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
237
238- new IDE naming scheme following SCSI format (i.e. /dev/id/c0b0t0u0p1
239 instead of /dev/hda1)
240 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
241
242- new XT disc naming scheme following SCSI format (i.e. /dev/xd/c0t0p1
243 instead of /dev/xda1)
244 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
245
246- new non-standard CD-ROM names (i.e. /dev/sbp/c#t#)
247 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
248
249- allow symlink traversal when mounting the root filesystem
250
251- Create entries for MD devices at MD init
252 Thanks to Christophe Leroy <christophe.leroy5@capway.com>
253===============================================================================
254Changes for patch v21
255
256- ported to kernel 2.1.91
257===============================================================================
258Changes for patch v22
259
260- SCSI host number patch ("scsihosts=" kernel option)
261 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
262===============================================================================
263Changes for patch v23
264
265- Fixed persistence bug with device numbers for manually created
266 device files
267
268- Fixed problem with recreating symlinks with different content
269
270- Added CONFIG_DEVFS_MOUNT (mount devfs on /dev at boot time)
271===============================================================================
272Changes for patch v24
273
274- Switched from CONFIG_KERNELD to CONFIG_KMOD: module autoloading
275 should now work again
276
277- Hide entries which are manually unlinked
278
279- Always invalidate devfs dentry cache when registering entries
280
281- Support removal of devfs directories via rmdir(2)
282
283- Ensure directories created by <devfs_mk_dir> are visible
284
285- Default no access for "other" for floppy device
286===============================================================================
287Changes for patch v25
288
289- Updates to CREDITS file and minor IDE numbering change
290 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
291
292- Invalidate devfs dentry cache when making directories
293
294- Invalidate devfs dentry cache when removing entries
295
296- More informative message if root FS mount fails when devfs
297 configured
298
299- Fixed persistence bug with fifos
300===============================================================================
301Changes for patch v26
302
303- ported to kernel 2.1.97
304
305- Changed serial directory from "/dev/serial" to "/dev/tts" and
306 "/dev/consoles" to "/dev/vc" to be more friendly to new procps
307===============================================================================
308Changes for patch v27
309
310- Added support for IDE4 and IDE5
311 Thanks to Andrzej Krzysztofowicz <ankry@green.mif.pg.gda.pl>
312
313- Documented "scsihosts=" boot parameter
314
315- Print process command when debugging kerneld/kmod
316
317- Added debugging for register/unregister/change operations
318
319- Added "devfs=" boot options
320
321- Hide unregistered entries by default
322===============================================================================
323Changes for patch v28
324
325- No longer lock/unlock superblock in <devfs_put_super> (cope with
326 recent VFS interface change)
327
328- Do not automatically change ownership/protection of /dev/tty
329
330- Drop negative dentries when they are released
331
332- Manage dcache more efficiently
333===============================================================================
334Changes for patch v29
335
336- Added DEVFS_FL_AUTO_DEVNUM flag
337===============================================================================
338Changes for patch v30
339
340- No longer set unnecessary methods
341
342- Ported to kernel 2.1.99-pre3
343===============================================================================
344Changes for patch v31
345
346- Added PID display to <call_kerneld> debugging message
347
348- Added "diread" and "diwrite" options
349
350- Ported to kernel 2.1.102
351
352- Fixed persistence problem with permissions
353===============================================================================
354Changes for patch v32
355
356- Fixed devfs support in drivers/block/md.c
357===============================================================================
358Changes for patch v33
359
360- Support legacy device nodes
361
362- Fixed bug where recreated inodes were hidden
363
364- New IDE naming scheme: everything is under /dev/ide
365===============================================================================
366Changes for patch v34
367
368- Improved debugging in <get_vfs_inode>
369
370- Prevent duplicate calls to <devfs_mk_dir> in SCSI layer
371
372- No longer free old dentries in <devfs_mk_dir>
373
374- Free all dentries for a given entry when deleting inodes
375===============================================================================
376Changes for patch v35
377
378- Ported to kernel 2.1.105 (sound driver changes)
379===============================================================================
380Changes for patch v36
381
382- Fixed sound driver port
383===============================================================================
384Changes for patch v37
385
386- Minor documentation tweaks
387===============================================================================
388Changes for patch v38
389
390- More documentation tweaks
391
392- Fix for sound driver port
393
394- Removed ttyname-patch (grab libc 5.4.44 instead)
395
396- Ported to kernel 2.1.107-pre2 (loop driver fix)
397===============================================================================
398Changes for patch v39
399
400- Ported to kernel 2.1.107 (hd.c hunk broke due to spelling "fixes"). Sigh
401
402- Removed many #ifdef's, replaced with trickery in include/devfs_fs.h
403===============================================================================
404Changes for patch v40
405
406- Fix for sound driver port
407
408- Limit auto-device numbering to majors 128 to 239
409===============================================================================
410Changes for patch v41
411
412- Fixed inode times persistence problem
413===============================================================================
414Changes for patch v42
415
416- Ported to kernel 2.1.108 (drivers/scsi/hosts.c hunk broke)
417===============================================================================
418Changes for patch v43
419
420- Fixed spelling in <devfs_readlink> debug
421
422- Fixed bug in <devfs_setup> parsing "dilookup"
423
424- More #ifdef's removed
425
426- Supported Sparc keyboard (/dev/kbd)
427
428- Supported DSP56001 digital signal processor (/dev/dsp56k)
429
430- Supported Apple Desktop Bus (/dev/adb)
431
432- Supported Coda network file system (/dev/cfs*)
433===============================================================================
434Changes for patch v44
435
436- Fixed devfs inode leak when manually recreating inodes
437
438- Fixed permission persistence problem when recreating inodes
439===============================================================================
440Changes for patch v45
441
442- Ported to kernel 2.1.110
443===============================================================================
444Changes for patch v46
445
446- Ported to kernel 2.1.112-pre1
447
448- Removed harmless "unused variable" compiler warning
449
450- Fixed modes for manually recreated device nodes
451===============================================================================
452Changes for patch v47
453
454- Added NULL devfs inode warning in <devfs_read_inode>
455
456- Force all inode nlink values to 1
457===============================================================================
458Changes for patch v48
459
460- Added "dimknod" option
461
462- Set inode nlink to 0 when freeing dentries
463
464- Added support for virtual console capture devices (/dev/vcs*)
465 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
466
467- Fixed modes for manually recreated symlinks
468===============================================================================
469Changes for patch v49
470
471- Ported to kernel 2.1.113
472===============================================================================
473Changes for patch v50
474
475- Fixed bugs in recreated directories and symlinks
476===============================================================================
477Changes for patch v51
478
479- Improved robustness of rc.devfs script
480 Thanks to Roderich Schupp <rsch@experteam.de>
481
482- Fixed bugs in recreated device nodes
483
484- Fixed bug in currently unused <devfs_get_handle_from_inode>
485
486- Defined new <devfs_handle_t> type
487
488- Improved debugging when getting entries
489
490- Fixed bug where directories could be emptied
491
492- Ported to kernel 2.1.115
493===============================================================================
494Changes for patch v52
495
496- Replaced dummy .epoch inode with .devfsd character device
497
498- Modified rc.devfs to take account of above change
499
500- Removed spurious driver warning messages when CONFIG_DEVFS_FS=n
501
502- Implemented devfsd protocol revision 0
503===============================================================================
504Changes for patch v53
505
506- Ported to kernel 2.1.116 (kmod change broke hunk)
507
508- Updated Documentation/Configure.help
509
510- Test and tty pattern patch for rc.devfs script
511 Thanks to Roderich Schupp <rsch@experteam.de>
512
513- Added soothing message to warning in <devfs_d_iput>
514===============================================================================
515Changes for patch v54
516
517- Ported to kernel 2.1.117
518
519- Fixed default permissions in sound driver
520
521- Added support for frame buffer devices (/dev/fb*)
522===============================================================================
523Changes for patch v55
524
525- Ported to kernel 2.1.119
526
527- Use GCC extensions for structure initialisations
528
529- Implemented async open notification
530
531- Incremented devfsd protocol revision to 1
532===============================================================================
533Changes for patch v56
534
535- Ported to kernel 2.1.120-pre3
536
537- Moved async open notification to end of <devfs_open>
538===============================================================================
539Changes for patch v57
540
541- Ported to kernel 2.1.121
542
543- Prepended "/dev/" to module load request
544
545- Renamed <call_kerneld> to <call_kmod>
546
547- Created sample modules.conf file
548===============================================================================
549Changes for patch v58
550
551- Fixed typo "AYSNC" -> "ASYNC"
552===============================================================================
553Changes for patch v59
554
555- Added open flag for files
556===============================================================================
557Changes for patch v60
558
559- Ported to kernel 2.1.123-pre2
560===============================================================================
561Changes for patch v61
562
563- Set i_blocks=0 and i_blksize=1024 in <devfs_read_inode>
564===============================================================================
565Changes for patch v62
566
567- Ported to kernel 2.1.123
568===============================================================================
569Changes for patch v63
570
571- Ported to kernel 2.1.124-pre2
572===============================================================================
573Changes for patch v64
574
575- Fixed Unix98 pty support
576
577- Increased buffer size in <get_partition_list> to avoid crash and
578 burn
579===============================================================================
580Changes for patch v65
581
582- More Unix98 pty support fixes
583
584- Added test for empty <<name>> in <devfs_find_handle>
585
586- Renamed <generate_path> to <devfs_generate_path> and published
587
588- Created /dev/root symlink
589 Thanks to Roderich Schupp <rsch@ExperTeam.de>
590 with further modifications by me
591===============================================================================
592Changes for patch v66
593
594- Yet more Unix98 pty support fixes (now tested)
595
596- Created <devfs_get_fops>
597
598- Support media change checks when CONFIG_DEVFS_ONLY=y
599
600- Abolished Unix98-style PTY names for old PTY devices
601===============================================================================
602Changes for patch v67
603
604- Added inline declaration for dummy <devfs_generate_path>
605
606- Removed spurious "unable to register... in devfs" messages when
607 CONFIG_DEVFS_FS=n
608
609- Fixed misc. devices when CONFIG_DEVFS_FS=n
610
611- Limit auto-device numbering to majors 144 to 239
612===============================================================================
613Changes for patch v68
614
615- Hide unopened virtual consoles from directory listings
616
617- Added support for video capture devices
618
619- Ported to kernel 2.1.125
620===============================================================================
621Changes for patch v69
622
623- Fix for CONFIG_VT=n
624===============================================================================
625Changes for patch v70
626
627- Added support for non-OSS/Free sound cards
628===============================================================================
629Changes for patch v71
630
631- Ported to kernel 2.1.126-pre2
632===============================================================================
633Changes for patch v72
634
635- #ifdef's for CONFIG_DEVFS_DISABLE_OLD_NAMES removed
636===============================================================================
637Changes for patch v73
638
639- CONFIG_DEVFS_DISABLE_OLD_NAMES replaced with "nocompat" boot option
640
641- CONFIG_DEVFS_BOOT_OPTIONS removed: boot options always available
642===============================================================================
643Changes for patch v74
644
645- Removed CONFIG_DEVFS_MOUNT and "mount" boot option and replaced with
646 "nomount" boot option
647
648- Documentation updates
649
650- Updated sample modules.conf
651===============================================================================
652Changes for patch v75
653
654- Updated sample modules.conf
655
656- Remount devfs after initrd finishes
657
658- Ported to kernel 2.1.127
659
660- Added support for ISDN
661 Thanks to Christophe Leroy <christophe.leroy5@capway.com>
662===============================================================================
663Changes for patch v76
664
665- Updated an email address in ChangeLog
666
667- CONFIG_DEVFS_ONLY replaced with "only" boot option
668===============================================================================
669Changes for patch v77
670
671- Added DEVFS_FL_REMOVABLE flag
672
673- Check for disc change when listing directories with removable media
674 devices
675
676- Use DEVFS_FL_REMOVABLE in sd.c
677
678- Ported to kernel 2.1.128
679===============================================================================
680Changes for patch v78
681
682- Only call <scan_dir_for_removable> on first call to <devfs_readdir>
683
684- Ported to kernel 2.1.129-pre5
685
686- ISDN support improvements
687 Thanks to Christophe Leroy <christophe.leroy5@capway.com>
688===============================================================================
689Changes for patch v79
690
691- Ported to kernel 2.1.130
692
693- Renamed miscdevice "apm" to "apm_bios" to be consistent with
694 devices.txt
695===============================================================================
696Changes for patch v80
697
698- Ported to kernel 2.1.131
699
700- Updated <devfs_rmdir> for VFS change in 2.1.131
701===============================================================================
702Changes for patch v81
703
704- Fixed permissions on /dev/ptmx
705===============================================================================
706Changes for patch v82
707
708- Ported to kernel 2.1.132-pre4
709
710- Changed initial permissions on /dev/pts/*
711
712- Created <devfs_mk_compat>
713
714- Added "symlinks" boot option
715
716- Changed devfs_register_blkdev() back to register_blkdev() for IDE
717
718- Check for partitions on removable media in <devfs_lookup>
719===============================================================================
720Changes for patch v83
721
722- Fixed support for ramdisc when using string-based root FS name
723
724- Ported to kernel 2.2.0-pre1
725===============================================================================
726Changes for patch v84
727
728- Ported to kernel 2.2.0-pre7
729===============================================================================
730Changes for patch v85
731
732- Compile fixes for driver/sound/sound_common.c (non-module) and
733 drivers/isdn/isdn_common.c
734 Thanks to Christophe Leroy <christophe.leroy5@capway.com>
735
736- Added support for registering regular files
737
738- Created <devfs_set_file_size>
739
740- Added /dev/cpu/mtrr as an alternative interface to /proc/mtrr
741
742- Update devfs inodes from entries if not changed through FS
743===============================================================================
744Changes for patch v86
745
746- Ported to kernel 2.2.0-pre9
747===============================================================================
748Changes for patch v87
749
750- Fixed bug when mounting non-devfs devices in a devfs
751===============================================================================
752Changes for patch v88
753
754- Fixed <devfs_fill_file> to only initialise temporary inodes
755
756- Trap for NULL fops in <devfs_register>
757
758- Return -ENODEV in <devfs_fill_file> for non-driver inodes
759
760- Fixed bug when unswapping non-devfs devices in a devfs
761===============================================================================
762Changes for patch v89
763
764- Switched to C data types in include/linux/devfs_fs.h
765
766- Switched from PATH_MAX to DEVFS_PATHLEN
767
768- Updated Documentation/filesystems/devfs/modules.conf to take account
769 of reverse scanning (!) by modprobe
770
771- Ported to kernel 2.2.0
772===============================================================================
773Changes for patch v90
774
775- CONFIG_DEVFS_DISABLE_OLD_TTY_NAMES replaced with "nottycompat" boot
776 option
777
778- CONFIG_DEVFS_TTY_COMPAT removed: existing "symlinks" boot option now
779 controls this. This means you must have libc 5.4.44 or later, or a
780 recent version of libc 6 if you use the "symlinks" option
781===============================================================================
782Changes for patch v91
783
784- Switch from <devfs_mk_symlink> to <devfs_mk_compat> in
785 drivers/char/vc_screen.c to fix problems with Midnight Commander
786===============================================================================
787Changes for patch v92
788
789- Ported to kernel 2.2.2-pre5
790===============================================================================
791Changes for patch v93
792
793- Modified <sd_name> in drivers/scsi/sd.c to cope with devices that
794 don't exist (which happens with new RAID autostart code printk()s)
795===============================================================================
796Changes for patch v94
797
798- Fixed bug in joystick driver: only first joystick was registered
799===============================================================================
800Changes for patch v95
801
802- Fixed another bug in joystick driver
803
804- Fixed <devfsd_read> to not overrun event buffer
805===============================================================================
806Changes for patch v96
807
808- Ported to kernel 2.2.5-2
809
810- Created <devfs_auto_unregister>
811
812- Fixed bugs: compatibility entries were not unregistered for:
813 loop driver
814 floppy driver
815 RAMDISC driver
816 IDE tape driver
817 SCSI CD-ROM driver
818 SCSI HDD driver
819===============================================================================
820Changes for patch v97
821
822- Fixed bugs: compatibility entries were not unregistered for:
823 ALSA sound driver
824 partitions in generic disc driver
825
826- Don't return unregistred entries in <devfs_find_handle>
827
828- Panic in <devfs_unregister> if entry unregistered
829
830- Don't panic in <devfs_auto_unregister> for duplicates
831===============================================================================
832Changes for patch v98
833
834- Don't unregister already unregistered entries in <unregister>
835
836- Register entry in <sd_detect>
837
838- Unregister entry in <sd_detach>
839
840- Changed to <devfs_*register_chrdev> in drivers/char/tty_io.c
841
842- Ported to kernel 2.2.7
843===============================================================================
844Changes for patch v99
845
846- Ported to kernel 2.2.8
847
848- Fixed bug in drivers/scsi/sd.c when >16 SCSI discs
849
850- Disable warning messages when unable to read partition table for
851 removable media
852===============================================================================
853Changes for patch v100
854
855- Ported to kernel 2.3.1-pre5
856
857- Added "oops-on-panic" boot option
858
859- Improved debugging in <devfs_register> and <devfs_unregister>
860
861- Register entry in <sr_detect>
862
863- Unregister entry in <sr_detach>
864
865- Register entry in <sg_detect>
866
867- Unregister entry in <sg_detach>
868
869- Added support for ALSA drivers
870===============================================================================
871Changes for patch v101
872
873- Ported to kernel 2.3.2
874===============================================================================
875Changes for patch v102
876
877- Update serial driver to register PCMCIA entries
878 Thanks to Roch-Alexandre Nomine-Beguin <roch@samarkand.infini.fr>
879
880- Updated an email address in ChangeLog
881
882- Hide virtual console capture entries from directory listings when
883 corresponding console device is not open
884===============================================================================
885Changes for patch v103
886
887- Ported to kernel 2.3.3
888===============================================================================
889Changes for patch v104
890
891- Added documentation for some functions
892
893- Added "doc" target to fs/devfs/Makefile
894
895- Added "v4l" directory for video4linux devices
896
897- Replaced call to <devfs_unregister> in <sd_detach> with call to
898 <devfs_register_partitions>
899
900- Moved registration for sr and sg drivers from detect() to attach()
901 methods
902
903- Register entries in <st_attach> and unregister in <st_detach>
904
905- Work around IDE driver treating CD-ROM as gendisk
906
907- Use <sed> instead of <tr> in rc.devfs
908
909- Updated ToDo list
910
911- Removed "oops-on-panic" boot option: now always Oops
912===============================================================================
913Changes for patch v105
914
915- Unregister SCSI host from <scsi_host_no_list> in <scsi_unregister>
916 Thanks to Zoltán Böszörményi <zboszor@mail.externet.hu>
917
918- Don't save /dev/log in rc.devfs
919
920- Ported to kernel 2.3.4-pre1
921===============================================================================
922Changes for patch v106
923
924- Fixed silly typo in drivers/scsi/st.c
925
926- Improved debugging in <devfs_register>
927===============================================================================
928Changes for patch v107
929
930- Added "diunlink" and "nokmod" boot options
931
932- Removed superfluous warning message in <devfs_d_iput>
933===============================================================================
934Changes for patch v108
935
936- Remove entries when unloading sound module
937===============================================================================
938Changes for patch v109
939
940- Ported to kernel 2.3.6-pre2
941===============================================================================
942Changes for patch v110
943
944- Took account of change to <d_alloc_root>
945===============================================================================
946Changes for patch v111
947
948- Created separate event queue for each mounted devfs
949
950- Removed <devfs_invalidate_dcache>
951
952- Created new ioctl()s for devfsd
953
954- Incremented devfsd protocol revision to 3
955
956- Fixed bug when re-creating directories: contents were lost
957
958- Block access to inodes until devfsd updates permissions
959===============================================================================
960Changes for patch v112
961
962- Modified patch so it applies against 2.3.5 and 2.3.6
963
964- Updated an email address in ChangeLog
965
966- Do not automatically change ownership/protection of /dev/tty<n>
967
968- Updated sample modules.conf
969
970- Switched to sending process uid/gid to devfsd
971
972- Renamed <call_kmod> to <try_modload>
973
974- Added DEVFSD_NOTIFY_LOOKUP event
975
976- Added DEVFSD_NOTIFY_CHANGE event
977
978- Added DEVFSD_NOTIFY_CREATE event
979
980- Incremented devfsd protocol revision to 4
981
982- Moved kernel-specific stuff to include/linux/devfs_fs_kernel.h
983===============================================================================
984Changes for patch v113
985
986- Ported to kernel 2.3.9
987
988- Restricted permissions on some block devices
989===============================================================================
990Changes for patch v114
991
992- Added support for /dev/netlink
993 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
994
995- Return EISDIR rather than EINVAL for read(2) on directories
996
997- Ported to kernel 2.3.10
998===============================================================================
999Changes for patch v115
1000
1001- Added support for all remaining character devices
1002 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
1003
1004- Cleaned up netlink support
1005===============================================================================
1006Changes for patch v116
1007
1008- Added support for /dev/parport%d
1009 Thanks to Tim Waugh <tim@cyberelk.demon.co.uk>
1010
1011- Fixed parallel port ATAPI tape driver
1012
1013- Fixed Atari SLM laser printer driver
1014===============================================================================
1015Changes for patch v117
1016
1017- Added support for COSA card
1018 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
1019
1020- Fixed drivers/char/ppdev.c: missing #include <linux/init.h>
1021
1022- Fixed drivers/char/ftape/zftape/zftape-init.c
1023 Thanks to Vladimir Popov <mashgrad@usa.net>
1024===============================================================================
1025Changes for patch v118
1026
1027- Ported to kernel 2.3.15-pre3
1028
1029- Fixed bug in loop driver
1030
1031- Unregister /dev/lp%d entries in drivers/char/lp.c
1032 Thanks to Maciej W. Rozycki <macro@ds2.pg.gda.pl>
1033===============================================================================
1034Changes for patch v119
1035
1036- Ported to kernel 2.3.16
1037===============================================================================
1038Changes for patch v120
1039
1040- Fixed bug in drivers/scsi/scsi.c
1041
1042- Added /dev/ppp
1043 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
1044
1045- Ported to kernel 2.3.17
1046===============================================================================
1047Changes for patch v121
1048
1049- Fixed bug in drivers/block/loop.c
1050
1051- Ported to kernel 2.3.18
1052===============================================================================
1053Changes for patch v122
1054
1055- Ported to kernel 2.3.19
1056===============================================================================
1057Changes for patch v123
1058
1059- Ported to kernel 2.3.20
1060===============================================================================
1061Changes for patch v124
1062
1063- Ported to kernel 2.3.21
1064===============================================================================
1065Changes for patch v125
1066
1067- Created <devfs_get_info>, <devfs_set_info>,
1068 <devfs_get_first_child> and <devfs_get_next_sibling>
1069 Added <<dir>> parameter to <devfs_register>, <devfs_mk_compat>,
1070 <devfs_mk_dir> and <devfs_find_handle>
1071 Work sponsored by SGI
1072
1073- Fixed apparent bug in COSA driver
1074
1075- Re-instated "scsihosts=" boot option
1076===============================================================================
1077Changes for patch v126
1078
1079- Always create /dev/pts if CONFIG_UNIX98_PTYS=y
1080
1081- Fixed call to <devfs_mk_dir> in drivers/block/ide-disk.c
1082 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
1083
1084- Allow multiple unregistrations
1085
1086- Created /dev/scsi hierarchy
1087 Work sponsored by SGI
1088===============================================================================
1089Changes for patch v127
1090
1091Work sponsored by SGI
1092
1093- No longer disable devpts if devfs enabled (caveat emptor)
1094
1095- Added flags array to struct gendisk and removed code from
1096 drivers/scsi/sd.c
1097
1098- Created /dev/discs hierarchy
1099===============================================================================
1100Changes for patch v128
1101
1102Work sponsored by SGI
1103
1104- Created /dev/cdroms hierarchy
1105===============================================================================
1106Changes for patch v129
1107
1108Work sponsored by SGI
1109
1110- Removed compatibility entries for sound devices
1111
1112- Removed compatibility entries for printer devices
1113
1114- Removed compatibility entries for video4linux devices
1115
1116- Removed compatibility entries for parallel port devices
1117
1118- Removed compatibility entries for frame buffer devices
1119===============================================================================
1120Changes for patch v130
1121
1122Work sponsored by SGI
1123
1124- Added major and minor number to devfsd protocol
1125
1126- Incremented devfsd protocol revision to 5
1127
1128- Removed compatibility entries for SoundBlaster CD-ROMs
1129
1130- Removed compatibility entries for netlink devices
1131
1132- Removed compatibility entries for SCSI generic devices
1133
1134- Removed compatibility entries for SCSI tape devices
1135===============================================================================
1136Changes for patch v131
1137
1138Work sponsored by SGI
1139
1140- Support info pointer for all devfs entry types
1141
1142- Added <<info>> parameter to <devfs_mk_dir> and <devfs_mk_symlink>
1143
1144- Removed /dev/st hierarchy
1145
1146- Removed /dev/sg hierarchy
1147
1148- Removed compatibility entries for loop devices
1149
1150- Removed compatibility entries for IDE tape devices
1151
1152- Removed compatibility entries for SCSI CD-ROMs
1153
1154- Removed /dev/sr hierarchy
1155===============================================================================
1156Changes for patch v132
1157
1158Work sponsored by SGI
1159
1160- Removed compatibility entries for floppy devices
1161
1162- Removed compatibility entries for RAMDISCs
1163
1164- Removed compatibility entries for meta-devices
1165
1166- Removed compatibility entries for SCSI discs
1167
1168- Created <devfs_make_root>
1169
1170- Removed /dev/sd hierarchy
1171
1172- Support "../" when searching devfs namespace
1173
1174- Created /dev/ide/host* hierarchy
1175
1176- Supported IDE hard discs in /dev/ide/host* hierarchy
1177
1178- Removed compatibility entries for IDE discs
1179
1180- Removed /dev/ide/hd hierarchy
1181
1182- Supported IDE CD-ROMs in /dev/ide/host* hierarchy
1183
1184- Removed compatibility entries for IDE CD-ROMs
1185
1186- Removed /dev/ide/cd hierarchy
1187===============================================================================
1188Changes for patch v133
1189
1190Work sponsored by SGI
1191
1192- Created <devfs_get_unregister_slave>
1193
1194- Fixed bug in fs/partitions/check.c when rescanning
1195===============================================================================
1196Changes for patch v134
1197
1198Work sponsored by SGI
1199
1200- Removed /dev/sd, /dev/sr, /dev/st and /dev/sg directories
1201
1202- Removed /dev/ide/hd directory
1203
1204- Exported <devfs_get_parent>
1205
1206- Created <devfs_register_tape> and /dev/tapes hierarchy
1207
1208- Removed /dev/ide/mt hierarchy
1209
1210- Removed /dev/ide/fd hierarchy
1211
1212- Ported to kernel 2.3.25
1213===============================================================================
1214Changes for patch v135
1215
1216Work sponsored by SGI
1217
1218- Removed compatibility entries for virtual console capture devices
1219
1220- Removed unused <devfs_set_symlink_destination>
1221
1222- Removed compatibility entries for serial devices
1223
1224- Removed compatibility entries for console devices
1225
1226- Do not hide entries from devfsd or children
1227
1228- Removed DEVFS_FL_TTY_COMPAT flag
1229
1230- Removed "nottycompat" boot option
1231
1232- Removed <devfs_mk_compat>
1233===============================================================================
1234Changes for patch v136
1235
1236Work sponsored by SGI
1237
1238- Moved BSD pty devices to /dev/pty
1239
1240- Added DEVFS_FL_WAIT flag
1241===============================================================================
1242Changes for patch v137
1243
1244Work sponsored by SGI
1245
1246- Really fixed bug in fs/partitions/check.c when rescanning
1247
1248- Support new "disc" naming scheme in <get_removable_partition>
1249
1250- Allow NULL fops in <devfs_register>
1251
1252- Removed redundant name functions in SCSI disc and IDE drivers
1253===============================================================================
1254Changes for patch v138
1255
1256Work sponsored by SGI
1257
1258- Fixed old bugs in drivers/block/paride/pt.c, drivers/char/tpqic02.c,
1259 drivers/net/wan/cosa.c and drivers/scsi/scsi.c
1260 Thanks to Sergey Kubushin <ksi@ksi-linux.com>
1261
1262- Fall back to major table if NULL fops given to <devfs_register>
1263===============================================================================
1264Changes for patch v139
1265
1266Work sponsored by SGI
1267
1268- Corrected and moved <get_blkfops> and <get_chrfops> declarations
1269 from arch/alpha/kernel/osf_sys.c to include/linux/fs.h
1270
1271- Removed name function from struct gendisk
1272
1273- Updated devfs FAQ
1274===============================================================================
1275Changes for patch v140
1276
1277Work sponsored by SGI
1278
1279- Ported to kernel 2.3.27
1280===============================================================================
1281Changes for patch v141
1282
1283Work sponsored by SGI
1284
1285- Bug fix in arch/m68k/atari/joystick.c
1286
1287- Moved ISDN and capi devices to /dev/isdn
1288===============================================================================
1289Changes for patch v142
1290
1291Work sponsored by SGI
1292
1293- Bug fix in drivers/block/ide-probe.c (patch confusion)
1294===============================================================================
1295Changes for patch v143
1296
1297Work sponsored by SGI
1298
1299- Bug fix in drivers/block/blkpg.c:partition_name()
1300===============================================================================
1301Changes for patch v144
1302
1303Work sponsored by SGI
1304
1305- Ported to kernel 2.3.29
1306
1307- Removed calls to <devfs_register> from cdu31a, cm206, mcd and mcdx
1308 CD-ROM drivers: generic driver handles this now
1309
1310- Moved joystick devices to /dev/joysticks
1311===============================================================================
1312Changes for patch v145
1313
1314Work sponsored by SGI
1315
1316- Ported to kernel 2.3.30-pre3
1317
1318- Register whole-disc entry even for invalid partition tables
1319
1320- Fixed bug in mounting root FS when initrd enabled
1321
1322- Fixed device entry leak with IDE CD-ROMs
1323
1324- Fixed compile problem with drivers/isdn/isdn_common.c
1325
1326- Moved COSA devices to /dev/cosa
1327
1328- Support fifos when unregistering
1329
1330- Created <devfs_register_series> and used in many drivers
1331
1332- Moved Coda devices to /dev/coda
1333
1334- Moved parallel port IDE tapes to /dev/pt
1335
1336- Moved parallel port IDE generic devices to /dev/pg
1337===============================================================================
1338Changes for patch v146
1339
1340Work sponsored by SGI
1341
1342- Removed obsolete DEVFS_FL_COMPAT and DEVFS_FL_TOLERANT flags
1343
1344- Fixed compile problem with fs/coda/psdev.c
1345
1346- Reinstate change to <devfs_register_blkdev> in
1347 drivers/block/ide-probe.c now that fs/isofs/inode.c is fixed
1348
1349- Switched to <devfs_register_blkdev> in drivers/block/floppy.c,
1350 drivers/scsi/sr.c and drivers/block/md.c
1351
1352- Moved DAC960 devices to /dev/dac960
1353===============================================================================
1354Changes for patch v147
1355
1356Work sponsored by SGI
1357
1358- Ported to kernel 2.3.32-pre4
1359===============================================================================
1360Changes for patch v148
1361
1362Work sponsored by SGI
1363
1364- Removed kmod support: use devfsd instead
1365
1366- Moved miscellaneous character devices to /dev/misc
1367===============================================================================
1368Changes for patch v149
1369
1370Work sponsored by SGI
1371
1372- Ensure include/linux/joystick.h is OK for user-space
1373
1374- Improved debugging in <get_vfs_inode>
1375
1376- Ensure dentries created by devfsd will be cleaned up
1377===============================================================================
1378Changes for patch v150
1379
1380Work sponsored by SGI
1381
1382- Ported to kernel 2.3.34
1383===============================================================================
1384Changes for patch v151
1385
1386Work sponsored by SGI
1387
1388- Ported to kernel 2.3.35-pre1
1389
1390- Created <devfs_get_name>
1391===============================================================================
1392Changes for patch v152
1393
1394Work sponsored by SGI
1395
1396- Updated sample modules.conf
1397
1398- Ported to kernel 2.3.36-pre1
1399===============================================================================
1400Changes for patch v153
1401
1402Work sponsored by SGI
1403
1404- Ported to kernel 2.3.42
1405
1406- Removed <devfs_fill_file>
1407===============================================================================
1408Changes for patch v154
1409
1410Work sponsored by SGI
1411
1412- Took account of device number changes for /dev/fb*
1413===============================================================================
1414Changes for patch v155
1415
1416Work sponsored by SGI
1417
1418- Ported to kernel 2.3.43-pre8
1419
1420- Moved /dev/tty0 to /dev/vc/0
1421
1422- Moved sequence number formatting from <_tty_make_name> to drivers
1423===============================================================================
1424Changes for patch v156
1425
1426Work sponsored by SGI
1427
1428- Fixed breakage in drivers/scsi/sd.c due to recent SCSI changes
1429===============================================================================
1430Changes for patch v157
1431
1432Work sponsored by SGI
1433
1434- Ported to kernel 2.3.45
1435===============================================================================
1436Changes for patch v158
1437
1438Work sponsored by SGI
1439
1440- Ported to kernel 2.3.46-pre2
1441===============================================================================
1442Changes for patch v159
1443
1444Work sponsored by SGI
1445
1446- Fixed drivers/block/md.c
1447 Thanks to Mike Galbraith <mikeg@weiden.de>
1448
1449- Documentation fixes
1450
1451- Moved device registration from <lp_init> to <lp_register>
1452 Thanks to Tim Waugh <twaugh@redhat.com>
1453===============================================================================
1454Changes for patch v160
1455
1456Work sponsored by SGI
1457
1458- Fixed drivers/char/joystick/joystick.c
1459 Thanks to Vojtech Pavlik <vojtech@suse.cz>
1460
1461- Documentation updates
1462
1463- Fixed arch/i386/kernel/mtrr.c if procfs and devfs not enabled
1464
1465- Fixed drivers/char/stallion.c
1466===============================================================================
1467Changes for patch v161
1468
1469Work sponsored by SGI
1470
1471- Remove /dev/ide when ide-mod is unloaded
1472
1473- Fixed bug in drivers/block/ide-probe.c when secondary but no primary
1474
1475- Added DEVFS_FL_NO_PERSISTENCE flag
1476
1477- Used new DEVFS_FL_NO_PERSISTENCE flag for Unix98 pty slaves
1478
1479- Removed unnecessary call to <update_devfs_inode_from_entry> in
1480 <devfs_readdir>
1481
1482- Only set auto-ownership for /dev/pty/s*
1483===============================================================================
1484Changes for patch v162
1485
1486Work sponsored by SGI
1487
1488- Set inode->i_size to correct size for symlinks
1489 Thanks to Jeremy Fitzhardinge <jeremy@goop.org>
1490
1491- Only give lookup() method to directories to comply with new VFS
1492 assumptions
1493
1494- Remove unnecessary tests in symlink methods
1495
1496- Don't kill existing block ops in <devfs_read_inode>
1497
1498- Restore auto-ownership for /dev/pty/m*
1499===============================================================================
1500Changes for patch v163
1501
1502Work sponsored by SGI
1503
1504- Don't create missing directories in <devfs_find_handle>
1505
1506- Removed Documentation/filesystems/devfs/mk-devlinks
1507
1508- Updated Documentation/filesystems/devfs/README
1509===============================================================================
1510Changes for patch v164
1511
1512Work sponsored by SGI
1513
1514- Fixed CONFIG_DEVFS breakage in drivers/char/serial.c introduced in
1515 linux-2.3.99-pre6-7
1516===============================================================================
1517Changes for patch v165
1518
1519Work sponsored by SGI
1520
1521- Ported to kernel 2.3.99-pre6
1522===============================================================================
1523Changes for patch v166
1524
1525Work sponsored by SGI
1526
1527- Added CONFIG_DEVFS_MOUNT
1528===============================================================================
1529Changes for patch v167
1530
1531Work sponsored by SGI
1532
1533- Updated Documentation/filesystems/devfs/README
1534
1535- Updated sample modules.conf
1536===============================================================================
1537Changes for patch v168
1538
1539Work sponsored by SGI
1540
1541- Disabled multi-mount capability (use VFS bindings instead)
1542
1543- Updated README from master HTML file
1544===============================================================================
1545Changes for patch v169
1546
1547Work sponsored by SGI
1548
1549- Removed multi-mount code
1550
1551- Removed compatibility macros: VFS has changed too much
1552===============================================================================
1553Changes for patch v170
1554
1555Work sponsored by SGI
1556
1557- Updated README from master HTML file
1558
1559- Merged devfs inode into devfs entry
1560===============================================================================
1561Changes for patch v171
1562
1563Work sponsored by SGI
1564
1565- Updated sample modules.conf
1566
1567- Removed dead code in <devfs_register> which used to call
1568 <free_dentries>
1569
1570- Ported to kernel 2.4.0-test2-pre3
1571===============================================================================
1572Changes for patch v172
1573
1574Work sponsored by SGI
1575
1576- Changed interface to <devfs_register>
1577
1578- Changed interface to <devfs_register_series>
1579===============================================================================
1580Changes for patch v173
1581
1582Work sponsored by SGI
1583
1584- Simplified interface to <devfs_mk_symlink>
1585
1586- Simplified interface to <devfs_mk_dir>
1587
1588- Simplified interface to <devfs_find_handle>
1589===============================================================================
1590Changes for patch v174
1591
1592Work sponsored by SGI
1593
1594- Updated README from master HTML file
1595===============================================================================
1596Changes for patch v175
1597
1598Work sponsored by SGI
1599
1600- DocBook update for fs/devfs/base.c
1601 Thanks to Tim Waugh <twaugh@redhat.com>
1602
1603- Removed stale fs/tunnel.c (was never used or completed)
1604===============================================================================
1605Changes for patch v176
1606
1607Work sponsored by SGI
1608
1609- Updated ToDo list
1610
1611- Removed sample modules.conf: now distributed with devfsd
1612
1613- Updated README from master HTML file
1614
1615- Ported to kernel 2.4.0-test3-pre4 (which had devfs-patch-v174)
1616===============================================================================
1617Changes for patch v177
1618
1619- Updated README from master HTML file
1620
1621- Documentation cleanups
1622
1623- Ensure <devfs_generate_path> terminates string for root entry
1624 Thanks to Tim Jansen <tim@tjansen.de>
1625
1626- Exported <devfs_get_name> to modules
1627
1628- Make <devfs_mk_symlink> send events to devfsd
1629
1630- Cleaned up option processing in <devfs_setup>
1631
1632- Fixed bugs in handling symlinks: could leak or cause Oops
1633
1634- Cleaned up directory handling by separating fops
1635 Thanks to Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
1636===============================================================================
1637Changes for patch v178
1638
1639- Fixed handling of inverted options in <devfs_setup>
1640===============================================================================
1641Changes for patch v179
1642
1643- Adjusted <try_modload> to account for <devfs_generate_path> fix
1644===============================================================================
1645Changes for patch v180
1646
1647- Fixed !CONFIG_DEVFS_FS stub declaration of <devfs_get_info>
1648===============================================================================
1649Changes for patch v181
1650
1651- Answered question posed by Al Viro and removed his comments from <devfs_open>
1652
1653- Moved setting of registered flag after other fields are changed
1654
1655- Fixed race between <devfsd_close> and <devfsd_notify_one>
1656
1657- Global VFS changes added bogus BKL to devfsd_close(): removed
1658
1659- Widened locking in <devfs_readlink> and <devfs_follow_link>
1660
1661- Replaced <devfsd_read> stack usage with <devfsd_ioctl> kmalloc
1662
1663- Simplified locking in <devfsd_ioctl> and fixed memory leak
1664===============================================================================
1665Changes for patch v182
1666
1667- Created <devfs_*alloc_major> and <devfs_*alloc_devnum>
1668
1669- Removed broken devnum allocation and use <devfs_alloc_devnum>
1670
1671- Fixed old devnum leak by calling new <devfs_dealloc_devnum>
1672
1673- Created <devfs_*alloc_unique_number>
1674
1675- Fixed number leak for /dev/cdroms/cdrom%d
1676
1677- Fixed number leak for /dev/discs/disc%d
1678===============================================================================
1679Changes for patch v183
1680
1681- Fixed bug in <devfs_setup> which could hang boot process
1682===============================================================================
1683Changes for patch v184
1684
1685- Documentation typo fix for fs/devfs/util.c
1686
1687- Fixed drivers/char/stallion.c for devfs
1688
1689- Added DEVFSD_NOTIFY_DELETE event
1690
1691- Updated README from master HTML file
1692
1693- Removed #include <asm/segment.h> from fs/devfs/base.c
1694===============================================================================
1695Changes for patch v185
1696
1697- Made <block_semaphore> and <char_semaphore> in fs/devfs/util.c
1698 private
1699
1700- Fixed inode table races by removing it and using inode->u.generic_ip
1701 instead
1702
1703- Moved <devfs_read_inode> into <get_vfs_inode>
1704
1705- Moved <devfs_write_inode> into <devfs_notify_change>
1706===============================================================================
1707Changes for patch v186
1708
1709- Fixed race in <devfs_do_symlink> for uni-processor
1710
1711- Updated README from master HTML file
1712===============================================================================
1713Changes for patch v187
1714
1715- Fixed drivers/char/stallion.c for devfs
1716
1717- Fixed drivers/char/rocket.c for devfs
1718
1719- Fixed bug in <devfs_alloc_unique_number>: limited to 128 numbers
1720===============================================================================
1721Changes for patch v188
1722
1723- Updated major masks in fs/devfs/util.c up to Linus' "no new majors"
1724 proclamation. Block: were 126 now 122 free, char: were 26 now 19 free
1725
1726- Updated README from master HTML file
1727
1728- Removed remnant of multi-mount support in <devfs_mknod>
1729
1730- Removed unused DEVFS_FL_SHOW_UNREG flag
1731===============================================================================
1732Changes for patch v189
1733
1734- Removed nlink field from struct devfs_inode
1735
1736- Removed auto-ownership for /dev/pty/* (BSD ptys) and used
1737 DEVFS_FL_CURRENT_OWNER|DEVFS_FL_NO_PERSISTENCE for /dev/pty/s* (just
1738 like Unix98 pty slaves) and made /dev/pty/m* rw-rw-rw- access
1739===============================================================================
1740Changes for patch v190
1741
1742- Updated README from master HTML file
1743
1744- Replaced BKL with global rwsem to protect symlink data (quick and
1745 dirty hack)
1746===============================================================================
1747Changes for patch v191
1748
1749- Replaced global rwsem for symlink with per-link refcount
1750===============================================================================
1751Changes for patch v192
1752
1753- Removed unnecessary #ifdef CONFIG_DEVFS_FS from arch/i386/kernel/mtrr.c
1754
1755- Ported to kernel 2.4.10-pre11
1756
1757- Set inode->i_mapping->a_ops for block nodes in <get_vfs_inode>
1758===============================================================================
1759Changes for patch v193
1760
1761- Went back to global rwsem for symlinks (refcount scheme no good)
1762===============================================================================
1763Changes for patch v194
1764
1765- Fixed overrun in <devfs_link> by removing function (not needed)
1766
1767- Updated README from master HTML file
1768===============================================================================
1769Changes for patch v195
1770
1771- Fixed buffer underrun in <try_modload>
1772
1773- Moved down_read() from <search_for_entry_in_dir> to <find_entry>
1774===============================================================================
1775Changes for patch v196
1776
1777- Fixed race in <devfsd_ioctl> when setting event mask
1778 Thanks to Kari Hurtta <hurtta@leija.mh.fmi.fi>
1779
1780- Avoid deadlock in <devfs_follow_link> by using temporary buffer
1781===============================================================================
1782Changes for patch v197
1783
1784- First release of new locking code for devfs core (v1.0)
1785
1786- Fixed bug in drivers/cdrom/cdrom.c
1787===============================================================================
1788Changes for patch v198
1789
1790- Discard temporary buffer, now use "%s" for dentry names
1791
1792- Don't generate path in <try_modload>: use fake entry instead
1793
1794- Use "existing" directory in <_devfs_make_parent_for_leaf>
1795
1796- Use slab cache rather than fixed buffer for devfsd events
1797===============================================================================
1798Changes for patch v199
1799
1800- Removed obsolete usage of DEVFS_FL_NO_PERSISTENCE
1801
1802- Send DEVFSD_NOTIFY_REGISTERED events in <devfs_mk_dir>
1803
1804- Fixed locking bug in <devfs_d_revalidate_wait> due to typo
1805
1806- Do not send CREATE, CHANGE, ASYNC_OPEN or DELETE events from devfsd
1807 or children
1808===============================================================================
1809Changes for patch v200
1810
1811- Ported to kernel 2.5.1-pre2
1812===============================================================================
1813Changes for patch v201
1814
1815- Fixed bug in <devfsd_read>: was dereferencing freed pointer
1816===============================================================================
1817Changes for patch v202
1818
1819- Fixed bug in <devfsd_close>: was dereferencing freed pointer
1820
1821- Added process group check for devfsd privileges
1822===============================================================================
1823Changes for patch v203
1824
1825- Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete>
1826===============================================================================
1827Changes for patch v204
1828
1829- Removed long obsolete rc.devfs
1830
1831- Return old entry in <devfs_mk_dir> for 2.4.x kernels
1832
1833- Updated README from master HTML file
1834
1835- Increment refcount on module in <check_disc_changed>
1836
1837- Created <devfs_get_handle> and exported <devfs_put>
1838
1839- Increment refcount on module in <devfs_get_ops>
1840
1841- Created <devfs_put_ops> and used where needed to fix races
1842
1843- Added clarifying comments in response to preliminary EMC code review
1844
1845- Added poisoning to <devfs_put>
1846
1847- Improved debugging messages
1848
1849- Fixed unregister bugs in drivers/md/lvm-fs.c
1850===============================================================================
1851Changes for patch v205
1852
1853- Corrected (made useful) debugging message in <unregister>
1854
1855- Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs>
1856
1857- Fixed drivers/md/lvm-fs.c to create "lvm" entry
1858
1859- Added magic number to guard against scribbling drivers
1860
1861- Only return old entry in <devfs_mk_dir> if a directory
1862
1863- Defined macros for error and debug messages
1864
1865- Updated README from master HTML file
1866===============================================================================
1867Changes for patch v206
1868
1869- Added support for multiple Compaq cpqarray controllers
1870
1871- Fixed (rare, old) race in <devfs_lookup>
1872===============================================================================
1873Changes for patch v207
1874
1875- Fixed deadlock bug in <devfs_d_revalidate_wait>
1876
1877- Tag VFS deletable in <devfs_mk_symlink> if handle ignored
1878
1879- Updated README from master HTML file
1880===============================================================================
1881Changes for patch v208
1882
1883- Added KERN_* to remaining messages
1884
1885- Cleaned up declaration of <stat_read>
1886
1887- Updated README from master HTML file
1888===============================================================================
1889Changes for patch v209
1890
1891- Updated README from master HTML file
1892
1893- Removed silently introduced calls to lock_kernel() and
1894 unlock_kernel() due to recent VFS locking changes. BKL isn't
1895 required in devfs
1896
1897- Changed <devfs_rmdir> to allow later additions if not yet empty
1898
1899- Added calls to <devfs_register_partitions> in drivers/block/blkpc.c
1900 <add_partition> and <del_partition>
1901
1902- Fixed bug in <devfs_alloc_unique_number>: was clearing beyond
1903 bitfield
1904
1905- Fixed bitfield data type for <devfs_*alloc_devnum>
1906
1907- Made major bitfield type and initialiser 64 bit safe
1908===============================================================================
1909Changes for patch v210
1910
1911- Updated fs/devfs/util.c to fix shift warning on 64 bit machines
1912 Thanks to Anton Blanchard <anton@samba.org>
1913
1914- Updated README from master HTML file
1915===============================================================================
1916Changes for patch v211
1917
1918- Do not put miscellaneous character devices in /dev/misc if they
1919 specify their own directory (i.e. contain a '/' character)
1920
1921- Copied macro for error messages from fs/devfs/base.c to
1922 fs/devfs/util.c and made use of this macro
1923
1924- Removed 2.4.x compatibility code from fs/devfs/base.c
1925===============================================================================
1926Changes for patch v212
1927
1928- Added BKL to <devfs_open> because drivers still need it
1929===============================================================================
1930Changes for patch v213
1931
1932- Protected <scan_dir_for_removable> and <get_removable_partition>
1933 from changing directory contents
1934===============================================================================
1935Changes for patch v214
1936
1937- Switched to ISO C structure field initialisers
1938
1939- Switch to set_current_state() and move before add_wait_queue()
1940
1941- Updated README from master HTML file
1942
1943- Fixed devfs entry leak in <devfs_readdir> when *readdir fails
1944===============================================================================
1945Changes for patch v215
1946
1947- Created <devfs_find_and_unregister>
1948
1949- Switched many functions from <devfs_find_handle> to
1950 <devfs_find_and_unregister>
1951
1952- Switched many functions from <devfs_find_handle> to <devfs_get_handle>
1953===============================================================================
1954Changes for patch v216
1955
1956- Switched arch/ia64/sn/io/hcl.c from <devfs_find_handle> to
1957 <devfs_get_handle>
1958
1959- Removed deprecated <devfs_find_handle>
1960===============================================================================
1961Changes for patch v217
1962
1963- Exported <devfs_find_and_unregister> and <devfs_only> to modules
1964
1965- Updated README from master HTML file
1966
1967- Fixed module unload race in <devfs_open>
1968===============================================================================
1969Changes for patch v218
1970
1971- Removed DEVFS_FL_AUTO_OWNER flag
1972
1973- Switched lingering structure field initialiser to ISO C
1974
1975- Added locking when setting/clearing flags
1976
1977- Documentation fix in fs/devfs/util.c
diff --git a/Documentation/filesystems/devfs/README b/Documentation/filesystems/devfs/README
deleted file mode 100644
index aabfba24bc2e..000000000000
--- a/Documentation/filesystems/devfs/README
+++ /dev/null
@@ -1,1959 +0,0 @@
1Devfs (Device File System) FAQ
2
3
4Linux Devfs (Device File System) FAQ
5Richard Gooch
620-AUG-2002
7
8
9Document languages:
10
11
12
13
14
15
16
17-----------------------------------------------------------------------------
18
19NOTE: the master copy of this document is available online at:
20
21http://www.atnf.csiro.au/~rgooch/linux/docs/devfs.html
22and looks much better than the text version distributed with the
23kernel sources. A mirror site is available at:
24
25http://www.ras.ucalgary.ca/~rgooch/linux/docs/devfs.html
26
27There is also an optional daemon that may be used with devfs. You can
28find out more about it at:
29
30http://www.atnf.csiro.au/~rgooch/linux/
31
32A mailing list is available which you may subscribe to. Send
33email
34to majordomo@oss.sgi.com with the following line in the
35body of the message:
36subscribe devfs
37To unsubscribe, send the message body:
38unsubscribe devfs
39instead. The list is archived at
40
41http://oss.sgi.com/projects/devfs/archive/.
42
43-----------------------------------------------------------------------------
44
45Contents
46
47
48What is it?
49
50Why do it?
51
52Who else does it?
53
54How it works
55
56Operational issues (essential reading)
57
58Instructions for the impatient
59Permissions persistence across reboots
60Dealing with drivers without devfs support
61All the way with Devfs
62Other Issues
63Kernel Naming Scheme
64Devfsd Naming Scheme
65Old Compatibility Names
66SCSI Host Probing Issues
67
68
69
70Device drivers currently ported
71
72Allocation of Device Numbers
73
74Questions and Answers
75
76Making things work
77Alternatives to devfs
78What I don't like about devfs
79How to report bugs
80Strange kernel messages
81Compilation problems with devfsd
82
83
84Other resources
85
86Translations of this document
87
88
89-----------------------------------------------------------------------------
90
91
92What is it?
93
94Devfs is an alternative to "real" character and block special devices
95on your root filesystem. Kernel device drivers can register devices by
96name rather than major and minor numbers. These devices will appear in
97devfs automatically, with whatever default ownership and
98protection the driver specified. A daemon (devfsd) can be used to
99override these defaults. Devfs has been in the kernel since 2.3.46.
100
101NOTE that devfs is entirely optional. If you prefer the old
102disc-based device nodes, then simply leave CONFIG_DEVFS_FS=n (the
103default). In this case, nothing will change. ALSO NOTE that if you do
104enable devfs, the defaults are such that full compatibility is
105maintained with the old devices names.
106
107There are two aspects to devfs: one is the underlying device
108namespace, which is a namespace just like any mounted filesystem. The
109other aspect is the filesystem code which provides a view of the
110device namespace. The reason I make a distinction is because devfs
111can be mounted many times, with each mount showing the same device
112namespace. Changes made are global to all mounted devfs filesystems.
113Also, because the devfs namespace exists without any devfs mounts, you
114can easily mount the root filesystem by referring to an entry in the
115devfs namespace.
116
117
118The cost of devfs is a small increase in kernel code size and memory
119usage. About 7 pages of code (some of that in __init sections) and 72
120bytes for each entry in the namespace. A modest system has only a
121couple of hundred device entries, so this costs a few more
122pages. Compare this with the suggestion to put /dev on a <a
123href="#why-faq-ramdisc">ramdisc.
124
125On a typical machine, the cost is under 0.2 percent. On a modest
126system with 64 MBytes of RAM, the cost is under 0.1 percent. The
127accusations of "bloatware" levelled at devfs are not justified.
128
129-----------------------------------------------------------------------------
130
131
132Why do it?
133
134There are several problems that devfs addresses. Some of these
135problems are more serious than others (depending on your point of
136view), and some can be solved without devfs. However, the totality of
137these problems really calls out for devfs.
138
139The choice is a patchwork of inefficient user space solutions, which
140are complex and likely to be fragile, or to use a simple and efficient
141devfs which is robust.
142
143There have been many counter-proposals to devfs, all seeking to
144provide some of the benefits without actually implementing devfs. So
145far there has been an absence of code and no proposed alternative has
146been able to provide all the features that devfs does. Further,
147alternative proposals require far more complexity in user-space (and
148still deliver less functionality than devfs). Some people have the
149mantra of reducing "kernel bloat", but don't consider the effects on
150user-space.
151
152A good solution limits the total complexity of kernel-space and
153user-space.
154
155
156Major&minor allocation
157
158The existing scheme requires the allocation of major and minor device
159numbers for each and every device. This means that a central
160co-ordinating authority is required to issue these device numbers
161(unless you're developing a "private" device driver), in order to
162preserve uniqueness. Devfs shifts the burden to a namespace. This may
163not seem like a huge benefit, but actually it is. Since driver authors
164will naturally choose a device name which reflects the functionality
165of the device, there is far less potential for namespace conflict.
166Solving this requires a kernel change.
167
168/dev management
169
170Because you currently access devices through device nodes, these must
171be created by the system administrator. For standard devices you can
172usually find a MAKEDEV programme which creates all these (hundreds!)
173of nodes. This means that changes in the kernel must be reflected by
174changes in the MAKEDEV programme, or else the system administrator
175creates device nodes by hand.
176
177The basic problem is that there are two separate databases of
178major and minor numbers. One is in the kernel and one is in /dev (or
179in a MAKEDEV programme, if you want to look at it that way). This is
180duplication of information, which is not good practice.
181Solving this requires a kernel change.
182
183/dev growth
184
185A typical /dev has over 1200 nodes! Most of these devices simply don't
186exist because the hardware is not available. A huge /dev increases the
187time to access devices (I'm just referring to the dentry lookup times
188and the time taken to read inodes off disc: the next subsection shows
189some more horrors).
190
191An example of how big /dev can grow is if we consider SCSI devices:
192
193host 6 bits (say up to 64 hosts on a really big machine)
194channel 4 bits (say up to 16 SCSI buses per host)
195id 4 bits
196lun 3 bits
197partition 6 bits
198TOTAL 23 bits
199
200
201This requires 8 Mega (1024*1024) inodes if we want to store all
202possible device nodes. Even if we scrap everything but id,partition
203and assume a single host adapter with a single SCSI bus and only one
204logical unit per SCSI target (id), that's still 10 bits or 1024
205inodes. Each VFS inode takes around 256 bytes (kernel 2.1.78), so
206that's 256 kBytes of inode storage on disc (assuming real inodes take
207a similar amount of space as VFS inodes). This is actually not so bad,
208because disc is cheap these days. Embedded systems would care about
209256 kBytes of /dev inodes, but you could argue that embedded systems
210would have hand-tuned /dev directories. I've had to do just that on my
211embedded systems, but I would rather just leave it to devfs.
212
213Another issue is the time taken to lookup an inode when first
214referenced. Not only does this take time in scanning through a list in
215memory, but also the seek times to read the inodes off disc.
216This could be solved in user-space using a clever programme which
217scanned the kernel logs and deleted /dev entries which are not
218available and created them when they were available. This programme
219would need to be run every time a new module was loaded, which would
220slow things down a lot.
221
222There is an existing programme called scsidev which will automatically
223create device nodes for SCSI devices. It can do this by scanning files
224in /proc/scsi. Unfortunately, to extend this idea to other device
225nodes would require significant modifications to existing drivers (so
226they too would provide information in /proc). This is a non-trivial
227change (I should know: devfs has had to do something similar). Once
228you go to this much effort, you may as well use devfs itself (which
229also provides this information). Furthermore, such a system would
230likely be implemented in an ad-hoc fashion, as different drivers will
231provide their information in different ways.
232
233Devfs is much cleaner, because it (naturally) has a uniform mechanism
234to provide this information: the device nodes themselves!
235
236
237Node to driver file_operations translation
238
239There is an important difference between the way disc-based character
240and block nodes and devfs entries make the connection between an entry
241in /dev and the actual device driver.
242
243With the current 8 bit major and minor numbers the connection between
244disc-based c&b nodes and per-major drivers is done through a
245fixed-length table of 128 entries. The various filesystem types set
246the inode operations for c&b nodes to {chr,blk}dev_inode_operations,
247so when a device is opened a few quick levels of indirection bring us
248to the driver file_operations.
249
250For miscellaneous character devices a second step is required: there
251is a scan for the driver entry with the same minor number as the file
252that was opened, and the appropriate minor open method is called. This
253scanning is done *every time* you open a device node. Potentially, you
254may be searching through dozens of misc. entries before you find your
255open method. While not an enormous performance overhead, this does
256seem pointless.
257
258Linux *must* move beyond the 8 bit major and minor barrier,
259somehow. If we simply increase each to 16 bits, then the indexing
260scheme used for major driver lookup becomes untenable, because the
261major tables (one each for character and block devices) would need to
262be 64 k entries long (512 kBytes on x86, 1 MByte for 64 bit
263systems). So we would have to use a scheme like that used for
264miscellaneous character devices, which means the search time goes up
265linearly with the average number of major device drivers on your
266system. Not all "devices" are hardware, some are higher-level drivers
267like KGI, so you can get more "devices" without adding hardware
268You can improve this by creating an ordered (balanced:-)
269binary tree, in which case your search time becomes log(N).
270Alternatively, you can use hashing to speed up the search.
271But why do that search at all if you don't have to? Once again, it
272seems pointless.
273
274Note that devfs doesn't use the major&minor system. For devfs
275entries, the connection is done when you lookup the /dev entry. When
276devfs_register() is called, an internal table is appended which has
277the entry name and the file_operations. If the dentry cache doesn't
278have the /dev entry already, this internal table is scanned to get the
279file_operations, and an inode is created. If the dentry cache already
280has the entry, there is *no lookup time* (other than the dentry scan
281itself, but we can't avoid that anyway, and besides Linux dentries
282cream other OS's which don't have them:-). Furthermore, the number of
283node entries in a devfs is only the number of available device
284entries, not the number of *conceivable* entries. Even if you remove
285unnecessary entries in a disc-based /dev, the number of conceivable
286entries remains the same: you just limit yourself in order to save
287space.
288
289Devfs provides a fast connection between a VFS node and the device
290driver, in a scalable way.
291
292/dev as a system administration tool
293
294Right now /dev contains a list of conceivable devices, most of which I
295don't have. Devfs only shows those devices available on my
296system. This means that listing /dev is a handy way of checking what
297devices are available.
298
299Major&minor size
300
301Existing major and minor numbers are limited to 8 bits each. This is
302now a limiting factor for some drivers, particularly the SCSI disc
303driver, which consumes a single major number. Only 16 discs are
304supported, and each disc may have only 15 partitions. Maybe this isn't
305a problem for you, but some of us are building huge Linux systems with
306disc arrays. With devfs an arbitrary pointer can be associated with
307each device entry, which can be used to give an effective 32 bit
308device identifier (i.e. that's like having a 32 bit minor
309number). Since this is private to the kernel, there are no C library
310compatibility issues which you would have with increasing major and
311minor number sizes. See the section on "Allocation of Device Numbers"
312for details on maintaining compatibility with userspace.
313
314Solving this requires a kernel change.
315
316Since writing this, the kernel has been modified so that the SCSI disc
317driver has more major numbers allocated to it and now supports up to
318128 discs. Since these major numbers are non-contiguous (a result of
319unplanned expansion), the implementation is a little more cumbersome
320than originally.
321
322Just like the changes to IPv4 to fix impending limitations in the
323address space, people find ways around the limitations. In the long
324run, however, solutions like IPv6 or devfs can't be put off forever.
325
326Read-only root filesystem
327
328Having your device nodes on the root filesystem means that you can't
329operate properly with a read-only root filesystem. This is because you
330want to change ownerships and protections of tty devices. Existing
331practice prevents you using a CD-ROM as your root filesystem for a
332*real* system. Sure, you can boot off a CD-ROM, but you can't change
333tty ownerships, so it's only good for installing.
334
335Also, you can't use a shared NFS root filesystem for a cluster of
336discless Linux machines (having tty ownerships changed on a common
337/dev is not good). Nor can you embed your root filesystem in a
338ROM-FS.
339
340You can get around this by creating a RAMDISC at boot time, making
341an ext2 filesystem in it, mounting it somewhere and copying the
342contents of /dev into it, then unmounting it and mounting it over
343/dev.
344
345A devfs is a cleaner way of solving this.
346
347Non-Unix root filesystem
348
349Non-Unix filesystems (such as NTFS) can't be used for a root
350filesystem because they variously don't support character and block
351special files or symbolic links. You can't have a separate disc-based
352or RAMDISC-based filesystem mounted on /dev because you need device
353nodes before you can mount these. Devfs can be mounted without any
354device nodes. Devlinks won't work because symlinks aren't supported.
355An alternative solution is to use initrd to mount a RAMDISC initial
356root filesystem (which is populated with a minimal set of device
357nodes), and then construct a new /dev in another RAMDISC, and finally
358switch to your non-Unix root filesystem. This requires clever boot
359scripts and a fragile and conceptually complex boot procedure.
360
361Devfs solves this in a robust and conceptually simple way.
362
363PTY security
364
365Current pseudo-tty (pty) devices are owned by root and read-writable
366by everyone. The user of a pty-pair cannot change
367ownership/protections without being suid-root.
368
369This could be solved with a secure user-space daemon which runs as
370root and does the actual creation of pty-pairs. Such a daemon would
371require modification to *every* programme that wants to use this new
372mechanism. It also slows down creation of pty-pairs.
373
374An alternative is to create a new open_pty() syscall which does much
375the same thing as the user-space daemon. Once again, this requires
376modifications to pty-handling programmes.
377
378The devfs solution allows a device driver to "tag" certain device
379files so that when an unopened device is opened, the ownerships are
380changed to the current euid and egid of the opening process, and the
381protections are changed to the default registered by the driver. When
382the device is closed ownership is set back to root and protections are
383set back to read-write for everybody. No programme need be changed.
384The devpts filesystem provides this auto-ownership feature for Unix98
385ptys. It doesn't support old-style pty devices, nor does it have all
386the other features of devfs.
387
388Intelligent device management
389
390Devfs implements a simple yet powerful protocol for communication with
391a device management daemon (devfsd) which runs in user space. It is
392possible to send a message (either synchronously or asynchronously) to
393devfsd on any event, such as registration/unregistration of device
394entries, opening and closing devices, looking up inodes, scanning
395directories and more. This has many possibilities. Some of these are
396already implemented. See:
397
398
399http://www.atnf.csiro.au/~rgooch/linux/
400
401Device entry registration events can be used by devfsd to change
402permissions of newly-created device nodes. This is one mechanism to
403control device permissions.
404
405Device entry registration/unregistration events can be used to run
406programmes or scripts. This can be used to provide automatic mounting
407of filesystems when a new block device media is inserted into the
408drive.
409
410Asynchronous device open and close events can be used to implement
411clever permissions management. For example, the default permissions on
412/dev/dsp do not allow everybody to read from the device. This is
413sensible, as you don't want some remote user recording what you say at
414your console. However, the console user is also prevented from
415recording. This behaviour is not desirable. With asynchronous device
416open and close events, you can have devfsd run a programme or script
417when console devices are opened to change the ownerships for *other*
418device nodes (such as /dev/dsp). On closure, you can run a different
419script to restore permissions. An advantage of this scheme over
420modifying the C library tty handling is that this works even if your
421programme crashes (how many times have you seen the utmp database with
422lingering entries for non-existent logins?).
423
424Synchronous device open events can be used to perform intelligent
425device access protections. Before the device driver open() method is
426called, the daemon must first validate the open attempt, by running an
427external programme or script. This is far more flexible than access
428control lists, as access can be determined on the basis of other
429system conditions instead of just the UID and GID.
430
431Inode lookup events can be used to authenticate module autoload
432requests. Instead of using kmod directly, the event is sent to
433devfsd which can implement an arbitrary authentication before loading
434the module itself.
435
436Inode lookup events can also be used to construct arbitrary
437namespaces, without having to resort to populating devfs with symlinks
438to devices that don't exist.
439
440Speculative Device Scanning
441
442Consider an application (like cdparanoia) that wants to find all
443CD-ROM devices on the system (SCSI, IDE and other types), whether or
444not their respective modules are loaded. The application must
445speculatively open certain device nodes (such as /dev/sr0 for the SCSI
446CD-ROMs) in order to make sure the module is loaded. This requires
447that all Linux distributions follow the standard device naming scheme
448(last time I looked RedHat did things differently). Devfs solves the
449naming problem.
450
451The same application also wants to see which devices are actually
452available on the system. With the existing system it needs to read the
453/dev directory and speculatively open each /dev/sr* device to
454determine if the device exists or not. With a large /dev this is an
455inefficient operation, especially if there are many /dev/sr* nodes. A
456solution like scsidev could reduce the number of /dev/sr* entries (but
457of course that also requires all that inefficient directory scanning).
458
459With devfs, the application can open the /dev/sr directory
460(which triggers the module autoloading if required), and proceed to
461read /dev/sr. Since only the available devices will have
462entries, there are no inefficencies in directory scanning or device
463openings.
464
465-----------------------------------------------------------------------------
466
467Who else does it?
468
469FreeBSD has a devfs implementation. Solaris and AIX each have a
470pseudo-devfs (something akin to scsidev but for all devices, with some
471unspecified kernel support). BeOS, Plan9 and QNX also have it. SGI's
472IRIX 6.4 and above also have a device filesystem.
473
474While we shouldn't just automatically do something because others do
475it, we should not ignore the work of others either. FreeBSD has a lot
476of competent people working on it, so their opinion should not be
477blithely ignored.
478
479-----------------------------------------------------------------------------
480
481
482How it works
483
484Registering device entries
485
486For every entry (device node) in a devfs-based /dev a driver must call
487devfs_register(). This adds the name of the device entry, the
488file_operations structure pointer and a few other things to an
489internal table. Device entries may be added and removed at any
490time. When a device entry is registered, it automagically appears in
491any mounted devfs'.
492
493Inode lookup
494
495When a lookup operation on an entry is performed and if there is no
496driver information for that entry devfs will attempt to call
497devfsd. If still no driver information can be found then a negative
498dentry is yielded and the next stage operation will be called by the
499VFS (such as create() or mknod() inode methods). If driver information
500can be found, an inode is created (if one does not exist already) and
501all is well.
502
503Manually creating device nodes
504
505The mknod() method allows you to create an ordinary named pipe in the
506devfs, or you can create a character or block special inode if one
507does not already exist. You may wish to create a character or block
508special inode so that you can set permissions and ownership. Later, if
509a device driver registers an entry with the same name, the
510permissions, ownership and times are retained. This is how you can set
511the protections on a device even before the driver is loaded. Once you
512create an inode it appears in the directory listing.
513
514Unregistering device entries
515
516A device driver calls devfs_unregister() to unregister an entry.
517
518Chroot() gaols
519
5202.2.x kernels
521
522The semantics of inode creation are different when devfs is mounted
523with the "explicit" option. Now, when a device entry is registered, it
524will not appear until you use mknod() to create the device. It doesn't
525matter if you mknod() before or after the device is registered with
526devfs_register(). The purpose of this behaviour is to support
527chroot(2) gaols, where you want to mount a minimal devfs inside the
528gaol. Only the devices you specifically want to be available (through
529your mknod() setup) will be accessible.
530
5312.4.x kernels
532
533As of kernel 2.3.99, the VFS has had the ability to rebind parts of
534the global filesystem namespace into another part of the namespace.
535This now works even at the leaf-node level, which means that
536individual files and device nodes may be bound into other parts of the
537namespace. This is like making links, but better, because it works
538across filesystems (unlike hard links) and works through chroot()
539gaols (unlike symbolic links).
540
541Because of these improvements to the VFS, the multi-mount capability
542in devfs is no longer needed. The administrator may create a minimal
543device tree inside a chroot(2) gaol by using VFS bindings. As this
544provides most of the features of the devfs multi-mount capability, I
545removed the multi-mount support code (after issuing an RFC). This
546yielded code size reductions and simplifications.
547
548If you want to construct a minimal chroot() gaol, the following
549command should suffice:
550
551mount --bind /dev/null /gaol/dev/null
552
553
554Repeat for other device nodes you want to expose. Simple!
555
556-----------------------------------------------------------------------------
557
558
559Operational issues
560
561
562Instructions for the impatient
563
564Nobody likes reading documentation. People just want to get in there
565and play. So this section tells you quickly the steps you need to take
566to run with devfs mounted over /dev. Skip these steps and you will end
567up with a nearly unbootable system. Subsequent sections describe the
568issues in more detail, and discuss non-essential configuration
569options.
570
571Devfsd
572OK, if you're reading this, I assume you want to play with
573devfs. First you should ensure that /usr/src/linux contains a
574recent kernel source tree. Then you need to compile devfsd, the device
575management daemon, available at
576
577http://www.atnf.csiro.au/~rgooch/linux/.
578Because the kernel has a naming scheme
579which is quite different from the old naming scheme, you need to
580install devfsd so that software and configuration files that use the
581old naming scheme will not break.
582
583Compile and install devfsd. You will be provided with a default
584configuration file /etc/devfsd.conf which will provide
585compatibility symlinks for the old naming scheme. Don't change this
586config file unless you know what you're doing. Even if you think you
587do know what you're doing, don't change it until you've followed all
588the steps below and booted a devfs-enabled system and verified that it
589works.
590
591Now edit your main system boot script so that devfsd is started at the
592very beginning (before any filesystem
593checks). /etc/rc.d/rc.sysinit is often the main boot script
594on systems with SysV-style boot scripts. On systems with BSD-style
595boot scripts it is often /etc/rc. Also check
596/sbin/rc.
597
598NOTE that the line you put into the boot
599script should be exactly:
600
601/sbin/devfsd /dev
602
603DO NOT use some special daemon-launching
604programme, otherwise the boot script may not wait for devfsd to finish
605initialising.
606
607System Libraries
608There may still be some problems because of broken software making
609assumptions about device names. In particular, some software does not
610handle devices which are symbolic links. If you are running a libc 5
611based system, install libc 5.4.44 (if you have libc 5.4.46, go back to
612libc 5.4.44, which is actually correct). If you are running a glibc
613based system, make sure you have glibc 2.1.3 or later.
614
615/etc/securetty
616PAM (Pluggable Authentication Modules) is supposed to be a flexible
617mechanism for providing better user authentication and access to
618services. Unfortunately, it's also fragile, complex and undocumented
619(check out RedHat 6.1, and probably other distributions as well). PAM
620has problems with symbolic links. Append the following lines to your
621/etc/securetty file:
622
623vc/1
624vc/2
625vc/3
626vc/4
627vc/5
628vc/6
629vc/7
630vc/8
631
632This will not weaken security. If you have a version of util-linux
633earlier than 2.10.h, please upgrade to 2.10.h or later. If you
634absolutely cannot upgrade, then also append the following lines to
635your /etc/securetty file:
636
6371
6382
6393
6404
6415
6426
6437
6448
645
646This may potentially weaken security by allowing root logins over the
647network (a password is still required, though). However, since there
648are problems with dealing with symlinks, I'm suspicious of the level
649of security offered in any case.
650
651XFree86
652While not essential, it's probably a good idea to upgrade to XFree86
6534.0, as patches went in to make it more devfs-friendly. If you don't,
654you'll probably need to apply the following patch to
655/etc/security/console.perms so that ordinary users can run
656startx. Note that not all distributions have this file (e.g. Debian),
657so if it's not present, don't worry about it.
658
659--- /etc/security/console.perms.orig Sat Apr 17 16:26:47 1999
660+++ /etc/security/console.perms Fri Feb 25 23:53:55 2000
661@@ -14,7 +14,7 @@
662 # man 5 console.perms
663
664 # file classes -- these are regular expressions
665-<console>=tty[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
666+<console>=tty[0-9][0-9]* vc/[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
667
668 # device classes -- these are shell-style globs
669 <floppy>=/dev/fd[0-1]*
670
671If the patch does not apply, then change the line:
672
673<console>=tty[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
674
675with:
676
677<console>=tty[0-9][0-9]* vc/[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
678
679
680Disable devpts
681I've had a report of devpts mounted on /dev/pts not working
682correctly. Since devfs will also manage /dev/pts, there is no
683need to mount devpts as well. You should either edit your
684/etc/fstab so devpts is not mounted, or disable devpts from
685your kernel configuration.
686
687Unsupported drivers
688Not all drivers have devfs support. If you depend on one of these
689drivers, you will need to create a script or tarfile that you can use
690at boot time to create device nodes as appropriate. There is a
691section which describes this. Another
692section lists the drivers which have
693devfs support.
694
695/dev/mouse
696
697Many disributions configure /dev/mouse to be the mouse device
698for XFree86 and GPM. I actually think this is a bad idea, because it
699adds another level of indirection. When looking at a config file, if
700you see /dev/mouse you're left wondering which mouse
701is being referred to. Hence I recommend putting the actual mouse
702device (for example /dev/psaux) into your
703/etc/X11/XF86Config file (and similarly for the GPM
704configuration file).
705
706Alternatively, use the same technique used for unsupported drivers
707described above.
708
709The Kernel
710Finally, you need to make sure devfs is compiled into your kernel. Set
711CONFIG_EXPERIMENTAL=y, CONFIG_DEVFS_FS=y and CONFIG_DEVFS_MOUNT=y by
712using favourite configuration tool (i.e. make config or
713make xconfig) and then make clean and then recompile your kernel and
714modules. At boot, devfs will be mounted onto /dev.
715
716If you encounter problems booting (for example if you forgot a
717configuration step), you can pass devfs=nomount at the kernel
718boot command line. This will prevent the kernel from mounting devfs at
719boot time onto /dev.
720
721In general, a kernel built with CONFIG_DEVFS_FS=y but without mounting
722devfs onto /dev is completely safe, and requires no
723configuration changes. One exception to take note of is when
724LABEL= directives are used in /etc/fstab. In this
725case you will be unable to boot properly. This is because the
726mount(8) programme uses /proc/partitions as part of
727the volume label search process, and the device names it finds are not
728available, because setting CONFIG_DEVFS_FS=y changes the names in
729/proc/partitions, irrespective of whether devfs is mounted.
730
731Now you've finished all the steps required. You're now ready to boot
732your shiny new kernel. Enjoy.
733
734Changing the configuration
735
736OK, you've now booted a devfs-enabled system, and everything works.
737Now you may feel like changing the configuration (common targets are
738/etc/fstab and /etc/devfsd.conf). Since you have a
739system that works, if you make any changes and it doesn't work, you
740now know that you only have to restore your configuration files to the
741default and it will work again.
742
743
744Permissions persistence across reboots
745
746If you don't use mknod(2) to create a device file, nor use chmod(2) or
747chown(2) to change the ownerships/permissions, the inode ctime will
748remain at 0 (the epoch, 12 am, 1-JAN-1970, GMT). Anything with a ctime
749later than this has had it's ownership/permissions changed. Hence, a
750simple script or programme may be used to tar up all changed inodes,
751prior to shutdown. Although effective, many consider this approach a
752kludge.
753
754A much better approach is to use devfsd to save and restore
755permissions. It may be configured to record changes in permissions and
756will save them in a database (in fact a directory tree), and restore
757these upon boot. This is an efficient method and results in immediate
758saving of current permissions (unlike the tar approach, which saves
759permissions at some unspecified future time).
760
761The default configuration file supplied with devfsd has config entries
762which you may uncomment to enable persistence management.
763
764If you decide to use the tar approach anyway, be aware that tar will
765first unlink(2) an inode before creating a new device node. The
766unlink(2) has the effect of breaking the connection between a devfs
767entry and the device driver. If you use the "devfs=only" boot option,
768you lose access to the device driver, requiring you to reload the
769module. I consider this a bug in tar (there is no real need to
770unlink(2) the inode first).
771
772Alternatively, you can use devfsd to provide more sophisticated
773management of device permissions. You can use devfsd to store
774permissions for whole groups of devices with a single configuration
775entry, rather than the conventional single entry per device entry.
776
777Permissions database stored in mounted-over /dev
778
779If you wish to save and restore your device permissions into the
780disc-based /dev while still mounting devfs onto /dev
781you may do so. This requires a 2.4.x kernel (in fact, 2.3.99 or
782later), which has the VFS binding facility. You need to do the
783following to set this up:
784
785
786
787make sure the kernel does not mount devfs at boot time
788
789
790make sure you have a correct /dev/console entry in your
791root file-system (where your disc-based /dev lives)
792
793create the /dev-state directory
794
795
796add the following lines near the very beginning of your boot
797scripts:
798
799mount --bind /dev /dev-state
800mount -t devfs none /dev
801devfsd /dev
802
803
804
805
806add the following lines to your /etc/devfsd.conf file:
807
808REGISTER ^pt[sy] IGNORE
809CREATE ^pt[sy] IGNORE
810CHANGE ^pt[sy] IGNORE
811DELETE ^pt[sy] IGNORE
812REGISTER .* COPY /dev-state/$devname $devpath
813CREATE .* COPY $devpath /dev-state/$devname
814CHANGE .* COPY $devpath /dev-state/$devname
815DELETE .* CFUNCTION GLOBAL unlink /dev-state/$devname
816RESTORE /dev-state
817
818Note that the sample devfsd.conf file contains these lines,
819as well as other sample configurations you may find useful. See the
820devfsd distribution
821
822
823reboot.
824
825
826
827
828Permissions database stored in normal directory
829
830If you are using an older kernel which doesn't support VFS binding,
831then you won't be able to have the permissions database in a
832mounted-over /dev. However, you can still use a regular
833directory to store the database. The sample /etc/devfsd.conf
834file above may still be used. You will need to create the
835/dev-state directory prior to installing devfsd. If you have
836old permissions in /dev, then just copy (or move) the device
837nodes over to the new directory.
838
839Which method is better?
840
841The best method is to have the permissions database stored in the
842mounted-over /dev. This is because you will not need to copy
843device nodes over to /dev-state, and because it allows you to
844switch between devfs and non-devfs kernels, without requiring you to
845copy permissions between /dev-state (for devfs) and
846/dev (for non-devfs).
847
848
849Dealing with drivers without devfs support
850
851Currently, not all device drivers in the kernel have been modified to
852use devfs. Device drivers which do not yet have devfs support will not
853automagically appear in devfs. The simplest way to create device nodes
854for these drivers is to unpack a tarfile containing the required
855device nodes. You can do this in your boot scripts. All your drivers
856will now work as before.
857
858Hopefully for most people devfs will have enough support so that they
859can mount devfs directly over /dev without losing most functionality
860(i.e. losing access to various devices). As of 22-JAN-1998 (devfs
861patch version 10) I am now running this way. All the devices I have
862are available in devfs, so I don't lose anything.
863
864WARNING: if your configuration requires the old-style device names
865(i.e. /dev/hda1 or /dev/sda1), you must install devfsd and configure
866it to maintain compatibility entries. It is almost certain that you
867will require this. Note that the kernel creates a compatibility entry
868for the root device, so you don't need initrd.
869
870Note that you no longer need to mount devpts if you use Unix98 PTYs,
871as devfs can manage /dev/pts itself. This saves you some RAM, as you
872don't need to compile and install devpts. Note that some versions of
873glibc have a bug with Unix98 pty handling on devfs systems. Contact
874the glibc maintainers for a fix. Glibc 2.1.3 has the fix.
875
876Note also that apart from editing /etc/fstab, other things will need
877to be changed if you *don't* install devfsd. Some software (like the X
878server) hard-wire device names in their source. It really is much
879easier to install devfsd so that compatibility entries are created.
880You can then slowly migrate your system to using the new device names
881(for example, by starting with /etc/fstab), and then limiting the
882compatibility entries that devfsd creates.
883
884IF YOU CONFIGURE TO MOUNT DEVFS AT BOOT, MAKE SURE YOU INSTALL DEVFSD
885BEFORE YOU BOOT A DEVFS-ENABLED KERNEL!
886
887Now that devfs has gone into the 2.3.46 kernel, I'm getting a lot of
888reports back. Many of these are because people are trying to run
889without devfsd, and hence some things break. Please just run devfsd if
890things break. I want to concentrate on real bugs rather than
891misconfiguration problems at the moment. If people are willing to fix
892bugs/false assumptions in other code (i.e. glibc, X server) and submit
893that to the respective maintainers, that would be great.
894
895
896All the way with Devfs
897
898The devfs kernel patch creates a rationalised device tree. As stated
899above, if you want to keep using the old /dev naming scheme,
900you just need to configure devfsd appopriately (see the man
901page). People who prefer the old names can ignore this section. For
902those of us who like the rationalised names and an uncluttered
903/dev, read on.
904
905If you don't run devfsd, or don't enable compatibility entry
906management, then you will have to configure your system to use the new
907names. For example, you will then need to edit your
908/etc/fstab to use the new disc naming scheme. If you want to
909be able to boot non-devfs kernels, you will need compatibility
910symlinks in the underlying disc-based /dev pointing back to
911the old-style names for when you boot a kernel without devfs.
912
913You can selectively decide which devices you want compatibility
914entries for. For example, you may only want compatibility entries for
915BSD pseudo-terminal devices (otherwise you'll have to patch you C
916library or use Unix98 ptys instead). It's just a matter of putting in
917the correct regular expression into /dev/devfsd.conf.
918
919There are other choices of naming schemes that you may prefer. For
920example, I don't use the kernel-supplied
921names, because they are too verbose. A common misconception is
922that the kernel-supplied names are meant to be used directly in
923configuration files. This is not the case. They are designed to
924reflect the layout of the devices attached and to provide easy
925classification.
926
927If you like the kernel-supplied names, that's fine. If you don't then
928you should be using devfsd to construct a namespace more to your
929liking. Devfsd has built-in code to construct a
930namespace that is both logical and easy to
931manage. In essence, it creates a convenient abbreviation of the
932kernel-supplied namespace.
933
934You are of course free to build your own namespace. Devfsd has all the
935infrastructure required to make this easy for you. All you need do is
936write a script. You can even write some C code and devfsd can load the
937shared object as a callable extension.
938
939
940Other Issues
941
942The init programme
943Another thing to take note of is whether your init programme
944creates a Unix socket /dev/telinit. Some versions of init
945create /dev/telinit so that the telinit programme can
946communicate with the init process. If you have such a system you need
947to make sure that devfs is mounted over /dev *before* init
948starts. In other words, you can't leave the mounting of devfs to
949/etc/rc, since this is executed after init. Other
950versions of init require a named pipe /dev/initctl
951which must exist *before* init starts. Once again, you need to
952mount devfs and then create the named pipe *before* init
953starts.
954
955The default behaviour now is not to mount devfs onto /dev at
956boot time for 2.3.x and later kernels. You can correct this with the
957"devfs=mount" boot option. This solves any problems with init,
958and also prevents the dreaded:
959
960Cannot open initial console
961
962message. For 2.2.x kernels where you need to apply the devfs patch,
963the default is to mount.
964
965If you have automatic mounting of devfs onto /dev then you
966may need to create /dev/initctl in your boot scripts. The
967following lines should suffice:
968
969mknod /dev/initctl p
970kill -SIGUSR1 1 # tell init that /dev/initctl now exists
971
972Alternatively, if you don't want the kernel to mount devfs onto
973/dev then you could use the following procedure is a
974guideline for how to get around /dev/initctl problems:
975
976# cd /sbin
977# mv init init.real
978# cat > init
979#! /bin/sh
980mount -n -t devfs none /dev
981mknod /dev/initctl p
982exec /sbin/init.real $*
983[control-D]
984# chmod a+x init
985
986Note that newer versions of init create /dev/initctl
987automatically, so you don't have to worry about this.
988
989Module autoloading
990You will need to configure devfsd to enable module
991autoloading. The following lines should be placed in your
992/etc/devfsd.conf file:
993
994LOOKUP .* MODLOAD
995
996
997As of devfsd-v1.3.10, a generic /etc/modules.devfs
998configuration file is installed, which is used by the MODLOAD
999action. This should be sufficient for most configurations. If you
1000require further configuration, edit your /etc/modules.conf
1001file. The way module autoloading work with devfs is:
1002
1003
1004a process attempts to lookup a device node (e.g. /dev/fred)
1005
1006
1007if that device node does not exist, the full pathname is passed to
1008devfsd as a string
1009
1010
1011devfsd will pass the string to the modprobe programme (provided the
1012configuration line shown above is present), and specifies that
1013/etc/modules.devfs is the configuration file
1014
1015
1016/etc/modules.devfs includes /etc/modules.conf to
1017access local configurations
1018
1019modprobe will search it's configuration files, looking for an alias
1020that translates the pathname into a module name
1021
1022
1023the translated pathname is then used to load the module.
1024
1025
1026If you wanted a lookup of /dev/fred to load the
1027mymod module, you would require the following configuration
1028line in /etc/modules.conf:
1029
1030alias /dev/fred mymod
1031
1032The /etc/modules.devfs configuration file provides many such
1033aliases for standard device names. If you look closely at this file,
1034you will note that some modules require multiple alias configuration
1035lines. This is required to support module autoloading for old and new
1036device names.
1037
1038Mounting root off a devfs device
1039If you wish to mount root off a devfs device when you pass the
1040"devfs=only" boot option, then you need to pass in the
1041"root=<device>" option to the kernel when booting. If you use
1042LILO, then you must have this in lilo.conf:
1043
1044append = "root=<device>"
1045
1046Surprised? Yep, so was I. It turns out if you have (as most people
1047do):
1048
1049root = <device>
1050
1051
1052then LILO will determine the device number of <device> and will
1053write that device number into a special place in the kernel image
1054before starting the kernel, and the kernel will use that device number
1055to mount the root filesystem. So, using the "append" variety ensures
1056that LILO passes the root filesystem device as a string, which devfs
1057can then use.
1058
1059Note that this isn't an issue if you don't pass "devfs=only".
1060
1061TTY issues
1062The ttyname(3) function in some versions of the C library makes
1063false assumptions about device entries which are symbolic links. The
1064tty(1) programme is one that depends on this function. I've
1065written a patch to libc 5.4.43 which fixes this. This has been
1066included in libc 5.4.44 and a similar fix is in glibc 2.1.3.
1067
1068
1069Kernel Naming Scheme
1070
1071The kernel provides a default naming scheme. This scheme is designed
1072to make it easy to search for specific devices or device types, and to
1073view the available devices. Some device types (such as hard discs),
1074have a directory of entries, making it easy to see what devices of
1075that class are available. Often, the entries are symbolic links into a
1076directory tree that reflects the topology of available devices. The
1077topological tree is useful for finding how your devices are arranged.
1078
1079Below is a list of the naming schemes for the most common drivers. A
1080list of reserved device names is
1081available for reference. Please send email to
1082rgooch@atnf.csiro.au to obtain an allocation. Please be
1083patient (the maintainer is busy). An alternative name may be allocated
1084instead of the requested name, at the discretion of the maintainer.
1085
1086Disc Devices
1087
1088All discs, whether SCSI, IDE or whatever, are placed under the
1089/dev/discs hierarchy:
1090
1091 /dev/discs/disc0 first disc
1092 /dev/discs/disc1 second disc
1093
1094
1095Each of these entries is a symbolic link to the directory for that
1096device. The device directory contains:
1097
1098 disc for the whole disc
1099 part* for individual partitions
1100
1101
1102CD-ROM Devices
1103
1104All CD-ROMs, whether SCSI, IDE or whatever, are placed under the
1105/dev/cdroms hierarchy:
1106
1107 /dev/cdroms/cdrom0 first CD-ROM
1108 /dev/cdroms/cdrom1 second CD-ROM
1109
1110
1111Each of these entries is a symbolic link to the real device entry for
1112that device.
1113
1114Tape Devices
1115
1116All tapes, whether SCSI, IDE or whatever, are placed under the
1117/dev/tapes hierarchy:
1118
1119 /dev/tapes/tape0 first tape
1120 /dev/tapes/tape1 second tape
1121
1122
1123Each of these entries is a symbolic link to the directory for that
1124device. The device directory contains:
1125
1126 mt for mode 0
1127 mtl for mode 1
1128 mtm for mode 2
1129 mta for mode 3
1130 mtn for mode 0, no rewind
1131 mtln for mode 1, no rewind
1132 mtmn for mode 2, no rewind
1133 mtan for mode 3, no rewind
1134
1135
1136SCSI Devices
1137
1138To uniquely identify any SCSI device requires the following
1139information:
1140
1141 controller (host adapter)
1142 bus (SCSI channel)
1143 target (SCSI ID)
1144 unit (Logical Unit Number)
1145
1146
1147All SCSI devices are placed under /dev/scsi (assuming devfs
1148is mounted on /dev). Hence, a SCSI device with the following
1149parameters: c=1,b=2,t=3,u=4 would appear as:
1150
1151 /dev/scsi/host1/bus2/target3/lun4 device directory
1152
1153
1154Inside this directory, a number of device entries may be created,
1155depending on which SCSI device-type drivers were installed.
1156
1157See the section on the disc naming scheme to see what entries the SCSI
1158disc driver creates.
1159
1160See the section on the tape naming scheme to see what entries the SCSI
1161tape driver creates.
1162
1163The SCSI CD-ROM driver creates:
1164
1165 cd
1166
1167
1168The SCSI generic driver creates:
1169
1170 generic
1171
1172
1173IDE Devices
1174
1175To uniquely identify any IDE device requires the following
1176information:
1177
1178 controller
1179 bus (aka. primary/secondary)
1180 target (aka. master/slave)
1181 unit
1182
1183
1184All IDE devices are placed under /dev/ide, and uses a similar
1185naming scheme to the SCSI subsystem.
1186
1187XT Hard Discs
1188
1189All XT discs are placed under /dev/xd. The first XT disc has
1190the directory /dev/xd/disc0.
1191
1192TTY devices
1193
1194The tty devices now appear as:
1195
1196 New name Old-name Device Type
1197 -------- -------- -----------
1198 /dev/tts/{0,1,...} /dev/ttyS{0,1,...} Serial ports
1199 /dev/cua/{0,1,...} /dev/cua{0,1,...} Call out devices
1200 /dev/vc/0 /dev/tty Current virtual console
1201 /dev/vc/{1,2,...} /dev/tty{1...63} Virtual consoles
1202 /dev/vcc/{0,1,...} /dev/vcs{1...63} Virtual consoles
1203 /dev/pty/m{0,1,...} /dev/ptyp?? PTY masters
1204 /dev/pty/s{0,1,...} /dev/ttyp?? PTY slaves
1205
1206
1207RAMDISCS
1208
1209The RAMDISCS are placed in their own directory, and are named thus:
1210
1211 /dev/rd/{0,1,2,...}
1212
1213
1214Meta Devices
1215
1216The meta devices are placed in their own directory, and are named
1217thus:
1218
1219 /dev/md/{0,1,2,...}
1220
1221
1222Floppy discs
1223
1224Floppy discs are placed in the /dev/floppy directory.
1225
1226Loop devices
1227
1228Loop devices are placed in the /dev/loop directory.
1229
1230Sound devices
1231
1232Sound devices are placed in the /dev/sound directory
1233(audio, sequencer, ...).
1234
1235
1236Devfsd Naming Scheme
1237
1238Devfsd provides a naming scheme which is a convenient abbreviation of
1239the kernel-supplied namespace. In some
1240cases, the kernel-supplied naming scheme is quite convenient, so
1241devfsd does not provide another naming scheme. The convenience names
1242that devfsd creates are in fact the same names as the original devfs
1243kernel patch created (before Linus mandated the Big Name
1244Change). These are referred to as "new compatibility entries".
1245
1246In order to configure devfsd to create these convenience names, the
1247following lines should be placed in your /etc/devfsd.conf:
1248
1249REGISTER .* MKNEWCOMPAT
1250UNREGISTER .* RMNEWCOMPAT
1251
1252This will cause devfsd to create (and destroy) symbolic links which
1253point to the kernel-supplied names.
1254
1255SCSI Hard Discs
1256
1257All SCSI discs are placed under /dev/sd (assuming devfs is
1258mounted on /dev). Hence, a SCSI disc with the following
1259parameters: c=1,b=2,t=3,u=4 would appear as:
1260
1261 /dev/sd/c1b2t3u4 for the whole disc
1262 /dev/sd/c1b2t3u4p5 for the 5th partition
1263 /dev/sd/c1b2t3u4p5s6 for the 6th slice in the 5th partition
1264
1265
1266SCSI Tapes
1267
1268All SCSI tapes are placed under /dev/st. A similar naming
1269scheme is used as for SCSI discs. A SCSI tape with the
1270parameters:c=1,b=2,t=3,u=4 would appear as:
1271
1272 /dev/st/c1b2t3u4m0 for mode 0
1273 /dev/st/c1b2t3u4m1 for mode 1
1274 /dev/st/c1b2t3u4m2 for mode 2
1275 /dev/st/c1b2t3u4m3 for mode 3
1276 /dev/st/c1b2t3u4m0n for mode 0, no rewind
1277 /dev/st/c1b2t3u4m1n for mode 1, no rewind
1278 /dev/st/c1b2t3u4m2n for mode 2, no rewind
1279 /dev/st/c1b2t3u4m3n for mode 3, no rewind
1280
1281
1282SCSI CD-ROMs
1283
1284All SCSI CD-ROMs are placed under /dev/sr. A similar naming
1285scheme is used as for SCSI discs. A SCSI CD-ROM with the
1286parameters:c=1,b=2,t=3,u=4 would appear as:
1287
1288 /dev/sr/c1b2t3u4
1289
1290
1291SCSI Generic Devices
1292
1293The generic (aka. raw) interface for all SCSI devices are placed under
1294/dev/sg. A similar naming scheme is used as for SCSI discs. A
1295SCSI generic device with the parameters:c=1,b=2,t=3,u=4 would appear
1296as:
1297
1298 /dev/sg/c1b2t3u4
1299
1300
1301IDE Hard Discs
1302
1303All IDE discs are placed under /dev/ide/hd, using a similar
1304convention to SCSI discs. The following mappings exist between the new
1305and the old names:
1306
1307 /dev/hda /dev/ide/hd/c0b0t0u0
1308 /dev/hdb /dev/ide/hd/c0b0t1u0
1309 /dev/hdc /dev/ide/hd/c0b1t0u0
1310 /dev/hdd /dev/ide/hd/c0b1t1u0
1311
1312
1313IDE Tapes
1314
1315A similar naming scheme is used as for IDE discs. The entries will
1316appear in the /dev/ide/mt directory.
1317
1318IDE CD-ROM
1319
1320A similar naming scheme is used as for IDE discs. The entries will
1321appear in the /dev/ide/cd directory.
1322
1323IDE Floppies
1324
1325A similar naming scheme is used as for IDE discs. The entries will
1326appear in the /dev/ide/fd directory.
1327
1328XT Hard Discs
1329
1330All XT discs are placed under /dev/xd. The first XT disc
1331would appear as /dev/xd/c0t0.
1332
1333
1334Old Compatibility Names
1335
1336The old compatibility names are the legacy device names, such as
1337/dev/hda, /dev/sda, /dev/rtc and so on.
1338Devfsd can be configured to create compatibility symlinks so that you
1339may continue to use the old names in your configuration files and so
1340that old applications will continue to function correctly.
1341
1342In order to configure devfsd to create these legacy names, the
1343following lines should be placed in your /etc/devfsd.conf:
1344
1345REGISTER .* MKOLDCOMPAT
1346UNREGISTER .* RMOLDCOMPAT
1347
1348This will cause devfsd to create (and destroy) symbolic links which
1349point to the kernel-supplied names.
1350
1351
1352-----------------------------------------------------------------------------
1353
1354
1355Device drivers currently ported
1356
1357- All miscellaneous character devices support devfs (this is done
1358 transparently through misc_register())
1359
1360- SCSI discs and generic hard discs
1361
1362- Character memory devices (null, zero, full and so on)
1363 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
1364
1365- Loop devices (/dev/loop?)
1366
1367- TTY devices (console, serial ports, terminals and pseudo-terminals)
1368 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
1369
1370- SCSI tapes (/dev/scsi and /dev/tapes)
1371
1372- SCSI CD-ROMs (/dev/scsi and /dev/cdroms)
1373
1374- SCSI generic devices (/dev/scsi)
1375
1376- RAMDISCS (/dev/ram?)
1377
1378- Meta Devices (/dev/md*)
1379
1380- Floppy discs (/dev/floppy)
1381
1382- Parallel port printers (/dev/printers)
1383
1384- Sound devices (/dev/sound)
1385 Thanks to Eric Dumas <dumas@linux.eu.org> and
1386 C. Scott Ananian <cananian@alumni.princeton.edu>
1387
1388- Joysticks (/dev/joysticks)
1389
1390- Sparc keyboard (/dev/kbd)
1391
1392- DSP56001 digital signal processor (/dev/dsp56k)
1393
1394- Apple Desktop Bus (/dev/adb)
1395
1396- Coda network file system (/dev/cfs*)
1397
1398- Virtual console capture devices (/dev/vcc)
1399 Thanks to Dennis Hou <smilax@mindmeld.yi.org>
1400
1401- Frame buffer devices (/dev/fb)
1402
1403- Video capture devices (/dev/v4l)
1404
1405
1406-----------------------------------------------------------------------------
1407
1408
1409Allocation of Device Numbers
1410
1411Devfs allows you to write a driver which doesn't need to allocate a
1412device number (major&minor numbers) for the internal operation of the
1413kernel. However, there are a number of userspace programmes that use
1414the device number as a unique handle for a device. An example is the
1415find programme, which uses device numbers to determine whether
1416an inode is on a different filesystem than another inode. The device
1417number used is the one for the block device which a filesystem is
1418using. To preserve compatibility with userspace programmes, block
1419devices using devfs need to have unique device numbers allocated to
1420them. Furthermore, POSIX specifies device numbers, so some kind of
1421device number needs to be presented to userspace.
1422
1423The simplest option (especially when porting drivers to devfs) is to
1424keep using the old major and minor numbers. Devfs will take whatever
1425values are given for major&minor and pass them onto userspace.
1426
1427This device number is a 16 bit number, so this leaves plenty of space
1428for large numbers of discs and partitions. This scheme can also be
1429used for character devices, in particular the tty devices, which are
1430currently limited to 256 pseudo-ttys (this limits the total number of
1431simultaneous xterms and remote logins). Note that the device number
1432is limited to the range 36864-61439 (majors 144-239), in order to
1433avoid any possible conflicts with existing official allocations.
1434
1435Please note that using dynamically allocated block device numbers may
1436break the NFS daemons (both user and kernel mode), which expect dev_t
1437for a given device to be constant over the lifetime of remote mounts.
1438
1439A final note on this scheme: since it doesn't increase the size of
1440device numbers, there are no compatibility issues with userspace.
1441
1442-----------------------------------------------------------------------------
1443
1444
1445Questions and Answers
1446
1447
1448Making things work
1449Alternatives to devfs
1450What I don't like about devfs
1451How to report bugs
1452Strange kernel messages
1453Compilation problems with devfsd
1454
1455
1456
1457Making things work
1458
1459Here are some common questions and answers.
1460
1461
1462
1463Devfsd doesn't start
1464
1465Make sure you have compiled and installed devfsd
1466Make sure devfsd is being started from your boot
1467scripts
1468Make sure you have configured your kernel to enable devfs (see
1469below)
1470Make sure devfs is mounted (see below)
1471
1472
1473Devfsd is not managing all my permissions
1474
1475Make sure you are capturing the appropriate events. For example,
1476device entries created by the kernel generate REGISTER events,
1477but those created by devfsd generate CREATE events.
1478
1479
1480Devfsd is not capturing all REGISTER events
1481
1482See the previous entry: you may need to capture CREATE events.
1483
1484
1485X will not start
1486
1487Make sure you followed the steps
1488outlined above.
1489
1490
1491Why don't my network devices appear in devfs?
1492
1493This is not a bug. Network devices have their own, completely separate
1494namespace. They are accessed via socket(2) and
1495setsockopt(2) calls, and thus require no device nodes. I have
1496raised the possibilty of moving network devices into the device
1497namespace, but have had no response.
1498
1499
1500How can I test if I have devfs compiled into my kernel?
1501
1502All filesystems built-in or currently loaded are listed in
1503/proc/filesystems. If you see a devfs entry, then
1504you know that devfs was compiled into your kernel. If you have
1505correctly configured and rebuilt your kernel, then devfs will be
1506built-in. If you think you've configured it in, but
1507/proc/filesystems doesn't show it, you've made a mistake.
1508Common mistakes include:
1509
1510Using a 2.2.x kernel without applying the devfs patch (if you
1511don't know how to patch your kernel, use 2.4.x instead, don't bother
1512asking me how to patch)
1513Forgetting to set CONFIG_EXPERIMENTAL=y
1514Forgetting to set CONFIG_DEVFS_FS=y
1515Forgetting to set CONFIG_DEVFS_MOUNT=y (if you want devfs
1516to be automatically mounted at boot)
1517Editing your .config manually, instead of using make
1518config or make xconfig
1519Forgetting to run make dep; make clean after changing the
1520configuration and before compiling
1521Forgetting to compile your kernel and modules
1522Forgetting to install your kernel
1523Forgetting to install your modules
1524
1525Please check twice that you've done all these steps before sending in
1526a bug report.
1527
1528
1529
1530How can I test if devfs is mounted on /dev?
1531
1532The device filesystem will always create an entry called
1533".devfsd", which is used to communicate with the daemon. Even
1534if the daemon is not running, this entry will exist. Testing for the
1535existence of this entry is the approved method of determining if devfs
1536is mounted or not. Note that the type of entry (i.e. regular file,
1537character device, named pipe, etc.) may change without notice. Only
1538the existence of the entry should be relied upon.
1539
1540
1541When I start devfsd, I see the error:
1542Error opening file: ".devfsd" No such file or directory?
1543
1544This means that devfs is not mounted. Make sure you have devfs mounted.
1545
1546
1547How do I mount devfs?
1548
1549First make sure you have devfs compiled into your kernel (see
1550above). Then you will either need to:
1551
1552set CONFIG_DEVFS_MOUNT=y in your kernel config
1553pass devfs=mount to your boot loader
1554mount devfs manually in your boot scripts with:
1555mount -t none devfs /dev
1556
1557
1558
1559Mount by volume LABEL=<label> doesn't work with
1560devfs
1561
1562Most probably you are not mounting devfs onto /dev. What
1563happens is that if your kernel config has CONFIG_DEVFS_FS=y
1564then the contents of /proc/partitions will have the devfs
1565names (such as scsi/host0/bus0/target0/lun0/part1). The
1566contents of /proc/partitions are used by mount(8) when
1567mounting by volume label. If devfs is not mounted on /dev,
1568then mount(8) will fail to find devices. The solution is to
1569make sure that devfs is mounted on /dev. See above for how to
1570do that.
1571
1572
1573I have extra or incorrect entries in /dev
1574
1575You may have stale entries in your dev-state area. Check for a
1576RESTORE configuration line in your devfsd configuration
1577(typically /etc/devfsd.conf). If you have this line, check
1578the contents of the specified directory for stale entries. Remove
1579any entries which are incorrect, then reboot.
1580
1581
1582I get "Unable to open initial console" messages at boot
1583
1584This usually happens when you don't have devfs automounted onto
1585/dev at boot time, and there is no valid
1586/dev/console entry on your root file-system. Create a valid
1587/dev/console device node.
1588
1589
1590
1591
1592
1593Alternatives to devfs
1594
1595I've attempted to collate all the anti-devfs proposals and explain
1596their limitations. Under construction.
1597
1598
1599Why not just pass device create/remove events to a daemon?
1600
1601Here the suggestion is to develop an API in the kernel so that devices
1602can register create and remove events, and a daemon listens for those
1603events. The daemon would then populate/depopulate /dev (which
1604resides on disc).
1605
1606This has several limitations:
1607
1608
1609it only works for modules loaded and unloaded (or devices inserted
1610and removed) after the kernel has finished booting. Without a database
1611of events, there is no way the daemon could fully populate
1612/dev
1613
1614
1615if you add a database to this scheme, the question is then how to
1616present that database to user-space. If you make it a list of strings
1617with embedded event codes which are passed through a pipe to the
1618daemon, then this is only of use to the daemon. I would argue that the
1619natural way to present this data is via a filesystem (since many of
1620the events will be of a hierarchical nature), such as devfs.
1621Presenting the data as a filesystem makes it easy for the user to see
1622what is available and also makes it easy to write scripts to scan the
1623"database"
1624
1625
1626the tight binding between device nodes and drivers is no longer
1627possible (requiring the otherwise perfectly avoidable
1628table lookups)
1629
1630
1631you cannot catch inode lookup events on /dev which means
1632that module autoloading requires device nodes to be created. This is a
1633problem, particularly for drivers where only a few inodes are created
1634from a potentially large set
1635
1636
1637this technique can't be used when the root FS is mounted
1638read-only
1639
1640
1641
1642
1643Just implement a better scsidev
1644
1645This suggestion involves taking the scsidev programme and
1646extending it to scan for all devices, not just SCSI devices. The
1647scsidev programme works by scanning /proc/scsi
1648
1649Problems:
1650
1651
1652the kernel does not currently provide a list of all devices
1653available. Not all drivers register entries in /proc or
1654generate kernel messages
1655
1656
1657there is no uniform mechanism to register devices other than the
1658devfs API
1659
1660
1661implementing such an API is then the same as the
1662proposal above
1663
1664
1665
1666
1667Put /dev on a ramdisc
1668
1669This suggestion involves creating a ramdisc and populating it with
1670device nodes and then mounting it over /dev.
1671
1672Problems:
1673
1674
1675
1676this doesn't help when mounting the root filesystem, since you
1677still need a device node to do that
1678
1679
1680if you want to use this technique for the root device node as
1681well, you need to use initrd. This complicates the booting sequence
1682and makes it significantly harder to administer and configure. The
1683initrd is essentially opaque, robbing the system administrator of easy
1684configuration
1685
1686
1687insufficient information is available to correctly populate the
1688ramdisc. So we come back to the
1689proposal above to "solve" this
1690
1691
1692a ramdisc-based solution would take more kernel memory, since the
1693backing store would be (at best) normal VFS inodes and dentries, which
1694take 284 bytes and 112 bytes, respectively, for each entry. Compare
1695that to 72 bytes for devfs
1696
1697
1698
1699
1700Do nothing: there's no problem
1701
1702Sometimes people can be heard to claim that the existing scheme is
1703fine. This is what they're ignoring:
1704
1705
1706device number size (8 bits each for major and minor) is a real
1707limitation, and must be fixed somehow. Systems with large numbers of
1708SCSI devices, for example, will continue to consume the remaining
1709unallocated major numbers. USB will also need to push beyond the 8 bit
1710minor limitation
1711
1712
1713simply increasing the device number size is insufficient. Apart
1714from causing a lot of pain, it doesn't solve the management issues
1715of a /dev with thousands or more device nodes
1716
1717
1718ignoring the problem of a huge /dev will not make it go
1719away, and dismisses the legitimacy of a large number of people who
1720want a dynamic /dev
1721
1722
1723the standard response then becomes: "write a device management
1724daemon", which brings us back to the
1725proposal above
1726
1727
1728
1729
1730What I don't like about devfs
1731
1732Here are some common complaints about devfs, and some suggestions and
1733solutions that may make it more palatable for you. I can't please
1734everybody, but I do try :-)
1735
1736I hate the naming scheme
1737
1738First, remember that no naming scheme will please everybody. You hate
1739the scheme, others love it. Who's to say who's right and who's wrong?
1740Ultimately, the person who writes the code gets to choose, and what
1741exists now is a combination of the choices made by the
1742devfs author and the
1743kernel maintainer (Linus).
1744
1745However, not all is lost. If you want to create your own naming
1746scheme, it is a simple matter to write a standalone script, hack
1747devfsd, or write a script called by devfsd. You can create whatever
1748naming scheme you like.
1749
1750Further, if you want to remove all traces of the devfs naming scheme
1751from /dev, you can mount devfs elsewhere (say
1752/devfs) and populate /dev with links into
1753/devfs. This population can be automated using devfsd if you
1754wish.
1755
1756You can even use the VFS binding facility to make the links, rather
1757than using symbolic links. This way, you don't even have to see the
1758"destination" of these symbolic links.
1759
1760Devfs puts policy into the kernel
1761
1762There's already policy in the kernel. Device numbers are in fact
1763policy (why should the kernel dictate what device numbers I use?).
1764Face it, some policy has to be in the kernel. The real difference
1765between device names as policy and device numbers as policy is that
1766no one will use device numbers directly, because device
1767numbers are devoid of meaning to humans and are ugly. At least with
1768the devfs device names, (even though you can add your own naming
1769scheme) some people will use the devfs-supplied names directly. This
1770offends some people :-)
1771
1772Devfs is bloatware
1773
1774This is not even remotely true. As shown above,
1775both code and data size are quite modest.
1776
1777
1778How to report bugs
1779
1780If you have (or think you have) a bug with devfs, please follow the
1781steps below:
1782
1783
1784
1785make sure you have enabled debugging output when configuring your
1786kernel. You will need to set (at least) the following config options:
1787
1788CONFIG_DEVFS_DEBUG=y
1789CONFIG_DEBUG_KERNEL=y
1790CONFIG_DEBUG_SLAB=y
1791
1792
1793
1794please make sure you have the latest devfs patches applied. The
1795latest kernel version might not have the latest devfs patches applied
1796yet (Linus is very busy)
1797
1798
1799save a copy of your complete kernel logs (preferably by
1800using the dmesg programme) for later inclusion in your bug
1801report. You may need to use the -s switch to increase the
1802internal buffer size so you can capture all the boot messages.
1803Don't edit or trim the dmesg output
1804
1805
1806
1807
1808try booting with devfs=dall passed to the kernel boot
1809command line (read the documentation on your bootloader on how to do
1810this), and save the result to a file. This may be quite verbose, and
1811it may overflow the messages buffer, but try to get as much of it as
1812you can
1813
1814
1815send a copy of your devfsd configuration file(s)
1816
1817send the bug report to me first.
1818Don't expect that I will see it if you post it to the linux-kernel
1819mailing list. Include all the information listed above, plus
1820anything else that you think might be relevant. Put the string
1821devfs somewhere in the subject line, so my mail filters mark
1822it as urgent
1823
1824
1825
1826
1827Here is a general guide on how to ask questions in a way that greatly
1828improves your chances of getting a reply:
1829
1830http://www.tuxedo.org/~esr/faqs/smart-questions.html. If you have
1831a bug to report, you should also read
1832
1833http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
1834
1835
1836Strange kernel messages
1837
1838You may see devfs-related messages in your kernel logs. Below are some
1839messages and what they mean (and what you should do about them, if
1840anything).
1841
1842
1843
1844devfs_register(fred): could not append to parent, err: -17
1845
1846You need to check what the error code means, but usually 17 means
1847EEXIST. This means that a driver attempted to create an entry
1848fred in a directory, but there already was an entry with that
1849name. This is often caused by flawed boot scripts which untar a bunch
1850of inodes into /dev, as a way to restore permissions. This
1851message is harmless, as the device nodes will still
1852provide access to the driver (unless you use the devfs=only
1853boot option, which is only for dedicated souls:-). If you want to get
1854rid of these annoying messages, upgrade to devfsd-v1.3.20 and use the
1855recommended RESTORE directive to restore permissions.
1856
1857
1858devfs_mk_dir(bill): using old entry in dir: c1808724 ""
1859
1860This is similar to the message above, except that a driver attempted
1861to create a directory named bill, and the parent directory
1862has an entry with the same name. In this case, to ensure that drivers
1863continue to work properly, the old entry is re-used and given to the
1864driver. In 2.5 kernels, the driver is given a NULL entry, and thus,
1865under rare circumstances, may not create the require device nodes.
1866The solution is the same as above.
1867
1868
1869
1870
1871
1872Compilation problems with devfsd
1873
1874Usually, you can compile devfsd just by typing in
1875make in the source directory, followed by a make
1876install (as root). Sometimes, you may have problems, particularly
1877on broken configurations.
1878
1879
1880
1881error messages relating to DEVFSD_NOTIFY_DELETE
1882
1883This happened because you have an ancient set of kernel headers
1884installed in /usr/include/linux or /usr/src/linux.
1885Install kernel 2.4.10 or later. You may need to pass the
1886KERNEL_DIR variable to make (if you did not install
1887the new kernel sources as /usr/src/linux), or you may copy
1888the devfs_fs.h file in the kernel source tree into
1889/usr/include/linux.
1890
1891
1892
1893
1894-----------------------------------------------------------------------------
1895
1896
1897Other resources
1898
1899
1900
1901Douglas Gilbert has written a useful document at
1902
1903http://www.torque.net/sg/devfs_scsi.html which
1904explores the SCSI subsystem and how it interacts with devfs
1905
1906
1907Douglas Gilbert has written another useful document at
1908
1909http://www.torque.net/scsi/SCSI-2.4-HOWTO/ which
1910discusses the Linux SCSI subsystem in 2.4.
1911
1912
1913Johannes Erdfelt has started a discussion paper on Linux and
1914hot-swap devices, describing what the requirements are for a scalable
1915solution and how and why he's used devfs+devfsd. Note that this is an
1916early draft only, available in plain text form at:
1917
1918http://johannes.erdfelt.com/hotswap.txt.
1919Johannes has promised a HTML version will follow.
1920
1921
1922I presented an invited
1923paper
1924at the
1925
19262nd Annual Storage Management Workshop held in Miamia, Florida,
1927U.S.A. in October 2000.
1928
1929
1930
1931
1932-----------------------------------------------------------------------------
1933
1934
1935Translations of this document
1936
1937This document has been translated into other languages.
1938
1939
1940
1941
1942The document master (in English) by rgooch@atnf.csiro.au is
1943available at
1944
1945http://www.atnf.csiro.au/~rgooch/linux/docs/devfs.html
1946
1947
1948
1949A Korean translation by viatoris@nownuri.net is available at
1950
1951http://your.destiny.pe.kr/devfs/devfs.html
1952
1953
1954
1955
1956-----------------------------------------------------------------------------
1957Most flags courtesy of ITA's
1958Flags of All Countries
1959used with permission.
diff --git a/Documentation/filesystems/devfs/ToDo b/Documentation/filesystems/devfs/ToDo
deleted file mode 100644
index afd5a8f2c19b..000000000000
--- a/Documentation/filesystems/devfs/ToDo
+++ /dev/null
@@ -1,40 +0,0 @@
1 Device File System (devfs) ToDo List
2
3 Richard Gooch <rgooch@atnf.csiro.au>
4
5 3-JUL-2000
6
7This is a list of things to be done for better devfs support in the
8Linux kernel. If you'd like to contribute to the devfs, please have a
9look at this list for anything that is unallocated. Also, if there are
10items missing (surely), please contact me so I can add them to the
11list (preferably with your name attached to them:-).
12
13
14- >256 ptys
15 Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>
16
17- Amiga floppy driver (drivers/block/amiflop.c)
18
19- Atari floppy driver (drivers/block/ataflop.c)
20
21- SWIM3 (Super Woz Integrated Machine 3) floppy driver (drivers/block/swim3.c)
22
23- Amiga ZorroII ramdisc driver (drivers/block/z2ram.c)
24
25- Parallel port ATAPI CD-ROM (drivers/block/paride/pcd.c)
26
27- Parallel port ATAPI floppy (drivers/block/paride/pf.c)
28
29- AP1000 block driver (drivers/ap1000/ap.c, drivers/ap1000/ddv.c)
30
31- Archimedes floppy (drivers/acorn/block/fd1772.c)
32
33- MFM hard drive (drivers/acorn/block/mfmhd.c)
34
35- I2O block device (drivers/message/i2o/i2o_block.c)
36
37- ST-RAM device (arch/m68k/atari/stram.c)
38
39- Raw devices
40
diff --git a/Documentation/filesystems/devfs/boot-options b/Documentation/filesystems/devfs/boot-options
deleted file mode 100644
index df3d33b03e0a..000000000000
--- a/Documentation/filesystems/devfs/boot-options
+++ /dev/null
@@ -1,65 +0,0 @@
1/* -*- auto-fill -*- */
2
3 Device File System (devfs) Boot Options
4
5 Richard Gooch <rgooch@atnf.csiro.au>
6
7 18-AUG-2001
8
9
10When CONFIG_DEVFS_DEBUG is enabled, you can pass several boot options
11to the kernel to debug devfs. The boot options are prefixed by
12"devfs=", and are separated by commas. Spaces are not allowed. The
13syntax looks like this:
14
15devfs=<option1>,<option2>,<option3>
16
17and so on. For example, if you wanted to turn on debugging for module
18load requests and device registration, you would do:
19
20devfs=dmod,dreg
21
22You may prefix "no" to any option. This will invert the option.
23
24
25Debugging Options
26=================
27
28These requires CONFIG_DEVFS_DEBUG to be enabled.
29Note that all debugging options have 'd' as the first character. By
30default all options are off. All debugging output is sent to the
31kernel logs. The debugging options do not take effect until the devfs
32version message appears (just prior to the root filesystem being
33mounted).
34
35These are the options:
36
37dmod print module load requests to <request_module>
38
39dreg print device register requests to <devfs_register>
40
41dunreg print device unregister requests to <devfs_unregister>
42
43dchange print device change requests to <devfs_set_flags>
44
45dilookup print inode lookup requests
46
47diget print VFS inode allocations
48
49diunlink print inode unlinks
50
51dichange print inode changes
52
53dimknod print calls to mknod(2)
54
55dall some debugging turned on
56
57
58Other Options
59=============
60
61These control the default behaviour of devfs. The options are:
62
63mount mount devfs onto /dev at boot time
64
65only disable non-devfs device nodes for devfs-capable drivers
diff --git a/Documentation/initrd.txt b/Documentation/initrd.txt
index 7de1c80cd719..b1b6440237a6 100644
--- a/Documentation/initrd.txt
+++ b/Documentation/initrd.txt
@@ -67,8 +67,7 @@ initrd adds the following new options:
67 as the last process has closed it, all data is freed and /dev/initrd 67 as the last process has closed it, all data is freed and /dev/initrd
68 can't be opened anymore. 68 can't be opened anymore.
69 69
70 root=/dev/ram0 (without devfs) 70 root=/dev/ram0
71 root=/dev/rd/0 (with devfs)
72 71
73 initrd is mounted as root, and the normal boot procedure is followed, 72 initrd is mounted as root, and the normal boot procedure is followed,
74 with the RAM disk still mounted as root. 73 with the RAM disk still mounted as root.
@@ -90,8 +89,7 @@ you're building an install floppy), the root file system creation
90procedure should create the /initrd directory. 89procedure should create the /initrd directory.
91 90
92If initrd will not be mounted in some cases, its content is still 91If initrd will not be mounted in some cases, its content is still
93accessible if the following device has been created (note that this 92accessible if the following device has been created:
94does not work if using devfs):
95 93
96# mknod /dev/initrd b 1 250 94# mknod /dev/initrd b 1 250
97# chmod 400 /dev/initrd 95# chmod 400 /dev/initrd
@@ -119,8 +117,7 @@ We'll describe the loopback device method:
119 (if space is critical, you may want to use the Minix FS instead of Ext2) 117 (if space is critical, you may want to use the Minix FS instead of Ext2)
120 3) mount the file system, e.g. 118 3) mount the file system, e.g.
121 # mount -t ext2 -o loop initrd /mnt 119 # mount -t ext2 -o loop initrd /mnt
122 4) create the console device (not necessary if using devfs, but it can't 120 4) create the console device:
123 hurt to do it anyway):
124 # mkdir /mnt/dev 121 # mkdir /mnt/dev
125 # mknod /mnt/dev/console c 5 1 122 # mknod /mnt/dev/console c 5 1
126 5) copy all the files that are needed to properly use the initrd 123 5) copy all the files that are needed to properly use the initrd
@@ -152,12 +149,7 @@ have to be given:
152 149
153 root=/dev/ram0 init=/linuxrc rw 150 root=/dev/ram0 init=/linuxrc rw
154 151
155if not using devfs, or 152(rw is only necessary if writing to the initrd file system.)
156
157 root=/dev/rd/0 init=/linuxrc rw
158
159if using devfs. (rw is only necessary if writing to the initrd file
160system.)
161 153
162With LOADLIN, you simply execute 154With LOADLIN, you simply execute
163 155
@@ -217,9 +209,9 @@ following command:
217# exec chroot . what-follows <dev/console >dev/console 2>&1 209# exec chroot . what-follows <dev/console >dev/console 2>&1
218 210
219Where what-follows is a program under the new root, e.g. /sbin/init 211Where what-follows is a program under the new root, e.g. /sbin/init
220If the new root file system will be used with devfs and has no valid 212If the new root file system will be used with udev and has no valid
221/dev directory, devfs must be mounted before invoking chroot in order to 213/dev directory, udev must be initialized before invoking chroot in order
222provide /dev/console. 214to provide /dev/console.
223 215
224Note: implementation details of pivot_root may change with time. In order 216Note: implementation details of pivot_root may change with time. In order
225to ensure compatibility, the following points should be observed: 217to ensure compatibility, the following points should be observed:
@@ -236,7 +228,7 @@ Now, the initrd can be unmounted and the memory allocated by the RAM
236disk can be freed: 228disk can be freed:
237 229
238# umount /initrd 230# umount /initrd
239# blockdev --flushbufs /dev/ram0 # /dev/rd/0 if using devfs 231# blockdev --flushbufs /dev/ram0
240 232
241It is also possible to use initrd with an NFS-mounted root, see the 233It is also possible to use initrd with an NFS-mounted root, see the
242pivot_root(8) man page for details. 234pivot_root(8) man page for details.
diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl-number.txt
index 1543802ef53e..edc04d74ae23 100644
--- a/Documentation/ioctl-number.txt
+++ b/Documentation/ioctl-number.txt
@@ -119,7 +119,6 @@ Code Seq# Include File Comments
119'c' 00-7F linux/comstats.h conflict! 119'c' 00-7F linux/comstats.h conflict!
120'c' 00-7F linux/coda.h conflict! 120'c' 00-7F linux/coda.h conflict!
121'd' 00-FF linux/char/drm/drm/h conflict! 121'd' 00-FF linux/char/drm/drm/h conflict!
122'd' 00-1F linux/devfs_fs.h conflict!
123'd' 00-DF linux/video_decoder.h conflict! 122'd' 00-DF linux/video_decoder.h conflict!
124'd' F0-FF linux/digi1.h 123'd' F0-FF linux/digi1.h
125'e' all linux/digi1.h conflict! 124'e' all linux/digi1.h conflict!
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 2e352a605fcf..86e9282d1c20 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -35,7 +35,6 @@ parameter is applicable:
35 APM Advanced Power Management support is enabled. 35 APM Advanced Power Management support is enabled.
36 AX25 Appropriate AX.25 support is enabled. 36 AX25 Appropriate AX.25 support is enabled.
37 CD Appropriate CD support is enabled. 37 CD Appropriate CD support is enabled.
38 DEVFS devfs support is enabled.
39 DRM Direct Rendering Management support is enabled. 38 DRM Direct Rendering Management support is enabled.
40 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled 39 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled
41 EFI EFI Partitioning (GPT) is enabled 40 EFI EFI Partitioning (GPT) is enabled
@@ -440,9 +439,6 @@ running once the system is up.
440 Format: <area>[,<node>] 439 Format: <area>[,<node>]
441 See also Documentation/networking/decnet.txt. 440 See also Documentation/networking/decnet.txt.
442 441
443 devfs= [DEVFS]
444 See Documentation/filesystems/devfs/boot-options.
445
446 dhash_entries= [KNL] 442 dhash_entries= [KNL]
447 Set number of hash buckets for dentry cache. 443 Set number of hash buckets for dentry cache.
448 444
@@ -1669,6 +1665,10 @@ running once the system is up.
1669 usbhid.mousepoll= 1665 usbhid.mousepoll=
1670 [USBHID] The interval which mice are to be polled at. 1666 [USBHID] The interval which mice are to be polled at.
1671 1667
1668 vdso= [IA-32]
1669 vdso=1: enable VDSO (default)
1670 vdso=0: disable VDSO mapping
1671
1672 video= [FB] Frame buffer configuration 1672 video= [FB] Frame buffer configuration
1673 See Documentation/fb/modedb.txt. 1673 See Documentation/fb/modedb.txt.
1674 1674
@@ -1685,9 +1685,14 @@ running once the system is up.
1685 decrease the size and leave more room for directly 1685 decrease the size and leave more room for directly
1686 mapped kernel RAM. 1686 mapped kernel RAM.
1687 1687
1688 vmhalt= [KNL,S390] 1688 vmhalt= [KNL,S390] Perform z/VM CP command after system halt.
1689 Format: <command>
1690
1691 vmpanic= [KNL,S390] Perform z/VM CP command after kernel panic.
1692 Format: <command>
1689 1693
1690 vmpoff= [KNL,S390] 1694 vmpoff= [KNL,S390] Perform z/VM CP command after power off.
1695 Format: <command>
1691 1696
1692 waveartist= [HW,OSS] 1697 waveartist= [HW,OSS]
1693 Format: <io>,<irq>,<dma>,<dma2> 1698 Format: <io>,<irq>,<dma>,<dma2>
diff --git a/Documentation/keys-request-key.txt b/Documentation/keys-request-key.txt
index 22488d791168..c1f64fdf84cb 100644
--- a/Documentation/keys-request-key.txt
+++ b/Documentation/keys-request-key.txt
@@ -3,16 +3,23 @@
3 =================== 3 ===================
4 4
5The key request service is part of the key retention service (refer to 5The key request service is part of the key retention service (refer to
6Documentation/keys.txt). This document explains more fully how that the 6Documentation/keys.txt). This document explains more fully how the requesting
7requesting algorithm works. 7algorithm works.
8 8
9The process starts by either the kernel requesting a service by calling 9The process starts by either the kernel requesting a service by calling
10request_key(): 10request_key*():
11 11
12 struct key *request_key(const struct key_type *type, 12 struct key *request_key(const struct key_type *type,
13 const char *description, 13 const char *description,
14 const char *callout_string); 14 const char *callout_string);
15 15
16or:
17
18 struct key *request_key_with_auxdata(const struct key_type *type,
19 const char *description,
20 const char *callout_string,
21 void *aux);
22
16Or by userspace invoking the request_key system call: 23Or by userspace invoking the request_key system call:
17 24
18 key_serial_t request_key(const char *type, 25 key_serial_t request_key(const char *type,
@@ -20,16 +27,26 @@ Or by userspace invoking the request_key system call:
20 const char *callout_info, 27 const char *callout_info,
21 key_serial_t dest_keyring); 28 key_serial_t dest_keyring);
22 29
23The main difference between the two access points is that the in-kernel 30The main difference between the access points is that the in-kernel interface
24interface does not need to link the key to a keyring to prevent it from being 31does not need to link the key to a keyring to prevent it from being immediately
25immediately destroyed. The kernel interface returns a pointer directly to the 32destroyed. The kernel interface returns a pointer directly to the key, and
26key, and it's up to the caller to destroy the key. 33it's up to the caller to destroy the key.
34
35The request_key_with_auxdata() call is like the in-kernel request_key() call,
36except that it permits auxiliary data to be passed to the upcaller (the default
37is NULL). This is only useful for those key types that define their own upcall
38mechanism rather than using /sbin/request-key.
27 39
28The userspace interface links the key to a keyring associated with the process 40The userspace interface links the key to a keyring associated with the process
29to prevent the key from going away, and returns the serial number of the key to 41to prevent the key from going away, and returns the serial number of the key to
30the caller. 42the caller.
31 43
32 44
45The following example assumes that the key types involved don't define their
46own upcall mechanisms. If they do, then those should be substituted for the
47forking and execution of /sbin/request-key.
48
49
33=========== 50===========
34THE PROCESS 51THE PROCESS
35=========== 52===========
@@ -40,8 +57,8 @@ A request proceeds in the following manner:
40 interface]. 57 interface].
41 58
42 (2) request_key() searches the process's subscribed keyrings to see if there's 59 (2) request_key() searches the process's subscribed keyrings to see if there's
43 a suitable key there. If there is, it returns the key. If there isn't, and 60 a suitable key there. If there is, it returns the key. If there isn't,
44 callout_info is not set, an error is returned. Otherwise the process 61 and callout_info is not set, an error is returned. Otherwise the process
45 proceeds to the next step. 62 proceeds to the next step.
46 63
47 (3) request_key() sees that A doesn't have the desired key yet, so it creates 64 (3) request_key() sees that A doesn't have the desired key yet, so it creates
@@ -62,7 +79,7 @@ A request proceeds in the following manner:
62 instantiation. 79 instantiation.
63 80
64 (7) The program may want to access another key from A's context (say a 81 (7) The program may want to access another key from A's context (say a
65 Kerberos TGT key). It just requests the appropriate key, and the keyring 82 Kerberos TGT key). It just requests the appropriate key, and the keyring
66 search notes that the session keyring has auth key V in its bottom level. 83 search notes that the session keyring has auth key V in its bottom level.
67 84
68 This will permit it to then search the keyrings of process A with the 85 This will permit it to then search the keyrings of process A with the
@@ -79,10 +96,11 @@ A request proceeds in the following manner:
79(10) The program then exits 0 and request_key() deletes key V and returns key 96(10) The program then exits 0 and request_key() deletes key V and returns key
80 U to the caller. 97 U to the caller.
81 98
82This also extends further. If key W (step 7 above) didn't exist, key W would be 99This also extends further. If key W (step 7 above) didn't exist, key W would
83created uninstantiated, another auth key (X) would be created (as per step 3) 100be created uninstantiated, another auth key (X) would be created (as per step
84and another copy of /sbin/request-key spawned (as per step 4); but the context 1013) and another copy of /sbin/request-key spawned (as per step 4); but the
85specified by auth key X will still be process A, as it was in auth key V. 102context specified by auth key X will still be process A, as it was in auth key
103V.
86 104
87This is because process A's keyrings can't simply be attached to 105This is because process A's keyrings can't simply be attached to
88/sbin/request-key at the appropriate places because (a) execve will discard two 106/sbin/request-key at the appropriate places because (a) execve will discard two
@@ -118,17 +136,17 @@ A search of any particular keyring proceeds in the following fashion:
118 136
119 (2) It considers all the non-keyring keys within that keyring and, if any key 137 (2) It considers all the non-keyring keys within that keyring and, if any key
120 matches the criteria specified, calls key_permission(SEARCH) on it to see 138 matches the criteria specified, calls key_permission(SEARCH) on it to see
121 if the key is allowed to be found. If it is, that key is returned; if 139 if the key is allowed to be found. If it is, that key is returned; if
122 not, the search continues, and the error code is retained if of higher 140 not, the search continues, and the error code is retained if of higher
123 priority than the one currently set. 141 priority than the one currently set.
124 142
125 (3) It then considers all the keyring-type keys in the keyring it's currently 143 (3) It then considers all the keyring-type keys in the keyring it's currently
126 searching. It calls key_permission(SEARCH) on each keyring, and if this 144 searching. It calls key_permission(SEARCH) on each keyring, and if this
127 grants permission, it recurses, executing steps (2) and (3) on that 145 grants permission, it recurses, executing steps (2) and (3) on that
128 keyring. 146 keyring.
129 147
130The process stops immediately a valid key is found with permission granted to 148The process stops immediately a valid key is found with permission granted to
131use it. Any error from a previous match attempt is discarded and the key is 149use it. Any error from a previous match attempt is discarded and the key is
132returned. 150returned.
133 151
134When search_process_keyrings() is invoked, it performs the following searches 152When search_process_keyrings() is invoked, it performs the following searches
@@ -153,7 +171,7 @@ The moment one succeeds, all pending errors are discarded and the found key is
153returned. 171returned.
154 172
155Only if all these fail does the whole thing fail with the highest priority 173Only if all these fail does the whole thing fail with the highest priority
156error. Note that several errors may have come from LSM. 174error. Note that several errors may have come from LSM.
157 175
158The error priority is: 176The error priority is:
159 177
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index 61c0fad2fe2f..e373f0212843 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -780,6 +780,17 @@ payload contents" for more information.
780 See also Documentation/keys-request-key.txt. 780 See also Documentation/keys-request-key.txt.
781 781
782 782
783(*) To search for a key, passing auxiliary data to the upcaller, call:
784
785 struct key *request_key_with_auxdata(const struct key_type *type,
786 const char *description,
787 const char *callout_string,
788 void *aux);
789
790 This is identical to request_key(), except that the auxiliary data is
791 passed to the key_type->request_key() op if it exists.
792
793
783(*) When it is no longer required, the key should be released using: 794(*) When it is no longer required, the key should be released using:
784 795
785 void key_put(struct key *key); 796 void key_put(struct key *key);
@@ -1031,6 +1042,24 @@ The structure has a number of fields, some of which are mandatory:
1031 as might happen when the userspace buffer is accessed. 1042 as might happen when the userspace buffer is accessed.
1032 1043
1033 1044
1045 (*) int (*request_key)(struct key *key, struct key *authkey, const char *op,
1046 void *aux);
1047
1048 This method is optional. If provided, request_key() and
1049 request_key_with_auxdata() will invoke this function rather than
1050 upcalling to /sbin/request-key to operate upon a key of this type.
1051
1052 The aux parameter is as passed to request_key_with_auxdata() or is NULL
1053 otherwise. Also passed are the key to be operated upon, the
1054 authorisation key for this operation and the operation type (currently
1055 only "create").
1056
1057 This function should return only when the upcall is complete. Upon return
1058 the authorisation key will be revoked, and the target key will be
1059 negatively instantiated if it is still uninstantiated. The error will be
1060 returned to the caller of request_key*().
1061
1062
1034============================ 1063============================
1035REQUEST-KEY CALLBACK SERVICE 1064REQUEST-KEY CALLBACK SERVICE
1036============================ 1065============================
diff --git a/Documentation/pi-futex.txt b/Documentation/pi-futex.txt
new file mode 100644
index 000000000000..5d61dacd21f6
--- /dev/null
+++ b/Documentation/pi-futex.txt
@@ -0,0 +1,121 @@
1Lightweight PI-futexes
2----------------------
3
4We are calling them lightweight for 3 reasons:
5
6 - in the user-space fastpath a PI-enabled futex involves no kernel work
7 (or any other PI complexity) at all. No registration, no extra kernel
8 calls - just pure fast atomic ops in userspace.
9
10 - even in the slowpath, the system call and scheduling pattern is very
11 similar to normal futexes.
12
13 - the in-kernel PI implementation is streamlined around the mutex
14 abstraction, with strict rules that keep the implementation
15 relatively simple: only a single owner may own a lock (i.e. no
16 read-write lock support), only the owner may unlock a lock, no
17 recursive locking, etc.
18
19Priority Inheritance - why?
20---------------------------
21
22The short reply: user-space PI helps achieving/improving determinism for
23user-space applications. In the best-case, it can help achieve
24determinism and well-bound latencies. Even in the worst-case, PI will
25improve the statistical distribution of locking related application
26delays.
27
28The longer reply:
29-----------------
30
31Firstly, sharing locks between multiple tasks is a common programming
32technique that often cannot be replaced with lockless algorithms. As we
33can see it in the kernel [which is a quite complex program in itself],
34lockless structures are rather the exception than the norm - the current
35ratio of lockless vs. locky code for shared data structures is somewhere
36between 1:10 and 1:100. Lockless is hard, and the complexity of lockless
37algorithms often endangers to ability to do robust reviews of said code.
38I.e. critical RT apps often choose lock structures to protect critical
39data structures, instead of lockless algorithms. Furthermore, there are
40cases (like shared hardware, or other resource limits) where lockless
41access is mathematically impossible.
42
43Media players (such as Jack) are an example of reasonable application
44design with multiple tasks (with multiple priority levels) sharing
45short-held locks: for example, a highprio audio playback thread is
46combined with medium-prio construct-audio-data threads and low-prio
47display-colory-stuff threads. Add video and decoding to the mix and
48we've got even more priority levels.
49
50So once we accept that synchronization objects (locks) are an
51unavoidable fact of life, and once we accept that multi-task userspace
52apps have a very fair expectation of being able to use locks, we've got
53to think about how to offer the option of a deterministic locking
54implementation to user-space.
55
56Most of the technical counter-arguments against doing priority
57inheritance only apply to kernel-space locks. But user-space locks are
58different, there we cannot disable interrupts or make the task
59non-preemptible in a critical section, so the 'use spinlocks' argument
60does not apply (user-space spinlocks have the same priority inversion
61problems as other user-space locking constructs). Fact is, pretty much
62the only technique that currently enables good determinism for userspace
63locks (such as futex-based pthread mutexes) is priority inheritance:
64
65Currently (without PI), if a high-prio and a low-prio task shares a lock
66[this is a quite common scenario for most non-trivial RT applications],
67even if all critical sections are coded carefully to be deterministic
68(i.e. all critical sections are short in duration and only execute a
69limited number of instructions), the kernel cannot guarantee any
70deterministic execution of the high-prio task: any medium-priority task
71could preempt the low-prio task while it holds the shared lock and
72executes the critical section, and could delay it indefinitely.
73
74Implementation:
75---------------
76
77As mentioned before, the userspace fastpath of PI-enabled pthread
78mutexes involves no kernel work at all - they behave quite similarly to
79normal futex-based locks: a 0 value means unlocked, and a value==TID
80means locked. (This is the same method as used by list-based robust
81futexes.) Userspace uses atomic ops to lock/unlock these mutexes without
82entering the kernel.
83
84To handle the slowpath, we have added two new futex ops:
85
86 FUTEX_LOCK_PI
87 FUTEX_UNLOCK_PI
88
89If the lock-acquire fastpath fails, [i.e. an atomic transition from 0 to
90TID fails], then FUTEX_LOCK_PI is called. The kernel does all the
91remaining work: if there is no futex-queue attached to the futex address
92yet then the code looks up the task that owns the futex [it has put its
93own TID into the futex value], and attaches a 'PI state' structure to
94the futex-queue. The pi_state includes an rt-mutex, which is a PI-aware,
95kernel-based synchronization object. The 'other' task is made the owner
96of the rt-mutex, and the FUTEX_WAITERS bit is atomically set in the
97futex value. Then this task tries to lock the rt-mutex, on which it
98blocks. Once it returns, it has the mutex acquired, and it sets the
99futex value to its own TID and returns. Userspace has no other work to
100perform - it now owns the lock, and futex value contains
101FUTEX_WAITERS|TID.
102
103If the unlock side fastpath succeeds, [i.e. userspace manages to do a
104TID -> 0 atomic transition of the futex value], then no kernel work is
105triggered.
106
107If the unlock fastpath fails (because the FUTEX_WAITERS bit is set),
108then FUTEX_UNLOCK_PI is called, and the kernel unlocks the futex on the
109behalf of userspace - and it also unlocks the attached
110pi_state->rt_mutex and thus wakes up any potential waiters.
111
112Note that under this approach, contrary to previous PI-futex approaches,
113there is no prior 'registration' of a PI-futex. [which is not quite
114possible anyway, due to existing ABI properties of pthread mutexes.]
115
116Also, under this scheme, 'robustness' and 'PI' are two orthogonal
117properties of futexes, and all four combinations are possible: futex,
118robust-futex, PI-futex, robust+PI-futex.
119
120More details about priority inheritance can be found in
121Documentation/rtmutex.txt.
diff --git a/Documentation/robust-futexes.txt b/Documentation/robust-futexes.txt
index df82d75245a0..76e8064b8c3a 100644
--- a/Documentation/robust-futexes.txt
+++ b/Documentation/robust-futexes.txt
@@ -95,7 +95,7 @@ comparison. If the thread has registered a list, then normally the list
95is empty. If the thread/process crashed or terminated in some incorrect 95is empty. If the thread/process crashed or terminated in some incorrect
96way then the list might be non-empty: in this case the kernel carefully 96way then the list might be non-empty: in this case the kernel carefully
97walks the list [not trusting it], and marks all locks that are owned by 97walks the list [not trusting it], and marks all locks that are owned by
98this thread with the FUTEX_OWNER_DEAD bit, and wakes up one waiter (if 98this thread with the FUTEX_OWNER_DIED bit, and wakes up one waiter (if
99any). 99any).
100 100
101The list is guaranteed to be private and per-thread at do_exit() time, 101The list is guaranteed to be private and per-thread at do_exit() time,
diff --git a/Documentation/rt-mutex-design.txt b/Documentation/rt-mutex-design.txt
new file mode 100644
index 000000000000..c472ffacc2f6
--- /dev/null
+++ b/Documentation/rt-mutex-design.txt
@@ -0,0 +1,781 @@
1#
2# Copyright (c) 2006 Steven Rostedt
3# Licensed under the GNU Free Documentation License, Version 1.2
4#
5
6RT-mutex implementation design
7------------------------------
8
9This document tries to describe the design of the rtmutex.c implementation.
10It doesn't describe the reasons why rtmutex.c exists. For that please see
11Documentation/rt-mutex.txt. Although this document does explain problems
12that happen without this code, but that is in the concept to understand
13what the code actually is doing.
14
15The goal of this document is to help others understand the priority
16inheritance (PI) algorithm that is used, as well as reasons for the
17decisions that were made to implement PI in the manner that was done.
18
19
20Unbounded Priority Inversion
21----------------------------
22
23Priority inversion is when a lower priority process executes while a higher
24priority process wants to run. This happens for several reasons, and
25most of the time it can't be helped. Anytime a high priority process wants
26to use a resource that a lower priority process has (a mutex for example),
27the high priority process must wait until the lower priority process is done
28with the resource. This is a priority inversion. What we want to prevent
29is something called unbounded priority inversion. That is when the high
30priority process is prevented from running by a lower priority process for
31an undetermined amount of time.
32
33The classic example of unbounded priority inversion is were you have three
34processes, let's call them processes A, B, and C, where A is the highest
35priority process, C is the lowest, and B is in between. A tries to grab a lock
36that C owns and must wait and lets C run to release the lock. But in the
37meantime, B executes, and since B is of a higher priority than C, it preempts C,
38but by doing so, it is in fact preempting A which is a higher priority process.
39Now there's no way of knowing how long A will be sleeping waiting for C
40to release the lock, because for all we know, B is a CPU hog and will
41never give C a chance to release the lock. This is called unbounded priority
42inversion.
43
44Here's a little ASCII art to show the problem.
45
46 grab lock L1 (owned by C)
47 |
48A ---+
49 C preempted by B
50 |
51C +----+
52
53B +-------->
54 B now keeps A from running.
55
56
57Priority Inheritance (PI)
58-------------------------
59
60There are several ways to solve this issue, but other ways are out of scope
61for this document. Here we only discuss PI.
62
63PI is where a process inherits the priority of another process if the other
64process blocks on a lock owned by the current process. To make this easier
65to understand, let's use the previous example, with processes A, B, and C again.
66
67This time, when A blocks on the lock owned by C, C would inherit the priority
68of A. So now if B becomes runnable, it would not preempt C, since C now has
69the high priority of A. As soon as C releases the lock, it loses its
70inherited priority, and A then can continue with the resource that C had.
71
72Terminology
73-----------
74
75Here I explain some terminology that is used in this document to help describe
76the design that is used to implement PI.
77
78PI chain - The PI chain is an ordered series of locks and processes that cause
79 processes to inherit priorities from a previous process that is
80 blocked on one of its locks. This is described in more detail
81 later in this document.
82
83mutex - In this document, to differentiate from locks that implement
84 PI and spin locks that are used in the PI code, from now on
85 the PI locks will be called a mutex.
86
87lock - In this document from now on, I will use the term lock when
88 referring to spin locks that are used to protect parts of the PI
89 algorithm. These locks disable preemption for UP (when
90 CONFIG_PREEMPT is enabled) and on SMP prevents multiple CPUs from
91 entering critical sections simultaneously.
92
93spin lock - Same as lock above.
94
95waiter - A waiter is a struct that is stored on the stack of a blocked
96 process. Since the scope of the waiter is within the code for
97 a process being blocked on the mutex, it is fine to allocate
98 the waiter on the process's stack (local variable). This
99 structure holds a pointer to the task, as well as the mutex that
100 the task is blocked on. It also has the plist node structures to
101 place the task in the waiter_list of a mutex as well as the
102 pi_list of a mutex owner task (described below).
103
104 waiter is sometimes used in reference to the task that is waiting
105 on a mutex. This is the same as waiter->task.
106
107waiters - A list of processes that are blocked on a mutex.
108
109top waiter - The highest priority process waiting on a specific mutex.
110
111top pi waiter - The highest priority process waiting on one of the mutexes
112 that a specific process owns.
113
114Note: task and process are used interchangeably in this document, mostly to
115 differentiate between two processes that are being described together.
116
117
118PI chain
119--------
120
121The PI chain is a list of processes and mutexes that may cause priority
122inheritance to take place. Multiple chains may converge, but a chain
123would never diverge, since a process can't be blocked on more than one
124mutex at a time.
125
126Example:
127
128 Process: A, B, C, D, E
129 Mutexes: L1, L2, L3, L4
130
131 A owns: L1
132 B blocked on L1
133 B owns L2
134 C blocked on L2
135 C owns L3
136 D blocked on L3
137 D owns L4
138 E blocked on L4
139
140The chain would be:
141
142 E->L4->D->L3->C->L2->B->L1->A
143
144To show where two chains merge, we could add another process F and
145another mutex L5 where B owns L5 and F is blocked on mutex L5.
146
147The chain for F would be:
148
149 F->L5->B->L1->A
150
151Since a process may own more than one mutex, but never be blocked on more than
152one, the chains merge.
153
154Here we show both chains:
155
156 E->L4->D->L3->C->L2-+
157 |
158 +->B->L1->A
159 |
160 F->L5-+
161
162For PI to work, the processes at the right end of these chains (or we may
163also call it the Top of the chain) must be equal to or higher in priority
164than the processes to the left or below in the chain.
165
166Also since a mutex may have more than one process blocked on it, we can
167have multiple chains merge at mutexes. If we add another process G that is
168blocked on mutex L2:
169
170 G->L2->B->L1->A
171
172And once again, to show how this can grow I will show the merging chains
173again.
174
175 E->L4->D->L3->C-+
176 +->L2-+
177 | |
178 G-+ +->B->L1->A
179 |
180 F->L5-+
181
182
183Plist
184-----
185
186Before I go further and talk about how the PI chain is stored through lists
187on both mutexes and processes, I'll explain the plist. This is similar to
188the struct list_head functionality that is already in the kernel.
189The implementation of plist is out of scope for this document, but it is
190very important to understand what it does.
191
192There are a few differences between plist and list, the most important one
193being that plist is a priority sorted linked list. This means that the
194priorities of the plist are sorted, such that it takes O(1) to retrieve the
195highest priority item in the list. Obviously this is useful to store processes
196based on their priorities.
197
198Another difference, which is important for implementation, is that, unlike
199list, the head of the list is a different element than the nodes of a list.
200So the head of the list is declared as struct plist_head and nodes that will
201be added to the list are declared as struct plist_node.
202
203
204Mutex Waiter List
205-----------------
206
207Every mutex keeps track of all the waiters that are blocked on itself. The mutex
208has a plist to store these waiters by priority. This list is protected by
209a spin lock that is located in the struct of the mutex. This lock is called
210wait_lock. Since the modification of the waiter list is never done in
211interrupt context, the wait_lock can be taken without disabling interrupts.
212
213
214Task PI List
215------------
216
217To keep track of the PI chains, each process has its own PI list. This is
218a list of all top waiters of the mutexes that are owned by the process.
219Note that this list only holds the top waiters and not all waiters that are
220blocked on mutexes owned by the process.
221
222The top of the task's PI list is always the highest priority task that
223is waiting on a mutex that is owned by the task. So if the task has
224inherited a priority, it will always be the priority of the task that is
225at the top of this list.
226
227This list is stored in the task structure of a process as a plist called
228pi_list. This list is protected by a spin lock also in the task structure,
229called pi_lock. This lock may also be taken in interrupt context, so when
230locking the pi_lock, interrupts must be disabled.
231
232
233Depth of the PI Chain
234---------------------
235
236The maximum depth of the PI chain is not dynamic, and could actually be
237defined. But is very complex to figure it out, since it depends on all
238the nesting of mutexes. Let's look at the example where we have 3 mutexes,
239L1, L2, and L3, and four separate functions func1, func2, func3 and func4.
240The following shows a locking order of L1->L2->L3, but may not actually
241be directly nested that way.
242
243void func1(void)
244{
245 mutex_lock(L1);
246
247 /* do anything */
248
249 mutex_unlock(L1);
250}
251
252void func2(void)
253{
254 mutex_lock(L1);
255 mutex_lock(L2);
256
257 /* do something */
258
259 mutex_unlock(L2);
260 mutex_unlock(L1);
261}
262
263void func3(void)
264{
265 mutex_lock(L2);
266 mutex_lock(L3);
267
268 /* do something else */
269
270 mutex_unlock(L3);
271 mutex_unlock(L2);
272}
273
274void func4(void)
275{
276 mutex_lock(L3);
277
278 /* do something again */
279
280 mutex_unlock(L3);
281}
282
283Now we add 4 processes that run each of these functions separately.
284Processes A, B, C, and D which run functions func1, func2, func3 and func4
285respectively, and such that D runs first and A last. With D being preempted
286in func4 in the "do something again" area, we have a locking that follows:
287
288D owns L3
289 C blocked on L3
290 C owns L2
291 B blocked on L2
292 B owns L1
293 A blocked on L1
294
295And thus we have the chain A->L1->B->L2->C->L3->D.
296
297This gives us a PI depth of 4 (four processes), but looking at any of the
298functions individually, it seems as though they only have at most a locking
299depth of two. So, although the locking depth is defined at compile time,
300it still is very difficult to find the possibilities of that depth.
301
302Now since mutexes can be defined by user-land applications, we don't want a DOS
303type of application that nests large amounts of mutexes to create a large
304PI chain, and have the code holding spin locks while looking at a large
305amount of data. So to prevent this, the implementation not only implements
306a maximum lock depth, but also only holds at most two different locks at a
307time, as it walks the PI chain. More about this below.
308
309
310Mutex owner and flags
311---------------------
312
313The mutex structure contains a pointer to the owner of the mutex. If the
314mutex is not owned, this owner is set to NULL. Since all architectures
315have the task structure on at least a four byte alignment (and if this is
316not true, the rtmutex.c code will be broken!), this allows for the two
317least significant bits to be used as flags. This part is also described
318in Documentation/rt-mutex.txt, but will also be briefly described here.
319
320Bit 0 is used as the "Pending Owner" flag. This is described later.
321Bit 1 is used as the "Has Waiters" flags. This is also described later
322 in more detail, but is set whenever there are waiters on a mutex.
323
324
325cmpxchg Tricks
326--------------
327
328Some architectures implement an atomic cmpxchg (Compare and Exchange). This
329is used (when applicable) to keep the fast path of grabbing and releasing
330mutexes short.
331
332cmpxchg is basically the following function performed atomically:
333
334unsigned long _cmpxchg(unsigned long *A, unsigned long *B, unsigned long *C)
335{
336 unsigned long T = *A;
337 if (*A == *B) {
338 *A = *C;
339 }
340 return T;
341}
342#define cmpxchg(a,b,c) _cmpxchg(&a,&b,&c)
343
344This is really nice to have, since it allows you to only update a variable
345if the variable is what you expect it to be. You know if it succeeded if
346the return value (the old value of A) is equal to B.
347
348The macro rt_mutex_cmpxchg is used to try to lock and unlock mutexes. If
349the architecture does not support CMPXCHG, then this macro is simply set
350to fail every time. But if CMPXCHG is supported, then this will
351help out extremely to keep the fast path short.
352
353The use of rt_mutex_cmpxchg with the flags in the owner field help optimize
354the system for architectures that support it. This will also be explained
355later in this document.
356
357
358Priority adjustments
359--------------------
360
361The implementation of the PI code in rtmutex.c has several places that a
362process must adjust its priority. With the help of the pi_list of a
363process this is rather easy to know what needs to be adjusted.
364
365The functions implementing the task adjustments are rt_mutex_adjust_prio,
366__rt_mutex_adjust_prio (same as the former, but expects the task pi_lock
367to already be taken), rt_mutex_get_prio, and rt_mutex_setprio.
368
369rt_mutex_getprio and rt_mutex_setprio are only used in __rt_mutex_adjust_prio.
370
371rt_mutex_getprio returns the priority that the task should have. Either the
372task's own normal priority, or if a process of a higher priority is waiting on
373a mutex owned by the task, then that higher priority should be returned.
374Since the pi_list of a task holds an order by priority list of all the top
375waiters of all the mutexes that the task owns, rt_mutex_getprio simply needs
376to compare the top pi waiter to its own normal priority, and return the higher
377priority back.
378
379(Note: if looking at the code, you will notice that the lower number of
380 prio is returned. This is because the prio field in the task structure
381 is an inverse order of the actual priority. So a "prio" of 5 is
382 of higher priority than a "prio" of 10.)
383
384__rt_mutex_adjust_prio examines the result of rt_mutex_getprio, and if the
385result does not equal the task's current priority, then rt_mutex_setprio
386is called to adjust the priority of the task to the new priority.
387Note that rt_mutex_setprio is defined in kernel/sched.c to implement the
388actual change in priority.
389
390It is interesting to note that __rt_mutex_adjust_prio can either increase
391or decrease the priority of the task. In the case that a higher priority
392process has just blocked on a mutex owned by the task, __rt_mutex_adjust_prio
393would increase/boost the task's priority. But if a higher priority task
394were for some reason to leave the mutex (timeout or signal), this same function
395would decrease/unboost the priority of the task. That is because the pi_list
396always contains the highest priority task that is waiting on a mutex owned
397by the task, so we only need to compare the priority of that top pi waiter
398to the normal priority of the given task.
399
400
401High level overview of the PI chain walk
402----------------------------------------
403
404The PI chain walk is implemented by the function rt_mutex_adjust_prio_chain.
405
406The implementation has gone through several iterations, and has ended up
407with what we believe is the best. It walks the PI chain by only grabbing
408at most two locks at a time, and is very efficient.
409
410The rt_mutex_adjust_prio_chain can be used either to boost or lower process
411priorities.
412
413rt_mutex_adjust_prio_chain is called with a task to be checked for PI
414(de)boosting (the owner of a mutex that a process is blocking on), a flag to
415check for deadlocking, the mutex that the task owns, and a pointer to a waiter
416that is the process's waiter struct that is blocked on the mutex (although this
417parameter may be NULL for deboosting).
418
419For this explanation, I will not mention deadlock detection. This explanation
420will try to stay at a high level.
421
422When this function is called, there are no locks held. That also means
423that the state of the owner and lock can change when entered into this function.
424
425Before this function is called, the task has already had rt_mutex_adjust_prio
426performed on it. This means that the task is set to the priority that it
427should be at, but the plist nodes of the task's waiter have not been updated
428with the new priorities, and that this task may not be in the proper locations
429in the pi_lists and wait_lists that the task is blocked on. This function
430solves all that.
431
432A loop is entered, where task is the owner to be checked for PI changes that
433was passed by parameter (for the first iteration). The pi_lock of this task is
434taken to prevent any more changes to the pi_list of the task. This also
435prevents new tasks from completing the blocking on a mutex that is owned by this
436task.
437
438If the task is not blocked on a mutex then the loop is exited. We are at
439the top of the PI chain.
440
441A check is now done to see if the original waiter (the process that is blocked
442on the current mutex) is the top pi waiter of the task. That is, is this
443waiter on the top of the task's pi_list. If it is not, it either means that
444there is another process higher in priority that is blocked on one of the
445mutexes that the task owns, or that the waiter has just woken up via a signal
446or timeout and has left the PI chain. In either case, the loop is exited, since
447we don't need to do any more changes to the priority of the current task, or any
448task that owns a mutex that this current task is waiting on. A priority chain
449walk is only needed when a new top pi waiter is made to a task.
450
451The next check sees if the task's waiter plist node has the priority equal to
452the priority the task is set at. If they are equal, then we are done with
453the loop. Remember that the function started with the priority of the
454task adjusted, but the plist nodes that hold the task in other processes
455pi_lists have not been adjusted.
456
457Next, we look at the mutex that the task is blocked on. The mutex's wait_lock
458is taken. This is done by a spin_trylock, because the locking order of the
459pi_lock and wait_lock goes in the opposite direction. If we fail to grab the
460lock, the pi_lock is released, and we restart the loop.
461
462Now that we have both the pi_lock of the task as well as the wait_lock of
463the mutex the task is blocked on, we update the task's waiter's plist node
464that is located on the mutex's wait_list.
465
466Now we release the pi_lock of the task.
467
468Next the owner of the mutex has its pi_lock taken, so we can update the
469task's entry in the owner's pi_list. If the task is the highest priority
470process on the mutex's wait_list, then we remove the previous top waiter
471from the owner's pi_list, and replace it with the task.
472
473Note: It is possible that the task was the current top waiter on the mutex,
474 in which case the task is not yet on the pi_list of the waiter. This
475 is OK, since plist_del does nothing if the plist node is not on any
476 list.
477
478If the task was not the top waiter of the mutex, but it was before we
479did the priority updates, that means we are deboosting/lowering the
480task. In this case, the task is removed from the pi_list of the owner,
481and the new top waiter is added.
482
483Lastly, we unlock both the pi_lock of the task, as well as the mutex's
484wait_lock, and continue the loop again. On the next iteration of the
485loop, the previous owner of the mutex will be the task that will be
486processed.
487
488Note: One might think that the owner of this mutex might have changed
489 since we just grab the mutex's wait_lock. And one could be right.
490 The important thing to remember is that the owner could not have
491 become the task that is being processed in the PI chain, since
492 we have taken that task's pi_lock at the beginning of the loop.
493 So as long as there is an owner of this mutex that is not the same
494 process as the tasked being worked on, we are OK.
495
496 Looking closely at the code, one might be confused. The check for the
497 end of the PI chain is when the task isn't blocked on anything or the
498 task's waiter structure "task" element is NULL. This check is
499 protected only by the task's pi_lock. But the code to unlock the mutex
500 sets the task's waiter structure "task" element to NULL with only
501 the protection of the mutex's wait_lock, which was not taken yet.
502 Isn't this a race condition if the task becomes the new owner?
503
504 The answer is No! The trick is the spin_trylock of the mutex's
505 wait_lock. If we fail that lock, we release the pi_lock of the
506 task and continue the loop, doing the end of PI chain check again.
507
508 In the code to release the lock, the wait_lock of the mutex is held
509 the entire time, and it is not let go when we grab the pi_lock of the
510 new owner of the mutex. So if the switch of a new owner were to happen
511 after the check for end of the PI chain and the grabbing of the
512 wait_lock, the unlocking code would spin on the new owner's pi_lock
513 but never give up the wait_lock. So the PI chain loop is guaranteed to
514 fail the spin_trylock on the wait_lock, release the pi_lock, and
515 try again.
516
517 If you don't quite understand the above, that's OK. You don't have to,
518 unless you really want to make a proof out of it ;)
519
520
521Pending Owners and Lock stealing
522--------------------------------
523
524One of the flags in the owner field of the mutex structure is "Pending Owner".
525What this means is that an owner was chosen by the process releasing the
526mutex, but that owner has yet to wake up and actually take the mutex.
527
528Why is this important? Why can't we just give the mutex to another process
529and be done with it?
530
531The PI code is to help with real-time processes, and to let the highest
532priority process run as long as possible with little latencies and delays.
533If a high priority process owns a mutex that a lower priority process is
534blocked on, when the mutex is released it would be given to the lower priority
535process. What if the higher priority process wants to take that mutex again.
536The high priority process would fail to take that mutex that it just gave up
537and it would need to boost the lower priority process to run with full
538latency of that critical section (since the low priority process just entered
539it).
540
541There's no reason a high priority process that gives up a mutex should be
542penalized if it tries to take that mutex again. If the new owner of the
543mutex has not woken up yet, there's no reason that the higher priority process
544could not take that mutex away.
545
546To solve this, we introduced Pending Ownership and Lock Stealing. When a
547new process is given a mutex that it was blocked on, it is only given
548pending ownership. This means that it's the new owner, unless a higher
549priority process comes in and tries to grab that mutex. If a higher priority
550process does come along and wants that mutex, we let the higher priority
551process "steal" the mutex from the pending owner (only if it is still pending)
552and continue with the mutex.
553
554
555Taking of a mutex (The walk through)
556------------------------------------
557
558OK, now let's take a look at the detailed walk through of what happens when
559taking a mutex.
560
561The first thing that is tried is the fast taking of the mutex. This is
562done when we have CMPXCHG enabled (otherwise the fast taking automatically
563fails). Only when the owner field of the mutex is NULL can the lock be
564taken with the CMPXCHG and nothing else needs to be done.
565
566If there is contention on the lock, whether it is owned or pending owner
567we go about the slow path (rt_mutex_slowlock).
568
569The slow path function is where the task's waiter structure is created on
570the stack. This is because the waiter structure is only needed for the
571scope of this function. The waiter structure holds the nodes to store
572the task on the wait_list of the mutex, and if need be, the pi_list of
573the owner.
574
575The wait_lock of the mutex is taken since the slow path of unlocking the
576mutex also takes this lock.
577
578We then call try_to_take_rt_mutex. This is where the architecture that
579does not implement CMPXCHG would always grab the lock (if there's no
580contention).
581
582try_to_take_rt_mutex is used every time the task tries to grab a mutex in the
583slow path. The first thing that is done here is an atomic setting of
584the "Has Waiters" flag of the mutex's owner field. Yes, this could really
585be false, because if the the mutex has no owner, there are no waiters and
586the current task also won't have any waiters. But we don't have the lock
587yet, so we assume we are going to be a waiter. The reason for this is to
588play nice for those architectures that do have CMPXCHG. By setting this flag
589now, the owner of the mutex can't release the mutex without going into the
590slow unlock path, and it would then need to grab the wait_lock, which this
591code currently holds. So setting the "Has Waiters" flag forces the owner
592to synchronize with this code.
593
594Now that we know that we can't have any races with the owner releasing the
595mutex, we check to see if we can take the ownership. This is done if the
596mutex doesn't have a owner, or if we can steal the mutex from a pending
597owner. Let's look at the situations we have here.
598
599 1) Has owner that is pending
600 ----------------------------
601
602 The mutex has a owner, but it hasn't woken up and the mutex flag
603 "Pending Owner" is set. The first check is to see if the owner isn't the
604 current task. This is because this function is also used for the pending
605 owner to grab the mutex. When a pending owner wakes up, it checks to see
606 if it can take the mutex, and this is done if the owner is already set to
607 itself. If so, we succeed and leave the function, clearing the "Pending
608 Owner" bit.
609
610 If the pending owner is not current, we check to see if the current priority is
611 higher than the pending owner. If not, we fail the function and return.
612
613 There's also something special about a pending owner. That is a pending owner
614 is never blocked on a mutex. So there is no PI chain to worry about. It also
615 means that if the mutex doesn't have any waiters, there's no accounting needed
616 to update the pending owner's pi_list, since we only worry about processes
617 blocked on the current mutex.
618
619 If there are waiters on this mutex, and we just stole the ownership, we need
620 to take the top waiter, remove it from the pi_list of the pending owner, and
621 add it to the current pi_list. Note that at this moment, the pending owner
622 is no longer on the list of waiters. This is fine, since the pending owner
623 would add itself back when it realizes that it had the ownership stolen
624 from itself. When the pending owner tries to grab the mutex, it will fail
625 in try_to_take_rt_mutex if the owner field points to another process.
626
627 2) No owner
628 -----------
629
630 If there is no owner (or we successfully stole the lock), we set the owner
631 of the mutex to current, and set the flag of "Has Waiters" if the current
632 mutex actually has waiters, or we clear the flag if it doesn't. See, it was
633 OK that we set that flag early, since now it is cleared.
634
635 3) Failed to grab ownership
636 ---------------------------
637
638 The most interesting case is when we fail to take ownership. This means that
639 there exists an owner, or there's a pending owner with equal or higher
640 priority than the current task.
641
642We'll continue on the failed case.
643
644If the mutex has a timeout, we set up a timer to go off to break us out
645of this mutex if we failed to get it after a specified amount of time.
646
647Now we enter a loop that will continue to try to take ownership of the mutex, or
648fail from a timeout or signal.
649
650Once again we try to take the mutex. This will usually fail the first time
651in the loop, since it had just failed to get the mutex. But the second time
652in the loop, this would likely succeed, since the task would likely be
653the pending owner.
654
655If the mutex is TASK_INTERRUPTIBLE a check for signals and timeout is done
656here.
657
658The waiter structure has a "task" field that points to the task that is blocked
659on the mutex. This field can be NULL the first time it goes through the loop
660or if the task is a pending owner and had it's mutex stolen. If the "task"
661field is NULL then we need to set up the accounting for it.
662
663Task blocks on mutex
664--------------------
665
666The accounting of a mutex and process is done with the waiter structure of
667the process. The "task" field is set to the process, and the "lock" field
668to the mutex. The plist nodes are initialized to the processes current
669priority.
670
671Since the wait_lock was taken at the entry of the slow lock, we can safely
672add the waiter to the wait_list. If the current process is the highest
673priority process currently waiting on this mutex, then we remove the
674previous top waiter process (if it exists) from the pi_list of the owner,
675and add the current process to that list. Since the pi_list of the owner
676has changed, we call rt_mutex_adjust_prio on the owner to see if the owner
677should adjust its priority accordingly.
678
679If the owner is also blocked on a lock, and had its pi_list changed
680(or deadlock checking is on), we unlock the wait_lock of the mutex and go ahead
681and run rt_mutex_adjust_prio_chain on the owner, as described earlier.
682
683Now all locks are released, and if the current process is still blocked on a
684mutex (waiter "task" field is not NULL), then we go to sleep (call schedule).
685
686Waking up in the loop
687---------------------
688
689The schedule can then wake up for a few reasons.
690 1) we were given pending ownership of the mutex.
691 2) we received a signal and was TASK_INTERRUPTIBLE
692 3) we had a timeout and was TASK_INTERRUPTIBLE
693
694In any of these cases, we continue the loop and once again try to grab the
695ownership of the mutex. If we succeed, we exit the loop, otherwise we continue
696and on signal and timeout, will exit the loop, or if we had the mutex stolen
697we just simply add ourselves back on the lists and go back to sleep.
698
699Note: For various reasons, because of timeout and signals, the steal mutex
700 algorithm needs to be careful. This is because the current process is
701 still on the wait_list. And because of dynamic changing of priorities,
702 especially on SCHED_OTHER tasks, the current process can be the
703 highest priority task on the wait_list.
704
705Failed to get mutex on Timeout or Signal
706----------------------------------------
707
708If a timeout or signal occurred, the waiter's "task" field would not be
709NULL and the task needs to be taken off the wait_list of the mutex and perhaps
710pi_list of the owner. If this process was a high priority process, then
711the rt_mutex_adjust_prio_chain needs to be executed again on the owner,
712but this time it will be lowering the priorities.
713
714
715Unlocking the Mutex
716-------------------
717
718The unlocking of a mutex also has a fast path for those architectures with
719CMPXCHG. Since the taking of a mutex on contention always sets the
720"Has Waiters" flag of the mutex's owner, we use this to know if we need to
721take the slow path when unlocking the mutex. If the mutex doesn't have any
722waiters, the owner field of the mutex would equal the current process and
723the mutex can be unlocked by just replacing the owner field with NULL.
724
725If the owner field has the "Has Waiters" bit set (or CMPXCHG is not available),
726the slow unlock path is taken.
727
728The first thing done in the slow unlock path is to take the wait_lock of the
729mutex. This synchronizes the locking and unlocking of the mutex.
730
731A check is made to see if the mutex has waiters or not. On architectures that
732do not have CMPXCHG, this is the location that the owner of the mutex will
733determine if a waiter needs to be awoken or not. On architectures that
734do have CMPXCHG, that check is done in the fast path, but it is still needed
735in the slow path too. If a waiter of a mutex woke up because of a signal
736or timeout between the time the owner failed the fast path CMPXCHG check and
737the grabbing of the wait_lock, the mutex may not have any waiters, thus the
738owner still needs to make this check. If there are no waiters than the mutex
739owner field is set to NULL, the wait_lock is released and nothing more is
740needed.
741
742If there are waiters, then we need to wake one up and give that waiter
743pending ownership.
744
745On the wake up code, the pi_lock of the current owner is taken. The top
746waiter of the lock is found and removed from the wait_list of the mutex
747as well as the pi_list of the current owner. The task field of the new
748pending owner's waiter structure is set to NULL, and the owner field of the
749mutex is set to the new owner with the "Pending Owner" bit set, as well
750as the "Has Waiters" bit if there still are other processes blocked on the
751mutex.
752
753The pi_lock of the previous owner is released, and the new pending owner's
754pi_lock is taken. Remember that this is the trick to prevent the race
755condition in rt_mutex_adjust_prio_chain from adding itself as a waiter
756on the mutex.
757
758We now clear the "pi_blocked_on" field of the new pending owner, and if
759the mutex still has waiters pending, we add the new top waiter to the pi_list
760of the pending owner.
761
762Finally we unlock the pi_lock of the pending owner and wake it up.
763
764
765Contact
766-------
767
768For updates on this document, please email Steven Rostedt <rostedt@goodmis.org>
769
770
771Credits
772-------
773
774Author: Steven Rostedt <rostedt@goodmis.org>
775
776Reviewers: Ingo Molnar, Thomas Gleixner, Thomas Duetsch, and Randy Dunlap
777
778Updates
779-------
780
781This document was originally written for 2.6.17-rc3-mm1
diff --git a/Documentation/rt-mutex.txt b/Documentation/rt-mutex.txt
new file mode 100644
index 000000000000..243393d882ee
--- /dev/null
+++ b/Documentation/rt-mutex.txt
@@ -0,0 +1,79 @@
1RT-mutex subsystem with PI support
2----------------------------------
3
4RT-mutexes with priority inheritance are used to support PI-futexes,
5which enable pthread_mutex_t priority inheritance attributes
6(PTHREAD_PRIO_INHERIT). [See Documentation/pi-futex.txt for more details
7about PI-futexes.]
8
9This technology was developed in the -rt tree and streamlined for
10pthread_mutex support.
11
12Basic principles:
13-----------------
14
15RT-mutexes extend the semantics of simple mutexes by the priority
16inheritance protocol.
17
18A low priority owner of a rt-mutex inherits the priority of a higher
19priority waiter until the rt-mutex is released. If the temporarily
20boosted owner blocks on a rt-mutex itself it propagates the priority
21boosting to the owner of the other rt_mutex it gets blocked on. The
22priority boosting is immediately removed once the rt_mutex has been
23unlocked.
24
25This approach allows us to shorten the block of high-prio tasks on
26mutexes which protect shared resources. Priority inheritance is not a
27magic bullet for poorly designed applications, but it allows
28well-designed applications to use userspace locks in critical parts of
29an high priority thread, without losing determinism.
30
31The enqueueing of the waiters into the rtmutex waiter list is done in
32priority order. For same priorities FIFO order is chosen. For each
33rtmutex, only the top priority waiter is enqueued into the owner's
34priority waiters list. This list too queues in priority order. Whenever
35the top priority waiter of a task changes (for example it timed out or
36got a signal), the priority of the owner task is readjusted. [The
37priority enqueueing is handled by "plists", see include/linux/plist.h
38for more details.]
39
40RT-mutexes are optimized for fastpath operations and have no internal
41locking overhead when locking an uncontended mutex or unlocking a mutex
42without waiters. The optimized fastpath operations require cmpxchg
43support. [If that is not available then the rt-mutex internal spinlock
44is used]
45
46The state of the rt-mutex is tracked via the owner field of the rt-mutex
47structure:
48
49rt_mutex->owner holds the task_struct pointer of the owner. Bit 0 and 1
50are used to keep track of the "owner is pending" and "rtmutex has
51waiters" state.
52
53 owner bit1 bit0
54 NULL 0 0 mutex is free (fast acquire possible)
55 NULL 0 1 invalid state
56 NULL 1 0 Transitional state*
57 NULL 1 1 invalid state
58 taskpointer 0 0 mutex is held (fast release possible)
59 taskpointer 0 1 task is pending owner
60 taskpointer 1 0 mutex is held and has waiters
61 taskpointer 1 1 task is pending owner and mutex has waiters
62
63Pending-ownership handling is a performance optimization:
64pending-ownership is assigned to the first (highest priority) waiter of
65the mutex, when the mutex is released. The thread is woken up and once
66it starts executing it can acquire the mutex. Until the mutex is taken
67by it (bit 0 is cleared) a competing higher priority thread can "steal"
68the mutex which puts the woken up thread back on the waiters list.
69
70The pending-ownership optimization is especially important for the
71uninterrupted workflow of high-prio tasks which repeatedly
72takes/releases locks that have lower-prio waiters. Without this
73optimization the higher-prio thread would ping-pong to the lower-prio
74task [because at unlock time we always assign a new owner].
75
76(*) The "mutex has waiters" bit gets set to take the lock. If the lock
77doesn't already have an owner, this bit is quickly cleared if there are
78no waiters. So this is a transitional state to synchronize with looking
79at the owner field of the mutex and the mutex owner releasing the lock.
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 87d76a5c73d0..f61af23dd85d 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -472,6 +472,22 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
472 472
473 The power-management is supported. 473 The power-management is supported.
474 474
475 Module snd-darla20
476 ------------------
477
478 Module for Echoaudio Darla20
479
480 This module supports multiple cards.
481 The driver requires the firmware loader support on kernel.
482
483 Module snd-darla24
484 ------------------
485
486 Module for Echoaudio Darla24
487
488 This module supports multiple cards.
489 The driver requires the firmware loader support on kernel.
490
475 Module snd-dt019x 491 Module snd-dt019x
476 ----------------- 492 -----------------
477 493
@@ -499,6 +515,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
499 515
500 The power-management is supported. 516 The power-management is supported.
501 517
518 Module snd-echo3g
519 -----------------
520
521 Module for Echoaudio 3G cards (Gina3G/Layla3G)
522
523 This module supports multiple cards.
524 The driver requires the firmware loader support on kernel.
525
502 Module snd-emu10k1 526 Module snd-emu10k1
503 ------------------ 527 ------------------
504 528
@@ -657,6 +681,22 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
657 681
658 The power-management is supported. 682 The power-management is supported.
659 683
684 Module snd-gina20
685 -----------------
686
687 Module for Echoaudio Gina20
688
689 This module supports multiple cards.
690 The driver requires the firmware loader support on kernel.
691
692 Module snd-gina24
693 -----------------
694
695 Module for Echoaudio Gina24
696
697 This module supports multiple cards.
698 The driver requires the firmware loader support on kernel.
699
660 Module snd-gusclassic 700 Module snd-gusclassic
661 --------------------- 701 ---------------------
662 702
@@ -760,12 +800,18 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
760 basic fixed pin assignment w/o SPDIF 800 basic fixed pin assignment w/o SPDIF
761 auto auto-config reading BIOS (default) 801 auto auto-config reading BIOS (default)
762 802
763 ALC882/883/885 803 ALC882/885
764 3stack-dig 3-jack with SPDIF I/O 804 3stack-dig 3-jack with SPDIF I/O
765 6stck-dig 6-jack digital with SPDIF I/O 805 6stck-dig 6-jack digital with SPDIF I/O
766 auto auto-config reading BIOS (default) 806 auto auto-config reading BIOS (default)
767 807
768 ALC861 808 ALC883/888
809 3stack-dig 3-jack with SPDIF I/O
810 6stack-dig 6-jack digital with SPDIF I/O
811 6stack-dig-demo 6-stack digital for Intel demo board
812 auto auto-config reading BIOS (default)
813
814 ALC861/660
769 3stack 3-jack 815 3stack 3-jack
770 3stack-dig 3-jack with SPDIF I/O 816 3stack-dig 3-jack with SPDIF I/O
771 6stack-dig 6-jack with SPDIF I/O 817 6stack-dig 6-jack with SPDIF I/O
@@ -937,6 +983,30 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
937 driver isn't configured properly or you want to try another 983 driver isn't configured properly or you want to try another
938 type for testing. 984 type for testing.
939 985
986 Module snd-indigo
987 -----------------
988
989 Module for Echoaudio Indigo
990
991 This module supports multiple cards.
992 The driver requires the firmware loader support on kernel.
993
994 Module snd-indigodj
995 -------------------
996
997 Module for Echoaudio Indigo DJ
998
999 This module supports multiple cards.
1000 The driver requires the firmware loader support on kernel.
1001
1002 Module snd-indigoio
1003 -------------------
1004
1005 Module for Echoaudio Indigo IO
1006
1007 This module supports multiple cards.
1008 The driver requires the firmware loader support on kernel.
1009
940 Module snd-intel8x0 1010 Module snd-intel8x0
941 ------------------- 1011 -------------------
942 1012
@@ -1036,6 +1106,22 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1036 1106
1037 This module supports multiple cards. 1107 This module supports multiple cards.
1038 1108
1109 Module snd-layla20
1110 ------------------
1111
1112 Module for Echoaudio Layla20
1113
1114 This module supports multiple cards.
1115 The driver requires the firmware loader support on kernel.
1116
1117 Module snd-layla24
1118 ------------------
1119
1120 Module for Echoaudio Layla24
1121
1122 This module supports multiple cards.
1123 The driver requires the firmware loader support on kernel.
1124
1039 Module snd-maestro3 1125 Module snd-maestro3
1040 ------------------- 1126 -------------------
1041 1127
@@ -1056,6 +1142,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1056 1142
1057 The power-management is supported. 1143 The power-management is supported.
1058 1144
1145 Module snd-mia
1146 ---------------
1147
1148 Module for Echoaudio Mia
1149
1150 This module supports multiple cards.
1151 The driver requires the firmware loader support on kernel.
1152
1059 Module snd-miro 1153 Module snd-miro
1060 --------------- 1154 ---------------
1061 1155
@@ -1088,6 +1182,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1088 When no hotplug fw loader is available, you need to load the 1182 When no hotplug fw loader is available, you need to load the
1089 firmware via mixartloader utility in alsa-tools package. 1183 firmware via mixartloader utility in alsa-tools package.
1090 1184
1185 Module snd-mona
1186 ---------------
1187
1188 Module for Echoaudio Mona
1189
1190 This module supports multiple cards.
1191 The driver requires the firmware loader support on kernel.
1192
1091 Module snd-mpu401 1193 Module snd-mpu401
1092 ----------------- 1194 -----------------
1093 1195
diff --git a/Documentation/video4linux/README.pvrusb2 b/Documentation/video4linux/README.pvrusb2
new file mode 100644
index 000000000000..c73a32c34528
--- /dev/null
+++ b/Documentation/video4linux/README.pvrusb2
@@ -0,0 +1,212 @@
1
2$Id$
3Mike Isely <isely@pobox.com>
4
5 pvrusb2 driver
6
7Background:
8
9 This driver is intended for the "Hauppauge WinTV PVR USB 2.0", which
10 is a USB 2.0 hosted TV Tuner. This driver is a work in progress.
11 Its history started with the reverse-engineering effort by Björn
12 Danielsson <pvrusb2@dax.nu> whose web page can be found here:
13
14 http://pvrusb2.dax.nu/
15
16 From there Aurelien Alleaume <slts@free.fr> began an effort to
17 create a video4linux compatible driver. I began with Aurelien's
18 last known snapshot and evolved the driver to the state it is in
19 here.
20
21 More information on this driver can be found at:
22
23 http://www.isely.net/pvrusb2.html
24
25
26 This driver has a strong separation of layers. They are very
27 roughly:
28
29 1a. Low level wire-protocol implementation with the device.
30
31 1b. I2C adaptor implementation and corresponding I2C client drivers
32 implemented elsewhere in V4L.
33
34 1c. High level hardware driver implementation which coordinates all
35 activities that ensure correct operation of the device.
36
37 2. A "context" layer which manages instancing of driver, setup,
38 tear-down, arbitration, and interaction with high level
39 interfaces appropriately as devices are hotplugged in the
40 system.
41
42 3. High level interfaces which glue the driver to various published
43 Linux APIs (V4L, sysfs, maybe DVB in the future).
44
45 The most important shearing layer is between the top 2 layers. A
46 lot of work went into the driver to ensure that any kind of
47 conceivable API can be laid on top of the core driver. (Yes, the
48 driver internally leverages V4L to do its work but that really has
49 nothing to do with the API published by the driver to the outside
50 world.) The architecture allows for different APIs to
51 simultaneously access the driver. I have a strong sense of fairness
52 about APIs and also feel that it is a good design principle to keep
53 implementation and interface isolated from each other. Thus while
54 right now the V4L high level interface is the most complete, the
55 sysfs high level interface will work equally well for similar
56 functions, and there's no reason I see right now why it shouldn't be
57 possible to produce a DVB high level interface that can sit right
58 alongside V4L.
59
60 NOTE: Complete documentation on the pvrusb2 driver is contained in
61 the html files within the doc directory; these are exactly the same
62 as what is on the web site at the time. Browse those files
63 (especially the FAQ) before asking questions.
64
65
66Building
67
68 To build these modules essentially amounts to just running "Make",
69 but you need the kernel source tree nearby and you will likely also
70 want to set a few controlling environment variables first in order
71 to link things up with that source tree. Please see the Makefile
72 here for comments that explain how to do that.
73
74
75Source file list / functional overview:
76
77 (Note: The term "module" used below generally refers to loosely
78 defined functional units within the pvrusb2 driver and bears no
79 relation to the Linux kernel's concept of a loadable module.)
80
81 pvrusb2-audio.[ch] - This is glue logic that resides between this
82 driver and the msp3400.ko I2C client driver (which is found
83 elsewhere in V4L).
84
85 pvrusb2-context.[ch] - This module implements the context for an
86 instance of the driver. Everything else eventually ties back to
87 or is otherwise instanced within the data structures implemented
88 here. Hotplugging is ultimately coordinated here. All high level
89 interfaces tie into the driver through this module. This module
90 helps arbitrate each interface's access to the actual driver core,
91 and is designed to allow concurrent access through multiple
92 instances of multiple interfaces (thus you can for example change
93 the tuner's frequency through sysfs while simultaneously streaming
94 video through V4L out to an instance of mplayer).
95
96 pvrusb2-debug.h - This header defines a printk() wrapper and a mask
97 of debugging bit definitions for the various kinds of debug
98 messages that can be enabled within the driver.
99
100 pvrusb2-debugifc.[ch] - This module implements a crude command line
101 oriented debug interface into the driver. Aside from being part
102 of the process for implementing manual firmware extraction (see
103 the pvrusb2 web site mentioned earlier), probably I'm the only one
104 who has ever used this. It is mainly a debugging aid.
105
106 pvrusb2-eeprom.[ch] - This is glue logic that resides between this
107 driver the tveeprom.ko module, which is itself implemented
108 elsewhere in V4L.
109
110 pvrusb2-encoder.[ch] - This module implements all protocol needed to
111 interact with the Conexant mpeg2 encoder chip within the pvrusb2
112 device. It is a crude echo of corresponding logic in ivtv,
113 however the design goals (strict isolation) and physical layer
114 (proxy through USB instead of PCI) are enough different that this
115 implementation had to be completely different.
116
117 pvrusb2-hdw-internal.h - This header defines the core data structure
118 in the driver used to track ALL internal state related to control
119 of the hardware. Nobody outside of the core hardware-handling
120 modules should have any business using this header. All external
121 access to the driver should be through one of the high level
122 interfaces (e.g. V4L, sysfs, etc), and in fact even those high
123 level interfaces are restricted to the API defined in
124 pvrusb2-hdw.h and NOT this header.
125
126 pvrusb2-hdw.h - This header defines the full internal API for
127 controlling the hardware. High level interfaces (e.g. V4L, sysfs)
128 will work through here.
129
130 pvrusb2-hdw.c - This module implements all the various bits of logic
131 that handle overall control of a specific pvrusb2 device.
132 (Policy, instantiation, and arbitration of pvrusb2 devices fall
133 within the jurisdiction of pvrusb-context not here).
134
135 pvrusb2-i2c-chips-*.c - These modules implement the glue logic to
136 tie together and configure various I2C modules as they attach to
137 the I2C bus. There are two versions of this file. The "v4l2"
138 version is intended to be used in-tree alongside V4L, where we
139 implement just the logic that makes sense for a pure V4L
140 environment. The "all" version is intended for use outside of
141 V4L, where we might encounter other possibly "challenging" modules
142 from ivtv or older kernel snapshots (or even the support modules
143 in the standalone snapshot).
144
145 pvrusb2-i2c-cmd-v4l1.[ch] - This module implements generic V4L1
146 compatible commands to the I2C modules. It is here where state
147 changes inside the pvrusb2 driver are translated into V4L1
148 commands that are in turn send to the various I2C modules.
149
150 pvrusb2-i2c-cmd-v4l2.[ch] - This module implements generic V4L2
151 compatible commands to the I2C modules. It is here where state
152 changes inside the pvrusb2 driver are translated into V4L2
153 commands that are in turn send to the various I2C modules.
154
155 pvrusb2-i2c-core.[ch] - This module provides an implementation of a
156 kernel-friendly I2C adaptor driver, through which other external
157 I2C client drivers (e.g. msp3400, tuner, lirc) may connect and
158 operate corresponding chips within the the pvrusb2 device. It is
159 through here that other V4L modules can reach into this driver to
160 operate specific pieces (and those modules are in turn driven by
161 glue logic which is coordinated by pvrusb2-hdw, doled out by
162 pvrusb2-context, and then ultimately made available to users
163 through one of the high level interfaces).
164
165 pvrusb2-io.[ch] - This module implements a very low level ring of
166 transfer buffers, required in order to stream data from the
167 device. This module is *very* low level. It only operates the
168 buffers and makes no attempt to define any policy or mechanism for
169 how such buffers might be used.
170
171 pvrusb2-ioread.[ch] - This module layers on top of pvrusb2-io.[ch]
172 to provide a streaming API usable by a read() system call style of
173 I/O. Right now this is the only layer on top of pvrusb2-io.[ch],
174 however the underlying architecture here was intended to allow for
175 other styles of I/O to be implemented with additonal modules, like
176 mmap()'ed buffers or something even more exotic.
177
178 pvrusb2-main.c - This is the top level of the driver. Module level
179 and USB core entry points are here. This is our "main".
180
181 pvrusb2-sysfs.[ch] - This is the high level interface which ties the
182 pvrusb2 driver into sysfs. Through this interface you can do
183 everything with the driver except actually stream data.
184
185 pvrusb2-tuner.[ch] - This is glue logic that resides between this
186 driver and the tuner.ko I2C client driver (which is found
187 elsewhere in V4L).
188
189 pvrusb2-util.h - This header defines some common macros used
190 throughout the driver. These macros are not really specific to
191 the driver, but they had to go somewhere.
192
193 pvrusb2-v4l2.[ch] - This is the high level interface which ties the
194 pvrusb2 driver into video4linux. It is through here that V4L
195 applications can open and operate the driver in the usual V4L
196 ways. Note that **ALL** V4L functionality is published only
197 through here and nowhere else.
198
199 pvrusb2-video-*.[ch] - This is glue logic that resides between this
200 driver and the saa711x.ko I2C client driver (which is found
201 elsewhere in V4L). Note that saa711x.ko used to be known as
202 saa7115.ko in ivtv. There are two versions of this; one is
203 selected depending on the particular saa711[5x].ko that is found.
204
205 pvrusb2.h - This header contains compile time tunable parameters
206 (and at the moment the driver has very little that needs to be
207 tuned).
208
209
210 -Mike Isely
211 isely@pobox.com
212
diff --git a/Documentation/watchdog/pcwd-watchdog.txt b/Documentation/watchdog/pcwd-watchdog.txt
index 12187a33e310..d9ee6336c1d4 100644
--- a/Documentation/watchdog/pcwd-watchdog.txt
+++ b/Documentation/watchdog/pcwd-watchdog.txt
@@ -22,78 +22,9 @@
22 to run the program with an "&" to run it in the background!) 22 to run the program with an "&" to run it in the background!)
23 23
24 If you want to write a program to be compatible with the PC Watchdog 24 If you want to write a program to be compatible with the PC Watchdog
25 driver, simply do the following: 25 driver, simply use of modify the watchdog test program:
26 26 Documentation/watchdog/src/watchdog-test.c
27-- Snippet of code -- 27
28/*
29 * Watchdog Driver Test Program
30 */
31
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <fcntl.h>
37#include <sys/ioctl.h>
38#include <linux/types.h>
39#include <linux/watchdog.h>
40
41int fd;
42
43/*
44 * This function simply sends an IOCTL to the driver, which in turn ticks
45 * the PC Watchdog card to reset its internal timer so it doesn't trigger
46 * a computer reset.
47 */
48void keep_alive(void)
49{
50 int dummy;
51
52 ioctl(fd, WDIOC_KEEPALIVE, &dummy);
53}
54
55/*
56 * The main program. Run the program with "-d" to disable the card,
57 * or "-e" to enable the card.
58 */
59int main(int argc, char *argv[])
60{
61 fd = open("/dev/watchdog", O_WRONLY);
62
63 if (fd == -1) {
64 fprintf(stderr, "Watchdog device not enabled.\n");
65 fflush(stderr);
66 exit(-1);
67 }
68
69 if (argc > 1) {
70 if (!strncasecmp(argv[1], "-d", 2)) {
71 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_DISABLECARD);
72 fprintf(stderr, "Watchdog card disabled.\n");
73 fflush(stderr);
74 exit(0);
75 } else if (!strncasecmp(argv[1], "-e", 2)) {
76 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_ENABLECARD);
77 fprintf(stderr, "Watchdog card enabled.\n");
78 fflush(stderr);
79 exit(0);
80 } else {
81 fprintf(stderr, "-d to disable, -e to enable.\n");
82 fprintf(stderr, "run by itself to tick the card.\n");
83 fflush(stderr);
84 exit(0);
85 }
86 } else {
87 fprintf(stderr, "Watchdog Ticking Away!\n");
88 fflush(stderr);
89 }
90
91 while(1) {
92 keep_alive();
93 sleep(1);
94 }
95}
96-- End snippet --
97 28
98 Other IOCTL functions include: 29 Other IOCTL functions include:
99 30
diff --git a/Documentation/watchdog/src/watchdog-simple.c b/Documentation/watchdog/src/watchdog-simple.c
new file mode 100644
index 000000000000..85cf17c48669
--- /dev/null
+++ b/Documentation/watchdog/src/watchdog-simple.c
@@ -0,0 +1,15 @@
1#include <stdlib.h>
2#include <fcntl.h>
3
4int main(int argc, const char *argv[]) {
5 int fd = open("/dev/watchdog", O_WRONLY);
6 if (fd == -1) {
7 perror("watchdog");
8 exit(1);
9 }
10 while (1) {
11 write(fd, "\0", 1);
12 fsync(fd);
13 sleep(10);
14 }
15}
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c
new file mode 100644
index 000000000000..65f6c19cb865
--- /dev/null
+++ b/Documentation/watchdog/src/watchdog-test.c
@@ -0,0 +1,68 @@
1/*
2 * Watchdog Driver Test Program
3 */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8#include <unistd.h>
9#include <fcntl.h>
10#include <sys/ioctl.h>
11#include <linux/types.h>
12#include <linux/watchdog.h>
13
14int fd;
15
16/*
17 * This function simply sends an IOCTL to the driver, which in turn ticks
18 * the PC Watchdog card to reset its internal timer so it doesn't trigger
19 * a computer reset.
20 */
21void keep_alive(void)
22{
23 int dummy;
24
25 ioctl(fd, WDIOC_KEEPALIVE, &dummy);
26}
27
28/*
29 * The main program. Run the program with "-d" to disable the card,
30 * or "-e" to enable the card.
31 */
32int main(int argc, char *argv[])
33{
34 fd = open("/dev/watchdog", O_WRONLY);
35
36 if (fd == -1) {
37 fprintf(stderr, "Watchdog device not enabled.\n");
38 fflush(stderr);
39 exit(-1);
40 }
41
42 if (argc > 1) {
43 if (!strncasecmp(argv[1], "-d", 2)) {
44 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_DISABLECARD);
45 fprintf(stderr, "Watchdog card disabled.\n");
46 fflush(stderr);
47 exit(0);
48 } else if (!strncasecmp(argv[1], "-e", 2)) {
49 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_ENABLECARD);
50 fprintf(stderr, "Watchdog card enabled.\n");
51 fflush(stderr);
52 exit(0);
53 } else {
54 fprintf(stderr, "-d to disable, -e to enable.\n");
55 fprintf(stderr, "run by itself to tick the card.\n");
56 fflush(stderr);
57 exit(0);
58 }
59 } else {
60 fprintf(stderr, "Watchdog Ticking Away!\n");
61 fflush(stderr);
62 }
63
64 while(1) {
65 keep_alive();
66 sleep(1);
67 }
68}
diff --git a/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt
index 21ed51173662..958ff3d48be3 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -34,22 +34,7 @@ activates as soon as /dev/watchdog is opened and will reboot unless
34the watchdog is pinged within a certain time, this time is called the 34the watchdog is pinged within a certain time, this time is called the
35timeout or margin. The simplest way to ping the watchdog is to write 35timeout or margin. The simplest way to ping the watchdog is to write
36some data to the device. So a very simple watchdog daemon would look 36some data to the device. So a very simple watchdog daemon would look
37like this: 37like this source file: see Documentation/watchdog/src/watchdog-simple.c
38
39#include <stdlib.h>
40#include <fcntl.h>
41
42int main(int argc, const char *argv[]) {
43 int fd=open("/dev/watchdog",O_WRONLY);
44 if (fd==-1) {
45 perror("watchdog");
46 exit(1);
47 }
48 while(1) {
49 write(fd, "\0", 1);
50 sleep(10);
51 }
52}
53 38
54A more advanced driver could for example check that a HTTP server is 39A more advanced driver could for example check that a HTTP server is
55still responding before doing the write call to ping the watchdog. 40still responding before doing the write call to ping the watchdog.
@@ -110,7 +95,40 @@ current timeout using the GETTIMEOUT ioctl.
110 ioctl(fd, WDIOC_GETTIMEOUT, &timeout); 95 ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
111 printf("The timeout was is %d seconds\n", timeout); 96 printf("The timeout was is %d seconds\n", timeout);
112 97
113Envinronmental monitoring: 98Pretimeouts:
99
100Some watchdog timers can be set to have a trigger go off before the
101actual time they will reset the system. This can be done with an NMI,
102interrupt, or other mechanism. This allows Linux to record useful
103information (like panic information and kernel coredumps) before it
104resets.
105
106 pretimeout = 10;
107 ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout);
108
109Note that the pretimeout is the number of seconds before the time
110when the timeout will go off. It is not the number of seconds until
111the pretimeout. So, for instance, if you set the timeout to 60 seconds
112and the pretimeout to 10 seconds, the pretimout will go of in 50
113seconds. Setting a pretimeout to zero disables it.
114
115There is also a get function for getting the pretimeout:
116
117 ioctl(fd, WDIOC_GETPRETIMEOUT, &timeout);
118 printf("The pretimeout was is %d seconds\n", timeout);
119
120Not all watchdog drivers will support a pretimeout.
121
122Get the number of seconds before reboot:
123
124Some watchdog drivers have the ability to report the remaining time
125before the system will reboot. The WDIOC_GETTIMELEFT is the ioctl
126that returns the number of seconds before reboot.
127
128 ioctl(fd, WDIOC_GETTIMELEFT, &timeleft);
129 printf("The timeout was is %d seconds\n", timeleft);
130
131Environmental monitoring:
114 132
115All watchdog drivers are required return more information about the system, 133All watchdog drivers are required return more information about the system,
116some do temperature, fan and power level monitoring, some can tell you 134some do temperature, fan and power level monitoring, some can tell you
@@ -169,6 +187,10 @@ The watchdog saw a keepalive ping since it was last queried.
169 187
170 WDIOF_SETTIMEOUT Can set/get the timeout 188 WDIOF_SETTIMEOUT Can set/get the timeout
171 189
190The watchdog can do pretimeouts.
191
192 WDIOF_PRETIMEOUT Pretimeout (in seconds), get/set
193
172 194
173For those drivers that return any bits set in the option field, the 195For those drivers that return any bits set in the option field, the
174GETSTATUS and GETBOOTSTATUS ioctls can be used to ask for the current 196GETSTATUS and GETBOOTSTATUS ioctls can be used to ask for the current
diff --git a/Documentation/watchdog/watchdog.txt b/Documentation/watchdog/watchdog.txt
index dffda29c8799..4b1ff69cc19a 100644
--- a/Documentation/watchdog/watchdog.txt
+++ b/Documentation/watchdog/watchdog.txt
@@ -65,28 +65,7 @@ The external event interfaces on the WDT boards are not currently supported.
65Minor numbers are however allocated for it. 65Minor numbers are however allocated for it.
66 66
67 67
68Example Watchdog Driver 68Example Watchdog Driver: see Documentation/watchdog/src/watchdog-simple.c
69-----------------------
70
71#include <stdio.h>
72#include <unistd.h>
73#include <fcntl.h>
74
75int main(int argc, const char *argv[])
76{
77 int fd=open("/dev/watchdog",O_WRONLY);
78 if(fd==-1)
79 {
80 perror("watchdog");
81 exit(1);
82 }
83 while(1)
84 {
85 write(fd,"\0",1);
86 fsync(fd);
87 sleep(10);
88 }
89}
90 69
91 70
92Contact Information 71Contact Information
diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
index da677f829f76..63af36cf7f6e 100644
--- a/arch/alpha/kernel/irq.c
+++ b/arch/alpha/kernel/irq.c
@@ -49,15 +49,15 @@ select_smp_affinity(unsigned int irq)
49 static int last_cpu; 49 static int last_cpu;
50 int cpu = last_cpu + 1; 50 int cpu = last_cpu + 1;
51 51
52 if (!irq_desc[irq].handler->set_affinity || irq_user_affinity[irq]) 52 if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
53 return 1; 53 return 1;
54 54
55 while (!cpu_possible(cpu)) 55 while (!cpu_possible(cpu))
56 cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); 56 cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
57 last_cpu = cpu; 57 last_cpu = cpu;
58 58
59 irq_affinity[irq] = cpumask_of_cpu(cpu); 59 irq_desc[irq].affinity = cpumask_of_cpu(cpu);
60 irq_desc[irq].handler->set_affinity(irq, cpumask_of_cpu(cpu)); 60 irq_desc[irq].chip->set_affinity(irq, cpumask_of_cpu(cpu));
61 return 0; 61 return 0;
62} 62}
63#endif /* CONFIG_SMP */ 63#endif /* CONFIG_SMP */
@@ -93,7 +93,7 @@ show_interrupts(struct seq_file *p, void *v)
93 for_each_online_cpu(j) 93 for_each_online_cpu(j)
94 seq_printf(p, "%10u ", kstat_cpu(j).irqs[irq]); 94 seq_printf(p, "%10u ", kstat_cpu(j).irqs[irq]);
95#endif 95#endif
96 seq_printf(p, " %14s", irq_desc[irq].handler->typename); 96 seq_printf(p, " %14s", irq_desc[irq].chip->typename);
97 seq_printf(p, " %c%s", 97 seq_printf(p, " %c%s",
98 (action->flags & SA_INTERRUPT)?'+':' ', 98 (action->flags & SA_INTERRUPT)?'+':' ',
99 action->name); 99 action->name);
diff --git a/arch/alpha/kernel/irq_alpha.c b/arch/alpha/kernel/irq_alpha.c
index 9d34ce26e5ef..f20f2dff9c43 100644
--- a/arch/alpha/kernel/irq_alpha.c
+++ b/arch/alpha/kernel/irq_alpha.c
@@ -233,7 +233,7 @@ void __init
233init_rtc_irq(void) 233init_rtc_irq(void)
234{ 234{
235 irq_desc[RTC_IRQ].status = IRQ_DISABLED; 235 irq_desc[RTC_IRQ].status = IRQ_DISABLED;
236 irq_desc[RTC_IRQ].handler = &rtc_irq_type; 236 irq_desc[RTC_IRQ].chip = &rtc_irq_type;
237 setup_irq(RTC_IRQ, &timer_irqaction); 237 setup_irq(RTC_IRQ, &timer_irqaction);
238} 238}
239 239
diff --git a/arch/alpha/kernel/irq_i8259.c b/arch/alpha/kernel/irq_i8259.c
index b188683b83fd..ac893bd48036 100644
--- a/arch/alpha/kernel/irq_i8259.c
+++ b/arch/alpha/kernel/irq_i8259.c
@@ -109,7 +109,7 @@ init_i8259a_irqs(void)
109 109
110 for (i = 0; i < 16; i++) { 110 for (i = 0; i < 16; i++) {
111 irq_desc[i].status = IRQ_DISABLED; 111 irq_desc[i].status = IRQ_DISABLED;
112 irq_desc[i].handler = &i8259a_irq_type; 112 irq_desc[i].chip = &i8259a_irq_type;
113 } 113 }
114 114
115 setup_irq(2, &cascade); 115 setup_irq(2, &cascade);
diff --git a/arch/alpha/kernel/irq_pyxis.c b/arch/alpha/kernel/irq_pyxis.c
index 146a20b9e3d5..3b581415bab0 100644
--- a/arch/alpha/kernel/irq_pyxis.c
+++ b/arch/alpha/kernel/irq_pyxis.c
@@ -120,7 +120,7 @@ init_pyxis_irqs(unsigned long ignore_mask)
120 if ((ignore_mask >> i) & 1) 120 if ((ignore_mask >> i) & 1)
121 continue; 121 continue;
122 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 122 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
123 irq_desc[i].handler = &pyxis_irq_type; 123 irq_desc[i].chip = &pyxis_irq_type;
124 } 124 }
125 125
126 setup_irq(16+7, &isa_cascade_irqaction); 126 setup_irq(16+7, &isa_cascade_irqaction);
diff --git a/arch/alpha/kernel/irq_srm.c b/arch/alpha/kernel/irq_srm.c
index 0a87e466918c..8e4d121f84cc 100644
--- a/arch/alpha/kernel/irq_srm.c
+++ b/arch/alpha/kernel/irq_srm.c
@@ -67,7 +67,7 @@ init_srm_irqs(long max, unsigned long ignore_mask)
67 if (i < 64 && ((ignore_mask >> i) & 1)) 67 if (i < 64 && ((ignore_mask >> i) & 1))
68 continue; 68 continue;
69 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 69 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
70 irq_desc[i].handler = &srm_irq_type; 70 irq_desc[i].chip = &srm_irq_type;
71 } 71 }
72} 72}
73 73
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 2a8b364c822e..4ea6711e55aa 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -124,12 +124,12 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final);
124 124
125void 125void
126pcibios_align_resource(void *data, struct resource *res, 126pcibios_align_resource(void *data, struct resource *res,
127 unsigned long size, unsigned long align) 127 resource_size_t size, resource_size_t align)
128{ 128{
129 struct pci_dev *dev = data; 129 struct pci_dev *dev = data;
130 struct pci_controller *hose = dev->sysdata; 130 struct pci_controller *hose = dev->sysdata;
131 unsigned long alignto; 131 unsigned long alignto;
132 unsigned long start = res->start; 132 resource_size_t start = res->start;
133 133
134 if (res->flags & IORESOURCE_IO) { 134 if (res->flags & IORESOURCE_IO) {
135 /* Make sure we start at our min on all hoses */ 135 /* Make sure we start at our min on all hoses */
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 558b83368559..254c507a608c 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -481,7 +481,7 @@ register_cpus(void)
481 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); 481 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
482 if (!p) 482 if (!p)
483 return -ENOMEM; 483 return -ENOMEM;
484 register_cpu(p, i, NULL); 484 register_cpu(p, i);
485 } 485 }
486 return 0; 486 return 0;
487} 487}
diff --git a/arch/alpha/kernel/sys_alcor.c b/arch/alpha/kernel/sys_alcor.c
index d7f0e97fe56f..1a1a2c7a3d94 100644
--- a/arch/alpha/kernel/sys_alcor.c
+++ b/arch/alpha/kernel/sys_alcor.c
@@ -144,7 +144,7 @@ alcor_init_irq(void)
144 if (i >= 16+20 && i <= 16+30) 144 if (i >= 16+20 && i <= 16+30)
145 continue; 145 continue;
146 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 146 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
147 irq_desc[i].handler = &alcor_irq_type; 147 irq_desc[i].chip = &alcor_irq_type;
148 } 148 }
149 i8259a_irq_type.ack = alcor_isa_mask_and_ack_irq; 149 i8259a_irq_type.ack = alcor_isa_mask_and_ack_irq;
150 150
diff --git a/arch/alpha/kernel/sys_cabriolet.c b/arch/alpha/kernel/sys_cabriolet.c
index 8e3374d34c95..8c9e443d93ad 100644
--- a/arch/alpha/kernel/sys_cabriolet.c
+++ b/arch/alpha/kernel/sys_cabriolet.c
@@ -124,7 +124,7 @@ common_init_irq(void (*srm_dev_int)(unsigned long v, struct pt_regs *r))
124 124
125 for (i = 16; i < 35; ++i) { 125 for (i = 16; i < 35; ++i) {
126 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 126 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
127 irq_desc[i].handler = &cabriolet_irq_type; 127 irq_desc[i].chip = &cabriolet_irq_type;
128 } 128 }
129 } 129 }
130 130
diff --git a/arch/alpha/kernel/sys_dp264.c b/arch/alpha/kernel/sys_dp264.c
index d5da6b1b28ee..b28c8f1c6e10 100644
--- a/arch/alpha/kernel/sys_dp264.c
+++ b/arch/alpha/kernel/sys_dp264.c
@@ -300,7 +300,7 @@ init_tsunami_irqs(struct hw_interrupt_type * ops, int imin, int imax)
300 long i; 300 long i;
301 for (i = imin; i <= imax; ++i) { 301 for (i = imin; i <= imax; ++i) {
302 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 302 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
303 irq_desc[i].handler = ops; 303 irq_desc[i].chip = ops;
304 } 304 }
305} 305}
306 306
diff --git a/arch/alpha/kernel/sys_eb64p.c b/arch/alpha/kernel/sys_eb64p.c
index 61a79c354f0b..aeb8e0277905 100644
--- a/arch/alpha/kernel/sys_eb64p.c
+++ b/arch/alpha/kernel/sys_eb64p.c
@@ -137,7 +137,7 @@ eb64p_init_irq(void)
137 137
138 for (i = 16; i < 32; ++i) { 138 for (i = 16; i < 32; ++i) {
139 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 139 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
140 irq_desc[i].handler = &eb64p_irq_type; 140 irq_desc[i].chip = &eb64p_irq_type;
141 } 141 }
142 142
143 common_init_isa_dma(); 143 common_init_isa_dma();
diff --git a/arch/alpha/kernel/sys_eiger.c b/arch/alpha/kernel/sys_eiger.c
index bd6e5f0e43c7..64a785baf53a 100644
--- a/arch/alpha/kernel/sys_eiger.c
+++ b/arch/alpha/kernel/sys_eiger.c
@@ -154,7 +154,7 @@ eiger_init_irq(void)
154 154
155 for (i = 16; i < 128; ++i) { 155 for (i = 16; i < 128; ++i) {
156 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 156 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
157 irq_desc[i].handler = &eiger_irq_type; 157 irq_desc[i].chip = &eiger_irq_type;
158 } 158 }
159} 159}
160 160
diff --git a/arch/alpha/kernel/sys_jensen.c b/arch/alpha/kernel/sys_jensen.c
index fcabb7c96a16..0148e095638f 100644
--- a/arch/alpha/kernel/sys_jensen.c
+++ b/arch/alpha/kernel/sys_jensen.c
@@ -206,11 +206,11 @@ jensen_init_irq(void)
206{ 206{
207 init_i8259a_irqs(); 207 init_i8259a_irqs();
208 208
209 irq_desc[1].handler = &jensen_local_irq_type; 209 irq_desc[1].chip = &jensen_local_irq_type;
210 irq_desc[4].handler = &jensen_local_irq_type; 210 irq_desc[4].chip = &jensen_local_irq_type;
211 irq_desc[3].handler = &jensen_local_irq_type; 211 irq_desc[3].chip = &jensen_local_irq_type;
212 irq_desc[7].handler = &jensen_local_irq_type; 212 irq_desc[7].chip = &jensen_local_irq_type;
213 irq_desc[9].handler = &jensen_local_irq_type; 213 irq_desc[9].chip = &jensen_local_irq_type;
214 214
215 common_init_isa_dma(); 215 common_init_isa_dma();
216} 216}
diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c
index e32fee505220..36d215954376 100644
--- a/arch/alpha/kernel/sys_marvel.c
+++ b/arch/alpha/kernel/sys_marvel.c
@@ -303,7 +303,7 @@ init_io7_irqs(struct io7 *io7,
303 /* Set up the lsi irqs. */ 303 /* Set up the lsi irqs. */
304 for (i = 0; i < 128; ++i) { 304 for (i = 0; i < 128; ++i) {
305 irq_desc[base + i].status = IRQ_DISABLED | IRQ_LEVEL; 305 irq_desc[base + i].status = IRQ_DISABLED | IRQ_LEVEL;
306 irq_desc[base + i].handler = lsi_ops; 306 irq_desc[base + i].chip = lsi_ops;
307 } 307 }
308 308
309 /* Disable the implemented irqs in hardware. */ 309 /* Disable the implemented irqs in hardware. */
@@ -317,7 +317,7 @@ init_io7_irqs(struct io7 *io7,
317 /* Set up the msi irqs. */ 317 /* Set up the msi irqs. */
318 for (i = 128; i < (128 + 512); ++i) { 318 for (i = 128; i < (128 + 512); ++i) {
319 irq_desc[base + i].status = IRQ_DISABLED | IRQ_LEVEL; 319 irq_desc[base + i].status = IRQ_DISABLED | IRQ_LEVEL;
320 irq_desc[base + i].handler = msi_ops; 320 irq_desc[base + i].chip = msi_ops;
321 } 321 }
322 322
323 for (i = 0; i < 16; ++i) 323 for (i = 0; i < 16; ++i)
@@ -335,7 +335,7 @@ marvel_init_irq(void)
335 /* Reserve the legacy irqs. */ 335 /* Reserve the legacy irqs. */
336 for (i = 0; i < 16; ++i) { 336 for (i = 0; i < 16; ++i) {
337 irq_desc[i].status = IRQ_DISABLED; 337 irq_desc[i].status = IRQ_DISABLED;
338 irq_desc[i].handler = &marvel_legacy_irq_type; 338 irq_desc[i].chip = &marvel_legacy_irq_type;
339 } 339 }
340 340
341 /* Init the io7 irqs. */ 341 /* Init the io7 irqs. */
diff --git a/arch/alpha/kernel/sys_mikasa.c b/arch/alpha/kernel/sys_mikasa.c
index d78a0daa6168..b741600e3761 100644
--- a/arch/alpha/kernel/sys_mikasa.c
+++ b/arch/alpha/kernel/sys_mikasa.c
@@ -117,7 +117,7 @@ mikasa_init_irq(void)
117 117
118 for (i = 16; i < 32; ++i) { 118 for (i = 16; i < 32; ++i) {
119 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 119 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
120 irq_desc[i].handler = &mikasa_irq_type; 120 irq_desc[i].chip = &mikasa_irq_type;
121 } 121 }
122 122
123 init_i8259a_irqs(); 123 init_i8259a_irqs();
diff --git a/arch/alpha/kernel/sys_noritake.c b/arch/alpha/kernel/sys_noritake.c
index 65061f5d7410..55db02d318d7 100644
--- a/arch/alpha/kernel/sys_noritake.c
+++ b/arch/alpha/kernel/sys_noritake.c
@@ -139,7 +139,7 @@ noritake_init_irq(void)
139 139
140 for (i = 16; i < 48; ++i) { 140 for (i = 16; i < 48; ++i) {
141 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 141 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
142 irq_desc[i].handler = &noritake_irq_type; 142 irq_desc[i].chip = &noritake_irq_type;
143 } 143 }
144 144
145 init_i8259a_irqs(); 145 init_i8259a_irqs();
diff --git a/arch/alpha/kernel/sys_rawhide.c b/arch/alpha/kernel/sys_rawhide.c
index 05888a02a604..949607e3d6fb 100644
--- a/arch/alpha/kernel/sys_rawhide.c
+++ b/arch/alpha/kernel/sys_rawhide.c
@@ -180,7 +180,7 @@ rawhide_init_irq(void)
180 180
181 for (i = 16; i < 128; ++i) { 181 for (i = 16; i < 128; ++i) {
182 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 182 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
183 irq_desc[i].handler = &rawhide_irq_type; 183 irq_desc[i].chip = &rawhide_irq_type;
184 } 184 }
185 185
186 init_i8259a_irqs(); 186 init_i8259a_irqs();
diff --git a/arch/alpha/kernel/sys_rx164.c b/arch/alpha/kernel/sys_rx164.c
index 58404243057b..6ae506052635 100644
--- a/arch/alpha/kernel/sys_rx164.c
+++ b/arch/alpha/kernel/sys_rx164.c
@@ -117,7 +117,7 @@ rx164_init_irq(void)
117 rx164_update_irq_hw(0); 117 rx164_update_irq_hw(0);
118 for (i = 16; i < 40; ++i) { 118 for (i = 16; i < 40; ++i) {
119 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 119 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
120 irq_desc[i].handler = &rx164_irq_type; 120 irq_desc[i].chip = &rx164_irq_type;
121 } 121 }
122 122
123 init_i8259a_irqs(); 123 init_i8259a_irqs();
diff --git a/arch/alpha/kernel/sys_sable.c b/arch/alpha/kernel/sys_sable.c
index a7ff84474ace..24dea40c9bfe 100644
--- a/arch/alpha/kernel/sys_sable.c
+++ b/arch/alpha/kernel/sys_sable.c
@@ -537,7 +537,7 @@ sable_lynx_init_irq(int nr_irqs)
537 537
538 for (i = 0; i < nr_irqs; ++i) { 538 for (i = 0; i < nr_irqs; ++i) {
539 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 539 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
540 irq_desc[i].handler = &sable_lynx_irq_type; 540 irq_desc[i].chip = &sable_lynx_irq_type;
541 } 541 }
542 542
543 common_init_isa_dma(); 543 common_init_isa_dma();
diff --git a/arch/alpha/kernel/sys_takara.c b/arch/alpha/kernel/sys_takara.c
index 7955bdfc2db0..2c75cd1fd81a 100644
--- a/arch/alpha/kernel/sys_takara.c
+++ b/arch/alpha/kernel/sys_takara.c
@@ -154,7 +154,7 @@ takara_init_irq(void)
154 154
155 for (i = 16; i < 128; ++i) { 155 for (i = 16; i < 128; ++i) {
156 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 156 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
157 irq_desc[i].handler = &takara_irq_type; 157 irq_desc[i].chip = &takara_irq_type;
158 } 158 }
159 159
160 common_init_isa_dma(); 160 common_init_isa_dma();
diff --git a/arch/alpha/kernel/sys_titan.c b/arch/alpha/kernel/sys_titan.c
index 2551fb49ae09..13f3ed8ed7ac 100644
--- a/arch/alpha/kernel/sys_titan.c
+++ b/arch/alpha/kernel/sys_titan.c
@@ -189,7 +189,7 @@ init_titan_irqs(struct hw_interrupt_type * ops, int imin, int imax)
189 long i; 189 long i;
190 for (i = imin; i <= imax; ++i) { 190 for (i = imin; i <= imax; ++i) {
191 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; 191 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
192 irq_desc[i].handler = ops; 192 irq_desc[i].chip = ops;
193 } 193 }
194} 194}
195 195
diff --git a/arch/alpha/kernel/sys_wildfire.c b/arch/alpha/kernel/sys_wildfire.c
index 1553f470246e..22c5798fe083 100644
--- a/arch/alpha/kernel/sys_wildfire.c
+++ b/arch/alpha/kernel/sys_wildfire.c
@@ -199,14 +199,14 @@ wildfire_init_irq_per_pca(int qbbno, int pcano)
199 if (i == 2) 199 if (i == 2)
200 continue; 200 continue;
201 irq_desc[i+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL; 201 irq_desc[i+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL;
202 irq_desc[i+irq_bias].handler = &wildfire_irq_type; 202 irq_desc[i+irq_bias].chip = &wildfire_irq_type;
203 } 203 }
204 204
205 irq_desc[36+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL; 205 irq_desc[36+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL;
206 irq_desc[36+irq_bias].handler = &wildfire_irq_type; 206 irq_desc[36+irq_bias].chip = &wildfire_irq_type;
207 for (i = 40; i < 64; ++i) { 207 for (i = 40; i < 64; ++i) {
208 irq_desc[i+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL; 208 irq_desc[i+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL;
209 irq_desc[i+irq_bias].handler = &wildfire_irq_type; 209 irq_desc[i+irq_bias].chip = &wildfire_irq_type;
210 } 210 }
211 211
212 setup_irq(32+irq_bias, &isa_enable); 212 setup_irq(32+irq_bias, &isa_enable);
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3d1a3fb7d5fc..f123c7c9fc98 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -188,23 +188,27 @@ config ARCH_IMX
188 188
189config ARCH_IOP3XX 189config ARCH_IOP3XX
190 bool "IOP3xx-based" 190 bool "IOP3xx-based"
191 depends on MMU
191 select PCI 192 select PCI
192 help 193 help
193 Support for Intel's IOP3XX (XScale) family of processors. 194 Support for Intel's IOP3XX (XScale) family of processors.
194 195
195config ARCH_IXP4XX 196config ARCH_IXP4XX
196 bool "IXP4xx-based" 197 bool "IXP4xx-based"
198 depends on MMU
197 help 199 help
198 Support for Intel's IXP4XX (XScale) family of processors. 200 Support for Intel's IXP4XX (XScale) family of processors.
199 201
200config ARCH_IXP2000 202config ARCH_IXP2000
201 bool "IXP2400/2800-based" 203 bool "IXP2400/2800-based"
204 depends on MMU
202 select PCI 205 select PCI
203 help 206 help
204 Support for Intel's IXP2400/2800 (XScale) family of processors. 207 Support for Intel's IXP2400/2800 (XScale) family of processors.
205 208
206config ARCH_IXP23XX 209config ARCH_IXP23XX
207 bool "IXP23XX-based" 210 bool "IXP23XX-based"
211 depends on MMU
208 select PCI 212 select PCI
209 help 213 help
210 Support for Intel's IXP23xx (XScale) family of processors. 214 Support for Intel's IXP23xx (XScale) family of processors.
@@ -229,6 +233,7 @@ config ARCH_PNX4008
229 233
230config ARCH_PXA 234config ARCH_PXA
231 bool "PXA2xx-based" 235 bool "PXA2xx-based"
236 depends on MMU
232 select ARCH_MTD_XIP 237 select ARCH_MTD_XIP
233 help 238 help
234 Support for Intel's PXA2XX processor line. 239 Support for Intel's PXA2XX processor line.
@@ -339,6 +344,10 @@ config XSCALE_PMU
339 depends on CPU_XSCALE && !XSCALE_PMU_TIMER 344 depends on CPU_XSCALE && !XSCALE_PMU_TIMER
340 default y 345 default y
341 346
347if !MMU
348source "arch/arm/Kconfig-nommu"
349endif
350
342endmenu 351endmenu
343 352
344source "arch/arm/common/Kconfig" 353source "arch/arm/common/Kconfig"
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index a601b8b55f35..7cffbaef064b 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -22,6 +22,9 @@ obj-$(CONFIG_PCI) += bios32.o
22obj-$(CONFIG_SMP) += smp.o 22obj-$(CONFIG_SMP) += smp.o
23obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o 23obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
24 24
25obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o
26AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
27
25obj-$(CONFIG_IWMMXT) += iwmmxt.o 28obj-$(CONFIG_IWMMXT) += iwmmxt.o
26AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt 29AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt
27 30
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index c49b5d4d7fca..da69e660574b 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -109,11 +109,13 @@ EXPORT_SYMBOL(memchr);
109EXPORT_SYMBOL(__memzero); 109EXPORT_SYMBOL(__memzero);
110 110
111 /* user mem (segment) */ 111 /* user mem (segment) */
112EXPORT_SYMBOL(__arch_copy_from_user); 112EXPORT_SYMBOL(__strnlen_user);
113EXPORT_SYMBOL(__arch_copy_to_user); 113EXPORT_SYMBOL(__strncpy_from_user);
114EXPORT_SYMBOL(__arch_clear_user); 114
115EXPORT_SYMBOL(__arch_strnlen_user); 115#ifdef CONFIG_MMU
116EXPORT_SYMBOL(__arch_strncpy_from_user); 116EXPORT_SYMBOL(__copy_from_user);
117EXPORT_SYMBOL(__copy_to_user);
118EXPORT_SYMBOL(__clear_user);
117 119
118EXPORT_SYMBOL(__get_user_1); 120EXPORT_SYMBOL(__get_user_1);
119EXPORT_SYMBOL(__get_user_2); 121EXPORT_SYMBOL(__get_user_2);
@@ -123,6 +125,7 @@ EXPORT_SYMBOL(__put_user_1);
123EXPORT_SYMBOL(__put_user_2); 125EXPORT_SYMBOL(__put_user_2);
124EXPORT_SYMBOL(__put_user_4); 126EXPORT_SYMBOL(__put_user_4);
125EXPORT_SYMBOL(__put_user_8); 127EXPORT_SYMBOL(__put_user_8);
128#endif
126 129
127 /* crypto hash */ 130 /* crypto hash */
128EXPORT_SYMBOL(sha_transform); 131EXPORT_SYMBOL(sha_transform);
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 396efba9bacd..447ede5143a8 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -60,6 +60,9 @@ int main(void)
60#ifdef CONFIG_IWMMXT 60#ifdef CONFIG_IWMMXT
61 DEFINE(TI_IWMMXT_STATE, offsetof(struct thread_info, fpstate.iwmmxt)); 61 DEFINE(TI_IWMMXT_STATE, offsetof(struct thread_info, fpstate.iwmmxt));
62#endif 62#endif
63#ifdef CONFIG_CRUNCH
64 DEFINE(TI_CRUNCH_STATE, offsetof(struct thread_info, crunchstate));
65#endif
63 BLANK(); 66 BLANK();
64 DEFINE(S_R0, offsetof(struct pt_regs, ARM_r0)); 67 DEFINE(S_R0, offsetof(struct pt_regs, ARM_r0));
65 DEFINE(S_R1, offsetof(struct pt_regs, ARM_r1)); 68 DEFINE(S_R1, offsetof(struct pt_regs, ARM_r1));
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 302fc1401547..45da06fc1ba1 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -304,7 +304,7 @@ static inline int pdev_bad_for_parity(struct pci_dev *dev)
304static void __devinit 304static void __devinit
305pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev) 305pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev)
306{ 306{
307 unsigned long offset; 307 resource_size_t offset;
308 int i; 308 int i;
309 309
310 for (i = 0; i < PCI_NUM_RESOURCES; i++) { 310 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
@@ -634,9 +634,9 @@ char * __init pcibios_setup(char *str)
634 * which might be mirrored at 0x0100-0x03ff.. 634 * which might be mirrored at 0x0100-0x03ff..
635 */ 635 */
636void pcibios_align_resource(void *data, struct resource *res, 636void pcibios_align_resource(void *data, struct resource *res,
637 unsigned long size, unsigned long align) 637 resource_size_t size, resource_size_t align)
638{ 638{
639 unsigned long start = res->start; 639 resource_size_t start = res->start;
640 640
641 if (res->flags & IORESOURCE_IO && start & 0x300) 641 if (res->flags & IORESOURCE_IO && start & 0x300)
642 start = (start + 0x3ff) & ~0x3ff; 642 start = (start + 0x3ff) & ~0x3ff;
diff --git a/arch/arm/kernel/crunch-bits.S b/arch/arm/kernel/crunch-bits.S
new file mode 100644
index 000000000000..a26886758c67
--- /dev/null
+++ b/arch/arm/kernel/crunch-bits.S
@@ -0,0 +1,305 @@
1/*
2 * arch/arm/kernel/crunch-bits.S
3 * Cirrus MaverickCrunch context switching and handling
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * Shamelessly stolen from the iWMMXt code by Nicolas Pitre, which is
8 * Copyright (c) 2003-2004, MontaVista Software, Inc.
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 version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/linkage.h>
16#include <asm/ptrace.h>
17#include <asm/thread_info.h>
18#include <asm/asm-offsets.h>
19#include <asm/arch/ep93xx-regs.h>
20
21/*
22 * We can't use hex constants here due to a bug in gas.
23 */
24#define CRUNCH_MVDX0 0
25#define CRUNCH_MVDX1 8
26#define CRUNCH_MVDX2 16
27#define CRUNCH_MVDX3 24
28#define CRUNCH_MVDX4 32
29#define CRUNCH_MVDX5 40
30#define CRUNCH_MVDX6 48
31#define CRUNCH_MVDX7 56
32#define CRUNCH_MVDX8 64
33#define CRUNCH_MVDX9 72
34#define CRUNCH_MVDX10 80
35#define CRUNCH_MVDX11 88
36#define CRUNCH_MVDX12 96
37#define CRUNCH_MVDX13 104
38#define CRUNCH_MVDX14 112
39#define CRUNCH_MVDX15 120
40#define CRUNCH_MVAX0L 128
41#define CRUNCH_MVAX0M 132
42#define CRUNCH_MVAX0H 136
43#define CRUNCH_MVAX1L 140
44#define CRUNCH_MVAX1M 144
45#define CRUNCH_MVAX1H 148
46#define CRUNCH_MVAX2L 152
47#define CRUNCH_MVAX2M 156
48#define CRUNCH_MVAX2H 160
49#define CRUNCH_MVAX3L 164
50#define CRUNCH_MVAX3M 168
51#define CRUNCH_MVAX3H 172
52#define CRUNCH_DSPSC 176
53
54#define CRUNCH_SIZE 184
55
56 .text
57
58/*
59 * Lazy switching of crunch coprocessor context
60 *
61 * r10 = struct thread_info pointer
62 * r9 = ret_from_exception
63 * lr = undefined instr exit
64 *
65 * called from prefetch exception handler with interrupts disabled
66 */
67ENTRY(crunch_task_enable)
68 ldr r8, =(EP93XX_APB_VIRT_BASE + 0x00130000) @ syscon addr
69
70 ldr r1, [r8, #0x80]
71 tst r1, #0x00800000 @ access to crunch enabled?
72 movne pc, lr @ if so no business here
73 mov r3, #0xaa @ unlock syscon swlock
74 str r3, [r8, #0xc0]
75 orr r1, r1, #0x00800000 @ enable access to crunch
76 str r1, [r8, #0x80]
77
78 ldr r3, =crunch_owner
79 add r0, r10, #TI_CRUNCH_STATE @ get task crunch save area
80 ldr r2, [sp, #60] @ current task pc value
81 ldr r1, [r3] @ get current crunch owner
82 str r0, [r3] @ this task now owns crunch
83 sub r2, r2, #4 @ adjust pc back
84 str r2, [sp, #60]
85
86 ldr r2, [r8, #0x80]
87 mov r2, r2 @ flush out enable (@@@)
88
89 teq r1, #0 @ test for last ownership
90 mov lr, r9 @ normal exit from exception
91 beq crunch_load @ no owner, skip save
92
93crunch_save:
94 cfstr64 mvdx0, [r1, #CRUNCH_MVDX0] @ save 64b registers
95 cfstr64 mvdx1, [r1, #CRUNCH_MVDX1]
96 cfstr64 mvdx2, [r1, #CRUNCH_MVDX2]
97 cfstr64 mvdx3, [r1, #CRUNCH_MVDX3]
98 cfstr64 mvdx4, [r1, #CRUNCH_MVDX4]
99 cfstr64 mvdx5, [r1, #CRUNCH_MVDX5]
100 cfstr64 mvdx6, [r1, #CRUNCH_MVDX6]
101 cfstr64 mvdx7, [r1, #CRUNCH_MVDX7]
102 cfstr64 mvdx8, [r1, #CRUNCH_MVDX8]
103 cfstr64 mvdx9, [r1, #CRUNCH_MVDX9]
104 cfstr64 mvdx10, [r1, #CRUNCH_MVDX10]
105 cfstr64 mvdx11, [r1, #CRUNCH_MVDX11]
106 cfstr64 mvdx12, [r1, #CRUNCH_MVDX12]
107 cfstr64 mvdx13, [r1, #CRUNCH_MVDX13]
108 cfstr64 mvdx14, [r1, #CRUNCH_MVDX14]
109 cfstr64 mvdx15, [r1, #CRUNCH_MVDX15]
110
111#ifdef __ARMEB__
112#error fix me for ARMEB
113#endif
114
115 cfmv32al mvfx0, mvax0 @ save 72b accumulators
116 cfstr32 mvfx0, [r1, #CRUNCH_MVAX0L]
117 cfmv32am mvfx0, mvax0
118 cfstr32 mvfx0, [r1, #CRUNCH_MVAX0M]
119 cfmv32ah mvfx0, mvax0
120 cfstr32 mvfx0, [r1, #CRUNCH_MVAX0H]
121 cfmv32al mvfx0, mvax1
122 cfstr32 mvfx0, [r1, #CRUNCH_MVAX1L]
123 cfmv32am mvfx0, mvax1
124 cfstr32 mvfx0, [r1, #CRUNCH_MVAX1M]
125 cfmv32ah mvfx0, mvax1
126 cfstr32 mvfx0, [r1, #CRUNCH_MVAX1H]
127 cfmv32al mvfx0, mvax2
128 cfstr32 mvfx0, [r1, #CRUNCH_MVAX2L]
129 cfmv32am mvfx0, mvax2
130 cfstr32 mvfx0, [r1, #CRUNCH_MVAX2M]
131 cfmv32ah mvfx0, mvax2
132 cfstr32 mvfx0, [r1, #CRUNCH_MVAX2H]
133 cfmv32al mvfx0, mvax3
134 cfstr32 mvfx0, [r1, #CRUNCH_MVAX3L]
135 cfmv32am mvfx0, mvax3
136 cfstr32 mvfx0, [r1, #CRUNCH_MVAX3M]
137 cfmv32ah mvfx0, mvax3
138 cfstr32 mvfx0, [r1, #CRUNCH_MVAX3H]
139
140 cfmv32sc mvdx0, dspsc @ save status word
141 cfstr64 mvdx0, [r1, #CRUNCH_DSPSC]
142
143 teq r0, #0 @ anything to load?
144 cfldr64eq mvdx0, [r1, #CRUNCH_MVDX0] @ mvdx0 was clobbered
145 moveq pc, lr
146
147crunch_load:
148 cfldr64 mvdx0, [r0, #CRUNCH_DSPSC] @ load status word
149 cfmvsc32 dspsc, mvdx0
150
151 cfldr32 mvfx0, [r0, #CRUNCH_MVAX0L] @ load 72b accumulators
152 cfmval32 mvax0, mvfx0
153 cfldr32 mvfx0, [r0, #CRUNCH_MVAX0M]
154 cfmvam32 mvax0, mvfx0
155 cfldr32 mvfx0, [r0, #CRUNCH_MVAX0H]
156 cfmvah32 mvax0, mvfx0
157 cfldr32 mvfx0, [r0, #CRUNCH_MVAX1L]
158 cfmval32 mvax1, mvfx0
159 cfldr32 mvfx0, [r0, #CRUNCH_MVAX1M]
160 cfmvam32 mvax1, mvfx0
161 cfldr32 mvfx0, [r0, #CRUNCH_MVAX1H]
162 cfmvah32 mvax1, mvfx0
163 cfldr32 mvfx0, [r0, #CRUNCH_MVAX2L]
164 cfmval32 mvax2, mvfx0
165 cfldr32 mvfx0, [r0, #CRUNCH_MVAX2M]
166 cfmvam32 mvax2, mvfx0
167 cfldr32 mvfx0, [r0, #CRUNCH_MVAX2H]
168 cfmvah32 mvax2, mvfx0
169 cfldr32 mvfx0, [r0, #CRUNCH_MVAX3L]
170 cfmval32 mvax3, mvfx0
171 cfldr32 mvfx0, [r0, #CRUNCH_MVAX3M]
172 cfmvam32 mvax3, mvfx0
173 cfldr32 mvfx0, [r0, #CRUNCH_MVAX3H]
174 cfmvah32 mvax3, mvfx0
175
176 cfldr64 mvdx0, [r0, #CRUNCH_MVDX0] @ load 64b registers
177 cfldr64 mvdx1, [r0, #CRUNCH_MVDX1]
178 cfldr64 mvdx2, [r0, #CRUNCH_MVDX2]
179 cfldr64 mvdx3, [r0, #CRUNCH_MVDX3]
180 cfldr64 mvdx4, [r0, #CRUNCH_MVDX4]
181 cfldr64 mvdx5, [r0, #CRUNCH_MVDX5]
182 cfldr64 mvdx6, [r0, #CRUNCH_MVDX6]
183 cfldr64 mvdx7, [r0, #CRUNCH_MVDX7]
184 cfldr64 mvdx8, [r0, #CRUNCH_MVDX8]
185 cfldr64 mvdx9, [r0, #CRUNCH_MVDX9]
186 cfldr64 mvdx10, [r0, #CRUNCH_MVDX10]
187 cfldr64 mvdx11, [r0, #CRUNCH_MVDX11]
188 cfldr64 mvdx12, [r0, #CRUNCH_MVDX12]
189 cfldr64 mvdx13, [r0, #CRUNCH_MVDX13]
190 cfldr64 mvdx14, [r0, #CRUNCH_MVDX14]
191 cfldr64 mvdx15, [r0, #CRUNCH_MVDX15]
192
193 mov pc, lr
194
195/*
196 * Back up crunch regs to save area and disable access to them
197 * (mainly for gdb or sleep mode usage)
198 *
199 * r0 = struct thread_info pointer of target task or NULL for any
200 */
201ENTRY(crunch_task_disable)
202 stmfd sp!, {r4, r5, lr}
203
204 mrs ip, cpsr
205 orr r2, ip, #PSR_I_BIT @ disable interrupts
206 msr cpsr_c, r2
207
208 ldr r4, =(EP93XX_APB_VIRT_BASE + 0x00130000) @ syscon addr
209
210 ldr r3, =crunch_owner
211 add r2, r0, #TI_CRUNCH_STATE @ get task crunch save area
212 ldr r1, [r3] @ get current crunch owner
213 teq r1, #0 @ any current owner?
214 beq 1f @ no: quit
215 teq r0, #0 @ any owner?
216 teqne r1, r2 @ or specified one?
217 bne 1f @ no: quit
218
219 ldr r5, [r4, #0x80] @ enable access to crunch
220 mov r2, #0xaa
221 str r2, [r4, #0xc0]
222 orr r5, r5, #0x00800000
223 str r5, [r4, #0x80]
224
225 mov r0, #0 @ nothing to load
226 str r0, [r3] @ no more current owner
227 ldr r2, [r4, #0x80] @ flush out enable (@@@)
228 mov r2, r2
229 bl crunch_save
230
231 mov r2, #0xaa @ disable access to crunch
232 str r2, [r4, #0xc0]
233 bic r5, r5, #0x00800000
234 str r5, [r4, #0x80]
235 ldr r5, [r4, #0x80] @ flush out enable (@@@)
236 mov r5, r5
237
2381: msr cpsr_c, ip @ restore interrupt mode
239 ldmfd sp!, {r4, r5, pc}
240
241/*
242 * Copy crunch state to given memory address
243 *
244 * r0 = struct thread_info pointer of target task
245 * r1 = memory address where to store crunch state
246 *
247 * this is called mainly in the creation of signal stack frames
248 */
249ENTRY(crunch_task_copy)
250 mrs ip, cpsr
251 orr r2, ip, #PSR_I_BIT @ disable interrupts
252 msr cpsr_c, r2
253
254 ldr r3, =crunch_owner
255 add r2, r0, #TI_CRUNCH_STATE @ get task crunch save area
256 ldr r3, [r3] @ get current crunch owner
257 teq r2, r3 @ does this task own it...
258 beq 1f
259
260 @ current crunch values are in the task save area
261 msr cpsr_c, ip @ restore interrupt mode
262 mov r0, r1
263 mov r1, r2
264 mov r2, #CRUNCH_SIZE
265 b memcpy
266
2671: @ this task owns crunch regs -- grab a copy from there
268 mov r0, #0 @ nothing to load
269 mov r3, lr @ preserve return address
270 bl crunch_save
271 msr cpsr_c, ip @ restore interrupt mode
272 mov pc, r3
273
274/*
275 * Restore crunch state from given memory address
276 *
277 * r0 = struct thread_info pointer of target task
278 * r1 = memory address where to get crunch state from
279 *
280 * this is used to restore crunch state when unwinding a signal stack frame
281 */
282ENTRY(crunch_task_restore)
283 mrs ip, cpsr
284 orr r2, ip, #PSR_I_BIT @ disable interrupts
285 msr cpsr_c, r2
286
287 ldr r3, =crunch_owner
288 add r2, r0, #TI_CRUNCH_STATE @ get task crunch save area
289 ldr r3, [r3] @ get current crunch owner
290 teq r2, r3 @ does this task own it...
291 beq 1f
292
293 @ this task doesn't own crunch regs -- use its save area
294 msr cpsr_c, ip @ restore interrupt mode
295 mov r0, r2
296 mov r2, #CRUNCH_SIZE
297 b memcpy
298
2991: @ this task owns crunch regs -- load them directly
300 mov r0, r1
301 mov r1, #0 @ nothing to save
302 mov r3, lr @ preserve return address
303 bl crunch_load
304 msr cpsr_c, ip @ restore interrupt mode
305 mov pc, r3
diff --git a/arch/arm/kernel/crunch.c b/arch/arm/kernel/crunch.c
new file mode 100644
index 000000000000..748175921f9b
--- /dev/null
+++ b/arch/arm/kernel/crunch.c
@@ -0,0 +1,83 @@
1/*
2 * arch/arm/kernel/crunch.c
3 * Cirrus MaverickCrunch context switching and handling
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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/config.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/signal.h>
17#include <linux/sched.h>
18#include <linux/init.h>
19#include <asm/arch/ep93xx-regs.h>
20#include <asm/thread_notify.h>
21#include <asm/io.h>
22
23struct crunch_state *crunch_owner;
24
25void crunch_task_release(struct thread_info *thread)
26{
27 local_irq_disable();
28 if (crunch_owner == &thread->crunchstate)
29 crunch_owner = NULL;
30 local_irq_enable();
31}
32
33static int crunch_enabled(u32 devcfg)
34{
35 return !!(devcfg & EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE);
36}
37
38static int crunch_do(struct notifier_block *self, unsigned long cmd, void *t)
39{
40 struct thread_info *thread = (struct thread_info *)t;
41 struct crunch_state *crunch_state;
42 u32 devcfg;
43
44 crunch_state = &thread->crunchstate;
45
46 switch (cmd) {
47 case THREAD_NOTIFY_FLUSH:
48 memset(crunch_state, 0, sizeof(*crunch_state));
49
50 /*
51 * FALLTHROUGH: Ensure we don't try to overwrite our newly
52 * initialised state information on the first fault.
53 */
54
55 case THREAD_NOTIFY_RELEASE:
56 crunch_task_release(thread);
57 break;
58
59 case THREAD_NOTIFY_SWITCH:
60 devcfg = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
61 if (crunch_enabled(devcfg) || crunch_owner == crunch_state) {
62 devcfg ^= EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE;
63 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
64 __raw_writel(devcfg, EP93XX_SYSCON_DEVICE_CONFIG);
65 }
66 break;
67 }
68
69 return NOTIFY_DONE;
70}
71
72static struct notifier_block crunch_notifier_block = {
73 .notifier_call = crunch_do,
74};
75
76static int __init crunch_init(void)
77{
78 thread_register_notifier(&crunch_notifier_block);
79
80 return 0;
81}
82
83late_initcall(crunch_init);
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 86c92523a346..6423a38839b8 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -492,9 +492,15 @@ call_fpe:
492 b do_fpe @ CP#1 (FPE) 492 b do_fpe @ CP#1 (FPE)
493 b do_fpe @ CP#2 (FPE) 493 b do_fpe @ CP#2 (FPE)
494 mov pc, lr @ CP#3 494 mov pc, lr @ CP#3
495#ifdef CONFIG_CRUNCH
496 b crunch_task_enable @ CP#4 (MaverickCrunch)
497 b crunch_task_enable @ CP#5 (MaverickCrunch)
498 b crunch_task_enable @ CP#6 (MaverickCrunch)
499#else
495 mov pc, lr @ CP#4 500 mov pc, lr @ CP#4
496 mov pc, lr @ CP#5 501 mov pc, lr @ CP#5
497 mov pc, lr @ CP#6 502 mov pc, lr @ CP#6
503#endif
498 mov pc, lr @ CP#7 504 mov pc, lr @ CP#7
499 mov pc, lr @ CP#8 505 mov pc, lr @ CP#8
500 mov pc, lr @ CP#9 506 mov pc, lr @ CP#9
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index a1d1b2906e8d..c40bdc770054 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -634,6 +634,32 @@ static int ptrace_setwmmxregs(struct task_struct *tsk, void __user *ufp)
634 634
635#endif 635#endif
636 636
637#ifdef CONFIG_CRUNCH
638/*
639 * Get the child Crunch state.
640 */
641static int ptrace_getcrunchregs(struct task_struct *tsk, void __user *ufp)
642{
643 struct thread_info *thread = task_thread_info(tsk);
644
645 crunch_task_disable(thread); /* force it to ram */
646 return copy_to_user(ufp, &thread->crunchstate, CRUNCH_SIZE)
647 ? -EFAULT : 0;
648}
649
650/*
651 * Set the child Crunch state.
652 */
653static int ptrace_setcrunchregs(struct task_struct *tsk, void __user *ufp)
654{
655 struct thread_info *thread = task_thread_info(tsk);
656
657 crunch_task_release(thread); /* force a reload */
658 return copy_from_user(&thread->crunchstate, ufp, CRUNCH_SIZE)
659 ? -EFAULT : 0;
660}
661#endif
662
637long arch_ptrace(struct task_struct *child, long request, long addr, long data) 663long arch_ptrace(struct task_struct *child, long request, long addr, long data)
638{ 664{
639 unsigned long tmp; 665 unsigned long tmp;
@@ -765,6 +791,16 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
765 child->ptrace_message = data; 791 child->ptrace_message = data;
766 break; 792 break;
767 793
794#ifdef CONFIG_CRUNCH
795 case PTRACE_GETCRUNCHREGS:
796 ret = ptrace_getcrunchregs(child, (void __user *)data);
797 break;
798
799 case PTRACE_SETCRUNCHREGS:
800 ret = ptrace_setcrunchregs(child, (void __user *)data);
801 break;
802#endif
803
768 default: 804 default:
769 ret = ptrace_request(child, request, addr, data); 805 ret = ptrace_request(child, request, addr, data);
770 break; 806 break;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 9fc9af88c60c..6bdf70def01f 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -119,9 +119,24 @@ DEFINE_PER_CPU(struct cpuinfo_arm, cpu_data);
119 * Standard memory resources 119 * Standard memory resources
120 */ 120 */
121static struct resource mem_res[] = { 121static struct resource mem_res[] = {
122 { "Video RAM", 0, 0, IORESOURCE_MEM }, 122 {
123 { "Kernel text", 0, 0, IORESOURCE_MEM }, 123 .name = "Video RAM",
124 { "Kernel data", 0, 0, IORESOURCE_MEM } 124 .start = 0,
125 .end = 0,
126 .flags = IORESOURCE_MEM
127 },
128 {
129 .name = "Kernel text",
130 .start = 0,
131 .end = 0,
132 .flags = IORESOURCE_MEM
133 },
134 {
135 .name = "Kernel data",
136 .start = 0,
137 .end = 0,
138 .flags = IORESOURCE_MEM
139 }
125}; 140};
126 141
127#define video_ram mem_res[0] 142#define video_ram mem_res[0]
@@ -129,9 +144,24 @@ static struct resource mem_res[] = {
129#define kernel_data mem_res[2] 144#define kernel_data mem_res[2]
130 145
131static struct resource io_res[] = { 146static struct resource io_res[] = {
132 { "reserved", 0x3bc, 0x3be, IORESOURCE_IO | IORESOURCE_BUSY }, 147 {
133 { "reserved", 0x378, 0x37f, IORESOURCE_IO | IORESOURCE_BUSY }, 148 .name = "reserved",
134 { "reserved", 0x278, 0x27f, IORESOURCE_IO | IORESOURCE_BUSY } 149 .start = 0x3bc,
150 .end = 0x3be,
151 .flags = IORESOURCE_IO | IORESOURCE_BUSY
152 },
153 {
154 .name = "reserved",
155 .start = 0x378,
156 .end = 0x37f,
157 .flags = IORESOURCE_IO | IORESOURCE_BUSY
158 },
159 {
160 .name = "reserved",
161 .start = 0x278,
162 .end = 0x27f,
163 .flags = IORESOURCE_IO | IORESOURCE_BUSY
164 }
135}; 165};
136 166
137#define lp0 io_res[0] 167#define lp0 io_res[0]
@@ -808,7 +838,7 @@ static int __init topology_init(void)
808 int cpu; 838 int cpu;
809 839
810 for_each_possible_cpu(cpu) 840 for_each_possible_cpu(cpu)
811 register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu, NULL); 841 register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu);
812 842
813 return 0; 843 return 0;
814} 844}
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 1ce05ec086c6..83a8d3c95eb3 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -132,6 +132,37 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
132 return ret; 132 return ret;
133} 133}
134 134
135#ifdef CONFIG_CRUNCH
136static int preserve_crunch_context(struct crunch_sigframe *frame)
137{
138 char kbuf[sizeof(*frame) + 8];
139 struct crunch_sigframe *kframe;
140
141 /* the crunch context must be 64 bit aligned */
142 kframe = (struct crunch_sigframe *)((unsigned long)(kbuf + 8) & ~7);
143 kframe->magic = CRUNCH_MAGIC;
144 kframe->size = CRUNCH_STORAGE_SIZE;
145 crunch_task_copy(current_thread_info(), &kframe->storage);
146 return __copy_to_user(frame, kframe, sizeof(*frame));
147}
148
149static int restore_crunch_context(struct crunch_sigframe *frame)
150{
151 char kbuf[sizeof(*frame) + 8];
152 struct crunch_sigframe *kframe;
153
154 /* the crunch context must be 64 bit aligned */
155 kframe = (struct crunch_sigframe *)((unsigned long)(kbuf + 8) & ~7);
156 if (__copy_from_user(kframe, frame, sizeof(*frame)))
157 return -1;
158 if (kframe->magic != CRUNCH_MAGIC ||
159 kframe->size != CRUNCH_STORAGE_SIZE)
160 return -1;
161 crunch_task_restore(current_thread_info(), &kframe->storage);
162 return 0;
163}
164#endif
165
135#ifdef CONFIG_IWMMXT 166#ifdef CONFIG_IWMMXT
136 167
137static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame) 168static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame)
@@ -214,6 +245,10 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
214 err |= !valid_user_regs(regs); 245 err |= !valid_user_regs(regs);
215 246
216 aux = (struct aux_sigframe __user *) sf->uc.uc_regspace; 247 aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
248#ifdef CONFIG_CRUNCH
249 if (err == 0)
250 err |= restore_crunch_context(&aux->crunch);
251#endif
217#ifdef CONFIG_IWMMXT 252#ifdef CONFIG_IWMMXT
218 if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) 253 if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
219 err |= restore_iwmmxt_context(&aux->iwmmxt); 254 err |= restore_iwmmxt_context(&aux->iwmmxt);
@@ -333,6 +368,10 @@ setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set)
333 err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); 368 err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set));
334 369
335 aux = (struct aux_sigframe __user *) sf->uc.uc_regspace; 370 aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
371#ifdef CONFIG_CRUNCH
372 if (err == 0)
373 err |= preserve_crunch_context(&aux->crunch);
374#endif
336#ifdef CONFIG_IWMMXT 375#ifdef CONFIG_IWMMXT
337 if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) 376 if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
338 err |= preserve_iwmmxt_context(&aux->iwmmxt); 377 err |= preserve_iwmmxt_context(&aux->iwmmxt);
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 2b254e88595c..2df9688a7028 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -80,6 +80,10 @@ SECTIONS
80 *(.exit.text) 80 *(.exit.text)
81 *(.exit.data) 81 *(.exit.data)
82 *(.exitcall.exit) 82 *(.exitcall.exit)
83#ifndef CONFIG_MMU
84 *(.fixup)
85 *(__ex_table)
86#endif
83 } 87 }
84 88
85 .text : { /* Real text segment */ 89 .text : { /* Real text segment */
@@ -87,7 +91,9 @@ SECTIONS
87 *(.text) 91 *(.text)
88 SCHED_TEXT 92 SCHED_TEXT
89 LOCK_TEXT 93 LOCK_TEXT
94#ifdef CONFIG_MMU
90 *(.fixup) 95 *(.fixup)
96#endif
91 *(.gnu.warning) 97 *(.gnu.warning)
92 *(.rodata) 98 *(.rodata)
93 *(.rodata.*) 99 *(.rodata.*)
@@ -142,7 +148,9 @@ SECTIONS
142 */ 148 */
143 . = ALIGN(32); 149 . = ALIGN(32);
144 __start___ex_table = .; 150 __start___ex_table = .;
151#ifdef CONFIG_MMU
145 *(__ex_table) 152 *(__ex_table)
153#endif
146 __stop___ex_table = .; 154 __stop___ex_table = .;
147 155
148 /* 156 /*
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 7b726b627ea5..30351cd4560d 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -6,28 +6,31 @@
6 6
7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \ 7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \ 8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \
9 copy_page.o delay.o findbit.o memchr.o memcpy.o \ 9 delay.o findbit.o memchr.o memcpy.o \
10 memmove.o memset.o memzero.o setbit.o \ 10 memmove.o memset.o memzero.o setbit.o \
11 strncpy_from_user.o strnlen_user.o \ 11 strncpy_from_user.o strnlen_user.o \
12 strchr.o strrchr.o \ 12 strchr.o strrchr.o \
13 testchangebit.o testclearbit.o testsetbit.o \ 13 testchangebit.o testclearbit.o testsetbit.o \
14 getuser.o putuser.o clear_user.o \
15 ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 14 ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
16 ucmpdi2.o lib1funcs.o div64.o sha1.o \ 15 ucmpdi2.o lib1funcs.o div64.o sha1.o \
17 io-readsb.o io-writesb.o io-readsl.o io-writesl.o 16 io-readsb.o io-writesb.o io-readsl.o io-writesl.o
18 17
18mmu-y := clear_user.o copy_page.o getuser.o putuser.o
19
19# the code in uaccess.S is not preemption safe and 20# the code in uaccess.S is not preemption safe and
20# probably faster on ARMv3 only 21# probably faster on ARMv3 only
21ifeq ($(CONFIG_PREEMPT),y) 22ifeq ($(CONFIG_PREEMPT),y)
22 lib-y += copy_from_user.o copy_to_user.o 23 mmu-y += copy_from_user.o copy_to_user.o
23else 24else
24ifneq ($(CONFIG_CPU_32v3),y) 25ifneq ($(CONFIG_CPU_32v3),y)
25 lib-y += copy_from_user.o copy_to_user.o 26 mmu-y += copy_from_user.o copy_to_user.o
26else 27else
27 lib-y += uaccess.o 28 mmu-y += uaccess.o
28endif 29endif
29endif 30endif
30 31
32lib-$(CONFIG_MMU) += $(mmu-y)
33
31ifeq ($(CONFIG_CPU_32v3),y) 34ifeq ($(CONFIG_CPU_32v3),y)
32 lib-y += io-readsw-armv3.o io-writesw-armv3.o 35 lib-y += io-readsw-armv3.o io-writesw-armv3.o
33else 36else
diff --git a/arch/arm/lib/backtrace.S b/arch/arm/lib/backtrace.S
index 058b80d72aa1..91f993f2e9db 100644
--- a/arch/arm/lib/backtrace.S
+++ b/arch/arm/lib/backtrace.S
@@ -97,16 +97,13 @@ ENTRY(c_backtrace)
97 b 1007f 97 b 1007f
98 98
99/* 99/*
100 * Fixup for LDMDB 100 * Fixup for LDMDB. Note that this must not be in the fixup section.
101 */ 101 */
102 .section .fixup,"ax"
103 .align 0
1041007: ldr r0, =.Lbad 1021007: ldr r0, =.Lbad
105 mov r1, frame 103 mov r1, frame
106 bl printk 104 bl printk
107 ldmfd sp!, {r4 - r8, pc} 105 ldmfd sp!, {r4 - r8, pc}
108 .ltorg 106 .ltorg
109 .previous
110 107
111 .section __ex_table,"a" 108 .section __ex_table,"a"
112 .align 3 109 .align 3
diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
index ea435ae2e4a5..ecb28dcdaf7b 100644
--- a/arch/arm/lib/clear_user.S
+++ b/arch/arm/lib/clear_user.S
@@ -12,13 +12,13 @@
12 12
13 .text 13 .text
14 14
15/* Prototype: int __arch_clear_user(void *addr, size_t sz) 15/* Prototype: int __clear_user(void *addr, size_t sz)
16 * Purpose : clear some user memory 16 * Purpose : clear some user memory
17 * Params : addr - user memory address to clear 17 * Params : addr - user memory address to clear
18 * : sz - number of bytes to clear 18 * : sz - number of bytes to clear
19 * Returns : number of bytes NOT cleared 19 * Returns : number of bytes NOT cleared
20 */ 20 */
21ENTRY(__arch_clear_user) 21ENTRY(__clear_user)
22 stmfd sp!, {r1, lr} 22 stmfd sp!, {r1, lr}
23 mov r2, #0 23 mov r2, #0
24 cmp r1, #4 24 cmp r1, #4
diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
index 7497393a0e81..6b7363ce749c 100644
--- a/arch/arm/lib/copy_from_user.S
+++ b/arch/arm/lib/copy_from_user.S
@@ -16,7 +16,7 @@
16/* 16/*
17 * Prototype: 17 * Prototype:
18 * 18 *
19 * size_t __arch_copy_from_user(void *to, const void *from, size_t n) 19 * size_t __copy_from_user(void *to, const void *from, size_t n)
20 * 20 *
21 * Purpose: 21 * Purpose:
22 * 22 *
@@ -83,7 +83,7 @@
83 83
84 .text 84 .text
85 85
86ENTRY(__arch_copy_from_user) 86ENTRY(__copy_from_user)
87 87
88#include "copy_template.S" 88#include "copy_template.S"
89 89
diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
index 4a6d8ea14022..5224d94688d9 100644
--- a/arch/arm/lib/copy_to_user.S
+++ b/arch/arm/lib/copy_to_user.S
@@ -16,7 +16,7 @@
16/* 16/*
17 * Prototype: 17 * Prototype:
18 * 18 *
19 * size_t __arch_copy_to_user(void *to, const void *from, size_t n) 19 * size_t __copy_to_user(void *to, const void *from, size_t n)
20 * 20 *
21 * Purpose: 21 * Purpose:
22 * 22 *
@@ -86,7 +86,7 @@
86 86
87 .text 87 .text
88 88
89ENTRY(__arch_copy_to_user) 89ENTRY(__copy_to_user)
90 90
91#include "copy_template.S" 91#include "copy_template.S"
92 92
diff --git a/arch/arm/lib/strncpy_from_user.S b/arch/arm/lib/strncpy_from_user.S
index 35649f04fcac..36e3741a3772 100644
--- a/arch/arm/lib/strncpy_from_user.S
+++ b/arch/arm/lib/strncpy_from_user.S
@@ -20,7 +20,7 @@
20 * returns the number of characters copied (strlen of copied string), 20 * returns the number of characters copied (strlen of copied string),
21 * -EFAULT on exception, or "len" if we fill the whole buffer 21 * -EFAULT on exception, or "len" if we fill the whole buffer
22 */ 22 */
23ENTRY(__arch_strncpy_from_user) 23ENTRY(__strncpy_from_user)
24 mov ip, r1 24 mov ip, r1
251: subs r2, r2, #1 251: subs r2, r2, #1
26USER( ldrplbt r3, [r1], #1) 26USER( ldrplbt r3, [r1], #1)
diff --git a/arch/arm/lib/strnlen_user.S b/arch/arm/lib/strnlen_user.S
index 3668a15991ef..18d8fa4f925a 100644
--- a/arch/arm/lib/strnlen_user.S
+++ b/arch/arm/lib/strnlen_user.S
@@ -14,13 +14,13 @@
14 .text 14 .text
15 .align 5 15 .align 5
16 16
17/* Prototype: unsigned long __arch_strnlen_user(const char *str, long n) 17/* Prototype: unsigned long __strnlen_user(const char *str, long n)
18 * Purpose : get length of a string in user memory 18 * Purpose : get length of a string in user memory
19 * Params : str - address of string in user memory 19 * Params : str - address of string in user memory
20 * Returns : length of string *including terminator* 20 * Returns : length of string *including terminator*
21 * or zero on exception, or n + 1 if too long 21 * or zero on exception, or n + 1 if too long
22 */ 22 */
23ENTRY(__arch_strnlen_user) 23ENTRY(__strnlen_user)
24 mov r2, r0 24 mov r2, r0
251: 251:
26USER( ldrbt r3, [r0], #1) 26USER( ldrbt r3, [r0], #1)
diff --git a/arch/arm/lib/uaccess.S b/arch/arm/lib/uaccess.S
index 1f1545d737be..b48bd6d5fd83 100644
--- a/arch/arm/lib/uaccess.S
+++ b/arch/arm/lib/uaccess.S
@@ -19,7 +19,7 @@
19 19
20#define PAGE_SHIFT 12 20#define PAGE_SHIFT 12
21 21
22/* Prototype: int __arch_copy_to_user(void *to, const char *from, size_t n) 22/* Prototype: int __copy_to_user(void *to, const char *from, size_t n)
23 * Purpose : copy a block to user memory from kernel memory 23 * Purpose : copy a block to user memory from kernel memory
24 * Params : to - user memory 24 * Params : to - user memory
25 * : from - kernel memory 25 * : from - kernel memory
@@ -39,7 +39,7 @@ USER( strgtbt r3, [r0], #1) @ May fault
39 sub r2, r2, ip 39 sub r2, r2, ip
40 b .Lc2u_dest_aligned 40 b .Lc2u_dest_aligned
41 41
42ENTRY(__arch_copy_to_user) 42ENTRY(__copy_to_user)
43 stmfd sp!, {r2, r4 - r7, lr} 43 stmfd sp!, {r2, r4 - r7, lr}
44 cmp r2, #4 44 cmp r2, #4
45 blt .Lc2u_not_enough 45 blt .Lc2u_not_enough
@@ -283,7 +283,7 @@ USER( strgtbt r3, [r0], #1) @ May fault
2839001: ldmfd sp!, {r0, r4 - r7, pc} 2839001: ldmfd sp!, {r0, r4 - r7, pc}
284 .previous 284 .previous
285 285
286/* Prototype: unsigned long __arch_copy_from_user(void *to,const void *from,unsigned long n); 286/* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n);
287 * Purpose : copy a block from user memory to kernel memory 287 * Purpose : copy a block from user memory to kernel memory
288 * Params : to - kernel memory 288 * Params : to - kernel memory
289 * : from - user memory 289 * : from - user memory
@@ -302,7 +302,7 @@ USER( ldrgtbt r3, [r1], #1) @ May fault
302 sub r2, r2, ip 302 sub r2, r2, ip
303 b .Lcfu_dest_aligned 303 b .Lcfu_dest_aligned
304 304
305ENTRY(__arch_copy_from_user) 305ENTRY(__copy_from_user)
306 stmfd sp!, {r0, r2, r4 - r7, lr} 306 stmfd sp!, {r0, r2, r4 - r7, lr}
307 cmp r2, #4 307 cmp r2, #4
308 blt .Lcfu_not_enough 308 blt .Lcfu_not_enough
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
index cec5a21ca4e3..e15e4c54a253 100644
--- a/arch/arm/mach-ep93xx/Kconfig
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -2,8 +2,19 @@ if ARCH_EP93XX
2 2
3menu "Cirrus EP93xx Implementation Options" 3menu "Cirrus EP93xx Implementation Options"
4 4
5config CRUNCH
6 bool "Support for MaverickCrunch"
7 help
8 Enable kernel support for MaverickCrunch.
9
5comment "EP93xx Platforms" 10comment "EP93xx Platforms"
6 11
12config MACH_EDB9315
13 bool "Support Cirrus Logic EDB9315"
14 help
15 Say 'Y' here if you want your kernel to support the Cirrus
16 Logic EDB9315 Evaluation Board.
17
7config MACH_GESBC9312 18config MACH_GESBC9312
8 bool "Support Glomation GESBC-9312-sx" 19 bool "Support Glomation GESBC-9312-sx"
9 help 20 help
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index 05a48a21038e..dfa7e2e8a18b 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -6,5 +6,6 @@ obj-m :=
6obj-n := 6obj-n :=
7obj- := 7obj- :=
8 8
9obj-$(CONFIG_MACH_EDB9315) += edb9315.o
9obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o 10obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o
10obj-$(CONFIG_MACH_TS72XX) += ts72xx.o 11obj-$(CONFIG_MACH_TS72XX) += ts72xx.o
diff --git a/arch/arm/mach-ep93xx/edb9315.c b/arch/arm/mach-ep93xx/edb9315.c
new file mode 100644
index 000000000000..ef7482faad81
--- /dev/null
+++ b/arch/arm/mach-ep93xx/edb9315.c
@@ -0,0 +1,62 @@
1/*
2 * arch/arm/mach-ep93xx/edb9315.c
3 * Cirrus Logic EDB9315 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/ioport.h>
20#include <linux/mtd/physmap.h>
21#include <linux/platform_device.h>
22#include <asm/io.h>
23#include <asm/hardware.h>
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26
27static struct physmap_flash_data edb9315_flash_data = {
28 .width = 4,
29};
30
31static struct resource edb9315_flash_resource = {
32 .start = 0x60000000,
33 .end = 0x61ffffff,
34 .flags = IORESOURCE_MEM,
35};
36
37static struct platform_device edb9315_flash = {
38 .name = "physmap-flash",
39 .id = 0,
40 .dev = {
41 .platform_data = &edb9315_flash_data,
42 },
43 .num_resources = 1,
44 .resource = &edb9315_flash_resource,
45};
46
47static void __init edb9315_init_machine(void)
48{
49 ep93xx_init_devices();
50 platform_device_register(&edb9315_flash);
51}
52
53MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
54 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
55 .phys_io = EP93XX_APB_PHYS_BASE,
56 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
57 .boot_params = 0x00000100,
58 .map_io = ep93xx_map_io,
59 .init_irq = ep93xx_init_irq,
60 .timer = &ep93xx_timer,
61 .init_machine = edb9315_init_machine,
62MACHINE_END
diff --git a/arch/arm/mach-ep93xx/gesbc9312.c b/arch/arm/mach-ep93xx/gesbc9312.c
index 47cc6c8b7c79..2c28d66d260e 100644
--- a/arch/arm/mach-ep93xx/gesbc9312.c
+++ b/arch/arm/mach-ep93xx/gesbc9312.c
@@ -30,7 +30,7 @@ static struct physmap_flash_data gesbc9312_flash_data = {
30 30
31static struct resource gesbc9312_flash_resource = { 31static struct resource gesbc9312_flash_resource = {
32 .start = 0x60000000, 32 .start = 0x60000000,
33 .end = 0x60800000, 33 .end = 0x607fffff,
34 .flags = IORESOURCE_MEM, 34 .flags = IORESOURCE_MEM,
35}; 35};
36 36
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index 6e5a56cd5ae8..0b3b875b1875 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -118,7 +118,7 @@ static struct physmap_flash_data ts72xx_flash_data = {
118 118
119static struct resource ts72xx_flash_resource = { 119static struct resource ts72xx_flash_resource = {
120 .start = TS72XX_NOR_PHYS_BASE, 120 .start = TS72XX_NOR_PHYS_BASE,
121 .end = TS72XX_NOR_PHYS_BASE + 0x01000000, 121 .end = TS72XX_NOR_PHYS_BASE + 0x00ffffff,
122 .flags = IORESOURCE_MEM, 122 .flags = IORESOURCE_MEM,
123}; 123};
124 124
diff --git a/arch/arm/mach-ixp23xx/espresso.c b/arch/arm/mach-ixp23xx/espresso.c
index dc5e489c70bc..357351fbb1e2 100644
--- a/arch/arm/mach-ixp23xx/espresso.c
+++ b/arch/arm/mach-ixp23xx/espresso.c
@@ -59,7 +59,7 @@ static struct physmap_flash_data espresso_flash_data = {
59 59
60static struct resource espresso_flash_resource = { 60static struct resource espresso_flash_resource = {
61 .start = 0x90000000, 61 .start = 0x90000000,
62 .end = 0x92000000, 62 .end = 0x91ffffff,
63 .flags = IORESOURCE_MEM, 63 .flags = IORESOURCE_MEM,
64}; 64};
65 65
diff --git a/arch/arm/mach-ixp23xx/ixdp2351.c b/arch/arm/mach-ixp23xx/ixdp2351.c
index 535b334ee045..e0886871cc77 100644
--- a/arch/arm/mach-ixp23xx/ixdp2351.c
+++ b/arch/arm/mach-ixp23xx/ixdp2351.c
@@ -304,7 +304,7 @@ static struct physmap_flash_data ixdp2351_flash_data = {
304 304
305static struct resource ixdp2351_flash_resource = { 305static struct resource ixdp2351_flash_resource = {
306 .start = 0x90000000, 306 .start = 0x90000000,
307 .end = 0x94000000, 307 .end = 0x93ffffff,
308 .flags = IORESOURCE_MEM, 308 .flags = IORESOURCE_MEM,
309}; 309};
310 310
diff --git a/arch/arm/mach-ixp23xx/roadrunner.c b/arch/arm/mach-ixp23xx/roadrunner.c
index b9f5d13fcfe1..92ad18f41251 100644
--- a/arch/arm/mach-ixp23xx/roadrunner.c
+++ b/arch/arm/mach-ixp23xx/roadrunner.c
@@ -143,7 +143,7 @@ static struct physmap_flash_data roadrunner_flash_data = {
143 143
144static struct resource roadrunner_flash_resource = { 144static struct resource roadrunner_flash_resource = {
145 .start = 0x90000000, 145 .start = 0x90000000,
146 .end = 0x94000000, 146 .end = 0x93ffffff,
147 .flags = IORESOURCE_MEM, 147 .flags = IORESOURCE_MEM,
148}; 148};
149 149
diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
index 539b596005fc..d9635ff4b10c 100644
--- a/arch/arm/mach-pxa/irq.c
+++ b/arch/arm/mach-pxa/irq.c
@@ -88,8 +88,8 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type)
88 88
89 if (type == IRQT_PROBE) { 89 if (type == IRQT_PROBE) {
90 /* Don't mess with enabled GPIOs using preconfigured edges or 90 /* Don't mess with enabled GPIOs using preconfigured edges or
91 GPIOs set to alternate function during probe */ 91 GPIOs set to alternate function or to output during probe */
92 if ((GPIO_IRQ_rising_edge[idx] | GPIO_IRQ_falling_edge[idx]) & 92 if ((GPIO_IRQ_rising_edge[idx] | GPIO_IRQ_falling_edge[idx] | GPDR(gpio)) &
93 GPIO_bit(gpio)) 93 GPIO_bit(gpio))
94 return 0; 94 return 0;
95 if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2))) 95 if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2)))
diff --git a/arch/arm/mach-s3c2410/s3c244x.c b/arch/arm/mach-s3c2410/s3c244x.c
index 838bc525e836..9a2258270de9 100644
--- a/arch/arm/mach-s3c2410/s3c244x.c
+++ b/arch/arm/mach-s3c2410/s3c244x.c
@@ -69,6 +69,7 @@ void __init s3c244x_map_io(struct map_desc *mach_desc, int size)
69 69
70 s3c_device_i2c.name = "s3c2440-i2c"; 70 s3c_device_i2c.name = "s3c2440-i2c";
71 s3c_device_nand.name = "s3c2440-nand"; 71 s3c_device_nand.name = "s3c2440-nand";
72 s3c_device_usbgadget.name = "s3c2440-usbgadget";
72} 73}
73 74
74void __init s3c244x_init_clocks(int xtal) 75void __init s3c244x_init_clocks(int xtal)
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index ecf5e232a6fc..c4bca753165b 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -15,8 +15,8 @@ config CPU_ARM610
15 select CPU_32v3 15 select CPU_32v3
16 select CPU_CACHE_V3 16 select CPU_CACHE_V3
17 select CPU_CACHE_VIVT 17 select CPU_CACHE_VIVT
18 select CPU_COPY_V3 18 select CPU_COPY_V3 if MMU
19 select CPU_TLB_V3 19 select CPU_TLB_V3 if MMU
20 help 20 help
21 The ARM610 is the successor to the ARM3 processor 21 The ARM610 is the successor to the ARM3 processor
22 and was produced by VLSI Technology Inc. 22 and was produced by VLSI Technology Inc.
@@ -31,8 +31,8 @@ config CPU_ARM710
31 select CPU_32v3 31 select CPU_32v3
32 select CPU_CACHE_V3 32 select CPU_CACHE_V3
33 select CPU_CACHE_VIVT 33 select CPU_CACHE_VIVT
34 select CPU_COPY_V3 34 select CPU_COPY_V3 if MMU
35 select CPU_TLB_V3 35 select CPU_TLB_V3 if MMU
36 help 36 help
37 A 32-bit RISC microprocessor based on the ARM7 processor core 37 A 32-bit RISC microprocessor based on the ARM7 processor core
38 designed by Advanced RISC Machines Ltd. The ARM710 is the 38 designed by Advanced RISC Machines Ltd. The ARM710 is the
@@ -50,8 +50,8 @@ config CPU_ARM720T
50 select CPU_ABRT_LV4T 50 select CPU_ABRT_LV4T
51 select CPU_CACHE_V4 51 select CPU_CACHE_V4
52 select CPU_CACHE_VIVT 52 select CPU_CACHE_VIVT
53 select CPU_COPY_V4WT 53 select CPU_COPY_V4WT if MMU
54 select CPU_TLB_V4WT 54 select CPU_TLB_V4WT if MMU
55 help 55 help
56 A 32-bit RISC processor with 8kByte Cache, Write Buffer and 56 A 32-bit RISC processor with 8kByte Cache, Write Buffer and
57 MMU built around an ARM7TDMI core. 57 MMU built around an ARM7TDMI core.
@@ -68,8 +68,8 @@ config CPU_ARM920T
68 select CPU_ABRT_EV4T 68 select CPU_ABRT_EV4T
69 select CPU_CACHE_V4WT 69 select CPU_CACHE_V4WT
70 select CPU_CACHE_VIVT 70 select CPU_CACHE_VIVT
71 select CPU_COPY_V4WB 71 select CPU_COPY_V4WB if MMU
72 select CPU_TLB_V4WBI 72 select CPU_TLB_V4WBI if MMU
73 help 73 help
74 The ARM920T is licensed to be produced by numerous vendors, 74 The ARM920T is licensed to be produced by numerous vendors,
75 and is used in the Maverick EP9312 and the Samsung S3C2410. 75 and is used in the Maverick EP9312 and the Samsung S3C2410.
@@ -89,8 +89,8 @@ config CPU_ARM922T
89 select CPU_ABRT_EV4T 89 select CPU_ABRT_EV4T
90 select CPU_CACHE_V4WT 90 select CPU_CACHE_V4WT
91 select CPU_CACHE_VIVT 91 select CPU_CACHE_VIVT
92 select CPU_COPY_V4WB 92 select CPU_COPY_V4WB if MMU
93 select CPU_TLB_V4WBI 93 select CPU_TLB_V4WBI if MMU
94 help 94 help
95 The ARM922T is a version of the ARM920T, but with smaller 95 The ARM922T is a version of the ARM920T, but with smaller
96 instruction and data caches. It is used in Altera's 96 instruction and data caches. It is used in Altera's
@@ -108,8 +108,8 @@ config CPU_ARM925T
108 select CPU_ABRT_EV4T 108 select CPU_ABRT_EV4T
109 select CPU_CACHE_V4WT 109 select CPU_CACHE_V4WT
110 select CPU_CACHE_VIVT 110 select CPU_CACHE_VIVT
111 select CPU_COPY_V4WB 111 select CPU_COPY_V4WB if MMU
112 select CPU_TLB_V4WBI 112 select CPU_TLB_V4WBI if MMU
113 help 113 help
114 The ARM925T is a mix between the ARM920T and ARM926T, but with 114 The ARM925T is a mix between the ARM920T and ARM926T, but with
115 different instruction and data caches. It is used in TI's OMAP 115 different instruction and data caches. It is used in TI's OMAP
@@ -126,8 +126,8 @@ config CPU_ARM926T
126 select CPU_32v5 126 select CPU_32v5
127 select CPU_ABRT_EV5TJ 127 select CPU_ABRT_EV5TJ
128 select CPU_CACHE_VIVT 128 select CPU_CACHE_VIVT
129 select CPU_COPY_V4WB 129 select CPU_COPY_V4WB if MMU
130 select CPU_TLB_V4WBI 130 select CPU_TLB_V4WBI if MMU
131 help 131 help
132 This is a variant of the ARM920. It has slightly different 132 This is a variant of the ARM920. It has slightly different
133 instruction sequences for cache and TLB operations. Curiously, 133 instruction sequences for cache and TLB operations. Curiously,
@@ -144,8 +144,8 @@ config CPU_ARM1020
144 select CPU_ABRT_EV4T 144 select CPU_ABRT_EV4T
145 select CPU_CACHE_V4WT 145 select CPU_CACHE_V4WT
146 select CPU_CACHE_VIVT 146 select CPU_CACHE_VIVT
147 select CPU_COPY_V4WB 147 select CPU_COPY_V4WB if MMU
148 select CPU_TLB_V4WBI 148 select CPU_TLB_V4WBI if MMU
149 help 149 help
150 The ARM1020 is the 32K cached version of the ARM10 processor, 150 The ARM1020 is the 32K cached version of the ARM10 processor,
151 with an addition of a floating-point unit. 151 with an addition of a floating-point unit.
@@ -161,8 +161,8 @@ config CPU_ARM1020E
161 select CPU_ABRT_EV4T 161 select CPU_ABRT_EV4T
162 select CPU_CACHE_V4WT 162 select CPU_CACHE_V4WT
163 select CPU_CACHE_VIVT 163 select CPU_CACHE_VIVT
164 select CPU_COPY_V4WB 164 select CPU_COPY_V4WB if MMU
165 select CPU_TLB_V4WBI 165 select CPU_TLB_V4WBI if MMU
166 depends on n 166 depends on n
167 167
168# ARM1022E 168# ARM1022E
@@ -172,8 +172,8 @@ config CPU_ARM1022
172 select CPU_32v5 172 select CPU_32v5
173 select CPU_ABRT_EV4T 173 select CPU_ABRT_EV4T
174 select CPU_CACHE_VIVT 174 select CPU_CACHE_VIVT
175 select CPU_COPY_V4WB # can probably do better 175 select CPU_COPY_V4WB if MMU # can probably do better
176 select CPU_TLB_V4WBI 176 select CPU_TLB_V4WBI if MMU
177 help 177 help
178 The ARM1022E is an implementation of the ARMv5TE architecture 178 The ARM1022E is an implementation of the ARMv5TE architecture
179 based upon the ARM10 integer core with a 16KiB L1 Harvard cache, 179 based upon the ARM10 integer core with a 16KiB L1 Harvard cache,
@@ -189,8 +189,8 @@ config CPU_ARM1026
189 select CPU_32v5 189 select CPU_32v5
190 select CPU_ABRT_EV5T # But need Jazelle, but EV5TJ ignores bit 10 190 select CPU_ABRT_EV5T # But need Jazelle, but EV5TJ ignores bit 10
191 select CPU_CACHE_VIVT 191 select CPU_CACHE_VIVT
192 select CPU_COPY_V4WB # can probably do better 192 select CPU_COPY_V4WB if MMU # can probably do better
193 select CPU_TLB_V4WBI 193 select CPU_TLB_V4WBI if MMU
194 help 194 help
195 The ARM1026EJ-S is an implementation of the ARMv5TEJ architecture 195 The ARM1026EJ-S is an implementation of the ARMv5TEJ architecture
196 based upon the ARM10 integer core. 196 based upon the ARM10 integer core.
@@ -207,8 +207,8 @@ config CPU_SA110
207 select CPU_ABRT_EV4 207 select CPU_ABRT_EV4
208 select CPU_CACHE_V4WB 208 select CPU_CACHE_V4WB
209 select CPU_CACHE_VIVT 209 select CPU_CACHE_VIVT
210 select CPU_COPY_V4WB 210 select CPU_COPY_V4WB if MMU
211 select CPU_TLB_V4WB 211 select CPU_TLB_V4WB if MMU
212 help 212 help
213 The Intel StrongARM(R) SA-110 is a 32-bit microprocessor and 213 The Intel StrongARM(R) SA-110 is a 32-bit microprocessor and
214 is available at five speeds ranging from 100 MHz to 233 MHz. 214 is available at five speeds ranging from 100 MHz to 233 MHz.
@@ -227,7 +227,7 @@ config CPU_SA1100
227 select CPU_ABRT_EV4 227 select CPU_ABRT_EV4
228 select CPU_CACHE_V4WB 228 select CPU_CACHE_V4WB
229 select CPU_CACHE_VIVT 229 select CPU_CACHE_VIVT
230 select CPU_TLB_V4WB 230 select CPU_TLB_V4WB if MMU
231 231
232# XScale 232# XScale
233config CPU_XSCALE 233config CPU_XSCALE
@@ -237,7 +237,7 @@ config CPU_XSCALE
237 select CPU_32v5 237 select CPU_32v5
238 select CPU_ABRT_EV5T 238 select CPU_ABRT_EV5T
239 select CPU_CACHE_VIVT 239 select CPU_CACHE_VIVT
240 select CPU_TLB_V4WBI 240 select CPU_TLB_V4WBI if MMU
241 241
242# XScale Core Version 3 242# XScale Core Version 3
243config CPU_XSC3 243config CPU_XSC3
@@ -247,7 +247,7 @@ config CPU_XSC3
247 select CPU_32v5 247 select CPU_32v5
248 select CPU_ABRT_EV5T 248 select CPU_ABRT_EV5T
249 select CPU_CACHE_VIVT 249 select CPU_CACHE_VIVT
250 select CPU_TLB_V4WBI 250 select CPU_TLB_V4WBI if MMU
251 select IO_36 251 select IO_36
252 252
253# ARMv6 253# ARMv6
@@ -258,8 +258,8 @@ config CPU_V6
258 select CPU_ABRT_EV6 258 select CPU_ABRT_EV6
259 select CPU_CACHE_V6 259 select CPU_CACHE_V6
260 select CPU_CACHE_VIPT 260 select CPU_CACHE_VIPT
261 select CPU_COPY_V6 261 select CPU_COPY_V6 if MMU
262 select CPU_TLB_V6 262 select CPU_TLB_V6 if MMU
263 263
264# ARMv6k 264# ARMv6k
265config CPU_32v6K 265config CPU_32v6K
@@ -277,17 +277,17 @@ config CPU_32v6K
277# This defines the compiler instruction set which depends on the machine type. 277# This defines the compiler instruction set which depends on the machine type.
278config CPU_32v3 278config CPU_32v3
279 bool 279 bool
280 select TLS_REG_EMUL if SMP 280 select TLS_REG_EMUL if SMP || !MMU
281 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 281 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
282 282
283config CPU_32v4 283config CPU_32v4
284 bool 284 bool
285 select TLS_REG_EMUL if SMP 285 select TLS_REG_EMUL if SMP || !MMU
286 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 286 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
287 287
288config CPU_32v5 288config CPU_32v5
289 bool 289 bool
290 select TLS_REG_EMUL if SMP 290 select TLS_REG_EMUL if SMP || !MMU
291 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 291 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
292 292
293config CPU_32v6 293config CPU_32v6
@@ -334,6 +334,7 @@ config CPU_CACHE_VIVT
334config CPU_CACHE_VIPT 334config CPU_CACHE_VIPT
335 bool 335 bool
336 336
337if MMU
337# The copy-page model 338# The copy-page model
338config CPU_COPY_V3 339config CPU_COPY_V3
339 bool 340 bool
@@ -372,6 +373,8 @@ config CPU_TLB_V4WBI
372config CPU_TLB_V6 373config CPU_TLB_V6
373 bool 374 bool
374 375
376endif
377
375# 378#
376# CPU supports 36-bit I/O 379# CPU supports 36-bit I/O
377# 380#
diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
index 07a538505784..21a2770226ee 100644
--- a/arch/arm/mm/Makefile
+++ b/arch/arm/mm/Makefile
@@ -2,10 +2,16 @@
2# Makefile for the linux arm-specific parts of the memory manager. 2# Makefile for the linux arm-specific parts of the memory manager.
3# 3#
4 4
5obj-y := consistent.o extable.o fault-armv.o \ 5obj-y := consistent.o extable.o fault.o init.o \
6 fault.o flush.o init.o ioremap.o mmap.o \ 6 iomap.o
7
8obj-$(CONFIG_MMU) += fault-armv.o flush.o ioremap.o mmap.o \
7 mm-armv.o 9 mm-armv.o
8 10
11ifneq ($(CONFIG_MMU),y)
12obj-y += nommu.o
13endif
14
9obj-$(CONFIG_MODULES) += proc-syms.o 15obj-$(CONFIG_MODULES) += proc-syms.o
10 16
11obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o 17obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 9ea1f87a7079..989fd681c822 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -26,8 +26,6 @@
26#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
27#include <asm/mach/map.h> 27#include <asm/mach/map.h>
28 28
29#define TABLE_SIZE (2 * PTRS_PER_PTE * sizeof(pte_t))
30
31DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 29DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
32 30
33extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 31extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
diff --git a/arch/arm/mm/iomap.c b/arch/arm/mm/iomap.c
new file mode 100644
index 000000000000..62066f3020c8
--- /dev/null
+++ b/arch/arm/mm/iomap.c
@@ -0,0 +1,55 @@
1/*
2 * linux/arch/arm/mm/iomap.c
3 *
4 * Map IO port and PCI memory spaces so that {read,write}[bwl] can
5 * be used to access this memory.
6 */
7#include <linux/module.h>
8#include <linux/pci.h>
9#include <linux/ioport.h>
10
11#include <asm/io.h>
12
13#ifdef __io
14void __iomem *ioport_map(unsigned long port, unsigned int nr)
15{
16 return __io(port);
17}
18EXPORT_SYMBOL(ioport_map);
19
20void ioport_unmap(void __iomem *addr)
21{
22}
23EXPORT_SYMBOL(ioport_unmap);
24#endif
25
26#ifdef CONFIG_PCI
27void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
28{
29 unsigned long start = pci_resource_start(dev, bar);
30 unsigned long len = pci_resource_len(dev, bar);
31 unsigned long flags = pci_resource_flags(dev, bar);
32
33 if (!len || !start)
34 return NULL;
35 if (maxlen && len > maxlen)
36 len = maxlen;
37 if (flags & IORESOURCE_IO)
38 return ioport_map(start, len);
39 if (flags & IORESOURCE_MEM) {
40 if (flags & IORESOURCE_CACHEABLE)
41 return ioremap(start, len);
42 return ioremap_nocache(start, len);
43 }
44 return NULL;
45}
46EXPORT_SYMBOL(pci_iomap);
47
48void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
49{
50 if ((unsigned long)addr >= VMALLOC_START &&
51 (unsigned long)addr < VMALLOC_END)
52 iounmap(addr);
53}
54EXPORT_SYMBOL(pci_iounmap);
55#endif
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index c1f7180c7bed..7691cfdba567 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -176,50 +176,3 @@ void __iounmap(void __iomem *addr)
176 vunmap((void *)(PAGE_MASK & (unsigned long)addr)); 176 vunmap((void *)(PAGE_MASK & (unsigned long)addr));
177} 177}
178EXPORT_SYMBOL(__iounmap); 178EXPORT_SYMBOL(__iounmap);
179
180#ifdef __io
181void __iomem *ioport_map(unsigned long port, unsigned int nr)
182{
183 return __io(port);
184}
185EXPORT_SYMBOL(ioport_map);
186
187void ioport_unmap(void __iomem *addr)
188{
189}
190EXPORT_SYMBOL(ioport_unmap);
191#endif
192
193#ifdef CONFIG_PCI
194#include <linux/pci.h>
195#include <linux/ioport.h>
196
197void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
198{
199 unsigned long start = pci_resource_start(dev, bar);
200 unsigned long len = pci_resource_len(dev, bar);
201 unsigned long flags = pci_resource_flags(dev, bar);
202
203 if (!len || !start)
204 return NULL;
205 if (maxlen && len > maxlen)
206 len = maxlen;
207 if (flags & IORESOURCE_IO)
208 return ioport_map(start, len);
209 if (flags & IORESOURCE_MEM) {
210 if (flags & IORESOURCE_CACHEABLE)
211 return ioremap(start, len);
212 return ioremap_nocache(start, len);
213 }
214 return NULL;
215}
216EXPORT_SYMBOL(pci_iomap);
217
218void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
219{
220 if ((unsigned long)addr >= VMALLOC_START &&
221 (unsigned long)addr < VMALLOC_END)
222 iounmap(addr);
223}
224EXPORT_SYMBOL(pci_iounmap);
225#endif
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
new file mode 100644
index 000000000000..1464ed817b5d
--- /dev/null
+++ b/arch/arm/mm/nommu.c
@@ -0,0 +1,39 @@
1/*
2 * linux/arch/arm/mm/nommu.c
3 *
4 * ARM uCLinux supporting functions.
5 */
6#include <linux/module.h>
7#include <linux/mm.h>
8#include <linux/pagemap.h>
9
10#include <asm/cacheflush.h>
11#include <asm/io.h>
12#include <asm/page.h>
13
14void flush_dcache_page(struct page *page)
15{
16 __cpuc_flush_dcache_page(page_address(page));
17}
18EXPORT_SYMBOL(flush_dcache_page);
19
20void __iomem *__ioremap_pfn(unsigned long pfn, unsigned long offset,
21 size_t size, unsigned long flags)
22{
23 if (pfn >= (0x100000000ULL >> PAGE_SHIFT))
24 return NULL;
25 return (void __iomem *) (offset + (pfn << PAGE_SHIFT));
26}
27EXPORT_SYMBOL(__ioremap_pfn);
28
29void __iomem *__ioremap(unsigned long phys_addr, size_t size,
30 unsigned long flags)
31{
32 return (void __iomem *)phys_addr;
33}
34EXPORT_SYMBOL(__ioremap);
35
36void __iounmap(void __iomem *addr)
37{
38}
39EXPORT_SYMBOL(__iounmap);
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 959588884fa5..b9abbafca812 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2000 ARM Limited 4 * Copyright (C) 2000 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -101,7 +102,9 @@ ENTRY(cpu_arm1020_reset)
101 mov ip, #0 102 mov ip, #0
102 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 103 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
103 mcr p15, 0, ip, c7, c10, 4 @ drain WB 104 mcr p15, 0, ip, c7, c10, 4 @ drain WB
105#ifdef CONFIG_MMU
104 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 106 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
107#endif
105 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 108 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
106 bic ip, ip, #0x000f @ ............wcam 109 bic ip, ip, #0x000f @ ............wcam
107 bic ip, ip, #0x1100 @ ...i...s........ 110 bic ip, ip, #0x1100 @ ...i...s........
@@ -359,6 +362,7 @@ ENTRY(cpu_arm1020_dcache_clean_area)
359 */ 362 */
360 .align 5 363 .align 5
361ENTRY(cpu_arm1020_switch_mm) 364ENTRY(cpu_arm1020_switch_mm)
365#ifdef CONFIG_MMU
362#ifndef CONFIG_CPU_DCACHE_DISABLE 366#ifndef CONFIG_CPU_DCACHE_DISABLE
363 mcr p15, 0, r3, c7, c10, 4 367 mcr p15, 0, r3, c7, c10, 4
364 mov r1, #0xF @ 16 segments 368 mov r1, #0xF @ 16 segments
@@ -383,6 +387,7 @@ ENTRY(cpu_arm1020_switch_mm)
383 mcr p15, 0, r1, c7, c10, 4 @ drain WB 387 mcr p15, 0, r1, c7, c10, 4 @ drain WB
384 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 388 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
385 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs 389 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
390#endif /* CONFIG_MMU */
386 mov pc, lr 391 mov pc, lr
387 392
388/* 393/*
@@ -392,6 +397,7 @@ ENTRY(cpu_arm1020_switch_mm)
392 */ 397 */
393 .align 5 398 .align 5
394ENTRY(cpu_arm1020_set_pte) 399ENTRY(cpu_arm1020_set_pte)
400#ifdef CONFIG_MMU
395 str r1, [r0], #-2048 @ linux version 401 str r1, [r0], #-2048 @ linux version
396 402
397 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 403 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -421,6 +427,7 @@ ENTRY(cpu_arm1020_set_pte)
421 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 427 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
422#endif 428#endif
423 mcr p15, 0, r0, c7, c10, 4 @ drain WB 429 mcr p15, 0, r0, c7, c10, 4 @ drain WB
430#endif /* CONFIG_MMU */
424 mov pc, lr 431 mov pc, lr
425 432
426 __INIT 433 __INIT
@@ -430,7 +437,9 @@ __arm1020_setup:
430 mov r0, #0 437 mov r0, #0
431 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 438 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
432 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 439 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
440#ifdef CONFIG_MMU
433 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 441 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
442#endif
434 mrc p15, 0, r0, c1, c0 @ get control register v4 443 mrc p15, 0, r0, c1, c0 @ get control register v4
435 ldr r5, arm1020_cr1_clear 444 ldr r5, arm1020_cr1_clear
436 bic r0, r0, r5 445 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index be6d081ff2b7..bcd5ee022e00 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2000 ARM Limited 4 * Copyright (C) 2000 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -101,7 +102,9 @@ ENTRY(cpu_arm1020e_reset)
101 mov ip, #0 102 mov ip, #0
102 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 103 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
103 mcr p15, 0, ip, c7, c10, 4 @ drain WB 104 mcr p15, 0, ip, c7, c10, 4 @ drain WB
105#ifdef CONFIG_MMU
104 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 106 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
107#endif
105 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 108 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
106 bic ip, ip, #0x000f @ ............wcam 109 bic ip, ip, #0x000f @ ............wcam
107 bic ip, ip, #0x1100 @ ...i...s........ 110 bic ip, ip, #0x1100 @ ...i...s........
@@ -344,6 +347,7 @@ ENTRY(cpu_arm1020e_dcache_clean_area)
344 */ 347 */
345 .align 5 348 .align 5
346ENTRY(cpu_arm1020e_switch_mm) 349ENTRY(cpu_arm1020e_switch_mm)
350#ifdef CONFIG_MMU
347#ifndef CONFIG_CPU_DCACHE_DISABLE 351#ifndef CONFIG_CPU_DCACHE_DISABLE
348 mcr p15, 0, r3, c7, c10, 4 352 mcr p15, 0, r3, c7, c10, 4
349 mov r1, #0xF @ 16 segments 353 mov r1, #0xF @ 16 segments
@@ -367,6 +371,7 @@ ENTRY(cpu_arm1020e_switch_mm)
367 mcr p15, 0, r1, c7, c10, 4 @ drain WB 371 mcr p15, 0, r1, c7, c10, 4 @ drain WB
368 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 372 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
369 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs 373 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
374#endif
370 mov pc, lr 375 mov pc, lr
371 376
372/* 377/*
@@ -376,6 +381,7 @@ ENTRY(cpu_arm1020e_switch_mm)
376 */ 381 */
377 .align 5 382 .align 5
378ENTRY(cpu_arm1020e_set_pte) 383ENTRY(cpu_arm1020e_set_pte)
384#ifdef CONFIG_MMU
379 str r1, [r0], #-2048 @ linux version 385 str r1, [r0], #-2048 @ linux version
380 386
381 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 387 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -403,6 +409,7 @@ ENTRY(cpu_arm1020e_set_pte)
403#ifndef CONFIG_CPU_DCACHE_DISABLE 409#ifndef CONFIG_CPU_DCACHE_DISABLE
404 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 410 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
405#endif 411#endif
412#endif /* CONFIG_MMU */
406 mov pc, lr 413 mov pc, lr
407 414
408 __INIT 415 __INIT
@@ -412,7 +419,9 @@ __arm1020e_setup:
412 mov r0, #0 419 mov r0, #0
413 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 420 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
414 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 421 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
422#ifdef CONFIG_MMU
415 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 423 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
424#endif
416 mrc p15, 0, r0, c1, c0 @ get control register v4 425 mrc p15, 0, r0, c1, c0 @ get control register v4
417 ldr r5, arm1020e_cr1_clear 426 ldr r5, arm1020e_cr1_clear
418 bic r0, r0, r5 427 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index f778545d57a2..b0ccff4fadd2 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2000 ARM Limited 4 * Copyright (C) 2000 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -90,7 +91,9 @@ ENTRY(cpu_arm1022_reset)
90 mov ip, #0 91 mov ip, #0
91 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 92 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
92 mcr p15, 0, ip, c7, c10, 4 @ drain WB 93 mcr p15, 0, ip, c7, c10, 4 @ drain WB
94#ifdef CONFIG_MMU
93 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 95 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
96#endif
94 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 97 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
95 bic ip, ip, #0x000f @ ............wcam 98 bic ip, ip, #0x000f @ ............wcam
96 bic ip, ip, #0x1100 @ ...i...s........ 99 bic ip, ip, #0x1100 @ ...i...s........
@@ -333,6 +336,7 @@ ENTRY(cpu_arm1022_dcache_clean_area)
333 */ 336 */
334 .align 5 337 .align 5
335ENTRY(cpu_arm1022_switch_mm) 338ENTRY(cpu_arm1022_switch_mm)
339#ifdef CONFIG_MMU
336#ifndef CONFIG_CPU_DCACHE_DISABLE 340#ifndef CONFIG_CPU_DCACHE_DISABLE
337 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments 341 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
3381: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries 3421: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
@@ -349,6 +353,7 @@ ENTRY(cpu_arm1022_switch_mm)
349 mcr p15, 0, r1, c7, c10, 4 @ drain WB 353 mcr p15, 0, r1, c7, c10, 4 @ drain WB
350 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 354 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
351 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs 355 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
356#endif
352 mov pc, lr 357 mov pc, lr
353 358
354/* 359/*
@@ -358,6 +363,7 @@ ENTRY(cpu_arm1022_switch_mm)
358 */ 363 */
359 .align 5 364 .align 5
360ENTRY(cpu_arm1022_set_pte) 365ENTRY(cpu_arm1022_set_pte)
366#ifdef CONFIG_MMU
361 str r1, [r0], #-2048 @ linux version 367 str r1, [r0], #-2048 @ linux version
362 368
363 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 369 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -385,6 +391,7 @@ ENTRY(cpu_arm1022_set_pte)
385#ifndef CONFIG_CPU_DCACHE_DISABLE 391#ifndef CONFIG_CPU_DCACHE_DISABLE
386 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 392 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
387#endif 393#endif
394#endif /* CONFIG_MMU */
388 mov pc, lr 395 mov pc, lr
389 396
390 __INIT 397 __INIT
@@ -394,7 +401,9 @@ __arm1022_setup:
394 mov r0, #0 401 mov r0, #0
395 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 402 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
396 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 403 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
404#ifdef CONFIG_MMU
397 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 405 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
406#endif
398 mrc p15, 0, r0, c1, c0 @ get control register v4 407 mrc p15, 0, r0, c1, c0 @ get control register v4
399 ldr r5, arm1022_cr1_clear 408 ldr r5, arm1022_cr1_clear
400 bic r0, r0, r5 409 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index 148c111fde73..abe850c9a641 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2000 ARM Limited 4 * Copyright (C) 2000 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -90,7 +91,9 @@ ENTRY(cpu_arm1026_reset)
90 mov ip, #0 91 mov ip, #0
91 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 92 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
92 mcr p15, 0, ip, c7, c10, 4 @ drain WB 93 mcr p15, 0, ip, c7, c10, 4 @ drain WB
94#ifdef CONFIG_MMU
93 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 95 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
96#endif
94 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 97 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
95 bic ip, ip, #0x000f @ ............wcam 98 bic ip, ip, #0x000f @ ............wcam
96 bic ip, ip, #0x1100 @ ...i...s........ 99 bic ip, ip, #0x1100 @ ...i...s........
@@ -327,6 +330,7 @@ ENTRY(cpu_arm1026_dcache_clean_area)
327 */ 330 */
328 .align 5 331 .align 5
329ENTRY(cpu_arm1026_switch_mm) 332ENTRY(cpu_arm1026_switch_mm)
333#ifdef CONFIG_MMU
330 mov r1, #0 334 mov r1, #0
331#ifndef CONFIG_CPU_DCACHE_DISABLE 335#ifndef CONFIG_CPU_DCACHE_DISABLE
3321: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate 3361: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
@@ -338,6 +342,7 @@ ENTRY(cpu_arm1026_switch_mm)
338 mcr p15, 0, r1, c7, c10, 4 @ drain WB 342 mcr p15, 0, r1, c7, c10, 4 @ drain WB
339 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 343 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
340 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs 344 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
345#endif
341 mov pc, lr 346 mov pc, lr
342 347
343/* 348/*
@@ -347,6 +352,7 @@ ENTRY(cpu_arm1026_switch_mm)
347 */ 352 */
348 .align 5 353 .align 5
349ENTRY(cpu_arm1026_set_pte) 354ENTRY(cpu_arm1026_set_pte)
355#ifdef CONFIG_MMU
350 str r1, [r0], #-2048 @ linux version 356 str r1, [r0], #-2048 @ linux version
351 357
352 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 358 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -374,6 +380,7 @@ ENTRY(cpu_arm1026_set_pte)
374#ifndef CONFIG_CPU_DCACHE_DISABLE 380#ifndef CONFIG_CPU_DCACHE_DISABLE
375 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 381 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
376#endif 382#endif
383#endif /* CONFIG_MMU */
377 mov pc, lr 384 mov pc, lr
378 385
379 386
@@ -384,8 +391,10 @@ __arm1026_setup:
384 mov r0, #0 391 mov r0, #0
385 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 392 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
386 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 393 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
394#ifdef CONFIG_MMU
387 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 395 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
388 mcr p15, 0, r4, c2, c0 @ load page table pointer 396 mcr p15, 0, r4, c2, c0 @ load page table pointer
397#endif
389#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 398#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
390 mov r0, #4 @ explicitly disable writeback 399 mov r0, #4 @ explicitly disable writeback
391 mcr p15, 7, r0, c15, c0, 0 400 mcr p15, 7, r0, c15, c0, 0
diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
index 540359b475d0..7a705edfa4b2 100644
--- a/arch/arm/mm/proc-arm6_7.S
+++ b/arch/arm/mm/proc-arm6_7.S
@@ -2,6 +2,7 @@
2 * linux/arch/arm/mm/proc-arm6,7.S 2 * linux/arch/arm/mm/proc-arm6,7.S
3 * 3 *
4 * Copyright (C) 1997-2000 Russell King 4 * Copyright (C) 1997-2000 Russell King
5 * hacked for non-paged-MM by Hyok S. Choi, 2003.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License version 2 as
@@ -199,10 +200,12 @@ ENTRY(cpu_arm7_do_idle)
199 */ 200 */
200ENTRY(cpu_arm6_switch_mm) 201ENTRY(cpu_arm6_switch_mm)
201ENTRY(cpu_arm7_switch_mm) 202ENTRY(cpu_arm7_switch_mm)
203#ifdef CONFIG_MMU
202 mov r1, #0 204 mov r1, #0
203 mcr p15, 0, r1, c7, c0, 0 @ flush cache 205 mcr p15, 0, r1, c7, c0, 0 @ flush cache
204 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr 206 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
205 mcr p15, 0, r1, c5, c0, 0 @ flush TLBs 207 mcr p15, 0, r1, c5, c0, 0 @ flush TLBs
208#endif
206 mov pc, lr 209 mov pc, lr
207 210
208/* 211/*
@@ -214,6 +217,7 @@ ENTRY(cpu_arm7_switch_mm)
214 .align 5 217 .align 5
215ENTRY(cpu_arm6_set_pte) 218ENTRY(cpu_arm6_set_pte)
216ENTRY(cpu_arm7_set_pte) 219ENTRY(cpu_arm7_set_pte)
220#ifdef CONFIG_MMU
217 str r1, [r0], #-2048 @ linux version 221 str r1, [r0], #-2048 @ linux version
218 222
219 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 223 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -232,6 +236,7 @@ ENTRY(cpu_arm7_set_pte)
232 movne r2, #0 236 movne r2, #0
233 237
234 str r2, [r0] @ hardware version 238 str r2, [r0] @ hardware version
239#endif /* CONFIG_MMU */
235 mov pc, lr 240 mov pc, lr
236 241
237/* 242/*
@@ -243,7 +248,9 @@ ENTRY(cpu_arm6_reset)
243ENTRY(cpu_arm7_reset) 248ENTRY(cpu_arm7_reset)
244 mov r1, #0 249 mov r1, #0
245 mcr p15, 0, r1, c7, c0, 0 @ flush cache 250 mcr p15, 0, r1, c7, c0, 0 @ flush cache
251#ifdef CONFIG_MMU
246 mcr p15, 0, r1, c5, c0, 0 @ flush TLB 252 mcr p15, 0, r1, c5, c0, 0 @ flush TLB
253#endif
247 mov r1, #0x30 254 mov r1, #0x30
248 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc 255 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
249 mov pc, r0 256 mov pc, r0
@@ -253,19 +260,27 @@ ENTRY(cpu_arm7_reset)
253 .type __arm6_setup, #function 260 .type __arm6_setup, #function
254__arm6_setup: mov r0, #0 261__arm6_setup: mov r0, #0
255 mcr p15, 0, r0, c7, c0 @ flush caches on v3 262 mcr p15, 0, r0, c7, c0 @ flush caches on v3
263#ifdef CONFIG_MMU
256 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3 264 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
257 mov r0, #0x3d @ . ..RS BLDP WCAM 265 mov r0, #0x3d @ . ..RS BLDP WCAM
258 orr r0, r0, #0x100 @ . ..01 0011 1101 266 orr r0, r0, #0x100 @ . ..01 0011 1101
267#else
268 mov r0, #0x3c @ . ..RS BLDP WCA.
269#endif
259 mov pc, lr 270 mov pc, lr
260 .size __arm6_setup, . - __arm6_setup 271 .size __arm6_setup, . - __arm6_setup
261 272
262 .type __arm7_setup, #function 273 .type __arm7_setup, #function
263__arm7_setup: mov r0, #0 274__arm7_setup: mov r0, #0
264 mcr p15, 0, r0, c7, c0 @ flush caches on v3 275 mcr p15, 0, r0, c7, c0 @ flush caches on v3
276#ifdef CONFIG_MMU
265 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3 277 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
266 mcr p15, 0, r0, c3, c0 @ load domain access register 278 mcr p15, 0, r0, c3, c0 @ load domain access register
267 mov r0, #0x7d @ . ..RS BLDP WCAM 279 mov r0, #0x7d @ . ..RS BLDP WCAM
268 orr r0, r0, #0x100 @ . ..01 0111 1101 280 orr r0, r0, #0x100 @ . ..01 0111 1101
281#else
282 mov r0, #0x7c @ . ..RS BLDP WCA.
283#endif
269 mov pc, lr 284 mov pc, lr
270 .size __arm7_setup, . - __arm7_setup 285 .size __arm7_setup, . - __arm7_setup
271 286
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index 26f00ee2ad9a..86102467d37f 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -4,6 +4,7 @@
4 * Copyright (C) 2000 Steve Hill (sjhill@cotw.com) 4 * Copyright (C) 2000 Steve Hill (sjhill@cotw.com)
5 * Rob Scott (rscott@mtrob.fdns.net) 5 * Rob Scott (rscott@mtrob.fdns.net)
6 * Copyright (C) 2000 ARM Limited, Deep Blue Solutions Ltd. 6 * Copyright (C) 2000 ARM Limited, Deep Blue Solutions Ltd.
7 * hacked for non-paged-MM by Hyok S. Choi, 2004.
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -29,6 +30,7 @@
29 * out of 'proc-arm6,7.S' per RMK discussion 30 * out of 'proc-arm6,7.S' per RMK discussion
30 * 07-25-2000 SJH Added idle function. 31 * 07-25-2000 SJH Added idle function.
31 * 08-25-2000 DBS Updated for integration of ARM Ltd version. 32 * 08-25-2000 DBS Updated for integration of ARM Ltd version.
33 * 04-20-2004 HSC modified for non-paged memory management mode.
32 */ 34 */
33#include <linux/linkage.h> 35#include <linux/linkage.h>
34#include <linux/init.h> 36#include <linux/init.h>
@@ -75,10 +77,12 @@ ENTRY(cpu_arm720_do_idle)
75 * the new. 77 * the new.
76 */ 78 */
77ENTRY(cpu_arm720_switch_mm) 79ENTRY(cpu_arm720_switch_mm)
80#ifdef CONFIG_MMU
78 mov r1, #0 81 mov r1, #0
79 mcr p15, 0, r1, c7, c7, 0 @ invalidate cache 82 mcr p15, 0, r1, c7, c7, 0 @ invalidate cache
80 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr 83 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
81 mcr p15, 0, r1, c8, c7, 0 @ flush TLB (v4) 84 mcr p15, 0, r1, c8, c7, 0 @ flush TLB (v4)
85#endif
82 mov pc, lr 86 mov pc, lr
83 87
84/* 88/*
@@ -89,6 +93,7 @@ ENTRY(cpu_arm720_switch_mm)
89 */ 93 */
90 .align 5 94 .align 5
91ENTRY(cpu_arm720_set_pte) 95ENTRY(cpu_arm720_set_pte)
96#ifdef CONFIG_MMU
92 str r1, [r0], #-2048 @ linux version 97 str r1, [r0], #-2048 @ linux version
93 98
94 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 99 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -107,6 +112,7 @@ ENTRY(cpu_arm720_set_pte)
107 movne r2, #0 112 movne r2, #0
108 113
109 str r2, [r0] @ hardware version 114 str r2, [r0] @ hardware version
115#endif
110 mov pc, lr 116 mov pc, lr
111 117
112/* 118/*
@@ -117,7 +123,9 @@ ENTRY(cpu_arm720_set_pte)
117ENTRY(cpu_arm720_reset) 123ENTRY(cpu_arm720_reset)
118 mov ip, #0 124 mov ip, #0
119 mcr p15, 0, ip, c7, c7, 0 @ invalidate cache 125 mcr p15, 0, ip, c7, c7, 0 @ invalidate cache
126#ifdef CONFIG_MMU
120 mcr p15, 0, ip, c8, c7, 0 @ flush TLB (v4) 127 mcr p15, 0, ip, c8, c7, 0 @ flush TLB (v4)
128#endif
121 mrc p15, 0, ip, c1, c0, 0 @ get ctrl register 129 mrc p15, 0, ip, c1, c0, 0 @ get ctrl register
122 bic ip, ip, #0x000f @ ............wcam 130 bic ip, ip, #0x000f @ ............wcam
123 bic ip, ip, #0x2100 @ ..v....s........ 131 bic ip, ip, #0x2100 @ ..v....s........
@@ -130,7 +138,9 @@ ENTRY(cpu_arm720_reset)
130__arm710_setup: 138__arm710_setup:
131 mov r0, #0 139 mov r0, #0
132 mcr p15, 0, r0, c7, c7, 0 @ invalidate caches 140 mcr p15, 0, r0, c7, c7, 0 @ invalidate caches
141#ifdef CONFIG_MMU
133 mcr p15, 0, r0, c8, c7, 0 @ flush TLB (v4) 142 mcr p15, 0, r0, c8, c7, 0 @ flush TLB (v4)
143#endif
134 mrc p15, 0, r0, c1, c0 @ get control register 144 mrc p15, 0, r0, c1, c0 @ get control register
135 ldr r5, arm710_cr1_clear 145 ldr r5, arm710_cr1_clear
136 bic r0, r0, r5 146 bic r0, r0, r5
@@ -156,7 +166,9 @@ arm710_cr1_set:
156__arm720_setup: 166__arm720_setup:
157 mov r0, #0 167 mov r0, #0
158 mcr p15, 0, r0, c7, c7, 0 @ invalidate caches 168 mcr p15, 0, r0, c7, c7, 0 @ invalidate caches
169#ifdef CONFIG_MMU
159 mcr p15, 0, r0, c8, c7, 0 @ flush TLB (v4) 170 mcr p15, 0, r0, c8, c7, 0 @ flush TLB (v4)
171#endif
160 mrc p15, 0, r0, c1, c0 @ get control register 172 mrc p15, 0, r0, c1, c0 @ get control register
161 ldr r5, arm720_cr1_clear 173 ldr r5, arm720_cr1_clear
162 bic r0, r0, r5 174 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index a17f79e0199c..31dc839ba07c 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 1999,2000 ARM Limited 4 * Copyright (C) 1999,2000 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -97,7 +98,9 @@ ENTRY(cpu_arm920_reset)
97 mov ip, #0 98 mov ip, #0
98 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 99 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
99 mcr p15, 0, ip, c7, c10, 4 @ drain WB 100 mcr p15, 0, ip, c7, c10, 4 @ drain WB
101#ifdef CONFIG_MMU
100 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 102 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
103#endif
101 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 104 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
102 bic ip, ip, #0x000f @ ............wcam 105 bic ip, ip, #0x000f @ ............wcam
103 bic ip, ip, #0x1100 @ ...i...s........ 106 bic ip, ip, #0x1100 @ ...i...s........
@@ -317,6 +320,7 @@ ENTRY(cpu_arm920_dcache_clean_area)
317 */ 320 */
318 .align 5 321 .align 5
319ENTRY(cpu_arm920_switch_mm) 322ENTRY(cpu_arm920_switch_mm)
323#ifdef CONFIG_MMU
320 mov ip, #0 324 mov ip, #0
321#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 325#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
322 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache 326 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
@@ -337,6 +341,7 @@ ENTRY(cpu_arm920_switch_mm)
337 mcr p15, 0, ip, c7, c10, 4 @ drain WB 341 mcr p15, 0, ip, c7, c10, 4 @ drain WB
338 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 342 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
339 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 343 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
344#endif
340 mov pc, lr 345 mov pc, lr
341 346
342/* 347/*
@@ -346,6 +351,7 @@ ENTRY(cpu_arm920_switch_mm)
346 */ 351 */
347 .align 5 352 .align 5
348ENTRY(cpu_arm920_set_pte) 353ENTRY(cpu_arm920_set_pte)
354#ifdef CONFIG_MMU
349 str r1, [r0], #-2048 @ linux version 355 str r1, [r0], #-2048 @ linux version
350 356
351 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 357 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -372,6 +378,7 @@ ENTRY(cpu_arm920_set_pte)
372 mov r0, r0 378 mov r0, r0
373 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 379 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
374 mcr p15, 0, r0, c7, c10, 4 @ drain WB 380 mcr p15, 0, r0, c7, c10, 4 @ drain WB
381#endif /* CONFIG_MMU */
375 mov pc, lr 382 mov pc, lr
376 383
377 __INIT 384 __INIT
@@ -381,7 +388,9 @@ __arm920_setup:
381 mov r0, #0 388 mov r0, #0
382 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 389 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
383 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 390 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
391#ifdef CONFIG_MMU
384 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 392 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
393#endif
385 mrc p15, 0, r0, c1, c0 @ get control register v4 394 mrc p15, 0, r0, c1, c0 @ get control register v4
386 ldr r5, arm920_cr1_clear 395 ldr r5, arm920_cr1_clear
387 bic r0, r0, r5 396 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index bbde4a024a48..9e57c34f5c09 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -4,6 +4,7 @@
4 * Copyright (C) 1999,2000 ARM Limited 4 * Copyright (C) 1999,2000 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * Copyright (C) 2001 Altera Corporation 6 * Copyright (C) 2001 Altera Corporation
7 * hacked for non-paged-MM by Hyok S. Choi, 2003.
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -99,7 +100,9 @@ ENTRY(cpu_arm922_reset)
99 mov ip, #0 100 mov ip, #0
100 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 101 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
101 mcr p15, 0, ip, c7, c10, 4 @ drain WB 102 mcr p15, 0, ip, c7, c10, 4 @ drain WB
103#ifdef CONFIG_MMU
102 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 104 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
105#endif
103 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 106 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
104 bic ip, ip, #0x000f @ ............wcam 107 bic ip, ip, #0x000f @ ............wcam
105 bic ip, ip, #0x1100 @ ...i...s........ 108 bic ip, ip, #0x1100 @ ...i...s........
@@ -321,6 +324,7 @@ ENTRY(cpu_arm922_dcache_clean_area)
321 */ 324 */
322 .align 5 325 .align 5
323ENTRY(cpu_arm922_switch_mm) 326ENTRY(cpu_arm922_switch_mm)
327#ifdef CONFIG_MMU
324 mov ip, #0 328 mov ip, #0
325#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 329#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
326 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache 330 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
@@ -341,6 +345,7 @@ ENTRY(cpu_arm922_switch_mm)
341 mcr p15, 0, ip, c7, c10, 4 @ drain WB 345 mcr p15, 0, ip, c7, c10, 4 @ drain WB
342 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 346 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
343 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 347 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
348#endif
344 mov pc, lr 349 mov pc, lr
345 350
346/* 351/*
@@ -350,6 +355,7 @@ ENTRY(cpu_arm922_switch_mm)
350 */ 355 */
351 .align 5 356 .align 5
352ENTRY(cpu_arm922_set_pte) 357ENTRY(cpu_arm922_set_pte)
358#ifdef CONFIG_MMU
353 str r1, [r0], #-2048 @ linux version 359 str r1, [r0], #-2048 @ linux version
354 360
355 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 361 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -376,6 +382,7 @@ ENTRY(cpu_arm922_set_pte)
376 mov r0, r0 382 mov r0, r0
377 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 383 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
378 mcr p15, 0, r0, c7, c10, 4 @ drain WB 384 mcr p15, 0, r0, c7, c10, 4 @ drain WB
385#endif /* CONFIG_MMU */
379 mov pc, lr 386 mov pc, lr
380 387
381 __INIT 388 __INIT
@@ -385,7 +392,9 @@ __arm922_setup:
385 mov r0, #0 392 mov r0, #0
386 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 393 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
387 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 394 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
395#ifdef CONFIG_MMU
388 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 396 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
397#endif
389 mrc p15, 0, r0, c1, c0 @ get control register v4 398 mrc p15, 0, r0, c1, c0 @ get control register v4
390 ldr r5, arm922_cr1_clear 399 ldr r5, arm922_cr1_clear
391 bic r0, r0, r5 400 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index 224ce226a01b..8d47c9f3f931 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -9,6 +9,8 @@
9 * Update for Linux-2.6 and cache flush improvements 9 * Update for Linux-2.6 and cache flush improvements
10 * Copyright (C) 2004 Nokia Corporation by Tony Lindgren <tony@atomide.com> 10 * Copyright (C) 2004 Nokia Corporation by Tony Lindgren <tony@atomide.com>
11 * 11 *
12 * hacked for non-paged-MM by Hyok S. Choi, 2004.
13 *
12 * This program is free software; you can redistribute it and/or modify 14 * 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 15 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 16 * the Free Software Foundation; either version 2 of the License, or
@@ -122,7 +124,9 @@ ENTRY(cpu_arm925_reset)
122 mov ip, #0 124 mov ip, #0
123 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 125 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
124 mcr p15, 0, ip, c7, c10, 4 @ drain WB 126 mcr p15, 0, ip, c7, c10, 4 @ drain WB
127#ifdef CONFIG_MMU
125 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 128 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
129#endif
126 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 130 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
127 bic ip, ip, #0x000f @ ............wcam 131 bic ip, ip, #0x000f @ ............wcam
128 bic ip, ip, #0x1100 @ ...i...s........ 132 bic ip, ip, #0x1100 @ ...i...s........
@@ -369,6 +373,7 @@ ENTRY(cpu_arm925_dcache_clean_area)
369 */ 373 */
370 .align 5 374 .align 5
371ENTRY(cpu_arm925_switch_mm) 375ENTRY(cpu_arm925_switch_mm)
376#ifdef CONFIG_MMU
372 mov ip, #0 377 mov ip, #0
373#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 378#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
374 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache 379 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
@@ -383,6 +388,7 @@ ENTRY(cpu_arm925_switch_mm)
383 mcr p15, 0, ip, c7, c10, 4 @ drain WB 388 mcr p15, 0, ip, c7, c10, 4 @ drain WB
384 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 389 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
385 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 390 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
391#endif
386 mov pc, lr 392 mov pc, lr
387 393
388/* 394/*
@@ -392,6 +398,7 @@ ENTRY(cpu_arm925_switch_mm)
392 */ 398 */
393 .align 5 399 .align 5
394ENTRY(cpu_arm925_set_pte) 400ENTRY(cpu_arm925_set_pte)
401#ifdef CONFIG_MMU
395 str r1, [r0], #-2048 @ linux version 402 str r1, [r0], #-2048 @ linux version
396 403
397 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 404 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -420,6 +427,7 @@ ENTRY(cpu_arm925_set_pte)
420 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 427 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
421#endif 428#endif
422 mcr p15, 0, r0, c7, c10, 4 @ drain WB 429 mcr p15, 0, r0, c7, c10, 4 @ drain WB
430#endif /* CONFIG_MMU */
423 mov pc, lr 431 mov pc, lr
424 432
425 __INIT 433 __INIT
@@ -438,7 +446,9 @@ __arm925_setup:
438 mov r0, #0 446 mov r0, #0
439 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 447 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
440 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 448 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
449#ifdef CONFIG_MMU
441 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 450 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
451#endif
442 452
443#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 453#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
444 mov r0, #4 @ disable write-back on caches explicitly 454 mov r0, #4 @ disable write-back on caches explicitly
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 4e2a087cf388..cb4d8f33d2a3 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 1999-2001 ARM Limited 4 * Copyright (C) 1999-2001 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd. 5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -85,7 +86,9 @@ ENTRY(cpu_arm926_reset)
85 mov ip, #0 86 mov ip, #0
86 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 87 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
87 mcr p15, 0, ip, c7, c10, 4 @ drain WB 88 mcr p15, 0, ip, c7, c10, 4 @ drain WB
89#ifdef CONFIG_MMU
88 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 90 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
91#endif
89 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 92 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
90 bic ip, ip, #0x000f @ ............wcam 93 bic ip, ip, #0x000f @ ............wcam
91 bic ip, ip, #0x1100 @ ...i...s........ 94 bic ip, ip, #0x1100 @ ...i...s........
@@ -329,6 +332,7 @@ ENTRY(cpu_arm926_dcache_clean_area)
329 */ 332 */
330 .align 5 333 .align 5
331ENTRY(cpu_arm926_switch_mm) 334ENTRY(cpu_arm926_switch_mm)
335#ifdef CONFIG_MMU
332 mov ip, #0 336 mov ip, #0
333#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 337#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
334 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache 338 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
@@ -341,6 +345,7 @@ ENTRY(cpu_arm926_switch_mm)
341 mcr p15, 0, ip, c7, c10, 4 @ drain WB 345 mcr p15, 0, ip, c7, c10, 4 @ drain WB
342 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 346 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
343 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 347 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
348#endif
344 mov pc, lr 349 mov pc, lr
345 350
346/* 351/*
@@ -350,6 +355,7 @@ ENTRY(cpu_arm926_switch_mm)
350 */ 355 */
351 .align 5 356 .align 5
352ENTRY(cpu_arm926_set_pte) 357ENTRY(cpu_arm926_set_pte)
358#ifdef CONFIG_MMU
353 str r1, [r0], #-2048 @ linux version 359 str r1, [r0], #-2048 @ linux version
354 360
355 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 361 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -378,6 +384,7 @@ ENTRY(cpu_arm926_set_pte)
378 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 384 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
379#endif 385#endif
380 mcr p15, 0, r0, c7, c10, 4 @ drain WB 386 mcr p15, 0, r0, c7, c10, 4 @ drain WB
387#endif
381 mov pc, lr 388 mov pc, lr
382 389
383 __INIT 390 __INIT
@@ -387,7 +394,9 @@ __arm926_setup:
387 mov r0, #0 394 mov r0, #0
388 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 395 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
389 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 396 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
397#ifdef CONFIG_MMU
390 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 398 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
399#endif
391 400
392 401
393#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 402#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index a2dd5ae1077d..5a760a2c629c 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -2,6 +2,7 @@
2 * linux/arch/arm/mm/proc-sa110.S 2 * linux/arch/arm/mm/proc-sa110.S
3 * 3 *
4 * Copyright (C) 1997-2002 Russell King 4 * Copyright (C) 1997-2002 Russell King
5 * hacked for non-paged-MM by Hyok S. Choi, 2003.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License version 2 as
@@ -67,7 +68,9 @@ ENTRY(cpu_sa110_reset)
67 mov ip, #0 68 mov ip, #0
68 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 69 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
69 mcr p15, 0, ip, c7, c10, 4 @ drain WB 70 mcr p15, 0, ip, c7, c10, 4 @ drain WB
71#ifdef CONFIG_MMU
70 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 72 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
73#endif
71 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 74 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
72 bic ip, ip, #0x000f @ ............wcam 75 bic ip, ip, #0x000f @ ............wcam
73 bic ip, ip, #0x1100 @ ...i...s........ 76 bic ip, ip, #0x1100 @ ...i...s........
@@ -130,11 +133,15 @@ ENTRY(cpu_sa110_dcache_clean_area)
130 */ 133 */
131 .align 5 134 .align 5
132ENTRY(cpu_sa110_switch_mm) 135ENTRY(cpu_sa110_switch_mm)
136#ifdef CONFIG_MMU
133 str lr, [sp, #-4]! 137 str lr, [sp, #-4]!
134 bl v4wb_flush_kern_cache_all @ clears IP 138 bl v4wb_flush_kern_cache_all @ clears IP
135 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 139 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
136 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 140 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
137 ldr pc, [sp], #4 141 ldr pc, [sp], #4
142#else
143 mov pc, lr
144#endif
138 145
139/* 146/*
140 * cpu_sa110_set_pte(ptep, pte) 147 * cpu_sa110_set_pte(ptep, pte)
@@ -143,6 +150,7 @@ ENTRY(cpu_sa110_switch_mm)
143 */ 150 */
144 .align 5 151 .align 5
145ENTRY(cpu_sa110_set_pte) 152ENTRY(cpu_sa110_set_pte)
153#ifdef CONFIG_MMU
146 str r1, [r0], #-2048 @ linux version 154 str r1, [r0], #-2048 @ linux version
147 155
148 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 156 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -164,6 +172,7 @@ ENTRY(cpu_sa110_set_pte)
164 mov r0, r0 172 mov r0, r0
165 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 173 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
166 mcr p15, 0, r0, c7, c10, 4 @ drain WB 174 mcr p15, 0, r0, c7, c10, 4 @ drain WB
175#endif
167 mov pc, lr 176 mov pc, lr
168 177
169 __INIT 178 __INIT
@@ -173,7 +182,9 @@ __sa110_setup:
173 mov r10, #0 182 mov r10, #0
174 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4 183 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
175 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4 184 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
185#ifdef CONFIG_MMU
176 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4 186 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
187#endif
177 mrc p15, 0, r0, c1, c0 @ get control register v4 188 mrc p15, 0, r0, c1, c0 @ get control register v4
178 ldr r5, sa110_cr1_clear 189 ldr r5, sa110_cr1_clear
179 bic r0, r0, r5 190 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index 777ad99c1439..0a2107ad4c32 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -2,6 +2,7 @@
2 * linux/arch/arm/mm/proc-sa1100.S 2 * linux/arch/arm/mm/proc-sa1100.S
3 * 3 *
4 * Copyright (C) 1997-2002 Russell King 4 * Copyright (C) 1997-2002 Russell King
5 * hacked for non-paged-MM by Hyok S. Choi, 2003.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License version 2 as
@@ -77,7 +78,9 @@ ENTRY(cpu_sa1100_reset)
77 mov ip, #0 78 mov ip, #0
78 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches 79 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
79 mcr p15, 0, ip, c7, c10, 4 @ drain WB 80 mcr p15, 0, ip, c7, c10, 4 @ drain WB
81#ifdef CONFIG_MMU
80 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 82 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
83#endif
81 mrc p15, 0, ip, c1, c0, 0 @ ctrl register 84 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
82 bic ip, ip, #0x000f @ ............wcam 85 bic ip, ip, #0x000f @ ............wcam
83 bic ip, ip, #0x1100 @ ...i...s........ 86 bic ip, ip, #0x1100 @ ...i...s........
@@ -142,12 +145,16 @@ ENTRY(cpu_sa1100_dcache_clean_area)
142 */ 145 */
143 .align 5 146 .align 5
144ENTRY(cpu_sa1100_switch_mm) 147ENTRY(cpu_sa1100_switch_mm)
148#ifdef CONFIG_MMU
145 str lr, [sp, #-4]! 149 str lr, [sp, #-4]!
146 bl v4wb_flush_kern_cache_all @ clears IP 150 bl v4wb_flush_kern_cache_all @ clears IP
147 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB 151 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
148 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 152 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
149 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 153 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
150 ldr pc, [sp], #4 154 ldr pc, [sp], #4
155#else
156 mov pc, lr
157#endif
151 158
152/* 159/*
153 * cpu_sa1100_set_pte(ptep, pte) 160 * cpu_sa1100_set_pte(ptep, pte)
@@ -156,6 +163,7 @@ ENTRY(cpu_sa1100_switch_mm)
156 */ 163 */
157 .align 5 164 .align 5
158ENTRY(cpu_sa1100_set_pte) 165ENTRY(cpu_sa1100_set_pte)
166#ifdef CONFIG_MMU
159 str r1, [r0], #-2048 @ linux version 167 str r1, [r0], #-2048 @ linux version
160 168
161 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 169 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -177,6 +185,7 @@ ENTRY(cpu_sa1100_set_pte)
177 mov r0, r0 185 mov r0, r0
178 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 186 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
179 mcr p15, 0, r0, c7, c10, 4 @ drain WB 187 mcr p15, 0, r0, c7, c10, 4 @ drain WB
188#endif
180 mov pc, lr 189 mov pc, lr
181 190
182 __INIT 191 __INIT
@@ -186,7 +195,9 @@ __sa1100_setup:
186 mov r0, #0 195 mov r0, #0
187 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 196 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
188 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 197 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
198#ifdef CONFIG_MMU
189 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 199 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
200#endif
190 mrc p15, 0, r0, c1, c0 @ get control register v4 201 mrc p15, 0, r0, c1, c0 @ get control register v4
191 ldr r5, sa1100_cr1_clear 202 ldr r5, sa1100_cr1_clear
192 bic r0, r0, r5 203 bic r0, r0, r5
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 09b1a41a6de8..ca13d4d05f65 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -2,6 +2,7 @@
2 * linux/arch/arm/mm/proc-v6.S 2 * linux/arch/arm/mm/proc-v6.S
3 * 3 *
4 * Copyright (C) 2001 Deep Blue Solutions Ltd. 4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
5 * Modified by Catalin Marinas for noMMU support
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License version 2 as
@@ -88,6 +89,7 @@ ENTRY(cpu_v6_dcache_clean_area)
88 * - we are not using split page tables 89 * - we are not using split page tables
89 */ 90 */
90ENTRY(cpu_v6_switch_mm) 91ENTRY(cpu_v6_switch_mm)
92#ifdef CONFIG_MMU
91 mov r2, #0 93 mov r2, #0
92 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id 94 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
93#ifdef CONFIG_SMP 95#ifdef CONFIG_SMP
@@ -97,6 +99,7 @@ ENTRY(cpu_v6_switch_mm)
97 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer 99 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
98 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0 100 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
99 mcr p15, 0, r1, c13, c0, 1 @ set context ID 101 mcr p15, 0, r1, c13, c0, 1 @ set context ID
102#endif
100 mov pc, lr 103 mov pc, lr
101 104
102/* 105/*
@@ -119,6 +122,7 @@ ENTRY(cpu_v6_switch_mm)
119 * 1111 0 1 1 r/w r/w 122 * 1111 0 1 1 r/w r/w
120 */ 123 */
121ENTRY(cpu_v6_set_pte) 124ENTRY(cpu_v6_set_pte)
125#ifdef CONFIG_MMU
122 str r1, [r0], #-2048 @ linux version 126 str r1, [r0], #-2048 @ linux version
123 127
124 bic r2, r1, #0x000003f0 128 bic r2, r1, #0x000003f0
@@ -145,6 +149,7 @@ ENTRY(cpu_v6_set_pte)
145 149
146 str r2, [r0] 150 str r2, [r0]
147 mcr p15, 0, r0, c7, c10, 1 @ flush_pte 151 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
152#endif
148 mov pc, lr 153 mov pc, lr
149 154
150 155
@@ -194,12 +199,14 @@ __v6_setup:
194 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache 199 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
195 mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache 200 mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
196 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer 201 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
202#ifdef CONFIG_MMU
197 mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs 203 mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
198 mcr p15, 0, r0, c2, c0, 2 @ TTB control register 204 mcr p15, 0, r0, c2, c0, 2 @ TTB control register
199#ifdef CONFIG_SMP 205#ifdef CONFIG_SMP
200 orr r4, r4, #TTB_RGN_WBWA|TTB_S @ mark PTWs shared, outer cacheable 206 orr r4, r4, #TTB_RGN_WBWA|TTB_S @ mark PTWs shared, outer cacheable
201#endif 207#endif
202 mcr p15, 0, r4, c2, c0, 1 @ load TTB1 208 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
209#endif /* CONFIG_MMU */
203#ifdef CONFIG_VFP 210#ifdef CONFIG_VFP
204 mrc p15, 0, r0, c1, c0, 2 211 mrc p15, 0, r0, c1, c0, 2
205 orr r0, r0, #(0xf << 20) 212 orr r0, r0, #(0xf << 20)
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 856b665020e7..6a1238a29d6c 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -28,6 +28,10 @@ config GENERIC_CALIBRATE_DELAY
28 bool 28 bool
29 default y 29 default y
30 30
31config IRQ_PER_CPU
32 bool
33 default y
34
31config CRIS 35config CRIS
32 bool 36 bool
33 default y 37 default y
diff --git a/arch/cris/arch-v10/kernel/debugport.c b/arch/cris/arch-v10/kernel/debugport.c
index f3a85b77c17e..dde813e16294 100644
--- a/arch/cris/arch-v10/kernel/debugport.c
+++ b/arch/cris/arch-v10/kernel/debugport.c
@@ -541,7 +541,7 @@ init_dummy_console(void)
541 dummy_driver.init_termios = tty_std_termios; 541 dummy_driver.init_termios = tty_std_termios;
542 dummy_driver.init_termios.c_cflag = 542 dummy_driver.init_termios.c_cflag =
543 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */ 543 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
544 dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 544 dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
545 545
546 dummy_driver.open = dummy_open; 546 dummy_driver.open = dummy_open;
547 dummy_driver.close = dummy_close; 547 dummy_driver.close = dummy_close;
diff --git a/arch/cris/arch-v10/kernel/irq.c b/arch/cris/arch-v10/kernel/irq.c
index 4b368a122015..2d5be93b5197 100644
--- a/arch/cris/arch-v10/kernel/irq.c
+++ b/arch/cris/arch-v10/kernel/irq.c
@@ -172,7 +172,7 @@ init_IRQ(void)
172 172
173 /* Initialize IRQ handler descriptiors. */ 173 /* Initialize IRQ handler descriptiors. */
174 for(i = 2; i < NR_IRQS; i++) { 174 for(i = 2; i < NR_IRQS; i++) {
175 irq_desc[i].handler = &crisv10_irq_type; 175 irq_desc[i].chip = &crisv10_irq_type;
176 set_int_vector(i, interrupt[i]); 176 set_int_vector(i, interrupt[i]);
177 } 177 }
178 178
diff --git a/arch/cris/arch-v32/drivers/pci/bios.c b/arch/cris/arch-v32/drivers/pci/bios.c
index 1e9d062103ae..a2b9c60c2777 100644
--- a/arch/cris/arch-v32/drivers/pci/bios.c
+++ b/arch/cris/arch-v32/drivers/pci/bios.c
@@ -43,10 +43,10 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
43 43
44void 44void
45pcibios_align_resource(void *data, struct resource *res, 45pcibios_align_resource(void *data, struct resource *res,
46 unsigned long size, unsigned long align) 46 resource_size_t size, resource_size_t align)
47{ 47{
48 if (res->flags & IORESOURCE_IO) { 48 if (res->flags & IORESOURCE_IO) {
49 unsigned long start = res->start; 49 resource_size_t start = res->start;
50 50
51 if (start & 0x300) { 51 if (start & 0x300) {
52 start = (start + 0x3ff) & ~0x3ff; 52 start = (start + 0x3ff) & ~0x3ff;
diff --git a/arch/cris/arch-v32/kernel/debugport.c b/arch/cris/arch-v32/kernel/debugport.c
index ffc1ebf2dfee..3dc587e6201a 100644
--- a/arch/cris/arch-v32/kernel/debugport.c
+++ b/arch/cris/arch-v32/kernel/debugport.c
@@ -353,7 +353,7 @@ init_dummy_console(void)
353 dummy_driver.init_termios = tty_std_termios; 353 dummy_driver.init_termios = tty_std_termios;
354 dummy_driver.init_termios.c_cflag = 354 dummy_driver.init_termios.c_cflag =
355 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */ 355 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
356 dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 356 dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
357 357
358 dummy_driver.open = dummy_open; 358 dummy_driver.open = dummy_open;
359 dummy_driver.close = dummy_close; 359 dummy_driver.close = dummy_close;
diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c
index c78cc2685133..06260874f018 100644
--- a/arch/cris/arch-v32/kernel/irq.c
+++ b/arch/cris/arch-v32/kernel/irq.c
@@ -369,7 +369,7 @@ init_IRQ(void)
369 369
370 /* Point all IRQ's to bad handlers. */ 370 /* Point all IRQ's to bad handlers. */
371 for (i = FIRST_IRQ, j = 0; j < NR_IRQS; i++, j++) { 371 for (i = FIRST_IRQ, j = 0; j < NR_IRQS; i++, j++) {
372 irq_desc[j].handler = &crisv32_irq_type; 372 irq_desc[j].chip = &crisv32_irq_type;
373 set_exception_vector(i, interrupt[j]); 373 set_exception_vector(i, interrupt[j]);
374 } 374 }
375 375
diff --git a/arch/cris/kernel/irq.c b/arch/cris/kernel/irq.c
index b504def3e346..6547bb646364 100644
--- a/arch/cris/kernel/irq.c
+++ b/arch/cris/kernel/irq.c
@@ -69,7 +69,7 @@ int show_interrupts(struct seq_file *p, void *v)
69 for_each_online_cpu(j) 69 for_each_online_cpu(j)
70 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 70 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
71#endif 71#endif
72 seq_printf(p, " %14s", irq_desc[i].handler->typename); 72 seq_printf(p, " %14s", irq_desc[i].chip->typename);
73 seq_printf(p, " %s", action->name); 73 seq_printf(p, " %s", action->name);
74 74
75 for (action=action->next; action; action = action->next) 75 for (action=action->next; action; action = action->next)
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index 0a26bf6f1cd4..4f165c93be42 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -64,10 +64,10 @@ pcibios_update_resource(struct pci_dev *dev, struct resource *root,
64 */ 64 */
65void 65void
66pcibios_align_resource(void *data, struct resource *res, 66pcibios_align_resource(void *data, struct resource *res,
67 unsigned long size, unsigned long align) 67 resource_size_t size, resource_size_t align)
68{ 68{
69 if (res->flags & IORESOURCE_IO) { 69 if (res->flags & IORESOURCE_IO) {
70 unsigned long start = res->start; 70 resource_size_t start = res->start;
71 71
72 if (start & 0x300) { 72 if (start & 0x300) {
73 start = (start + 0x3ff) & ~0x3ff; 73 start = (start + 0x3ff) & ~0x3ff;
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 47c08bcd9b24..1718429286d4 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -233,7 +233,7 @@ config NR_CPUS
233 233
234config SCHED_SMT 234config SCHED_SMT
235 bool "SMT (Hyperthreading) scheduler support" 235 bool "SMT (Hyperthreading) scheduler support"
236 depends on SMP 236 depends on X86_HT
237 help 237 help
238 SMT scheduler support improves the CPU scheduler's decision making 238 SMT scheduler support improves the CPU scheduler's decision making
239 when dealing with Intel Pentium 4 chips with HyperThreading at a 239 when dealing with Intel Pentium 4 chips with HyperThreading at a
@@ -242,7 +242,7 @@ config SCHED_SMT
242 242
243config SCHED_MC 243config SCHED_MC
244 bool "Multi-core scheduler support" 244 bool "Multi-core scheduler support"
245 depends on SMP 245 depends on X86_HT
246 default y 246 default y
247 help 247 help
248 Multi-core scheduler support improves the CPU scheduler's decision 248 Multi-core scheduler support improves the CPU scheduler's decision
@@ -529,6 +529,7 @@ config X86_PAE
529 bool 529 bool
530 depends on HIGHMEM64G 530 depends on HIGHMEM64G
531 default y 531 default y
532 select RESOURCES_64BIT
532 533
533# Common NUMA Features 534# Common NUMA Features
534config NUMA 535config NUMA
@@ -737,7 +738,7 @@ config KEXEC
737 but it is independent of the system firmware. And like a reboot 738 but it is independent of the system firmware. And like a reboot
738 you can start any kernel with it, not just Linux. 739 you can start any kernel with it, not just Linux.
739 740
740 The name comes from the similiarity to the exec system call. 741 The name comes from the similarity to the exec system call.
741 742
742 It is an ongoing process to be certain the hardware in a machine 743 It is an ongoing process to be certain the hardware in a machine
743 is properly shutdown, so do not be surprised if this code does not 744 is properly shutdown, so do not be surprised if this code does not
@@ -780,9 +781,23 @@ config HOTPLUG_CPU
780 enable suspend on SMP systems. CPUs can be controlled through 781 enable suspend on SMP systems. CPUs can be controlled through
781 /sys/devices/system/cpu. 782 /sys/devices/system/cpu.
782 783
784config COMPAT_VDSO
785 bool "Compat VDSO support"
786 default y
787 help
788 Map the VDSO to the predictable old-style address too.
789 ---help---
790 Say N here if you are running a sufficiently recent glibc
791 version (2.3.3 or later), to remove the high-mapped
792 VDSO mapping and to exclusively use the randomized VDSO.
793
794 If unsure, say Y.
783 795
784endmenu 796endmenu
785 797
798config ARCH_ENABLE_MEMORY_HOTPLUG
799 def_bool y
800 depends on HIGHMEM
786 801
787menu "Power management options (ACPI, APM)" 802menu "Power management options (ACPI, APM)"
788 depends on !X86_VOYAGER 803 depends on !X86_VOYAGER
diff --git a/arch/i386/kernel/asm-offsets.c b/arch/i386/kernel/asm-offsets.c
index 1c3a809e6421..c80271f8f084 100644
--- a/arch/i386/kernel/asm-offsets.c
+++ b/arch/i386/kernel/asm-offsets.c
@@ -14,6 +14,7 @@
14#include <asm/fixmap.h> 14#include <asm/fixmap.h>
15#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/thread_info.h> 16#include <asm/thread_info.h>
17#include <asm/elf.h>
17 18
18#define DEFINE(sym, val) \ 19#define DEFINE(sym, val) \
19 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 20 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -54,6 +55,7 @@ void foo(void)
54 OFFSET(TI_preempt_count, thread_info, preempt_count); 55 OFFSET(TI_preempt_count, thread_info, preempt_count);
55 OFFSET(TI_addr_limit, thread_info, addr_limit); 56 OFFSET(TI_addr_limit, thread_info, addr_limit);
56 OFFSET(TI_restart_block, thread_info, restart_block); 57 OFFSET(TI_restart_block, thread_info, restart_block);
58 OFFSET(TI_sysenter_return, thread_info, sysenter_return);
57 BLANK(); 59 BLANK();
58 60
59 OFFSET(EXEC_DOMAIN_handler, exec_domain, handler); 61 OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
@@ -69,7 +71,7 @@ void foo(void)
69 sizeof(struct tss_struct)); 71 sizeof(struct tss_struct));
70 72
71 DEFINE(PAGE_SIZE_asm, PAGE_SIZE); 73 DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
72 DEFINE(VSYSCALL_BASE, __fix_to_virt(FIX_VSYSCALL)); 74 DEFINE(VDSO_PRELINK, VDSO_PRELINK);
73 75
74 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); 76 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
75} 77}
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index fd0457c9c827..e6a2d6b80cda 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -235,10 +235,10 @@ static void __init init_amd(struct cpuinfo_x86 *c)
235 while ((1 << bits) < c->x86_max_cores) 235 while ((1 << bits) < c->x86_max_cores)
236 bits++; 236 bits++;
237 } 237 }
238 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1); 238 c->cpu_core_id = c->phys_proc_id & ((1<<bits)-1);
239 phys_proc_id[cpu] >>= bits; 239 c->phys_proc_id >>= bits;
240 printk(KERN_INFO "CPU %d(%d) -> Core %d\n", 240 printk(KERN_INFO "CPU %d(%d) -> Core %d\n",
241 cpu, c->x86_max_cores, cpu_core_id[cpu]); 241 cpu, c->x86_max_cores, c->cpu_core_id);
242 } 242 }
243#endif 243#endif
244 244
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 44f2c5f2dda1..70c87de582c7 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -294,7 +294,7 @@ void __cpuinit generic_identify(struct cpuinfo_x86 * c)
294 if (c->x86 >= 0x6) 294 if (c->x86 >= 0x6)
295 c->x86_model += ((tfms >> 16) & 0xF) << 4; 295 c->x86_model += ((tfms >> 16) & 0xF) << 4;
296 c->x86_mask = tfms & 15; 296 c->x86_mask = tfms & 15;
297#ifdef CONFIG_SMP 297#ifdef CONFIG_X86_HT
298 c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0); 298 c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
299#else 299#else
300 c->apicid = (ebx >> 24) & 0xFF; 300 c->apicid = (ebx >> 24) & 0xFF;
@@ -319,7 +319,7 @@ void __cpuinit generic_identify(struct cpuinfo_x86 * c)
319 early_intel_workaround(c); 319 early_intel_workaround(c);
320 320
321#ifdef CONFIG_X86_HT 321#ifdef CONFIG_X86_HT
322 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff; 322 c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
323#endif 323#endif
324} 324}
325 325
@@ -477,11 +477,9 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
477{ 477{
478 u32 eax, ebx, ecx, edx; 478 u32 eax, ebx, ecx, edx;
479 int index_msb, core_bits; 479 int index_msb, core_bits;
480 int cpu = smp_processor_id();
481 480
482 cpuid(1, &eax, &ebx, &ecx, &edx); 481 cpuid(1, &eax, &ebx, &ecx, &edx);
483 482
484
485 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) 483 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
486 return; 484 return;
487 485
@@ -492,16 +490,17 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
492 } else if (smp_num_siblings > 1 ) { 490 } else if (smp_num_siblings > 1 ) {
493 491
494 if (smp_num_siblings > NR_CPUS) { 492 if (smp_num_siblings > NR_CPUS) {
495 printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); 493 printk(KERN_WARNING "CPU: Unsupported number of the "
494 "siblings %d", smp_num_siblings);
496 smp_num_siblings = 1; 495 smp_num_siblings = 1;
497 return; 496 return;
498 } 497 }
499 498
500 index_msb = get_count_order(smp_num_siblings); 499 index_msb = get_count_order(smp_num_siblings);
501 phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); 500 c->phys_proc_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
502 501
503 printk(KERN_INFO "CPU: Physical Processor ID: %d\n", 502 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
504 phys_proc_id[cpu]); 503 c->phys_proc_id);
505 504
506 smp_num_siblings = smp_num_siblings / c->x86_max_cores; 505 smp_num_siblings = smp_num_siblings / c->x86_max_cores;
507 506
@@ -509,12 +508,12 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
509 508
510 core_bits = get_count_order(c->x86_max_cores); 509 core_bits = get_count_order(c->x86_max_cores);
511 510
512 cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) & 511 c->cpu_core_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) &
513 ((1 << core_bits) - 1); 512 ((1 << core_bits) - 1);
514 513
515 if (c->x86_max_cores > 1) 514 if (c->x86_max_cores > 1)
516 printk(KERN_INFO "CPU: Processor Core ID: %d\n", 515 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
517 cpu_core_id[cpu]); 516 c->cpu_core_id);
518 } 517 }
519} 518}
520#endif 519#endif
@@ -613,6 +612,12 @@ void __cpuinit cpu_init(void)
613 set_in_cr4(X86_CR4_TSD); 612 set_in_cr4(X86_CR4_TSD);
614 } 613 }
615 614
615 /* The CPU hotplug case */
616 if (cpu_gdt_descr->address) {
617 gdt = (struct desc_struct *)cpu_gdt_descr->address;
618 memset(gdt, 0, PAGE_SIZE);
619 goto old_gdt;
620 }
616 /* 621 /*
617 * This is a horrible hack to allocate the GDT. The problem 622 * This is a horrible hack to allocate the GDT. The problem
618 * is that cpu_init() is called really early for the boot CPU 623 * is that cpu_init() is called really early for the boot CPU
@@ -631,7 +636,7 @@ void __cpuinit cpu_init(void)
631 local_irq_enable(); 636 local_irq_enable();
632 } 637 }
633 } 638 }
634 639old_gdt:
635 /* 640 /*
636 * Initialize the per-CPU GDT with the boot GDT, 641 * Initialize the per-CPU GDT with the boot GDT,
637 * and set up the GDT descriptor: 642 * and set up the GDT descriptor:
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index 6c37b4fd8ce2..e9f0b928b0a9 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -159,13 +159,13 @@ union l2_cache {
159 unsigned val; 159 unsigned val;
160}; 160};
161 161
162static unsigned short assocs[] = { 162static const unsigned short assocs[] = {
163 [1] = 1, [2] = 2, [4] = 4, [6] = 8, 163 [1] = 1, [2] = 2, [4] = 4, [6] = 8,
164 [8] = 16, 164 [8] = 16,
165 [0xf] = 0xffff // ?? 165 [0xf] = 0xffff // ??
166 }; 166 };
167static unsigned char levels[] = { 1, 1, 2 }; 167static const unsigned char levels[] = { 1, 1, 2 };
168static unsigned char types[] = { 1, 2, 3 }; 168static const unsigned char types[] = { 1, 2, 3 };
169 169
170static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, 170static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
171 union _cpuid4_leaf_ebx *ebx, 171 union _cpuid4_leaf_ebx *ebx,
@@ -261,7 +261,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
261 unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */ 261 unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
262 unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */ 262 unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
263 unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb; 263 unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;
264#ifdef CONFIG_SMP 264#ifdef CONFIG_X86_HT
265 unsigned int cpu = (c == &boot_cpu_data) ? 0 : (c - cpu_data); 265 unsigned int cpu = (c == &boot_cpu_data) ? 0 : (c - cpu_data);
266#endif 266#endif
267 267
@@ -383,14 +383,14 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
383 383
384 if (new_l2) { 384 if (new_l2) {
385 l2 = new_l2; 385 l2 = new_l2;
386#ifdef CONFIG_SMP 386#ifdef CONFIG_X86_HT
387 cpu_llc_id[cpu] = l2_id; 387 cpu_llc_id[cpu] = l2_id;
388#endif 388#endif
389 } 389 }
390 390
391 if (new_l3) { 391 if (new_l3) {
392 l3 = new_l3; 392 l3 = new_l3;
393#ifdef CONFIG_SMP 393#ifdef CONFIG_X86_HT
394 cpu_llc_id[cpu] = l3_id; 394 cpu_llc_id[cpu] = l3_id;
395#endif 395#endif
396 } 396 }
@@ -729,7 +729,7 @@ static void __cpuexit cache_remove_dev(struct sys_device * sys_dev)
729 return; 729 return;
730} 730}
731 731
732static int cacheinfo_cpu_callback(struct notifier_block *nfb, 732static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
733 unsigned long action, void *hcpu) 733 unsigned long action, void *hcpu)
734{ 734{
735 unsigned int cpu = (unsigned long)hcpu; 735 unsigned int cpu = (unsigned long)hcpu;
@@ -747,7 +747,7 @@ static int cacheinfo_cpu_callback(struct notifier_block *nfb,
747 return NOTIFY_OK; 747 return NOTIFY_OK;
748} 748}
749 749
750static struct notifier_block cacheinfo_cpu_notifier = 750static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier =
751{ 751{
752 .notifier_call = cacheinfo_cpu_callback, 752 .notifier_call = cacheinfo_cpu_callback,
753}; 753};
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index a19fcb262dbb..f54a15268ed7 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -18,7 +18,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
18 * applications want to get the raw CPUID data, they should access 18 * applications want to get the raw CPUID data, they should access
19 * /dev/cpu/<cpu_nr>/cpuid instead. 19 * /dev/cpu/<cpu_nr>/cpuid instead.
20 */ 20 */
21 static char *x86_cap_flags[] = { 21 static const char * const x86_cap_flags[] = {
22 /* Intel-defined */ 22 /* Intel-defined */
23 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", 23 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
24 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov", 24 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
@@ -62,7 +62,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
62 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 62 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
63 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 63 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
64 }; 64 };
65 static char *x86_power_flags[] = { 65 static const char * const x86_power_flags[] = {
66 "ts", /* temperature sensor */ 66 "ts", /* temperature sensor */
67 "fid", /* frequency id control */ 67 "fid", /* frequency id control */
68 "vid", /* voltage id control */ 68 "vid", /* voltage id control */
@@ -109,9 +109,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
109 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); 109 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
110#ifdef CONFIG_X86_HT 110#ifdef CONFIG_X86_HT
111 if (c->x86_max_cores * smp_num_siblings > 1) { 111 if (c->x86_max_cores * smp_num_siblings > 1) {
112 seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]); 112 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
113 seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n])); 113 seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
114 seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]); 114 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
115 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); 115 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
116 } 116 }
117#endif 117#endif
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index 1d9a4abcdfc7..f6dfa9fb675c 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -183,7 +183,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long ac
183 return NOTIFY_OK; 183 return NOTIFY_OK;
184} 184}
185 185
186static struct notifier_block cpuid_class_cpu_notifier = 186static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier =
187{ 187{
188 .notifier_call = cpuid_class_cpu_callback, 188 .notifier_call = cpuid_class_cpu_callback,
189}; 189};
diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c
index 9202b67c4b2e..8beb0f07d999 100644
--- a/arch/i386/kernel/efi.c
+++ b/arch/i386/kernel/efi.c
@@ -601,8 +601,10 @@ efi_initialize_iomem_resources(struct resource *code_resource,
601 res->end = res->start + ((md->num_pages << EFI_PAGE_SHIFT) - 1); 601 res->end = res->start + ((md->num_pages << EFI_PAGE_SHIFT) - 1);
602 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 602 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
603 if (request_resource(&iomem_resource, res) < 0) 603 if (request_resource(&iomem_resource, res) < 0)
604 printk(KERN_ERR PFX "Failed to allocate res %s : 0x%lx-0x%lx\n", 604 printk(KERN_ERR PFX "Failed to allocate res %s : "
605 res->name, res->start, res->end); 605 "0x%llx-0x%llx\n", res->name,
606 (unsigned long long)res->start,
607 (unsigned long long)res->end);
606 /* 608 /*
607 * We don't know which region contains kernel data so we try 609 * We don't know which region contains kernel data so we try
608 * it repeatedly and let the resource manager test it. 610 * it repeatedly and let the resource manager test it.
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index e6e4506e749a..fbdb933251b6 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -83,6 +83,12 @@ VM_MASK = 0x00020000
83#define resume_kernel restore_nocheck 83#define resume_kernel restore_nocheck
84#endif 84#endif
85 85
86#ifdef CONFIG_VM86
87#define resume_userspace_sig check_userspace
88#else
89#define resume_userspace_sig resume_userspace
90#endif
91
86#define SAVE_ALL \ 92#define SAVE_ALL \
87 cld; \ 93 cld; \
88 pushl %es; \ 94 pushl %es; \
@@ -211,6 +217,7 @@ ret_from_exception:
211 preempt_stop 217 preempt_stop
212ret_from_intr: 218ret_from_intr:
213 GET_THREAD_INFO(%ebp) 219 GET_THREAD_INFO(%ebp)
220check_userspace:
214 movl EFLAGS(%esp), %eax # mix EFLAGS and CS 221 movl EFLAGS(%esp), %eax # mix EFLAGS and CS
215 movb CS(%esp), %al 222 movb CS(%esp), %al
216 testl $(VM_MASK | 3), %eax 223 testl $(VM_MASK | 3), %eax
@@ -263,7 +270,12 @@ sysenter_past_esp:
263 pushl $(__USER_CS) 270 pushl $(__USER_CS)
264 CFI_ADJUST_CFA_OFFSET 4 271 CFI_ADJUST_CFA_OFFSET 4
265 /*CFI_REL_OFFSET cs, 0*/ 272 /*CFI_REL_OFFSET cs, 0*/
266 pushl $SYSENTER_RETURN 273 /*
274 * Push current_thread_info()->sysenter_return to the stack.
275 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
276 * pushed above; +8 corresponds to copy_thread's esp0 setting.
277 */
278 pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
267 CFI_ADJUST_CFA_OFFSET 4 279 CFI_ADJUST_CFA_OFFSET 4
268 CFI_REL_OFFSET eip, 0 280 CFI_REL_OFFSET eip, 0
269 281
@@ -415,7 +427,7 @@ work_notifysig: # deal with pending signals and
415 # vm86-space 427 # vm86-space
416 xorl %edx, %edx 428 xorl %edx, %edx
417 call do_notify_resume 429 call do_notify_resume
418 jmp resume_userspace 430 jmp resume_userspace_sig
419 431
420 ALIGN 432 ALIGN
421work_notifysig_v86: 433work_notifysig_v86:
@@ -428,7 +440,7 @@ work_notifysig_v86:
428 movl %eax, %esp 440 movl %eax, %esp
429 xorl %edx, %edx 441 xorl %edx, %edx
430 call do_notify_resume 442 call do_notify_resume
431 jmp resume_userspace 443 jmp resume_userspace_sig
432#endif 444#endif
433 445
434 # perform syscall exit tracing 446 # perform syscall exit tracing
@@ -515,7 +527,7 @@ ENTRY(irq_entries_start)
515 .if vector 527 .if vector
516 CFI_ADJUST_CFA_OFFSET -4 528 CFI_ADJUST_CFA_OFFSET -4
517 .endif 529 .endif
5181: pushl $vector-256 5301: pushl $~(vector)
519 CFI_ADJUST_CFA_OFFSET 4 531 CFI_ADJUST_CFA_OFFSET 4
520 jmp common_interrupt 532 jmp common_interrupt
521.data 533.data
@@ -535,7 +547,7 @@ common_interrupt:
535#define BUILD_INTERRUPT(name, nr) \ 547#define BUILD_INTERRUPT(name, nr) \
536ENTRY(name) \ 548ENTRY(name) \
537 RING0_INT_FRAME; \ 549 RING0_INT_FRAME; \
538 pushl $nr-256; \ 550 pushl $~(nr); \
539 CFI_ADJUST_CFA_OFFSET 4; \ 551 CFI_ADJUST_CFA_OFFSET 4; \
540 SAVE_ALL; \ 552 SAVE_ALL; \
541 movl %esp,%eax; \ 553 movl %esp,%eax; \
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
index c1a42feba286..3c6063671a9f 100644
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -132,7 +132,7 @@ void make_8259A_irq(unsigned int irq)
132{ 132{
133 disable_irq_nosync(irq); 133 disable_irq_nosync(irq);
134 io_apic_irqs &= ~(1<<irq); 134 io_apic_irqs &= ~(1<<irq);
135 irq_desc[irq].handler = &i8259A_irq_type; 135 irq_desc[irq].chip = &i8259A_irq_type;
136 enable_irq(irq); 136 enable_irq(irq);
137} 137}
138 138
@@ -386,12 +386,12 @@ void __init init_ISA_irqs (void)
386 /* 386 /*
387 * 16 old-style INTA-cycle interrupts: 387 * 16 old-style INTA-cycle interrupts:
388 */ 388 */
389 irq_desc[i].handler = &i8259A_irq_type; 389 irq_desc[i].chip = &i8259A_irq_type;
390 } else { 390 } else {
391 /* 391 /*
392 * 'high' PCI IRQs filled in on demand 392 * 'high' PCI IRQs filled in on demand
393 */ 393 */
394 irq_desc[i].handler = &no_irq_type; 394 irq_desc[i].chip = &no_irq_type;
395 } 395 }
396 } 396 }
397} 397}
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 72ae414e4d49..ec9ea0269d36 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -581,7 +581,7 @@ static int balanced_irq(void *unused)
581 581
582 /* push everything to CPU 0 to give us a starting point. */ 582 /* push everything to CPU 0 to give us a starting point. */
583 for (i = 0 ; i < NR_IRQS ; i++) { 583 for (i = 0 ; i < NR_IRQS ; i++) {
584 pending_irq_cpumask[i] = cpumask_of_cpu(0); 584 irq_desc[i].pending_mask = cpumask_of_cpu(0);
585 set_pending_irq(i, cpumask_of_cpu(0)); 585 set_pending_irq(i, cpumask_of_cpu(0));
586 } 586 }
587 587
@@ -1205,15 +1205,17 @@ static struct hw_interrupt_type ioapic_edge_type;
1205#define IOAPIC_EDGE 0 1205#define IOAPIC_EDGE 0
1206#define IOAPIC_LEVEL 1 1206#define IOAPIC_LEVEL 1
1207 1207
1208static inline void ioapic_register_intr(int irq, int vector, unsigned long trigger) 1208static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
1209{ 1209{
1210 unsigned idx = use_pci_vector() && !platform_legacy_irq(irq) ? vector : irq; 1210 unsigned idx;
1211
1212 idx = use_pci_vector() && !platform_legacy_irq(irq) ? vector : irq;
1211 1213
1212 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || 1214 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
1213 trigger == IOAPIC_LEVEL) 1215 trigger == IOAPIC_LEVEL)
1214 irq_desc[idx].handler = &ioapic_level_type; 1216 irq_desc[idx].chip = &ioapic_level_type;
1215 else 1217 else
1216 irq_desc[idx].handler = &ioapic_edge_type; 1218 irq_desc[idx].chip = &ioapic_edge_type;
1217 set_intr_gate(vector, interrupt[idx]); 1219 set_intr_gate(vector, interrupt[idx]);
1218} 1220}
1219 1221
@@ -1325,7 +1327,7 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, in
1325 * The timer IRQ doesn't have to know that behind the 1327 * The timer IRQ doesn't have to know that behind the
1326 * scene we have a 8259A-master in AEOI mode ... 1328 * scene we have a 8259A-master in AEOI mode ...
1327 */ 1329 */
1328 irq_desc[0].handler = &ioapic_edge_type; 1330 irq_desc[0].chip = &ioapic_edge_type;
1329 1331
1330 /* 1332 /*
1331 * Add it to the IO-APIC irq-routing table: 1333 * Add it to the IO-APIC irq-routing table:
@@ -2069,6 +2071,13 @@ static void set_ioapic_affinity_vector (unsigned int vector,
2069#endif 2071#endif
2070#endif 2072#endif
2071 2073
2074static int ioapic_retrigger(unsigned int irq)
2075{
2076 send_IPI_self(IO_APIC_VECTOR(irq));
2077
2078 return 1;
2079}
2080
2072/* 2081/*
2073 * Level and edge triggered IO-APIC interrupts need different handling, 2082 * Level and edge triggered IO-APIC interrupts need different handling,
2074 * so we use two separate IRQ descriptors. Edge triggered IRQs can be 2083 * so we use two separate IRQ descriptors. Edge triggered IRQs can be
@@ -2088,6 +2097,7 @@ static struct hw_interrupt_type ioapic_edge_type __read_mostly = {
2088#ifdef CONFIG_SMP 2097#ifdef CONFIG_SMP
2089 .set_affinity = set_ioapic_affinity, 2098 .set_affinity = set_ioapic_affinity,
2090#endif 2099#endif
2100 .retrigger = ioapic_retrigger,
2091}; 2101};
2092 2102
2093static struct hw_interrupt_type ioapic_level_type __read_mostly = { 2103static struct hw_interrupt_type ioapic_level_type __read_mostly = {
@@ -2101,6 +2111,7 @@ static struct hw_interrupt_type ioapic_level_type __read_mostly = {
2101#ifdef CONFIG_SMP 2111#ifdef CONFIG_SMP
2102 .set_affinity = set_ioapic_affinity, 2112 .set_affinity = set_ioapic_affinity,
2103#endif 2113#endif
2114 .retrigger = ioapic_retrigger,
2104}; 2115};
2105 2116
2106static inline void init_IO_APIC_traps(void) 2117static inline void init_IO_APIC_traps(void)
@@ -2135,7 +2146,7 @@ static inline void init_IO_APIC_traps(void)
2135 make_8259A_irq(irq); 2146 make_8259A_irq(irq);
2136 else 2147 else
2137 /* Strange. Oh, well.. */ 2148 /* Strange. Oh, well.. */
2138 irq_desc[irq].handler = &no_irq_type; 2149 irq_desc[irq].chip = &no_irq_type;
2139 } 2150 }
2140 } 2151 }
2141} 2152}
@@ -2351,7 +2362,7 @@ static inline void check_timer(void)
2351 printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ..."); 2362 printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
2352 2363
2353 disable_8259A_irq(0); 2364 disable_8259A_irq(0);
2354 irq_desc[0].handler = &lapic_irq_type; 2365 irq_desc[0].chip = &lapic_irq_type;
2355 apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */ 2366 apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */
2356 enable_8259A_irq(0); 2367 enable_8259A_irq(0);
2357 2368
diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
index 061533e0cb5e..16b491703967 100644
--- a/arch/i386/kernel/irq.c
+++ b/arch/i386/kernel/irq.c
@@ -53,13 +53,19 @@ static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
53 */ 53 */
54fastcall unsigned int do_IRQ(struct pt_regs *regs) 54fastcall unsigned int do_IRQ(struct pt_regs *regs)
55{ 55{
56 /* high bits used in ret_from_ code */ 56 /* high bit used in ret_from_ code */
57 int irq = regs->orig_eax & 0xff; 57 int irq = ~regs->orig_eax;
58#ifdef CONFIG_4KSTACKS 58#ifdef CONFIG_4KSTACKS
59 union irq_ctx *curctx, *irqctx; 59 union irq_ctx *curctx, *irqctx;
60 u32 *isp; 60 u32 *isp;
61#endif 61#endif
62 62
63 if (unlikely((unsigned)irq >= NR_IRQS)) {
64 printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
65 __FUNCTION__, irq);
66 BUG();
67 }
68
63 irq_enter(); 69 irq_enter();
64#ifdef CONFIG_DEBUG_STACKOVERFLOW 70#ifdef CONFIG_DEBUG_STACKOVERFLOW
65 /* Debugging check for stack overflow: is there less than 1KB free? */ 71 /* Debugging check for stack overflow: is there less than 1KB free? */
@@ -76,6 +82,10 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
76 } 82 }
77#endif 83#endif
78 84
85 if (!irq_desc[irq].handle_irq) {
86 __do_IRQ(irq, regs);
87 goto out_exit;
88 }
79#ifdef CONFIG_4KSTACKS 89#ifdef CONFIG_4KSTACKS
80 90
81 curctx = (union irq_ctx *) current_thread_info(); 91 curctx = (union irq_ctx *) current_thread_info();
@@ -100,8 +110,8 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
100 * softirq checks work in the hardirq context. 110 * softirq checks work in the hardirq context.
101 */ 111 */
102 irqctx->tinfo.preempt_count = 112 irqctx->tinfo.preempt_count =
103 irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK | 113 (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
104 curctx->tinfo.preempt_count & SOFTIRQ_MASK; 114 (curctx->tinfo.preempt_count & SOFTIRQ_MASK);
105 115
106 asm volatile( 116 asm volatile(
107 " xchgl %%ebx,%%esp \n" 117 " xchgl %%ebx,%%esp \n"
@@ -115,6 +125,7 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
115#endif 125#endif
116 __do_IRQ(irq, regs); 126 __do_IRQ(irq, regs);
117 127
128out_exit:
118 irq_exit(); 129 irq_exit();
119 130
120 return 1; 131 return 1;
@@ -243,7 +254,7 @@ int show_interrupts(struct seq_file *p, void *v)
243 for_each_online_cpu(j) 254 for_each_online_cpu(j)
244 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 255 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
245#endif 256#endif
246 seq_printf(p, " %14s", irq_desc[i].handler->typename); 257 seq_printf(p, " %14s", irq_desc[i].chip->typename);
247 seq_printf(p, " %s", action->name); 258 seq_printf(p, " %s", action->name);
248 259
249 for (action=action->next; action; action = action->next) 260 for (action=action->next; action; action = action->next)
@@ -285,13 +296,13 @@ void fixup_irqs(cpumask_t map)
285 if (irq == 2) 296 if (irq == 2)
286 continue; 297 continue;
287 298
288 cpus_and(mask, irq_affinity[irq], map); 299 cpus_and(mask, irq_desc[irq].affinity, map);
289 if (any_online_cpu(mask) == NR_CPUS) { 300 if (any_online_cpu(mask) == NR_CPUS) {
290 printk("Breaking affinity for irq %i\n", irq); 301 printk("Breaking affinity for irq %i\n", irq);
291 mask = map; 302 mask = map;
292 } 303 }
293 if (irq_desc[irq].handler->set_affinity) 304 if (irq_desc[irq].chip->set_affinity)
294 irq_desc[irq].handler->set_affinity(irq, mask); 305 irq_desc[irq].chip->set_affinity(irq, mask);
295 else if (irq_desc[irq].action && !(warned++)) 306 else if (irq_desc[irq].action && !(warned++))
296 printk("Cannot set affinity for irq %i\n", irq); 307 printk("Cannot set affinity for irq %i\n", irq);
297 } 308 }
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 0a865889b2a9..40b44cc0d14b 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -493,7 +493,6 @@ static struct file_operations microcode_fops = {
493static struct miscdevice microcode_dev = { 493static struct miscdevice microcode_dev = {
494 .minor = MICROCODE_MINOR, 494 .minor = MICROCODE_MINOR,
495 .name = "microcode", 495 .name = "microcode",
496 .devfs_name = "cpu/microcode",
497 .fops = &microcode_fops, 496 .fops = &microcode_fops,
498}; 497};
499 498
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index 7a328230e540..d022cb8fd725 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -266,7 +266,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb, unsigned long acti
266 return NOTIFY_OK; 266 return NOTIFY_OK;
267} 267}
268 268
269static struct notifier_block msr_class_cpu_notifier = 269static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
270{ 270{
271 .notifier_call = msr_class_cpu_callback, 271 .notifier_call = msr_class_cpu_callback,
272}; 272};
diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c
index 321f5fd26e75..9bf590cefc7d 100644
--- a/arch/i386/kernel/scx200.c
+++ b/arch/i386/kernel/scx200.c
@@ -9,6 +9,7 @@
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/mutex.h>
12#include <linux/pci.h> 13#include <linux/pci.h>
13 14
14#include <linux/scx200.h> 15#include <linux/scx200.h>
@@ -45,11 +46,19 @@ static struct pci_driver scx200_pci_driver = {
45 .probe = scx200_probe, 46 .probe = scx200_probe,
46}; 47};
47 48
48static DEFINE_SPINLOCK(scx200_gpio_config_lock); 49static DEFINE_MUTEX(scx200_gpio_config_lock);
49 50
50static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 51static void __devinit scx200_init_shadow(void)
51{ 52{
52 int bank; 53 int bank;
54
55 /* read the current values driven on the GPIO signals */
56 for (bank = 0; bank < 2; ++bank)
57 scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);
58}
59
60static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
61{
53 unsigned base; 62 unsigned base;
54 63
55 if (pdev->device == PCI_DEVICE_ID_NS_SCx200_BRIDGE || 64 if (pdev->device == PCI_DEVICE_ID_NS_SCx200_BRIDGE ||
@@ -63,10 +72,7 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_
63 } 72 }
64 73
65 scx200_gpio_base = base; 74 scx200_gpio_base = base;
66 75 scx200_init_shadow();
67 /* read the current values driven on the GPIO signals */
68 for (bank = 0; bank < 2; ++bank)
69 scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);
70 76
71 } else { 77 } else {
72 /* find the base of the Configuration Block */ 78 /* find the base of the Configuration Block */
@@ -87,12 +93,11 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_
87 return 0; 93 return 0;
88} 94}
89 95
90u32 scx200_gpio_configure(int index, u32 mask, u32 bits) 96u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits)
91{ 97{
92 u32 config, new_config; 98 u32 config, new_config;
93 unsigned long flags;
94 99
95 spin_lock_irqsave(&scx200_gpio_config_lock, flags); 100 mutex_lock(&scx200_gpio_config_lock);
96 101
97 outl(index, scx200_gpio_base + 0x20); 102 outl(index, scx200_gpio_base + 0x20);
98 config = inl(scx200_gpio_base + 0x24); 103 config = inl(scx200_gpio_base + 0x24);
@@ -100,45 +105,11 @@ u32 scx200_gpio_configure(int index, u32 mask, u32 bits)
100 new_config = (config & mask) | bits; 105 new_config = (config & mask) | bits;
101 outl(new_config, scx200_gpio_base + 0x24); 106 outl(new_config, scx200_gpio_base + 0x24);
102 107
103 spin_unlock_irqrestore(&scx200_gpio_config_lock, flags); 108 mutex_unlock(&scx200_gpio_config_lock);
104 109
105 return config; 110 return config;
106} 111}
107 112
108#if 0
109void scx200_gpio_dump(unsigned index)
110{
111 u32 config = scx200_gpio_configure(index, ~0, 0);
112 printk(KERN_DEBUG "GPIO%02u: 0x%08lx", index, (unsigned long)config);
113
114 if (config & 1)
115 printk(" OE"); /* output enabled */
116 else
117 printk(" TS"); /* tristate */
118 if (config & 2)
119 printk(" PP"); /* push pull */
120 else
121 printk(" OD"); /* open drain */
122 if (config & 4)
123 printk(" PUE"); /* pull up enabled */
124 else
125 printk(" PUD"); /* pull up disabled */
126 if (config & 8)
127 printk(" LOCKED"); /* locked */
128 if (config & 16)
129 printk(" LEVEL"); /* level input */
130 else
131 printk(" EDGE"); /* edge input */
132 if (config & 32)
133 printk(" HI"); /* trigger on rising edge */
134 else
135 printk(" LO"); /* trigger on falling edge */
136 if (config & 64)
137 printk(" DEBOUNCE"); /* debounce */
138 printk("\n");
139}
140#endif /* 0 */
141
142static int __init scx200_init(void) 113static int __init scx200_init(void)
143{ 114{
144 printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n"); 115 printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");
@@ -159,10 +130,3 @@ EXPORT_SYMBOL(scx200_gpio_base);
159EXPORT_SYMBOL(scx200_gpio_shadow); 130EXPORT_SYMBOL(scx200_gpio_shadow);
160EXPORT_SYMBOL(scx200_gpio_configure); 131EXPORT_SYMBOL(scx200_gpio_configure);
161EXPORT_SYMBOL(scx200_cb_base); 132EXPORT_SYMBOL(scx200_cb_base);
162
163/*
164 Local variables:
165 compile-command: "make -k -C ../../.. SUBDIRS=arch/i386/kernel modules"
166 c-basic-offset: 8
167 End:
168*/
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 4a65040cc624..6712f0d2eb37 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -1314,8 +1314,10 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
1314 probe_roms(); 1314 probe_roms();
1315 for (i = 0; i < e820.nr_map; i++) { 1315 for (i = 0; i < e820.nr_map; i++) {
1316 struct resource *res; 1316 struct resource *res;
1317#ifndef CONFIG_RESOURCES_64BIT
1317 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL) 1318 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
1318 continue; 1319 continue;
1320#endif
1319 res = kzalloc(sizeof(struct resource), GFP_ATOMIC); 1321 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
1320 switch (e820.map[i].type) { 1322 switch (e820.map[i].type) {
1321 case E820_RAM: res->name = "System RAM"; break; 1323 case E820_RAM: res->name = "System RAM"; break;
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index 5c352c3a9e7f..43002cfb40c4 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -351,7 +351,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
351 goto give_sigsegv; 351 goto give_sigsegv;
352 } 352 }
353 353
354 restorer = &__kernel_sigreturn; 354 restorer = (void *)VDSO_SYM(&__kernel_sigreturn);
355 if (ka->sa.sa_flags & SA_RESTORER) 355 if (ka->sa.sa_flags & SA_RESTORER)
356 restorer = ka->sa.sa_restorer; 356 restorer = ka->sa.sa_restorer;
357 357
@@ -447,7 +447,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
447 goto give_sigsegv; 447 goto give_sigsegv;
448 448
449 /* Set up to return from userspace. */ 449 /* Set up to return from userspace. */
450 restorer = &__kernel_rt_sigreturn; 450 restorer = (void *)VDSO_SYM(&__kernel_rt_sigreturn);
451 if (ka->sa.sa_flags & SA_RESTORER) 451 if (ka->sa.sa_flags & SA_RESTORER)
452 restorer = ka->sa.sa_restorer; 452 restorer = ka->sa.sa_restorer;
453 err |= __put_user(restorer, &frame->pretcode); 453 err |= __put_user(restorer, &frame->pretcode);
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index bce5470ecb42..89e7315e539c 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -67,12 +67,6 @@ int smp_num_siblings = 1;
67EXPORT_SYMBOL(smp_num_siblings); 67EXPORT_SYMBOL(smp_num_siblings);
68#endif 68#endif
69 69
70/* Package ID of each logical CPU */
71int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
72
73/* Core ID of each logical CPU */
74int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
75
76/* Last level cache ID of each logical CPU */ 70/* Last level cache ID of each logical CPU */
77int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID}; 71int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID};
78 72
@@ -454,10 +448,12 @@ cpumask_t cpu_coregroup_map(int cpu)
454 struct cpuinfo_x86 *c = cpu_data + cpu; 448 struct cpuinfo_x86 *c = cpu_data + cpu;
455 /* 449 /*
456 * For perf, we return last level cache shared map. 450 * For perf, we return last level cache shared map.
457 * TBD: when power saving sched policy is added, we will return 451 * And for power savings, we return cpu_core_map
458 * cpu_core_map when power saving policy is enabled
459 */ 452 */
460 return c->llc_shared_map; 453 if (sched_mc_power_savings || sched_smt_power_savings)
454 return cpu_core_map[cpu];
455 else
456 return c->llc_shared_map;
461} 457}
462 458
463/* representing cpus for which sibling maps can be computed */ 459/* representing cpus for which sibling maps can be computed */
@@ -473,8 +469,8 @@ set_cpu_sibling_map(int cpu)
473 469
474 if (smp_num_siblings > 1) { 470 if (smp_num_siblings > 1) {
475 for_each_cpu_mask(i, cpu_sibling_setup_map) { 471 for_each_cpu_mask(i, cpu_sibling_setup_map) {
476 if (phys_proc_id[cpu] == phys_proc_id[i] && 472 if (c[cpu].phys_proc_id == c[i].phys_proc_id &&
477 cpu_core_id[cpu] == cpu_core_id[i]) { 473 c[cpu].cpu_core_id == c[i].cpu_core_id) {
478 cpu_set(i, cpu_sibling_map[cpu]); 474 cpu_set(i, cpu_sibling_map[cpu]);
479 cpu_set(cpu, cpu_sibling_map[i]); 475 cpu_set(cpu, cpu_sibling_map[i]);
480 cpu_set(i, cpu_core_map[cpu]); 476 cpu_set(i, cpu_core_map[cpu]);
@@ -501,7 +497,7 @@ set_cpu_sibling_map(int cpu)
501 cpu_set(i, c[cpu].llc_shared_map); 497 cpu_set(i, c[cpu].llc_shared_map);
502 cpu_set(cpu, c[i].llc_shared_map); 498 cpu_set(cpu, c[i].llc_shared_map);
503 } 499 }
504 if (phys_proc_id[cpu] == phys_proc_id[i]) { 500 if (c[cpu].phys_proc_id == c[i].phys_proc_id) {
505 cpu_set(i, cpu_core_map[cpu]); 501 cpu_set(i, cpu_core_map[cpu]);
506 cpu_set(cpu, cpu_core_map[i]); 502 cpu_set(cpu, cpu_core_map[i]);
507 /* 503 /*
@@ -1056,6 +1052,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1056 struct warm_boot_cpu_info info; 1052 struct warm_boot_cpu_info info;
1057 struct work_struct task; 1053 struct work_struct task;
1058 int apicid, ret; 1054 int apicid, ret;
1055 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
1059 1056
1060 apicid = x86_cpu_to_apicid[cpu]; 1057 apicid = x86_cpu_to_apicid[cpu];
1061 if (apicid == BAD_APICID) { 1058 if (apicid == BAD_APICID) {
@@ -1063,6 +1060,18 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1063 goto exit; 1060 goto exit;
1064 } 1061 }
1065 1062
1063 /*
1064 * the CPU isn't initialized at boot time, allocate gdt table here.
1065 * cpu_init will initialize it
1066 */
1067 if (!cpu_gdt_descr->address) {
1068 cpu_gdt_descr->address = get_zeroed_page(GFP_KERNEL);
1069 if (!cpu_gdt_descr->address)
1070 printk(KERN_CRIT "CPU%d failed to allocate GDT\n", cpu);
1071 ret = -ENOMEM;
1072 goto exit;
1073 }
1074
1066 info.complete = &done; 1075 info.complete = &done;
1067 info.apicid = apicid; 1076 info.apicid = apicid;
1068 info.cpu = cpu; 1077 info.cpu = cpu;
@@ -1340,8 +1349,8 @@ remove_siblinginfo(int cpu)
1340 cpu_clear(cpu, cpu_sibling_map[sibling]); 1349 cpu_clear(cpu, cpu_sibling_map[sibling]);
1341 cpus_clear(cpu_sibling_map[cpu]); 1350 cpus_clear(cpu_sibling_map[cpu]);
1342 cpus_clear(cpu_core_map[cpu]); 1351 cpus_clear(cpu_core_map[cpu]);
1343 phys_proc_id[cpu] = BAD_APICID; 1352 c[cpu].phys_proc_id = 0;
1344 cpu_core_id[cpu] = BAD_APICID; 1353 c[cpu].cpu_core_id = 0;
1345 cpu_clear(cpu, cpu_sibling_setup_map); 1354 cpu_clear(cpu, cpu_sibling_setup_map);
1346} 1355}
1347 1356
diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
index 0bada1870bdf..713ba39d32c6 100644
--- a/arch/i386/kernel/sysenter.c
+++ b/arch/i386/kernel/sysenter.c
@@ -2,6 +2,8 @@
2 * linux/arch/i386/kernel/sysenter.c 2 * linux/arch/i386/kernel/sysenter.c
3 * 3 *
4 * (C) Copyright 2002 Linus Torvalds 4 * (C) Copyright 2002 Linus Torvalds
5 * Portions based on the vdso-randomization code from exec-shield:
6 * Copyright(C) 2005-2006, Red Hat, Inc., Ingo Molnar
5 * 7 *
6 * This file contains the needed initializations to support sysenter. 8 * This file contains the needed initializations to support sysenter.
7 */ 9 */
@@ -13,12 +15,31 @@
13#include <linux/gfp.h> 15#include <linux/gfp.h>
14#include <linux/string.h> 16#include <linux/string.h>
15#include <linux/elf.h> 17#include <linux/elf.h>
18#include <linux/mm.h>
19#include <linux/module.h>
16 20
17#include <asm/cpufeature.h> 21#include <asm/cpufeature.h>
18#include <asm/msr.h> 22#include <asm/msr.h>
19#include <asm/pgtable.h> 23#include <asm/pgtable.h>
20#include <asm/unistd.h> 24#include <asm/unistd.h>
21 25
26/*
27 * Should the kernel map a VDSO page into processes and pass its
28 * address down to glibc upon exec()?
29 */
30unsigned int __read_mostly vdso_enabled = 1;
31
32EXPORT_SYMBOL_GPL(vdso_enabled);
33
34static int __init vdso_setup(char *s)
35{
36 vdso_enabled = simple_strtoul(s, NULL, 0);
37
38 return 1;
39}
40
41__setup("vdso=", vdso_setup);
42
22extern asmlinkage void sysenter_entry(void); 43extern asmlinkage void sysenter_entry(void);
23 44
24void enable_sep_cpu(void) 45void enable_sep_cpu(void)
@@ -45,23 +66,120 @@ void enable_sep_cpu(void)
45 */ 66 */
46extern const char vsyscall_int80_start, vsyscall_int80_end; 67extern const char vsyscall_int80_start, vsyscall_int80_end;
47extern const char vsyscall_sysenter_start, vsyscall_sysenter_end; 68extern const char vsyscall_sysenter_start, vsyscall_sysenter_end;
69static void *syscall_page;
48 70
49int __init sysenter_setup(void) 71int __init sysenter_setup(void)
50{ 72{
51 void *page = (void *)get_zeroed_page(GFP_ATOMIC); 73 syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
52 74
53 __set_fixmap(FIX_VSYSCALL, __pa(page), PAGE_READONLY_EXEC); 75#ifdef CONFIG_COMPAT_VDSO
76 __set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_READONLY);
77 printk("Compat vDSO mapped to %08lx.\n", __fix_to_virt(FIX_VDSO));
78#else
79 /*
80 * In the non-compat case the ELF coredumping code needs the fixmap:
81 */
82 __set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_KERNEL_RO);
83#endif
54 84
55 if (!boot_cpu_has(X86_FEATURE_SEP)) { 85 if (!boot_cpu_has(X86_FEATURE_SEP)) {
56 memcpy(page, 86 memcpy(syscall_page,
57 &vsyscall_int80_start, 87 &vsyscall_int80_start,
58 &vsyscall_int80_end - &vsyscall_int80_start); 88 &vsyscall_int80_end - &vsyscall_int80_start);
59 return 0; 89 return 0;
60 } 90 }
61 91
62 memcpy(page, 92 memcpy(syscall_page,
63 &vsyscall_sysenter_start, 93 &vsyscall_sysenter_start,
64 &vsyscall_sysenter_end - &vsyscall_sysenter_start); 94 &vsyscall_sysenter_end - &vsyscall_sysenter_start);
65 95
66 return 0; 96 return 0;
67} 97}
98
99static struct page *syscall_nopage(struct vm_area_struct *vma,
100 unsigned long adr, int *type)
101{
102 struct page *p = virt_to_page(adr - vma->vm_start + syscall_page);
103 get_page(p);
104 return p;
105}
106
107/* Prevent VMA merging */
108static void syscall_vma_close(struct vm_area_struct *vma)
109{
110}
111
112static struct vm_operations_struct syscall_vm_ops = {
113 .close = syscall_vma_close,
114 .nopage = syscall_nopage,
115};
116
117/* Defined in vsyscall-sysenter.S */
118extern void SYSENTER_RETURN;
119
120/* Setup a VMA at program startup for the vsyscall page */
121int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
122{
123 struct vm_area_struct *vma;
124 struct mm_struct *mm = current->mm;
125 unsigned long addr;
126 int ret;
127
128 down_write(&mm->mmap_sem);
129 addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
130 if (IS_ERR_VALUE(addr)) {
131 ret = addr;
132 goto up_fail;
133 }
134
135 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL);
136 if (!vma) {
137 ret = -ENOMEM;
138 goto up_fail;
139 }
140
141 vma->vm_start = addr;
142 vma->vm_end = addr + PAGE_SIZE;
143 /* MAYWRITE to allow gdb to COW and set breakpoints */
144 vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE;
145 vma->vm_flags |= mm->def_flags;
146 vma->vm_page_prot = protection_map[vma->vm_flags & 7];
147 vma->vm_ops = &syscall_vm_ops;
148 vma->vm_mm = mm;
149
150 ret = insert_vm_struct(mm, vma);
151 if (unlikely(ret)) {
152 kmem_cache_free(vm_area_cachep, vma);
153 goto up_fail;
154 }
155
156 current->mm->context.vdso = (void *)addr;
157 current_thread_info()->sysenter_return =
158 (void *)VDSO_SYM(&SYSENTER_RETURN);
159 mm->total_vm++;
160up_fail:
161 up_write(&mm->mmap_sem);
162 return ret;
163}
164
165const char *arch_vma_name(struct vm_area_struct *vma)
166{
167 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
168 return "[vdso]";
169 return NULL;
170}
171
172struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
173{
174 return NULL;
175}
176
177int in_gate_area(struct task_struct *task, unsigned long addr)
178{
179 return 0;
180}
181
182int in_gate_area_no_task(unsigned long addr)
183{
184 return 0;
185}
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c
index 296355292c7c..e2e281d4bcc8 100644
--- a/arch/i386/kernel/topology.c
+++ b/arch/i386/kernel/topology.c
@@ -32,15 +32,8 @@
32 32
33static struct i386_cpu cpu_devices[NR_CPUS]; 33static struct i386_cpu cpu_devices[NR_CPUS];
34 34
35int arch_register_cpu(int num){ 35int arch_register_cpu(int num)
36 struct node *parent = NULL; 36{
37
38#ifdef CONFIG_NUMA
39 int node = cpu_to_node(num);
40 if (node_online(node))
41 parent = &node_devices[node].node;
42#endif /* CONFIG_NUMA */
43
44 /* 37 /*
45 * CPU0 cannot be offlined due to several 38 * CPU0 cannot be offlined due to several
46 * restrictions and assumptions in kernel. This basically 39 * restrictions and assumptions in kernel. This basically
@@ -50,21 +43,13 @@ int arch_register_cpu(int num){
50 if (!num) 43 if (!num)
51 cpu_devices[num].cpu.no_control = 1; 44 cpu_devices[num].cpu.no_control = 1;
52 45
53 return register_cpu(&cpu_devices[num].cpu, num, parent); 46 return register_cpu(&cpu_devices[num].cpu, num);
54} 47}
55 48
56#ifdef CONFIG_HOTPLUG_CPU 49#ifdef CONFIG_HOTPLUG_CPU
57 50
58void arch_unregister_cpu(int num) { 51void arch_unregister_cpu(int num) {
59 struct node *parent = NULL; 52 return unregister_cpu(&cpu_devices[num].cpu);
60
61#ifdef CONFIG_NUMA
62 int node = cpu_to_node(num);
63 if (node_online(node))
64 parent = &node_devices[node].node;
65#endif /* CONFIG_NUMA */
66
67 return unregister_cpu(&cpu_devices[num].cpu, parent);
68} 53}
69EXPORT_SYMBOL(arch_register_cpu); 54EXPORT_SYMBOL(arch_register_cpu);
70EXPORT_SYMBOL(arch_unregister_cpu); 55EXPORT_SYMBOL(arch_unregister_cpu);
@@ -74,16 +59,13 @@ EXPORT_SYMBOL(arch_unregister_cpu);
74 59
75#ifdef CONFIG_NUMA 60#ifdef CONFIG_NUMA
76#include <linux/mmzone.h> 61#include <linux/mmzone.h>
77#include <asm/node.h>
78
79struct i386_node node_devices[MAX_NUMNODES];
80 62
81static int __init topology_init(void) 63static int __init topology_init(void)
82{ 64{
83 int i; 65 int i;
84 66
85 for_each_online_node(i) 67 for_each_online_node(i)
86 arch_register_node(i); 68 register_one_node(i);
87 69
88 for_each_present_cpu(i) 70 for_each_present_cpu(i)
89 arch_register_cpu(i); 71 arch_register_cpu(i);
diff --git a/arch/i386/kernel/vsyscall-sysenter.S b/arch/i386/kernel/vsyscall-sysenter.S
index 3b62baa6a371..1a36d26e15eb 100644
--- a/arch/i386/kernel/vsyscall-sysenter.S
+++ b/arch/i386/kernel/vsyscall-sysenter.S
@@ -42,10 +42,10 @@ __kernel_vsyscall:
42 /* 7: align return point with nop's to make disassembly easier */ 42 /* 7: align return point with nop's to make disassembly easier */
43 .space 7,0x90 43 .space 7,0x90
44 44
45 /* 14: System call restart point is here! (SYSENTER_RETURN - 2) */ 45 /* 14: System call restart point is here! (SYSENTER_RETURN-2) */
46 jmp .Lenter_kernel 46 jmp .Lenter_kernel
47 /* 16: System call normal return point is here! */ 47 /* 16: System call normal return point is here! */
48 .globl SYSENTER_RETURN /* Symbol used by entry.S. */ 48 .globl SYSENTER_RETURN /* Symbol used by sysenter.c */
49SYSENTER_RETURN: 49SYSENTER_RETURN:
50 pop %ebp 50 pop %ebp
51.Lpop_ebp: 51.Lpop_ebp:
diff --git a/arch/i386/kernel/vsyscall.lds.S b/arch/i386/kernel/vsyscall.lds.S
index 98699ca6e52d..e26975fc68b6 100644
--- a/arch/i386/kernel/vsyscall.lds.S
+++ b/arch/i386/kernel/vsyscall.lds.S
@@ -7,7 +7,7 @@
7 7
8SECTIONS 8SECTIONS
9{ 9{
10 . = VSYSCALL_BASE + SIZEOF_HEADERS; 10 . = VDSO_PRELINK + SIZEOF_HEADERS;
11 11
12 .hash : { *(.hash) } :text 12 .hash : { *(.hash) } :text
13 .dynsym : { *(.dynsym) } 13 .dynsym : { *(.dynsym) }
@@ -20,7 +20,7 @@ SECTIONS
20 For the layouts to match, we need to skip more than enough 20 For the layouts to match, we need to skip more than enough
21 space for the dynamic symbol table et al. If this amount 21 space for the dynamic symbol table et al. If this amount
22 is insufficient, ld -shared will barf. Just increase it here. */ 22 is insufficient, ld -shared will barf. Just increase it here. */
23 . = VSYSCALL_BASE + 0x400; 23 . = VDSO_PRELINK + 0x400;
24 24
25 .text : { *(.text) } :text =0x90909090 25 .text : { *(.text) } :text =0x90909090
26 .note : { *(.note.*) } :text :note 26 .note : { *(.note.*) } :text :note
diff --git a/arch/i386/mach-visws/setup.c b/arch/i386/mach-visws/setup.c
index 8a9e1a6f745d..1f84cdb24779 100644
--- a/arch/i386/mach-visws/setup.c
+++ b/arch/i386/mach-visws/setup.c
@@ -140,8 +140,8 @@ void __init time_init_hook(void)
140 140
141#define MB (1024 * 1024) 141#define MB (1024 * 1024)
142 142
143static unsigned long sgivwfb_mem_phys; 143unsigned long sgivwfb_mem_phys;
144static unsigned long sgivwfb_mem_size; 144unsigned long sgivwfb_mem_size;
145 145
146long long mem_size __initdata = 0; 146long long mem_size __initdata = 0;
147 147
@@ -177,8 +177,4 @@ char * __init machine_specific_memory_setup(void)
177 add_memory_region(sgivwfb_mem_phys, sgivwfb_mem_size, E820_RESERVED); 177 add_memory_region(sgivwfb_mem_phys, sgivwfb_mem_size, E820_RESERVED);
178 178
179 return "PROM"; 179 return "PROM";
180
181 /* Remove gcc warnings */
182 (void) sanitize_e820_map(NULL, NULL);
183 (void) copy_e820_map(NULL, 0);
184} 180}
diff --git a/arch/i386/mach-visws/visws_apic.c b/arch/i386/mach-visws/visws_apic.c
index 3e64fb721291..c418521dd554 100644
--- a/arch/i386/mach-visws/visws_apic.c
+++ b/arch/i386/mach-visws/visws_apic.c
@@ -278,22 +278,22 @@ void init_VISWS_APIC_irqs(void)
278 irq_desc[i].depth = 1; 278 irq_desc[i].depth = 1;
279 279
280 if (i == 0) { 280 if (i == 0) {
281 irq_desc[i].handler = &cobalt_irq_type; 281 irq_desc[i].chip = &cobalt_irq_type;
282 } 282 }
283 else if (i == CO_IRQ_IDE0) { 283 else if (i == CO_IRQ_IDE0) {
284 irq_desc[i].handler = &cobalt_irq_type; 284 irq_desc[i].chip = &cobalt_irq_type;
285 } 285 }
286 else if (i == CO_IRQ_IDE1) { 286 else if (i == CO_IRQ_IDE1) {
287 irq_desc[i].handler = &cobalt_irq_type; 287 irq_desc[i].chip = &cobalt_irq_type;
288 } 288 }
289 else if (i == CO_IRQ_8259) { 289 else if (i == CO_IRQ_8259) {
290 irq_desc[i].handler = &piix4_master_irq_type; 290 irq_desc[i].chip = &piix4_master_irq_type;
291 } 291 }
292 else if (i < CO_IRQ_APIC0) { 292 else if (i < CO_IRQ_APIC0) {
293 irq_desc[i].handler = &piix4_virtual_irq_type; 293 irq_desc[i].chip = &piix4_virtual_irq_type;
294 } 294 }
295 else if (IS_CO_APIC(i)) { 295 else if (IS_CO_APIC(i)) {
296 irq_desc[i].handler = &cobalt_irq_type; 296 irq_desc[i].chip = &cobalt_irq_type;
297 } 297 }
298 } 298 }
299 299
diff --git a/arch/i386/mach-voyager/setup.c b/arch/i386/mach-voyager/setup.c
index 0e225054e222..defc6ebbd565 100644
--- a/arch/i386/mach-voyager/setup.c
+++ b/arch/i386/mach-voyager/setup.c
@@ -5,10 +5,10 @@
5#include <linux/config.h> 5#include <linux/config.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/interrupt.h> 7#include <linux/interrupt.h>
8#include <asm/acpi.h>
9#include <asm/arch_hooks.h> 8#include <asm/arch_hooks.h>
10#include <asm/voyager.h> 9#include <asm/voyager.h>
11#include <asm/e820.h> 10#include <asm/e820.h>
11#include <asm/io.h>
12#include <asm/setup.h> 12#include <asm/setup.h>
13 13
14void __init pre_intr_init_hook(void) 14void __init pre_intr_init_hook(void)
@@ -27,8 +27,7 @@ void __init intr_init_hook(void)
27 smp_intr_init(); 27 smp_intr_init();
28#endif 28#endif
29 29
30 if (!acpi_ioapic) 30 setup_irq(2, &irq2);
31 setup_irq(2, &irq2);
32} 31}
33 32
34void __init pre_setup_arch_hook(void) 33void __init pre_setup_arch_hook(void)
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index 70e560a1b79a..5b8b579a079f 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -661,6 +661,7 @@ do_boot_cpu(__u8 cpu)
661 print_cpu_info(&cpu_data[cpu]); 661 print_cpu_info(&cpu_data[cpu]);
662 wmb(); 662 wmb();
663 cpu_set(cpu, cpu_callout_map); 663 cpu_set(cpu, cpu_callout_map);
664 cpu_set(cpu, cpu_present_map);
664 } 665 }
665 else { 666 else {
666 printk("CPU%d FAILED TO BOOT: ", cpu); 667 printk("CPU%d FAILED TO BOOT: ", cpu);
@@ -1418,7 +1419,7 @@ smp_intr_init(void)
1418 * This is for later: first 16 correspond to PC IRQs; next 16 1419 * This is for later: first 16 correspond to PC IRQs; next 16
1419 * are Primary MC IRQs and final 16 are Secondary MC IRQs */ 1420 * are Primary MC IRQs and final 16 are Secondary MC IRQs */
1420 for(i = 0; i < 48; i++) 1421 for(i = 0; i < 48; i++)
1421 irq_desc[i].handler = &vic_irq_type; 1422 irq_desc[i].chip = &vic_irq_type;
1422} 1423}
1423 1424
1424/* send a CPI at level cpi to a set of cpus in cpuset (set 1 bit per 1425/* send a CPI at level cpi to a set of cpus in cpuset (set 1 bit per
@@ -1912,6 +1913,7 @@ void __devinit smp_prepare_boot_cpu(void)
1912 cpu_set(smp_processor_id(), cpu_online_map); 1913 cpu_set(smp_processor_id(), cpu_online_map);
1913 cpu_set(smp_processor_id(), cpu_callout_map); 1914 cpu_set(smp_processor_id(), cpu_callout_map);
1914 cpu_set(smp_processor_id(), cpu_possible_map); 1915 cpu_set(smp_processor_id(), cpu_possible_map);
1916 cpu_set(smp_processor_id(), cpu_present_map);
1915} 1917}
1916 1918
1917int __devinit 1919int __devinit
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index bf19513f0cea..f84b16e007ff 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/highmem.h> 24#include <linux/highmem.h>
25#include <linux/pagemap.h> 25#include <linux/pagemap.h>
26#include <linux/poison.h>
26#include <linux/bootmem.h> 27#include <linux/bootmem.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/proc_fs.h> 29#include <linux/proc_fs.h>
@@ -654,7 +655,7 @@ void __init mem_init(void)
654 */ 655 */
655#ifdef CONFIG_MEMORY_HOTPLUG 656#ifdef CONFIG_MEMORY_HOTPLUG
656#ifndef CONFIG_NEED_MULTIPLE_NODES 657#ifndef CONFIG_NEED_MULTIPLE_NODES
657int add_memory(u64 start, u64 size) 658int arch_add_memory(int nid, u64 start, u64 size)
658{ 659{
659 struct pglist_data *pgdata = &contig_page_data; 660 struct pglist_data *pgdata = &contig_page_data;
660 struct zone *zone = pgdata->node_zones + MAX_NR_ZONES-1; 661 struct zone *zone = pgdata->node_zones + MAX_NR_ZONES-1;
@@ -753,7 +754,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
753 for (addr = begin; addr < end; addr += PAGE_SIZE) { 754 for (addr = begin; addr < end; addr += PAGE_SIZE) {
754 ClearPageReserved(virt_to_page(addr)); 755 ClearPageReserved(virt_to_page(addr));
755 init_page_count(virt_to_page(addr)); 756 init_page_count(virt_to_page(addr));
756 memset((void *)addr, 0xcc, PAGE_SIZE); 757 memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
757 free_page(addr); 758 free_page(addr);
758 totalram_pages++; 759 totalram_pages++;
759 } 760 }
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
index 0887b34bc59b..353a836ed63c 100644
--- a/arch/i386/mm/pageattr.c
+++ b/arch/i386/mm/pageattr.c
@@ -229,8 +229,8 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
229 if (PageHighMem(page)) 229 if (PageHighMem(page))
230 return; 230 return;
231 if (!enable) 231 if (!enable)
232 mutex_debug_check_no_locks_freed(page_address(page), 232 debug_check_no_locks_freed(page_address(page),
233 numpages * PAGE_SIZE); 233 numpages * PAGE_SIZE);
234 234
235 /* the return value is ignored - the calls cannot fail, 235 /* the return value is ignored - the calls cannot fail,
236 * large pages are disabled at boot time. 236 * large pages are disabled at boot time.
diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
index a151f7a99f5e..10154a2cac68 100644
--- a/arch/i386/pci/i386.c
+++ b/arch/i386/pci/i386.c
@@ -48,10 +48,10 @@
48 */ 48 */
49void 49void
50pcibios_align_resource(void *data, struct resource *res, 50pcibios_align_resource(void *data, struct resource *res,
51 unsigned long size, unsigned long align) 51 resource_size_t size, resource_size_t align)
52{ 52{
53 if (res->flags & IORESOURCE_IO) { 53 if (res->flags & IORESOURCE_IO) {
54 unsigned long start = res->start; 54 resource_size_t start = res->start;
55 55
56 if (start & 0x300) { 56 if (start & 0x300) {
57 start = (start + 0x3ff) & ~0x3ff; 57 start = (start + 0x3ff) & ~0x3ff;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 18318749884b..b487e227a1f7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -271,6 +271,9 @@ config HOTPLUG_CPU
271 can be controlled through /sys/devices/system/cpu/cpu#. 271 can be controlled through /sys/devices/system/cpu/cpu#.
272 Say N if you want to disable CPU hotplug. 272 Say N if you want to disable CPU hotplug.
273 273
274config ARCH_ENABLE_MEMORY_HOTPLUG
275 def_bool y
276
274config SCHED_SMT 277config SCHED_SMT
275 bool "SMT scheduler support" 278 bool "SMT scheduler support"
276 depends on SMP 279 depends on SMP
@@ -374,6 +377,10 @@ config HAVE_ARCH_EARLY_PFN_TO_NID
374 def_bool y 377 def_bool y
375 depends on NEED_MULTIPLE_NODES 378 depends on NEED_MULTIPLE_NODES
376 379
380config HAVE_ARCH_NODEDATA_EXTENSION
381 def_bool y
382 depends on NUMA
383
377config IA32_SUPPORT 384config IA32_SUPPORT
378 bool "Support for Linux/x86 binaries" 385 bool "Support for Linux/x86 binaries"
379 help 386 help
@@ -485,6 +492,10 @@ config GENERIC_PENDING_IRQ
485 depends on GENERIC_HARDIRQS && SMP 492 depends on GENERIC_HARDIRQS && SMP
486 default y 493 default y
487 494
495config IRQ_PER_CPU
496 bool
497 default y
498
488source "arch/ia64/hp/sim/Kconfig" 499source "arch/ia64/hp/sim/Kconfig"
489 500
490menu "Instrumentation Support" 501menu "Instrumentation Support"
diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig
index 766bf4955432..9d1cffb57cde 100644
--- a/arch/ia64/configs/tiger_defconfig
+++ b/arch/ia64/configs/tiger_defconfig
@@ -114,7 +114,7 @@ CONFIG_IA64_CYCLONE=y
114CONFIG_IOSAPIC=y 114CONFIG_IOSAPIC=y
115CONFIG_FORCE_MAX_ZONEORDER=17 115CONFIG_FORCE_MAX_ZONEORDER=17
116CONFIG_SMP=y 116CONFIG_SMP=y
117CONFIG_NR_CPUS=4 117CONFIG_NR_CPUS=16
118CONFIG_HOTPLUG_CPU=y 118CONFIG_HOTPLUG_CPU=y
119CONFIG_PERMIT_BSP_REMOVE=y 119CONFIG_PERMIT_BSP_REMOVE=y
120CONFIG_FORCE_CPEI_RETARGET=y 120CONFIG_FORCE_CPEI_RETARGET=y
diff --git a/arch/ia64/hp/sim/hpsim_irq.c b/arch/ia64/hp/sim/hpsim_irq.c
index c0d25a2a3e9c..8145547bb52d 100644
--- a/arch/ia64/hp/sim/hpsim_irq.c
+++ b/arch/ia64/hp/sim/hpsim_irq.c
@@ -44,8 +44,8 @@ hpsim_irq_init (void)
44 int i; 44 int i;
45 45
46 for (i = 0; i < NR_IRQS; ++i) { 46 for (i = 0; i < NR_IRQS; ++i) {
47 idesc = irq_descp(i); 47 idesc = irq_desc + i;
48 if (idesc->handler == &no_irq_type) 48 if (idesc->chip == &no_irq_type)
49 idesc->handler = &irq_type_hp_sim; 49 idesc->chip = &irq_type_hp_sim;
50 } 50 }
51} 51}
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index d58c1c5c903a..efc7df4b0fd2 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -456,7 +456,7 @@ iosapic_startup_edge_irq (unsigned int irq)
456static void 456static void
457iosapic_ack_edge_irq (unsigned int irq) 457iosapic_ack_edge_irq (unsigned int irq)
458{ 458{
459 irq_desc_t *idesc = irq_descp(irq); 459 irq_desc_t *idesc = irq_desc + irq;
460 460
461 move_native_irq(irq); 461 move_native_irq(irq);
462 /* 462 /*
@@ -659,14 +659,14 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
659 else 659 else
660 irq_type = &irq_type_iosapic_level; 660 irq_type = &irq_type_iosapic_level;
661 661
662 idesc = irq_descp(vector); 662 idesc = irq_desc + vector;
663 if (idesc->handler != irq_type) { 663 if (idesc->chip != irq_type) {
664 if (idesc->handler != &no_irq_type) 664 if (idesc->chip != &no_irq_type)
665 printk(KERN_WARNING 665 printk(KERN_WARNING
666 "%s: changing vector %d from %s to %s\n", 666 "%s: changing vector %d from %s to %s\n",
667 __FUNCTION__, vector, 667 __FUNCTION__, vector,
668 idesc->handler->typename, irq_type->typename); 668 idesc->chip->typename, irq_type->typename);
669 idesc->handler = irq_type; 669 idesc->chip = irq_type;
670 } 670 }
671 return 0; 671 return 0;
672} 672}
@@ -793,14 +793,14 @@ again:
793 return -ENOSPC; 793 return -ENOSPC;
794 } 794 }
795 795
796 spin_lock_irqsave(&irq_descp(vector)->lock, flags); 796 spin_lock_irqsave(&irq_desc[vector].lock, flags);
797 spin_lock(&iosapic_lock); 797 spin_lock(&iosapic_lock);
798 { 798 {
799 if (gsi_to_vector(gsi) > 0) { 799 if (gsi_to_vector(gsi) > 0) {
800 if (list_empty(&iosapic_intr_info[vector].rtes)) 800 if (list_empty(&iosapic_intr_info[vector].rtes))
801 free_irq_vector(vector); 801 free_irq_vector(vector);
802 spin_unlock(&iosapic_lock); 802 spin_unlock(&iosapic_lock);
803 spin_unlock_irqrestore(&irq_descp(vector)->lock, 803 spin_unlock_irqrestore(&irq_desc[vector].lock,
804 flags); 804 flags);
805 goto again; 805 goto again;
806 } 806 }
@@ -810,7 +810,7 @@ again:
810 polarity, trigger); 810 polarity, trigger);
811 if (err < 0) { 811 if (err < 0) {
812 spin_unlock(&iosapic_lock); 812 spin_unlock(&iosapic_lock);
813 spin_unlock_irqrestore(&irq_descp(vector)->lock, 813 spin_unlock_irqrestore(&irq_desc[vector].lock,
814 flags); 814 flags);
815 return err; 815 return err;
816 } 816 }
@@ -825,7 +825,7 @@ again:
825 set_rte(gsi, vector, dest, mask); 825 set_rte(gsi, vector, dest, mask);
826 } 826 }
827 spin_unlock(&iosapic_lock); 827 spin_unlock(&iosapic_lock);
828 spin_unlock_irqrestore(&irq_descp(vector)->lock, flags); 828 spin_unlock_irqrestore(&irq_desc[vector].lock, flags);
829 829
830 printk(KERN_INFO "GSI %u (%s, %s) -> CPU %d (0x%04x) vector %d\n", 830 printk(KERN_INFO "GSI %u (%s, %s) -> CPU %d (0x%04x) vector %d\n",
831 gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"), 831 gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"),
@@ -860,7 +860,7 @@ iosapic_unregister_intr (unsigned int gsi)
860 } 860 }
861 vector = irq_to_vector(irq); 861 vector = irq_to_vector(irq);
862 862
863 idesc = irq_descp(irq); 863 idesc = irq_desc + irq;
864 spin_lock_irqsave(&idesc->lock, flags); 864 spin_lock_irqsave(&idesc->lock, flags);
865 spin_lock(&iosapic_lock); 865 spin_lock(&iosapic_lock);
866 { 866 {
@@ -903,7 +903,7 @@ iosapic_unregister_intr (unsigned int gsi)
903 BUG_ON(iosapic_intr_info[vector].count); 903 BUG_ON(iosapic_intr_info[vector].count);
904 904
905 /* Clear the interrupt controller descriptor */ 905 /* Clear the interrupt controller descriptor */
906 idesc->handler = &no_irq_type; 906 idesc->chip = &no_irq_type;
907 907
908 /* Clear the interrupt information */ 908 /* Clear the interrupt information */
909 memset(&iosapic_intr_info[vector], 0, 909 memset(&iosapic_intr_info[vector], 0,
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
index 9c72ea3f6432..7852382de2fa 100644
--- a/arch/ia64/kernel/irq.c
+++ b/arch/ia64/kernel/irq.c
@@ -76,7 +76,7 @@ int show_interrupts(struct seq_file *p, void *v)
76 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 76 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
77 } 77 }
78#endif 78#endif
79 seq_printf(p, " %14s", irq_desc[i].handler->typename); 79 seq_printf(p, " %14s", irq_desc[i].chip->typename);
80 seq_printf(p, " %s", action->name); 80 seq_printf(p, " %s", action->name);
81 81
82 for (action=action->next; action; action = action->next) 82 for (action=action->next; action; action = action->next)
@@ -100,7 +100,7 @@ void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
100 cpu_set(cpu_logical_id(hwid), mask); 100 cpu_set(cpu_logical_id(hwid), mask);
101 101
102 if (irq < NR_IRQS) { 102 if (irq < NR_IRQS) {
103 irq_affinity[irq] = mask; 103 irq_desc[irq].affinity = mask;
104 irq_redir[irq] = (char) (redir & 0xff); 104 irq_redir[irq] = (char) (redir & 0xff);
105 } 105 }
106} 106}
@@ -120,7 +120,7 @@ static void migrate_irqs(void)
120 int irq, new_cpu; 120 int irq, new_cpu;
121 121
122 for (irq=0; irq < NR_IRQS; irq++) { 122 for (irq=0; irq < NR_IRQS; irq++) {
123 desc = irq_descp(irq); 123 desc = irq_desc + irq;
124 124
125 /* 125 /*
126 * No handling for now. 126 * No handling for now.
@@ -131,7 +131,7 @@ static void migrate_irqs(void)
131 if (desc->status == IRQ_PER_CPU) 131 if (desc->status == IRQ_PER_CPU)
132 continue; 132 continue;
133 133
134 cpus_and(mask, irq_affinity[irq], cpu_online_map); 134 cpus_and(mask, irq_desc[irq].affinity, cpu_online_map);
135 if (any_online_cpu(mask) == NR_CPUS) { 135 if (any_online_cpu(mask) == NR_CPUS) {
136 /* 136 /*
137 * Save it for phase 2 processing 137 * Save it for phase 2 processing
@@ -144,15 +144,15 @@ static void migrate_irqs(void)
144 /* 144 /*
145 * Al three are essential, currently WARN_ON.. maybe panic? 145 * Al three are essential, currently WARN_ON.. maybe panic?
146 */ 146 */
147 if (desc->handler && desc->handler->disable && 147 if (desc->chip && desc->chip->disable &&
148 desc->handler->enable && desc->handler->set_affinity) { 148 desc->chip->enable && desc->chip->set_affinity) {
149 desc->handler->disable(irq); 149 desc->chip->disable(irq);
150 desc->handler->set_affinity(irq, mask); 150 desc->chip->set_affinity(irq, mask);
151 desc->handler->enable(irq); 151 desc->chip->enable(irq);
152 } else { 152 } else {
153 WARN_ON((!(desc->handler) || !(desc->handler->disable) || 153 WARN_ON((!(desc->chip) || !(desc->chip->disable) ||
154 !(desc->handler->enable) || 154 !(desc->chip->enable) ||
155 !(desc->handler->set_affinity))); 155 !(desc->chip->set_affinity)));
156 } 156 }
157 } 157 }
158 } 158 }
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index ef9a2b49307a..f5035304594e 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -249,9 +249,9 @@ register_percpu_irq (ia64_vector vec, struct irqaction *action)
249 249
250 for (irq = 0; irq < NR_IRQS; ++irq) 250 for (irq = 0; irq < NR_IRQS; ++irq)
251 if (irq_to_vector(irq) == vec) { 251 if (irq_to_vector(irq) == vec) {
252 desc = irq_descp(irq); 252 desc = irq_desc + irq;
253 desc->status |= IRQ_PER_CPU; 253 desc->status |= IRQ_PER_CPU;
254 desc->handler = &irq_type_ia64_lsapic; 254 desc->chip = &irq_type_ia64_lsapic;
255 if (action) 255 if (action)
256 setup_irq(irq, action); 256 setup_irq(irq, action);
257 } 257 }
diff --git a/arch/ia64/kernel/irq_lsapic.c b/arch/ia64/kernel/irq_lsapic.c
index ea14e6a04409..1ab58b09f3d7 100644
--- a/arch/ia64/kernel/irq_lsapic.c
+++ b/arch/ia64/kernel/irq_lsapic.c
@@ -26,6 +26,13 @@ lsapic_noop (unsigned int irq)
26 /* nuthing to do... */ 26 /* nuthing to do... */
27} 27}
28 28
29static int lsapic_retrigger(unsigned int irq)
30{
31 ia64_resend_irq(irq);
32
33 return 1;
34}
35
29struct hw_interrupt_type irq_type_ia64_lsapic = { 36struct hw_interrupt_type irq_type_ia64_lsapic = {
30 .typename = "LSAPIC", 37 .typename = "LSAPIC",
31 .startup = lsapic_noop_startup, 38 .startup = lsapic_noop_startup,
@@ -33,5 +40,6 @@ struct hw_interrupt_type irq_type_ia64_lsapic = {
33 .enable = lsapic_noop, 40 .enable = lsapic_noop,
34 .disable = lsapic_noop, 41 .disable = lsapic_noop,
35 .ack = lsapic_noop, 42 .ack = lsapic_noop,
36 .end = lsapic_noop 43 .end = lsapic_noop,
44 .retrigger = lsapic_retrigger,
37}; 45};
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 6a0880639bc9..d7dc5e63de63 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1788,7 +1788,7 @@ ia64_mca_late_init(void)
1788 cpe_poll_enabled = 0; 1788 cpe_poll_enabled = 0;
1789 for (irq = 0; irq < NR_IRQS; ++irq) 1789 for (irq = 0; irq < NR_IRQS; ++irq)
1790 if (irq_to_vector(irq) == cpe_vector) { 1790 if (irq_to_vector(irq) == cpe_vector) {
1791 desc = irq_descp(irq); 1791 desc = irq_desc + irq;
1792 desc->status |= IRQ_PER_CPU; 1792 desc->status |= IRQ_PER_CPU;
1793 setup_irq(irq, &mca_cpe_irqaction); 1793 setup_irq(irq, &mca_cpe_irqaction);
1794 ia64_cpe_irq = irq; 1794 ia64_cpe_irq = irq;
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index 859fb37ff49b..8a1208419138 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -959,7 +959,7 @@ remove_palinfo_proc_entries(unsigned int hcpu)
959 } 959 }
960} 960}
961 961
962static int palinfo_cpu_callback(struct notifier_block *nfb, 962static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
963 unsigned long action, 963 unsigned long action,
964 void *hcpu) 964 void *hcpu)
965{ 965{
@@ -978,7 +978,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
978 return NOTIFY_OK; 978 return NOTIFY_OK;
979} 979}
980 980
981static struct notifier_block palinfo_cpu_notifier = 981static struct notifier_block __cpuinitdata palinfo_cpu_notifier =
982{ 982{
983 .notifier_call = palinfo_cpu_callback, 983 .notifier_call = palinfo_cpu_callback,
984 .priority = 0, 984 .priority = 0,
@@ -998,7 +998,7 @@ palinfo_init(void)
998 } 998 }
999 999
1000 /* Register for future delivery via notify registration */ 1000 /* Register for future delivery via notify registration */
1001 register_cpu_notifier(&palinfo_cpu_notifier); 1001 register_hotcpu_notifier(&palinfo_cpu_notifier);
1002 1002
1003 return 0; 1003 return 0;
1004} 1004}
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 6d7bc8ff7b3a..a0055d3d695c 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -6165,7 +6165,7 @@ pfm_load_regs (struct task_struct *task)
6165 /* 6165 /*
6166 * will replay the PMU interrupt 6166 * will replay the PMU interrupt
6167 */ 6167 */
6168 if (need_irq_resend) hw_resend_irq(NULL, IA64_PERFMON_VECTOR); 6168 if (need_irq_resend) ia64_resend_irq(IA64_PERFMON_VECTOR);
6169 6169
6170 pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++; 6170 pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++;
6171 } 6171 }
@@ -6305,7 +6305,7 @@ pfm_load_regs (struct task_struct *task)
6305 /* 6305 /*
6306 * will replay the PMU interrupt 6306 * will replay the PMU interrupt
6307 */ 6307 */
6308 if (need_irq_resend) hw_resend_irq(NULL, IA64_PERFMON_VECTOR); 6308 if (need_irq_resend) ia64_resend_irq(IA64_PERFMON_VECTOR);
6309 6309
6310 pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++; 6310 pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++;
6311 } 6311 }
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 663a186ad194..9065f0f01ba3 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -572,7 +572,7 @@ static struct file_operations salinfo_data_fops = {
572}; 572};
573 573
574#ifdef CONFIG_HOTPLUG_CPU 574#ifdef CONFIG_HOTPLUG_CPU
575static int 575static int __devinit
576salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 576salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
577{ 577{
578 unsigned int i, cpu = (unsigned long)hcpu; 578 unsigned int i, cpu = (unsigned long)hcpu;
@@ -673,9 +673,7 @@ salinfo_init(void)
673 salinfo_timer.function = &salinfo_timeout; 673 salinfo_timer.function = &salinfo_timeout;
674 add_timer(&salinfo_timer); 674 add_timer(&salinfo_timer);
675 675
676#ifdef CONFIG_HOTPLUG_CPU 676 register_hotcpu_notifier(&salinfo_cpu_notifier);
677 register_cpu_notifier(&salinfo_cpu_notifier);
678#endif
679 677
680 return 0; 678 return 0;
681} 679}
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 44e9547878ac..5203df78f150 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -677,16 +677,16 @@ int migrate_platform_irqs(unsigned int cpu)
677 new_cpei_cpu = any_online_cpu(cpu_online_map); 677 new_cpei_cpu = any_online_cpu(cpu_online_map);
678 mask = cpumask_of_cpu(new_cpei_cpu); 678 mask = cpumask_of_cpu(new_cpei_cpu);
679 set_cpei_target_cpu(new_cpei_cpu); 679 set_cpei_target_cpu(new_cpei_cpu);
680 desc = irq_descp(ia64_cpe_irq); 680 desc = irq_desc + ia64_cpe_irq;
681 /* 681 /*
682 * Switch for now, immediatly, we need to do fake intr 682 * Switch for now, immediatly, we need to do fake intr
683 * as other interrupts, but need to study CPEI behaviour with 683 * as other interrupts, but need to study CPEI behaviour with
684 * polling before making changes. 684 * polling before making changes.
685 */ 685 */
686 if (desc) { 686 if (desc) {
687 desc->handler->disable(ia64_cpe_irq); 687 desc->chip->disable(ia64_cpe_irq);
688 desc->handler->set_affinity(ia64_cpe_irq, mask); 688 desc->chip->set_affinity(ia64_cpe_irq, mask);
689 desc->handler->enable(ia64_cpe_irq); 689 desc->chip->enable(ia64_cpe_irq);
690 printk ("Re-targetting CPEI to cpu %d\n", new_cpei_cpu); 690 printk ("Re-targetting CPEI to cpu %d\n", new_cpei_cpu);
691 } 691 }
692 } 692 }
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 879edb51d1e0..5511d9c6c701 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -26,19 +26,10 @@
26#include <asm/numa.h> 26#include <asm/numa.h>
27#include <asm/cpu.h> 27#include <asm/cpu.h>
28 28
29#ifdef CONFIG_NUMA
30static struct node *sysfs_nodes;
31#endif
32static struct ia64_cpu *sysfs_cpus; 29static struct ia64_cpu *sysfs_cpus;
33 30
34int arch_register_cpu(int num) 31int arch_register_cpu(int num)
35{ 32{
36 struct node *parent = NULL;
37
38#ifdef CONFIG_NUMA
39 parent = &sysfs_nodes[cpu_to_node(num)];
40#endif /* CONFIG_NUMA */
41
42#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) 33#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
43 /* 34 /*
44 * If CPEI cannot be re-targetted, and this is 35 * If CPEI cannot be re-targetted, and this is
@@ -48,21 +39,14 @@ int arch_register_cpu(int num)
48 sysfs_cpus[num].cpu.no_control = 1; 39 sysfs_cpus[num].cpu.no_control = 1;
49#endif 40#endif
50 41
51 return register_cpu(&sysfs_cpus[num].cpu, num, parent); 42 return register_cpu(&sysfs_cpus[num].cpu, num);
52} 43}
53 44
54#ifdef CONFIG_HOTPLUG_CPU 45#ifdef CONFIG_HOTPLUG_CPU
55 46
56void arch_unregister_cpu(int num) 47void arch_unregister_cpu(int num)
57{ 48{
58 struct node *parent = NULL; 49 return unregister_cpu(&sysfs_cpus[num].cpu);
59
60#ifdef CONFIG_NUMA
61 int node = cpu_to_node(num);
62 parent = &sysfs_nodes[node];
63#endif /* CONFIG_NUMA */
64
65 return unregister_cpu(&sysfs_cpus[num].cpu, parent);
66} 50}
67EXPORT_SYMBOL(arch_register_cpu); 51EXPORT_SYMBOL(arch_register_cpu);
68EXPORT_SYMBOL(arch_unregister_cpu); 52EXPORT_SYMBOL(arch_unregister_cpu);
@@ -74,17 +58,11 @@ static int __init topology_init(void)
74 int i, err = 0; 58 int i, err = 0;
75 59
76#ifdef CONFIG_NUMA 60#ifdef CONFIG_NUMA
77 sysfs_nodes = kzalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL);
78 if (!sysfs_nodes) {
79 err = -ENOMEM;
80 goto out;
81 }
82
83 /* 61 /*
84 * MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? 62 * MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes?
85 */ 63 */
86 for_each_online_node(i) { 64 for_each_online_node(i) {
87 if ((err = register_node(&sysfs_nodes[i], i, 0))) 65 if ((err = register_one_node(i)))
88 goto out; 66 goto out;
89 } 67 }
90#endif 68#endif
@@ -426,7 +404,7 @@ static int __cpuinit cache_remove_dev(struct sys_device * sys_dev)
426 * When a cpu is hot-plugged, do a check and initiate 404 * When a cpu is hot-plugged, do a check and initiate
427 * cache kobject if necessary 405 * cache kobject if necessary
428 */ 406 */
429static int cache_cpu_callback(struct notifier_block *nfb, 407static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
430 unsigned long action, void *hcpu) 408 unsigned long action, void *hcpu)
431{ 409{
432 unsigned int cpu = (unsigned long)hcpu; 410 unsigned int cpu = (unsigned long)hcpu;
@@ -444,7 +422,7 @@ static int cache_cpu_callback(struct notifier_block *nfb,
444 return NOTIFY_OK; 422 return NOTIFY_OK;
445} 423}
446 424
447static struct notifier_block cache_cpu_notifier = 425static struct notifier_block __cpuinitdata cache_cpu_notifier =
448{ 426{
449 .notifier_call = cache_cpu_callback 427 .notifier_call = cache_cpu_callback
450}; 428};
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index b6bcc9fa3603..525b082eb661 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -33,7 +33,6 @@
33 */ 33 */
34struct early_node_data { 34struct early_node_data {
35 struct ia64_node_data *node_data; 35 struct ia64_node_data *node_data;
36 pg_data_t *pgdat;
37 unsigned long pernode_addr; 36 unsigned long pernode_addr;
38 unsigned long pernode_size; 37 unsigned long pernode_size;
39 struct bootmem_data bootmem_data; 38 struct bootmem_data bootmem_data;
@@ -46,6 +45,8 @@ struct early_node_data {
46static struct early_node_data mem_data[MAX_NUMNODES] __initdata; 45static struct early_node_data mem_data[MAX_NUMNODES] __initdata;
47static nodemask_t memory_less_mask __initdata; 46static nodemask_t memory_less_mask __initdata;
48 47
48static pg_data_t *pgdat_list[MAX_NUMNODES];
49
49/* 50/*
50 * To prevent cache aliasing effects, align per-node structures so that they 51 * To prevent cache aliasing effects, align per-node structures so that they
51 * start at addresses that are strided by node number. 52 * start at addresses that are strided by node number.
@@ -99,7 +100,7 @@ static int __init build_node_maps(unsigned long start, unsigned long len,
99 * acpi_boot_init() (which builds the node_to_cpu_mask array) hasn't been 100 * acpi_boot_init() (which builds the node_to_cpu_mask array) hasn't been
100 * called yet. Note that node 0 will also count all non-existent cpus. 101 * called yet. Note that node 0 will also count all non-existent cpus.
101 */ 102 */
102static int __init early_nr_cpus_node(int node) 103static int __meminit early_nr_cpus_node(int node)
103{ 104{
104 int cpu, n = 0; 105 int cpu, n = 0;
105 106
@@ -114,7 +115,7 @@ static int __init early_nr_cpus_node(int node)
114 * compute_pernodesize - compute size of pernode data 115 * compute_pernodesize - compute size of pernode data
115 * @node: the node id. 116 * @node: the node id.
116 */ 117 */
117static unsigned long __init compute_pernodesize(int node) 118static unsigned long __meminit compute_pernodesize(int node)
118{ 119{
119 unsigned long pernodesize = 0, cpus; 120 unsigned long pernodesize = 0, cpus;
120 121
@@ -175,13 +176,13 @@ static void __init fill_pernode(int node, unsigned long pernode,
175 pernode += PERCPU_PAGE_SIZE * cpus; 176 pernode += PERCPU_PAGE_SIZE * cpus;
176 pernode += node * L1_CACHE_BYTES; 177 pernode += node * L1_CACHE_BYTES;
177 178
178 mem_data[node].pgdat = __va(pernode); 179 pgdat_list[node] = __va(pernode);
179 pernode += L1_CACHE_ALIGN(sizeof(pg_data_t)); 180 pernode += L1_CACHE_ALIGN(sizeof(pg_data_t));
180 181
181 mem_data[node].node_data = __va(pernode); 182 mem_data[node].node_data = __va(pernode);
182 pernode += L1_CACHE_ALIGN(sizeof(struct ia64_node_data)); 183 pernode += L1_CACHE_ALIGN(sizeof(struct ia64_node_data));
183 184
184 mem_data[node].pgdat->bdata = bdp; 185 pgdat_list[node]->bdata = bdp;
185 pernode += L1_CACHE_ALIGN(sizeof(pg_data_t)); 186 pernode += L1_CACHE_ALIGN(sizeof(pg_data_t));
186 187
187 cpu_data = per_cpu_node_setup(cpu_data, node); 188 cpu_data = per_cpu_node_setup(cpu_data, node);
@@ -268,7 +269,7 @@ static int __init find_pernode_space(unsigned long start, unsigned long len,
268static int __init free_node_bootmem(unsigned long start, unsigned long len, 269static int __init free_node_bootmem(unsigned long start, unsigned long len,
269 int node) 270 int node)
270{ 271{
271 free_bootmem_node(mem_data[node].pgdat, start, len); 272 free_bootmem_node(pgdat_list[node], start, len);
272 273
273 return 0; 274 return 0;
274} 275}
@@ -287,7 +288,7 @@ static void __init reserve_pernode_space(void)
287 int node; 288 int node;
288 289
289 for_each_online_node(node) { 290 for_each_online_node(node) {
290 pg_data_t *pdp = mem_data[node].pgdat; 291 pg_data_t *pdp = pgdat_list[node];
291 292
292 if (node_isset(node, memory_less_mask)) 293 if (node_isset(node, memory_less_mask))
293 continue; 294 continue;
@@ -307,6 +308,17 @@ static void __init reserve_pernode_space(void)
307 } 308 }
308} 309}
309 310
311static void __meminit scatter_node_data(void)
312{
313 pg_data_t **dst;
314 int node;
315
316 for_each_online_node(node) {
317 dst = LOCAL_DATA_ADDR(pgdat_list[node])->pg_data_ptrs;
318 memcpy(dst, pgdat_list, sizeof(pgdat_list));
319 }
320}
321
310/** 322/**
311 * initialize_pernode_data - fixup per-cpu & per-node pointers 323 * initialize_pernode_data - fixup per-cpu & per-node pointers
312 * 324 *
@@ -317,17 +329,10 @@ static void __init reserve_pernode_space(void)
317 */ 329 */
318static void __init initialize_pernode_data(void) 330static void __init initialize_pernode_data(void)
319{ 331{
320 pg_data_t *pgdat_list[MAX_NUMNODES];
321 int cpu, node; 332 int cpu, node;
322 333
323 for_each_online_node(node) 334 scatter_node_data();
324 pgdat_list[node] = mem_data[node].pgdat;
325 335
326 /* Copy the pg_data_t list to each node and init the node field */
327 for_each_online_node(node) {
328 memcpy(mem_data[node].node_data->pg_data_ptrs, pgdat_list,
329 sizeof(pgdat_list));
330 }
331#ifdef CONFIG_SMP 336#ifdef CONFIG_SMP
332 /* Set the node_data pointer for each per-cpu struct */ 337 /* Set the node_data pointer for each per-cpu struct */
333 for (cpu = 0; cpu < NR_CPUS; cpu++) { 338 for (cpu = 0; cpu < NR_CPUS; cpu++) {
@@ -372,7 +377,7 @@ static void __init *memory_less_node_alloc(int nid, unsigned long pernodesize)
372 if (bestnode == -1) 377 if (bestnode == -1)
373 bestnode = anynode; 378 bestnode = anynode;
374 379
375 ptr = __alloc_bootmem_node(mem_data[bestnode].pgdat, pernodesize, 380 ptr = __alloc_bootmem_node(pgdat_list[bestnode], pernodesize,
376 PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); 381 PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
377 382
378 return ptr; 383 return ptr;
@@ -476,7 +481,7 @@ void __init find_memory(void)
476 pernodesize = mem_data[node].pernode_size; 481 pernodesize = mem_data[node].pernode_size;
477 map = pernode + pernodesize; 482 map = pernode + pernodesize;
478 483
479 init_bootmem_node(mem_data[node].pgdat, 484 init_bootmem_node(pgdat_list[node],
480 map>>PAGE_SHIFT, 485 map>>PAGE_SHIFT,
481 bdp->node_boot_start>>PAGE_SHIFT, 486 bdp->node_boot_start>>PAGE_SHIFT,
482 bdp->node_low_pfn); 487 bdp->node_low_pfn);
@@ -786,3 +791,21 @@ void __init paging_init(void)
786 791
787 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page)); 792 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
788} 793}
794
795pg_data_t *arch_alloc_nodedata(int nid)
796{
797 unsigned long size = compute_pernodesize(nid);
798
799 return kzalloc(size, GFP_KERNEL);
800}
801
802void arch_free_nodedata(pg_data_t *pgdat)
803{
804 kfree(pgdat);
805}
806
807void arch_refresh_nodedata(int update_node, pg_data_t *update_pgdat)
808{
809 pgdat_list[update_node] = update_pgdat;
810 scatter_node_data();
811}
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 11f08001f8c2..38306e98f04b 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -652,7 +652,7 @@ void online_page(struct page *page)
652 num_physpages++; 652 num_physpages++;
653} 653}
654 654
655int add_memory(u64 start, u64 size) 655int arch_add_memory(int nid, u64 start, u64 size)
656{ 656{
657 pg_data_t *pgdat; 657 pg_data_t *pgdat;
658 struct zone *zone; 658 struct zone *zone;
@@ -660,7 +660,7 @@ int add_memory(u64 start, u64 size)
660 unsigned long nr_pages = size >> PAGE_SHIFT; 660 unsigned long nr_pages = size >> PAGE_SHIFT;
661 int ret; 661 int ret;
662 662
663 pgdat = NODE_DATA(0); 663 pgdat = NODE_DATA(nid);
664 664
665 zone = pgdat->node_zones + ZONE_NORMAL; 665 zone = pgdat->node_zones + ZONE_NORMAL;
666 ret = __add_pages(zone, start_pfn, nr_pages); 666 ret = __add_pages(zone, start_pfn, nr_pages);
@@ -671,7 +671,6 @@ int add_memory(u64 start, u64 size)
671 671
672 return ret; 672 return ret;
673} 673}
674EXPORT_SYMBOL_GPL(add_memory);
675 674
676int remove_memory(u64 start, u64 size) 675int remove_memory(u64 start, u64 size)
677{ 676{
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 77375a55da31..5bef0e3603f2 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -568,7 +568,7 @@ pcibios_disable_device (struct pci_dev *dev)
568 568
569void 569void
570pcibios_align_resource (void *data, struct resource *res, 570pcibios_align_resource (void *data, struct resource *res,
571 unsigned long size, unsigned long align) 571 resource_size_t size, resource_size_t align)
572{ 572{
573} 573}
574 574
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index dc8e2b696713..7bb6ad188ba3 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -27,7 +27,7 @@ static void unregister_intr_pda(struct sn_irq_info *sn_irq_info);
27int sn_force_interrupt_flag = 1; 27int sn_force_interrupt_flag = 1;
28extern int sn_ioif_inited; 28extern int sn_ioif_inited;
29struct list_head **sn_irq_lh; 29struct list_head **sn_irq_lh;
30static spinlock_t sn_irq_info_lock = SPIN_LOCK_UNLOCKED; /* non-IRQ lock */ 30static DEFINE_SPINLOCK(sn_irq_info_lock); /* non-IRQ lock */
31 31
32u64 sn_intr_alloc(nasid_t local_nasid, int local_widget, 32u64 sn_intr_alloc(nasid_t local_nasid, int local_widget,
33 struct sn_irq_info *sn_irq_info, 33 struct sn_irq_info *sn_irq_info,
@@ -225,8 +225,8 @@ void sn_irq_init(void)
225 ia64_last_device_vector = IA64_SN2_LAST_DEVICE_VECTOR; 225 ia64_last_device_vector = IA64_SN2_LAST_DEVICE_VECTOR;
226 226
227 for (i = 0; i < NR_IRQS; i++) { 227 for (i = 0; i < NR_IRQS; i++) {
228 if (base_desc[i].handler == &no_irq_type) { 228 if (base_desc[i].chip == &no_irq_type) {
229 base_desc[i].handler = &irq_type_sn; 229 base_desc[i].chip = &irq_type_sn;
230 } 230 }
231 } 231 }
232} 232}
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index 93577abae36d..3bfccf354343 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -458,7 +458,7 @@ void __init sn_setup(char **cmdline_p)
458 * support here so we don't have to listen to failed keyboard probe 458 * support here so we don't have to listen to failed keyboard probe
459 * messages. 459 * messages.
460 */ 460 */
461 if (version <= 0x0209 && acpi_kbd_controller_present) { 461 if (is_shub1() && version <= 0x0209 && acpi_kbd_controller_present) {
462 printk(KERN_INFO "Disabling legacy keyboard support as prom " 462 printk(KERN_INFO "Disabling legacy keyboard support as prom "
463 "is too old and doesn't provide FADT\n"); 463 "is too old and doesn't provide FADT\n");
464 acpi_kbd_controller_present = 0; 464 acpi_kbd_controller_present = 0;
@@ -577,7 +577,8 @@ void __init sn_cpu_init(void)
577 int i; 577 int i;
578 static int wars_have_been_checked; 578 static int wars_have_been_checked;
579 579
580 if (smp_processor_id() == 0 && IS_MEDUSA()) { 580 cpuid = smp_processor_id();
581 if (cpuid == 0 && IS_MEDUSA()) {
581 if (ia64_sn_is_fake_prom()) 582 if (ia64_sn_is_fake_prom())
582 sn_prom_type = 2; 583 sn_prom_type = 2;
583 else 584 else
@@ -597,6 +598,12 @@ void __init sn_cpu_init(void)
597 sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2; 598 sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2;
598 599
599 /* 600 /*
601 * Don't check status. The SAL call is not supported on all PROMs
602 * but a failure is harmless.
603 */
604 (void) ia64_sn_set_cpu_number(cpuid);
605
606 /*
600 * The boot cpu makes this call again after platform initialization is 607 * The boot cpu makes this call again after platform initialization is
601 * complete. 608 * complete.
602 */ 609 */
@@ -607,7 +614,6 @@ void __init sn_cpu_init(void)
607 if (ia64_sn_get_prom_feature_set(i, &sn_prom_features[i]) != 0) 614 if (ia64_sn_get_prom_feature_set(i, &sn_prom_features[i]) != 0)
608 break; 615 break;
609 616
610 cpuid = smp_processor_id();
611 cpuphyid = get_sapicid(); 617 cpuphyid = get_sapicid();
612 618
613 if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice)) 619 if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice))
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index 20de72791b97..e4aa839d0189 100644
--- a/arch/ia64/sn/pci/tioca_provider.c
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -595,7 +595,7 @@ tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
595 595
596 /* sanity check prom rev */ 596 /* sanity check prom rev */
597 597
598 if (sn_sal_rev() < 0x0406) { 598 if (is_shub1() && sn_sal_rev() < 0x0406) {
599 printk 599 printk
600 (KERN_ERR "%s: SGI prom rev 4.06 or greater required " 600 (KERN_ERR "%s: SGI prom rev 4.06 or greater required "
601 "for tioca support\n", __FUNCTION__); 601 "for tioca support\n", __FUNCTION__);
diff --git a/arch/m32r/kernel/irq.c b/arch/m32r/kernel/irq.c
index a4634b06f675..3841861df6a2 100644
--- a/arch/m32r/kernel/irq.c
+++ b/arch/m32r/kernel/irq.c
@@ -54,7 +54,7 @@ int show_interrupts(struct seq_file *p, void *v)
54 for_each_online_cpu(j) 54 for_each_online_cpu(j)
55 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 55 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
56#endif 56#endif
57 seq_printf(p, " %14s", irq_desc[i].handler->typename); 57 seq_printf(p, " %14s", irq_desc[i].chip->typename);
58 seq_printf(p, " %s", action->name); 58 seq_printf(p, " %s", action->name);
59 59
60 for (action=action->next; action; action = action->next) 60 for (action=action->next; action; action = action->next)
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 3cd3c2988a48..1ff483c8a4c9 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -275,7 +275,7 @@ static int __init topology_init(void)
275 int i; 275 int i;
276 276
277 for_each_present_cpu(i) 277 for_each_present_cpu(i)
278 register_cpu(&cpu_devices[i], i, NULL); 278 register_cpu(&cpu_devices[i], i);
279 279
280 return 0; 280 return 0;
281} 281}
diff --git a/arch/m32r/kernel/setup_m32104ut.c b/arch/m32r/kernel/setup_m32104ut.c
index 6328e1357a80..f9f56c270195 100644
--- a/arch/m32r/kernel/setup_m32104ut.c
+++ b/arch/m32r/kernel/setup_m32104ut.c
@@ -87,7 +87,7 @@ void __init init_IRQ(void)
87#if defined(CONFIG_SMC91X) 87#if defined(CONFIG_SMC91X)
88 /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/ 88 /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/
89 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; 89 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
90 irq_desc[M32R_IRQ_INT0].handler = &m32104ut_irq_type; 90 irq_desc[M32R_IRQ_INT0].chip = &m32104ut_irq_type;
91 irq_desc[M32R_IRQ_INT0].action = 0; 91 irq_desc[M32R_IRQ_INT0].action = 0;
92 irq_desc[M32R_IRQ_INT0].depth = 1; 92 irq_desc[M32R_IRQ_INT0].depth = 1;
93 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11; /* "H" level sense */ 93 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11; /* "H" level sense */
@@ -96,7 +96,7 @@ void __init init_IRQ(void)
96 96
97 /* MFT2 : system timer */ 97 /* MFT2 : system timer */
98 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 98 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
99 irq_desc[M32R_IRQ_MFT2].handler = &m32104ut_irq_type; 99 irq_desc[M32R_IRQ_MFT2].chip = &m32104ut_irq_type;
100 irq_desc[M32R_IRQ_MFT2].action = 0; 100 irq_desc[M32R_IRQ_MFT2].action = 0;
101 irq_desc[M32R_IRQ_MFT2].depth = 1; 101 irq_desc[M32R_IRQ_MFT2].depth = 1;
102 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 102 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -105,7 +105,7 @@ void __init init_IRQ(void)
105#ifdef CONFIG_SERIAL_M32R_SIO 105#ifdef CONFIG_SERIAL_M32R_SIO
106 /* SIO0_R : uart receive data */ 106 /* SIO0_R : uart receive data */
107 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 107 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
108 irq_desc[M32R_IRQ_SIO0_R].handler = &m32104ut_irq_type; 108 irq_desc[M32R_IRQ_SIO0_R].chip = &m32104ut_irq_type;
109 irq_desc[M32R_IRQ_SIO0_R].action = 0; 109 irq_desc[M32R_IRQ_SIO0_R].action = 0;
110 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 110 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
111 icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN; 111 icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN;
@@ -113,7 +113,7 @@ void __init init_IRQ(void)
113 113
114 /* SIO0_S : uart send data */ 114 /* SIO0_S : uart send data */
115 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 115 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
116 irq_desc[M32R_IRQ_SIO0_S].handler = &m32104ut_irq_type; 116 irq_desc[M32R_IRQ_SIO0_S].chip = &m32104ut_irq_type;
117 irq_desc[M32R_IRQ_SIO0_S].action = 0; 117 irq_desc[M32R_IRQ_SIO0_S].action = 0;
118 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 118 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
119 icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN; 119 icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN;
diff --git a/arch/m32r/kernel/setup_m32700ut.c b/arch/m32r/kernel/setup_m32700ut.c
index fad1fc99bb27..b6ab00eff580 100644
--- a/arch/m32r/kernel/setup_m32700ut.c
+++ b/arch/m32r/kernel/setup_m32700ut.c
@@ -301,7 +301,7 @@ void __init init_IRQ(void)
301#if defined(CONFIG_SMC91X) 301#if defined(CONFIG_SMC91X)
302 /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/ 302 /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/
303 irq_desc[M32700UT_LAN_IRQ_LAN].status = IRQ_DISABLED; 303 irq_desc[M32700UT_LAN_IRQ_LAN].status = IRQ_DISABLED;
304 irq_desc[M32700UT_LAN_IRQ_LAN].handler = &m32700ut_lanpld_irq_type; 304 irq_desc[M32700UT_LAN_IRQ_LAN].chip = &m32700ut_lanpld_irq_type;
305 irq_desc[M32700UT_LAN_IRQ_LAN].action = 0; 305 irq_desc[M32700UT_LAN_IRQ_LAN].action = 0;
306 irq_desc[M32700UT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */ 306 irq_desc[M32700UT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */
307 lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */ 307 lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
@@ -310,7 +310,7 @@ void __init init_IRQ(void)
310 310
311 /* MFT2 : system timer */ 311 /* MFT2 : system timer */
312 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 312 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
313 irq_desc[M32R_IRQ_MFT2].handler = &m32700ut_irq_type; 313 irq_desc[M32R_IRQ_MFT2].chip = &m32700ut_irq_type;
314 irq_desc[M32R_IRQ_MFT2].action = 0; 314 irq_desc[M32R_IRQ_MFT2].action = 0;
315 irq_desc[M32R_IRQ_MFT2].depth = 1; 315 irq_desc[M32R_IRQ_MFT2].depth = 1;
316 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 316 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -318,7 +318,7 @@ void __init init_IRQ(void)
318 318
319 /* SIO0 : receive */ 319 /* SIO0 : receive */
320 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 320 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
321 irq_desc[M32R_IRQ_SIO0_R].handler = &m32700ut_irq_type; 321 irq_desc[M32R_IRQ_SIO0_R].chip = &m32700ut_irq_type;
322 irq_desc[M32R_IRQ_SIO0_R].action = 0; 322 irq_desc[M32R_IRQ_SIO0_R].action = 0;
323 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 323 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
324 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 324 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -326,7 +326,7 @@ void __init init_IRQ(void)
326 326
327 /* SIO0 : send */ 327 /* SIO0 : send */
328 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 328 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
329 irq_desc[M32R_IRQ_SIO0_S].handler = &m32700ut_irq_type; 329 irq_desc[M32R_IRQ_SIO0_S].chip = &m32700ut_irq_type;
330 irq_desc[M32R_IRQ_SIO0_S].action = 0; 330 irq_desc[M32R_IRQ_SIO0_S].action = 0;
331 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 331 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
332 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 332 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
@@ -334,7 +334,7 @@ void __init init_IRQ(void)
334 334
335 /* SIO1 : receive */ 335 /* SIO1 : receive */
336 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 336 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
337 irq_desc[M32R_IRQ_SIO1_R].handler = &m32700ut_irq_type; 337 irq_desc[M32R_IRQ_SIO1_R].chip = &m32700ut_irq_type;
338 irq_desc[M32R_IRQ_SIO1_R].action = 0; 338 irq_desc[M32R_IRQ_SIO1_R].action = 0;
339 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 339 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
340 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 340 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -342,7 +342,7 @@ void __init init_IRQ(void)
342 342
343 /* SIO1 : send */ 343 /* SIO1 : send */
344 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 344 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
345 irq_desc[M32R_IRQ_SIO1_S].handler = &m32700ut_irq_type; 345 irq_desc[M32R_IRQ_SIO1_S].chip = &m32700ut_irq_type;
346 irq_desc[M32R_IRQ_SIO1_S].action = 0; 346 irq_desc[M32R_IRQ_SIO1_S].action = 0;
347 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 347 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
348 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 348 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
@@ -350,7 +350,7 @@ void __init init_IRQ(void)
350 350
351 /* DMA1 : */ 351 /* DMA1 : */
352 irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED; 352 irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED;
353 irq_desc[M32R_IRQ_DMA1].handler = &m32700ut_irq_type; 353 irq_desc[M32R_IRQ_DMA1].chip = &m32700ut_irq_type;
354 irq_desc[M32R_IRQ_DMA1].action = 0; 354 irq_desc[M32R_IRQ_DMA1].action = 0;
355 irq_desc[M32R_IRQ_DMA1].depth = 1; 355 irq_desc[M32R_IRQ_DMA1].depth = 1;
356 icu_data[M32R_IRQ_DMA1].icucr = 0; 356 icu_data[M32R_IRQ_DMA1].icucr = 0;
@@ -359,7 +359,7 @@ void __init init_IRQ(void)
359#ifdef CONFIG_SERIAL_M32R_PLDSIO 359#ifdef CONFIG_SERIAL_M32R_PLDSIO
360 /* INT#1: SIO0 Receive on PLD */ 360 /* INT#1: SIO0 Receive on PLD */
361 irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED; 361 irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED;
362 irq_desc[PLD_IRQ_SIO0_RCV].handler = &m32700ut_pld_irq_type; 362 irq_desc[PLD_IRQ_SIO0_RCV].chip = &m32700ut_pld_irq_type;
363 irq_desc[PLD_IRQ_SIO0_RCV].action = 0; 363 irq_desc[PLD_IRQ_SIO0_RCV].action = 0;
364 irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */ 364 irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */
365 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; 365 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
@@ -367,7 +367,7 @@ void __init init_IRQ(void)
367 367
368 /* INT#1: SIO0 Send on PLD */ 368 /* INT#1: SIO0 Send on PLD */
369 irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED; 369 irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED;
370 irq_desc[PLD_IRQ_SIO0_SND].handler = &m32700ut_pld_irq_type; 370 irq_desc[PLD_IRQ_SIO0_SND].chip = &m32700ut_pld_irq_type;
371 irq_desc[PLD_IRQ_SIO0_SND].action = 0; 371 irq_desc[PLD_IRQ_SIO0_SND].action = 0;
372 irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */ 372 irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */
373 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; 373 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
@@ -376,7 +376,7 @@ void __init init_IRQ(void)
376 376
377 /* INT#1: CFC IREQ on PLD */ 377 /* INT#1: CFC IREQ on PLD */
378 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; 378 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
379 irq_desc[PLD_IRQ_CFIREQ].handler = &m32700ut_pld_irq_type; 379 irq_desc[PLD_IRQ_CFIREQ].chip = &m32700ut_pld_irq_type;
380 irq_desc[PLD_IRQ_CFIREQ].action = 0; 380 irq_desc[PLD_IRQ_CFIREQ].action = 0;
381 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ 381 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
382 pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */ 382 pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
@@ -384,7 +384,7 @@ void __init init_IRQ(void)
384 384
385 /* INT#1: CFC Insert on PLD */ 385 /* INT#1: CFC Insert on PLD */
386 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; 386 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
387 irq_desc[PLD_IRQ_CFC_INSERT].handler = &m32700ut_pld_irq_type; 387 irq_desc[PLD_IRQ_CFC_INSERT].chip = &m32700ut_pld_irq_type;
388 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; 388 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
389 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ 389 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
390 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */ 390 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
@@ -392,7 +392,7 @@ void __init init_IRQ(void)
392 392
393 /* INT#1: CFC Eject on PLD */ 393 /* INT#1: CFC Eject on PLD */
394 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; 394 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
395 irq_desc[PLD_IRQ_CFC_EJECT].handler = &m32700ut_pld_irq_type; 395 irq_desc[PLD_IRQ_CFC_EJECT].chip = &m32700ut_pld_irq_type;
396 irq_desc[PLD_IRQ_CFC_EJECT].action = 0; 396 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
397 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ 397 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
398 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */ 398 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
@@ -416,7 +416,7 @@ void __init init_IRQ(void)
416 outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */ 416 outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
417 417
418 irq_desc[M32700UT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED; 418 irq_desc[M32700UT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED;
419 irq_desc[M32700UT_LCD_IRQ_USB_INT1].handler = &m32700ut_lcdpld_irq_type; 419 irq_desc[M32700UT_LCD_IRQ_USB_INT1].chip = &m32700ut_lcdpld_irq_type;
420 irq_desc[M32700UT_LCD_IRQ_USB_INT1].action = 0; 420 irq_desc[M32700UT_LCD_IRQ_USB_INT1].action = 0;
421 irq_desc[M32700UT_LCD_IRQ_USB_INT1].depth = 1; 421 irq_desc[M32700UT_LCD_IRQ_USB_INT1].depth = 1;
422 lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */ 422 lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
@@ -434,7 +434,7 @@ void __init init_IRQ(void)
434 * INT3# is used for AR 434 * INT3# is used for AR
435 */ 435 */
436 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED; 436 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED;
437 irq_desc[M32R_IRQ_INT3].handler = &m32700ut_irq_type; 437 irq_desc[M32R_IRQ_INT3].chip = &m32700ut_irq_type;
438 irq_desc[M32R_IRQ_INT3].action = 0; 438 irq_desc[M32R_IRQ_INT3].action = 0;
439 irq_desc[M32R_IRQ_INT3].depth = 1; 439 irq_desc[M32R_IRQ_INT3].depth = 1;
440 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 440 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c
index 00f253209cb3..c268044185f5 100644
--- a/arch/m32r/kernel/setup_mappi.c
+++ b/arch/m32r/kernel/setup_mappi.c
@@ -86,7 +86,7 @@ void __init init_IRQ(void)
86#ifdef CONFIG_NE2000 86#ifdef CONFIG_NE2000
87 /* INT0 : LAN controller (RTL8019AS) */ 87 /* INT0 : LAN controller (RTL8019AS) */
88 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; 88 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
89 irq_desc[M32R_IRQ_INT0].handler = &mappi_irq_type; 89 irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type;
90 irq_desc[M32R_IRQ_INT0].action = 0; 90 irq_desc[M32R_IRQ_INT0].action = 0;
91 irq_desc[M32R_IRQ_INT0].depth = 1; 91 irq_desc[M32R_IRQ_INT0].depth = 1;
92 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 92 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
@@ -95,7 +95,7 @@ void __init init_IRQ(void)
95 95
96 /* MFT2 : system timer */ 96 /* MFT2 : system timer */
97 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 97 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
98 irq_desc[M32R_IRQ_MFT2].handler = &mappi_irq_type; 98 irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type;
99 irq_desc[M32R_IRQ_MFT2].action = 0; 99 irq_desc[M32R_IRQ_MFT2].action = 0;
100 irq_desc[M32R_IRQ_MFT2].depth = 1; 100 irq_desc[M32R_IRQ_MFT2].depth = 1;
101 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 101 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -104,7 +104,7 @@ void __init init_IRQ(void)
104#ifdef CONFIG_SERIAL_M32R_SIO 104#ifdef CONFIG_SERIAL_M32R_SIO
105 /* SIO0_R : uart receive data */ 105 /* SIO0_R : uart receive data */
106 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 106 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
107 irq_desc[M32R_IRQ_SIO0_R].handler = &mappi_irq_type; 107 irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type;
108 irq_desc[M32R_IRQ_SIO0_R].action = 0; 108 irq_desc[M32R_IRQ_SIO0_R].action = 0;
109 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 109 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
110 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 110 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -112,7 +112,7 @@ void __init init_IRQ(void)
112 112
113 /* SIO0_S : uart send data */ 113 /* SIO0_S : uart send data */
114 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 114 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
115 irq_desc[M32R_IRQ_SIO0_S].handler = &mappi_irq_type; 115 irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type;
116 irq_desc[M32R_IRQ_SIO0_S].action = 0; 116 irq_desc[M32R_IRQ_SIO0_S].action = 0;
117 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 117 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
118 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 118 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
@@ -120,7 +120,7 @@ void __init init_IRQ(void)
120 120
121 /* SIO1_R : uart receive data */ 121 /* SIO1_R : uart receive data */
122 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 122 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
123 irq_desc[M32R_IRQ_SIO1_R].handler = &mappi_irq_type; 123 irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type;
124 irq_desc[M32R_IRQ_SIO1_R].action = 0; 124 irq_desc[M32R_IRQ_SIO1_R].action = 0;
125 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 125 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
126 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 126 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -128,7 +128,7 @@ void __init init_IRQ(void)
128 128
129 /* SIO1_S : uart send data */ 129 /* SIO1_S : uart send data */
130 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 130 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
131 irq_desc[M32R_IRQ_SIO1_S].handler = &mappi_irq_type; 131 irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type;
132 irq_desc[M32R_IRQ_SIO1_S].action = 0; 132 irq_desc[M32R_IRQ_SIO1_S].action = 0;
133 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 133 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
134 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 134 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
@@ -138,7 +138,7 @@ void __init init_IRQ(void)
138#if defined(CONFIG_M32R_PCC) 138#if defined(CONFIG_M32R_PCC)
139 /* INT1 : pccard0 interrupt */ 139 /* INT1 : pccard0 interrupt */
140 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; 140 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
141 irq_desc[M32R_IRQ_INT1].handler = &mappi_irq_type; 141 irq_desc[M32R_IRQ_INT1].chip = &mappi_irq_type;
142 irq_desc[M32R_IRQ_INT1].action = 0; 142 irq_desc[M32R_IRQ_INT1].action = 0;
143 irq_desc[M32R_IRQ_INT1].depth = 1; 143 irq_desc[M32R_IRQ_INT1].depth = 1;
144 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00; 144 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
@@ -146,7 +146,7 @@ void __init init_IRQ(void)
146 146
147 /* INT2 : pccard1 interrupt */ 147 /* INT2 : pccard1 interrupt */
148 irq_desc[M32R_IRQ_INT2].status = IRQ_DISABLED; 148 irq_desc[M32R_IRQ_INT2].status = IRQ_DISABLED;
149 irq_desc[M32R_IRQ_INT2].handler = &mappi_irq_type; 149 irq_desc[M32R_IRQ_INT2].chip = &mappi_irq_type;
150 irq_desc[M32R_IRQ_INT2].action = 0; 150 irq_desc[M32R_IRQ_INT2].action = 0;
151 irq_desc[M32R_IRQ_INT2].depth = 1; 151 irq_desc[M32R_IRQ_INT2].depth = 1;
152 icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00; 152 icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
diff --git a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c
index eebc9d8b4e72..bd2327d5cca2 100644
--- a/arch/m32r/kernel/setup_mappi2.c
+++ b/arch/m32r/kernel/setup_mappi2.c
@@ -87,7 +87,7 @@ void __init init_IRQ(void)
87#if defined(CONFIG_SMC91X) 87#if defined(CONFIG_SMC91X)
88 /* INT0 : LAN controller (SMC91111) */ 88 /* INT0 : LAN controller (SMC91111) */
89 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; 89 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
90 irq_desc[M32R_IRQ_INT0].handler = &mappi2_irq_type; 90 irq_desc[M32R_IRQ_INT0].chip = &mappi2_irq_type;
91 irq_desc[M32R_IRQ_INT0].action = 0; 91 irq_desc[M32R_IRQ_INT0].action = 0;
92 irq_desc[M32R_IRQ_INT0].depth = 1; 92 irq_desc[M32R_IRQ_INT0].depth = 1;
93 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 93 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
@@ -96,7 +96,7 @@ void __init init_IRQ(void)
96 96
97 /* MFT2 : system timer */ 97 /* MFT2 : system timer */
98 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 98 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
99 irq_desc[M32R_IRQ_MFT2].handler = &mappi2_irq_type; 99 irq_desc[M32R_IRQ_MFT2].chip = &mappi2_irq_type;
100 irq_desc[M32R_IRQ_MFT2].action = 0; 100 irq_desc[M32R_IRQ_MFT2].action = 0;
101 irq_desc[M32R_IRQ_MFT2].depth = 1; 101 irq_desc[M32R_IRQ_MFT2].depth = 1;
102 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 102 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -105,7 +105,7 @@ void __init init_IRQ(void)
105#ifdef CONFIG_SERIAL_M32R_SIO 105#ifdef CONFIG_SERIAL_M32R_SIO
106 /* SIO0_R : uart receive data */ 106 /* SIO0_R : uart receive data */
107 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 107 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
108 irq_desc[M32R_IRQ_SIO0_R].handler = &mappi2_irq_type; 108 irq_desc[M32R_IRQ_SIO0_R].chip = &mappi2_irq_type;
109 irq_desc[M32R_IRQ_SIO0_R].action = 0; 109 irq_desc[M32R_IRQ_SIO0_R].action = 0;
110 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 110 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
111 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 111 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -113,14 +113,14 @@ void __init init_IRQ(void)
113 113
114 /* SIO0_S : uart send data */ 114 /* SIO0_S : uart send data */
115 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 115 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
116 irq_desc[M32R_IRQ_SIO0_S].handler = &mappi2_irq_type; 116 irq_desc[M32R_IRQ_SIO0_S].chip = &mappi2_irq_type;
117 irq_desc[M32R_IRQ_SIO0_S].action = 0; 117 irq_desc[M32R_IRQ_SIO0_S].action = 0;
118 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 118 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
119 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 119 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
120 disable_mappi2_irq(M32R_IRQ_SIO0_S); 120 disable_mappi2_irq(M32R_IRQ_SIO0_S);
121 /* SIO1_R : uart receive data */ 121 /* SIO1_R : uart receive data */
122 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 122 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
123 irq_desc[M32R_IRQ_SIO1_R].handler = &mappi2_irq_type; 123 irq_desc[M32R_IRQ_SIO1_R].chip = &mappi2_irq_type;
124 irq_desc[M32R_IRQ_SIO1_R].action = 0; 124 irq_desc[M32R_IRQ_SIO1_R].action = 0;
125 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 125 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
126 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 126 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -128,7 +128,7 @@ void __init init_IRQ(void)
128 128
129 /* SIO1_S : uart send data */ 129 /* SIO1_S : uart send data */
130 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 130 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
131 irq_desc[M32R_IRQ_SIO1_S].handler = &mappi2_irq_type; 131 irq_desc[M32R_IRQ_SIO1_S].chip = &mappi2_irq_type;
132 irq_desc[M32R_IRQ_SIO1_S].action = 0; 132 irq_desc[M32R_IRQ_SIO1_S].action = 0;
133 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 133 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
134 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 134 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
@@ -138,7 +138,7 @@ void __init init_IRQ(void)
138#if defined(CONFIG_USB) 138#if defined(CONFIG_USB)
139 /* INT1 : USB Host controller interrupt */ 139 /* INT1 : USB Host controller interrupt */
140 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; 140 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
141 irq_desc[M32R_IRQ_INT1].handler = &mappi2_irq_type; 141 irq_desc[M32R_IRQ_INT1].chip = &mappi2_irq_type;
142 irq_desc[M32R_IRQ_INT1].action = 0; 142 irq_desc[M32R_IRQ_INT1].action = 0;
143 irq_desc[M32R_IRQ_INT1].depth = 1; 143 irq_desc[M32R_IRQ_INT1].depth = 1;
144 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01; 144 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01;
@@ -147,7 +147,7 @@ void __init init_IRQ(void)
147 147
148 /* ICUCR40: CFC IREQ */ 148 /* ICUCR40: CFC IREQ */
149 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; 149 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
150 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type; 150 irq_desc[PLD_IRQ_CFIREQ].chip = &mappi2_irq_type;
151 irq_desc[PLD_IRQ_CFIREQ].action = 0; 151 irq_desc[PLD_IRQ_CFIREQ].action = 0;
152 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ 152 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
153 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01; 153 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
@@ -156,7 +156,7 @@ void __init init_IRQ(void)
156#if defined(CONFIG_M32R_CFC) 156#if defined(CONFIG_M32R_CFC)
157 /* ICUCR41: CFC Insert */ 157 /* ICUCR41: CFC Insert */
158 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; 158 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
159 irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi2_irq_type; 159 irq_desc[PLD_IRQ_CFC_INSERT].chip = &mappi2_irq_type;
160 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; 160 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
161 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ 161 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
162 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; 162 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
@@ -164,7 +164,7 @@ void __init init_IRQ(void)
164 164
165 /* ICUCR42: CFC Eject */ 165 /* ICUCR42: CFC Eject */
166 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; 166 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
167 irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi2_irq_type; 167 irq_desc[PLD_IRQ_CFC_EJECT].chip = &mappi2_irq_type;
168 irq_desc[PLD_IRQ_CFC_EJECT].action = 0; 168 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
169 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ 169 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
170 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 170 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c
index d2ff021e2d3d..014b51d17505 100644
--- a/arch/m32r/kernel/setup_mappi3.c
+++ b/arch/m32r/kernel/setup_mappi3.c
@@ -87,7 +87,7 @@ void __init init_IRQ(void)
87#if defined(CONFIG_SMC91X) 87#if defined(CONFIG_SMC91X)
88 /* INT0 : LAN controller (SMC91111) */ 88 /* INT0 : LAN controller (SMC91111) */
89 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; 89 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
90 irq_desc[M32R_IRQ_INT0].handler = &mappi3_irq_type; 90 irq_desc[M32R_IRQ_INT0].chip = &mappi3_irq_type;
91 irq_desc[M32R_IRQ_INT0].action = 0; 91 irq_desc[M32R_IRQ_INT0].action = 0;
92 irq_desc[M32R_IRQ_INT0].depth = 1; 92 irq_desc[M32R_IRQ_INT0].depth = 1;
93 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 93 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
@@ -96,7 +96,7 @@ void __init init_IRQ(void)
96 96
97 /* MFT2 : system timer */ 97 /* MFT2 : system timer */
98 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 98 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
99 irq_desc[M32R_IRQ_MFT2].handler = &mappi3_irq_type; 99 irq_desc[M32R_IRQ_MFT2].chip = &mappi3_irq_type;
100 irq_desc[M32R_IRQ_MFT2].action = 0; 100 irq_desc[M32R_IRQ_MFT2].action = 0;
101 irq_desc[M32R_IRQ_MFT2].depth = 1; 101 irq_desc[M32R_IRQ_MFT2].depth = 1;
102 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 102 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -105,7 +105,7 @@ void __init init_IRQ(void)
105#ifdef CONFIG_SERIAL_M32R_SIO 105#ifdef CONFIG_SERIAL_M32R_SIO
106 /* SIO0_R : uart receive data */ 106 /* SIO0_R : uart receive data */
107 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 107 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
108 irq_desc[M32R_IRQ_SIO0_R].handler = &mappi3_irq_type; 108 irq_desc[M32R_IRQ_SIO0_R].chip = &mappi3_irq_type;
109 irq_desc[M32R_IRQ_SIO0_R].action = 0; 109 irq_desc[M32R_IRQ_SIO0_R].action = 0;
110 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 110 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
111 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 111 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -113,14 +113,14 @@ void __init init_IRQ(void)
113 113
114 /* SIO0_S : uart send data */ 114 /* SIO0_S : uart send data */
115 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 115 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
116 irq_desc[M32R_IRQ_SIO0_S].handler = &mappi3_irq_type; 116 irq_desc[M32R_IRQ_SIO0_S].chip = &mappi3_irq_type;
117 irq_desc[M32R_IRQ_SIO0_S].action = 0; 117 irq_desc[M32R_IRQ_SIO0_S].action = 0;
118 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 118 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
119 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 119 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
120 disable_mappi3_irq(M32R_IRQ_SIO0_S); 120 disable_mappi3_irq(M32R_IRQ_SIO0_S);
121 /* SIO1_R : uart receive data */ 121 /* SIO1_R : uart receive data */
122 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 122 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
123 irq_desc[M32R_IRQ_SIO1_R].handler = &mappi3_irq_type; 123 irq_desc[M32R_IRQ_SIO1_R].chip = &mappi3_irq_type;
124 irq_desc[M32R_IRQ_SIO1_R].action = 0; 124 irq_desc[M32R_IRQ_SIO1_R].action = 0;
125 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 125 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
126 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 126 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -128,7 +128,7 @@ void __init init_IRQ(void)
128 128
129 /* SIO1_S : uart send data */ 129 /* SIO1_S : uart send data */
130 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 130 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
131 irq_desc[M32R_IRQ_SIO1_S].handler = &mappi3_irq_type; 131 irq_desc[M32R_IRQ_SIO1_S].chip = &mappi3_irq_type;
132 irq_desc[M32R_IRQ_SIO1_S].action = 0; 132 irq_desc[M32R_IRQ_SIO1_S].action = 0;
133 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 133 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
134 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 134 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
@@ -138,7 +138,7 @@ void __init init_IRQ(void)
138#if defined(CONFIG_USB) 138#if defined(CONFIG_USB)
139 /* INT1 : USB Host controller interrupt */ 139 /* INT1 : USB Host controller interrupt */
140 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; 140 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
141 irq_desc[M32R_IRQ_INT1].handler = &mappi3_irq_type; 141 irq_desc[M32R_IRQ_INT1].chip = &mappi3_irq_type;
142 irq_desc[M32R_IRQ_INT1].action = 0; 142 irq_desc[M32R_IRQ_INT1].action = 0;
143 irq_desc[M32R_IRQ_INT1].depth = 1; 143 irq_desc[M32R_IRQ_INT1].depth = 1;
144 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01; 144 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01;
@@ -147,7 +147,7 @@ void __init init_IRQ(void)
147 147
148 /* CFC IREQ */ 148 /* CFC IREQ */
149 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; 149 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
150 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type; 150 irq_desc[PLD_IRQ_CFIREQ].chip = &mappi3_irq_type;
151 irq_desc[PLD_IRQ_CFIREQ].action = 0; 151 irq_desc[PLD_IRQ_CFIREQ].action = 0;
152 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ 152 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
153 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01; 153 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
@@ -156,7 +156,7 @@ void __init init_IRQ(void)
156#if defined(CONFIG_M32R_CFC) 156#if defined(CONFIG_M32R_CFC)
157 /* ICUCR41: CFC Insert & eject */ 157 /* ICUCR41: CFC Insert & eject */
158 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; 158 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
159 irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type; 159 irq_desc[PLD_IRQ_CFC_INSERT].chip = &mappi3_irq_type;
160 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; 160 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
161 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ 161 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
162 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; 162 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
@@ -166,7 +166,7 @@ void __init init_IRQ(void)
166 166
167 /* IDE IREQ */ 167 /* IDE IREQ */
168 irq_desc[PLD_IRQ_IDEIREQ].status = IRQ_DISABLED; 168 irq_desc[PLD_IRQ_IDEIREQ].status = IRQ_DISABLED;
169 irq_desc[PLD_IRQ_IDEIREQ].handler = &mappi3_irq_type; 169 irq_desc[PLD_IRQ_IDEIREQ].chip = &mappi3_irq_type;
170 irq_desc[PLD_IRQ_IDEIREQ].action = 0; 170 irq_desc[PLD_IRQ_IDEIREQ].action = 0;
171 irq_desc[PLD_IRQ_IDEIREQ].depth = 1; /* disable nested irq */ 171 irq_desc[PLD_IRQ_IDEIREQ].depth = 1; /* disable nested irq */
172 icu_data[PLD_IRQ_IDEIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 172 icu_data[PLD_IRQ_IDEIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
diff --git a/arch/m32r/kernel/setup_oaks32r.c b/arch/m32r/kernel/setup_oaks32r.c
index 0e9e63538c0f..ea64831aef7a 100644
--- a/arch/m32r/kernel/setup_oaks32r.c
+++ b/arch/m32r/kernel/setup_oaks32r.c
@@ -85,7 +85,7 @@ void __init init_IRQ(void)
85#ifdef CONFIG_NE2000 85#ifdef CONFIG_NE2000
86 /* INT3 : LAN controller (RTL8019AS) */ 86 /* INT3 : LAN controller (RTL8019AS) */
87 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED; 87 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED;
88 irq_desc[M32R_IRQ_INT3].handler = &oaks32r_irq_type; 88 irq_desc[M32R_IRQ_INT3].chip = &oaks32r_irq_type;
89 irq_desc[M32R_IRQ_INT3].action = 0; 89 irq_desc[M32R_IRQ_INT3].action = 0;
90 irq_desc[M32R_IRQ_INT3].depth = 1; 90 irq_desc[M32R_IRQ_INT3].depth = 1;
91 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 91 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
@@ -94,7 +94,7 @@ void __init init_IRQ(void)
94 94
95 /* MFT2 : system timer */ 95 /* MFT2 : system timer */
96 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 96 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
97 irq_desc[M32R_IRQ_MFT2].handler = &oaks32r_irq_type; 97 irq_desc[M32R_IRQ_MFT2].chip = &oaks32r_irq_type;
98 irq_desc[M32R_IRQ_MFT2].action = 0; 98 irq_desc[M32R_IRQ_MFT2].action = 0;
99 irq_desc[M32R_IRQ_MFT2].depth = 1; 99 irq_desc[M32R_IRQ_MFT2].depth = 1;
100 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 100 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -103,7 +103,7 @@ void __init init_IRQ(void)
103#ifdef CONFIG_SERIAL_M32R_SIO 103#ifdef CONFIG_SERIAL_M32R_SIO
104 /* SIO0_R : uart receive data */ 104 /* SIO0_R : uart receive data */
105 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 105 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
106 irq_desc[M32R_IRQ_SIO0_R].handler = &oaks32r_irq_type; 106 irq_desc[M32R_IRQ_SIO0_R].chip = &oaks32r_irq_type;
107 irq_desc[M32R_IRQ_SIO0_R].action = 0; 107 irq_desc[M32R_IRQ_SIO0_R].action = 0;
108 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 108 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
109 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 109 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -111,7 +111,7 @@ void __init init_IRQ(void)
111 111
112 /* SIO0_S : uart send data */ 112 /* SIO0_S : uart send data */
113 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 113 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
114 irq_desc[M32R_IRQ_SIO0_S].handler = &oaks32r_irq_type; 114 irq_desc[M32R_IRQ_SIO0_S].chip = &oaks32r_irq_type;
115 irq_desc[M32R_IRQ_SIO0_S].action = 0; 115 irq_desc[M32R_IRQ_SIO0_S].action = 0;
116 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 116 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
117 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 117 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
@@ -119,7 +119,7 @@ void __init init_IRQ(void)
119 119
120 /* SIO1_R : uart receive data */ 120 /* SIO1_R : uart receive data */
121 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 121 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
122 irq_desc[M32R_IRQ_SIO1_R].handler = &oaks32r_irq_type; 122 irq_desc[M32R_IRQ_SIO1_R].chip = &oaks32r_irq_type;
123 irq_desc[M32R_IRQ_SIO1_R].action = 0; 123 irq_desc[M32R_IRQ_SIO1_R].action = 0;
124 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 124 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
125 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 125 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -127,7 +127,7 @@ void __init init_IRQ(void)
127 127
128 /* SIO1_S : uart send data */ 128 /* SIO1_S : uart send data */
129 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 129 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
130 irq_desc[M32R_IRQ_SIO1_S].handler = &oaks32r_irq_type; 130 irq_desc[M32R_IRQ_SIO1_S].chip = &oaks32r_irq_type;
131 irq_desc[M32R_IRQ_SIO1_S].action = 0; 131 irq_desc[M32R_IRQ_SIO1_S].action = 0;
132 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 132 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
133 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 133 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
diff --git a/arch/m32r/kernel/setup_opsput.c b/arch/m32r/kernel/setup_opsput.c
index 548e8fc7949b..55e8972d455a 100644
--- a/arch/m32r/kernel/setup_opsput.c
+++ b/arch/m32r/kernel/setup_opsput.c
@@ -302,7 +302,7 @@ void __init init_IRQ(void)
302#if defined(CONFIG_SMC91X) 302#if defined(CONFIG_SMC91X)
303 /* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/ 303 /* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/
304 irq_desc[OPSPUT_LAN_IRQ_LAN].status = IRQ_DISABLED; 304 irq_desc[OPSPUT_LAN_IRQ_LAN].status = IRQ_DISABLED;
305 irq_desc[OPSPUT_LAN_IRQ_LAN].handler = &opsput_lanpld_irq_type; 305 irq_desc[OPSPUT_LAN_IRQ_LAN].chip = &opsput_lanpld_irq_type;
306 irq_desc[OPSPUT_LAN_IRQ_LAN].action = 0; 306 irq_desc[OPSPUT_LAN_IRQ_LAN].action = 0;
307 irq_desc[OPSPUT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */ 307 irq_desc[OPSPUT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */
308 lanpld_icu_data[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */ 308 lanpld_icu_data[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
@@ -311,7 +311,7 @@ void __init init_IRQ(void)
311 311
312 /* MFT2 : system timer */ 312 /* MFT2 : system timer */
313 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 313 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
314 irq_desc[M32R_IRQ_MFT2].handler = &opsput_irq_type; 314 irq_desc[M32R_IRQ_MFT2].chip = &opsput_irq_type;
315 irq_desc[M32R_IRQ_MFT2].action = 0; 315 irq_desc[M32R_IRQ_MFT2].action = 0;
316 irq_desc[M32R_IRQ_MFT2].depth = 1; 316 irq_desc[M32R_IRQ_MFT2].depth = 1;
317 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 317 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -319,7 +319,7 @@ void __init init_IRQ(void)
319 319
320 /* SIO0 : receive */ 320 /* SIO0 : receive */
321 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 321 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
322 irq_desc[M32R_IRQ_SIO0_R].handler = &opsput_irq_type; 322 irq_desc[M32R_IRQ_SIO0_R].chip = &opsput_irq_type;
323 irq_desc[M32R_IRQ_SIO0_R].action = 0; 323 irq_desc[M32R_IRQ_SIO0_R].action = 0;
324 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 324 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
325 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 325 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -327,7 +327,7 @@ void __init init_IRQ(void)
327 327
328 /* SIO0 : send */ 328 /* SIO0 : send */
329 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 329 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
330 irq_desc[M32R_IRQ_SIO0_S].handler = &opsput_irq_type; 330 irq_desc[M32R_IRQ_SIO0_S].chip = &opsput_irq_type;
331 irq_desc[M32R_IRQ_SIO0_S].action = 0; 331 irq_desc[M32R_IRQ_SIO0_S].action = 0;
332 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 332 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
333 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 333 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
@@ -335,7 +335,7 @@ void __init init_IRQ(void)
335 335
336 /* SIO1 : receive */ 336 /* SIO1 : receive */
337 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 337 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
338 irq_desc[M32R_IRQ_SIO1_R].handler = &opsput_irq_type; 338 irq_desc[M32R_IRQ_SIO1_R].chip = &opsput_irq_type;
339 irq_desc[M32R_IRQ_SIO1_R].action = 0; 339 irq_desc[M32R_IRQ_SIO1_R].action = 0;
340 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 340 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
341 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 341 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -343,7 +343,7 @@ void __init init_IRQ(void)
343 343
344 /* SIO1 : send */ 344 /* SIO1 : send */
345 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 345 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
346 irq_desc[M32R_IRQ_SIO1_S].handler = &opsput_irq_type; 346 irq_desc[M32R_IRQ_SIO1_S].chip = &opsput_irq_type;
347 irq_desc[M32R_IRQ_SIO1_S].action = 0; 347 irq_desc[M32R_IRQ_SIO1_S].action = 0;
348 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 348 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
349 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 349 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
@@ -351,7 +351,7 @@ void __init init_IRQ(void)
351 351
352 /* DMA1 : */ 352 /* DMA1 : */
353 irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED; 353 irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED;
354 irq_desc[M32R_IRQ_DMA1].handler = &opsput_irq_type; 354 irq_desc[M32R_IRQ_DMA1].chip = &opsput_irq_type;
355 irq_desc[M32R_IRQ_DMA1].action = 0; 355 irq_desc[M32R_IRQ_DMA1].action = 0;
356 irq_desc[M32R_IRQ_DMA1].depth = 1; 356 irq_desc[M32R_IRQ_DMA1].depth = 1;
357 icu_data[M32R_IRQ_DMA1].icucr = 0; 357 icu_data[M32R_IRQ_DMA1].icucr = 0;
@@ -360,7 +360,7 @@ void __init init_IRQ(void)
360#ifdef CONFIG_SERIAL_M32R_PLDSIO 360#ifdef CONFIG_SERIAL_M32R_PLDSIO
361 /* INT#1: SIO0 Receive on PLD */ 361 /* INT#1: SIO0 Receive on PLD */
362 irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED; 362 irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED;
363 irq_desc[PLD_IRQ_SIO0_RCV].handler = &opsput_pld_irq_type; 363 irq_desc[PLD_IRQ_SIO0_RCV].chip = &opsput_pld_irq_type;
364 irq_desc[PLD_IRQ_SIO0_RCV].action = 0; 364 irq_desc[PLD_IRQ_SIO0_RCV].action = 0;
365 irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */ 365 irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */
366 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; 366 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
@@ -368,7 +368,7 @@ void __init init_IRQ(void)
368 368
369 /* INT#1: SIO0 Send on PLD */ 369 /* INT#1: SIO0 Send on PLD */
370 irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED; 370 irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED;
371 irq_desc[PLD_IRQ_SIO0_SND].handler = &opsput_pld_irq_type; 371 irq_desc[PLD_IRQ_SIO0_SND].chip = &opsput_pld_irq_type;
372 irq_desc[PLD_IRQ_SIO0_SND].action = 0; 372 irq_desc[PLD_IRQ_SIO0_SND].action = 0;
373 irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */ 373 irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */
374 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; 374 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
@@ -378,7 +378,7 @@ void __init init_IRQ(void)
378#if defined(CONFIG_M32R_CFC) 378#if defined(CONFIG_M32R_CFC)
379 /* INT#1: CFC IREQ on PLD */ 379 /* INT#1: CFC IREQ on PLD */
380 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; 380 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
381 irq_desc[PLD_IRQ_CFIREQ].handler = &opsput_pld_irq_type; 381 irq_desc[PLD_IRQ_CFIREQ].chip = &opsput_pld_irq_type;
382 irq_desc[PLD_IRQ_CFIREQ].action = 0; 382 irq_desc[PLD_IRQ_CFIREQ].action = 0;
383 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ 383 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
384 pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */ 384 pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
@@ -386,7 +386,7 @@ void __init init_IRQ(void)
386 386
387 /* INT#1: CFC Insert on PLD */ 387 /* INT#1: CFC Insert on PLD */
388 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; 388 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
389 irq_desc[PLD_IRQ_CFC_INSERT].handler = &opsput_pld_irq_type; 389 irq_desc[PLD_IRQ_CFC_INSERT].chip = &opsput_pld_irq_type;
390 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; 390 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
391 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ 391 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
392 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */ 392 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
@@ -394,7 +394,7 @@ void __init init_IRQ(void)
394 394
395 /* INT#1: CFC Eject on PLD */ 395 /* INT#1: CFC Eject on PLD */
396 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; 396 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
397 irq_desc[PLD_IRQ_CFC_EJECT].handler = &opsput_pld_irq_type; 397 irq_desc[PLD_IRQ_CFC_EJECT].chip = &opsput_pld_irq_type;
398 irq_desc[PLD_IRQ_CFC_EJECT].action = 0; 398 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
399 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ 399 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
400 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */ 400 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
@@ -420,7 +420,7 @@ void __init init_IRQ(void)
420 outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */ 420 outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
421 421
422 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED; 422 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED;
423 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].handler = &opsput_lcdpld_irq_type; 423 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].chip = &opsput_lcdpld_irq_type;
424 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].action = 0; 424 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].action = 0;
425 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].depth = 1; 425 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].depth = 1;
426 lcdpld_icu_data[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */ 426 lcdpld_icu_data[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
@@ -438,7 +438,7 @@ void __init init_IRQ(void)
438 * INT3# is used for AR 438 * INT3# is used for AR
439 */ 439 */
440 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED; 440 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED;
441 irq_desc[M32R_IRQ_INT3].handler = &opsput_irq_type; 441 irq_desc[M32R_IRQ_INT3].chip = &opsput_irq_type;
442 irq_desc[M32R_IRQ_INT3].action = 0; 442 irq_desc[M32R_IRQ_INT3].action = 0;
443 irq_desc[M32R_IRQ_INT3].depth = 1; 443 irq_desc[M32R_IRQ_INT3].depth = 1;
444 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 444 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
diff --git a/arch/m32r/kernel/setup_usrv.c b/arch/m32r/kernel/setup_usrv.c
index 64be659a23e7..7fa12d8f66b4 100644
--- a/arch/m32r/kernel/setup_usrv.c
+++ b/arch/m32r/kernel/setup_usrv.c
@@ -158,7 +158,7 @@ void __init init_IRQ(void)
158 158
159 /* MFT2 : system timer */ 159 /* MFT2 : system timer */
160 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 160 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
161 irq_desc[M32R_IRQ_MFT2].handler = &mappi_irq_type; 161 irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type;
162 irq_desc[M32R_IRQ_MFT2].action = 0; 162 irq_desc[M32R_IRQ_MFT2].action = 0;
163 irq_desc[M32R_IRQ_MFT2].depth = 1; 163 irq_desc[M32R_IRQ_MFT2].depth = 1;
164 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 164 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
@@ -167,7 +167,7 @@ void __init init_IRQ(void)
167#if defined(CONFIG_SERIAL_M32R_SIO) 167#if defined(CONFIG_SERIAL_M32R_SIO)
168 /* SIO0_R : uart receive data */ 168 /* SIO0_R : uart receive data */
169 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 169 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
170 irq_desc[M32R_IRQ_SIO0_R].handler = &mappi_irq_type; 170 irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type;
171 irq_desc[M32R_IRQ_SIO0_R].action = 0; 171 irq_desc[M32R_IRQ_SIO0_R].action = 0;
172 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 172 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
173 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 173 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
@@ -175,7 +175,7 @@ void __init init_IRQ(void)
175 175
176 /* SIO0_S : uart send data */ 176 /* SIO0_S : uart send data */
177 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 177 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
178 irq_desc[M32R_IRQ_SIO0_S].handler = &mappi_irq_type; 178 irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type;
179 irq_desc[M32R_IRQ_SIO0_S].action = 0; 179 irq_desc[M32R_IRQ_SIO0_S].action = 0;
180 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 180 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
181 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 181 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
@@ -183,7 +183,7 @@ void __init init_IRQ(void)
183 183
184 /* SIO1_R : uart receive data */ 184 /* SIO1_R : uart receive data */
185 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 185 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
186 irq_desc[M32R_IRQ_SIO1_R].handler = &mappi_irq_type; 186 irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type;
187 irq_desc[M32R_IRQ_SIO1_R].action = 0; 187 irq_desc[M32R_IRQ_SIO1_R].action = 0;
188 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 188 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
189 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 189 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
@@ -191,7 +191,7 @@ void __init init_IRQ(void)
191 191
192 /* SIO1_S : uart send data */ 192 /* SIO1_S : uart send data */
193 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 193 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
194 irq_desc[M32R_IRQ_SIO1_S].handler = &mappi_irq_type; 194 irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type;
195 irq_desc[M32R_IRQ_SIO1_S].action = 0; 195 irq_desc[M32R_IRQ_SIO1_S].action = 0;
196 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 196 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
197 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 197 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
@@ -201,7 +201,7 @@ void __init init_IRQ(void)
201 /* INT#67-#71: CFC#0 IREQ on PLD */ 201 /* INT#67-#71: CFC#0 IREQ on PLD */
202 for (i = 0 ; i < CONFIG_CFC_NUM ; i++ ) { 202 for (i = 0 ; i < CONFIG_CFC_NUM ; i++ ) {
203 irq_desc[PLD_IRQ_CF0 + i].status = IRQ_DISABLED; 203 irq_desc[PLD_IRQ_CF0 + i].status = IRQ_DISABLED;
204 irq_desc[PLD_IRQ_CF0 + i].handler = &m32700ut_pld_irq_type; 204 irq_desc[PLD_IRQ_CF0 + i].chip = &m32700ut_pld_irq_type;
205 irq_desc[PLD_IRQ_CF0 + i].action = 0; 205 irq_desc[PLD_IRQ_CF0 + i].action = 0;
206 irq_desc[PLD_IRQ_CF0 + i].depth = 1; /* disable nested irq */ 206 irq_desc[PLD_IRQ_CF0 + i].depth = 1; /* disable nested irq */
207 pld_icu_data[irq2pldirq(PLD_IRQ_CF0 + i)].icucr 207 pld_icu_data[irq2pldirq(PLD_IRQ_CF0 + i)].icucr
@@ -212,7 +212,7 @@ void __init init_IRQ(void)
212#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 212#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
213 /* INT#76: 16552D#0 IREQ on PLD */ 213 /* INT#76: 16552D#0 IREQ on PLD */
214 irq_desc[PLD_IRQ_UART0].status = IRQ_DISABLED; 214 irq_desc[PLD_IRQ_UART0].status = IRQ_DISABLED;
215 irq_desc[PLD_IRQ_UART0].handler = &m32700ut_pld_irq_type; 215 irq_desc[PLD_IRQ_UART0].chip = &m32700ut_pld_irq_type;
216 irq_desc[PLD_IRQ_UART0].action = 0; 216 irq_desc[PLD_IRQ_UART0].action = 0;
217 irq_desc[PLD_IRQ_UART0].depth = 1; /* disable nested irq */ 217 irq_desc[PLD_IRQ_UART0].depth = 1; /* disable nested irq */
218 pld_icu_data[irq2pldirq(PLD_IRQ_UART0)].icucr 218 pld_icu_data[irq2pldirq(PLD_IRQ_UART0)].icucr
@@ -221,7 +221,7 @@ void __init init_IRQ(void)
221 221
222 /* INT#77: 16552D#1 IREQ on PLD */ 222 /* INT#77: 16552D#1 IREQ on PLD */
223 irq_desc[PLD_IRQ_UART1].status = IRQ_DISABLED; 223 irq_desc[PLD_IRQ_UART1].status = IRQ_DISABLED;
224 irq_desc[PLD_IRQ_UART1].handler = &m32700ut_pld_irq_type; 224 irq_desc[PLD_IRQ_UART1].chip = &m32700ut_pld_irq_type;
225 irq_desc[PLD_IRQ_UART1].action = 0; 225 irq_desc[PLD_IRQ_UART1].action = 0;
226 irq_desc[PLD_IRQ_UART1].depth = 1; /* disable nested irq */ 226 irq_desc[PLD_IRQ_UART1].depth = 1; /* disable nested irq */
227 pld_icu_data[irq2pldirq(PLD_IRQ_UART1)].icucr 227 pld_icu_data[irq2pldirq(PLD_IRQ_UART1)].icucr
@@ -232,7 +232,7 @@ void __init init_IRQ(void)
232#if defined(CONFIG_IDC_AK4524) || defined(CONFIG_IDC_AK4524_MODULE) 232#if defined(CONFIG_IDC_AK4524) || defined(CONFIG_IDC_AK4524_MODULE)
233 /* INT#80: AK4524 IREQ on PLD */ 233 /* INT#80: AK4524 IREQ on PLD */
234 irq_desc[PLD_IRQ_SNDINT].status = IRQ_DISABLED; 234 irq_desc[PLD_IRQ_SNDINT].status = IRQ_DISABLED;
235 irq_desc[PLD_IRQ_SNDINT].handler = &m32700ut_pld_irq_type; 235 irq_desc[PLD_IRQ_SNDINT].chip = &m32700ut_pld_irq_type;
236 irq_desc[PLD_IRQ_SNDINT].action = 0; 236 irq_desc[PLD_IRQ_SNDINT].action = 0;
237 irq_desc[PLD_IRQ_SNDINT].depth = 1; /* disable nested irq */ 237 irq_desc[PLD_IRQ_SNDINT].depth = 1; /* disable nested irq */
238 pld_icu_data[irq2pldirq(PLD_IRQ_SNDINT)].icucr 238 pld_icu_data[irq2pldirq(PLD_IRQ_SNDINT)].icucr
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index 8b6e723eb82b..e767f2ddae72 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -540,6 +540,59 @@ config RAM32BIT
540 540
541endchoice 541endchoice
542 542
543comment "ROM configuration"
544
545config ROM
546 bool "Specify ROM linker regions"
547 default n
548 help
549 Define a ROM region for the linker script. This creates a kernel
550 that can be stored in flash, with possibly the text, and data
551 regions being copied out to RAM at startup.
552
553config ROMBASE
554 hex "Address of the base of ROM device"
555 default "0"
556 depends on ROM
557 help
558 Define the address that the ROM region starts at. Some platforms
559 use this to set their chip select region accordingly for the boot
560 device.
561
562config ROMVEC
563 hex "Address of the base of the ROM vectors"
564 default "0"
565 depends on ROM
566 help
567 This is almost always the same as the base of the ROM. Since on all
568 68000 type varients the vectors are at the base of the boot device
569 on system startup.
570
571config ROMVECSIZE
572 hex "Size of ROM vector region (in bytes)"
573 default "0x400"
574 depends on ROM
575 help
576 Define the size of the vector region in ROM. For most 68000
577 varients this would be 0x400 bytes in size. Set to 0 if you do
578 not want a vector region at the start of the ROM.
579
580config ROMSTART
581 hex "Address of the base of system image in ROM"
582 default "0x400"
583 depends on ROM
584 help
585 Define the start address of the system image in ROM. Commonly this
586 is strait after the ROM vectors.
587
588config ROMSIZE
589 hex "Size of the ROM device"
590 default "0x100000"
591 depends on ROM
592 help
593 Size of the ROM device. On some platforms this is used to setup
594 the chip select that controls the boot ROM device.
595
543choice 596choice
544 prompt "Kernel executes from" 597 prompt "Kernel executes from"
545 ---help--- 598 ---help---
diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
index 6f880cbff1c8..8951793fd8d4 100644
--- a/arch/m68knommu/Makefile
+++ b/arch/m68knommu/Makefile
@@ -21,6 +21,7 @@ platform-$(CONFIG_M527x) := 527x
21platform-$(CONFIG_M5272) := 5272 21platform-$(CONFIG_M5272) := 5272
22platform-$(CONFIG_M528x) := 528x 22platform-$(CONFIG_M528x) := 528x
23platform-$(CONFIG_M5307) := 5307 23platform-$(CONFIG_M5307) := 5307
24platform-$(CONFIG_M532x) := 532x
24platform-$(CONFIG_M5407) := 5407 25platform-$(CONFIG_M5407) := 5407
25PLATFORM := $(platform-y) 26PLATFORM := $(platform-y)
26 27
@@ -44,6 +45,7 @@ board-$(CONFIG_senTec) := senTec
44board-$(CONFIG_SNEHA) := SNEHA 45board-$(CONFIG_SNEHA) := SNEHA
45board-$(CONFIG_M5208EVB) := M5208EVB 46board-$(CONFIG_M5208EVB) := M5208EVB
46board-$(CONFIG_MOD5272) := MOD5272 47board-$(CONFIG_MOD5272) := MOD5272
48board-$(CONFIG_AVNET) := AVNET
47BOARD := $(board-y) 49BOARD := $(board-y)
48 50
49model-$(CONFIG_RAMKERNEL) := ram 51model-$(CONFIG_RAMKERNEL) := ram
@@ -65,6 +67,7 @@ cpuclass-$(CONFIG_M527x) := 5307
65cpuclass-$(CONFIG_M5272) := 5307 67cpuclass-$(CONFIG_M5272) := 5307
66cpuclass-$(CONFIG_M528x) := 5307 68cpuclass-$(CONFIG_M528x) := 5307
67cpuclass-$(CONFIG_M5307) := 5307 69cpuclass-$(CONFIG_M5307) := 5307
70cpuclass-$(CONFIG_M532x) := 5307
68cpuclass-$(CONFIG_M5407) := 5307 71cpuclass-$(CONFIG_M5407) := 5307
69cpuclass-$(CONFIG_M68328) := 68328 72cpuclass-$(CONFIG_M68328) := 68328
70cpuclass-$(CONFIG_M68EZ328) := 68328 73cpuclass-$(CONFIG_M68EZ328) := 68328
@@ -81,16 +84,17 @@ export PLATFORM BOARD MODEL CPUCLASS
81# 84#
82# Some CFLAG additions based on specific CPU type. 85# Some CFLAG additions based on specific CPU type.
83# 86#
84cflags-$(CONFIG_M5206) := -m5200 -Wa,-S -Wa,-m5200 87cflags-$(CONFIG_M5206) := -m5200
85cflags-$(CONFIG_M5206e) := -m5200 -Wa,-S -Wa,-m5200 88cflags-$(CONFIG_M5206e) := -m5200
86cflags-$(CONFIG_M520x) := -m5307 -Wa,-S -Wa,-m5307 89cflags-$(CONFIG_M520x) := -m5307
87cflags-$(CONFIG_M523x) := -m5307 -Wa,-S -Wa,-m5307 90cflags-$(CONFIG_M523x) := -m5307
88cflags-$(CONFIG_M5249) := -m5200 -Wa,-S -Wa,-m5200 91cflags-$(CONFIG_M5249) := -m5200
89cflags-$(CONFIG_M527x) := -m5307 -Wa,-S -Wa,-m5307 92cflags-$(CONFIG_M527x) := -m5307
90cflags-$(CONFIG_M5272) := -m5307 -Wa,-S -Wa,-m5307 93cflags-$(CONFIG_M5272) := -m5307
91cflags-$(CONFIG_M528x) := -m5307 -Wa,-S -Wa,-m5307 94cflags-$(CONFIG_M528x) := -m5307
92cflags-$(CONFIG_M5307) := -m5307 -Wa,-S -Wa,-m5307 95cflags-$(CONFIG_M5307) := -m5307
93cflags-$(CONFIG_M5407) := -m5200 -Wa,-S -Wa,-m5200 96cflags-$(CONFIG_M532x) := -m5307
97cflags-$(CONFIG_M5407) := -m5200
94cflags-$(CONFIG_M68328) := -m68000 98cflags-$(CONFIG_M68328) := -m68000
95cflags-$(CONFIG_M68EZ328) := -m68000 99cflags-$(CONFIG_M68EZ328) := -m68000
96cflags-$(CONFIG_M68VZ328) := -m68000 100cflags-$(CONFIG_M68VZ328) := -m68000
diff --git a/arch/m68knommu/defconfig b/arch/m68knommu/defconfig
index 2d59ba1a79ba..3891de09ac23 100644
--- a/arch/m68knommu/defconfig
+++ b/arch/m68knommu/defconfig
@@ -1,21 +1,22 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-uc0 3# Linux kernel version: 2.6.17
4# Wed Aug 31 15:03:26 2005 4# Tue Jun 27 12:57:06 2006
5# 5#
6CONFIG_M68KNOMMU=y 6CONFIG_M68K=y
7# CONFIG_MMU is not set 7# CONFIG_MMU is not set
8# CONFIG_FPU is not set 8# CONFIG_FPU is not set
9CONFIG_UID16=y
10CONFIG_RWSEM_GENERIC_SPINLOCK=y 9CONFIG_RWSEM_GENERIC_SPINLOCK=y
11# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set 10# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
11CONFIG_GENERIC_FIND_NEXT_BIT=y
12CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 13CONFIG_GENERIC_CALIBRATE_DELAY=y
14CONFIG_TIME_LOW_RES=y
13 15
14# 16#
15# Code maturity level options 17# Code maturity level options
16# 18#
17CONFIG_EXPERIMENTAL=y 19CONFIG_EXPERIMENTAL=y
18CONFIG_CLEAN_COMPILE=y
19CONFIG_BROKEN_ON_SMP=y 20CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32 21CONFIG_INIT_ENV_ARG_LIMIT=32
21 22
@@ -23,26 +24,30 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
23# General setup 24# General setup
24# 25#
25CONFIG_LOCALVERSION="" 26CONFIG_LOCALVERSION=""
27CONFIG_LOCALVERSION_AUTO=y
28# CONFIG_SYSVIPC is not set
26# CONFIG_POSIX_MQUEUE is not set 29# CONFIG_POSIX_MQUEUE is not set
27# CONFIG_BSD_PROCESS_ACCT is not set 30# CONFIG_BSD_PROCESS_ACCT is not set
28# CONFIG_SYSCTL is not set 31# CONFIG_SYSCTL is not set
29# CONFIG_AUDIT is not set 32# CONFIG_AUDIT is not set
30# CONFIG_HOTPLUG is not set
31# CONFIG_KOBJECT_UEVENT is not set
32# CONFIG_IKCONFIG is not set 33# CONFIG_IKCONFIG is not set
34# CONFIG_RELAY is not set
35CONFIG_INITRAMFS_SOURCE=""
36CONFIG_UID16=y
37# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
33CONFIG_EMBEDDED=y 38CONFIG_EMBEDDED=y
34# CONFIG_KALLSYMS is not set 39# CONFIG_KALLSYMS is not set
40# CONFIG_HOTPLUG is not set
35CONFIG_PRINTK=y 41CONFIG_PRINTK=y
36CONFIG_BUG=y 42CONFIG_BUG=y
43CONFIG_ELF_CORE=y
37CONFIG_BASE_FULL=y 44CONFIG_BASE_FULL=y
38# CONFIG_FUTEX is not set 45# CONFIG_FUTEX is not set
39# CONFIG_EPOLL is not set 46# CONFIG_EPOLL is not set
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 47CONFIG_SLAB=y
41CONFIG_CC_ALIGN_FUNCTIONS=0 48CONFIG_TINY_SHMEM=y
42CONFIG_CC_ALIGN_LABELS=0
43CONFIG_CC_ALIGN_LOOPS=0
44CONFIG_CC_ALIGN_JUMPS=0
45CONFIG_BASE_SMALL=0 49CONFIG_BASE_SMALL=0
50# CONFIG_SLOB is not set
46 51
47# 52#
48# Loadable module support 53# Loadable module support
@@ -50,6 +55,24 @@ CONFIG_BASE_SMALL=0
50# CONFIG_MODULES is not set 55# CONFIG_MODULES is not set
51 56
52# 57#
58# Block layer
59#
60# CONFIG_BLK_DEV_IO_TRACE is not set
61
62#
63# IO Schedulers
64#
65CONFIG_IOSCHED_NOOP=y
66# CONFIG_IOSCHED_AS is not set
67# CONFIG_IOSCHED_DEADLINE is not set
68# CONFIG_IOSCHED_CFQ is not set
69# CONFIG_DEFAULT_AS is not set
70# CONFIG_DEFAULT_DEADLINE is not set
71# CONFIG_DEFAULT_CFQ is not set
72CONFIG_DEFAULT_NOOP=y
73CONFIG_DEFAULT_IOSCHED="noop"
74
75#
53# Processor type and features 76# Processor type and features
54# 77#
55# CONFIG_M68328 is not set 78# CONFIG_M68328 is not set
@@ -58,6 +81,7 @@ CONFIG_BASE_SMALL=0
58# CONFIG_M68360 is not set 81# CONFIG_M68360 is not set
59# CONFIG_M5206 is not set 82# CONFIG_M5206 is not set
60# CONFIG_M5206e is not set 83# CONFIG_M5206e is not set
84# CONFIG_M520x is not set
61# CONFIG_M523x is not set 85# CONFIG_M523x is not set
62# CONFIG_M5249 is not set 86# CONFIG_M5249 is not set
63# CONFIG_M5271 is not set 87# CONFIG_M5271 is not set
@@ -65,29 +89,12 @@ CONFIG_M5272=y
65# CONFIG_M5275 is not set 89# CONFIG_M5275 is not set
66# CONFIG_M528x is not set 90# CONFIG_M528x is not set
67# CONFIG_M5307 is not set 91# CONFIG_M5307 is not set
92# CONFIG_M532x is not set
68# CONFIG_M5407 is not set 93# CONFIG_M5407 is not set
69CONFIG_COLDFIRE=y 94CONFIG_COLDFIRE=y
70# CONFIG_CLOCK_AUTO is not set 95CONFIG_CLOCK_SET=y
71# CONFIG_CLOCK_11MHz is not set 96CONFIG_CLOCK_FREQ=66666666
72# CONFIG_CLOCK_16MHz is not set 97CONFIG_CLOCK_DIV=1
73# CONFIG_CLOCK_20MHz is not set
74# CONFIG_CLOCK_24MHz is not set
75# CONFIG_CLOCK_25MHz is not set
76# CONFIG_CLOCK_33MHz is not set
77# CONFIG_CLOCK_40MHz is not set
78# CONFIG_CLOCK_45MHz is not set
79# CONFIG_CLOCK_48MHz is not set
80# CONFIG_CLOCK_50MHz is not set
81# CONFIG_CLOCK_54MHz is not set
82# CONFIG_CLOCK_60MHz is not set
83# CONFIG_CLOCK_62_5MHz is not set
84# CONFIG_CLOCK_64MHz is not set
85CONFIG_CLOCK_66MHz=y
86# CONFIG_CLOCK_70MHz is not set
87# CONFIG_CLOCK_100MHz is not set
88# CONFIG_CLOCK_140MHz is not set
89# CONFIG_CLOCK_150MHz is not set
90# CONFIG_CLOCK_166MHz is not set
91 98
92# 99#
93# Platform 100# Platform
@@ -102,11 +109,14 @@ CONFIG_M5272C3=y
102CONFIG_FREESCALE=y 109CONFIG_FREESCALE=y
103# CONFIG_LARGE_ALLOCS is not set 110# CONFIG_LARGE_ALLOCS is not set
104CONFIG_4KSTACKS=y 111CONFIG_4KSTACKS=y
105CONFIG_RAMAUTO=y 112
106# CONFIG_RAM4MB is not set 113#
107# CONFIG_RAM8MB is not set 114# RAM configuration
108# CONFIG_RAM16MB is not set 115#
109# CONFIG_RAM32MB is not set 116CONFIG_RAMBASE=0x0
117CONFIG_RAMSIZE=0x800000
118CONFIG_VECTORBASE=0x0
119CONFIG_KERNELBASE=0x20000
110CONFIG_RAMAUTOBIT=y 120CONFIG_RAMAUTOBIT=y
111# CONFIG_RAM8BIT is not set 121# CONFIG_RAM8BIT is not set
112# CONFIG_RAM16BIT is not set 122# CONFIG_RAM16BIT is not set
@@ -119,6 +129,8 @@ CONFIG_FLATMEM_MANUAL=y
119# CONFIG_SPARSEMEM_MANUAL is not set 129# CONFIG_SPARSEMEM_MANUAL is not set
120CONFIG_FLATMEM=y 130CONFIG_FLATMEM=y
121CONFIG_FLAT_NODE_MEM_MAP=y 131CONFIG_FLAT_NODE_MEM_MAP=y
132# CONFIG_SPARSEMEM_STATIC is not set
133CONFIG_SPLIT_PTLOCK_CPUS=4
122 134
123# 135#
124# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 136# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -140,6 +152,7 @@ CONFIG_FLAT_NODE_MEM_MAP=y
140CONFIG_BINFMT_FLAT=y 152CONFIG_BINFMT_FLAT=y
141# CONFIG_BINFMT_ZFLAT is not set 153# CONFIG_BINFMT_ZFLAT is not set
142# CONFIG_BINFMT_SHARED_FLAT is not set 154# CONFIG_BINFMT_SHARED_FLAT is not set
155# CONFIG_BINFMT_AOUT is not set
143# CONFIG_BINFMT_MISC is not set 156# CONFIG_BINFMT_MISC is not set
144 157
145# 158#
@@ -155,6 +168,7 @@ CONFIG_NET=y
155# 168#
156# Networking options 169# Networking options
157# 170#
171# CONFIG_NETDEBUG is not set
158CONFIG_PACKET=y 172CONFIG_PACKET=y
159# CONFIG_PACKET_MMAP is not set 173# CONFIG_PACKET_MMAP is not set
160CONFIG_UNIX=y 174CONFIG_UNIX=y
@@ -171,18 +185,30 @@ CONFIG_IP_FIB_HASH=y
171# CONFIG_INET_AH is not set 185# CONFIG_INET_AH is not set
172# CONFIG_INET_ESP is not set 186# CONFIG_INET_ESP is not set
173# CONFIG_INET_IPCOMP is not set 187# CONFIG_INET_IPCOMP is not set
188# CONFIG_INET_XFRM_TUNNEL is not set
174# CONFIG_INET_TUNNEL is not set 189# CONFIG_INET_TUNNEL is not set
175# CONFIG_IP_TCPDIAG is not set 190# CONFIG_INET_DIAG is not set
176# CONFIG_IP_TCPDIAG_IPV6 is not set
177# CONFIG_TCP_CONG_ADVANCED is not set 191# CONFIG_TCP_CONG_ADVANCED is not set
178CONFIG_TCP_CONG_BIC=y 192CONFIG_TCP_CONG_BIC=y
179# CONFIG_IPV6 is not set 193# CONFIG_IPV6 is not set
194# CONFIG_INET6_XFRM_TUNNEL is not set
195# CONFIG_INET6_TUNNEL is not set
180# CONFIG_NETFILTER is not set 196# CONFIG_NETFILTER is not set
181 197
182# 198#
199# DCCP Configuration (EXPERIMENTAL)
200#
201# CONFIG_IP_DCCP is not set
202
203#
183# SCTP Configuration (EXPERIMENTAL) 204# SCTP Configuration (EXPERIMENTAL)
184# 205#
185# CONFIG_IP_SCTP is not set 206# CONFIG_IP_SCTP is not set
207
208#
209# TIPC Configuration (EXPERIMENTAL)
210#
211# CONFIG_TIPC is not set
186# CONFIG_ATM is not set 212# CONFIG_ATM is not set
187# CONFIG_BRIDGE is not set 213# CONFIG_BRIDGE is not set
188# CONFIG_VLAN_8021Q is not set 214# CONFIG_VLAN_8021Q is not set
@@ -195,8 +221,11 @@ CONFIG_TCP_CONG_BIC=y
195# CONFIG_NET_DIVERT is not set 221# CONFIG_NET_DIVERT is not set
196# CONFIG_ECONET is not set 222# CONFIG_ECONET is not set
197# CONFIG_WAN_ROUTER is not set 223# CONFIG_WAN_ROUTER is not set
224
225#
226# QoS and/or fair queueing
227#
198# CONFIG_NET_SCHED is not set 228# CONFIG_NET_SCHED is not set
199# CONFIG_NET_CLS_ROUTE is not set
200 229
201# 230#
202# Network testing 231# Network testing
@@ -205,6 +234,7 @@ CONFIG_TCP_CONG_BIC=y
205# CONFIG_HAMRADIO is not set 234# CONFIG_HAMRADIO is not set
206# CONFIG_IRDA is not set 235# CONFIG_IRDA is not set
207# CONFIG_BT is not set 236# CONFIG_BT is not set
237# CONFIG_IEEE80211 is not set
208 238
209# 239#
210# Device Drivers 240# Device Drivers
@@ -218,6 +248,11 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
218# CONFIG_FW_LOADER is not set 248# CONFIG_FW_LOADER is not set
219 249
220# 250#
251# Connector - unified userspace <-> kernelspace linker
252#
253# CONFIG_CONNECTOR is not set
254
255#
221# Memory Technology Devices (MTD) 256# Memory Technology Devices (MTD)
222# 257#
223CONFIG_MTD=y 258CONFIG_MTD=y
@@ -235,6 +270,7 @@ CONFIG_MTD_BLOCK=y
235# CONFIG_FTL is not set 270# CONFIG_FTL is not set
236# CONFIG_NFTL is not set 271# CONFIG_NFTL is not set
237# CONFIG_INFTL is not set 272# CONFIG_INFTL is not set
273# CONFIG_RFD_FTL is not set
238 274
239# 275#
240# RAM/ROM/Flash chip drivers 276# RAM/ROM/Flash chip drivers
@@ -254,13 +290,13 @@ CONFIG_MTD_CFI_I2=y
254CONFIG_MTD_RAM=y 290CONFIG_MTD_RAM=y
255# CONFIG_MTD_ROM is not set 291# CONFIG_MTD_ROM is not set
256# CONFIG_MTD_ABSENT is not set 292# CONFIG_MTD_ABSENT is not set
293# CONFIG_MTD_OBSOLETE_CHIPS is not set
257 294
258# 295#
259# Mapping drivers for chip access 296# Mapping drivers for chip access
260# 297#
261# CONFIG_MTD_COMPLEX_MAPPINGS is not set 298# CONFIG_MTD_COMPLEX_MAPPINGS is not set
262CONFIG_MTD_UCLINUX=y 299CONFIG_MTD_UCLINUX=y
263# CONFIG_MTD_SNAPGEARuC is not set
264# CONFIG_MTD_PLATRAM is not set 300# CONFIG_MTD_PLATRAM is not set
265 301
266# 302#
@@ -269,7 +305,6 @@ CONFIG_MTD_UCLINUX=y
269# CONFIG_MTD_SLRAM is not set 305# CONFIG_MTD_SLRAM is not set
270# CONFIG_MTD_PHRAM is not set 306# CONFIG_MTD_PHRAM is not set
271# CONFIG_MTD_MTDRAM is not set 307# CONFIG_MTD_MTDRAM is not set
272# CONFIG_MTD_BLKMTD is not set
273# CONFIG_MTD_BLOCK2MTD is not set 308# CONFIG_MTD_BLOCK2MTD is not set
274 309
275# 310#
@@ -285,6 +320,11 @@ CONFIG_MTD_UCLINUX=y
285# CONFIG_MTD_NAND is not set 320# CONFIG_MTD_NAND is not set
286 321
287# 322#
323# OneNAND Flash Device Drivers
324#
325# CONFIG_MTD_ONENAND is not set
326
327#
288# Parallel port support 328# Parallel port support
289# 329#
290# CONFIG_PARPORT is not set 330# CONFIG_PARPORT is not set
@@ -296,7 +336,6 @@ CONFIG_MTD_UCLINUX=y
296# 336#
297# Block devices 337# Block devices
298# 338#
299# CONFIG_BLK_DEV_FD is not set
300# CONFIG_BLK_DEV_COW_COMMON is not set 339# CONFIG_BLK_DEV_COW_COMMON is not set
301# CONFIG_BLK_DEV_LOOP is not set 340# CONFIG_BLK_DEV_LOOP is not set
302# CONFIG_BLK_DEV_NBD is not set 341# CONFIG_BLK_DEV_NBD is not set
@@ -304,16 +343,7 @@ CONFIG_BLK_DEV_RAM=y
304CONFIG_BLK_DEV_RAM_COUNT=16 343CONFIG_BLK_DEV_RAM_COUNT=16
305CONFIG_BLK_DEV_RAM_SIZE=4096 344CONFIG_BLK_DEV_RAM_SIZE=4096
306# CONFIG_BLK_DEV_INITRD is not set 345# CONFIG_BLK_DEV_INITRD is not set
307CONFIG_INITRAMFS_SOURCE=""
308# CONFIG_CDROM_PKTCDVD is not set 346# CONFIG_CDROM_PKTCDVD is not set
309
310#
311# IO Schedulers
312#
313CONFIG_IOSCHED_NOOP=y
314# CONFIG_IOSCHED_AS is not set
315# CONFIG_IOSCHED_DEADLINE is not set
316# CONFIG_IOSCHED_CFQ is not set
317# CONFIG_ATA_OVER_ETH is not set 347# CONFIG_ATA_OVER_ETH is not set
318 348
319# 349#
@@ -324,6 +354,7 @@ CONFIG_IOSCHED_NOOP=y
324# 354#
325# SCSI device support 355# SCSI device support
326# 356#
357# CONFIG_RAID_ATTRS is not set
327# CONFIG_SCSI is not set 358# CONFIG_SCSI is not set
328 359
329# 360#
@@ -354,13 +385,15 @@ CONFIG_NETDEVICES=y
354# CONFIG_TUN is not set 385# CONFIG_TUN is not set
355 386
356# 387#
388# PHY device support
389#
390# CONFIG_PHYLIB is not set
391
392#
357# Ethernet (10 or 100Mbit) 393# Ethernet (10 or 100Mbit)
358# 394#
359CONFIG_NET_ETHERNET=y 395CONFIG_NET_ETHERNET=y
360# CONFIG_MII is not set 396# CONFIG_MII is not set
361# CONFIG_NET_VENDOR_SMC is not set
362# CONFIG_NE2000 is not set
363# CONFIG_NET_PCI is not set
364CONFIG_FEC=y 397CONFIG_FEC=y
365# CONFIG_FEC2 is not set 398# CONFIG_FEC2 is not set
366 399
@@ -392,6 +425,7 @@ CONFIG_PPP=y
392# CONFIG_PPP_SYNC_TTY is not set 425# CONFIG_PPP_SYNC_TTY is not set
393# CONFIG_PPP_DEFLATE is not set 426# CONFIG_PPP_DEFLATE is not set
394# CONFIG_PPP_BSDCOMP is not set 427# CONFIG_PPP_BSDCOMP is not set
428# CONFIG_PPP_MPPE is not set
395# CONFIG_PPPOE is not set 429# CONFIG_PPPOE is not set
396# CONFIG_SLIP is not set 430# CONFIG_SLIP is not set
397# CONFIG_SHAPER is not set 431# CONFIG_SHAPER is not set
@@ -425,8 +459,6 @@ CONFIG_PPP=y
425# 459#
426# CONFIG_VT is not set 460# CONFIG_VT is not set
427# CONFIG_SERIAL_NONSTANDARD is not set 461# CONFIG_SERIAL_NONSTANDARD is not set
428# CONFIG_LEDMAN is not set
429# CONFIG_RESETSWITCH is not set
430 462
431# 463#
432# Serial drivers 464# Serial drivers
@@ -450,8 +482,6 @@ CONFIG_LEGACY_PTY_COUNT=256
450# Watchdog Cards 482# Watchdog Cards
451# 483#
452# CONFIG_WATCHDOG is not set 484# CONFIG_WATCHDOG is not set
453# CONFIG_MCFWATCHDOG is not set
454# CONFIG_RTC is not set
455# CONFIG_GEN_RTC is not set 485# CONFIG_GEN_RTC is not set
456# CONFIG_DTLK is not set 486# CONFIG_DTLK is not set
457# CONFIG_R3964 is not set 487# CONFIG_R3964 is not set
@@ -464,14 +494,19 @@ CONFIG_LEGACY_PTY_COUNT=256
464# 494#
465# TPM devices 495# TPM devices
466# 496#
467# CONFIG_MCF_QSPI is not set 497# CONFIG_TCG_TPM is not set
468# CONFIG_M41T11M6 is not set 498# CONFIG_TELCLOCK is not set
469 499
470# 500#
471# I2C support 501# I2C support
472# 502#
473# CONFIG_I2C is not set 503# CONFIG_I2C is not set
474# CONFIG_I2C_SENSOR is not set 504
505#
506# SPI support
507#
508# CONFIG_SPI is not set
509# CONFIG_SPI_MASTER is not set
475 510
476# 511#
477# Dallas's 1-wire bus 512# Dallas's 1-wire bus
@@ -482,6 +517,7 @@ CONFIG_LEGACY_PTY_COUNT=256
482# Hardware Monitoring support 517# Hardware Monitoring support
483# 518#
484# CONFIG_HWMON is not set 519# CONFIG_HWMON is not set
520# CONFIG_HWMON_VID is not set
485 521
486# 522#
487# Misc devices 523# Misc devices
@@ -491,6 +527,7 @@ CONFIG_LEGACY_PTY_COUNT=256
491# Multimedia devices 527# Multimedia devices
492# 528#
493# CONFIG_VIDEO_DEV is not set 529# CONFIG_VIDEO_DEV is not set
530CONFIG_VIDEO_V4L2=y
494 531
495# 532#
496# Digital Video Broadcasting Devices 533# Digital Video Broadcasting Devices
@@ -503,11 +540,6 @@ CONFIG_LEGACY_PTY_COUNT=256
503# CONFIG_FB is not set 540# CONFIG_FB is not set
504 541
505# 542#
506# SPI support
507#
508# CONFIG_SPI is not set
509
510#
511# Sound 543# Sound
512# 544#
513# CONFIG_SOUND is not set 545# CONFIG_SOUND is not set
@@ -517,6 +549,11 @@ CONFIG_LEGACY_PTY_COUNT=256
517# 549#
518# CONFIG_USB_ARCH_HAS_HCD is not set 550# CONFIG_USB_ARCH_HAS_HCD is not set
519# CONFIG_USB_ARCH_HAS_OHCI is not set 551# CONFIG_USB_ARCH_HAS_OHCI is not set
552# CONFIG_USB_ARCH_HAS_EHCI is not set
553
554#
555# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
556#
520 557
521# 558#
522# USB Gadget Support 559# USB Gadget Support
@@ -529,29 +566,43 @@ CONFIG_LEGACY_PTY_COUNT=256
529# CONFIG_MMC is not set 566# CONFIG_MMC is not set
530 567
531# 568#
569# LED devices
570#
571# CONFIG_NEW_LEDS is not set
572
573#
574# LED drivers
575#
576
577#
578# LED Triggers
579#
580
581#
532# InfiniBand support 582# InfiniBand support
533# 583#
534 584
535# 585#
536# SN Devices 586# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
537# 587#
538 588
539# 589#
590# Real Time Clock
591#
592# CONFIG_RTC_CLASS is not set
593
594#
540# File systems 595# File systems
541# 596#
542CONFIG_EXT2_FS=y 597CONFIG_EXT2_FS=y
543# CONFIG_EXT2_FS_XATTR is not set 598# CONFIG_EXT2_FS_XATTR is not set
544# CONFIG_EXT2_FS_XIP is not set 599# CONFIG_EXT2_FS_XIP is not set
545# CONFIG_EXT3_FS is not set 600# CONFIG_EXT3_FS is not set
546# CONFIG_JBD is not set
547# CONFIG_REISERFS_FS is not set 601# CONFIG_REISERFS_FS is not set
548# CONFIG_JFS_FS is not set 602# CONFIG_JFS_FS is not set
549# CONFIG_FS_POSIX_ACL is not set 603# CONFIG_FS_POSIX_ACL is not set
550
551#
552# XFS support
553#
554# CONFIG_XFS_FS is not set 604# CONFIG_XFS_FS is not set
605# CONFIG_OCFS2_FS is not set
555# CONFIG_MINIX_FS is not set 606# CONFIG_MINIX_FS is not set
556CONFIG_ROMFS_FS=y 607CONFIG_ROMFS_FS=y
557# CONFIG_INOTIFY is not set 608# CONFIG_INOTIFY is not set
@@ -559,6 +610,7 @@ CONFIG_ROMFS_FS=y
559# CONFIG_DNOTIFY is not set 610# CONFIG_DNOTIFY is not set
560# CONFIG_AUTOFS_FS is not set 611# CONFIG_AUTOFS_FS is not set
561# CONFIG_AUTOFS4_FS is not set 612# CONFIG_AUTOFS4_FS is not set
613# CONFIG_FUSE_FS is not set
562 614
563# 615#
564# CD-ROM/DVD Filesystems 616# CD-ROM/DVD Filesystems
@@ -581,6 +633,7 @@ CONFIG_SYSFS=y
581# CONFIG_TMPFS is not set 633# CONFIG_TMPFS is not set
582# CONFIG_HUGETLB_PAGE is not set 634# CONFIG_HUGETLB_PAGE is not set
583CONFIG_RAMFS=y 635CONFIG_RAMFS=y
636# CONFIG_CONFIGFS_FS is not set
584 637
585# 638#
586# Miscellaneous filesystems 639# Miscellaneous filesystems
@@ -611,6 +664,7 @@ CONFIG_RAMFS=y
611# CONFIG_NCP_FS is not set 664# CONFIG_NCP_FS is not set
612# CONFIG_CODA_FS is not set 665# CONFIG_CODA_FS is not set
613# CONFIG_AFS_FS is not set 666# CONFIG_AFS_FS is not set
667# CONFIG_9P_FS is not set
614 668
615# 669#
616# Partition Types 670# Partition Types
@@ -627,8 +681,12 @@ CONFIG_MSDOS_PARTITION=y
627# Kernel hacking 681# Kernel hacking
628# 682#
629# CONFIG_PRINTK_TIME is not set 683# CONFIG_PRINTK_TIME is not set
684# CONFIG_MAGIC_SYSRQ is not set
630# CONFIG_DEBUG_KERNEL is not set 685# CONFIG_DEBUG_KERNEL is not set
631CONFIG_LOG_BUF_SHIFT=14 686CONFIG_LOG_BUF_SHIFT=14
687# CONFIG_DEBUG_BUGVERBOSE is not set
688# CONFIG_DEBUG_FS is not set
689# CONFIG_UNWIND_INFO is not set
632# CONFIG_FULLDEBUG is not set 690# CONFIG_FULLDEBUG is not set
633# CONFIG_HIGHPROFILE is not set 691# CONFIG_HIGHPROFILE is not set
634# CONFIG_BOOTPARAM is not set 692# CONFIG_BOOTPARAM is not set
@@ -655,5 +713,6 @@ CONFIG_LOG_BUF_SHIFT=14
655# Library routines 713# Library routines
656# 714#
657# CONFIG_CRC_CCITT is not set 715# CONFIG_CRC_CCITT is not set
716# CONFIG_CRC16 is not set
658# CONFIG_CRC32 is not set 717# CONFIG_CRC32 is not set
659# CONFIG_LIBCRC32C is not set 718# CONFIG_LIBCRC32C is not set
diff --git a/arch/m68knommu/kernel/comempci.c b/arch/m68knommu/kernel/comempci.c
index 8670938f1107..db7a0c1cebae 100644
--- a/arch/m68knommu/kernel/comempci.c
+++ b/arch/m68knommu/kernel/comempci.c
@@ -357,7 +357,8 @@ void pcibios_fixup_bus(struct pci_bus *b)
357 357
358/*****************************************************************************/ 358/*****************************************************************************/
359 359
360void pcibios_align_resource(void *data, struct resource *res, unsigned long size, unsigned long align) 360void pcibios_align_resource(void *data, struct resource *res,
361 resource_size_t size, resource_size_t align)
361{ 362{
362} 363}
363 364
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index 6a2f0c693254..59ced831b792 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -3,63 +3,13 @@
3 * 3 *
4 * (C) Copyright 2002-2006, Greg Ungerer <gerg@snapgear.com> 4 * (C) Copyright 2002-2006, Greg Ungerer <gerg@snapgear.com>
5 * 5 *
6 * This ends up looking compilcated, because of the number of 6 * This linker script is equiped to build either ROM loaded or RAM
7 * address variations for ram and rom/flash layouts. The real 7 * run kernels.
8 * work of the linker script is all at the end, and reasonably
9 * strait forward.
10 */ 8 */
11 9
12#include <linux/config.h> 10#include <linux/config.h>
13#include <asm-generic/vmlinux.lds.h> 11#include <asm-generic/vmlinux.lds.h>
14 12
15/*
16 * Original Palm pilot (same for Xcopilot).
17 * There is really only a rom target for this.
18 */
19#ifdef CONFIG_PILOT3
20#define ROMVEC_START 0x10c00000
21#define ROMVEC_LENGTH 0x10400
22#define ROM_START 0x10c10400
23#define ROM_LENGTH 0xfec00
24#define ROM_END 0x10d00000
25#define DATA_ADDR CONFIG_KERNELBASE
26#endif
27
28/*
29 * Same setup on both the uCsimm and uCdimm.
30 */
31#if defined(CONFIG_UCSIMM) || defined(CONFIG_UCDIMM)
32#ifdef CONFIG_RAMKERNEL
33#define ROMVEC_START 0x10c10000
34#define ROMVEC_LENGTH 0x400
35#define ROM_START 0x10c10400
36#define ROM_LENGTH 0x1efc00
37#define ROM_END 0x10e00000
38#endif
39#ifdef CONFIG_ROMKERNEL
40#define ROMVEC_START 0x10c10000
41#define ROMVEC_LENGTH 0x400
42#define ROM_START 0x10c10400
43#define ROM_LENGTH 0x1efc00
44#define ROM_END 0x10e00000
45#endif
46#ifdef CONFIG_HIMEMKERNEL
47#define ROMVEC_START 0x00600000
48#define ROMVEC_LENGTH 0x400
49#define ROM_START 0x00600400
50#define ROM_LENGTH 0x1efc00
51#define ROM_END 0x007f0000
52#endif
53#endif
54
55#ifdef CONFIG_UCQUICC
56#define ROMVEC_START 0x00000000
57#define ROMVEC_LENGTH 0x404
58#define ROM_START 0x00000404
59#define ROM_LENGTH 0x1ff6fc
60#define ROM_END 0x00200000
61#endif
62
63#if defined(CONFIG_RAMKERNEL) 13#if defined(CONFIG_RAMKERNEL)
64#define RAM_START CONFIG_KERNELBASE 14#define RAM_START CONFIG_KERNELBASE
65#define RAM_LENGTH (CONFIG_RAMBASE + CONFIG_RAMSIZE - CONFIG_KERNELBASE) 15#define RAM_LENGTH (CONFIG_RAMBASE + CONFIG_RAMSIZE - CONFIG_KERNELBASE)
@@ -71,6 +21,10 @@
71#if defined(CONFIG_ROMKERNEL) || defined(CONFIG_HIMEMKERNEL) 21#if defined(CONFIG_ROMKERNEL) || defined(CONFIG_HIMEMKERNEL)
72#define RAM_START CONFIG_RAMBASE 22#define RAM_START CONFIG_RAMBASE
73#define RAM_LENGTH CONFIG_RAMSIZE 23#define RAM_LENGTH CONFIG_RAMSIZE
24#define ROMVEC_START CONFIG_ROMVEC
25#define ROMVEC_LENGTH CONFIG_ROMVECSIZE
26#define ROM_START CONFIG_ROMSTART
27#define ROM_LENGTH CONFIG_ROMSIZE
74#define TEXT rom 28#define TEXT rom
75#define DATA ram 29#define DATA ram
76#define INIT ram 30#define INIT ram
@@ -90,7 +44,6 @@ MEMORY {
90#ifdef ROM_START 44#ifdef ROM_START
91 romvec : ORIGIN = ROMVEC_START, LENGTH = ROMVEC_LENGTH 45 romvec : ORIGIN = ROMVEC_START, LENGTH = ROMVEC_LENGTH
92 rom : ORIGIN = ROM_START, LENGTH = ROM_LENGTH 46 rom : ORIGIN = ROM_START, LENGTH = ROM_LENGTH
93 erom : ORIGIN = ROM_END, LENGTH = 0
94#endif 47#endif
95} 48}
96 49
@@ -167,13 +120,6 @@ SECTIONS {
167 _etext = . ; 120 _etext = . ;
168 } > TEXT 121 } > TEXT
169 122
170#ifdef ROM_END
171 . = ROM_END ;
172 .erom : {
173 __rom_end = . ;
174 } > erom
175#endif
176
177 .data DATA_ADDR : { 123 .data DATA_ADDR : {
178 . = ALIGN(4); 124 . = ALIGN(4);
179 _sdata = . ; 125 _sdata = . ;
diff --git a/arch/m68knommu/platform/68328/Makefile b/arch/m68knommu/platform/68328/Makefile
index 1b3b719e4479..5e5435552d56 100644
--- a/arch/m68knommu/platform/68328/Makefile
+++ b/arch/m68knommu/platform/68328/Makefile
@@ -8,6 +8,7 @@ head-$(CONFIG_DRAGEN2) = head-de2.o
8 8
9obj-y += entry.o ints.o timers.o 9obj-y += entry.o ints.o timers.o
10obj-$(CONFIG_M68328) += config.o 10obj-$(CONFIG_M68328) += config.o
11obj-$(CONFIG_ROM) += romvec.o
11 12
12extra-y := head.o 13extra-y := head.o
13extra-$(CONFIG_M68328) += bootlogo.rh head.o 14extra-$(CONFIG_M68328) += bootlogo.rh head.o
diff --git a/arch/m68knommu/platform/68328/head-rom.S b/arch/m68knommu/platform/68328/head-rom.S
index 2b448a297011..234430b9551c 100644
--- a/arch/m68knommu/platform/68328/head-rom.S
+++ b/arch/m68knommu/platform/68328/head-rom.S
@@ -28,6 +28,8 @@ _ramstart:
28_ramend: 28_ramend:
29.long 0 29.long 0
30 30
31#define RAMEND (CONFIG_RAMBASE + CONFIG_RAMSIZE)
32
31#ifdef CONFIG_INIT_LCD 33#ifdef CONFIG_INIT_LCD
32splash_bits: 34splash_bits:
33#include "bootlogo.rh" 35#include "bootlogo.rh"
@@ -48,7 +50,7 @@ _stext: movew #0x2700,%sr
48 moveb #0x81, 0xfffffA27 /* LCKCON */ 50 moveb #0x81, 0xfffffA27 /* LCKCON */
49 movew #0xff00, 0xfffff412 /* LCD pins */ 51 movew #0xff00, 0xfffff412 /* LCD pins */
50#endif 52#endif
51 moveal #__ramend-CONFIG_MEMORY_RESERVE*0x100000 - 0x10, %sp 53 moveal #RAMEND-CONFIG_MEMORY_RESERVE*0x100000 - 0x10, %sp
52 movew #32767, %d0 /* PLL settle wait loop */ 54 movew #32767, %d0 /* PLL settle wait loop */
531: subq #1, %d0 551: subq #1, %d0
54 bne 1b 56 bne 1b
@@ -73,13 +75,13 @@ _stext: movew #0x2700,%sr
73 bhi 1b 75 bhi 1b
74 76
75 movel #_sdata, %d0 77 movel #_sdata, %d0
76 movel %d0, _rambase 78 movel %d0, _rambase
77 movel #_ebss, %d0 79 movel #_ebss, %d0
78 movel %d0, _ramstart 80 movel %d0, _ramstart
79 movel #__ramend-CONFIG_MEMORY_RESERVE*0x100000, %d0 81 movel #RAMEND-CONFIG_MEMORY_RESERVE*0x100000, %d0
80 movel %d0, _ramend 82 movel %d0, _ramend
81 movel #__ramvec, %d0 83 movel #CONFIG_VECTORBASE, %d0
82 movel %d0, _ramvec 84 movel %d0, _ramvec
83 85
84/* 86/*
85 * load the current task pointer and stack 87 * load the current task pointer and stack
diff --git a/arch/m68knommu/platform/68328/ints.c b/arch/m68knommu/platform/68328/ints.c
index 7437217813d2..2dda7339aae5 100644
--- a/arch/m68knommu/platform/68328/ints.c
+++ b/arch/m68knommu/platform/68328/ints.c
@@ -18,6 +18,7 @@
18 18
19#include <asm/system.h> 19#include <asm/system.h>
20#include <asm/irq.h> 20#include <asm/irq.h>
21#include <asm/irqnode.h>
21#include <asm/traps.h> 22#include <asm/traps.h>
22#include <asm/io.h> 23#include <asm/io.h>
23#include <asm/machdep.h> 24#include <asm/machdep.h>
@@ -82,25 +83,6 @@ unsigned int local_irq_count[NR_CPUS];
82/* irq node variables for the 32 (potential) on chip sources */ 83/* irq node variables for the 32 (potential) on chip sources */
83static irq_node_t int_irq_list[NR_IRQS]; 84static irq_node_t int_irq_list[NR_IRQS];
84 85
85#if !defined(CONFIG_DRAGEN2)
86asm (".global _start, __ramend/n/t"
87 ".section .romvec/n"
88 "e_vectors:\n\t"
89 ".long __ramend-4, _start, buserr, trap, trap, trap, trap, trap\n\t"
90 ".long trap, trap, trap, trap, trap, trap, trap, trap\n\t"
91 ".long trap, trap, trap, trap, trap, trap, trap, trap\n\t"
92 ".long trap, trap, trap, trap\n\t"
93 ".long trap, trap, trap, trap\n\t"
94 /*.long inthandler, inthandler, inthandler, inthandler
95 .long inthandler4, inthandler, inthandler, inthandler */
96 /* TRAP #0-15 */
97 ".long system_call, trap, trap, trap, trap, trap, trap, trap\n\t"
98 ".long trap, trap, trap, trap, trap, trap, trap, trap\n\t"
99 ".long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n\t"
100 ".text\n"
101 "ignore: rte");
102#endif
103
104/* 86/*
105 * This function should be called during kernel startup to initialize 87 * This function should be called during kernel startup to initialize
106 * the IRQ handling routines. 88 * the IRQ handling routines.
diff --git a/arch/m68knommu/platform/68328/romvec.S b/arch/m68knommu/platform/68328/romvec.S
new file mode 100644
index 000000000000..3e7fe1e14913
--- /dev/null
+++ b/arch/m68knommu/platform/68328/romvec.S
@@ -0,0 +1,37 @@
1/*
2 * linux/arch/m68knommu/platform/68328/romvec.S
3 *
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
6 * for more details.
7 *
8 * Copyright 1996 Roman Zippel
9 * Copyright 1999 D. Jeff Dionne <jeff@rt-control.com>
10 * Copyright 2006 Greg Ungerer <gerg@snapgear.com>
11 */
12
13#include <linux/config.h>
14
15.global _start
16.global _buserr
17.global trap
18.global system_call
19
20.section .romvec
21
22e_vectors:
23.long CONFIG_RAMBASE+CONFIG_RAMSIZE-4, _start, buserr, trap
24.long trap, trap, trap, trap
25.long trap, trap, trap, trap
26.long trap, trap, trap, trap
27.long trap, trap, trap, trap
28.long trap, trap, trap, trap
29.long trap, trap, trap, trap
30.long trap, trap, trap, trap
31/* TRAP #0-15 */
32.long system_call, trap, trap, trap
33.long trap, trap, trap, trap
34.long trap, trap, trap, trap
35.long trap, trap, trap, trap
36.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
37
diff --git a/arch/m68knommu/platform/68360/config.c b/arch/m68knommu/platform/68360/config.c
index 3db244625f0f..69c670dfd62b 100644
--- a/arch/m68knommu/platform/68360/config.c
+++ b/arch/m68knommu/platform/68360/config.c
@@ -141,13 +141,13 @@ int BSP_set_clock_mmss (unsigned long nowtime)
141void BSP_reset (void) 141void BSP_reset (void)
142{ 142{
143 local_irq_disable(); 143 local_irq_disable();
144 asm volatile (" 144 asm volatile (
145 moveal #_start, %a0; 145 "moveal #_start, %a0;\n"
146 moveb #0, 0xFFFFF300; 146 "moveb #0, 0xFFFFF300;\n"
147 moveal 0(%a0), %sp; 147 "moveal 0(%a0), %sp;\n"
148 moveal 4(%a0), %a0; 148 "moveal 4(%a0), %a0;\n"
149 jmp (%a0); 149 "jmp (%a0);\n"
150 "); 150 );
151} 151}
152 152
153unsigned char *scc1_hwaddr; 153unsigned char *scc1_hwaddr;
diff --git a/arch/m68knommu/platform/68360/head-ram.S b/arch/m68knommu/platform/68360/head-ram.S
index a5c639a51eef..f497713a4ec7 100644
--- a/arch/m68knommu/platform/68360/head-ram.S
+++ b/arch/m68knommu/platform/68360/head-ram.S
@@ -18,7 +18,6 @@
18.global _start 18.global _start
19 19
20.global _rambase 20.global _rambase
21.global __ramvec
22.global _ramvec 21.global _ramvec
23.global _ramstart 22.global _ramstart
24.global _ramend 23.global _ramend
@@ -26,6 +25,8 @@
26.global _quicc_base 25.global _quicc_base
27.global _periph_base 26.global _periph_base
28 27
28#define RAMEND (CONFIG_RAMBASE + CONFIG_RAMSIZE)
29
29#define REGB 0x1000 30#define REGB 0x1000
30#define PEPAR (_dprbase + REGB + 0x0016) 31#define PEPAR (_dprbase + REGB + 0x0016)
31#define GMR (_dprbase + REGB + 0x0040) 32#define GMR (_dprbase + REGB + 0x0040)
@@ -103,7 +104,7 @@ _stext:
103 nop 104 nop
104 ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */ 105 ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */
105 /* We should not need to setup the boot stack the reset should do it. */ 106 /* We should not need to setup the boot stack the reset should do it. */
106 movea.l #__ramend, %sp /*set up stack at the end of DRAM:*/ 107 movea.l #RAMEND, %sp /*set up stack at the end of DRAM:*/
107 108
108set_mbar_register: 109set_mbar_register:
109 moveq.l #0x07, %d1 /* Setup MBAR */ 110 moveq.l #0x07, %d1 /* Setup MBAR */
@@ -163,7 +164,7 @@ configure_memory_controller:
163 move.l %d0, GMR 164 move.l %d0, GMR
164 165
165configure_chip_select_0: 166configure_chip_select_0:
166 move.l #__ramend, %d0 167 move.l #RAMEND, %d0
167 subi.l #__ramstart, %d0 168 subi.l #__ramstart, %d0
168 subq.l #0x01, %d0 169 subq.l #0x01, %d0
169 eori.l #SIM_OR_MASK, %d0 170 eori.l #SIM_OR_MASK, %d0
@@ -234,16 +235,10 @@ store_ram_size:
234 /* Set ram size information */ 235 /* Set ram size information */
235 move.l #_sdata, _rambase 236 move.l #_sdata, _rambase
236 move.l #_ebss, _ramstart 237 move.l #_ebss, _ramstart
237 move.l #__ramend, %d0 238 move.l #RAMEND, %d0
238 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/ 239 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
239 move.l %d0, _ramend /* Different from __ramend.*/ 240 move.l %d0, _ramend /* Different from RAMEND.*/
240 241
241store_flash_size:
242 /* Set rom size information */
243 move.l #__rom_end, %d0
244 sub.l #__rom_start, %d0
245 move.l %d0, rom_length
246
247 pea 0 242 pea 0
248 pea env 243 pea env
249 pea %sp@(4) 244 pea %sp@(4)
@@ -286,7 +281,7 @@ _dprbase:
286 */ 281 */
287 282
288.section ".data.initvect","awx" 283.section ".data.initvect","awx"
289 .long __ramend /* Reset: Initial Stack Pointer - 0. */ 284 .long RAMEND /* Reset: Initial Stack Pointer - 0. */
290 .long _start /* Reset: Initial Program Counter - 1. */ 285 .long _start /* Reset: Initial Program Counter - 1. */
291 .long buserr /* Bus Error - 2. */ 286 .long buserr /* Bus Error - 2. */
292 .long trap /* Address Error - 3. */ 287 .long trap /* Address Error - 3. */
diff --git a/arch/m68knommu/platform/68360/head-rom.S b/arch/m68knommu/platform/68360/head-rom.S
index 0da357a4cfee..2d28c3e19a88 100644
--- a/arch/m68knommu/platform/68360/head-rom.S
+++ b/arch/m68knommu/platform/68360/head-rom.S
@@ -18,7 +18,6 @@
18.global _start 18.global _start
19 19
20.global _rambase 20.global _rambase
21.global __ramvec
22.global _ramvec 21.global _ramvec
23.global _ramstart 22.global _ramstart
24.global _ramend 23.global _ramend
@@ -26,6 +25,8 @@
26.global _quicc_base 25.global _quicc_base
27.global _periph_base 26.global _periph_base
28 27
28#define RAMEND (CONFIG_RAMBASE + CONFIG_RAMSIZE)
29
29#define REGB 0x1000 30#define REGB 0x1000
30#define PEPAR (_dprbase + REGB + 0x0016) 31#define PEPAR (_dprbase + REGB + 0x0016)
31#define GMR (_dprbase + REGB + 0x0040) 32#define GMR (_dprbase + REGB + 0x0040)
@@ -115,7 +116,7 @@ _stext:
115 nop 116 nop
116 ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */ 117 ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */
117 /* We should not need to setup the boot stack the reset should do it. */ 118 /* We should not need to setup the boot stack the reset should do it. */
118 movea.l #__ramend, %sp /* set up stack at the end of DRAM:*/ 119 movea.l #RAMEND, %sp /* set up stack at the end of DRAM:*/
119 120
120 121
121set_mbar_register: 122set_mbar_register:
@@ -245,16 +246,10 @@ store_ram_size:
245 /* Set ram size information */ 246 /* Set ram size information */
246 move.l #_sdata, _rambase 247 move.l #_sdata, _rambase
247 move.l #_ebss, _ramstart 248 move.l #_ebss, _ramstart
248 move.l #__ramend, %d0 249 move.l #RAMEND, %d0
249 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/ 250 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
250 move.l %d0, _ramend /* Different from __ramend.*/ 251 move.l %d0, _ramend /* Different from RAMEND.*/
251 252
252store_flash_size:
253 /* Set rom size information */
254 move.l #__rom_end, %d0
255 sub.l #__rom_start, %d0
256 move.l %d0, rom_length
257
258 pea 0 253 pea 0
259 pea env 254 pea env
260 pea %sp@(4) 255 pea %sp@(4)
@@ -298,7 +293,7 @@ _dprbase:
298 */ 293 */
299 294
300.section ".data.initvect","awx" 295.section ".data.initvect","awx"
301 .long __ramend /* Reset: Initial Stack Pointer - 0. */ 296 .long RAMEND /* Reset: Initial Stack Pointer - 0. */
302 .long _start /* Reset: Initial Program Counter - 1. */ 297 .long _start /* Reset: Initial Program Counter - 1. */
303 .long buserr /* Bus Error - 2. */ 298 .long buserr /* Bus Error - 2. */
304 .long trap /* Address Error - 3. */ 299 .long trap /* Address Error - 3. */
diff --git a/arch/m68knommu/platform/68360/ints.c b/arch/m68knommu/platform/68360/ints.c
index ba184db1651b..0245fc4a4781 100644
--- a/arch/m68knommu/platform/68360/ints.c
+++ b/arch/m68knommu/platform/68360/ints.c
@@ -20,6 +20,7 @@
20 20
21#include <asm/system.h> 21#include <asm/system.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
23#include <asm/irqnode.h>
23#include <asm/traps.h> 24#include <asm/traps.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/machdep.h> 26#include <asm/machdep.h>
diff --git a/arch/m68knommu/platform/68EZ328/config.c b/arch/m68knommu/platform/68EZ328/config.c
index d8d56e5de310..15a14a67c2bf 100644
--- a/arch/m68knommu/platform/68EZ328/config.c
+++ b/arch/m68knommu/platform/68EZ328/config.c
@@ -42,13 +42,13 @@ void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int
42void m68ez328_reset(void) 42void m68ez328_reset(void)
43{ 43{
44 local_irq_disable(); 44 local_irq_disable();
45 asm volatile (" 45 asm volatile (
46 moveal #0x10c00000, %a0; 46 "moveal #0x10c00000, %a0;\n"
47 moveb #0, 0xFFFFF300; 47 "moveb #0, 0xFFFFF300;\n"
48 moveal 0(%a0), %sp; 48 "moveal 0(%a0), %sp;\n"
49 moveal 4(%a0), %a0; 49 "moveal 4(%a0), %a0;\n"
50 jmp (%a0); 50 "jmp (%a0);\n"
51 "); 51 );
52} 52}
53 53
54/***************************************************************************/ 54/***************************************************************************/
diff --git a/arch/m68knommu/platform/68VZ328/config.c b/arch/m68knommu/platform/68VZ328/config.c
index d926524cdf82..4058de5c8fa2 100644
--- a/arch/m68knommu/platform/68VZ328/config.c
+++ b/arch/m68knommu/platform/68VZ328/config.c
@@ -141,13 +141,13 @@ static void init_hardware(char *command, int size)
141static void m68vz328_reset(void) 141static void m68vz328_reset(void)
142{ 142{
143 local_irq_disable(); 143 local_irq_disable();
144 asm volatile (" 144 asm volatile (
145 moveal #0x10c00000, %a0; 145 "moveal #0x10c00000, %a0;\n\t"
146 moveb #0, 0xFFFFF300; 146 "moveb #0, 0xFFFFF300;\n\t"
147 moveal 0(%a0), %sp; 147 "moveal 0(%a0), %sp;\n\t"
148 moveal 4(%a0), %a0; 148 "moveal 4(%a0), %a0;\n\t"
149 jmp (%a0); 149 "jmp (%a0);\n"
150 "); 150 );
151} 151}
152 152
153unsigned char *cs8900a_hwaddr; 153unsigned char *cs8900a_hwaddr;
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 35e038a974c6..747a9c1228f2 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -308,6 +308,7 @@ config MIPS_ATLAS
308 select SYS_SUPPORTS_64BIT_KERNEL 308 select SYS_SUPPORTS_64BIT_KERNEL
309 select SYS_SUPPORTS_BIG_ENDIAN 309 select SYS_SUPPORTS_BIG_ENDIAN
310 select SYS_SUPPORTS_LITTLE_ENDIAN 310 select SYS_SUPPORTS_LITTLE_ENDIAN
311 select SYS_SUPPORTS_MULTITHREADING if EXPERIMENTAL
311 help 312 help
312 This enables support for the MIPS Technologies Atlas evaluation 313 This enables support for the MIPS Technologies Atlas evaluation
313 board. 314 board.
@@ -324,6 +325,7 @@ config MIPS_MALTA
324 select I8259 325 select I8259
325 select MIPS_BOARDS_GEN 326 select MIPS_BOARDS_GEN
326 select MIPS_BONITO64 327 select MIPS_BONITO64
328 select MIPS_CPU_SCACHE
327 select MIPS_GT64120 329 select MIPS_GT64120
328 select MIPS_MSC 330 select MIPS_MSC
329 select SWAP_IO_SPACE 331 select SWAP_IO_SPACE
@@ -336,6 +338,7 @@ config MIPS_MALTA
336 select SYS_SUPPORTS_64BIT_KERNEL 338 select SYS_SUPPORTS_64BIT_KERNEL
337 select SYS_SUPPORTS_BIG_ENDIAN 339 select SYS_SUPPORTS_BIG_ENDIAN
338 select SYS_SUPPORTS_LITTLE_ENDIAN 340 select SYS_SUPPORTS_LITTLE_ENDIAN
341 select SYS_SUPPORTS_MULTITHREADING
339 help 342 help
340 This enables support for the MIPS Technologies Malta evaluation 343 This enables support for the MIPS Technologies Malta evaluation
341 board. 344 board.
@@ -358,7 +361,7 @@ config MIPS_SEAD
358 board. 361 board.
359 362
360config WR_PPMC 363config WR_PPMC
361 bool "Support for Wind River PPMC board" 364 bool "Wind River PPMC board"
362 select IRQ_CPU 365 select IRQ_CPU
363 select BOOT_ELF32 366 select BOOT_ELF32
364 select DMA_NONCOHERENT 367 select DMA_NONCOHERENT
@@ -536,6 +539,7 @@ config PMC_YOSEMITE
536 select SYS_SUPPORTS_64BIT_KERNEL 539 select SYS_SUPPORTS_64BIT_KERNEL
537 select SYS_SUPPORTS_BIG_ENDIAN 540 select SYS_SUPPORTS_BIG_ENDIAN
538 select SYS_SUPPORTS_HIGHMEM 541 select SYS_SUPPORTS_HIGHMEM
542 select SYS_SUPPORTS_SMP
539 help 543 help
540 Yosemite is an evaluation board for the RM9000x2 processor 544 Yosemite is an evaluation board for the RM9000x2 processor
541 manufactured by PMC-Sierra. 545 manufactured by PMC-Sierra.
@@ -590,6 +594,7 @@ config SGI_IP22
590 select SYS_SUPPORTS_32BIT_KERNEL 594 select SYS_SUPPORTS_32BIT_KERNEL
591 select SYS_SUPPORTS_64BIT_KERNEL 595 select SYS_SUPPORTS_64BIT_KERNEL
592 select SYS_SUPPORTS_BIG_ENDIAN 596 select SYS_SUPPORTS_BIG_ENDIAN
597 select SYS_SUPPORTS_SMP
593 help 598 help
594 This are the SGI Indy, Challenge S and Indigo2, as well as certain 599 This are the SGI Indy, Challenge S and Indigo2, as well as certain
595 OEM variants like the Tandem CMN B006S. To compile a Linux kernel 600 OEM variants like the Tandem CMN B006S. To compile a Linux kernel
@@ -601,6 +606,7 @@ config SGI_IP27
601 select ARC64 606 select ARC64
602 select BOOT_ELF64 607 select BOOT_ELF64
603 select DMA_IP27 608 select DMA_IP27
609 select EARLY_PRINTK
604 select HW_HAS_PCI 610 select HW_HAS_PCI
605 select PCI_DOMAINS 611 select PCI_DOMAINS
606 select SYS_HAS_CPU_R10000 612 select SYS_HAS_CPU_R10000
@@ -1249,7 +1255,7 @@ config CPU_R6000
1249 select CPU_SUPPORTS_32BIT_KERNEL 1255 select CPU_SUPPORTS_32BIT_KERNEL
1250 help 1256 help
1251 MIPS Technologies R6000 and R6000A series processors. Note these 1257 MIPS Technologies R6000 and R6000A series processors. Note these
1252 processors are extremly rare and the support for them is incomplete. 1258 processors are extremely rare and the support for them is incomplete.
1253 1259
1254config CPU_NEVADA 1260config CPU_NEVADA
1255 bool "RM52xx" 1261 bool "RM52xx"
@@ -1370,7 +1376,7 @@ config SYS_HAS_CPU_SB1
1370endmenu 1376endmenu
1371 1377
1372# 1378#
1373# These two indicate any levelof the MIPS32 and MIPS64 architecture 1379# These two indicate any level of the MIPS32 and MIPS64 architecture
1374# 1380#
1375config CPU_MIPS32 1381config CPU_MIPS32
1376 bool 1382 bool
@@ -1381,7 +1387,7 @@ config CPU_MIPS64
1381 default y if CPU_MIPS64_R1 || CPU_MIPS64_R2 1387 default y if CPU_MIPS64_R1 || CPU_MIPS64_R2
1382 1388
1383# 1389#
1384# These two indicate the revision of the architecture, either 32 bot 64 bit. 1390# These two indicate the revision of the architecture, either Release 1 or Release 2
1385# 1391#
1386config CPU_MIPSR1 1392config CPU_MIPSR1
1387 bool 1393 bool
@@ -1474,6 +1480,13 @@ config IP22_CPU_SCACHE
1474 bool 1480 bool
1475 select BOARD_SCACHE 1481 select BOARD_SCACHE
1476 1482
1483#
1484# Support for a MIPS32 / MIPS64 style S-caches
1485#
1486config MIPS_CPU_SCACHE
1487 bool
1488 select BOARD_SCACHE
1489
1477config R5000_CPU_SCACHE 1490config R5000_CPU_SCACHE
1478 bool 1491 bool
1479 select BOARD_SCACHE 1492 select BOARD_SCACHE
@@ -1493,32 +1506,57 @@ config SIBYTE_DMA_PAGEOPS
1493config CPU_HAS_PREFETCH 1506config CPU_HAS_PREFETCH
1494 bool 1507 bool
1495 1508
1496config MIPS_MT
1497 bool "Enable MIPS MT"
1498
1499choice 1509choice
1500 prompt "MIPS MT options" 1510 prompt "MIPS MT options"
1501 depends on MIPS_MT 1511
1512config MIPS_MT_DISABLED
1513 bool "Disable multithreading support."
1514 help
1515 Use this option if your workload can't take advantage of
1516 MIPS hardware multithreading support. On systems that don't have
1517 the option of an MT-enabled processor this option will be the only
1518 option in this menu.
1502 1519
1503config MIPS_MT_SMTC 1520config MIPS_MT_SMTC
1504 bool "SMTC: Use all TCs on all VPEs for SMP" 1521 bool "SMTC: Use all TCs on all VPEs for SMP"
1522 depends on CPU_MIPS32_R2
1523 #depends on CPU_MIPS64_R2 # once there is hardware ...
1524 depends on SYS_SUPPORTS_MULTITHREADING
1505 select CPU_MIPSR2_IRQ_VI 1525 select CPU_MIPSR2_IRQ_VI
1506 select CPU_MIPSR2_SRS 1526 select CPU_MIPSR2_SRS
1527 select MIPS_MT
1507 select SMP 1528 select SMP
1529 help
1530 This is a kernel model which is known a SMTC or lately has been
1531 marketesed into SMVP.
1508 1532
1509config MIPS_MT_SMP 1533config MIPS_MT_SMP
1510 bool "Use 1 TC on each available VPE for SMP" 1534 bool "Use 1 TC on each available VPE for SMP"
1535 depends on SYS_SUPPORTS_MULTITHREADING
1536 select CPU_MIPSR2_IRQ_VI
1537 select CPU_MIPSR2_SRS
1538 select MIPS_MT
1511 select SMP 1539 select SMP
1540 help
1541 This is a kernel model which is also known a VSMP or lately
1542 has been marketesed into SMVP.
1512 1543
1513config MIPS_VPE_LOADER 1544config MIPS_VPE_LOADER
1514 bool "VPE loader support." 1545 bool "VPE loader support."
1515 depends on MIPS_MT 1546 depends on SYS_SUPPORTS_MULTITHREADING
1547 select MIPS_MT
1516 help 1548 help
1517 Includes a loader for loading an elf relocatable object 1549 Includes a loader for loading an elf relocatable object
1518 onto another VPE and running it. 1550 onto another VPE and running it.
1519 1551
1520endchoice 1552endchoice
1521 1553
1554config MIPS_MT
1555 bool
1556
1557config SYS_SUPPORTS_MULTITHREADING
1558 bool
1559
1522config MIPS_MT_FPAFF 1560config MIPS_MT_FPAFF
1523 bool "Dynamic FPU affinity for FP-intensive threads" 1561 bool "Dynamic FPU affinity for FP-intensive threads"
1524 depends on MIPS_MT 1562 depends on MIPS_MT
@@ -1575,32 +1613,23 @@ config CPU_HAS_LLSC
1575config CPU_HAS_WB 1613config CPU_HAS_WB
1576 bool 1614 bool
1577 1615
1616#
1617# Vectored interrupt mode is an R2 feature
1618#
1578config CPU_MIPSR2_IRQ_VI 1619config CPU_MIPSR2_IRQ_VI
1579 bool "Vectored interrupt mode" 1620 bool
1580 depends on CPU_MIPSR2
1581 help
1582 Vectored interrupt mode allowing faster dispatching of interrupts.
1583 The board support code needs to be written to take advantage of this
1584 mode. Compatibility code is included to allow the kernel to run on
1585 a CPU that does not support vectored interrupts. It's safe to
1586 say Y here.
1587 1621
1622#
1623# Extended interrupt mode is an R2 feature
1624#
1588config CPU_MIPSR2_IRQ_EI 1625config CPU_MIPSR2_IRQ_EI
1589 bool "External interrupt controller mode" 1626 bool
1590 depends on CPU_MIPSR2
1591 help
1592 Extended interrupt mode takes advantage of an external interrupt
1593 controller to allow fast dispatching from many possible interrupt
1594 sources. Say N unless you know that external interrupt support is
1595 required.
1596 1627
1628#
1629# Shadow registers are an R2 feature
1630#
1597config CPU_MIPSR2_SRS 1631config CPU_MIPSR2_SRS
1598 bool "Make shadow set registers available for interrupt handlers" 1632 bool
1599 depends on CPU_MIPSR2_IRQ_VI || CPU_MIPSR2_IRQ_EI
1600 help
1601 Allow the kernel to use shadow register sets for fast interrupts.
1602 Interrupt handlers must be specially written to use shadow sets.
1603 Say N unless you know that shadow register set upport is needed.
1604 1633
1605config CPU_HAS_SYNC 1634config CPU_HAS_SYNC
1606 bool 1635 bool
@@ -1618,6 +1647,11 @@ config GENERIC_IRQ_PROBE
1618 bool 1647 bool
1619 default y 1648 default y
1620 1649
1650config IRQ_PER_CPU
1651 depends on SMP
1652 bool
1653 default y
1654
1621# 1655#
1622# - Highmem only makes sense for the 32-bit kernel. 1656# - Highmem only makes sense for the 32-bit kernel.
1623# - The current highmem code will only work properly on physically indexed 1657# - The current highmem code will only work properly on physically indexed
@@ -1676,8 +1710,8 @@ source "mm/Kconfig"
1676 1710
1677config SMP 1711config SMP
1678 bool "Multi-Processing support" 1712 bool "Multi-Processing support"
1679 depends on CPU_RM9000 || ((SIBYTE_BCM1x80 || SIBYTE_BCM1x55 || SIBYTE_SB1250 || QEMU) && !SIBYTE_STANDALONE) || SGI_IP27 || MIPS_MT_SMP || MIPS_MT_SMTC 1713 depends on SYS_SUPPORTS_SMP
1680 ---help--- 1714 help
1681 This enables support for systems with more than one CPU. If you have 1715 This enables support for systems with more than one CPU. If you have
1682 a system with only one CPU, like most personal computers, say N. If 1716 a system with only one CPU, like most personal computers, say N. If
1683 you have a system with more than one CPU, say Y. 1717 you have a system with more than one CPU, say Y.
@@ -1696,6 +1730,9 @@ config SMP
1696 1730
1697 If you don't know what to do here, say N. 1731 If you don't know what to do here, say N.
1698 1732
1733config SYS_SUPPORTS_SMP
1734 bool
1735
1699config NR_CPUS 1736config NR_CPUS
1700 int "Maximum number of CPUs (2-64)" 1737 int "Maximum number of CPUs (2-64)"
1701 range 2 64 1738 range 2 64
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index d5930148495a..ebbb9adc0e2f 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -374,6 +374,7 @@ core-$(CONFIG_PMC_YOSEMITE) += arch/mips/pmc-sierra/yosemite/
374cflags-$(CONFIG_PMC_YOSEMITE) += -Iinclude/asm-mips/mach-yosemite 374cflags-$(CONFIG_PMC_YOSEMITE) += -Iinclude/asm-mips/mach-yosemite
375load-$(CONFIG_PMC_YOSEMITE) += 0xffffffff80100000 375load-$(CONFIG_PMC_YOSEMITE) += 0xffffffff80100000
376 376
377#
377# Qemu simulating MIPS32 4Kc 378# Qemu simulating MIPS32 4Kc
378# 379#
379core-$(CONFIG_QEMU) += arch/mips/qemu/ 380core-$(CONFIG_QEMU) += arch/mips/qemu/
diff --git a/arch/mips/au1000/common/dbdma.c b/arch/mips/au1000/common/dbdma.c
index 6ee090bd86c9..a547e47dd5fd 100644
--- a/arch/mips/au1000/common/dbdma.c
+++ b/arch/mips/au1000/common/dbdma.c
@@ -290,7 +290,7 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
290 /* If kmalloc fails, it is caught below same 290 /* If kmalloc fails, it is caught below same
291 * as a channel not available. 291 * as a channel not available.
292 */ 292 */
293 ctp = kmalloc(sizeof(chan_tab_t), GFP_KERNEL); 293 ctp = kmalloc(sizeof(chan_tab_t), GFP_ATOMIC);
294 chan_tab_ptr[i] = ctp; 294 chan_tab_ptr[i] = ctp;
295 break; 295 break;
296 } 296 }
@@ -730,6 +730,8 @@ au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes)
730 return rv; 730 return rv;
731} 731}
732 732
733EXPORT_SYMBOL_GPL(au1xxx_dbdma_get_dest);
734
733void 735void
734au1xxx_dbdma_stop(u32 chanid) 736au1xxx_dbdma_stop(u32 chanid)
735{ 737{
@@ -821,6 +823,8 @@ au1xxx_get_dma_residue(u32 chanid)
821 return rv; 823 return rv;
822} 824}
823 825
826EXPORT_SYMBOL_GPL(au1xxx_get_dma_residue);
827
824void 828void
825au1xxx_dbdma_chan_free(u32 chanid) 829au1xxx_dbdma_chan_free(u32 chanid)
826{ 830{
diff --git a/arch/mips/au1000/common/irq.c b/arch/mips/au1000/common/irq.c
index afe05ec12c27..12d6edee895e 100644
--- a/arch/mips/au1000/common/irq.c
+++ b/arch/mips/au1000/common/irq.c
@@ -333,31 +333,31 @@ static void setup_local_irq(unsigned int irq_nr, int type, int int_req)
333 au_writel(1<<(irq_nr-32), IC1_CFG2CLR); 333 au_writel(1<<(irq_nr-32), IC1_CFG2CLR);
334 au_writel(1<<(irq_nr-32), IC1_CFG1CLR); 334 au_writel(1<<(irq_nr-32), IC1_CFG1CLR);
335 au_writel(1<<(irq_nr-32), IC1_CFG0SET); 335 au_writel(1<<(irq_nr-32), IC1_CFG0SET);
336 irq_desc[irq_nr].handler = &rise_edge_irq_type; 336 irq_desc[irq_nr].chip = &rise_edge_irq_type;
337 break; 337 break;
338 case INTC_INT_FALL_EDGE: /* 0:1:0 */ 338 case INTC_INT_FALL_EDGE: /* 0:1:0 */
339 au_writel(1<<(irq_nr-32), IC1_CFG2CLR); 339 au_writel(1<<(irq_nr-32), IC1_CFG2CLR);
340 au_writel(1<<(irq_nr-32), IC1_CFG1SET); 340 au_writel(1<<(irq_nr-32), IC1_CFG1SET);
341 au_writel(1<<(irq_nr-32), IC1_CFG0CLR); 341 au_writel(1<<(irq_nr-32), IC1_CFG0CLR);
342 irq_desc[irq_nr].handler = &fall_edge_irq_type; 342 irq_desc[irq_nr].chip = &fall_edge_irq_type;
343 break; 343 break;
344 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */ 344 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
345 au_writel(1<<(irq_nr-32), IC1_CFG2CLR); 345 au_writel(1<<(irq_nr-32), IC1_CFG2CLR);
346 au_writel(1<<(irq_nr-32), IC1_CFG1SET); 346 au_writel(1<<(irq_nr-32), IC1_CFG1SET);
347 au_writel(1<<(irq_nr-32), IC1_CFG0SET); 347 au_writel(1<<(irq_nr-32), IC1_CFG0SET);
348 irq_desc[irq_nr].handler = &either_edge_irq_type; 348 irq_desc[irq_nr].chip = &either_edge_irq_type;
349 break; 349 break;
350 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ 350 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
351 au_writel(1<<(irq_nr-32), IC1_CFG2SET); 351 au_writel(1<<(irq_nr-32), IC1_CFG2SET);
352 au_writel(1<<(irq_nr-32), IC1_CFG1CLR); 352 au_writel(1<<(irq_nr-32), IC1_CFG1CLR);
353 au_writel(1<<(irq_nr-32), IC1_CFG0SET); 353 au_writel(1<<(irq_nr-32), IC1_CFG0SET);
354 irq_desc[irq_nr].handler = &level_irq_type; 354 irq_desc[irq_nr].chip = &level_irq_type;
355 break; 355 break;
356 case INTC_INT_LOW_LEVEL: /* 1:1:0 */ 356 case INTC_INT_LOW_LEVEL: /* 1:1:0 */
357 au_writel(1<<(irq_nr-32), IC1_CFG2SET); 357 au_writel(1<<(irq_nr-32), IC1_CFG2SET);
358 au_writel(1<<(irq_nr-32), IC1_CFG1SET); 358 au_writel(1<<(irq_nr-32), IC1_CFG1SET);
359 au_writel(1<<(irq_nr-32), IC1_CFG0CLR); 359 au_writel(1<<(irq_nr-32), IC1_CFG0CLR);
360 irq_desc[irq_nr].handler = &level_irq_type; 360 irq_desc[irq_nr].chip = &level_irq_type;
361 break; 361 break;
362 case INTC_INT_DISABLED: /* 0:0:0 */ 362 case INTC_INT_DISABLED: /* 0:0:0 */
363 au_writel(1<<(irq_nr-32), IC1_CFG0CLR); 363 au_writel(1<<(irq_nr-32), IC1_CFG0CLR);
@@ -385,31 +385,31 @@ static void setup_local_irq(unsigned int irq_nr, int type, int int_req)
385 au_writel(1<<irq_nr, IC0_CFG2CLR); 385 au_writel(1<<irq_nr, IC0_CFG2CLR);
386 au_writel(1<<irq_nr, IC0_CFG1CLR); 386 au_writel(1<<irq_nr, IC0_CFG1CLR);
387 au_writel(1<<irq_nr, IC0_CFG0SET); 387 au_writel(1<<irq_nr, IC0_CFG0SET);
388 irq_desc[irq_nr].handler = &rise_edge_irq_type; 388 irq_desc[irq_nr].chip = &rise_edge_irq_type;
389 break; 389 break;
390 case INTC_INT_FALL_EDGE: /* 0:1:0 */ 390 case INTC_INT_FALL_EDGE: /* 0:1:0 */
391 au_writel(1<<irq_nr, IC0_CFG2CLR); 391 au_writel(1<<irq_nr, IC0_CFG2CLR);
392 au_writel(1<<irq_nr, IC0_CFG1SET); 392 au_writel(1<<irq_nr, IC0_CFG1SET);
393 au_writel(1<<irq_nr, IC0_CFG0CLR); 393 au_writel(1<<irq_nr, IC0_CFG0CLR);
394 irq_desc[irq_nr].handler = &fall_edge_irq_type; 394 irq_desc[irq_nr].chip = &fall_edge_irq_type;
395 break; 395 break;
396 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */ 396 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
397 au_writel(1<<irq_nr, IC0_CFG2CLR); 397 au_writel(1<<irq_nr, IC0_CFG2CLR);
398 au_writel(1<<irq_nr, IC0_CFG1SET); 398 au_writel(1<<irq_nr, IC0_CFG1SET);
399 au_writel(1<<irq_nr, IC0_CFG0SET); 399 au_writel(1<<irq_nr, IC0_CFG0SET);
400 irq_desc[irq_nr].handler = &either_edge_irq_type; 400 irq_desc[irq_nr].chip = &either_edge_irq_type;
401 break; 401 break;
402 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ 402 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
403 au_writel(1<<irq_nr, IC0_CFG2SET); 403 au_writel(1<<irq_nr, IC0_CFG2SET);
404 au_writel(1<<irq_nr, IC0_CFG1CLR); 404 au_writel(1<<irq_nr, IC0_CFG1CLR);
405 au_writel(1<<irq_nr, IC0_CFG0SET); 405 au_writel(1<<irq_nr, IC0_CFG0SET);
406 irq_desc[irq_nr].handler = &level_irq_type; 406 irq_desc[irq_nr].chip = &level_irq_type;
407 break; 407 break;
408 case INTC_INT_LOW_LEVEL: /* 1:1:0 */ 408 case INTC_INT_LOW_LEVEL: /* 1:1:0 */
409 au_writel(1<<irq_nr, IC0_CFG2SET); 409 au_writel(1<<irq_nr, IC0_CFG2SET);
410 au_writel(1<<irq_nr, IC0_CFG1SET); 410 au_writel(1<<irq_nr, IC0_CFG1SET);
411 au_writel(1<<irq_nr, IC0_CFG0CLR); 411 au_writel(1<<irq_nr, IC0_CFG0CLR);
412 irq_desc[irq_nr].handler = &level_irq_type; 412 irq_desc[irq_nr].chip = &level_irq_type;
413 break; 413 break;
414 case INTC_INT_DISABLED: /* 0:0:0 */ 414 case INTC_INT_DISABLED: /* 0:0:0 */
415 au_writel(1<<irq_nr, IC0_CFG0CLR); 415 au_writel(1<<irq_nr, IC0_CFG0CLR);
@@ -585,13 +585,13 @@ void intc1_req1_irqdispatch(struct pt_regs *regs)
585 * au_sleep function in power.c.....maybe I should just pm_register() 585 * au_sleep function in power.c.....maybe I should just pm_register()
586 * them instead? 586 * them instead?
587 */ 587 */
588static uint sleep_intctl_config0[2]; 588static unsigned int sleep_intctl_config0[2];
589static uint sleep_intctl_config1[2]; 589static unsigned int sleep_intctl_config1[2];
590static uint sleep_intctl_config2[2]; 590static unsigned int sleep_intctl_config2[2];
591static uint sleep_intctl_src[2]; 591static unsigned int sleep_intctl_src[2];
592static uint sleep_intctl_assign[2]; 592static unsigned int sleep_intctl_assign[2];
593static uint sleep_intctl_wake[2]; 593static unsigned int sleep_intctl_wake[2];
594static uint sleep_intctl_mask[2]; 594static unsigned int sleep_intctl_mask[2];
595 595
596void 596void
597save_au1xxx_intctl(void) 597save_au1xxx_intctl(void)
diff --git a/arch/mips/au1000/common/power.c b/arch/mips/au1000/common/power.c
index f4926315fb68..b035513fe30a 100644
--- a/arch/mips/au1000/common/power.c
+++ b/arch/mips/au1000/common/power.c
@@ -80,17 +80,17 @@ static DEFINE_SPINLOCK(pm_lock);
80 * We only have to save/restore registers that aren't otherwise 80 * We only have to save/restore registers that aren't otherwise
81 * done as part of a driver pm_* function. 81 * done as part of a driver pm_* function.
82 */ 82 */
83static uint sleep_aux_pll_cntrl; 83static unsigned int sleep_aux_pll_cntrl;
84static uint sleep_cpu_pll_cntrl; 84static unsigned int sleep_cpu_pll_cntrl;
85static uint sleep_pin_function; 85static unsigned int sleep_pin_function;
86static uint sleep_uart0_inten; 86static unsigned int sleep_uart0_inten;
87static uint sleep_uart0_fifoctl; 87static unsigned int sleep_uart0_fifoctl;
88static uint sleep_uart0_linectl; 88static unsigned int sleep_uart0_linectl;
89static uint sleep_uart0_clkdiv; 89static unsigned int sleep_uart0_clkdiv;
90static uint sleep_uart0_enable; 90static unsigned int sleep_uart0_enable;
91static uint sleep_usbhost_enable; 91static unsigned int sleep_usbhost_enable;
92static uint sleep_usbdev_enable; 92static unsigned int sleep_usbdev_enable;
93static uint sleep_static_memctlr[4][3]; 93static unsigned int sleep_static_memctlr[4][3];
94 94
95/* Define this to cause the value you write to /proc/sys/pm/sleep to 95/* Define this to cause the value you write to /proc/sys/pm/sleep to
96 * set the TOY timer for the amount of time you want to sleep. 96 * set the TOY timer for the amount of time you want to sleep.
diff --git a/arch/mips/au1000/csb250/init.c b/arch/mips/au1000/csb250/init.c
index a4898b1bc66a..83f1b31a0b8e 100644
--- a/arch/mips/au1000/csb250/init.c
+++ b/arch/mips/au1000/csb250/init.c
@@ -65,9 +65,9 @@ int __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
65 65
66 /* We use a0 and a1 to pass initrd start and size. 66 /* We use a0 and a1 to pass initrd start and size.
67 */ 67 */
68 if (((uint) argc > 0) && ((uint)argv > 0)) { 68 if (((unsigned int) argc > 0) && ((uint)argv > 0)) {
69 my_initrd_start = (uint)argc; 69 my_initrd_start = (unsigned int)argc;
70 my_initrd_size = (uint)argv; 70 my_initrd_size = (unsigned int)argv;
71 } 71 }
72 72
73 /* First argv is ignored. 73 /* First argv is ignored.
diff --git a/arch/mips/au1000/pb1200/irqmap.c b/arch/mips/au1000/pb1200/irqmap.c
index bacc0c6bfe67..5dd164fc1889 100644
--- a/arch/mips/au1000/pb1200/irqmap.c
+++ b/arch/mips/au1000/pb1200/irqmap.c
@@ -172,7 +172,7 @@ void _board_init_irq(void)
172 172
173 for (irq_nr = PB1200_INT_BEGIN; irq_nr <= PB1200_INT_END; irq_nr++) 173 for (irq_nr = PB1200_INT_BEGIN; irq_nr <= PB1200_INT_END; irq_nr++)
174 { 174 {
175 irq_desc[irq_nr].handler = &external_irq_type; 175 irq_desc[irq_nr].chip = &external_irq_type;
176 pb1200_disable_irq(irq_nr); 176 pb1200_disable_irq(irq_nr);
177 } 177 }
178 178
diff --git a/arch/mips/basler/excite/excite_setup.c b/arch/mips/basler/excite/excite_setup.c
index 005b025605e6..3d7670edd5cd 100644
--- a/arch/mips/basler/excite/excite_setup.c
+++ b/arch/mips/basler/excite/excite_setup.c
@@ -254,7 +254,7 @@ static int __init excite_platform_init(void)
254 return 0; 254 return 0;
255} 255}
256 256
257void __init plat_setup(void) 257void __init plat_mem_setup(void)
258{ 258{
259 volatile u32 * const boot_ocd_base = (u32 *) 0xbf7fc000; 259 volatile u32 * const boot_ocd_base = (u32 *) 0xbf7fc000;
260 260
diff --git a/arch/mips/ddb5xxx/common/prom.c b/arch/mips/ddb5xxx/common/prom.c
index 00c62c1c28a3..20c845c84d4b 100644
--- a/arch/mips/ddb5xxx/common/prom.c
+++ b/arch/mips/ddb5xxx/common/prom.c
@@ -21,8 +21,6 @@
21const char *get_system_type(void) 21const char *get_system_type(void)
22{ 22{
23 switch (mips_machtype) { 23 switch (mips_machtype) {
24 case MACH_NEC_DDB5074: return "NEC DDB Vrc-5074";
25 case MACH_NEC_DDB5476: return "NEC DDB Vrc-5476";
26 case MACH_NEC_DDB5477: return "NEC DDB Vrc-5477"; 24 case MACH_NEC_DDB5477: return "NEC DDB Vrc-5477";
27 case MACH_NEC_ROCKHOPPER: return "NEC Rockhopper"; 25 case MACH_NEC_ROCKHOPPER: return "NEC Rockhopper";
28 case MACH_NEC_ROCKHOPPERII: return "NEC RockhopperII"; 26 case MACH_NEC_ROCKHOPPERII: return "NEC RockhopperII";
diff --git a/arch/mips/ddb5xxx/ddb5477/irq_5477.c b/arch/mips/ddb5xxx/ddb5477/irq_5477.c
index 5fcd5f070cdc..63c3d6534b3a 100644
--- a/arch/mips/ddb5xxx/ddb5477/irq_5477.c
+++ b/arch/mips/ddb5xxx/ddb5477/irq_5477.c
@@ -107,7 +107,7 @@ void __init vrc5477_irq_init(u32 irq_base)
107 irq_desc[i].status = IRQ_DISABLED; 107 irq_desc[i].status = IRQ_DISABLED;
108 irq_desc[i].action = NULL; 108 irq_desc[i].action = NULL;
109 irq_desc[i].depth = 1; 109 irq_desc[i].depth = 1;
110 irq_desc[i].handler = &vrc5477_irq_controller; 110 irq_desc[i].chip = &vrc5477_irq_controller;
111 } 111 }
112 112
113 vrc5477_irq_base = irq_base; 113 vrc5477_irq_base = irq_base;
diff --git a/arch/mips/dec/ioasic-irq.c b/arch/mips/dec/ioasic-irq.c
index d5bca5d233b6..da2dbb42f913 100644
--- a/arch/mips/dec/ioasic-irq.c
+++ b/arch/mips/dec/ioasic-irq.c
@@ -144,13 +144,13 @@ void __init init_ioasic_irqs(int base)
144 irq_desc[i].status = IRQ_DISABLED; 144 irq_desc[i].status = IRQ_DISABLED;
145 irq_desc[i].action = 0; 145 irq_desc[i].action = 0;
146 irq_desc[i].depth = 1; 146 irq_desc[i].depth = 1;
147 irq_desc[i].handler = &ioasic_irq_type; 147 irq_desc[i].chip = &ioasic_irq_type;
148 } 148 }
149 for (; i < base + IO_IRQ_LINES; i++) { 149 for (; i < base + IO_IRQ_LINES; i++) {
150 irq_desc[i].status = IRQ_DISABLED; 150 irq_desc[i].status = IRQ_DISABLED;
151 irq_desc[i].action = 0; 151 irq_desc[i].action = 0;
152 irq_desc[i].depth = 1; 152 irq_desc[i].depth = 1;
153 irq_desc[i].handler = &ioasic_dma_irq_type; 153 irq_desc[i].chip = &ioasic_dma_irq_type;
154 } 154 }
155 155
156 ioasic_irq_base = base; 156 ioasic_irq_base = base;
diff --git a/arch/mips/dec/kn02-irq.c b/arch/mips/dec/kn02-irq.c
index 898bed502a34..d44c00d9e80f 100644
--- a/arch/mips/dec/kn02-irq.c
+++ b/arch/mips/dec/kn02-irq.c
@@ -123,7 +123,7 @@ void __init init_kn02_irqs(int base)
123 irq_desc[i].status = IRQ_DISABLED; 123 irq_desc[i].status = IRQ_DISABLED;
124 irq_desc[i].action = 0; 124 irq_desc[i].action = 0;
125 irq_desc[i].depth = 1; 125 irq_desc[i].depth = 1;
126 irq_desc[i].handler = &kn02_irq_type; 126 irq_desc[i].chip = &kn02_irq_type;
127 } 127 }
128 128
129 kn02_irq_base = base; 129 kn02_irq_base = base;
diff --git a/arch/mips/gt64120/common/Makefile b/arch/mips/gt64120/common/Makefile
index eba5051015a5..1ef676e22ab4 100644
--- a/arch/mips/gt64120/common/Makefile
+++ b/arch/mips/gt64120/common/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5obj-y += time.o 5obj-y += time.o
6obj-$(CONFIG_PCI) += pci.o
diff --git a/arch/mips/gt64120/common/pci.c b/arch/mips/gt64120/common/pci.c
deleted file mode 100644
index e9e5419a0d53..000000000000
--- a/arch/mips/gt64120/common/pci.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Galileo Evaluation Boards PCI support.
4 *
5 * The general-purpose functions to read/write and configure the GT64120A's
6 * PCI registers (function names start with pci0 or pci1) are either direct
7 * copies of functions written by Galileo Technology, or are modifications
8 * of their functions to work with Linux 2.4 vs Linux 2.2. These functions
9 * are Copyright - Galileo Technology.
10 *
11 * Other functions are derived from other MIPS PCI implementations, or were
12 * written by RidgeRun, Inc, Copyright (C) 2000 RidgeRun, Inc.
13 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * You should have received a copy of the GNU General Public License along
32 * with this program; if not, write to the Free Software Foundation, Inc.,
33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35#include <linux/init.h>
36#include <linux/types.h>
37#include <linux/pci.h>
38#include <linux/kernel.h>
39#include <asm/gt64120.h>
40
41#define SELF 0
42
43/*
44 * pciXReadConfigReg - Read from a PCI configuration register
45 * - Make sure the GT is configured as a master before
46 * reading from another device on the PCI.
47 * - The function takes care of Big/Little endian conversion.
48 * INPUTS: regOffset: The register offset as it apears in the GT spec (or PCI
49 * spec)
50 * pciDevNum: The device number needs to be addressed.
51 * RETURNS: data , if the data == 0xffffffff check the master abort bit in the
52 * cause register to make sure the data is valid
53 *
54 * Configuration Address 0xCF8:
55 *
56 * 31 30 24 23 16 15 11 10 8 7 2 0 <=bit Number
57 * |congif|Reserved| Bus |Device|Function|Register|00|
58 * |Enable| |Number|Number| Number | Number | | <=field Name
59 *
60 */
61static unsigned int pci0ReadConfigReg(int offset, struct pci_dev *device)
62{
63 unsigned int DataForRegCf8;
64 unsigned int data;
65
66 DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
67 (PCI_FUNC(device->devfn) << 8) |
68 (offset & ~0x3)) | 0x80000000;
69 GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
70
71 /*
72 * The casual observer might wonder why the READ is duplicated here,
73 * rather than immediately following the WRITE, and just have the swap
74 * in the "if". That's because there is a latency problem with trying
75 * to read immediately after setting up the address register. The "if"
76 * check gives enough time for the address to stabilize, so the READ
77 * can work.
78 */
79 if (PCI_SLOT(device->devfn) == SELF) /* This board */
80 return GT_READ(GT_PCI0_CFGDATA_OFS);
81 else /* PCI is little endian so swap the Data. */
82 return __GT_READ(GT_PCI0_CFGDATA_OFS);
83}
84
85/*
86 * pciXWriteConfigReg - Write to a PCI configuration register
87 * - Make sure the GT is configured as a master before
88 * writingto another device on the PCI.
89 * - The function takes care of Big/Little endian conversion.
90 * Inputs: unsigned int regOffset: The register offset as it apears in the
91 * GT spec
92 * (or any other PCI device spec)
93 * pciDevNum: The device number needs to be addressed.
94 *
95 * Configuration Address 0xCF8:
96 *
97 * 31 30 24 23 16 15 11 10 8 7 2 0 <=bit Number
98 * |congif|Reserved| Bus |Device|Function|Register|00|
99 * |Enable| |Number|Number| Number | Number | | <=field Name
100 *
101 */
102static void pci0WriteConfigReg(unsigned int offset,
103 struct pci_dev *device, unsigned int data)
104{
105 unsigned int DataForRegCf8;
106
107 DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
108 (PCI_FUNC(device->devfn) << 8) |
109 (offset & ~0x3)) | 0x80000000;
110 GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
111
112 if (PCI_SLOT(device->devfn) == SELF) /* This board */
113 GT_WRITE(GT_PCI0_CFGDATA_OFS, data);
114 else /* configuration Transaction over the pci. */
115 __GT_WRITE(GT_PCI0_CFGDATA_OFS, data);
116}
117
118extern struct pci_ops gt64120_pci_ops;
119
120void __init pcibios_init(void)
121{
122 u32 tmp;
123 struct pci_dev controller;
124
125 controller.devfn = SELF;
126
127 tmp = GT_READ(GT_PCI0_CMD_OFS); /* Huh??? -- Ralf */
128 tmp = GT_READ(GT_PCI0_BARE_OFS);
129
130 /*
131 * You have to enable bus mastering to configure any other
132 * card on the bus.
133 */
134 tmp = pci0ReadConfigReg(PCI_COMMAND, &controller);
135 tmp |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_SERR;
136 pci0WriteConfigReg(PCI_COMMAND, &controller, tmp);
137
138 /*
139 * Reset PCI I/O and PCI MEM values to ones supported by EVM.
140 */
141 ioport_resource.start = GT_PCI_IO_BASE;
142 ioport_resource.end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1;
143 iomem_resource.start = GT_PCI_MEM_BASE;
144 iomem_resource.end = GT_PCI_MEM_BASE + GT_PCI_MEM_SIZE - 1;
145
146 pci_scan_bus(0, &gt64120_pci_ops, NULL);
147}
diff --git a/arch/mips/gt64120/ev64120/irq.c b/arch/mips/gt64120/ev64120/irq.c
index 46c468b26b30..f489a8067a93 100644
--- a/arch/mips/gt64120/ev64120/irq.c
+++ b/arch/mips/gt64120/ev64120/irq.c
@@ -138,7 +138,7 @@ void __init arch_init_irq(void)
138 /* Let's initialize our IRQ descriptors */ 138 /* Let's initialize our IRQ descriptors */
139 for (i = 0; i < NR_IRQS; i++) { 139 for (i = 0; i < NR_IRQS; i++) {
140 irq_desc[i].status = 0; 140 irq_desc[i].status = 0;
141 irq_desc[i].handler = &no_irq_type; 141 irq_desc[i].chip = &no_irq_type;
142 irq_desc[i].action = NULL; 142 irq_desc[i].action = NULL;
143 irq_desc[i].depth = 0; 143 irq_desc[i].depth = 0;
144 spin_lock_init(&irq_desc[i].lock); 144 spin_lock_init(&irq_desc[i].lock);
diff --git a/arch/mips/gt64120/momenco_ocelot/setup.c b/arch/mips/gt64120/momenco_ocelot/setup.c
index 1193a22c4693..9804642ecf89 100644
--- a/arch/mips/gt64120/momenco_ocelot/setup.c
+++ b/arch/mips/gt64120/momenco_ocelot/setup.c
@@ -164,8 +164,8 @@ void __init plat_mem_setup(void)
164 pm_power_off = momenco_ocelot_power_off; 164 pm_power_off = momenco_ocelot_power_off;
165 165
166 /* 166 /*
167 * initrd_start = (ulong)ocelot_initrd_start; 167 * initrd_start = (unsigned long)ocelot_initrd_start;
168 * initrd_end = (ulong)ocelot_initrd_start + (ulong)ocelot_initrd_size; 168 * initrd_end = (unsigned long)ocelot_initrd_start + (ulong)ocelot_initrd_size;
169 * initrd_below_start_ok = 1; 169 * initrd_below_start_ok = 1;
170 */ 170 */
171 171
diff --git a/arch/mips/gt64120/wrppmc/Makefile b/arch/mips/gt64120/wrppmc/Makefile
index 72606b9af12a..7cf52205511c 100644
--- a/arch/mips/gt64120/wrppmc/Makefile
+++ b/arch/mips/gt64120/wrppmc/Makefile
@@ -9,6 +9,6 @@
9# Makefile for the Wind River MIPS 4KC PPMC Eval Board 9# Makefile for the Wind River MIPS 4KC PPMC Eval Board
10# 10#
11 11
12obj-y += int-handler.o irq.o reset.o setup.o time.o pci.o 12obj-y += irq.o reset.o setup.o time.o pci.o
13 13
14EXTRA_AFLAGS := $(CFLAGS) 14EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/gt64120/wrppmc/int-handler.S b/arch/mips/gt64120/wrppmc/int-handler.S
deleted file mode 100644
index edee7b394175..000000000000
--- a/arch/mips/gt64120/wrppmc/int-handler.S
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle
7 * Copyright (C) Wind River System Inc. Rongkai.Zhan <rongkai.zhan@windriver.com>
8 */
9#include <asm/asm.h>
10#include <asm/mipsregs.h>
11#include <asm/addrspace.h>
12#include <asm/regdef.h>
13#include <asm/stackframe.h>
14#include <asm/mach-wrppmc/mach-gt64120.h>
15
16 .align 5
17 .set noat
18NESTED(handle_IRQ, PT_SIZE, sp)
19 SAVE_ALL
20 CLI # Important: mark KERNEL mode !
21 .set at
22
23 mfc0 t0, CP0_CAUSE # get pending interrupts
24 mfc0 t1, CP0_STATUS # get enabled interrupts
25 and t0, t0, t1 # get allowed interrupts
26 andi t0, t0, 0xFF00
27 beqz t0, 1f
28 move a1, sp # Prepare 'struct pt_regs *regs' pointer
29
30 andi t1, t0, CAUSEF_IP7 # CPU Compare/Count internal timer
31 bnez t1, handle_cputimer_irq
32 andi t1, t0, CAUSEF_IP6 # UART 16550 port
33 bnez t1, handle_uart_irq
34 andi t1, t0, CAUSEF_IP3 # PCI INT_A
35 bnez t1, handle_pci_intA_irq
36
37 /* wrong alarm or masked ... */
381: j spurious_interrupt
39 nop
40END(handle_IRQ)
41
42 .align 5
43handle_cputimer_irq:
44 li a0, WRPPMC_MIPS_TIMER_IRQ
45 jal do_IRQ
46 j ret_from_irq
47
48 .align 5
49handle_uart_irq:
50 li a0, WRPPMC_UART16550_IRQ
51 jal do_IRQ
52 j ret_from_irq
53
54 .align 5
55handle_pci_intA_irq:
56 li a0, WRPPMC_PCI_INTA_IRQ
57 jal do_IRQ
58 j ret_from_irq
59
diff --git a/arch/mips/gt64120/wrppmc/irq.c b/arch/mips/gt64120/wrppmc/irq.c
index 8605687e24ed..8d75a43ce877 100644
--- a/arch/mips/gt64120/wrppmc/irq.c
+++ b/arch/mips/gt64120/wrppmc/irq.c
@@ -30,7 +30,19 @@
30#include <asm/irq_cpu.h> 30#include <asm/irq_cpu.h>
31#include <asm/gt64120.h> 31#include <asm/gt64120.h>
32 32
33extern asmlinkage void handle_IRQ(void); 33asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
34{
35 unsigned int pending = read_c0_status() & read_c0_cause();
36
37 if (pending & STATUSF_IP7)
38 do_IRQ(WRPPMC_MIPS_TIMER_IRQ, regs); /* CPU Compare/Count internal timer */
39 else if (pending & STATUSF_IP6)
40 do_IRQ(WRPPMC_UART16550_IRQ, regs); /* UART 16550 port */
41 else if (pending & STATUSF_IP3)
42 do_IRQ(WRPPMC_PCI_INTA_IRQ, regs); /* PCI INT_A */
43 else
44 spurious_interrupt(regs);
45}
34 46
35/** 47/**
36 * Initialize GT64120 Interrupt Controller 48 * Initialize GT64120 Interrupt Controller
@@ -50,12 +62,6 @@ void gt64120_init_pic(void)
50 62
51void __init arch_init_irq(void) 63void __init arch_init_irq(void)
52{ 64{
53 /* enable all CPU interrupt bits. */
54 set_c0_status(ST0_IM); /* IE bit is still 0 */
55
56 /* Install MIPS Interrupt Trap Vector */
57 set_except_vector(0, handle_IRQ);
58
59 /* IRQ 0 - 7 are for MIPS common irq_cpu controller */ 65 /* IRQ 0 - 7 are for MIPS common irq_cpu controller */
60 mips_cpu_irq_init(0); 66 mips_cpu_irq_init(0);
61 67
diff --git a/arch/mips/gt64120/wrppmc/setup.c b/arch/mips/gt64120/wrppmc/setup.c
index 20c591e49dae..2db6375ef29e 100644
--- a/arch/mips/gt64120/wrppmc/setup.c
+++ b/arch/mips/gt64120/wrppmc/setup.c
@@ -125,7 +125,7 @@ static void wrppmc_setup_serial(void)
125} 125}
126#endif 126#endif
127 127
128void __init plat_setup(void) 128void __init plat_mem_setup(void)
129{ 129{
130 extern void wrppmc_time_init(void); 130 extern void wrppmc_time_init(void);
131 extern void wrppmc_timer_setup(struct irqaction *); 131 extern void wrppmc_timer_setup(struct irqaction *);
diff --git a/arch/mips/gt64120/wrppmc/time.c b/arch/mips/gt64120/wrppmc/time.c
index 175d22adb450..6c24a82df0dd 100644
--- a/arch/mips/gt64120/wrppmc/time.c
+++ b/arch/mips/gt64120/wrppmc/time.c
@@ -31,10 +31,6 @@ void __init wrppmc_timer_setup(struct irqaction *irq)
31{ 31{
32 /* Install ISR for timer interrupt */ 32 /* Install ISR for timer interrupt */
33 setup_irq(WRPPMC_MIPS_TIMER_IRQ, irq); 33 setup_irq(WRPPMC_MIPS_TIMER_IRQ, irq);
34
35 /* to generate the first timer interrupt */
36 write_c0_compare(mips_hpt_frequency/HZ);
37 write_c0_count(0);
38} 34}
39 35
40/* 36/*
diff --git a/arch/mips/ite-boards/generic/irq.c b/arch/mips/ite-boards/generic/irq.c
index 77be7216bdd0..a6749c56fe38 100644
--- a/arch/mips/ite-boards/generic/irq.c
+++ b/arch/mips/ite-boards/generic/irq.c
@@ -208,10 +208,10 @@ void __init arch_init_irq(void)
208#endif 208#endif
209 209
210 for (i = 0; i <= IT8172_LAST_IRQ; i++) { 210 for (i = 0; i <= IT8172_LAST_IRQ; i++) {
211 irq_desc[i].handler = &it8172_irq_type; 211 irq_desc[i].chip = &it8172_irq_type;
212 spin_lock_init(&irq_desc[i].lock); 212 spin_lock_init(&irq_desc[i].lock);
213 } 213 }
214 irq_desc[MIPS_CPU_TIMER_IRQ].handler = &cp0_irq_type; 214 irq_desc[MIPS_CPU_TIMER_IRQ].chip = &cp0_irq_type;
215 set_c0_status(ALLINTS_NOTIMER); 215 set_c0_status(ALLINTS_NOTIMER);
216} 216}
217 217
diff --git a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c
index becc9accd495..478be9858a1e 100644
--- a/arch/mips/jazz/irq.c
+++ b/arch/mips/jazz/irq.c
@@ -73,7 +73,7 @@ void __init init_r4030_ints(void)
73 irq_desc[i].status = IRQ_DISABLED; 73 irq_desc[i].status = IRQ_DISABLED;
74 irq_desc[i].action = 0; 74 irq_desc[i].action = 0;
75 irq_desc[i].depth = 1; 75 irq_desc[i].depth = 1;
76 irq_desc[i].handler = &r4030_irq_type; 76 irq_desc[i].chip = &r4030_irq_type;
77 } 77 }
78 78
79 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0); 79 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
diff --git a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/jmr3927/rbhma3100/irq.c
index 11304d1354f4..380046ea1db5 100644
--- a/arch/mips/jmr3927/rbhma3100/irq.c
+++ b/arch/mips/jmr3927/rbhma3100/irq.c
@@ -435,7 +435,7 @@ void jmr3927_irq_init(u32 irq_base)
435 irq_desc[i].status = IRQ_DISABLED; 435 irq_desc[i].status = IRQ_DISABLED;
436 irq_desc[i].action = NULL; 436 irq_desc[i].action = NULL;
437 irq_desc[i].depth = 1; 437 irq_desc[i].depth = 1;
438 irq_desc[i].handler = &jmr3927_irq_controller; 438 irq_desc[i].chip = &jmr3927_irq_controller;
439 } 439 }
440 440
441 jmr3927_irq_base = irq_base; 441 jmr3927_irq_base = irq_base;
diff --git a/arch/mips/kernel/apm.c b/arch/mips/kernel/apm.c
index 15f46b4471fd..7bdbcd811b57 100644
--- a/arch/mips/kernel/apm.c
+++ b/arch/mips/kernel/apm.c
@@ -260,7 +260,7 @@ static unsigned int apm_poll(struct file *fp, poll_table * wait)
260 * has acknowledge does the actual suspend happen. 260 * has acknowledge does the actual suspend happen.
261 */ 261 */
262static int 262static int
263apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) 263apm_ioctl(struct inode * inode, struct file *filp, unsigned int cmd, unsigned long arg)
264{ 264{
265 struct apm_user *as = filp->private_data; 265 struct apm_user *as = filp->private_data;
266 unsigned long flags; 266 unsigned long flags;
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 8c2c359a05f4..e045aba4ebda 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -597,8 +597,6 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c)
597 break; 597 break;
598 case PRID_IMP_25KF: 598 case PRID_IMP_25KF:
599 c->cputype = CPU_25KF; 599 c->cputype = CPU_25KF;
600 /* Probe for L2 cache */
601 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
602 break; 600 break;
603 case PRID_IMP_34K: 601 case PRID_IMP_34K:
604 c->cputype = CPU_34K; 602 c->cputype = CPU_34K;
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index a9c6de1b9542..457565162dd5 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -87,7 +87,7 @@ FEXPORT(restore_all) # restore full frame
87 ori v1, v0, TCSTATUS_IXMT 87 ori v1, v0, TCSTATUS_IXMT
88 mtc0 v1, CP0_TCSTATUS 88 mtc0 v1, CP0_TCSTATUS
89 andi v0, TCSTATUS_IXMT 89 andi v0, TCSTATUS_IXMT
90 ehb 90 _ehb
91 mfc0 t0, CP0_TCCONTEXT 91 mfc0 t0, CP0_TCCONTEXT
92 DMT 9 # dmt t1 92 DMT 9 # dmt t1
93 jal mips_ihb 93 jal mips_ihb
@@ -95,7 +95,7 @@ FEXPORT(restore_all) # restore full frame
95 andi t3, t0, 0xff00 95 andi t3, t0, 0xff00
96 or t2, t2, t3 96 or t2, t2, t3
97 mtc0 t2, CP0_STATUS 97 mtc0 t2, CP0_STATUS
98 ehb 98 _ehb
99 andi t1, t1, VPECONTROL_TE 99 andi t1, t1, VPECONTROL_TE
100 beqz t1, 1f 100 beqz t1, 1f
101 EMT 101 EMT
@@ -105,7 +105,7 @@ FEXPORT(restore_all) # restore full frame
105 xori v1, v1, TCSTATUS_IXMT 105 xori v1, v1, TCSTATUS_IXMT
106 or v1, v0, v1 106 or v1, v0, v1
107 mtc0 v1, CP0_TCSTATUS 107 mtc0 v1, CP0_TCSTATUS
108 ehb 108 _ehb
109 xor t0, t0, t3 109 xor t0, t0, t3
110 mtc0 t0, CP0_TCCONTEXT 110 mtc0 t0, CP0_TCCONTEXT
111#endif /* CONFIG_MIPS_MT_SMTC */ 111#endif /* CONFIG_MIPS_MT_SMTC */
diff --git a/arch/mips/kernel/gdb-low.S b/arch/mips/kernel/gdb-low.S
index 5fd7a8af0c62..8760131f89d9 100644
--- a/arch/mips/kernel/gdb-low.S
+++ b/arch/mips/kernel/gdb-low.S
@@ -291,7 +291,7 @@
291 ori t1, t2, TCSTATUS_IXMT 291 ori t1, t2, TCSTATUS_IXMT
292 mtc0 t1, CP0_TCSTATUS 292 mtc0 t1, CP0_TCSTATUS
293 andi t2, t2, TCSTATUS_IXMT 293 andi t2, t2, TCSTATUS_IXMT
294 ehb 294 _ehb
295 DMT 9 # dmt t1 295 DMT 9 # dmt t1
296 jal mips_ihb 296 jal mips_ihb
297 nop 297 nop
@@ -310,7 +310,7 @@
310 xori t1, t1, TCSTATUS_IXMT 310 xori t1, t1, TCSTATUS_IXMT
311 or t1, t1, t2 311 or t1, t1, t2
312 mtc0 t1, CP0_TCSTATUS 312 mtc0 t1, CP0_TCSTATUS
313 ehb 313 _ehb
314#endif /* CONFIG_MIPS_MT_SMTC */ 314#endif /* CONFIG_MIPS_MT_SMTC */
315 LONG_L v0, GDB_FR_STATUS(sp) 315 LONG_L v0, GDB_FR_STATUS(sp)
316 LONG_L v1, GDB_FR_EPC(sp) 316 LONG_L v1, GDB_FR_EPC(sp)
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index ff7af369f286..6888cde560af 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -214,7 +214,7 @@ NESTED(except_vec_vi_handler, 0, sp)
214 mtc0 t0, CP0_TCCONTEXT 214 mtc0 t0, CP0_TCCONTEXT
215 xor t1, t1, t0 215 xor t1, t1, t0
216 mtc0 t1, CP0_STATUS 216 mtc0 t1, CP0_STATUS
217 ehb 217 _ehb
218#endif /* CONFIG_MIPS_MT_SMTC */ 218#endif /* CONFIG_MIPS_MT_SMTC */
219 CLI 219 CLI
220 move a0, sp 220 move a0, sp
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index bdf6f6eff721..c018098c9a56 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -96,7 +96,7 @@
96 /* Clear TKSU, leave IXMT */ 96 /* Clear TKSU, leave IXMT */
97 xori t0, 0x00001800 97 xori t0, 0x00001800
98 mtc0 t0, CP0_TCSTATUS 98 mtc0 t0, CP0_TCSTATUS
99 ehb 99 _ehb
100 /* We need to leave the global IE bit set, but clear EXL...*/ 100 /* We need to leave the global IE bit set, but clear EXL...*/
101 mfc0 t0, CP0_STATUS 101 mfc0 t0, CP0_STATUS
102 or t0, ST0_CU0 | ST0_EXL | ST0_ERL | \set | \clr 102 or t0, ST0_CU0 | ST0_EXL | ST0_ERL | \set | \clr
diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
index 0cb8ed5662f3..91ffb1233cad 100644
--- a/arch/mips/kernel/i8259.c
+++ b/arch/mips/kernel/i8259.c
@@ -120,7 +120,7 @@ int i8259A_irq_pending(unsigned int irq)
120void make_8259A_irq(unsigned int irq) 120void make_8259A_irq(unsigned int irq)
121{ 121{
122 disable_irq_nosync(irq); 122 disable_irq_nosync(irq);
123 irq_desc[irq].handler = &i8259A_irq_type; 123 irq_desc[irq].chip = &i8259A_irq_type;
124 enable_irq(irq); 124 enable_irq(irq);
125} 125}
126 126
@@ -327,7 +327,7 @@ void __init init_i8259_irqs (void)
327 irq_desc[i].status = IRQ_DISABLED; 327 irq_desc[i].status = IRQ_DISABLED;
328 irq_desc[i].action = NULL; 328 irq_desc[i].action = NULL;
329 irq_desc[i].depth = 1; 329 irq_desc[i].depth = 1;
330 irq_desc[i].handler = &i8259A_irq_type; 330 irq_desc[i].chip = &i8259A_irq_type;
331 } 331 }
332 332
333 setup_irq(2, &irq2); 333 setup_irq(2, &irq2);
diff --git a/arch/mips/kernel/irq-msc01.c b/arch/mips/kernel/irq-msc01.c
index 97ebdc754b9e..f8cd1ac64d88 100644
--- a/arch/mips/kernel/irq-msc01.c
+++ b/arch/mips/kernel/irq-msc01.c
@@ -174,14 +174,14 @@ void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
174 174
175 switch (imp->im_type) { 175 switch (imp->im_type) {
176 case MSC01_IRQ_EDGE: 176 case MSC01_IRQ_EDGE:
177 irq_desc[base+n].handler = &msc_edgeirq_type; 177 irq_desc[base+n].chip = &msc_edgeirq_type;
178 if (cpu_has_veic) 178 if (cpu_has_veic)
179 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT); 179 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT);
180 else 180 else
181 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl); 181 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl);
182 break; 182 break;
183 case MSC01_IRQ_LEVEL: 183 case MSC01_IRQ_LEVEL:
184 irq_desc[base+n].handler = &msc_levelirq_type; 184 irq_desc[base+n].chip = &msc_levelirq_type;
185 if (cpu_has_veic) 185 if (cpu_has_veic)
186 MSCIC_WRITE(MSC01_IC_SUP+n*8, 0); 186 MSCIC_WRITE(MSC01_IC_SUP+n*8, 0);
187 else 187 else
diff --git a/arch/mips/kernel/irq-mv6434x.c b/arch/mips/kernel/irq-mv6434x.c
index 0613f1f36b1b..f9c763a65547 100644
--- a/arch/mips/kernel/irq-mv6434x.c
+++ b/arch/mips/kernel/irq-mv6434x.c
@@ -155,7 +155,7 @@ void __init mv64340_irq_init(unsigned int base)
155 irq_desc[i].status = IRQ_DISABLED; 155 irq_desc[i].status = IRQ_DISABLED;
156 irq_desc[i].action = 0; 156 irq_desc[i].action = 0;
157 irq_desc[i].depth = 2; 157 irq_desc[i].depth = 2;
158 irq_desc[i].handler = &mv64340_irq_type; 158 irq_desc[i].chip = &mv64340_irq_type;
159 } 159 }
160 160
161 irq_base = base; 161 irq_base = base;
diff --git a/arch/mips/kernel/irq-rm7000.c b/arch/mips/kernel/irq-rm7000.c
index 0b130c5ac5d9..121da385a94d 100644
--- a/arch/mips/kernel/irq-rm7000.c
+++ b/arch/mips/kernel/irq-rm7000.c
@@ -91,7 +91,7 @@ void __init rm7k_cpu_irq_init(int base)
91 irq_desc[i].status = IRQ_DISABLED; 91 irq_desc[i].status = IRQ_DISABLED;
92 irq_desc[i].action = NULL; 92 irq_desc[i].action = NULL;
93 irq_desc[i].depth = 1; 93 irq_desc[i].depth = 1;
94 irq_desc[i].handler = &rm7k_irq_controller; 94 irq_desc[i].chip = &rm7k_irq_controller;
95 } 95 }
96 96
97 irq_base = base; 97 irq_base = base;
diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c
index 9b5f20c32acb..25109c103e44 100644
--- a/arch/mips/kernel/irq-rm9000.c
+++ b/arch/mips/kernel/irq-rm9000.c
@@ -139,11 +139,11 @@ void __init rm9k_cpu_irq_init(int base)
139 irq_desc[i].status = IRQ_DISABLED; 139 irq_desc[i].status = IRQ_DISABLED;
140 irq_desc[i].action = NULL; 140 irq_desc[i].action = NULL;
141 irq_desc[i].depth = 1; 141 irq_desc[i].depth = 1;
142 irq_desc[i].handler = &rm9k_irq_controller; 142 irq_desc[i].chip = &rm9k_irq_controller;
143 } 143 }
144 144
145 rm9000_perfcount_irq = base + 1; 145 rm9000_perfcount_irq = base + 1;
146 irq_desc[rm9000_perfcount_irq].handler = &rm9k_perfcounter_irq; 146 irq_desc[rm9000_perfcount_irq].chip = &rm9k_perfcounter_irq;
147 147
148 irq_base = base; 148 irq_base = base;
149} 149}
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 3dce742e716f..5c9dcd5eed59 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -95,7 +95,7 @@ int show_interrupts(struct seq_file *p, void *v)
95 for_each_online_cpu(j) 95 for_each_online_cpu(j)
96 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 96 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
97#endif 97#endif
98 seq_printf(p, " %14s", irq_desc[i].handler->typename); 98 seq_printf(p, " %14s", irq_desc[i].chip->typename);
99 seq_printf(p, " %s", action->name); 99 seq_printf(p, " %s", action->name);
100 100
101 for (action=action->next; action; action = action->next) 101 for (action=action->next; action; action = action->next)
@@ -137,7 +137,7 @@ void __init init_IRQ(void)
137 irq_desc[i].status = IRQ_DISABLED; 137 irq_desc[i].status = IRQ_DISABLED;
138 irq_desc[i].action = NULL; 138 irq_desc[i].action = NULL;
139 irq_desc[i].depth = 1; 139 irq_desc[i].depth = 1;
140 irq_desc[i].handler = &no_irq_type; 140 irq_desc[i].chip = &no_irq_type;
141 spin_lock_init(&irq_desc[i].lock); 141 spin_lock_init(&irq_desc[i].lock);
142#ifdef CONFIG_MIPS_MT_SMTC 142#ifdef CONFIG_MIPS_MT_SMTC
143 irq_hwmask[i] = 0; 143 irq_hwmask[i] = 0;
diff --git a/arch/mips/kernel/irq_cpu.c b/arch/mips/kernel/irq_cpu.c
index 5db67e31ec1a..0e455a8ad860 100644
--- a/arch/mips/kernel/irq_cpu.c
+++ b/arch/mips/kernel/irq_cpu.c
@@ -167,14 +167,14 @@ void __init mips_cpu_irq_init(int irq_base)
167 irq_desc[i].status = IRQ_DISABLED; 167 irq_desc[i].status = IRQ_DISABLED;
168 irq_desc[i].action = NULL; 168 irq_desc[i].action = NULL;
169 irq_desc[i].depth = 1; 169 irq_desc[i].depth = 1;
170 irq_desc[i].handler = &mips_mt_cpu_irq_controller; 170 irq_desc[i].chip = &mips_mt_cpu_irq_controller;
171 } 171 }
172 172
173 for (i = irq_base + 2; i < irq_base + 8; i++) { 173 for (i = irq_base + 2; i < irq_base + 8; i++) {
174 irq_desc[i].status = IRQ_DISABLED; 174 irq_desc[i].status = IRQ_DISABLED;
175 irq_desc[i].action = NULL; 175 irq_desc[i].action = NULL;
176 irq_desc[i].depth = 1; 176 irq_desc[i].depth = 1;
177 irq_desc[i].handler = &mips_cpu_irq_controller; 177 irq_desc[i].chip = &mips_cpu_irq_controller;
178 } 178 }
179 179
180 mips_cpu_irq_base = irq_base; 180 mips_cpu_irq_base = irq_base;
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index db94e556fc97..e1b85e6c486a 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -94,7 +94,7 @@
94 ori t1, t2, TCSTATUS_IXMT 94 ori t1, t2, TCSTATUS_IXMT
95 mtc0 t1, CP0_TCSTATUS 95 mtc0 t1, CP0_TCSTATUS
96 andi t2, t2, TCSTATUS_IXMT 96 andi t2, t2, TCSTATUS_IXMT
97 ehb 97 _ehb
98 DMT 8 # dmt t0 98 DMT 8 # dmt t0
99 move t1,ra 99 move t1,ra
100 jal mips_ihb 100 jal mips_ihb
@@ -109,7 +109,7 @@
109 or a2, t1 109 or a2, t1
110 mtc0 a2, CP0_STATUS 110 mtc0 a2, CP0_STATUS
111#ifdef CONFIG_MIPS_MT_SMTC 111#ifdef CONFIG_MIPS_MT_SMTC
112 ehb 112 _ehb
113 andi t0, t0, VPECONTROL_TE 113 andi t0, t0, VPECONTROL_TE
114 beqz t0, 1f 114 beqz t0, 1f
115 emt 115 emt
@@ -118,7 +118,7 @@
118 xori t1, t1, TCSTATUS_IXMT 118 xori t1, t1, TCSTATUS_IXMT
119 or t1, t1, t2 119 or t1, t1, t2
120 mtc0 t1, CP0_TCSTATUS 120 mtc0 t1, CP0_TCSTATUS
121 ehb 121 _ehb
122#endif /* CONFIG_MIPS_MT_SMTC */ 122#endif /* CONFIG_MIPS_MT_SMTC */
123 move v0, a0 123 move v0, a0
124 jr ra 124 jr ra
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 2d2fdf77e308..6344be46ca8c 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -647,6 +647,7 @@ einval: li v0, -EINVAL
647 sys sys_unshare 1 647 sys sys_unshare 1
648 sys sys_splice 4 648 sys sys_splice 4
649 sys sys_sync_file_range 7 /* 4305 */ 649 sys sys_sync_file_range 7 /* 4305 */
650 sys sys_tee 4
650 .endm 651 .endm
651 652
652 /* We pre-compute the number of _instruction_ bytes needed to 653 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 9ba750887377..12d96c7d0bb2 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -462,3 +462,4 @@ sys_call_table:
462 PTR sys_unshare 462 PTR sys_unshare
463 PTR sys_splice 463 PTR sys_splice
464 PTR sys_sync_file_range 464 PTR sys_sync_file_range
465 PTR sys_tee /* 5265 */
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 942aca26f9c4..685698554a8a 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -388,3 +388,4 @@ EXPORT(sysn32_call_table)
388 PTR sys_unshare 388 PTR sys_unshare
389 PTR sys_splice 389 PTR sys_splice
390 PTR sys_sync_file_range 390 PTR sys_sync_file_range
391 PTR sys_tee
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 8efb23a84131..0e632934cb76 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -510,4 +510,5 @@ sys_call_table:
510 PTR sys_unshare 510 PTR sys_unshare
511 PTR sys_splice 511 PTR sys_splice
512 PTR sys32_sync_file_range /* 4305 */ 512 PTR sys32_sync_file_range /* 4305 */
513 PTR sys_tee
513 .size sys_call_table,.-sys_call_table 514 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index bfcec8d9bfe4..d3e087115023 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -488,6 +488,9 @@ static inline void resource_init(void)
488{ 488{
489 int i; 489 int i;
490 490
491 if (UNCAC_BASE != IO_BASE)
492 return;
493
491 code_resource.start = virt_to_phys(&_text); 494 code_resource.start = virt_to_phys(&_text);
492 code_resource.end = virt_to_phys(&_etext) - 1; 495 code_resource.end = virt_to_phys(&_etext) - 1;
493 data_resource.start = virt_to_phys(&_etext); 496 data_resource.start = virt_to_phys(&_etext);
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 298f82fe8440..9096a5ea4229 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -446,7 +446,7 @@ static int __init topology_init(void)
446 int ret; 446 int ret;
447 447
448 for_each_present_cpu(cpu) { 448 for_each_present_cpu(cpu) {
449 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL); 449 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu);
450 if (ret) 450 if (ret)
451 printk(KERN_WARNING "topology_init: register_cpu %d " 451 printk(KERN_WARNING "topology_init: register_cpu %d "
452 "failed (%d)\n", cpu, ret); 452 "failed (%d)\n", cpu, ret);
diff --git a/arch/mips/kernel/smtc-asm.S b/arch/mips/kernel/smtc-asm.S
index c9d65196d917..72c6d98f8854 100644
--- a/arch/mips/kernel/smtc-asm.S
+++ b/arch/mips/kernel/smtc-asm.S
@@ -52,12 +52,12 @@ FEXPORT(__smtc_ipi_vector)
52 .set noat 52 .set noat
53 /* Disable thread scheduling to make Status update atomic */ 53 /* Disable thread scheduling to make Status update atomic */
54 DMT 27 # dmt k1 54 DMT 27 # dmt k1
55 ehb 55 _ehb
56 /* Set EXL */ 56 /* Set EXL */
57 mfc0 k0,CP0_STATUS 57 mfc0 k0,CP0_STATUS
58 ori k0,k0,ST0_EXL 58 ori k0,k0,ST0_EXL
59 mtc0 k0,CP0_STATUS 59 mtc0 k0,CP0_STATUS
60 ehb 60 _ehb
61 /* Thread scheduling now inhibited by EXL. Restore TE state. */ 61 /* Thread scheduling now inhibited by EXL. Restore TE state. */
62 andi k1,k1,VPECONTROL_TE 62 andi k1,k1,VPECONTROL_TE
63 beqz k1,1f 63 beqz k1,1f
@@ -82,7 +82,7 @@ FEXPORT(__smtc_ipi_vector)
82 li k1,ST0_CU0 82 li k1,ST0_CU0
83 or k1,k1,k0 83 or k1,k1,k0
84 mtc0 k1,CP0_STATUS 84 mtc0 k1,CP0_STATUS
85 ehb 85 _ehb
86 get_saved_sp 86 get_saved_sp
87 /* Interrupting TC will have pre-set values in slots in the new frame */ 87 /* Interrupting TC will have pre-set values in slots in the new frame */
882: subu k1,k1,PT_SIZE 882: subu k1,k1,PT_SIZE
@@ -90,7 +90,7 @@ FEXPORT(__smtc_ipi_vector)
90 lw k0,PT_TCSTATUS(k1) 90 lw k0,PT_TCSTATUS(k1)
91 /* Write it to TCStatus to restore CU/KSU/IXMT state */ 91 /* Write it to TCStatus to restore CU/KSU/IXMT state */
92 mtc0 k0,$2,1 92 mtc0 k0,$2,1
93 ehb 93 _ehb
94 lw k0,PT_EPC(k1) 94 lw k0,PT_EPC(k1)
95 mtc0 k0,CP0_EPC 95 mtc0 k0,CP0_EPC
96 /* Save all will redundantly recompute the SP, but use it for now */ 96 /* Save all will redundantly recompute the SP, but use it for now */
@@ -116,7 +116,7 @@ LEAF(self_ipi)
116 mfc0 t0,CP0_TCSTATUS 116 mfc0 t0,CP0_TCSTATUS
117 ori t1,t0,TCSTATUS_IXMT 117 ori t1,t0,TCSTATUS_IXMT
118 mtc0 t1,CP0_TCSTATUS 118 mtc0 t1,CP0_TCSTATUS
119 ehb 119 _ehb
120 /* We know we're in kernel mode, so prepare stack frame */ 120 /* We know we're in kernel mode, so prepare stack frame */
121 subu t1,sp,PT_SIZE 121 subu t1,sp,PT_SIZE
122 sw ra,PT_EPC(t1) 122 sw ra,PT_EPC(t1)
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 2e8e52c135e6..70cf09afdf56 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -367,7 +367,7 @@ void mipsmt_prepare_cpus(void)
367 dvpe(); 367 dvpe();
368 dmt(); 368 dmt();
369 369
370 freeIPIq.lock = SPIN_LOCK_UNLOCKED; 370 spin_lock_init(&freeIPIq.lock);
371 371
372 /* 372 /*
373 * We probably don't have as many VPEs as we do SMP "CPUs", 373 * We probably don't have as many VPEs as we do SMP "CPUs",
@@ -375,7 +375,7 @@ void mipsmt_prepare_cpus(void)
375 */ 375 */
376 for (i=0; i<NR_CPUS; i++) { 376 for (i=0; i<NR_CPUS; i++) {
377 IPIQ[i].head = IPIQ[i].tail = NULL; 377 IPIQ[i].head = IPIQ[i].tail = NULL;
378 IPIQ[i].lock = SPIN_LOCK_UNLOCKED; 378 spin_lock_init(&IPIQ[i].lock);
379 IPIQ[i].depth = 0; 379 IPIQ[i].depth = 0;
380 ipi_timer_latch[i] = 0; 380 ipi_timer_latch[i] = 0;
381 } 381 }
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 5e8a18a8e2bd..6da8c68e89db 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -301,7 +301,7 @@ asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
301 * 301 *
302 * This is really horribly ugly. 302 * This is really horribly ugly.
303 */ 303 */
304asmlinkage int sys_ipc (uint call, int first, int second, 304asmlinkage int sys_ipc (unsigned int call, int first, int second,
305 unsigned long third, void __user *ptr, long fifth) 305 unsigned long third, void __user *ptr, long fifth)
306{ 306{
307 int version, ret; 307 int version, ret;
@@ -359,18 +359,18 @@ asmlinkage int sys_ipc (uint call, int first, int second,
359 case SHMAT: 359 case SHMAT:
360 switch (version) { 360 switch (version) {
361 default: { 361 default: {
362 ulong raddr; 362 unsigned long raddr;
363 ret = do_shmat (first, (char __user *) ptr, second, 363 ret = do_shmat (first, (char __user *) ptr, second,
364 &raddr); 364 &raddr);
365 if (ret) 365 if (ret)
366 return ret; 366 return ret;
367 return put_user (raddr, (ulong __user *) third); 367 return put_user (raddr, (unsigned long __user *) third);
368 } 368 }
369 case 1: /* iBCS2 emulator entry point */ 369 case 1: /* iBCS2 emulator entry point */
370 if (!segment_eq(get_fs(), get_ds())) 370 if (!segment_eq(get_fs(), get_ds()))
371 return -EINVAL; 371 return -EINVAL;
372 return do_shmat (first, (char __user *) ptr, second, 372 return do_shmat (first, (char __user *) ptr, second,
373 (ulong *) third); 373 (unsigned long *) third);
374 } 374 }
375 case SHMDT: 375 case SHMDT:
376 return sys_shmdt ((char __user *)ptr); 376 return sys_shmdt ((char __user *)ptr);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index ad16eceb24dd..67971938a2cb 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1050,7 +1050,7 @@ void *set_except_vector(int n, void *addr)
1050 return (void *)old_handler; 1050 return (void *)old_handler;
1051} 1051}
1052 1052
1053#ifdef CONFIG_CPU_MIPSR2 1053#ifdef CONFIG_CPU_MIPSR2_SRS
1054/* 1054/*
1055 * MIPSR2 shadow register set allocation 1055 * MIPSR2 shadow register set allocation
1056 * FIXME: SMP... 1056 * FIXME: SMP...
@@ -1069,11 +1069,9 @@ static struct shadow_registers {
1069 1069
1070static void mips_srs_init(void) 1070static void mips_srs_init(void)
1071{ 1071{
1072#ifdef CONFIG_CPU_MIPSR2_SRS
1073 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1; 1072 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1074 printk(KERN_INFO "%d MIPSR2 register sets available\n", 1073 printk(KERN_INFO "%d MIPSR2 register sets available\n",
1075 shadow_registers.sr_supported); 1074 shadow_registers.sr_supported);
1076#endif
1077 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */ 1075 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */
1078} 1076}
1079 1077
@@ -1198,7 +1196,14 @@ void *set_vi_handler(int n, void *addr)
1198{ 1196{
1199 return set_vi_srs_handler(n, addr, 0); 1197 return set_vi_srs_handler(n, addr, 0);
1200} 1198}
1201#endif 1199
1200#else
1201
1202static inline void mips_srs_init(void)
1203{
1204}
1205
1206#endif /* CONFIG_CPU_MIPSR2_SRS */
1202 1207
1203/* 1208/*
1204 * This is used by native signal handling 1209 * This is used by native signal handling
@@ -1388,9 +1393,7 @@ void __init trap_init(void)
1388 else 1393 else
1389 ebase = CAC_BASE; 1394 ebase = CAC_BASE;
1390 1395
1391#ifdef CONFIG_CPU_MIPSR2
1392 mips_srs_init(); 1396 mips_srs_init();
1393#endif
1394 1397
1395 per_cpu_trap_init(); 1398 per_cpu_trap_init();
1396 1399
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
index 2d3472b21ebb..9316a024a818 100644
--- a/arch/mips/lasat/interrupt.c
+++ b/arch/mips/lasat/interrupt.c
@@ -156,6 +156,6 @@ void __init arch_init_irq(void)
156 irq_desc[i].status = IRQ_DISABLED; 156 irq_desc[i].status = IRQ_DISABLED;
157 irq_desc[i].action = 0; 157 irq_desc[i].action = 0;
158 irq_desc[i].depth = 1; 158 irq_desc[i].depth = 1;
159 irq_desc[i].handler = &lasat_irq_type; 159 irq_desc[i].chip = &lasat_irq_type;
160 } 160 }
161} 161}
diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
index db53950b7cfb..9dd6b8925581 100644
--- a/arch/mips/mips-boards/atlas/atlas_int.c
+++ b/arch/mips/mips-boards/atlas/atlas_int.c
@@ -215,7 +215,7 @@ void __init arch_init_irq(void)
215 irq_desc[i].status = IRQ_DISABLED; 215 irq_desc[i].status = IRQ_DISABLED;
216 irq_desc[i].action = 0; 216 irq_desc[i].action = 0;
217 irq_desc[i].depth = 1; 217 irq_desc[i].depth = 1;
218 irq_desc[i].handler = &atlas_irq_type; 218 irq_desc[i].chip = &atlas_irq_type;
219 spin_lock_init(&irq_desc[i].lock); 219 spin_lock_init(&irq_desc[i].lock);
220 } 220 }
221} 221}
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 4a6220116c96..19e41fd186c4 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_CPU_VR41XX) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
30obj-$(CONFIG_IP22_CPU_SCACHE) += sc-ip22.o 30obj-$(CONFIG_IP22_CPU_SCACHE) += sc-ip22.o
31obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o 31obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o
32obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o 32obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o
33obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o
33 34
34# 35#
35# Choose one DMA coherency model 36# Choose one DMA coherency model
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 4a43924cd4fc..75d887e89739 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -60,13 +60,13 @@ static unsigned long scache_size __read_mostly;
60/* 60/*
61 * Dummy cache handling routines for machines without boardcaches 61 * Dummy cache handling routines for machines without boardcaches
62 */ 62 */
63static void no_sc_noop(void) {} 63static void cache_noop(void) {}
64 64
65static struct bcache_ops no_sc_ops = { 65static struct bcache_ops no_sc_ops = {
66 .bc_enable = (void *)no_sc_noop, 66 .bc_enable = (void *)cache_noop,
67 .bc_disable = (void *)no_sc_noop, 67 .bc_disable = (void *)cache_noop,
68 .bc_wback_inv = (void *)no_sc_noop, 68 .bc_wback_inv = (void *)cache_noop,
69 .bc_inv = (void *)no_sc_noop 69 .bc_inv = (void *)cache_noop
70}; 70};
71 71
72struct bcache_ops *bcops = &no_sc_ops; 72struct bcache_ops *bcops = &no_sc_ops;
@@ -94,7 +94,9 @@ static inline void r4k_blast_dcache_page_setup(void)
94{ 94{
95 unsigned long dc_lsize = cpu_dcache_line_size(); 95 unsigned long dc_lsize = cpu_dcache_line_size();
96 96
97 if (dc_lsize == 16) 97 if (dc_lsize == 0)
98 r4k_blast_dcache_page = (void *)cache_noop;
99 else if (dc_lsize == 16)
98 r4k_blast_dcache_page = blast_dcache16_page; 100 r4k_blast_dcache_page = blast_dcache16_page;
99 else if (dc_lsize == 32) 101 else if (dc_lsize == 32)
100 r4k_blast_dcache_page = r4k_blast_dcache_page_dc32; 102 r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
@@ -106,7 +108,9 @@ static inline void r4k_blast_dcache_page_indexed_setup(void)
106{ 108{
107 unsigned long dc_lsize = cpu_dcache_line_size(); 109 unsigned long dc_lsize = cpu_dcache_line_size();
108 110
109 if (dc_lsize == 16) 111 if (dc_lsize == 0)
112 r4k_blast_dcache_page_indexed = (void *)cache_noop;
113 else if (dc_lsize == 16)
110 r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed; 114 r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
111 else if (dc_lsize == 32) 115 else if (dc_lsize == 32)
112 r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed; 116 r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
@@ -118,7 +122,9 @@ static inline void r4k_blast_dcache_setup(void)
118{ 122{
119 unsigned long dc_lsize = cpu_dcache_line_size(); 123 unsigned long dc_lsize = cpu_dcache_line_size();
120 124
121 if (dc_lsize == 16) 125 if (dc_lsize == 0)
126 r4k_blast_dcache = (void *)cache_noop;
127 else if (dc_lsize == 16)
122 r4k_blast_dcache = blast_dcache16; 128 r4k_blast_dcache = blast_dcache16;
123 else if (dc_lsize == 32) 129 else if (dc_lsize == 32)
124 r4k_blast_dcache = blast_dcache32; 130 r4k_blast_dcache = blast_dcache32;
@@ -201,7 +207,9 @@ static inline void r4k_blast_icache_page_setup(void)
201{ 207{
202 unsigned long ic_lsize = cpu_icache_line_size(); 208 unsigned long ic_lsize = cpu_icache_line_size();
203 209
204 if (ic_lsize == 16) 210 if (ic_lsize == 0)
211 r4k_blast_icache_page = (void *)cache_noop;
212 else if (ic_lsize == 16)
205 r4k_blast_icache_page = blast_icache16_page; 213 r4k_blast_icache_page = blast_icache16_page;
206 else if (ic_lsize == 32) 214 else if (ic_lsize == 32)
207 r4k_blast_icache_page = blast_icache32_page; 215 r4k_blast_icache_page = blast_icache32_page;
@@ -216,7 +224,9 @@ static inline void r4k_blast_icache_page_indexed_setup(void)
216{ 224{
217 unsigned long ic_lsize = cpu_icache_line_size(); 225 unsigned long ic_lsize = cpu_icache_line_size();
218 226
219 if (ic_lsize == 16) 227 if (ic_lsize == 0)
228 r4k_blast_icache_page_indexed = (void *)cache_noop;
229 else if (ic_lsize == 16)
220 r4k_blast_icache_page_indexed = blast_icache16_page_indexed; 230 r4k_blast_icache_page_indexed = blast_icache16_page_indexed;
221 else if (ic_lsize == 32) { 231 else if (ic_lsize == 32) {
222 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) 232 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
@@ -238,7 +248,9 @@ static inline void r4k_blast_icache_setup(void)
238{ 248{
239 unsigned long ic_lsize = cpu_icache_line_size(); 249 unsigned long ic_lsize = cpu_icache_line_size();
240 250
241 if (ic_lsize == 16) 251 if (ic_lsize == 0)
252 r4k_blast_icache = (void *)cache_noop;
253 else if (ic_lsize == 16)
242 r4k_blast_icache = blast_icache16; 254 r4k_blast_icache = blast_icache16;
243 else if (ic_lsize == 32) { 255 else if (ic_lsize == 32) {
244 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) 256 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
@@ -258,7 +270,7 @@ static inline void r4k_blast_scache_page_setup(void)
258 unsigned long sc_lsize = cpu_scache_line_size(); 270 unsigned long sc_lsize = cpu_scache_line_size();
259 271
260 if (scache_size == 0) 272 if (scache_size == 0)
261 r4k_blast_scache_page = (void *)no_sc_noop; 273 r4k_blast_scache_page = (void *)cache_noop;
262 else if (sc_lsize == 16) 274 else if (sc_lsize == 16)
263 r4k_blast_scache_page = blast_scache16_page; 275 r4k_blast_scache_page = blast_scache16_page;
264 else if (sc_lsize == 32) 276 else if (sc_lsize == 32)
@@ -276,7 +288,7 @@ static inline void r4k_blast_scache_page_indexed_setup(void)
276 unsigned long sc_lsize = cpu_scache_line_size(); 288 unsigned long sc_lsize = cpu_scache_line_size();
277 289
278 if (scache_size == 0) 290 if (scache_size == 0)
279 r4k_blast_scache_page_indexed = (void *)no_sc_noop; 291 r4k_blast_scache_page_indexed = (void *)cache_noop;
280 else if (sc_lsize == 16) 292 else if (sc_lsize == 16)
281 r4k_blast_scache_page_indexed = blast_scache16_page_indexed; 293 r4k_blast_scache_page_indexed = blast_scache16_page_indexed;
282 else if (sc_lsize == 32) 294 else if (sc_lsize == 32)
@@ -294,7 +306,7 @@ static inline void r4k_blast_scache_setup(void)
294 unsigned long sc_lsize = cpu_scache_line_size(); 306 unsigned long sc_lsize = cpu_scache_line_size();
295 307
296 if (scache_size == 0) 308 if (scache_size == 0)
297 r4k_blast_scache = (void *)no_sc_noop; 309 r4k_blast_scache = (void *)cache_noop;
298 else if (sc_lsize == 16) 310 else if (sc_lsize == 16)
299 r4k_blast_scache = blast_scache16; 311 r4k_blast_scache = blast_scache16;
300 else if (sc_lsize == 32) 312 else if (sc_lsize == 32)
@@ -508,7 +520,7 @@ static inline void local_r4k_flush_icache_range(void *args)
508 unsigned long end = fir_args->end; 520 unsigned long end = fir_args->end;
509 521
510 if (!cpu_has_ic_fills_f_dc) { 522 if (!cpu_has_ic_fills_f_dc) {
511 if (end - start > dcache_size) { 523 if (end - start >= dcache_size) {
512 r4k_blast_dcache(); 524 r4k_blast_dcache();
513 } else { 525 } else {
514 R4600_HIT_CACHEOP_WAR_IMPL; 526 R4600_HIT_CACHEOP_WAR_IMPL;
@@ -683,10 +695,12 @@ static void local_r4k_flush_cache_sigtramp(void * arg)
683 unsigned long addr = (unsigned long) arg; 695 unsigned long addr = (unsigned long) arg;
684 696
685 R4600_HIT_CACHEOP_WAR_IMPL; 697 R4600_HIT_CACHEOP_WAR_IMPL;
686 protected_writeback_dcache_line(addr & ~(dc_lsize - 1)); 698 if (dc_lsize)
699 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
687 if (!cpu_icache_snoops_remote_store && scache_size) 700 if (!cpu_icache_snoops_remote_store && scache_size)
688 protected_writeback_scache_line(addr & ~(sc_lsize - 1)); 701 protected_writeback_scache_line(addr & ~(sc_lsize - 1));
689 protected_flush_icache_line(addr & ~(ic_lsize - 1)); 702 if (ic_lsize)
703 protected_flush_icache_line(addr & ~(ic_lsize - 1));
690 if (MIPS4K_ICACHE_REFILL_WAR) { 704 if (MIPS4K_ICACHE_REFILL_WAR) {
691 __asm__ __volatile__ ( 705 __asm__ __volatile__ (
692 ".set push\n\t" 706 ".set push\n\t"
@@ -973,8 +987,10 @@ static void __init probe_pcache(void)
973 c->icache.waysize = icache_size / c->icache.ways; 987 c->icache.waysize = icache_size / c->icache.ways;
974 c->dcache.waysize = dcache_size / c->dcache.ways; 988 c->dcache.waysize = dcache_size / c->dcache.ways;
975 989
976 c->icache.sets = icache_size / (c->icache.linesz * c->icache.ways); 990 c->icache.sets = c->icache.linesz ?
977 c->dcache.sets = dcache_size / (c->dcache.linesz * c->dcache.ways); 991 icache_size / (c->icache.linesz * c->icache.ways) : 0;
992 c->dcache.sets = c->dcache.linesz ?
993 dcache_size / (c->dcache.linesz * c->dcache.ways) : 0;
978 994
979 /* 995 /*
980 * R10000 and R12000 P-caches are odd in a positive way. They're 32kB 996 * R10000 and R12000 P-caches are odd in a positive way. They're 32kB
@@ -993,10 +1009,16 @@ static void __init probe_pcache(void)
993 break; 1009 break;
994 case CPU_24K: 1010 case CPU_24K:
995 case CPU_34K: 1011 case CPU_34K:
996 if (!(read_c0_config7() & (1 << 16))) 1012 case CPU_74K:
1013 if ((read_c0_config7() & (1 << 16))) {
1014 /* effectively physically indexed dcache,
1015 thus no virtual aliases. */
1016 c->dcache.flags |= MIPS_CACHE_PINDEX;
1017 break;
1018 }
997 default: 1019 default:
998 if (c->dcache.waysize > PAGE_SIZE) 1020 if (c->dcache.waysize > PAGE_SIZE)
999 c->dcache.flags |= MIPS_CACHE_ALIASES; 1021 c->dcache.flags |= MIPS_CACHE_ALIASES;
1000 } 1022 }
1001 1023
1002 switch (c->cputype) { 1024 switch (c->cputype) {
@@ -1092,6 +1114,7 @@ static int __init probe_scache(void)
1092 1114
1093extern int r5k_sc_init(void); 1115extern int r5k_sc_init(void);
1094extern int rm7k_sc_init(void); 1116extern int rm7k_sc_init(void);
1117extern int mips_sc_init(void);
1095 1118
1096static void __init setup_scache(void) 1119static void __init setup_scache(void)
1097{ 1120{
@@ -1139,17 +1162,29 @@ static void __init setup_scache(void)
1139 return; 1162 return;
1140 1163
1141 default: 1164 default:
1165 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
1166 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1167 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1168 c->isa_level == MIPS_CPU_ISA_M64R2) {
1169#ifdef CONFIG_MIPS_CPU_SCACHE
1170 if (mips_sc_init ()) {
1171 scache_size = c->scache.ways * c->scache.sets * c->scache.linesz;
1172 printk("MIPS secondary cache %ldkB, %s, linesize %d bytes.\n",
1173 scache_size >> 10,
1174 way_string[c->scache.ways], c->scache.linesz);
1175 }
1176#else
1177 if (!(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
1178 panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
1179#endif
1180 return;
1181 }
1142 sc_present = 0; 1182 sc_present = 0;
1143 } 1183 }
1144 1184
1145 if (!sc_present) 1185 if (!sc_present)
1146 return; 1186 return;
1147 1187
1148 if ((c->isa_level == MIPS_CPU_ISA_M32R1 ||
1149 c->isa_level == MIPS_CPU_ISA_M64R1) &&
1150 !(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
1151 panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
1152
1153 /* compute a couple of other cache variables */ 1188 /* compute a couple of other cache variables */
1154 c->scache.waysize = scache_size / c->scache.ways; 1189 c->scache.waysize = scache_size / c->scache.ways;
1155 1190
@@ -1246,10 +1281,12 @@ void __init r4k_cache_init(void)
1246 * This code supports virtually indexed processors and will be 1281 * This code supports virtually indexed processors and will be
1247 * unnecessarily inefficient on physically indexed processors. 1282 * unnecessarily inefficient on physically indexed processors.
1248 */ 1283 */
1249 shm_align_mask = max_t( unsigned long, 1284 if (c->dcache.linesz)
1250 c->dcache.sets * c->dcache.linesz - 1, 1285 shm_align_mask = max_t( unsigned long,
1251 PAGE_SIZE - 1); 1286 c->dcache.sets * c->dcache.linesz - 1,
1252 1287 PAGE_SIZE - 1);
1288 else
1289 shm_align_mask = PAGE_SIZE-1;
1253 flush_cache_all = r4k_flush_cache_all; 1290 flush_cache_all = r4k_flush_cache_all;
1254 __flush_cache_all = r4k___flush_cache_all; 1291 __flush_cache_all = r4k___flush_cache_all;
1255 flush_cache_mm = r4k_flush_cache_mm; 1292 flush_cache_mm = r4k_flush_cache_mm;
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
new file mode 100644
index 000000000000..42b50964c644
--- /dev/null
+++ b/arch/mips/mm/sc-mips.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright (C) 2006 Chris Dearman (chris@mips.com),
3 */
4#include <linux/init.h>
5#include <linux/kernel.h>
6#include <linux/sched.h>
7#include <linux/mm.h>
8
9#include <asm/mipsregs.h>
10#include <asm/bcache.h>
11#include <asm/cacheops.h>
12#include <asm/page.h>
13#include <asm/pgtable.h>
14#include <asm/system.h>
15#include <asm/mmu_context.h>
16#include <asm/r4kcache.h>
17
18/*
19 * MIPS32/MIPS64 L2 cache handling
20 */
21
22/*
23 * Writeback and invalidate the secondary cache before DMA.
24 */
25static void mips_sc_wback_inv(unsigned long addr, unsigned long size)
26{
27 blast_scache_range(addr, addr + size);
28}
29
30/*
31 * Invalidate the secondary cache before DMA.
32 */
33static void mips_sc_inv(unsigned long addr, unsigned long size)
34{
35 blast_inv_scache_range(addr, addr + size);
36}
37
38static void mips_sc_enable(void)
39{
40 /* L2 cache is permanently enabled */
41}
42
43static void mips_sc_disable(void)
44{
45 /* L2 cache is permanently enabled */
46}
47
48static struct bcache_ops mips_sc_ops = {
49 .bc_enable = mips_sc_enable,
50 .bc_disable = mips_sc_disable,
51 .bc_wback_inv = mips_sc_wback_inv,
52 .bc_inv = mips_sc_inv
53};
54
55static inline int __init mips_sc_probe(void)
56{
57 struct cpuinfo_mips *c = &current_cpu_data;
58 unsigned int config1, config2;
59 unsigned int tmp;
60
61 /* Mark as not present until probe completed */
62 c->scache.flags |= MIPS_CACHE_NOT_PRESENT;
63
64 /* Ignore anything but MIPSxx processors */
65 if (c->isa_level != MIPS_CPU_ISA_M32R1 &&
66 c->isa_level != MIPS_CPU_ISA_M32R2 &&
67 c->isa_level != MIPS_CPU_ISA_M64R1 &&
68 c->isa_level != MIPS_CPU_ISA_M64R2)
69 return 0;
70
71 /* Does this MIPS32/MIPS64 CPU have a config2 register? */
72 config1 = read_c0_config1();
73 if (!(config1 & MIPS_CONF_M))
74 return 0;
75
76 config2 = read_c0_config2();
77 tmp = (config2 >> 4) & 0x0f;
78 if (0 < tmp && tmp <= 7)
79 c->scache.linesz = 2 << tmp;
80 else
81 return 0;
82
83 tmp = (config2 >> 8) & 0x0f;
84 if (0 <= tmp && tmp <= 7)
85 c->scache.sets = 64 << tmp;
86 else
87 return 0;
88
89 tmp = (config2 >> 0) & 0x0f;
90 if (0 <= tmp && tmp <= 7)
91 c->scache.ways = tmp + 1;
92 else
93 return 0;
94
95 c->scache.waysize = c->scache.sets * c->scache.linesz;
96 c->scache.waybit = __ffs(c->scache.waysize);
97
98 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
99
100 return 1;
101}
102
103int __init mips_sc_init(void)
104{
105 int found = mips_sc_probe ();
106 if (found) {
107 mips_sc_enable();
108 bcops = &mips_sc_ops;
109 }
110 return found;
111}
112
diff --git a/arch/mips/momentum/jaguar_atx/setup.c b/arch/mips/momentum/jaguar_atx/setup.c
index df1485501ce6..d0419480b097 100644
--- a/arch/mips/momentum/jaguar_atx/setup.c
+++ b/arch/mips/momentum/jaguar_atx/setup.c
@@ -370,8 +370,8 @@ void __init plat_mem_setup(void)
370 pm_power_off = momenco_jaguar_power_off; 370 pm_power_off = momenco_jaguar_power_off;
371 371
372 /* 372 /*
373 * initrd_start = (ulong)jaguar_initrd_start; 373 * initrd_start = (unsigned long)jaguar_initrd_start;
374 * initrd_end = (ulong)jaguar_initrd_start + (ulong)jaguar_initrd_size; 374 * initrd_end = (unsigned long)jaguar_initrd_start + (ulong)jaguar_initrd_size;
375 * initrd_below_start_ok = 1; 375 * initrd_below_start_ok = 1;
376 */ 376 */
377 377
diff --git a/arch/mips/momentum/ocelot_c/cpci-irq.c b/arch/mips/momentum/ocelot_c/cpci-irq.c
index bd885785e2f9..31d179c4673f 100644
--- a/arch/mips/momentum/ocelot_c/cpci-irq.c
+++ b/arch/mips/momentum/ocelot_c/cpci-irq.c
@@ -147,6 +147,6 @@ void cpci_irq_init(void)
147 irq_desc[i].status = IRQ_DISABLED; 147 irq_desc[i].status = IRQ_DISABLED;
148 irq_desc[i].action = 0; 148 irq_desc[i].action = 0;
149 irq_desc[i].depth = 2; 149 irq_desc[i].depth = 2;
150 irq_desc[i].handler = &cpci_irq_type; 150 irq_desc[i].chip = &cpci_irq_type;
151 } 151 }
152} 152}
diff --git a/arch/mips/momentum/ocelot_c/setup.c b/arch/mips/momentum/ocelot_c/setup.c
index 257e1d1b72dd..a0ee006d75cf 100644
--- a/arch/mips/momentum/ocelot_c/setup.c
+++ b/arch/mips/momentum/ocelot_c/setup.c
@@ -242,8 +242,8 @@ void __init plat_mem_setup(void)
242 pm_power_off = momenco_ocelot_power_off; 242 pm_power_off = momenco_ocelot_power_off;
243 243
244 /* 244 /*
245 * initrd_start = (ulong)ocelot_initrd_start; 245 * initrd_start = (unsigned long)ocelot_initrd_start;
246 * initrd_end = (ulong)ocelot_initrd_start + (ulong)ocelot_initrd_size; 246 * initrd_end = (unsigned long)ocelot_initrd_start + (ulong)ocelot_initrd_size;
247 * initrd_below_start_ok = 1; 247 * initrd_below_start_ok = 1;
248 */ 248 */
249 249
diff --git a/arch/mips/momentum/ocelot_c/uart-irq.c b/arch/mips/momentum/ocelot_c/uart-irq.c
index 755bde5146be..852265026fd1 100644
--- a/arch/mips/momentum/ocelot_c/uart-irq.c
+++ b/arch/mips/momentum/ocelot_c/uart-irq.c
@@ -137,10 +137,10 @@ void uart_irq_init(void)
137 irq_desc[80].status = IRQ_DISABLED; 137 irq_desc[80].status = IRQ_DISABLED;
138 irq_desc[80].action = 0; 138 irq_desc[80].action = 0;
139 irq_desc[80].depth = 2; 139 irq_desc[80].depth = 2;
140 irq_desc[80].handler = &uart_irq_type; 140 irq_desc[80].chip = &uart_irq_type;
141 141
142 irq_desc[81].status = IRQ_DISABLED; 142 irq_desc[81].status = IRQ_DISABLED;
143 irq_desc[81].action = 0; 143 irq_desc[81].action = 0;
144 irq_desc[81].depth = 2; 144 irq_desc[81].depth = 2;
145 irq_desc[81].handler = &uart_irq_type; 145 irq_desc[81].chip = &uart_irq_type;
146} 146}
diff --git a/arch/mips/momentum/ocelot_g/setup.c b/arch/mips/momentum/ocelot_g/setup.c
index 72143ab1e900..39da02b4e076 100644
--- a/arch/mips/momentum/ocelot_g/setup.c
+++ b/arch/mips/momentum/ocelot_g/setup.c
@@ -174,8 +174,8 @@ void __init plat_mem_setup(void)
174 pm_power_off = momenco_ocelot_power_off; 174 pm_power_off = momenco_ocelot_power_off;
175 175
176 /* 176 /*
177 * initrd_start = (ulong)ocelot_initrd_start; 177 * initrd_start = (unsigned long)ocelot_initrd_start;
178 * initrd_end = (ulong)ocelot_initrd_start + (ulong)ocelot_initrd_size; 178 * initrd_end = (unsigned long)ocelot_initrd_start + (ulong)ocelot_initrd_size;
179 * initrd_below_start_ok = 1; 179 * initrd_below_start_ok = 1;
180 */ 180 */
181 181
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index f26a00e13204..a09c5f901233 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -12,16 +12,70 @@
12 12
13#include "op_impl.h" 13#include "op_impl.h"
14 14
15#define M_PERFCTL_EXL (1UL << 0) 15#define M_PERFCTL_EXL (1UL << 0)
16#define M_PERFCTL_KERNEL (1UL << 1) 16#define M_PERFCTL_KERNEL (1UL << 1)
17#define M_PERFCTL_SUPERVISOR (1UL << 2) 17#define M_PERFCTL_SUPERVISOR (1UL << 2)
18#define M_PERFCTL_USER (1UL << 3) 18#define M_PERFCTL_USER (1UL << 3)
19#define M_PERFCTL_INTERRUPT_ENABLE (1UL << 4) 19#define M_PERFCTL_INTERRUPT_ENABLE (1UL << 4)
20#define M_PERFCTL_EVENT(event) ((event) << 5) 20#define M_PERFCTL_EVENT(event) ((event) << 5)
21#define M_PERFCTL_WIDE (1UL << 30) 21#define M_PERFCTL_VPEID(vpe) ((vpe) << 16)
22#define M_PERFCTL_MORE (1UL << 31) 22#define M_PERFCTL_MT_EN(filter) ((filter) << 20)
23#define M_TC_EN_ALL M_PERFCTL_MT_EN(0)
24#define M_TC_EN_VPE M_PERFCTL_MT_EN(1)
25#define M_TC_EN_TC M_PERFCTL_MT_EN(2)
26#define M_PERFCTL_TCID(tcid) ((tcid) << 22)
27#define M_PERFCTL_WIDE (1UL << 30)
28#define M_PERFCTL_MORE (1UL << 31)
29
30#define M_COUNTER_OVERFLOW (1UL << 31)
31
32#ifdef CONFIG_MIPS_MT_SMP
33#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id()))
34#else
35#define WHAT 0
36#endif
23 37
24#define M_COUNTER_OVERFLOW (1UL << 31) 38#define __define_perf_accessors(r, n, np) \
39 \
40static inline unsigned int r_c0_ ## r ## n(void) \
41{ \
42 unsigned int cpu = smp_processor_id(); \
43 \
44 switch (cpu) { \
45 case 0: \
46 return read_c0_ ## r ## n(); \
47 case 1: \
48 return read_c0_ ## r ## np(); \
49 default: \
50 BUG(); \
51 } \
52} \
53 \
54static inline void w_c0_ ## r ## n(unsigned int value) \
55{ \
56 unsigned int cpu = smp_processor_id(); \
57 \
58 switch (cpu) { \
59 case 0: \
60 write_c0_ ## r ## n(value); \
61 return; \
62 case 1: \
63 write_c0_ ## r ## np(value); \
64 return; \
65 default: \
66 BUG(); \
67 } \
68} \
69
70__define_perf_accessors(perfcntr, 0, 2)
71__define_perf_accessors(perfcntr, 1, 3)
72__define_perf_accessors(perfcntr, 2, 2)
73__define_perf_accessors(perfcntr, 3, 2)
74
75__define_perf_accessors(perfctrl, 0, 2)
76__define_perf_accessors(perfctrl, 1, 3)
77__define_perf_accessors(perfctrl, 2, 2)
78__define_perf_accessors(perfctrl, 3, 2)
25 79
26struct op_mips_model op_model_mipsxx_ops; 80struct op_mips_model op_model_mipsxx_ops;
27 81
@@ -66,17 +120,17 @@ static void mipsxx_cpu_setup (void *args)
66 120
67 switch (counters) { 121 switch (counters) {
68 case 4: 122 case 4:
69 write_c0_perfctrl3(0); 123 w_c0_perfctrl3(0);
70 write_c0_perfcntr3(reg.counter[3]); 124 w_c0_perfcntr3(reg.counter[3]);
71 case 3: 125 case 3:
72 write_c0_perfctrl2(0); 126 w_c0_perfctrl2(0);
73 write_c0_perfcntr2(reg.counter[2]); 127 w_c0_perfcntr2(reg.counter[2]);
74 case 2: 128 case 2:
75 write_c0_perfctrl1(0); 129 w_c0_perfctrl1(0);
76 write_c0_perfcntr1(reg.counter[1]); 130 w_c0_perfcntr1(reg.counter[1]);
77 case 1: 131 case 1:
78 write_c0_perfctrl0(0); 132 w_c0_perfctrl0(0);
79 write_c0_perfcntr0(reg.counter[0]); 133 w_c0_perfcntr0(reg.counter[0]);
80 } 134 }
81} 135}
82 136
@@ -87,13 +141,13 @@ static void mipsxx_cpu_start(void *args)
87 141
88 switch (counters) { 142 switch (counters) {
89 case 4: 143 case 4:
90 write_c0_perfctrl3(reg.control[3]); 144 w_c0_perfctrl3(WHAT | reg.control[3]);
91 case 3: 145 case 3:
92 write_c0_perfctrl2(reg.control[2]); 146 w_c0_perfctrl2(WHAT | reg.control[2]);
93 case 2: 147 case 2:
94 write_c0_perfctrl1(reg.control[1]); 148 w_c0_perfctrl1(WHAT | reg.control[1]);
95 case 1: 149 case 1:
96 write_c0_perfctrl0(reg.control[0]); 150 w_c0_perfctrl0(WHAT | reg.control[0]);
97 } 151 }
98} 152}
99 153
@@ -104,13 +158,13 @@ static void mipsxx_cpu_stop(void *args)
104 158
105 switch (counters) { 159 switch (counters) {
106 case 4: 160 case 4:
107 write_c0_perfctrl3(0); 161 w_c0_perfctrl3(0);
108 case 3: 162 case 3:
109 write_c0_perfctrl2(0); 163 w_c0_perfctrl2(0);
110 case 2: 164 case 2:
111 write_c0_perfctrl1(0); 165 w_c0_perfctrl1(0);
112 case 1: 166 case 1:
113 write_c0_perfctrl0(0); 167 w_c0_perfctrl0(0);
114 } 168 }
115} 169}
116 170
@@ -124,12 +178,12 @@ static int mipsxx_perfcount_handler(struct pt_regs *regs)
124 switch (counters) { 178 switch (counters) {
125#define HANDLE_COUNTER(n) \ 179#define HANDLE_COUNTER(n) \
126 case n + 1: \ 180 case n + 1: \
127 control = read_c0_perfctrl ## n(); \ 181 control = r_c0_perfctrl ## n(); \
128 counter = read_c0_perfcntr ## n(); \ 182 counter = r_c0_perfcntr ## n(); \
129 if ((control & M_PERFCTL_INTERRUPT_ENABLE) && \ 183 if ((control & M_PERFCTL_INTERRUPT_ENABLE) && \
130 (counter & M_COUNTER_OVERFLOW)) { \ 184 (counter & M_COUNTER_OVERFLOW)) { \
131 oprofile_add_sample(regs, n); \ 185 oprofile_add_sample(regs, n); \
132 write_c0_perfcntr ## n(reg.counter[n]); \ 186 w_c0_perfcntr ## n(reg.counter[n]); \
133 handled = 1; \ 187 handled = 1; \
134 } 188 }
135 HANDLE_COUNTER(3) 189 HANDLE_COUNTER(3)
@@ -143,35 +197,47 @@ static int mipsxx_perfcount_handler(struct pt_regs *regs)
143 197
144#define M_CONFIG1_PC (1 << 4) 198#define M_CONFIG1_PC (1 << 4)
145 199
146static inline int n_counters(void) 200static inline int __n_counters(void)
147{ 201{
148 if (!(read_c0_config1() & M_CONFIG1_PC)) 202 if (!(read_c0_config1() & M_CONFIG1_PC))
149 return 0; 203 return 0;
150 if (!(read_c0_perfctrl0() & M_PERFCTL_MORE)) 204 if (!(r_c0_perfctrl0() & M_PERFCTL_MORE))
151 return 1; 205 return 1;
152 if (!(read_c0_perfctrl1() & M_PERFCTL_MORE)) 206 if (!(r_c0_perfctrl1() & M_PERFCTL_MORE))
153 return 2; 207 return 2;
154 if (!(read_c0_perfctrl2() & M_PERFCTL_MORE)) 208 if (!(r_c0_perfctrl2() & M_PERFCTL_MORE))
155 return 3; 209 return 3;
156 210
157 return 4; 211 return 4;
158} 212}
159 213
214static inline int n_counters(void)
215{
216 int counters = __n_counters();
217
218#ifndef CONFIG_SMP
219 if (current_cpu_data.cputype == CPU_34K)
220 return counters >> 1;
221#endif
222
223 return counters;
224}
225
160static inline void reset_counters(int counters) 226static inline void reset_counters(int counters)
161{ 227{
162 switch (counters) { 228 switch (counters) {
163 case 4: 229 case 4:
164 write_c0_perfctrl3(0); 230 w_c0_perfctrl3(0);
165 write_c0_perfcntr3(0); 231 w_c0_perfcntr3(0);
166 case 3: 232 case 3:
167 write_c0_perfctrl2(0); 233 w_c0_perfctrl2(0);
168 write_c0_perfcntr2(0); 234 w_c0_perfcntr2(0);
169 case 2: 235 case 2:
170 write_c0_perfctrl1(0); 236 w_c0_perfctrl1(0);
171 write_c0_perfcntr1(0); 237 w_c0_perfcntr1(0);
172 case 1: 238 case 1:
173 write_c0_perfctrl0(0); 239 w_c0_perfctrl0(0);
174 write_c0_perfcntr0(0); 240 w_c0_perfcntr0(0);
175 } 241 }
176} 242}
177 243
@@ -201,7 +267,6 @@ static int __init mipsxx_init(void)
201 op_model_mipsxx_ops.cpu_type = "mips/25K"; 267 op_model_mipsxx_ops.cpu_type = "mips/25K";
202 break; 268 break;
203 269
204#ifndef CONFIG_SMP
205 case CPU_34K: 270 case CPU_34K:
206 op_model_mipsxx_ops.cpu_type = "mips/34K"; 271 op_model_mipsxx_ops.cpu_type = "mips/34K";
207 break; 272 break;
@@ -209,7 +274,6 @@ static int __init mipsxx_init(void)
209 case CPU_74K: 274 case CPU_74K:
210 op_model_mipsxx_ops.cpu_type = "mips/74K"; 275 op_model_mipsxx_ops.cpu_type = "mips/74K";
211 break; 276 break;
212#endif
213 277
214 case CPU_5KC: 278 case CPU_5KC:
215 op_model_mipsxx_ops.cpu_type = "mips/5K"; 279 op_model_mipsxx_ops.cpu_type = "mips/5K";
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index 465778c5d816..35d5927706ea 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_MARKEINS) += ops-emma2rh.o pci-emma2rh.o fixup-emma2rh.o
23# 23#
24# These are still pretty much in the old state, watch, go blind. 24# These are still pretty much in the old state, watch, go blind.
25# 25#
26obj-$(CONFIG_BASLER_EXCITE) = ops-titan.o pci-excite.o fixup-excite.o 26obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o
27obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o 27obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o
28obj-$(CONFIG_LASAT) += pci-lasat.o 28obj-$(CONFIG_LASAT) += pci-lasat.o
29obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o 29obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
index 7688b7711329..150419c8b414 100644
--- a/arch/mips/pci/ops-tx4927.c
+++ b/arch/mips/pci/ops-tx4927.c
@@ -119,7 +119,7 @@ static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, i
119 119
120 switch (size) { 120 switch (size) {
121 case 1: 121 case 1:
122 *val = *(volatile u8 *) ((ulong) & tx4927_pcicptr-> 122 *val = *(volatile u8 *) ((unsigned long) & tx4927_pcicptr->
123 g2pcfgdata | 123 g2pcfgdata |
124#ifdef __LITTLE_ENDIAN 124#ifdef __LITTLE_ENDIAN
125 (where & 3)); 125 (where & 3));
@@ -128,7 +128,7 @@ static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, i
128#endif 128#endif
129 break; 129 break;
130 case 2: 130 case 2:
131 *val = *(volatile u16 *) ((ulong) & tx4927_pcicptr-> 131 *val = *(volatile u16 *) ((unsigned long) & tx4927_pcicptr->
132 g2pcfgdata | 132 g2pcfgdata |
133#ifdef __LITTLE_ENDIAN 133#ifdef __LITTLE_ENDIAN
134 (where & 3)); 134 (where & 3));
@@ -168,7 +168,7 @@ static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn,
168 168
169 switch (size) { 169 switch (size) {
170 case 1: 170 case 1:
171 *(volatile u8 *) ((ulong) & tx4927_pcicptr-> 171 *(volatile u8 *) ((unsigned long) & tx4927_pcicptr->
172 g2pcfgdata | 172 g2pcfgdata |
173#ifdef __LITTLE_ENDIAN 173#ifdef __LITTLE_ENDIAN
174 (where & 3)) = val; 174 (where & 3)) = val;
@@ -178,7 +178,7 @@ static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn,
178 break; 178 break;
179 179
180 case 2: 180 case 2:
181 *(volatile u16 *) ((ulong) & tx4927_pcicptr-> 181 *(volatile u16 *) ((unsigned long) & tx4927_pcicptr->
182 g2pcfgdata | 182 g2pcfgdata |
183#ifdef __LITTLE_ENDIAN 183#ifdef __LITTLE_ENDIAN
184 (where & 3)) = val; 184 (where & 3)) = val;
diff --git a/arch/mips/pci/ops-tx4938.c b/arch/mips/pci/ops-tx4938.c
index 0ff083489efd..445007084515 100644
--- a/arch/mips/pci/ops-tx4938.c
+++ b/arch/mips/pci/ops-tx4938.c
@@ -106,7 +106,7 @@ static int tx4938_pcibios_read_config(struct pci_bus *bus, unsigned int devfn,
106 106
107 switch (size) { 107 switch (size) {
108 case 1: 108 case 1:
109 *val = *(volatile u8 *) ((ulong) & tx4938_pcicptr->g2pcfgdata | 109 *val = *(volatile u8 *) ((unsigned long) & tx4938_pcicptr->g2pcfgdata |
110#ifdef __BIG_ENDIAN 110#ifdef __BIG_ENDIAN
111 ((where & 3) ^ 3)); 111 ((where & 3) ^ 3));
112#else 112#else
@@ -114,7 +114,7 @@ static int tx4938_pcibios_read_config(struct pci_bus *bus, unsigned int devfn,
114#endif 114#endif
115 break; 115 break;
116 case 2: 116 case 2:
117 *val = *(volatile u16 *) ((ulong) & tx4938_pcicptr->g2pcfgdata | 117 *val = *(volatile u16 *) ((unsigned long) & tx4938_pcicptr->g2pcfgdata |
118#ifdef __BIG_ENDIAN 118#ifdef __BIG_ENDIAN
119 ((where & 3) ^ 2)); 119 ((where & 3) ^ 2));
120#else 120#else
@@ -154,7 +154,7 @@ static int tx4938_pcibios_write_config(struct pci_bus *bus, unsigned int devfn,
154 154
155 switch (size) { 155 switch (size) {
156 case 1: 156 case 1:
157 *(volatile u8 *) ((ulong) & tx4938_pcicptr->g2pcfgdata | 157 *(volatile u8 *) ((unsigned long) & tx4938_pcicptr->g2pcfgdata |
158#ifdef __BIG_ENDIAN 158#ifdef __BIG_ENDIAN
159 ((where & 3) ^ 3)) = val; 159 ((where & 3) ^ 3)) = val;
160#else 160#else
@@ -162,7 +162,7 @@ static int tx4938_pcibios_write_config(struct pci_bus *bus, unsigned int devfn,
162#endif 162#endif
163 break; 163 break;
164 case 2: 164 case 2:
165 *(volatile u16 *) ((ulong) & tx4938_pcicptr->g2pcfgdata | 165 *(volatile u16 *) ((unsigned long) & tx4938_pcicptr->g2pcfgdata |
166#ifdef __BIG_ENDIAN 166#ifdef __BIG_ENDIAN
167 ((where & 0x3) ^ 0x2)) = val; 167 ((where & 0x3) ^ 0x2)) = val;
168#else 168#else
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 4dfce154d4af..ba66f8c9bd4e 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -51,11 +51,11 @@ unsigned long PCIBIOS_MIN_MEM = 0;
51 */ 51 */
52void 52void
53pcibios_align_resource(void *data, struct resource *res, 53pcibios_align_resource(void *data, struct resource *res,
54 unsigned long size, unsigned long align) 54 resource_size_t size, resource_size_t align)
55{ 55{
56 struct pci_dev *dev = data; 56 struct pci_dev *dev = data;
57 struct pci_controller *hose = dev->sysdata; 57 struct pci_controller *hose = dev->sysdata;
58 unsigned long start = res->start; 58 resource_size_t start = res->start;
59 59
60 if (res->flags & IORESOURCE_IO) { 60 if (res->flags & IORESOURCE_IO) {
61 /* Make sure we start at our min on all hoses */ 61 /* Make sure we start at our min on all hoses */
diff --git a/arch/mips/philips/pnx8550/common/int.c b/arch/mips/philips/pnx8550/common/int.c
index 39ee6314f627..8f18764a2359 100644
--- a/arch/mips/philips/pnx8550/common/int.c
+++ b/arch/mips/philips/pnx8550/common/int.c
@@ -236,7 +236,7 @@ void __init arch_init_irq(void)
236 int configPR; 236 int configPR;
237 237
238 for (i = 0; i < PNX8550_INT_CP0_TOTINT; i++) { 238 for (i = 0; i < PNX8550_INT_CP0_TOTINT; i++) {
239 irq_desc[i].handler = &level_irq_type; 239 irq_desc[i].chip = &level_irq_type;
240 pnx8550_ack(i); /* mask the irq just in case */ 240 pnx8550_ack(i); /* mask the irq just in case */
241 } 241 }
242 242
@@ -273,7 +273,7 @@ void __init arch_init_irq(void)
273 /* mask/priority is still 0 so we will not get any 273 /* mask/priority is still 0 so we will not get any
274 * interrupts until it is unmasked */ 274 * interrupts until it is unmasked */
275 275
276 irq_desc[i].handler = &level_irq_type; 276 irq_desc[i].chip = &level_irq_type;
277 } 277 }
278 278
279 /* Priority level 0 */ 279 /* Priority level 0 */
@@ -282,12 +282,12 @@ void __init arch_init_irq(void)
282 /* Set int vector table address */ 282 /* Set int vector table address */
283 PNX8550_GIC_VECTOR_0 = PNX8550_GIC_VECTOR_1 = 0; 283 PNX8550_GIC_VECTOR_0 = PNX8550_GIC_VECTOR_1 = 0;
284 284
285 irq_desc[MIPS_CPU_GIC_IRQ].handler = &level_irq_type; 285 irq_desc[MIPS_CPU_GIC_IRQ].chip = &level_irq_type;
286 setup_irq(MIPS_CPU_GIC_IRQ, &gic_action); 286 setup_irq(MIPS_CPU_GIC_IRQ, &gic_action);
287 287
288 /* init of Timer interrupts */ 288 /* init of Timer interrupts */
289 for (i = PNX8550_INT_TIMER_MIN; i <= PNX8550_INT_TIMER_MAX; i++) { 289 for (i = PNX8550_INT_TIMER_MIN; i <= PNX8550_INT_TIMER_MAX; i++) {
290 irq_desc[i].handler = &level_irq_type; 290 irq_desc[i].chip = &level_irq_type;
291 } 291 }
292 292
293 /* Stop Timer 1-3 */ 293 /* Stop Timer 1-3 */
@@ -295,7 +295,7 @@ void __init arch_init_irq(void)
295 configPR |= 0x00000038; 295 configPR |= 0x00000038;
296 write_c0_config7(configPR); 296 write_c0_config7(configPR);
297 297
298 irq_desc[MIPS_CPU_TIMER_IRQ].handler = &level_irq_type; 298 irq_desc[MIPS_CPU_TIMER_IRQ].chip = &level_irq_type;
299 setup_irq(MIPS_CPU_TIMER_IRQ, &timer_action); 299 setup_irq(MIPS_CPU_TIMER_IRQ, &timer_action);
300} 300}
301 301
diff --git a/arch/mips/pmc-sierra/yosemite/ht.c b/arch/mips/pmc-sierra/yosemite/ht.c
index 54b65a80abf5..fb523ebcafa8 100644
--- a/arch/mips/pmc-sierra/yosemite/ht.c
+++ b/arch/mips/pmc-sierra/yosemite/ht.c
@@ -383,12 +383,12 @@ void pcibios_update_resource(struct pci_dev *dev, struct resource *root,
383 383
384 384
385void pcibios_align_resource(void *data, struct resource *res, 385void pcibios_align_resource(void *data, struct resource *res,
386 unsigned long size, unsigned long align) 386 resource_size_t size, resource_size_t align)
387{ 387{
388 struct pci_dev *dev = data; 388 struct pci_dev *dev = data;
389 389
390 if (res->flags & IORESOURCE_IO) { 390 if (res->flags & IORESOURCE_IO) {
391 unsigned long start = res->start; 391 resource_size_t start = res->start;
392 392
393 /* We need to avoid collisions with `mirrored' VGA ports 393 /* We need to avoid collisions with `mirrored' VGA ports
394 and other strange ISA hardware, so we always want the 394 and other strange ISA hardware, so we always want the
diff --git a/arch/mips/sgi-ip22/ip22-eisa.c b/arch/mips/sgi-ip22/ip22-eisa.c
index b19820110aa3..989167b49ce9 100644
--- a/arch/mips/sgi-ip22/ip22-eisa.c
+++ b/arch/mips/sgi-ip22/ip22-eisa.c
@@ -279,9 +279,9 @@ int __init ip22_eisa_init(void)
279 irq_desc[i].action = 0; 279 irq_desc[i].action = 0;
280 irq_desc[i].depth = 1; 280 irq_desc[i].depth = 1;
281 if (i < (SGINT_EISA + 8)) 281 if (i < (SGINT_EISA + 8))
282 irq_desc[i].handler = &ip22_eisa1_irq_type; 282 irq_desc[i].chip = &ip22_eisa1_irq_type;
283 else 283 else
284 irq_desc[i].handler = &ip22_eisa2_irq_type; 284 irq_desc[i].chip = &ip22_eisa2_irq_type;
285 } 285 }
286 286
287 /* Cannot use request_irq because of kmalloc not being ready at such 287 /* Cannot use request_irq because of kmalloc not being ready at such
diff --git a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c
index fc6a7e2b189c..18906af69691 100644
--- a/arch/mips/sgi-ip22/ip22-int.c
+++ b/arch/mips/sgi-ip22/ip22-int.c
@@ -436,7 +436,7 @@ void __init arch_init_irq(void)
436 irq_desc[i].status = IRQ_DISABLED; 436 irq_desc[i].status = IRQ_DISABLED;
437 irq_desc[i].action = 0; 437 irq_desc[i].action = 0;
438 irq_desc[i].depth = 1; 438 irq_desc[i].depth = 1;
439 irq_desc[i].handler = handler; 439 irq_desc[i].chip = handler;
440 } 440 }
441 441
442 /* vector handler. this register the IRQ as non-sharable */ 442 /* vector handler. this register the IRQ as non-sharable */
diff --git a/arch/mips/sgi-ip27/Kconfig b/arch/mips/sgi-ip27/Kconfig
index f14ef38646d0..5e960ae9735a 100644
--- a/arch/mips/sgi-ip27/Kconfig
+++ b/arch/mips/sgi-ip27/Kconfig
@@ -33,12 +33,13 @@ config MAPPED_KERNEL
33 depends on SGI_IP27 33 depends on SGI_IP27
34 help 34 help
35 Change the way a Linux kernel is loaded into memory on a MIPS64 35 Change the way a Linux kernel is loaded into memory on a MIPS64
36 machine. This is required in order to support text replication and 36 machine. This is required in order to support text replication on
37 NUMA. If you need to understand it, read the source code. 37 NUMA. If you need to understand it, read the source code.
38 38
39config REPLICATE_KTEXT 39config REPLICATE_KTEXT
40 bool "Kernel text replication support" 40 bool "Kernel text replication support"
41 depends on SGI_IP27 41 depends on SGI_IP27
42 select MAPPED_KERNEL
42 help 43 help
43 Say Y here to enable replicating the kernel text across multiple 44 Say Y here to enable replicating the kernel text across multiple
44 nodes in a NUMA cluster. This trades memory for speed. 45 nodes in a NUMA cluster. This trades memory for speed.
diff --git a/arch/mips/sgi-ip27/Makefile b/arch/mips/sgi-ip27/Makefile
index 686ba14e2882..a457263f4391 100644
--- a/arch/mips/sgi-ip27/Makefile
+++ b/arch/mips/sgi-ip27/Makefile
@@ -2,11 +2,12 @@
2# Makefile for the IP27 specific kernel interface routines under Linux. 2# Makefile for the IP27 specific kernel interface routines under Linux.
3# 3#
4 4
5obj-y := ip27-berr.o ip27-console.o ip27-irq.o ip27-init.o \ 5obj-y := ip27-berr.o ip27-irq.o ip27-init.o ip27-klconfig.o ip27-klnuma.o \
6 ip27-klconfig.o ip27-klnuma.o ip27-memory.o ip27-nmi.o ip27-reset.o \ 6 ip27-memory.o ip27-nmi.o ip27-reset.o ip27-timer.o ip27-hubio.o \
7 ip27-timer.o ip27-hubio.o ip27-xtalk.o 7 ip27-xtalk.o
8 8
9obj-$(CONFIG_KGDB) += ip27-dbgio.o 9obj-$(CONFIG_EARLY_PRINTK) += ip27-console.o
10obj-$(CONFIG_SMP) += ip27-smp.o 10obj-$(CONFIG_KGDB) += ip27-dbgio.o
11obj-$(CONFIG_SMP) += ip27-smp.o
11 12
12EXTRA_AFLAGS := $(CFLAGS) 13EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/sgi-ip27/ip27-console.c b/arch/mips/sgi-ip27/ip27-console.c
index 3e1ac299b804..14211e382374 100644
--- a/arch/mips/sgi-ip27/ip27-console.c
+++ b/arch/mips/sgi-ip27/ip27-console.c
@@ -46,33 +46,29 @@ void prom_putchar(char c)
46 uart->iu_thr = c; 46 uart->iu_thr = c;
47} 47}
48 48
49char __init prom_getchar(void) 49static void ioc3_console_write(struct console *con, const char *s, unsigned n)
50{ 50{
51 return 0; 51 while (n-- && *s) {
52 if (*s == '\n')
53 prom_putchar('\r');
54 prom_putchar(*s);
55 s++;
56 }
52} 57}
53 58
54static void inline ioc3_console_probe(void) 59static struct console ioc3_console = {
55{ 60 .name = "ioc3",
56 struct uart_port up; 61 .write = ioc3_console_write,
57 62 .flags = CON_PRINTBUFFER | CON_BOOT,
58 /* 63 .index = -1
59 * Register to interrupt zero because we share the interrupt with 64};
60 * the serial driver which we don't properly support yet.
61 */
62 memset(&up, 0, sizeof(up));
63 up.membase = (unsigned char *) console_uart();
64 up.irq = 0;
65 up.uartclk = IOC3_CLK;
66 up.regshift = 0;
67 up.iotype = UPIO_MEM;
68 up.flags = IOC3_FLAGS;
69 up.line = 0;
70 65
71 if (early_serial_setup(&up)) 66__init void ip27_setup_console(void)
72 printk(KERN_ERR "Early serial init of port 0 failed\n"); 67{
68 register_console(&ioc3_console);
73} 69}
74 70
75__init void ip27_setup_console(void) 71void __init disable_early_printk(void)
76{ 72{
77 ioc3_console_probe(); 73 unregister_console(&ioc3_console);
78} 74}
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 0b61a39ce2bb..869566c360ae 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -386,7 +386,7 @@ void __devinit register_bridge_irq(unsigned int irq)
386 irq_desc[irq].status = IRQ_DISABLED; 386 irq_desc[irq].status = IRQ_DISABLED;
387 irq_desc[irq].action = 0; 387 irq_desc[irq].action = 0;
388 irq_desc[irq].depth = 1; 388 irq_desc[irq].depth = 1;
389 irq_desc[irq].handler = &bridge_irq_type; 389 irq_desc[irq].chip = &bridge_irq_type;
390} 390}
391 391
392int __devinit request_bridge_irq(struct bridge_controller *bc) 392int __devinit request_bridge_irq(struct bridge_controller *bc)
diff --git a/arch/mips/sgi-ip32/ip32-irq.c b/arch/mips/sgi-ip32/ip32-irq.c
index 8ba08047d164..00b94aaf6371 100644
--- a/arch/mips/sgi-ip32/ip32-irq.c
+++ b/arch/mips/sgi-ip32/ip32-irq.c
@@ -591,7 +591,7 @@ void __init arch_init_irq(void)
591 irq_desc[irq].status = IRQ_DISABLED; 591 irq_desc[irq].status = IRQ_DISABLED;
592 irq_desc[irq].action = 0; 592 irq_desc[irq].action = 0;
593 irq_desc[irq].depth = 0; 593 irq_desc[irq].depth = 0;
594 irq_desc[irq].handler = controller; 594 irq_desc[irq].chip = controller;
595 } 595 }
596 setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); 596 setup_irq(CRIME_MEMERR_IRQ, &memerr_irq);
597 setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); 597 setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq);
diff --git a/arch/mips/sibyte/Kconfig b/arch/mips/sibyte/Kconfig
index 816aee7fcd25..ec7a2cffacf0 100644
--- a/arch/mips/sibyte/Kconfig
+++ b/arch/mips/sibyte/Kconfig
@@ -3,6 +3,7 @@ config SIBYTE_SB1250
3 select HW_HAS_PCI 3 select HW_HAS_PCI
4 select SIBYTE_HAS_LDT 4 select SIBYTE_HAS_LDT
5 select SIBYTE_SB1xxx_SOC 5 select SIBYTE_SB1xxx_SOC
6 select SYS_SUPPORTS_SMP
6 7
7config SIBYTE_BCM1120 8config SIBYTE_BCM1120
8 bool 9 bool
@@ -30,11 +31,13 @@ config SIBYTE_BCM1x80
30 bool 31 bool
31 select HW_HAS_PCI 32 select HW_HAS_PCI
32 select SIBYTE_SB1xxx_SOC 33 select SIBYTE_SB1xxx_SOC
34 select SYS_SUPPORTS_SMP
33 35
34config SIBYTE_BCM1x55 36config SIBYTE_BCM1x55
35 bool 37 bool
36 select HW_HAS_PCI 38 select HW_HAS_PCI
37 select SIBYTE_SB1xxx_SOC 39 select SIBYTE_SB1xxx_SOC
40 select SYS_SUPPORTS_SMP
38 41
39config SIBYTE_SB1xxx_SOC 42config SIBYTE_SB1xxx_SOC
40 bool 43 bool
diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
index e61760b14d99..610df40cb820 100644
--- a/arch/mips/sibyte/bcm1480/irq.c
+++ b/arch/mips/sibyte/bcm1480/irq.c
@@ -276,10 +276,10 @@ void __init init_bcm1480_irqs(void)
276 irq_desc[i].action = 0; 276 irq_desc[i].action = 0;
277 irq_desc[i].depth = 1; 277 irq_desc[i].depth = 1;
278 if (i < BCM1480_NR_IRQS) { 278 if (i < BCM1480_NR_IRQS) {
279 irq_desc[i].handler = &bcm1480_irq_type; 279 irq_desc[i].chip = &bcm1480_irq_type;
280 bcm1480_irq_owner[i] = 0; 280 bcm1480_irq_owner[i] = 0;
281 } else { 281 } else {
282 irq_desc[i].handler = &no_irq_type; 282 irq_desc[i].chip = &no_irq_type;
283 } 283 }
284 } 284 }
285} 285}
diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
index f853c32f60a0..fcc61940f1ff 100644
--- a/arch/mips/sibyte/sb1250/irq.c
+++ b/arch/mips/sibyte/sb1250/irq.c
@@ -246,10 +246,10 @@ void __init init_sb1250_irqs(void)
246 irq_desc[i].action = 0; 246 irq_desc[i].action = 0;
247 irq_desc[i].depth = 1; 247 irq_desc[i].depth = 1;
248 if (i < SB1250_NR_IRQS) { 248 if (i < SB1250_NR_IRQS) {
249 irq_desc[i].handler = &sb1250_irq_type; 249 irq_desc[i].chip = &sb1250_irq_type;
250 sb1250_irq_owner[i] = 0; 250 sb1250_irq_owner[i] = 0;
251 } else { 251 } else {
252 irq_desc[i].handler = &no_irq_type; 252 irq_desc[i].chip = &no_irq_type;
253 } 253 }
254 } 254 }
255} 255}
diff --git a/arch/mips/sni/irq.c b/arch/mips/sni/irq.c
index 7365b4853ddb..c19e158ec402 100644
--- a/arch/mips/sni/irq.c
+++ b/arch/mips/sni/irq.c
@@ -203,7 +203,7 @@ void __init arch_init_irq(void)
203 irq_desc[i].status = IRQ_DISABLED; 203 irq_desc[i].status = IRQ_DISABLED;
204 irq_desc[i].action = 0; 204 irq_desc[i].action = 0;
205 irq_desc[i].depth = 1; 205 irq_desc[i].depth = 1;
206 irq_desc[i].handler = &pciasic_irq_type; 206 irq_desc[i].chip = &pciasic_irq_type;
207 } 207 }
208 208
209 change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4); 209 change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4);
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
index 8ca68015cf40..a42be00483e6 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/tx4927/common/tx4927_irq.c
@@ -227,7 +227,7 @@ static void __init tx4927_irq_cp0_init(void)
227 irq_desc[i].status = IRQ_DISABLED; 227 irq_desc[i].status = IRQ_DISABLED;
228 irq_desc[i].action = 0; 228 irq_desc[i].action = 0;
229 irq_desc[i].depth = 1; 229 irq_desc[i].depth = 1;
230 irq_desc[i].handler = &tx4927_irq_cp0_type; 230 irq_desc[i].chip = &tx4927_irq_cp0_type;
231 } 231 }
232 232
233 return; 233 return;
@@ -435,7 +435,7 @@ static void __init tx4927_irq_pic_init(void)
435 irq_desc[i].status = IRQ_DISABLED; 435 irq_desc[i].status = IRQ_DISABLED;
436 irq_desc[i].action = 0; 436 irq_desc[i].action = 0;
437 irq_desc[i].depth = 2; 437 irq_desc[i].depth = 2;
438 irq_desc[i].handler = &tx4927_irq_pic_type; 438 irq_desc[i].chip = &tx4927_irq_pic_type;
439 } 439 }
440 440
441 setup_irq(TX4927_IRQ_NEST_PIC_ON_CP0, &tx4927_irq_pic_action); 441 setup_irq(TX4927_IRQ_NEST_PIC_ON_CP0, &tx4927_irq_pic_action);
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
index aee07ff2212a..c67978b6dae4 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
@@ -368,7 +368,7 @@ static void __init toshiba_rbtx4927_irq_ioc_init(void)
368 irq_desc[i].status = IRQ_DISABLED; 368 irq_desc[i].status = IRQ_DISABLED;
369 irq_desc[i].action = 0; 369 irq_desc[i].action = 0;
370 irq_desc[i].depth = 3; 370 irq_desc[i].depth = 3;
371 irq_desc[i].handler = &toshiba_rbtx4927_irq_ioc_type; 371 irq_desc[i].chip = &toshiba_rbtx4927_irq_ioc_type;
372 } 372 }
373 373
374 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC, 374 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC,
@@ -526,7 +526,7 @@ static void __init toshiba_rbtx4927_irq_isa_init(void)
526 irq_desc[i].action = 0; 526 irq_desc[i].action = 0;
527 irq_desc[i].depth = 527 irq_desc[i].depth =
528 ((i < TOSHIBA_RBTX4927_IRQ_ISA_MID) ? (4) : (5)); 528 ((i < TOSHIBA_RBTX4927_IRQ_ISA_MID) ? (4) : (5));
529 irq_desc[i].handler = &toshiba_rbtx4927_irq_isa_type; 529 irq_desc[i].chip = &toshiba_rbtx4927_irq_isa_type;
530 } 530 }
531 531
532 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC, 532 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC,
@@ -692,13 +692,13 @@ void toshiba_rbtx4927_irq_dump(char *key)
692 { 692 {
693 u32 i, j = 0; 693 u32 i, j = 0;
694 for (i = 0; i < NR_IRQS; i++) { 694 for (i = 0; i < NR_IRQS; i++) {
695 if (strcmp(irq_desc[i].handler->typename, "none") 695 if (strcmp(irq_desc[i].chip->typename, "none")
696 == 0) 696 == 0)
697 continue; 697 continue;
698 698
699 if ((i >= 1) 699 if ((i >= 1)
700 && (irq_desc[i - 1].handler->typename == 700 && (irq_desc[i - 1].chip->typename ==
701 irq_desc[i].handler->typename)) { 701 irq_desc[i].chip->typename)) {
702 j++; 702 j++;
703 } else { 703 } else {
704 j = 0; 704 j = 0;
@@ -707,12 +707,12 @@ void toshiba_rbtx4927_irq_dump(char *key)
707 (TOSHIBA_RBTX4927_IRQ_INFO, 707 (TOSHIBA_RBTX4927_IRQ_INFO,
708 "%s irq=0x%02x/%3d s=0x%08x h=0x%08x a=0x%08x ah=0x%08x d=%1d n=%s/%02d\n", 708 "%s irq=0x%02x/%3d s=0x%08x h=0x%08x a=0x%08x ah=0x%08x d=%1d n=%s/%02d\n",
709 key, i, i, irq_desc[i].status, 709 key, i, i, irq_desc[i].status,
710 (u32) irq_desc[i].handler, 710 (u32) irq_desc[i].chip,
711 (u32) irq_desc[i].action, 711 (u32) irq_desc[i].action,
712 (u32) (irq_desc[i].action ? irq_desc[i]. 712 (u32) (irq_desc[i].action ? irq_desc[i].
713 action->handler : 0), 713 action->handler : 0),
714 irq_desc[i].depth, 714 irq_desc[i].depth,
715 irq_desc[i].handler->typename, j); 715 irq_desc[i].chip->typename, j);
716 } 716 }
717 } 717 }
718#endif 718#endif
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c
index 873805178d8e..0b2f8c849218 100644
--- a/arch/mips/tx4938/common/irq.c
+++ b/arch/mips/tx4938/common/irq.c
@@ -102,7 +102,7 @@ tx4938_irq_cp0_init(void)
102 irq_desc[i].status = IRQ_DISABLED; 102 irq_desc[i].status = IRQ_DISABLED;
103 irq_desc[i].action = 0; 103 irq_desc[i].action = 0;
104 irq_desc[i].depth = 1; 104 irq_desc[i].depth = 1;
105 irq_desc[i].handler = &tx4938_irq_cp0_type; 105 irq_desc[i].chip = &tx4938_irq_cp0_type;
106 } 106 }
107 107
108 return; 108 return;
@@ -306,7 +306,7 @@ tx4938_irq_pic_init(void)
306 irq_desc[i].status = IRQ_DISABLED; 306 irq_desc[i].status = IRQ_DISABLED;
307 irq_desc[i].action = 0; 307 irq_desc[i].action = 0;
308 irq_desc[i].depth = 2; 308 irq_desc[i].depth = 2;
309 irq_desc[i].handler = &tx4938_irq_pic_type; 309 irq_desc[i].chip = &tx4938_irq_pic_type;
310 } 310 }
311 311
312 setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action); 312 setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action);
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
index 9cd9c0fe2265..3b8245dc5bd3 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
@@ -146,7 +146,7 @@ toshiba_rbtx4938_irq_ioc_init(void)
146 irq_desc[i].status = IRQ_DISABLED; 146 irq_desc[i].status = IRQ_DISABLED;
147 irq_desc[i].action = 0; 147 irq_desc[i].action = 0;
148 irq_desc[i].depth = 3; 148 irq_desc[i].depth = 3;
149 irq_desc[i].handler = &toshiba_rbtx4938_irq_ioc_type; 149 irq_desc[i].chip = &toshiba_rbtx4938_irq_ioc_type;
150 } 150 }
151 151
152 setup_irq(RBTX4938_IRQ_IOCINT, 152 setup_irq(RBTX4938_IRQ_IOCINT,
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 07ae19cf0c29..b9323302cc4e 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -722,10 +722,10 @@ static int __init vr41xx_icu_init(void)
722 icu2_write(MGIUINTHREG, 0xffff); 722 icu2_write(MGIUINTHREG, 0xffff);
723 723
724 for (i = SYSINT1_IRQ_BASE; i <= SYSINT1_IRQ_LAST; i++) 724 for (i = SYSINT1_IRQ_BASE; i <= SYSINT1_IRQ_LAST; i++)
725 irq_desc[i].handler = &sysint1_irq_type; 725 irq_desc[i].chip = &sysint1_irq_type;
726 726
727 for (i = SYSINT2_IRQ_BASE; i <= SYSINT2_IRQ_LAST; i++) 727 for (i = SYSINT2_IRQ_BASE; i <= SYSINT2_IRQ_LAST; i++)
728 irq_desc[i].handler = &sysint2_irq_type; 728 irq_desc[i].chip = &sysint2_irq_type;
729 729
730 cascade_irq(INT0_IRQ, icu_get_irq); 730 cascade_irq(INT0_IRQ, icu_get_irq);
731 cascade_irq(INT1_IRQ, icu_get_irq); 731 cascade_irq(INT1_IRQ, icu_get_irq);
diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
index 86796bb63c3c..66aa50802deb 100644
--- a/arch/mips/vr41xx/common/irq.c
+++ b/arch/mips/vr41xx/common/irq.c
@@ -73,13 +73,13 @@ static void irq_dispatch(unsigned int irq, struct pt_regs *regs)
73 if (cascade->get_irq != NULL) { 73 if (cascade->get_irq != NULL) {
74 unsigned int source_irq = irq; 74 unsigned int source_irq = irq;
75 desc = irq_desc + source_irq; 75 desc = irq_desc + source_irq;
76 desc->handler->ack(source_irq); 76 desc->chip->ack(source_irq);
77 irq = cascade->get_irq(irq, regs); 77 irq = cascade->get_irq(irq, regs);
78 if (irq < 0) 78 if (irq < 0)
79 atomic_inc(&irq_err_count); 79 atomic_inc(&irq_err_count);
80 else 80 else
81 irq_dispatch(irq, regs); 81 irq_dispatch(irq, regs);
82 desc->handler->end(source_irq); 82 desc->chip->end(source_irq);
83 } else 83 } else
84 do_IRQ(irq, regs); 84 do_IRQ(irq, regs);
85} 85}
diff --git a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
index 3e31f8193d21..2d287b8893d9 100644
--- a/arch/mips/vr41xx/common/vrc4173.c
+++ b/arch/mips/vr41xx/common/vrc4173.c
@@ -483,7 +483,7 @@ static inline int vrc4173_icu_init(int cascade_irq)
483 vr41xx_set_irq_level(GIU_IRQ_TO_PIN(cascade_irq), LEVEL_LOW); 483 vr41xx_set_irq_level(GIU_IRQ_TO_PIN(cascade_irq), LEVEL_LOW);
484 484
485 for (i = VRC4173_IRQ_BASE; i <= VRC4173_IRQ_LAST; i++) 485 for (i = VRC4173_IRQ_BASE; i <= VRC4173_IRQ_LAST; i++)
486 irq_desc[i].handler = &vrc4173_irq_type; 486 irq_desc[i].chip = &vrc4173_irq_type;
487 487
488 return 0; 488 return 0;
489} 489}
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/irq.c b/arch/mips/vr41xx/nec-cmbvr4133/irq.c
index 31db6b61a39e..7b2511ca0a61 100644
--- a/arch/mips/vr41xx/nec-cmbvr4133/irq.c
+++ b/arch/mips/vr41xx/nec-cmbvr4133/irq.c
@@ -104,7 +104,7 @@ void __init rockhopper_init_irq(void)
104 } 104 }
105 105
106 for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++) 106 for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
107 irq_desc[i].handler = &i8259_irq_type; 107 irq_desc[i].chip = &i8259_irq_type;
108 108
109 setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade); 109 setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
110 110
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 910fb3afc0b5..6dd0ea8f88e0 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -51,6 +51,10 @@ config GENERIC_HARDIRQS
51config GENERIC_IRQ_PROBE 51config GENERIC_IRQ_PROBE
52 def_bool y 52 def_bool y
53 53
54config IRQ_PER_CPU
55 bool
56 default y
57
54# unless you want to implement ACPI on PA-RISC ... ;-) 58# unless you want to implement ACPI on PA-RISC ... ;-)
55config PM 59config PM
56 bool 60 bool
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index c057ad7605ba..bc7c4a4e26a1 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -97,15 +97,17 @@ update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte)
97void 97void
98show_cache_info(struct seq_file *m) 98show_cache_info(struct seq_file *m)
99{ 99{
100 char buf[32];
101
100 seq_printf(m, "I-cache\t\t: %ld KB\n", 102 seq_printf(m, "I-cache\t\t: %ld KB\n",
101 cache_info.ic_size/1024 ); 103 cache_info.ic_size/1024 );
102 seq_printf(m, "D-cache\t\t: %ld KB (%s%s, %d-way associative)\n", 104 if (cache_info.dc_loop == 1)
105 snprintf(buf, 32, "%lu-way associative", cache_info.dc_loop);
106 seq_printf(m, "D-cache\t\t: %ld KB (%s%s, %s)\n",
103 cache_info.dc_size/1024, 107 cache_info.dc_size/1024,
104 (cache_info.dc_conf.cc_wt ? "WT":"WB"), 108 (cache_info.dc_conf.cc_wt ? "WT":"WB"),
105 (cache_info.dc_conf.cc_sh ? ", shared I/D":""), 109 (cache_info.dc_conf.cc_sh ? ", shared I/D":""),
106 (cache_info.dc_conf.cc_assoc) 110 ((cache_info.dc_loop == 1) ? "direct mapped" : buf));
107 );
108
109 seq_printf(m, "ITLB entries\t: %ld\n" "DTLB entries\t: %ld%s\n", 111 seq_printf(m, "ITLB entries\t: %ld\n" "DTLB entries\t: %ld%s\n",
110 cache_info.it_size, 112 cache_info.it_size,
111 cache_info.dt_size, 113 cache_info.dt_size,
@@ -158,11 +160,11 @@ parisc_cache_init(void)
158 cache_info.dc_conf.cc_block, 160 cache_info.dc_conf.cc_block,
159 cache_info.dc_conf.cc_line, 161 cache_info.dc_conf.cc_line,
160 cache_info.dc_conf.cc_shift); 162 cache_info.dc_conf.cc_shift);
161 printk(" wt %d sh %d cst %d assoc %d\n", 163 printk(" wt %d sh %d cst %d hv %d\n",
162 cache_info.dc_conf.cc_wt, 164 cache_info.dc_conf.cc_wt,
163 cache_info.dc_conf.cc_sh, 165 cache_info.dc_conf.cc_sh,
164 cache_info.dc_conf.cc_cst, 166 cache_info.dc_conf.cc_cst,
165 cache_info.dc_conf.cc_assoc); 167 cache_info.dc_conf.cc_hv);
166 168
167 printk("IC base 0x%lx stride 0x%lx count 0x%lx loop 0x%lx\n", 169 printk("IC base 0x%lx stride 0x%lx count 0x%lx loop 0x%lx\n",
168 cache_info.ic_base, 170 cache_info.ic_base,
@@ -176,11 +178,11 @@ parisc_cache_init(void)
176 cache_info.ic_conf.cc_block, 178 cache_info.ic_conf.cc_block,
177 cache_info.ic_conf.cc_line, 179 cache_info.ic_conf.cc_line,
178 cache_info.ic_conf.cc_shift); 180 cache_info.ic_conf.cc_shift);
179 printk(" wt %d sh %d cst %d assoc %d\n", 181 printk(" wt %d sh %d cst %d hv %d\n",
180 cache_info.ic_conf.cc_wt, 182 cache_info.ic_conf.cc_wt,
181 cache_info.ic_conf.cc_sh, 183 cache_info.ic_conf.cc_sh,
182 cache_info.ic_conf.cc_cst, 184 cache_info.ic_conf.cc_cst,
183 cache_info.ic_conf.cc_assoc); 185 cache_info.ic_conf.cc_hv);
184 186
185 printk("D-TLB conf: sh %d page %d cst %d aid %d pad1 %d \n", 187 printk("D-TLB conf: sh %d page %d cst %d aid %d pad1 %d \n",
186 cache_info.dt_conf.tc_sh, 188 cache_info.dt_conf.tc_sh,
@@ -234,7 +236,8 @@ parisc_cache_init(void)
234 236
235void disable_sr_hashing(void) 237void disable_sr_hashing(void)
236{ 238{
237 int srhash_type; 239 int srhash_type, retval;
240 unsigned long space_bits;
238 241
239 switch (boot_cpu_data.cpu_type) { 242 switch (boot_cpu_data.cpu_type) {
240 case pcx: /* We shouldn't get this far. setup.c should prevent it. */ 243 case pcx: /* We shouldn't get this far. setup.c should prevent it. */
@@ -260,6 +263,13 @@ void disable_sr_hashing(void)
260 } 263 }
261 264
262 disable_sr_hashing_asm(srhash_type); 265 disable_sr_hashing_asm(srhash_type);
266
267 retval = pdc_spaceid_bits(&space_bits);
268 /* If this procedure isn't implemented, don't panic. */
269 if (retval < 0 && retval != PDC_BAD_OPTION)
270 panic("pdc_spaceid_bits call failed.\n");
271 if (space_bits != 0)
272 panic("SpaceID hashing is still on!\n");
263} 273}
264 274
265void flush_dcache_page(struct page *page) 275void flush_dcache_page(struct page *page)
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index d9e53cf0372b..630730c32a5a 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -1638,7 +1638,7 @@ dbit_trap_20w:
1638 load32 PA(pa_dbit_lock),t0 1638 load32 PA(pa_dbit_lock),t0
1639 1639
1640dbit_spin_20w: 1640dbit_spin_20w:
1641 ldcw 0(t0),t1 1641 LDCW 0(t0),t1
1642 cmpib,= 0,t1,dbit_spin_20w 1642 cmpib,= 0,t1,dbit_spin_20w
1643 nop 1643 nop
1644 1644
@@ -1674,7 +1674,7 @@ dbit_trap_11:
1674 load32 PA(pa_dbit_lock),t0 1674 load32 PA(pa_dbit_lock),t0
1675 1675
1676dbit_spin_11: 1676dbit_spin_11:
1677 ldcw 0(t0),t1 1677 LDCW 0(t0),t1
1678 cmpib,= 0,t1,dbit_spin_11 1678 cmpib,= 0,t1,dbit_spin_11
1679 nop 1679 nop
1680 1680
@@ -1714,7 +1714,7 @@ dbit_trap_20:
1714 load32 PA(pa_dbit_lock),t0 1714 load32 PA(pa_dbit_lock),t0
1715 1715
1716dbit_spin_20: 1716dbit_spin_20:
1717 ldcw 0(t0),t1 1717 LDCW 0(t0),t1
1718 cmpib,= 0,t1,dbit_spin_20 1718 cmpib,= 0,t1,dbit_spin_20
1719 nop 1719 nop
1720 1720
diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c
index 2dc06b8e1817..4398d2a95789 100644
--- a/arch/parisc/kernel/firmware.c
+++ b/arch/parisc/kernel/firmware.c
@@ -11,7 +11,7 @@
11 * Copyright 1999 The Puffin Group, (Alex deVries, David Kennedy) 11 * Copyright 1999 The Puffin Group, (Alex deVries, David Kennedy)
12 * Copyright 2003 Grant Grundler <grundler parisc-linux org> 12 * Copyright 2003 Grant Grundler <grundler parisc-linux org>
13 * Copyright 2003,2004 Ryan Bradetich <rbrad@parisc-linux.org> 13 * Copyright 2003,2004 Ryan Bradetich <rbrad@parisc-linux.org>
14 * Copyright 2004 Thibaut VARENE <varenet@parisc-linux.org> 14 * Copyright 2004,2006 Thibaut VARENE <varenet@parisc-linux.org>
15 * 15 *
16 * This program is free software; you can redistribute it and/or modify 16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by 17 * it under the terms of the GNU General Public License as published by
@@ -252,10 +252,8 @@ int pdc_pat_chassis_send_log(unsigned long state, unsigned long data)
252#endif 252#endif
253 253
254/** 254/**
255 * pdc_chassis_disp - Updates display 255 * pdc_chassis_disp - Updates chassis code
256 * @retval: -1 on error, 0 on success 256 * @retval: -1 on error, 0 on success
257 *
258 * Works on old PDC only (E class, others?)
259 */ 257 */
260int pdc_chassis_disp(unsigned long disp) 258int pdc_chassis_disp(unsigned long disp)
261{ 259{
@@ -269,6 +267,22 @@ int pdc_chassis_disp(unsigned long disp)
269} 267}
270 268
271/** 269/**
270 * pdc_chassis_warn - Fetches chassis warnings
271 * @retval: -1 on error, 0 on success
272 */
273int pdc_chassis_warn(unsigned long *warn)
274{
275 int retval = 0;
276
277 spin_lock_irq(&pdc_lock);
278 retval = mem_pdc_call(PDC_CHASSIS, PDC_CHASSIS_WARN, __pa(pdc_result));
279 *warn = pdc_result[0];
280 spin_unlock_irq(&pdc_lock);
281
282 return retval;
283}
284
285/**
272 * pdc_coproc_cfg - To identify coprocessors attached to the processor. 286 * pdc_coproc_cfg - To identify coprocessors attached to the processor.
273 * @pdc_coproc_info: Return buffer address. 287 * @pdc_coproc_info: Return buffer address.
274 * 288 *
@@ -393,7 +407,9 @@ int pdc_model_info(struct pdc_model *model)
393 * pdc_model_sysmodel - Get the system model name. 407 * pdc_model_sysmodel - Get the system model name.
394 * @name: A char array of at least 81 characters. 408 * @name: A char array of at least 81 characters.
395 * 409 *
396 * Get system model name from PDC ROM (e.g. 9000/715 or 9000/778/B160L) 410 * Get system model name from PDC ROM (e.g. 9000/715 or 9000/778/B160L).
411 * Using OS_ID_HPUX will return the equivalent of the 'modelname' command
412 * on HP/UX.
397 */ 413 */
398int pdc_model_sysmodel(char *name) 414int pdc_model_sysmodel(char *name)
399{ 415{
@@ -498,6 +514,26 @@ int pdc_cache_info(struct pdc_cache_info *cache_info)
498 return retval; 514 return retval;
499} 515}
500 516
517/**
518 * pdc_spaceid_bits - Return whether Space ID hashing is turned on.
519 * @space_bits: Should be 0, if not, bad mojo!
520 *
521 * Returns information about Space ID hashing.
522 */
523int pdc_spaceid_bits(unsigned long *space_bits)
524{
525 int retval;
526
527 spin_lock_irq(&pdc_lock);
528 pdc_result[0] = 0;
529 retval = mem_pdc_call(PDC_CACHE, PDC_CACHE_RET_SPID, __pa(pdc_result), 0);
530 convert_to_wide(pdc_result);
531 *space_bits = pdc_result[0];
532 spin_unlock_irq(&pdc_lock);
533
534 return retval;
535}
536
501#ifndef CONFIG_PA20 537#ifndef CONFIG_PA20
502/** 538/**
503 * pdc_btlb_info - Return block TLB information. 539 * pdc_btlb_info - Return block TLB information.
diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c
index 197936d9359a..82fe6ba29727 100644
--- a/arch/parisc/kernel/irq.c
+++ b/arch/parisc/kernel/irq.c
@@ -94,7 +94,7 @@ int cpu_check_affinity(unsigned int irq, cpumask_t *dest)
94 if (irq == TIMER_IRQ || irq == IPI_IRQ) { 94 if (irq == TIMER_IRQ || irq == IPI_IRQ) {
95 /* Bad linux design decision. The mask has already 95 /* Bad linux design decision. The mask has already
96 * been set; we must reset it */ 96 * been set; we must reset it */
97 irq_affinity[irq] = CPU_MASK_ALL; 97 irq_desc[irq].affinity = CPU_MASK_ALL;
98 return -EINVAL; 98 return -EINVAL;
99 } 99 }
100 100
@@ -110,7 +110,7 @@ static void cpu_set_affinity_irq(unsigned int irq, cpumask_t dest)
110 if (cpu_check_affinity(irq, &dest)) 110 if (cpu_check_affinity(irq, &dest))
111 return; 111 return;
112 112
113 irq_affinity[irq] = dest; 113 irq_desc[irq].affinity = dest;
114} 114}
115#endif 115#endif
116 116
@@ -125,6 +125,10 @@ static struct hw_interrupt_type cpu_interrupt_type = {
125#ifdef CONFIG_SMP 125#ifdef CONFIG_SMP
126 .set_affinity = cpu_set_affinity_irq, 126 .set_affinity = cpu_set_affinity_irq,
127#endif 127#endif
128 /* XXX: Needs to be written. We managed without it so far, but
129 * we really ought to write it.
130 */
131 .retrigger = NULL,
128}; 132};
129 133
130int show_interrupts(struct seq_file *p, void *v) 134int show_interrupts(struct seq_file *p, void *v)
@@ -158,7 +162,7 @@ int show_interrupts(struct seq_file *p, void *v)
158 seq_printf(p, "%10u ", kstat_irqs(i)); 162 seq_printf(p, "%10u ", kstat_irqs(i));
159#endif 163#endif
160 164
161 seq_printf(p, " %14s", irq_desc[i].handler->typename); 165 seq_printf(p, " %14s", irq_desc[i].chip->typename);
162#ifndef PARISC_IRQ_CR16_COUNTS 166#ifndef PARISC_IRQ_CR16_COUNTS
163 seq_printf(p, " %s", action->name); 167 seq_printf(p, " %s", action->name);
164 168
@@ -210,12 +214,12 @@ int cpu_claim_irq(unsigned int irq, struct hw_interrupt_type *type, void *data)
210{ 214{
211 if (irq_desc[irq].action) 215 if (irq_desc[irq].action)
212 return -EBUSY; 216 return -EBUSY;
213 if (irq_desc[irq].handler != &cpu_interrupt_type) 217 if (irq_desc[irq].chip != &cpu_interrupt_type)
214 return -EBUSY; 218 return -EBUSY;
215 219
216 if (type) { 220 if (type) {
217 irq_desc[irq].handler = type; 221 irq_desc[irq].chip = type;
218 irq_desc[irq].handler_data = data; 222 irq_desc[irq].chip_data = data;
219 cpu_interrupt_type.enable(irq); 223 cpu_interrupt_type.enable(irq);
220 } 224 }
221 return 0; 225 return 0;
@@ -265,7 +269,7 @@ int txn_alloc_irq(unsigned int bits_wide)
265unsigned long txn_affinity_addr(unsigned int irq, int cpu) 269unsigned long txn_affinity_addr(unsigned int irq, int cpu)
266{ 270{
267#ifdef CONFIG_SMP 271#ifdef CONFIG_SMP
268 irq_affinity[irq] = cpumask_of_cpu(cpu); 272 irq_desc[irq].affinity = cpumask_of_cpu(cpu);
269#endif 273#endif
270 274
271 return cpu_data[cpu].txn_addr; 275 return cpu_data[cpu].txn_addr;
@@ -326,7 +330,7 @@ void do_cpu_irq_mask(struct pt_regs *regs)
326 /* Work our way from MSb to LSb...same order we alloc EIRs */ 330 /* Work our way from MSb to LSb...same order we alloc EIRs */
327 for (irq = TIMER_IRQ; eirr_val && bit; bit>>=1, irq++) { 331 for (irq = TIMER_IRQ; eirr_val && bit; bit>>=1, irq++) {
328#ifdef CONFIG_SMP 332#ifdef CONFIG_SMP
329 cpumask_t dest = irq_affinity[irq]; 333 cpumask_t dest = irq_desc[irq].affinity;
330#endif 334#endif
331 if (!(bit & eirr_val)) 335 if (!(bit & eirr_val))
332 continue; 336 continue;
@@ -378,7 +382,7 @@ static void claim_cpu_irqs(void)
378{ 382{
379 int i; 383 int i;
380 for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) { 384 for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) {
381 irq_desc[i].handler = &cpu_interrupt_type; 385 irq_desc[i].chip = &cpu_interrupt_type;
382 } 386 }
383 387
384 irq_desc[TIMER_IRQ].action = &timer_action; 388 irq_desc[TIMER_IRQ].action = &timer_action;
@@ -404,13 +408,6 @@ void __init init_IRQ(void)
404 408
405} 409}
406 410
407void hw_resend_irq(struct hw_interrupt_type *type, unsigned int irq)
408{
409 /* XXX: Needs to be written. We managed without it so far, but
410 * we really ought to write it.
411 */
412}
413
414void ack_bad_irq(unsigned int irq) 411void ack_bad_irq(unsigned int irq)
415{ 412{
416 printk("unexpected IRQ %d\n", irq); 413 printk("unexpected IRQ %d\n", irq);
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index f27cfe4771b8..aee311884f3f 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -89,6 +89,12 @@ static inline int is_local(struct module *me, void *loc)
89 return is_init(me, loc) || is_core(me, loc); 89 return is_init(me, loc) || is_core(me, loc);
90} 90}
91 91
92static inline int is_local_section(struct module *me, void *loc, void *dot)
93{
94 return (is_init(me, loc) && is_init(me, dot)) ||
95 (is_core(me, loc) && is_core(me, dot));
96}
97
92 98
93#ifndef __LP64__ 99#ifndef __LP64__
94struct got_entry { 100struct got_entry {
@@ -364,8 +370,14 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
364} 370}
365#endif /* __LP64__ */ 371#endif /* __LP64__ */
366 372
373enum elf_stub_type {
374 ELF_STUB_GOT,
375 ELF_STUB_MILLI,
376 ELF_STUB_DIRECT,
377};
378
367static Elf_Addr get_stub(struct module *me, unsigned long value, long addend, 379static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
368 int millicode, int init_section) 380 enum elf_stub_type stub_type, int init_section)
369{ 381{
370 unsigned long i; 382 unsigned long i;
371 struct stub_entry *stub; 383 struct stub_entry *stub;
@@ -396,7 +408,7 @@ static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
396 stub->insns[1] |= reassemble_17(rrsel(value, addend) / 4); 408 stub->insns[1] |= reassemble_17(rrsel(value, addend) / 4);
397 409
398#else 410#else
399/* for 64-bit we have two kinds of stubs: 411/* for 64-bit we have three kinds of stubs:
400 * for normal function calls: 412 * for normal function calls:
401 * ldd 0(%dp),%dp 413 * ldd 0(%dp),%dp
402 * ldd 10(%dp), %r1 414 * ldd 10(%dp), %r1
@@ -408,18 +420,23 @@ static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
408 * ldo 0(%r1), %r1 420 * ldo 0(%r1), %r1
409 * ldd 10(%r1), %r1 421 * ldd 10(%r1), %r1
410 * bve,n (%r1) 422 * bve,n (%r1)
423 *
424 * for direct branches (jumps between different section of the
425 * same module):
426 * ldil 0, %r1
427 * ldo 0(%r1), %r1
428 * bve,n (%r1)
411 */ 429 */
412 if (!millicode) 430 switch (stub_type) {
413 { 431 case ELF_STUB_GOT:
414 stub->insns[0] = 0x537b0000; /* ldd 0(%dp),%dp */ 432 stub->insns[0] = 0x537b0000; /* ldd 0(%dp),%dp */
415 stub->insns[1] = 0x53610020; /* ldd 10(%dp),%r1 */ 433 stub->insns[1] = 0x53610020; /* ldd 10(%dp),%r1 */
416 stub->insns[2] = 0xe820d000; /* bve (%r1) */ 434 stub->insns[2] = 0xe820d000; /* bve (%r1) */
417 stub->insns[3] = 0x537b0030; /* ldd 18(%dp),%dp */ 435 stub->insns[3] = 0x537b0030; /* ldd 18(%dp),%dp */
418 436
419 stub->insns[0] |= reassemble_14(get_got(me, value, addend) & 0x3fff); 437 stub->insns[0] |= reassemble_14(get_got(me, value, addend) & 0x3fff);
420 } 438 break;
421 else 439 case ELF_STUB_MILLI:
422 {
423 stub->insns[0] = 0x20200000; /* ldil 0,%r1 */ 440 stub->insns[0] = 0x20200000; /* ldil 0,%r1 */
424 stub->insns[1] = 0x34210000; /* ldo 0(%r1), %r1 */ 441 stub->insns[1] = 0x34210000; /* ldo 0(%r1), %r1 */
425 stub->insns[2] = 0x50210020; /* ldd 10(%r1),%r1 */ 442 stub->insns[2] = 0x50210020; /* ldd 10(%r1),%r1 */
@@ -427,7 +444,17 @@ static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
427 444
428 stub->insns[0] |= reassemble_21(lrsel(value, addend)); 445 stub->insns[0] |= reassemble_21(lrsel(value, addend));
429 stub->insns[1] |= reassemble_14(rrsel(value, addend)); 446 stub->insns[1] |= reassemble_14(rrsel(value, addend));
447 break;
448 case ELF_STUB_DIRECT:
449 stub->insns[0] = 0x20200000; /* ldil 0,%r1 */
450 stub->insns[1] = 0x34210000; /* ldo 0(%r1), %r1 */
451 stub->insns[2] = 0xe820d002; /* bve,n (%r1) */
452
453 stub->insns[0] |= reassemble_21(lrsel(value, addend));
454 stub->insns[1] |= reassemble_14(rrsel(value, addend));
455 break;
430 } 456 }
457
431#endif 458#endif
432 459
433 return (Elf_Addr)stub; 460 return (Elf_Addr)stub;
@@ -539,14 +566,14 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
539 break; 566 break;
540 case R_PARISC_PCREL17F: 567 case R_PARISC_PCREL17F:
541 /* 17-bit PC relative address */ 568 /* 17-bit PC relative address */
542 val = get_stub(me, val, addend, 0, is_init(me, loc)); 569 val = get_stub(me, val, addend, ELF_STUB_GOT, is_init(me, loc));
543 val = (val - dot - 8)/4; 570 val = (val - dot - 8)/4;
544 CHECK_RELOC(val, 17) 571 CHECK_RELOC(val, 17)
545 *loc = (*loc & ~0x1f1ffd) | reassemble_17(val); 572 *loc = (*loc & ~0x1f1ffd) | reassemble_17(val);
546 break; 573 break;
547 case R_PARISC_PCREL22F: 574 case R_PARISC_PCREL22F:
548 /* 22-bit PC relative address; only defined for pa20 */ 575 /* 22-bit PC relative address; only defined for pa20 */
549 val = get_stub(me, val, addend, 0, is_init(me, loc)); 576 val = get_stub(me, val, addend, ELF_STUB_GOT, is_init(me, loc));
550 DEBUGP("STUB FOR %s loc %lx+%lx at %lx\n", 577 DEBUGP("STUB FOR %s loc %lx+%lx at %lx\n",
551 strtab + sym->st_name, (unsigned long)loc, addend, 578 strtab + sym->st_name, (unsigned long)loc, addend,
552 val) 579 val)
@@ -643,13 +670,23 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
643 strtab + sym->st_name, 670 strtab + sym->st_name,
644 loc, val); 671 loc, val);
645 /* can we reach it locally? */ 672 /* can we reach it locally? */
646 if(!is_local(me, (void *)val)) { 673 if(!is_local_section(me, (void *)val, (void *)dot)) {
647 if (strncmp(strtab + sym->st_name, "$$", 2) 674
675 if (is_local(me, (void *)val))
676 /* this is the case where the
677 * symbol is local to the
678 * module, but in a different
679 * section, so stub the jump
680 * in case it's more than 22
681 * bits away */
682 val = get_stub(me, val, addend, ELF_STUB_DIRECT,
683 is_init(me, loc));
684 else if (strncmp(strtab + sym->st_name, "$$", 2)
648 == 0) 685 == 0)
649 val = get_stub(me, val, addend, 1, 686 val = get_stub(me, val, addend, ELF_STUB_MILLI,
650 is_init(me, loc)); 687 is_init(me, loc));
651 else 688 else
652 val = get_stub(me, val, addend, 0, 689 val = get_stub(me, val, addend, ELF_STUB_GOT,
653 is_init(me, loc)); 690 is_init(me, loc));
654 } 691 }
655 DEBUGP("STUB FOR %s loc %lx, val %lx+%lx at %lx\n", 692 DEBUGP("STUB FOR %s loc %lx, val %lx+%lx at %lx\n",
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index 79c7db2705fd..7d6967ee367c 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -289,7 +289,7 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
289 * than res->start. 289 * than res->start.
290 */ 290 */
291void pcibios_align_resource(void *data, struct resource *res, 291void pcibios_align_resource(void *data, struct resource *res,
292 unsigned long size, unsigned long alignment) 292 resource_size_t size, resource_size_t alignment)
293{ 293{
294 unsigned long mask, align; 294 unsigned long mask, align;
295 295
diff --git a/arch/parisc/kernel/pdc_chassis.c b/arch/parisc/kernel/pdc_chassis.c
index a45e2e2ffd9f..d47ba1aa8253 100644
--- a/arch/parisc/kernel/pdc_chassis.c
+++ b/arch/parisc/kernel/pdc_chassis.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * interfaces to log Chassis Codes via PDC (firmware) 2 * interfaces to Chassis Codes via PDC (firmware)
3 * 3 *
4 * Copyright (C) 2002 Laurent Canet <canetl@esiee.fr> 4 * Copyright (C) 2002 Laurent Canet <canetl@esiee.fr>
5 * Copyright (C) 2002-2004 Thibaut VARENE <varenet@parisc-linux.org> 5 * Copyright (C) 2002-2006 Thibaut VARENE <varenet@parisc-linux.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of the GNU General Public License, version 2, as
@@ -16,6 +16,10 @@
16 * You should have received a copy of the GNU General Public License 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 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 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * TODO: poll chassis warns, trigger (configurable) machine shutdown when
21 * needed.
22 * Find out how to get Chassis warnings out of PAT boxes?
19 */ 23 */
20 24
21#undef PDC_CHASSIS_DEBUG 25#undef PDC_CHASSIS_DEBUG
@@ -30,15 +34,16 @@
30#include <linux/reboot.h> 34#include <linux/reboot.h>
31#include <linux/notifier.h> 35#include <linux/notifier.h>
32#include <linux/cache.h> 36#include <linux/cache.h>
37#include <linux/proc_fs.h>
33 38
34#include <asm/pdc_chassis.h> 39#include <asm/pdc_chassis.h>
35#include <asm/processor.h> 40#include <asm/processor.h>
36#include <asm/pdc.h> 41#include <asm/pdc.h>
37#include <asm/pdcpat.h> 42#include <asm/pdcpat.h>
38 43
44#define PDC_CHASSIS_VER "0.05"
39 45
40#ifdef CONFIG_PDC_CHASSIS 46#ifdef CONFIG_PDC_CHASSIS
41static int pdc_chassis_old __read_mostly = 0;
42static unsigned int pdc_chassis_enabled __read_mostly = 1; 47static unsigned int pdc_chassis_enabled __read_mostly = 1;
43 48
44 49
@@ -64,7 +69,7 @@ __setup("pdcchassis=", pdc_chassis_setup);
64 * Currently, only E class and A180 are known to work with this. 69 * Currently, only E class and A180 are known to work with this.
65 * Inspired by Christoph Plattner 70 * Inspired by Christoph Plattner
66 */ 71 */
67 72#if 0
68static void __init pdc_chassis_checkold(void) 73static void __init pdc_chassis_checkold(void)
69{ 74{
70 switch(CPU_HVERSION) { 75 switch(CPU_HVERSION) {
@@ -73,7 +78,6 @@ static void __init pdc_chassis_checkold(void)
73 case 0x482: /* E45 */ 78 case 0x482: /* E45 */
74 case 0x483: /* E55 */ 79 case 0x483: /* E55 */
75 case 0x516: /* A180 */ 80 case 0x516: /* A180 */
76 pdc_chassis_old = 1;
77 break; 81 break;
78 82
79 default: 83 default:
@@ -81,7 +85,7 @@ static void __init pdc_chassis_checkold(void)
81 } 85 }
82 DPRINTK(KERN_DEBUG "%s: pdc_chassis_checkold(); pdc_chassis_old = %d\n", __FILE__, pdc_chassis_old); 86 DPRINTK(KERN_DEBUG "%s: pdc_chassis_checkold(); pdc_chassis_old = %d\n", __FILE__, pdc_chassis_old);
83} 87}
84 88#endif
85 89
86/** 90/**
87 * pdc_chassis_panic_event() - Called by the panic handler. 91 * pdc_chassis_panic_event() - Called by the panic handler.
@@ -131,30 +135,20 @@ static struct notifier_block pdc_chassis_reboot_block = {
131void __init parisc_pdc_chassis_init(void) 135void __init parisc_pdc_chassis_init(void)
132{ 136{
133#ifdef CONFIG_PDC_CHASSIS 137#ifdef CONFIG_PDC_CHASSIS
134 int handle = 0;
135 if (likely(pdc_chassis_enabled)) { 138 if (likely(pdc_chassis_enabled)) {
136 DPRINTK(KERN_DEBUG "%s: parisc_pdc_chassis_init()\n", __FILE__); 139 DPRINTK(KERN_DEBUG "%s: parisc_pdc_chassis_init()\n", __FILE__);
137 140
138 /* Let see if we have something to handle... */ 141 /* Let see if we have something to handle... */
139 /* Check for PDC_PAT or old LED Panel */ 142 printk(KERN_INFO "Enabling %s chassis codes support v%s\n",
140 pdc_chassis_checkold(); 143 is_pdc_pat() ? "PDC_PAT" : "regular",
141 if (is_pdc_pat()) { 144 PDC_CHASSIS_VER);
142 printk(KERN_INFO "Enabling PDC_PAT chassis codes support.\n"); 145
143 handle = 1; 146 /* initialize panic notifier chain */
144 } 147 atomic_notifier_chain_register(&panic_notifier_list,
145 else if (unlikely(pdc_chassis_old)) { 148 &pdc_chassis_panic_block);
146 printk(KERN_INFO "Enabling old style chassis LED panel support.\n"); 149
147 handle = 1; 150 /* initialize reboot notifier chain */
148 } 151 register_reboot_notifier(&pdc_chassis_reboot_block);
149
150 if (handle) {
151 /* initialize panic notifier chain */
152 atomic_notifier_chain_register(&panic_notifier_list,
153 &pdc_chassis_panic_block);
154
155 /* initialize reboot notifier chain */
156 register_reboot_notifier(&pdc_chassis_reboot_block);
157 }
158 } 152 }
159#endif /* CONFIG_PDC_CHASSIS */ 153#endif /* CONFIG_PDC_CHASSIS */
160} 154}
@@ -215,9 +209,12 @@ int pdc_chassis_send_status(int message)
215 } 209 }
216 } else retval = -1; 210 } else retval = -1;
217#else 211#else
218 if (unlikely(pdc_chassis_old)) { 212 if (1) {
219 switch (message) { 213 switch (message) {
220 case PDC_CHASSIS_DIRECT_BSTART: 214 case PDC_CHASSIS_DIRECT_BSTART:
215 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_INIT));
216 break;
217
221 case PDC_CHASSIS_DIRECT_BCOMPLETE: 218 case PDC_CHASSIS_DIRECT_BCOMPLETE:
222 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_RUN)); 219 retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_RUN));
223 break; 220 break;
@@ -244,3 +241,61 @@ int pdc_chassis_send_status(int message)
244#endif /* CONFIG_PDC_CHASSIS */ 241#endif /* CONFIG_PDC_CHASSIS */
245 return retval; 242 return retval;
246} 243}
244
245#ifdef CONFIG_PDC_CHASSIS_WARN
246#ifdef CONFIG_PROC_FS
247static int pdc_chassis_warn_pread(char *page, char **start, off_t off,
248 int count, int *eof, void *data)
249{
250 char *out = page;
251 int len, ret;
252 unsigned long warn;
253 u32 warnreg;
254
255 ret = pdc_chassis_warn(&warn);
256 if (ret != PDC_OK)
257 return -EIO;
258
259 warnreg = (warn & 0xFFFFFFFF);
260
261 if ((warnreg >> 24) & 0xFF)
262 out += sprintf(out, "Chassis component failure! (eg fan or PSU): 0x%.2x\n", ((warnreg >> 24) & 0xFF));
263
264 out += sprintf(out, "Battery: %s\n", (warnreg & 0x04) ? "Low!" : "OK");
265 out += sprintf(out, "Temp low: %s\n", (warnreg & 0x02) ? "Exceeded!" : "OK");
266 out += sprintf(out, "Temp mid: %s\n", (warnreg & 0x01) ? "Exceeded!" : "OK");
267
268 len = out - page - off;
269 if (len < count) {
270 *eof = 1;
271 if (len <= 0) return 0;
272 } else {
273 len = count;
274 }
275 *start = page + off;
276 return len;
277}
278
279static int __init pdc_chassis_create_procfs(void)
280{
281 unsigned long test;
282 int ret;
283
284 ret = pdc_chassis_warn(&test);
285 if ((ret == PDC_BAD_PROC) || (ret == PDC_BAD_OPTION)) {
286 /* seems that some boxes (eg L1000) do not implement this */
287 printk(KERN_INFO "Chassis warnings not supported.\n");
288 return 0;
289 }
290
291 printk(KERN_INFO "Enabling PDC chassis warnings support v%s\n",
292 PDC_CHASSIS_VER);
293 create_proc_read_entry("chassis", 0400, NULL, pdc_chassis_warn_pread,
294 NULL);
295 return 0;
296}
297
298__initcall(pdc_chassis_create_procfs);
299
300#endif /* CONFIG_PROC_FS */
301#endif /* CONFIG_PDC_CHASSIS_WARN */
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 413292f1a4a3..3f28de974556 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -91,7 +91,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
91 int copied; 91 int copied;
92 92
93#ifdef __LP64__ 93#ifdef __LP64__
94 if (personality(child->personality) == PER_LINUX32) { 94 if (__is_compat_task(child)) {
95 unsigned int tmp; 95 unsigned int tmp;
96 96
97 addr &= 0xffffffffL; 97 addr &= 0xffffffffL;
@@ -123,7 +123,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
123 case PTRACE_POKEDATA: 123 case PTRACE_POKEDATA:
124 ret = 0; 124 ret = 0;
125#ifdef __LP64__ 125#ifdef __LP64__
126 if (personality(child->personality) == PER_LINUX32) { 126 if (__is_compat_task(child)) {
127 unsigned int tmp = (unsigned int)data; 127 unsigned int tmp = (unsigned int)data;
128 DBG("sys_ptrace(POKE%s, %d, %lx, %lx)\n", 128 DBG("sys_ptrace(POKE%s, %d, %lx, %lx)\n",
129 request == PTRACE_POKETEXT ? "TEXT" : "DATA", 129 request == PTRACE_POKETEXT ? "TEXT" : "DATA",
@@ -146,7 +146,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
146 case PTRACE_PEEKUSR: { 146 case PTRACE_PEEKUSR: {
147 ret = -EIO; 147 ret = -EIO;
148#ifdef __LP64__ 148#ifdef __LP64__
149 if (personality(child->personality) == PER_LINUX32) { 149 if (__is_compat_task(child)) {
150 unsigned int tmp; 150 unsigned int tmp;
151 151
152 if (addr & (sizeof(int)-1)) 152 if (addr & (sizeof(int)-1))
@@ -205,7 +205,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
205 goto out_tsk; 205 goto out_tsk;
206 } 206 }
207#ifdef __LP64__ 207#ifdef __LP64__
208 if (personality(child->personality) == PER_LINUX32) { 208 if (__is_compat_task(child)) {
209 if (addr & (sizeof(int)-1)) 209 if (addr & (sizeof(int)-1))
210 goto out_tsk; 210 goto out_tsk;
211 if ((addr = translate_usr_offset(addr)) < 0) 211 if ((addr = translate_usr_offset(addr)) < 0)
diff --git a/arch/parisc/kernel/real2.S b/arch/parisc/kernel/real2.S
index 8c2859cca77e..453d01a9f971 100644
--- a/arch/parisc/kernel/real2.S
+++ b/arch/parisc/kernel/real2.S
@@ -276,15 +276,6 @@ r64_ret:
276 276
277#endif 277#endif
278 278
279 .export pc_in_user_space
280 .text
281 /* Doesn't belong here but I couldn't find a nicer spot. */
282 /* Should never get called, only used by profile stuff in time.c */
283pc_in_user_space:
284 bv,n 0(%rp)
285 nop
286
287
288 .export __canonicalize_funcptr_for_compare 279 .export __canonicalize_funcptr_for_compare
289 .text 280 .text
290 /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html 281 /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 4a36ec3f6ac1..278f4b9f6a38 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -303,6 +303,8 @@ extern void eisa_init(void);
303 303
304static int __init parisc_init(void) 304static int __init parisc_init(void)
305{ 305{
306 u32 osid = (OS_ID_LINUX << 16);
307
306 parisc_proc_mkdir(); 308 parisc_proc_mkdir();
307 parisc_init_resources(); 309 parisc_init_resources();
308 do_device_inventory(); /* probe for hardware */ 310 do_device_inventory(); /* probe for hardware */
@@ -311,6 +313,9 @@ static int __init parisc_init(void)
311 313
312 /* set up a new led state on systems shipped LED State panel */ 314 /* set up a new led state on systems shipped LED State panel */
313 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART); 315 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
316
317 /* tell PDC we're Linux. Nevermind failure. */
318 pdc_stable_write(0x40, &osid, sizeof(osid));
314 319
315 processor_init(); 320 processor_init();
316 printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n", 321 printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n",
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index cc38edfd90c5..bb83880c5ee3 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -76,7 +76,7 @@ sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize, struct pt_regs *r
76#ifdef __LP64__ 76#ifdef __LP64__
77 compat_sigset_t newset32; 77 compat_sigset_t newset32;
78 78
79 if(personality(current->personality) == PER_LINUX32){ 79 if (is_compat_task()) {
80 /* XXX: Don't preclude handling different sized sigset_t's. */ 80 /* XXX: Don't preclude handling different sized sigset_t's. */
81 if (sigsetsize != sizeof(compat_sigset_t)) 81 if (sigsetsize != sizeof(compat_sigset_t))
82 return -EINVAL; 82 return -EINVAL;
@@ -153,7 +153,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
153 compat_sigset_t compat_set; 153 compat_sigset_t compat_set;
154 struct compat_rt_sigframe __user * compat_frame; 154 struct compat_rt_sigframe __user * compat_frame;
155 155
156 if(personality(current->personality) == PER_LINUX32) 156 if (is_compat_task())
157 sigframe_size = PARISC_RT_SIGFRAME_SIZE32; 157 sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
158#endif 158#endif
159 159
@@ -166,7 +166,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
166#ifdef __LP64__ 166#ifdef __LP64__
167 compat_frame = (struct compat_rt_sigframe __user *)frame; 167 compat_frame = (struct compat_rt_sigframe __user *)frame;
168 168
169 if(personality(current->personality) == PER_LINUX32){ 169 if (is_compat_task()) {
170 DBG(2,"sys_rt_sigreturn: ELF32 process.\n"); 170 DBG(2,"sys_rt_sigreturn: ELF32 process.\n");
171 if (__copy_from_user(&compat_set, &compat_frame->uc.uc_sigmask, sizeof(compat_set))) 171 if (__copy_from_user(&compat_set, &compat_frame->uc.uc_sigmask, sizeof(compat_set)))
172 goto give_sigsegv; 172 goto give_sigsegv;
@@ -186,7 +186,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
186 186
187 /* Good thing we saved the old gr[30], eh? */ 187 /* Good thing we saved the old gr[30], eh? */
188#ifdef __LP64__ 188#ifdef __LP64__
189 if(personality(current->personality) == PER_LINUX32){ 189 if (is_compat_task()) {
190 DBG(1,"sys_rt_sigreturn: compat_frame->uc.uc_mcontext 0x%p\n", 190 DBG(1,"sys_rt_sigreturn: compat_frame->uc.uc_mcontext 0x%p\n",
191 &compat_frame->uc.uc_mcontext); 191 &compat_frame->uc.uc_mcontext);
192// FIXME: Load upper half from register file 192// FIXME: Load upper half from register file
@@ -315,7 +315,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
315 315
316 compat_frame = (struct compat_rt_sigframe __user *)frame; 316 compat_frame = (struct compat_rt_sigframe __user *)frame;
317 317
318 if(personality(current->personality) == PER_LINUX32) { 318 if (is_compat_task()) {
319 DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); 319 DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info);
320 err |= copy_siginfo_to_user32(&compat_frame->info, info); 320 err |= copy_siginfo_to_user32(&compat_frame->info, info);
321 DBG(1,"SETUP_RT_FRAME: 1\n"); 321 DBG(1,"SETUP_RT_FRAME: 1\n");
@@ -392,7 +392,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
392 haddr = A(ka->sa.sa_handler); 392 haddr = A(ka->sa.sa_handler);
393 /* The sa_handler may be a pointer to a function descriptor */ 393 /* The sa_handler may be a pointer to a function descriptor */
394#ifdef __LP64__ 394#ifdef __LP64__
395 if(personality(current->personality) == PER_LINUX32) { 395 if (is_compat_task()) {
396#endif 396#endif
397 if (haddr & PA_PLABEL_FDESC) { 397 if (haddr & PA_PLABEL_FDESC) {
398 Elf32_Fdesc fdesc; 398 Elf32_Fdesc fdesc;
@@ -427,19 +427,19 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
427 */ 427 */
428 sigframe_size = PARISC_RT_SIGFRAME_SIZE; 428 sigframe_size = PARISC_RT_SIGFRAME_SIZE;
429#ifdef __LP64__ 429#ifdef __LP64__
430 if(personality(current->personality) == PER_LINUX32) 430 if (is_compat_task())
431 sigframe_size = PARISC_RT_SIGFRAME_SIZE32; 431 sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
432#endif 432#endif
433 if (in_syscall) { 433 if (in_syscall) {
434 regs->gr[31] = haddr; 434 regs->gr[31] = haddr;
435#ifdef __LP64__ 435#ifdef __LP64__
436 if(personality(current->personality) == PER_LINUX) 436 if (personality(current->personality) == PER_LINUX)
437 sigframe_size |= 1; 437 sigframe_size |= 1;
438#endif 438#endif
439 } else { 439 } else {
440 unsigned long psw = USER_PSW; 440 unsigned long psw = USER_PSW;
441#ifdef __LP64__ 441#ifdef __LP64__
442 if(personality(current->personality) == PER_LINUX) 442 if (personality(current->personality) == PER_LINUX)
443 psw |= PSW_W; 443 psw |= PSW_W;
444#endif 444#endif
445 445
@@ -464,7 +464,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
464 regs->gr[26] = sig; /* signal number */ 464 regs->gr[26] = sig; /* signal number */
465 465
466#ifdef __LP64__ 466#ifdef __LP64__
467 if(personality(current->personality) == PER_LINUX32){ 467 if (is_compat_task()) {
468 regs->gr[25] = A(&compat_frame->info); /* siginfo pointer */ 468 regs->gr[25] = A(&compat_frame->info); /* siginfo pointer */
469 regs->gr[24] = A(&compat_frame->uc); /* ucontext pointer */ 469 regs->gr[24] = A(&compat_frame->uc); /* ucontext pointer */
470 } else 470 } else
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index 479d9a017cd1..9670a89c77fe 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -29,18 +29,6 @@
29 .level 1.1 29 .level 1.1
30#endif 30#endif
31 31
32#ifndef CONFIG_64BIT
33 .macro fixup_branch,lbl
34 b \lbl
35 .endm
36#else
37 .macro fixup_branch,lbl
38 ldil L%\lbl, %r1
39 ldo R%\lbl(%r1), %r1
40 bv,n %r0(%r1)
41 .endm
42#endif
43
44 .text 32 .text
45 33
46 .import syscall_exit,code 34 .import syscall_exit,code
@@ -541,7 +529,7 @@ cas_nocontend:
541# endif 529# endif
542/* ENABLE_LWS_DEBUG */ 530/* ENABLE_LWS_DEBUG */
543 531
544 ldcw 0(%sr2,%r20), %r28 /* Try to acquire the lock */ 532 LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
545 cmpb,<>,n %r0, %r28, cas_action /* Did we get it? */ 533 cmpb,<>,n %r0, %r28, cas_action /* Did we get it? */
546cas_wouldblock: 534cas_wouldblock:
547 ldo 2(%r0), %r28 /* 2nd case */ 535 ldo 2(%r0), %r28 /* 2nd case */
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 594930bc4bcf..eb35e1c0bb53 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -157,8 +157,22 @@ do_gettimeofday (struct timeval *tv)
157 usec += (xtime.tv_nsec / 1000); 157 usec += (xtime.tv_nsec / 1000);
158 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); 158 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
159 159
160 while (usec >= 1000000) { 160 if (unlikely(usec > LONG_MAX)) {
161 usec -= 1000000; 161 /* This can happen if the gettimeoffset adjustment is
162 * negative and xtime.tv_nsec is smaller than the
163 * adjustment */
164 printk(KERN_ERR "do_gettimeofday() spurious xtime.tv_nsec of %ld\n", usec);
165 usec += USEC_PER_SEC;
166 --sec;
167 /* This should never happen, it means the negative
168 * time adjustment was more than a second, so there's
169 * something seriously wrong */
170 BUG_ON(usec > LONG_MAX);
171 }
172
173
174 while (usec >= USEC_PER_SEC) {
175 usec -= USEC_PER_SEC;
162 ++sec; 176 ++sec;
163 } 177 }
164 178
diff --git a/arch/parisc/kernel/topology.c b/arch/parisc/kernel/topology.c
index 3ba040050e4c..068b20d822e7 100644
--- a/arch/parisc/kernel/topology.c
+++ b/arch/parisc/kernel/topology.c
@@ -26,11 +26,10 @@ static struct cpu cpu_devices[NR_CPUS] __read_mostly;
26 26
27static int __init topology_init(void) 27static int __init topology_init(void)
28{ 28{
29 struct node *parent = NULL;
30 int num; 29 int num;
31 30
32 for_each_present_cpu(num) { 31 for_each_present_cpu(num) {
33 register_cpu(&cpu_devices[num], num, parent); 32 register_cpu(&cpu_devices[num], num);
34 } 33 }
35 return 0; 34 return 0;
36} 35}
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index ff200608c851..348344a84bf7 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -66,57 +66,42 @@ int printbinary(char *buf, unsigned long x, int nbits)
66#else 66#else
67#define RFMT "%08lx" 67#define RFMT "%08lx"
68#endif 68#endif
69#define FFMT "%016llx" /* fpregs are 64-bit always */
69 70
70void show_regs(struct pt_regs *regs) 71#define PRINTREGS(lvl,r,f,fmt,x) \
72 printk("%s%s%02d-%02d " fmt " " fmt " " fmt " " fmt "\n", \
73 lvl, f, (x), (x+3), (r)[(x)+0], (r)[(x)+1], \
74 (r)[(x)+2], (r)[(x)+3])
75
76static void print_gr(char *level, struct pt_regs *regs)
71{ 77{
72 int i; 78 int i;
73 char buf[128], *p; 79 char buf[64];
74 char *level;
75 unsigned long cr30;
76 unsigned long cr31;
77 /* carlos says that gcc understands better memory in a struct,
78 * and it makes our life easier with fpregs -- T-Bone */
79 struct { u32 sw[2]; } s;
80
81 level = user_mode(regs) ? KERN_DEBUG : KERN_CRIT;
82
83 printk("%s\n", level); /* don't want to have that pretty register dump messed up */
84 80
81 printk("%s\n", level);
85 printk("%s YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI\n", level); 82 printk("%s YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI\n", level);
86 printbinary(buf, regs->gr[0], 32); 83 printbinary(buf, regs->gr[0], 32);
87 printk("%sPSW: %s %s\n", level, buf, print_tainted()); 84 printk("%sPSW: %s %s\n", level, buf, print_tainted());
88 85
89 for (i = 0; i < 32; i += 4) { 86 for (i = 0; i < 32; i += 4)
90 int j; 87 PRINTREGS(level, regs->gr, "r", RFMT, i);
91 p = buf; 88}
92 p += sprintf(p, "%sr%02d-%02d ", level, i, i + 3);
93 for (j = 0; j < 4; j++) {
94 p += sprintf(p, " " RFMT, (i+j) == 0 ? 0 : regs->gr[i + j]);
95 }
96 printk("%s\n", buf);
97 }
98 89
99 for (i = 0; i < 8; i += 4) { 90static void print_fr(char *level, struct pt_regs *regs)
100 int j; 91{
101 p = buf; 92 int i;
102 p += sprintf(p, "%ssr%d-%d ", level, i, i + 3); 93 char buf[64];
103 for (j = 0; j < 4; j++) { 94 struct { u32 sw[2]; } s;
104 p += sprintf(p, " " RFMT, regs->sr[i + j]);
105 }
106 printk("%s\n", buf);
107 }
108 95
109 /* FR are 64bit everywhere. Need to use asm to get the content 96 /* FR are 64bit everywhere. Need to use asm to get the content
110 * of fpsr/fper1, and we assume that we won't have a FP Identify 97 * of fpsr/fper1, and we assume that we won't have a FP Identify
111 * in our way, otherwise we're screwed. 98 * in our way, otherwise we're screwed.
112 * The fldd is used to restore the T-bit if there was one, as the 99 * The fldd is used to restore the T-bit if there was one, as the
113 * store clears it anyway. 100 * store clears it anyway.
114 * BTW, PA2.0 book says "thou shall not use fstw on FPSR/FPERs". */ 101 * PA2.0 book says "thou shall not use fstw on FPSR/FPERs" - T-Bone */
115 __asm__ ( 102 asm volatile ("fstd %%fr0,0(%1) \n\t"
116 "fstd %%fr0,0(%1) \n\t" 103 "fldd 0(%1),%%fr0 \n\t"
117 "fldd 0(%1),%%fr0 \n\t" 104 : "=m" (s) : "r" (&s) : "r0");
118 : "=m" (s) : "r" (&s) : "%r0"
119 );
120 105
121 printk("%s\n", level); 106 printk("%s\n", level);
122 printk("%s VZOUICununcqcqcqcqcqcrmunTDVZOUI\n", level); 107 printk("%s VZOUICununcqcqcqcqcqcrmunTDVZOUI\n", level);
@@ -125,14 +110,25 @@ void show_regs(struct pt_regs *regs)
125 printk("%sFPER1: %08x\n", level, s.sw[1]); 110 printk("%sFPER1: %08x\n", level, s.sw[1]);
126 111
127 /* here we'll print fr0 again, tho it'll be meaningless */ 112 /* here we'll print fr0 again, tho it'll be meaningless */
128 for (i = 0; i < 32; i += 4) { 113 for (i = 0; i < 32; i += 4)
129 int j; 114 PRINTREGS(level, regs->fr, "fr", FFMT, i);
130 p = buf; 115}
131 p += sprintf(p, "%sfr%02d-%02d ", level, i, i + 3); 116
132 for (j = 0; j < 4; j++) 117void show_regs(struct pt_regs *regs)
133 p += sprintf(p, " %016llx", (i+j) == 0 ? 0 : regs->fr[i+j]); 118{
134 printk("%s\n", buf); 119 int i;
135 } 120 char *level;
121 unsigned long cr30, cr31;
122
123 level = user_mode(regs) ? KERN_DEBUG : KERN_CRIT;
124
125 print_gr(level, regs);
126
127 for (i = 0; i < 8; i += 4)
128 PRINTREGS(level, regs->sr, "sr", RFMT, i);
129
130 if (user_mode(regs))
131 print_fr(level, regs);
136 132
137 cr30 = mfctl(30); 133 cr30 = mfctl(30);
138 cr31 = mfctl(31); 134 cr31 = mfctl(31);
diff --git a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c
index de0a1b21cb40..92328fbddb3e 100644
--- a/arch/parisc/kernel/unaligned.c
+++ b/arch/parisc/kernel/unaligned.c
@@ -43,6 +43,8 @@
43 "\tldil L%%" #lbl ", %%r1\n" \ 43 "\tldil L%%" #lbl ", %%r1\n" \
44 "\tldo R%%" #lbl "(%%r1), %%r1\n" \ 44 "\tldo R%%" #lbl "(%%r1), %%r1\n" \
45 "\tbv,n %%r0(%%r1)\n" 45 "\tbv,n %%r0(%%r1)\n"
46/* If you use FIXUP_BRANCH, then you must list this clobber */
47#define FIXUP_BRANCH_CLOBBER "r1"
46 48
47/* 1111 1100 0000 0000 0001 0011 1100 0000 */ 49/* 1111 1100 0000 0000 0001 0011 1100 0000 */
48#define OPCODE1(a,b,c) ((a)<<26|(b)<<12|(c)<<6) 50#define OPCODE1(a,b,c) ((a)<<26|(b)<<12|(c)<<6)
@@ -157,7 +159,7 @@ static int emulate_ldh(struct pt_regs *regs, int toreg)
157" .previous\n" 159" .previous\n"
158 : "=r" (val), "=r" (ret) 160 : "=r" (val), "=r" (ret)
159 : "0" (val), "r" (saddr), "r" (regs->isr) 161 : "0" (val), "r" (saddr), "r" (regs->isr)
160 : "r20" ); 162 : "r20", FIXUP_BRANCH_CLOBBER );
161 163
162 DPRINTF("val = 0x" RFMT "\n", val); 164 DPRINTF("val = 0x" RFMT "\n", val);
163 165
@@ -202,7 +204,7 @@ static int emulate_ldw(struct pt_regs *regs, int toreg, int flop)
202" .previous\n" 204" .previous\n"
203 : "=r" (val), "=r" (ret) 205 : "=r" (val), "=r" (ret)
204 : "0" (val), "r" (saddr), "r" (regs->isr) 206 : "0" (val), "r" (saddr), "r" (regs->isr)
205 : "r19", "r20" ); 207 : "r19", "r20", FIXUP_BRANCH_CLOBBER );
206 208
207 DPRINTF("val = 0x" RFMT "\n", val); 209 DPRINTF("val = 0x" RFMT "\n", val);
208 210
@@ -253,7 +255,7 @@ static int emulate_ldd(struct pt_regs *regs, int toreg, int flop)
253" .previous\n" 255" .previous\n"
254 : "=r" (val), "=r" (ret) 256 : "=r" (val), "=r" (ret)
255 : "0" (val), "r" (saddr), "r" (regs->isr) 257 : "0" (val), "r" (saddr), "r" (regs->isr)
256 : "r19", "r20" ); 258 : "r19", "r20", FIXUP_BRANCH_CLOBBER );
257#else 259#else
258 { 260 {
259 unsigned long valh=0,vall=0; 261 unsigned long valh=0,vall=0;
@@ -287,7 +289,7 @@ static int emulate_ldd(struct pt_regs *regs, int toreg, int flop)
287" .previous\n" 289" .previous\n"
288 : "=r" (valh), "=r" (vall), "=r" (ret) 290 : "=r" (valh), "=r" (vall), "=r" (ret)
289 : "0" (valh), "1" (vall), "r" (saddr), "r" (regs->isr) 291 : "0" (valh), "1" (vall), "r" (saddr), "r" (regs->isr)
290 : "r19", "r20" ); 292 : "r19", "r20", FIXUP_BRANCH_CLOBBER );
291 val=((__u64)valh<<32)|(__u64)vall; 293 val=((__u64)valh<<32)|(__u64)vall;
292 } 294 }
293#endif 295#endif
@@ -335,7 +337,7 @@ static int emulate_sth(struct pt_regs *regs, int frreg)
335" .previous\n" 337" .previous\n"
336 : "=r" (ret) 338 : "=r" (ret)
337 : "r" (val), "r" (regs->ior), "r" (regs->isr) 339 : "r" (val), "r" (regs->ior), "r" (regs->isr)
338 : "r19" ); 340 : "r19", FIXUP_BRANCH_CLOBBER );
339 341
340 return ret; 342 return ret;
341} 343}
@@ -389,7 +391,7 @@ static int emulate_stw(struct pt_regs *regs, int frreg, int flop)
389" .previous\n" 391" .previous\n"
390 : "=r" (ret) 392 : "=r" (ret)
391 : "r" (val), "r" (regs->ior), "r" (regs->isr) 393 : "r" (val), "r" (regs->ior), "r" (regs->isr)
392 : "r19", "r20", "r21", "r22", "r1" ); 394 : "r19", "r20", "r21", "r22", "r1", FIXUP_BRANCH_CLOBBER );
393 395
394 return 0; 396 return 0;
395} 397}
@@ -450,7 +452,7 @@ static int emulate_std(struct pt_regs *regs, int frreg, int flop)
450" .previous\n" 452" .previous\n"
451 : "=r" (ret) 453 : "=r" (ret)
452 : "r" (val), "r" (regs->ior), "r" (regs->isr) 454 : "r" (val), "r" (regs->ior), "r" (regs->isr)
453 : "r19", "r20", "r21", "r22", "r1" ); 455 : "r19", "r20", "r21", "r22", "r1", FIXUP_BRANCH_CLOBBER );
454#else 456#else
455 { 457 {
456 unsigned long valh=(val>>32),vall=(val&0xffffffffl); 458 unsigned long valh=(val>>32),vall=(val&0xffffffffl);
@@ -495,7 +497,7 @@ static int emulate_std(struct pt_regs *regs, int frreg, int flop)
495" .previous\n" 497" .previous\n"
496 : "=r" (ret) 498 : "=r" (ret)
497 : "r" (valh), "r" (vall), "r" (regs->ior), "r" (regs->isr) 499 : "r" (valh), "r" (vall), "r" (regs->ior), "r" (regs->isr)
498 : "r19", "r20", "r21", "r1" ); 500 : "r19", "r20", "r21", "r1", FIXUP_BRANCH_CLOBBER );
499 } 501 }
500#endif 502#endif
501 503
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e922a88b2bad..2643dbc3f289 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -30,6 +30,10 @@ config GENERIC_HARDIRQS
30 bool 30 bool
31 default y 31 default y
32 32
33config IRQ_PER_CPU
34 bool
35 default y
36
33config RWSEM_GENERIC_SPINLOCK 37config RWSEM_GENERIC_SPINLOCK
34 bool 38 bool
35 39
@@ -336,7 +340,7 @@ config PPC_ISERIES
336 340
337config EMBEDDED6xx 341config EMBEDDED6xx
338 bool "Embedded 6xx/7xx/7xxx-based board" 342 bool "Embedded 6xx/7xx/7xxx-based board"
339 depends on PPC32 && BROKEN 343 depends on PPC32 && (BROKEN||BROKEN_ON_SMP)
340 344
341config APUS 345config APUS
342 bool "Amiga-APUS" 346 bool "Amiga-APUS"
@@ -413,12 +417,17 @@ config PPC_CELL_NATIVE
413 default n 417 default n
414 418
415config PPC_IBM_CELL_BLADE 419config PPC_IBM_CELL_BLADE
416 bool " IBM Cell Blade" 420 bool "IBM Cell Blade"
417 depends on PPC_MULTIPLATFORM && PPC64 421 depends on PPC_MULTIPLATFORM && PPC64
418 select PPC_CELL_NATIVE 422 select PPC_CELL_NATIVE
419 select PPC_RTAS 423 select PPC_RTAS
420 select MMIO_NVRAM 424 select MMIO_NVRAM
421 select PPC_UDBG_16550 425 select PPC_UDBG_16550
426 select UDBG_RTAS_CONSOLE
427
428config UDBG_RTAS_CONSOLE
429 bool
430 default n
422 431
423config XICS 432config XICS
424 depends on PPC_PSERIES 433 depends on PPC_PSERIES
@@ -431,7 +440,8 @@ config U3_DART
431 default n 440 default n
432 441
433config MPIC 442config MPIC
434 depends on PPC_PSERIES || PPC_PMAC || PPC_MAPLE || PPC_CHRP 443 depends on PPC_PSERIES || PPC_PMAC || PPC_MAPLE || PPC_CHRP \
444 || MPC7448HPC2
435 bool 445 bool
436 default y 446 default y
437 447
@@ -557,6 +567,13 @@ config TAU_AVERAGE
557 /proc/cpuinfo. 567 /proc/cpuinfo.
558 568
559 If in doubt, say N here. 569 If in doubt, say N here.
570
571config PPC_TODC
572 depends on EMBEDDED6xx
573 bool "Generic Time-of-day Clock (TODC) support"
574 ---help---
575 This adds support for many TODC/RTC chips.
576
560endmenu 577endmenu
561 578
562source arch/powerpc/platforms/embedded6xx/Kconfig 579source arch/powerpc/platforms/embedded6xx/Kconfig
@@ -618,16 +635,19 @@ config HOTPLUG_CPU
618 635
619 Say N if you are unsure. 636 Say N if you are unsure.
620 637
638config ARCH_ENABLE_MEMORY_HOTPLUG
639 def_bool y
640
621config KEXEC 641config KEXEC
622 bool "kexec system call (EXPERIMENTAL)" 642 bool "kexec system call (EXPERIMENTAL)"
623 depends on PPC_MULTIPLATFORM && EXPERIMENTAL 643 depends on PPC_MULTIPLATFORM && EXPERIMENTAL
624 help 644 help
625 kexec is a system call that implements the ability to shutdown your 645 kexec is a system call that implements the ability to shutdown your
626 current kernel, and to start another kernel. It is like a reboot 646 current kernel, and to start another kernel. It is like a reboot
627 but it is indepedent of the system firmware. And like a reboot 647 but it is independent of the system firmware. And like a reboot
628 you can start any kernel with it, not just Linux. 648 you can start any kernel with it, not just Linux.
629 649
630 The name comes from the similiarity to the exec system call. 650 The name comes from the similarity to the exec system call.
631 651
632 It is an ongoing process to be certain the hardware in a machine 652 It is an ongoing process to be certain the hardware in a machine
633 is properly shutdown, so do not be surprised if this code does not 653 is properly shutdown, so do not be surprised if this code does not
@@ -794,7 +814,6 @@ config GENERIC_ISA_DMA
794 814
795config PPC_I8259 815config PPC_I8259
796 bool 816 bool
797 default y if MPC8641_HPCN
798 default n 817 default n
799 818
800config PPC_INDIRECT_PCI 819config PPC_INDIRECT_PCI
@@ -817,7 +836,8 @@ config MCA
817 bool 836 bool
818 837
819config PCI 838config PCI
820 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) 839 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) \
840 || MPC7448HPC2
821 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !PPC_85xx && !PPC_86xx 841 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !PPC_85xx && !PPC_86xx
822 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS 842 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
823 default PCI_QSPAN if !4xx && !CPM2 && 8xx 843 default PCI_QSPAN if !4xx && !CPM2 && 8xx
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index c69006ae8246..e29ef77d3b00 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -134,12 +134,19 @@ config PPC_EARLY_DEBUG_G5
134 help 134 help
135 Select this to enable early debugging for Apple G5 machines. 135 Select this to enable early debugging for Apple G5 machines.
136 136
137config PPC_EARLY_DEBUG_RTAS 137config PPC_EARLY_DEBUG_RTAS_PANEL
138 bool "RTAS Panel" 138 bool "RTAS Panel"
139 depends on PPC_RTAS 139 depends on PPC_RTAS
140 help 140 help
141 Select this to enable early debugging via the RTAS panel. 141 Select this to enable early debugging via the RTAS panel.
142 142
143config PPC_EARLY_DEBUG_RTAS_CONSOLE
144 bool "RTAS Console"
145 depends on PPC_RTAS
146 select UDBG_RTAS_CONSOLE
147 help
148 Select this to enable early debugging via the RTAS console.
149
143config PPC_EARLY_DEBUG_MAPLE 150config PPC_EARLY_DEBUG_MAPLE
144 bool "Maple real mode" 151 bool "Maple real mode"
145 depends on PPC_MAPLE 152 depends on PPC_MAPLE
diff --git a/arch/powerpc/configs/cell_defconfig b/arch/powerpc/configs/cell_defconfig
index b8b8d4675dc0..e028a2ecb8a3 100644
--- a/arch/powerpc/configs/cell_defconfig
+++ b/arch/powerpc/configs/cell_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.17 3# Linux kernel version: 2.6.17-rc6
4# Mon Jun 19 17:23:03 2006 4# Thu Jun 22 15:28:36 2006
5# 5#
6CONFIG_PPC64=y 6CONFIG_PPC64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -1063,7 +1063,8 @@ CONFIG_DEBUG_FS=y
1063# CONFIG_DEBUG_STACKOVERFLOW is not set 1063# CONFIG_DEBUG_STACKOVERFLOW is not set
1064# CONFIG_DEBUG_STACK_USAGE is not set 1064# CONFIG_DEBUG_STACK_USAGE is not set
1065CONFIG_DEBUGGER=y 1065CONFIG_DEBUGGER=y
1066# CONFIG_XMON is not set 1066CONFIG_XMON=y
1067CONFIG_XMON_DEFAULT=y
1067CONFIG_IRQSTACKS=y 1068CONFIG_IRQSTACKS=y
1068# CONFIG_BOOTX_TEXT is not set 1069# CONFIG_BOOTX_TEXT is not set
1069# CONFIG_PPC_EARLY_DEBUG is not set 1070# CONFIG_PPC_EARLY_DEBUG is not set
diff --git a/arch/powerpc/configs/mpc7448_hpc2_defconfig b/arch/powerpc/configs/mpc7448_hpc2_defconfig
new file mode 100644
index 000000000000..15a50f4ceb1f
--- /dev/null
+++ b/arch/powerpc/configs/mpc7448_hpc2_defconfig
@@ -0,0 +1,923 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17-rc4
4# Sat May 27 18:45:55 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_HWEIGHT=y
13CONFIG_GENERIC_CALIBRATE_DELAY=y
14CONFIG_PPC=y
15CONFIG_EARLY_PRINTK=y
16CONFIG_GENERIC_NVRAM=y
17CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
18CONFIG_ARCH_MAY_HAVE_PC_FDC=y
19CONFIG_PPC_OF=y
20CONFIG_PPC_UDBG_16550=y
21# CONFIG_GENERIC_TBSYNC is not set
22CONFIG_DEFAULT_UIMAGE=y
23
24#
25# Processor support
26#
27CONFIG_CLASSIC32=y
28# CONFIG_PPC_52xx is not set
29# CONFIG_PPC_82xx is not set
30# CONFIG_PPC_83xx is not set
31# CONFIG_PPC_85xx is not set
32# CONFIG_40x is not set
33# CONFIG_44x is not set
34# CONFIG_8xx is not set
35# CONFIG_E200 is not set
36CONFIG_6xx=y
37CONFIG_PPC_FPU=y
38# CONFIG_ALTIVEC is not set
39CONFIG_PPC_STD_MMU=y
40CONFIG_PPC_STD_MMU_32=y
41# CONFIG_SMP is not set
42
43#
44# Code maturity level options
45#
46CONFIG_EXPERIMENTAL=y
47CONFIG_BROKEN_ON_SMP=y
48CONFIG_INIT_ENV_ARG_LIMIT=32
49
50#
51# General setup
52#
53CONFIG_LOCALVERSION=""
54CONFIG_LOCALVERSION_AUTO=y
55CONFIG_SWAP=y
56CONFIG_SYSVIPC=y
57# CONFIG_POSIX_MQUEUE is not set
58# CONFIG_BSD_PROCESS_ACCT is not set
59CONFIG_SYSCTL=y
60# CONFIG_AUDIT is not set
61# CONFIG_IKCONFIG is not set
62# CONFIG_RELAY is not set
63CONFIG_INITRAMFS_SOURCE=""
64# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
65CONFIG_EMBEDDED=y
66CONFIG_KALLSYMS=y
67# CONFIG_KALLSYMS_EXTRA_PASS is not set
68CONFIG_HOTPLUG=y
69CONFIG_PRINTK=y
70CONFIG_BUG=y
71CONFIG_ELF_CORE=y
72CONFIG_BASE_FULL=y
73CONFIG_FUTEX=y
74CONFIG_EPOLL=y
75CONFIG_SHMEM=y
76CONFIG_SLAB=y
77# CONFIG_TINY_SHMEM is not set
78CONFIG_BASE_SMALL=0
79# CONFIG_SLOB is not set
80
81#
82# Loadable module support
83#
84# CONFIG_MODULES is not set
85
86#
87# Block layer
88#
89CONFIG_LBD=y
90# CONFIG_BLK_DEV_IO_TRACE is not set
91# CONFIG_LSF is not set
92
93#
94# IO Schedulers
95#
96CONFIG_IOSCHED_NOOP=y
97CONFIG_IOSCHED_AS=y
98CONFIG_IOSCHED_DEADLINE=y
99CONFIG_IOSCHED_CFQ=y
100CONFIG_DEFAULT_AS=y
101# CONFIG_DEFAULT_DEADLINE is not set
102# CONFIG_DEFAULT_CFQ is not set
103# CONFIG_DEFAULT_NOOP is not set
104CONFIG_DEFAULT_IOSCHED="anticipatory"
105
106#
107# Platform support
108#
109# CONFIG_PPC_MULTIPLATFORM is not set
110# CONFIG_PPC_ISERIES is not set
111CONFIG_EMBEDDED6xx=y
112# CONFIG_APUS is not set
113CONFIG_MPIC=y
114# CONFIG_PPC_RTAS is not set
115# CONFIG_MMIO_NVRAM is not set
116# CONFIG_PPC_MPC106 is not set
117# CONFIG_PPC_970_NAP is not set
118# CONFIG_CPU_FREQ is not set
119# CONFIG_TAU is not set
120# CONFIG_KATANA is not set
121# CONFIG_WILLOW is not set
122# CONFIG_CPCI690 is not set
123# CONFIG_POWERPMC250 is not set
124# CONFIG_CHESTNUT is not set
125# CONFIG_SPRUCE is not set
126# CONFIG_HDPU is not set
127# CONFIG_EV64260 is not set
128# CONFIG_LOPEC is not set
129# CONFIG_MVME5100 is not set
130# CONFIG_PPLUS is not set
131# CONFIG_PRPMC750 is not set
132# CONFIG_PRPMC800 is not set
133# CONFIG_SANDPOINT is not set
134CONFIG_MPC7448HPC2=y
135# CONFIG_RADSTONE_PPC7D is not set
136# CONFIG_PAL4 is not set
137# CONFIG_GEMINI is not set
138# CONFIG_EST8260 is not set
139# CONFIG_SBC82xx is not set
140# CONFIG_SBS8260 is not set
141# CONFIG_RPX8260 is not set
142# CONFIG_TQM8260 is not set
143# CONFIG_ADS8272 is not set
144# CONFIG_PQ2FADS is not set
145# CONFIG_LITE5200 is not set
146# CONFIG_EV64360 is not set
147CONFIG_TSI108_BRIDGE=y
148# CONFIG_WANT_EARLY_SERIAL is not set
149
150#
151# Kernel options
152#
153# CONFIG_HIGHMEM is not set
154# CONFIG_HZ_100 is not set
155CONFIG_HZ_250=y
156# CONFIG_HZ_1000 is not set
157CONFIG_HZ=250
158CONFIG_PREEMPT_NONE=y
159# CONFIG_PREEMPT_VOLUNTARY is not set
160# CONFIG_PREEMPT is not set
161CONFIG_BINFMT_ELF=y
162CONFIG_BINFMT_MISC=y
163CONFIG_ARCH_FLATMEM_ENABLE=y
164CONFIG_SELECT_MEMORY_MODEL=y
165CONFIG_FLATMEM_MANUAL=y
166# CONFIG_DISCONTIGMEM_MANUAL is not set
167# CONFIG_SPARSEMEM_MANUAL is not set
168CONFIG_FLATMEM=y
169CONFIG_FLAT_NODE_MEM_MAP=y
170# CONFIG_SPARSEMEM_STATIC is not set
171CONFIG_SPLIT_PTLOCK_CPUS=4
172CONFIG_PROC_DEVICETREE=y
173# CONFIG_CMDLINE_BOOL is not set
174# CONFIG_PM is not set
175# CONFIG_SOFTWARE_SUSPEND is not set
176# CONFIG_SECCOMP is not set
177CONFIG_ISA_DMA_API=y
178
179#
180# Bus options
181#
182CONFIG_GENERIC_ISA_DMA=y
183# CONFIG_PPC_I8259 is not set
184# CONFIG_PPC_INDIRECT_PCI is not set
185CONFIG_PCI=y
186CONFIG_PCI_DOMAINS=y
187
188#
189# PCCARD (PCMCIA/CardBus) support
190#
191# CONFIG_PCCARD is not set
192
193#
194# PCI Hotplug Support
195#
196# CONFIG_HOTPLUG_PCI is not set
197
198#
199# Advanced setup
200#
201# CONFIG_ADVANCED_OPTIONS is not set
202
203#
204# Default settings for advanced configuration options are used
205#
206CONFIG_HIGHMEM_START=0xfe000000
207CONFIG_LOWMEM_SIZE=0x30000000
208CONFIG_KERNEL_START=0xc0000000
209CONFIG_TASK_SIZE=0x80000000
210CONFIG_BOOT_LOAD=0x00800000
211
212#
213# Networking
214#
215CONFIG_NET=y
216
217#
218# Networking options
219#
220# CONFIG_NETDEBUG is not set
221CONFIG_PACKET=y
222# CONFIG_PACKET_MMAP is not set
223CONFIG_UNIX=y
224# CONFIG_NET_KEY is not set
225CONFIG_INET=y
226CONFIG_IP_MULTICAST=y
227# CONFIG_IP_ADVANCED_ROUTER is not set
228CONFIG_IP_FIB_HASH=y
229CONFIG_IP_PNP=y
230CONFIG_IP_PNP_DHCP=y
231CONFIG_IP_PNP_BOOTP=y
232# CONFIG_IP_PNP_RARP is not set
233# CONFIG_NET_IPIP is not set
234# CONFIG_NET_IPGRE is not set
235# CONFIG_IP_MROUTE is not set
236# CONFIG_ARPD is not set
237CONFIG_SYN_COOKIES=y
238# CONFIG_INET_AH is not set
239# CONFIG_INET_ESP is not set
240# CONFIG_INET_IPCOMP is not set
241# CONFIG_INET_XFRM_TUNNEL is not set
242# CONFIG_INET_TUNNEL is not set
243CONFIG_INET_DIAG=y
244CONFIG_INET_TCP_DIAG=y
245# CONFIG_TCP_CONG_ADVANCED is not set
246CONFIG_TCP_CONG_BIC=y
247# CONFIG_IPV6 is not set
248# CONFIG_INET6_XFRM_TUNNEL is not set
249# CONFIG_INET6_TUNNEL is not set
250# CONFIG_NETFILTER is not set
251
252#
253# DCCP Configuration (EXPERIMENTAL)
254#
255# CONFIG_IP_DCCP is not set
256
257#
258# SCTP Configuration (EXPERIMENTAL)
259#
260# CONFIG_IP_SCTP is not set
261
262#
263# TIPC Configuration (EXPERIMENTAL)
264#
265# CONFIG_TIPC is not set
266# CONFIG_ATM is not set
267# CONFIG_BRIDGE is not set
268# CONFIG_VLAN_8021Q is not set
269# CONFIG_DECNET is not set
270# CONFIG_LLC2 is not set
271# CONFIG_IPX is not set
272# CONFIG_ATALK is not set
273# CONFIG_X25 is not set
274# CONFIG_LAPB is not set
275# CONFIG_NET_DIVERT is not set
276# CONFIG_ECONET is not set
277# CONFIG_WAN_ROUTER is not set
278
279#
280# QoS and/or fair queueing
281#
282# CONFIG_NET_SCHED is not set
283
284#
285# Network testing
286#
287# CONFIG_NET_PKTGEN is not set
288# CONFIG_HAMRADIO is not set
289# CONFIG_IRDA is not set
290# CONFIG_BT is not set
291# CONFIG_IEEE80211 is not set
292
293#
294# Device Drivers
295#
296
297#
298# Generic Driver Options
299#
300CONFIG_STANDALONE=y
301CONFIG_PREVENT_FIRMWARE_BUILD=y
302# CONFIG_FW_LOADER is not set
303
304#
305# Connector - unified userspace <-> kernelspace linker
306#
307# CONFIG_CONNECTOR is not set
308
309#
310# Memory Technology Devices (MTD)
311#
312# CONFIG_MTD is not set
313
314#
315# Parallel port support
316#
317# CONFIG_PARPORT is not set
318
319#
320# Plug and Play support
321#
322
323#
324# Block devices
325#
326# CONFIG_BLK_DEV_FD is not set
327# CONFIG_BLK_CPQ_DA is not set
328# CONFIG_BLK_CPQ_CISS_DA is not set
329# CONFIG_BLK_DEV_DAC960 is not set
330# CONFIG_BLK_DEV_UMEM is not set
331# CONFIG_BLK_DEV_COW_COMMON is not set
332CONFIG_BLK_DEV_LOOP=y
333# CONFIG_BLK_DEV_CRYPTOLOOP is not set
334# CONFIG_BLK_DEV_NBD is not set
335# CONFIG_BLK_DEV_SX8 is not set
336CONFIG_BLK_DEV_RAM=y
337CONFIG_BLK_DEV_RAM_COUNT=16
338CONFIG_BLK_DEV_RAM_SIZE=131072
339CONFIG_BLK_DEV_INITRD=y
340# CONFIG_CDROM_PKTCDVD is not set
341# CONFIG_ATA_OVER_ETH is not set
342
343#
344# ATA/ATAPI/MFM/RLL support
345#
346# CONFIG_IDE is not set
347
348#
349# SCSI device support
350#
351# CONFIG_RAID_ATTRS is not set
352CONFIG_SCSI=y
353CONFIG_SCSI_PROC_FS=y
354
355#
356# SCSI support type (disk, tape, CD-ROM)
357#
358CONFIG_BLK_DEV_SD=y
359# CONFIG_CHR_DEV_ST is not set
360# CONFIG_CHR_DEV_OSST is not set
361# CONFIG_BLK_DEV_SR is not set
362# CONFIG_CHR_DEV_SG is not set
363# CONFIG_CHR_DEV_SCH is not set
364
365#
366# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
367#
368# CONFIG_SCSI_MULTI_LUN is not set
369# CONFIG_SCSI_CONSTANTS is not set
370# CONFIG_SCSI_LOGGING is not set
371
372#
373# SCSI Transport Attributes
374#
375# CONFIG_SCSI_SPI_ATTRS is not set
376# CONFIG_SCSI_FC_ATTRS is not set
377# CONFIG_SCSI_ISCSI_ATTRS is not set
378# CONFIG_SCSI_SAS_ATTRS is not set
379
380#
381# SCSI low-level drivers
382#
383# CONFIG_ISCSI_TCP is not set
384# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
385# CONFIG_SCSI_3W_9XXX is not set
386# CONFIG_SCSI_ACARD is not set
387# CONFIG_SCSI_AACRAID is not set
388# CONFIG_SCSI_AIC7XXX is not set
389# CONFIG_SCSI_AIC7XXX_OLD is not set
390# CONFIG_SCSI_AIC79XX is not set
391# CONFIG_SCSI_DPT_I2O is not set
392# CONFIG_MEGARAID_NEWGEN is not set
393# CONFIG_MEGARAID_LEGACY is not set
394# CONFIG_MEGARAID_SAS is not set
395CONFIG_SCSI_SATA=y
396# CONFIG_SCSI_SATA_AHCI is not set
397# CONFIG_SCSI_SATA_SVW is not set
398# CONFIG_SCSI_ATA_PIIX is not set
399CONFIG_SCSI_SATA_MV=y
400# CONFIG_SCSI_SATA_NV is not set
401# CONFIG_SCSI_PDC_ADMA is not set
402# CONFIG_SCSI_SATA_QSTOR is not set
403# CONFIG_SCSI_SATA_PROMISE is not set
404# CONFIG_SCSI_SATA_SX4 is not set
405# CONFIG_SCSI_SATA_SIL is not set
406# CONFIG_SCSI_SATA_SIL24 is not set
407# CONFIG_SCSI_SATA_SIS is not set
408# CONFIG_SCSI_SATA_ULI is not set
409# CONFIG_SCSI_SATA_VIA is not set
410# CONFIG_SCSI_SATA_VITESSE is not set
411# CONFIG_SCSI_BUSLOGIC is not set
412# CONFIG_SCSI_DMX3191D is not set
413# CONFIG_SCSI_EATA is not set
414# CONFIG_SCSI_FUTURE_DOMAIN is not set
415# CONFIG_SCSI_GDTH is not set
416# CONFIG_SCSI_IPS is not set
417# CONFIG_SCSI_INITIO is not set
418# CONFIG_SCSI_INIA100 is not set
419# CONFIG_SCSI_SYM53C8XX_2 is not set
420# CONFIG_SCSI_IPR is not set
421# CONFIG_SCSI_QLOGIC_1280 is not set
422# CONFIG_SCSI_QLA_FC is not set
423# CONFIG_SCSI_LPFC is not set
424# CONFIG_SCSI_DC395x is not set
425# CONFIG_SCSI_DC390T is not set
426# CONFIG_SCSI_NSP32 is not set
427# CONFIG_SCSI_DEBUG is not set
428
429#
430# Multi-device support (RAID and LVM)
431#
432# CONFIG_MD is not set
433
434#
435# Fusion MPT device support
436#
437# CONFIG_FUSION is not set
438# CONFIG_FUSION_SPI is not set
439# CONFIG_FUSION_FC is not set
440# CONFIG_FUSION_SAS is not set
441
442#
443# IEEE 1394 (FireWire) support
444#
445# CONFIG_IEEE1394 is not set
446
447#
448# I2O device support
449#
450# CONFIG_I2O is not set
451
452#
453# Macintosh device drivers
454#
455# CONFIG_WINDFARM is not set
456
457#
458# Network device support
459#
460CONFIG_NETDEVICES=y
461# CONFIG_DUMMY is not set
462# CONFIG_BONDING is not set
463# CONFIG_EQUALIZER is not set
464# CONFIG_TUN is not set
465
466#
467# ARCnet devices
468#
469# CONFIG_ARCNET is not set
470
471#
472# PHY device support
473#
474CONFIG_PHYLIB=y
475
476#
477# MII PHY device drivers
478#
479# CONFIG_MARVELL_PHY is not set
480# CONFIG_DAVICOM_PHY is not set
481# CONFIG_QSEMI_PHY is not set
482# CONFIG_LXT_PHY is not set
483# CONFIG_CICADA_PHY is not set
484
485#
486# Ethernet (10 or 100Mbit)
487#
488CONFIG_NET_ETHERNET=y
489CONFIG_MII=y
490# CONFIG_HAPPYMEAL is not set
491# CONFIG_SUNGEM is not set
492# CONFIG_CASSINI is not set
493# CONFIG_NET_VENDOR_3COM is not set
494
495#
496# Tulip family network device support
497#
498# CONFIG_NET_TULIP is not set
499# CONFIG_HP100 is not set
500CONFIG_NET_PCI=y
501# CONFIG_PCNET32 is not set
502# CONFIG_AMD8111_ETH is not set
503# CONFIG_ADAPTEC_STARFIRE is not set
504# CONFIG_B44 is not set
505# CONFIG_FORCEDETH is not set
506# CONFIG_DGRS is not set
507# CONFIG_EEPRO100 is not set
508CONFIG_E100=y
509# CONFIG_FEALNX is not set
510# CONFIG_NATSEMI is not set
511# CONFIG_NE2K_PCI is not set
512# CONFIG_8139CP is not set
513CONFIG_8139TOO=y
514# CONFIG_8139TOO_PIO is not set
515# CONFIG_8139TOO_TUNE_TWISTER is not set
516# CONFIG_8139TOO_8129 is not set
517# CONFIG_8139_OLD_RX_RESET is not set
518# CONFIG_SIS900 is not set
519# CONFIG_EPIC100 is not set
520# CONFIG_SUNDANCE is not set
521# CONFIG_TLAN is not set
522# CONFIG_VIA_RHINE is not set
523
524#
525# Ethernet (1000 Mbit)
526#
527# CONFIG_ACENIC is not set
528# CONFIG_DL2K is not set
529# CONFIG_E1000 is not set
530# CONFIG_NS83820 is not set
531# CONFIG_HAMACHI is not set
532# CONFIG_YELLOWFIN is not set
533# CONFIG_R8169 is not set
534# CONFIG_SIS190 is not set
535# CONFIG_SKGE is not set
536# CONFIG_SKY2 is not set
537# CONFIG_SK98LIN is not set
538# CONFIG_VIA_VELOCITY is not set
539# CONFIG_TIGON3 is not set
540# CONFIG_BNX2 is not set
541CONFIG_TSI108_ETH=y
542
543#
544# Ethernet (10000 Mbit)
545#
546# CONFIG_CHELSIO_T1 is not set
547# CONFIG_IXGB is not set
548# CONFIG_S2IO is not set
549
550#
551# Token Ring devices
552#
553# CONFIG_TR is not set
554
555#
556# Wireless LAN (non-hamradio)
557#
558# CONFIG_NET_RADIO is not set
559
560#
561# Wan interfaces
562#
563# CONFIG_WAN is not set
564# CONFIG_FDDI is not set
565# CONFIG_HIPPI is not set
566# CONFIG_PPP is not set
567# CONFIG_SLIP is not set
568# CONFIG_NET_FC is not set
569# CONFIG_SHAPER is not set
570# CONFIG_NETCONSOLE is not set
571# CONFIG_NETPOLL is not set
572# CONFIG_NET_POLL_CONTROLLER is not set
573
574#
575# ISDN subsystem
576#
577# CONFIG_ISDN is not set
578
579#
580# Telephony Support
581#
582# CONFIG_PHONE is not set
583
584#
585# Input device support
586#
587CONFIG_INPUT=y
588
589#
590# Userland interfaces
591#
592# CONFIG_INPUT_MOUSEDEV is not set
593# CONFIG_INPUT_JOYDEV is not set
594# CONFIG_INPUT_TSDEV is not set
595# CONFIG_INPUT_EVDEV is not set
596# CONFIG_INPUT_EVBUG is not set
597
598#
599# Input Device Drivers
600#
601# CONFIG_INPUT_KEYBOARD is not set
602# CONFIG_INPUT_MOUSE is not set
603# CONFIG_INPUT_JOYSTICK is not set
604# CONFIG_INPUT_TOUCHSCREEN is not set
605# CONFIG_INPUT_MISC is not set
606
607#
608# Hardware I/O ports
609#
610# CONFIG_SERIO is not set
611# CONFIG_GAMEPORT is not set
612
613#
614# Character devices
615#
616# CONFIG_VT is not set
617# CONFIG_SERIAL_NONSTANDARD is not set
618
619#
620# Serial drivers
621#
622CONFIG_SERIAL_8250=y
623CONFIG_SERIAL_8250_CONSOLE=y
624CONFIG_SERIAL_8250_PCI=y
625CONFIG_SERIAL_8250_NR_UARTS=4
626CONFIG_SERIAL_8250_RUNTIME_UARTS=4
627# CONFIG_SERIAL_8250_EXTENDED is not set
628
629#
630# Non-8250 serial port support
631#
632CONFIG_SERIAL_CORE=y
633CONFIG_SERIAL_CORE_CONSOLE=y
634# CONFIG_SERIAL_JSM is not set
635CONFIG_UNIX98_PTYS=y
636CONFIG_LEGACY_PTYS=y
637CONFIG_LEGACY_PTY_COUNT=256
638
639#
640# IPMI
641#
642# CONFIG_IPMI_HANDLER is not set
643
644#
645# Watchdog Cards
646#
647# CONFIG_WATCHDOG is not set
648# CONFIG_NVRAM is not set
649CONFIG_GEN_RTC=y
650# CONFIG_GEN_RTC_X is not set
651# CONFIG_DTLK is not set
652# CONFIG_R3964 is not set
653# CONFIG_APPLICOM is not set
654
655#
656# Ftape, the floppy tape device driver
657#
658# CONFIG_AGP is not set
659# CONFIG_DRM is not set
660# CONFIG_RAW_DRIVER is not set
661
662#
663# TPM devices
664#
665# CONFIG_TCG_TPM is not set
666# CONFIG_TELCLOCK is not set
667
668#
669# I2C support
670#
671# CONFIG_I2C is not set
672
673#
674# SPI support
675#
676# CONFIG_SPI is not set
677# CONFIG_SPI_MASTER is not set
678
679#
680# Dallas's 1-wire bus
681#
682# CONFIG_W1 is not set
683
684#
685# Hardware Monitoring support
686#
687CONFIG_HWMON=y
688# CONFIG_HWMON_VID is not set
689# CONFIG_SENSORS_F71805F is not set
690# CONFIG_HWMON_DEBUG_CHIP is not set
691
692#
693# Misc devices
694#
695
696#
697# Multimedia devices
698#
699# CONFIG_VIDEO_DEV is not set
700
701#
702# Digital Video Broadcasting Devices
703#
704# CONFIG_DVB is not set
705
706#
707# Graphics support
708#
709# CONFIG_FB is not set
710
711#
712# Sound
713#
714# CONFIG_SOUND is not set
715
716#
717# USB support
718#
719CONFIG_USB_ARCH_HAS_HCD=y
720CONFIG_USB_ARCH_HAS_OHCI=y
721CONFIG_USB_ARCH_HAS_EHCI=y
722# CONFIG_USB is not set
723
724#
725# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
726#
727
728#
729# USB Gadget Support
730#
731# CONFIG_USB_GADGET is not set
732
733#
734# MMC/SD Card support
735#
736# CONFIG_MMC is not set
737
738#
739# LED devices
740#
741# CONFIG_NEW_LEDS is not set
742
743#
744# LED drivers
745#
746
747#
748# LED Triggers
749#
750
751#
752# InfiniBand support
753#
754# CONFIG_INFINIBAND is not set
755
756#
757# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
758#
759
760#
761# Real Time Clock
762#
763# CONFIG_RTC_CLASS is not set
764
765#
766# File systems
767#
768CONFIG_EXT2_FS=y
769# CONFIG_EXT2_FS_XATTR is not set
770# CONFIG_EXT2_FS_XIP is not set
771CONFIG_EXT3_FS=y
772CONFIG_EXT3_FS_XATTR=y
773# CONFIG_EXT3_FS_POSIX_ACL is not set
774# CONFIG_EXT3_FS_SECURITY is not set
775CONFIG_JBD=y
776# CONFIG_JBD_DEBUG is not set
777CONFIG_FS_MBCACHE=y
778# CONFIG_REISERFS_FS is not set
779# CONFIG_JFS_FS is not set
780# CONFIG_FS_POSIX_ACL is not set
781# CONFIG_XFS_FS is not set
782# CONFIG_OCFS2_FS is not set
783# CONFIG_MINIX_FS is not set
784# CONFIG_ROMFS_FS is not set
785CONFIG_INOTIFY=y
786# CONFIG_QUOTA is not set
787CONFIG_DNOTIFY=y
788# CONFIG_AUTOFS_FS is not set
789# CONFIG_AUTOFS4_FS is not set
790# CONFIG_FUSE_FS is not set
791
792#
793# CD-ROM/DVD Filesystems
794#
795# CONFIG_ISO9660_FS is not set
796# CONFIG_UDF_FS is not set
797
798#
799# DOS/FAT/NT Filesystems
800#
801# CONFIG_MSDOS_FS is not set
802# CONFIG_VFAT_FS is not set
803# CONFIG_NTFS_FS is not set
804
805#
806# Pseudo filesystems
807#
808CONFIG_PROC_FS=y
809CONFIG_PROC_KCORE=y
810CONFIG_SYSFS=y
811CONFIG_TMPFS=y
812# CONFIG_HUGETLB_PAGE is not set
813CONFIG_RAMFS=y
814# CONFIG_CONFIGFS_FS is not set
815
816#
817# Miscellaneous filesystems
818#
819# CONFIG_ADFS_FS is not set
820# CONFIG_AFFS_FS is not set
821# CONFIG_HFS_FS is not set
822# CONFIG_HFSPLUS_FS is not set
823# CONFIG_BEFS_FS is not set
824# CONFIG_BFS_FS is not set
825# CONFIG_EFS_FS is not set
826# CONFIG_CRAMFS is not set
827# CONFIG_VXFS_FS is not set
828# CONFIG_HPFS_FS is not set
829# CONFIG_QNX4FS_FS is not set
830# CONFIG_SYSV_FS is not set
831# CONFIG_UFS_FS is not set
832
833#
834# Network File Systems
835#
836CONFIG_NFS_FS=y
837# CONFIG_NFS_V3 is not set
838# CONFIG_NFS_V4 is not set
839# CONFIG_NFS_DIRECTIO is not set
840# CONFIG_NFSD is not set
841CONFIG_ROOT_NFS=y
842CONFIG_LOCKD=y
843CONFIG_NFS_COMMON=y
844CONFIG_SUNRPC=y
845# CONFIG_RPCSEC_GSS_KRB5 is not set
846# CONFIG_RPCSEC_GSS_SPKM3 is not set
847# CONFIG_SMB_FS is not set
848# CONFIG_CIFS is not set
849# CONFIG_NCP_FS is not set
850# CONFIG_CODA_FS is not set
851# CONFIG_AFS_FS is not set
852# CONFIG_9P_FS is not set
853
854#
855# Partition Types
856#
857CONFIG_PARTITION_ADVANCED=y
858# CONFIG_ACORN_PARTITION is not set
859# CONFIG_OSF_PARTITION is not set
860# CONFIG_AMIGA_PARTITION is not set
861# CONFIG_ATARI_PARTITION is not set
862# CONFIG_MAC_PARTITION is not set
863CONFIG_MSDOS_PARTITION=y
864# CONFIG_BSD_DISKLABEL is not set
865# CONFIG_MINIX_SUBPARTITION is not set
866# CONFIG_SOLARIS_X86_PARTITION is not set
867# CONFIG_UNIXWARE_DISKLABEL is not set
868# CONFIG_LDM_PARTITION is not set
869# CONFIG_SGI_PARTITION is not set
870# CONFIG_ULTRIX_PARTITION is not set
871# CONFIG_SUN_PARTITION is not set
872# CONFIG_KARMA_PARTITION is not set
873# CONFIG_EFI_PARTITION is not set
874
875#
876# Native Language Support
877#
878# CONFIG_NLS is not set
879
880#
881# Library routines
882#
883# CONFIG_CRC_CCITT is not set
884# CONFIG_CRC16 is not set
885CONFIG_CRC32=y
886# CONFIG_LIBCRC32C is not set
887
888#
889# Instrumentation Support
890#
891# CONFIG_PROFILING is not set
892
893#
894# Kernel hacking
895#
896# CONFIG_PRINTK_TIME is not set
897# CONFIG_MAGIC_SYSRQ is not set
898# CONFIG_DEBUG_KERNEL is not set
899CONFIG_LOG_BUF_SHIFT=14
900# CONFIG_DEBUG_FS is not set
901# CONFIG_UNWIND_INFO is not set
902# CONFIG_BOOTX_TEXT is not set
903# CONFIG_SERIAL_TEXT_DEBUG is not set
904# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
905# CONFIG_PPC_EARLY_DEBUG_G5 is not set
906# CONFIG_PPC_EARLY_DEBUG_RTAS is not set
907# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set
908# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
909
910#
911# Security options
912#
913# CONFIG_KEYS is not set
914# CONFIG_SECURITY is not set
915
916#
917# Cryptographic options
918#
919# CONFIG_CRYPTO is not set
920
921#
922# Hardware crypto devices
923#
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 803858e86160..814f242aeb8c 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -50,7 +50,8 @@ extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o
50extra-$(CONFIG_8xx) := head_8xx.o 50extra-$(CONFIG_8xx) := head_8xx.o
51extra-y += vmlinux.lds 51extra-y += vmlinux.lds
52 52
53obj-y += time.o prom.o traps.o setup-common.o udbg.o 53obj-y += time.o prom.o traps.o setup-common.o \
54 udbg.o misc.o
54obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o 55obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o
55obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o 56obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o
56obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o 57obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o
diff --git a/arch/powerpc/kernel/cpu_setup_power4.S b/arch/powerpc/kernel/cpu_setup_power4.S
index 271418308d53..1fc863261003 100644
--- a/arch/powerpc/kernel/cpu_setup_power4.S
+++ b/arch/powerpc/kernel/cpu_setup_power4.S
@@ -125,7 +125,12 @@ _GLOBAL(__save_cpu_setup)
125 cmpwi r0,0x44 125 cmpwi r0,0x44
126 bne 2f 126 bne 2f
127 127
1281: /* Save HID0,1,4 and 5 */ 1281: /* skip if not running in HV mode */
129 mfmsr r0
130 rldicl. r0,r0,4,63
131 beq 2f
132
133 /* Save HID0,1,4 and 5 */
129 mfspr r3,SPRN_HID0 134 mfspr r3,SPRN_HID0
130 std r3,CS_HID0(r5) 135 std r3,CS_HID0(r5)
131 mfspr r3,SPRN_HID1 136 mfspr r3,SPRN_HID1
@@ -159,7 +164,12 @@ _GLOBAL(__restore_cpu_setup)
159 cmpwi r0,0x44 164 cmpwi r0,0x44
160 bnelr 165 bnelr
161 166
1621: /* Before accessing memory, we make sure rm_ci is clear */ 1671: /* skip if not running in HV mode */
168 mfmsr r0
169 rldicl. r0,r0,4,63
170 beqlr
171
172 /* Before accessing memory, we make sure rm_ci is clear */
163 li r0,0 173 li r0,0
164 mfspr r3,SPRN_HID4 174 mfspr r3,SPRN_HID4
165 rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */ 175 rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 1c114880dc05..abf7d42a8b07 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -722,18 +722,6 @@ struct cpu_spec cpu_specs[] = {
722 .oprofile_type = PPC_OPROFILE_G4, 722 .oprofile_type = PPC_OPROFILE_G4,
723 .platform = "ppc7450", 723 .platform = "ppc7450",
724 }, 724 },
725 { /* 8641 */
726 .pvr_mask = 0xffffffff,
727 .pvr_value = 0x80040010,
728 .cpu_name = "8641",
729 .cpu_features = CPU_FTRS_7447A,
730 .cpu_user_features = COMMON_USER | PPC_FEATURE_HAS_ALTIVEC_COMP,
731 .icache_bsize = 32,
732 .dcache_bsize = 32,
733 .num_pmcs = 6,
734 .cpu_setup = __setup_cpu_745x
735 },
736
737 { /* 82xx (8240, 8245, 8260 are all 603e cores) */ 725 { /* 82xx (8240, 8245, 8260 are all 603e cores) */
738 .pvr_mask = 0x7fff0000, 726 .pvr_mask = 0x7fff0000,
739 .pvr_value = 0x00810000, 727 .pvr_value = 0x00810000,
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index e253a45dcf10..358cecdc6aef 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -24,9 +24,11 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/irq.h> 25#include <linux/irq.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/irq.h>
27 28
28#include <asm/processor.h> 29#include <asm/processor.h>
29#include <asm/machdep.h> 30#include <asm/machdep.h>
31#include <asm/kexec.h>
30#include <asm/kdump.h> 32#include <asm/kdump.h>
31#include <asm/lmb.h> 33#include <asm/lmb.h>
32#include <asm/firmware.h> 34#include <asm/firmware.h>
@@ -41,6 +43,7 @@
41 43
42/* This keeps a track of which one is crashing cpu. */ 44/* This keeps a track of which one is crashing cpu. */
43int crashing_cpu = -1; 45int crashing_cpu = -1;
46static cpumask_t cpus_in_crash = CPU_MASK_NONE;
44 47
45static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data, 48static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
46 size_t data_len) 49 size_t data_len)
@@ -98,34 +101,66 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
98} 101}
99 102
100#ifdef CONFIG_SMP 103#ifdef CONFIG_SMP
101static atomic_t waiting_for_crash_ipi; 104static atomic_t enter_on_soft_reset = ATOMIC_INIT(0);
102 105
103void crash_ipi_callback(struct pt_regs *regs) 106void crash_ipi_callback(struct pt_regs *regs)
104{ 107{
105 int cpu = smp_processor_id(); 108 int cpu = smp_processor_id();
106 109
107 if (cpu == crashing_cpu)
108 return;
109
110 if (!cpu_online(cpu)) 110 if (!cpu_online(cpu))
111 return; 111 return;
112 112
113 if (ppc_md.kexec_cpu_down)
114 ppc_md.kexec_cpu_down(1, 1);
115
116 local_irq_disable(); 113 local_irq_disable();
114 if (!cpu_isset(cpu, cpus_in_crash))
115 crash_save_this_cpu(regs, cpu);
116 cpu_set(cpu, cpus_in_crash);
117 117
118 crash_save_this_cpu(regs, cpu); 118 /*
119 atomic_dec(&waiting_for_crash_ipi); 119 * Entered via soft-reset - could be the kdump
120 * process is invoked using soft-reset or user activated
121 * it if some CPU did not respond to an IPI.
122 * For soft-reset, the secondary CPU can enter this func
123 * twice. 1 - using IPI, and 2. soft-reset.
124 * Tell the kexec CPU that entered via soft-reset and ready
125 * to go down.
126 */
127 if (cpu_isset(cpu, cpus_in_sr)) {
128 cpu_clear(cpu, cpus_in_sr);
129 atomic_inc(&enter_on_soft_reset);
130 }
131
132 /*
133 * Starting the kdump boot.
134 * This barrier is needed to make sure that all CPUs are stopped.
135 * If not, soft-reset will be invoked to bring other CPUs.
136 */
137 while (!cpu_isset(crashing_cpu, cpus_in_crash))
138 cpu_relax();
139
140 if (ppc_md.kexec_cpu_down)
141 ppc_md.kexec_cpu_down(1, 1);
120 kexec_smp_wait(); 142 kexec_smp_wait();
121 /* NOTREACHED */ 143 /* NOTREACHED */
122} 144}
123 145
124static void crash_kexec_prepare_cpus(void) 146/*
147 * Wait until all CPUs are entered via soft-reset.
148 */
149static void crash_soft_reset_check(int cpu)
150{
151 unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
152
153 cpu_clear(cpu, cpus_in_sr);
154 while (atomic_read(&enter_on_soft_reset) != ncpus)
155 cpu_relax();
156}
157
158
159static void crash_kexec_prepare_cpus(int cpu)
125{ 160{
126 unsigned int msecs; 161 unsigned int msecs;
127 162
128 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); 163 unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
129 164
130 crash_send_ipi(crash_ipi_callback); 165 crash_send_ipi(crash_ipi_callback);
131 smp_wmb(); 166 smp_wmb();
@@ -133,14 +168,13 @@ static void crash_kexec_prepare_cpus(void)
133 /* 168 /*
134 * FIXME: Until we will have the way to stop other CPUSs reliabally, 169 * FIXME: Until we will have the way to stop other CPUSs reliabally,
135 * the crash CPU will send an IPI and wait for other CPUs to 170 * the crash CPU will send an IPI and wait for other CPUs to
136 * respond. If not, proceed the kexec boot even though we failed to 171 * respond.
137 * capture other CPU states.
138 * Delay of at least 10 seconds. 172 * Delay of at least 10 seconds.
139 */ 173 */
140 printk(KERN_ALERT "Sending IPI to other cpus...\n"); 174 printk(KERN_EMERG "Sending IPI to other cpus...\n");
141 msecs = 10000; 175 msecs = 10000;
142 while ((atomic_read(&waiting_for_crash_ipi) > 0) && (--msecs > 0)) { 176 while ((cpus_weight(cpus_in_crash) < ncpus) && (--msecs > 0)) {
143 barrier(); 177 cpu_relax();
144 mdelay(1); 178 mdelay(1);
145 } 179 }
146 180
@@ -149,18 +183,71 @@ static void crash_kexec_prepare_cpus(void)
149 /* 183 /*
150 * FIXME: In case if we do not get all CPUs, one possibility: ask the 184 * FIXME: In case if we do not get all CPUs, one possibility: ask the
151 * user to do soft reset such that we get all. 185 * user to do soft reset such that we get all.
152 * IPI handler is already set by the panic cpu initially. Therefore, 186 * Soft-reset will be used until better mechanism is implemented.
153 * all cpus could invoke this handler from die() and the panic CPU 187 */
154 * will call machine_kexec() directly from this handler to do 188 if (cpus_weight(cpus_in_crash) < ncpus) {
155 * kexec boot. 189 printk(KERN_EMERG "done waiting: %d cpu(s) not responding\n",
190 ncpus - cpus_weight(cpus_in_crash));
191 printk(KERN_EMERG "Activate soft-reset to stop other cpu(s)\n");
192 cpus_in_sr = CPU_MASK_NONE;
193 atomic_set(&enter_on_soft_reset, 0);
194 while (cpus_weight(cpus_in_crash) < ncpus)
195 cpu_relax();
196 }
197 /*
198 * Make sure all CPUs are entered via soft-reset if the kdump is
199 * invoked using soft-reset.
156 */ 200 */
157 if (atomic_read(&waiting_for_crash_ipi)) 201 if (cpu_isset(cpu, cpus_in_sr))
158 printk(KERN_ALERT "done waiting: %d cpus not responding\n", 202 crash_soft_reset_check(cpu);
159 atomic_read(&waiting_for_crash_ipi));
160 /* Leave the IPI callback set */ 203 /* Leave the IPI callback set */
161} 204}
205
206/*
207 * This function will be called by secondary cpus or by kexec cpu
208 * if soft-reset is activated to stop some CPUs.
209 */
210void crash_kexec_secondary(struct pt_regs *regs)
211{
212 int cpu = smp_processor_id();
213 unsigned long flags;
214 int msecs = 5;
215
216 local_irq_save(flags);
217 /* Wait 5ms if the kexec CPU is not entered yet. */
218 while (crashing_cpu < 0) {
219 if (--msecs < 0) {
220 /*
221 * Either kdump image is not loaded or
222 * kdump process is not started - Probably xmon
223 * exited using 'x'(exit and recover) or
224 * kexec_should_crash() failed for all running tasks.
225 */
226 cpu_clear(cpu, cpus_in_sr);
227 local_irq_restore(flags);
228 return;
229 }
230 mdelay(1);
231 cpu_relax();
232 }
233 if (cpu == crashing_cpu) {
234 /*
235 * Panic CPU will enter this func only via soft-reset.
236 * Wait until all secondary CPUs entered and
237 * then start kexec boot.
238 */
239 crash_soft_reset_check(cpu);
240 cpu_set(crashing_cpu, cpus_in_crash);
241 if (ppc_md.kexec_cpu_down)
242 ppc_md.kexec_cpu_down(1, 0);
243 machine_kexec(kexec_crash_image);
244 /* NOTREACHED */
245 }
246 crash_ipi_callback(regs);
247}
248
162#else 249#else
163static void crash_kexec_prepare_cpus(void) 250static void crash_kexec_prepare_cpus(int cpu)
164{ 251{
165 /* 252 /*
166 * move the secondarys to us so that we can copy 253 * move the secondarys to us so that we can copy
@@ -171,6 +258,10 @@ static void crash_kexec_prepare_cpus(void)
171 smp_release_cpus(); 258 smp_release_cpus();
172} 259}
173 260
261void crash_kexec_secondary(struct pt_regs *regs)
262{
263 cpus_in_sr = CPU_MASK_NONE;
264}
174#endif 265#endif
175 266
176void default_machine_crash_shutdown(struct pt_regs *regs) 267void default_machine_crash_shutdown(struct pt_regs *regs)
@@ -190,23 +281,23 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
190 local_irq_disable(); 281 local_irq_disable();
191 282
192 for_each_irq(irq) { 283 for_each_irq(irq) {
193 struct irq_desc *desc = irq_descp(irq); 284 struct irq_desc *desc = irq_desc + irq;
194 285
195 if (desc->status & IRQ_INPROGRESS) 286 if (desc->status & IRQ_INPROGRESS)
196 desc->handler->end(irq); 287 desc->chip->end(irq);
197 288
198 if (!(desc->status & IRQ_DISABLED)) 289 if (!(desc->status & IRQ_DISABLED))
199 desc->handler->disable(irq); 290 desc->chip->disable(irq);
200 } 291 }
201 292
202 if (ppc_md.kexec_cpu_down)
203 ppc_md.kexec_cpu_down(1, 0);
204
205 /* 293 /*
206 * Make a note of crashing cpu. Will be used in machine_kexec 294 * Make a note of crashing cpu. Will be used in machine_kexec
207 * such that another IPI will not be sent. 295 * such that another IPI will not be sent.
208 */ 296 */
209 crashing_cpu = smp_processor_id(); 297 crashing_cpu = smp_processor_id();
210 crash_kexec_prepare_cpus();
211 crash_save_this_cpu(regs, crashing_cpu); 298 crash_save_this_cpu(regs, crashing_cpu);
299 crash_kexec_prepare_cpus(crashing_cpu);
300 cpu_set(crashing_cpu, cpus_in_crash);
301 if (ppc_md.kexec_cpu_down)
302 ppc_md.kexec_cpu_down(1, 0);
212} 303}
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 831acbdf2592..8cfd040d1f50 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -85,34 +85,6 @@ END_FTR_SECTION(0, 1)
85 /* Catch branch to 0 in real mode */ 85 /* Catch branch to 0 in real mode */
86 trap 86 trap
87 87
88#ifdef CONFIG_PPC_ISERIES
89 /*
90 * At offset 0x20, there is a pointer to iSeries LPAR data.
91 * This is required by the hypervisor
92 */
93 . = 0x20
94 .llong hvReleaseData-KERNELBASE
95
96 /*
97 * At offset 0x28 and 0x30 are offsets to the mschunks_map
98 * array (used by the iSeries LPAR debugger to do translation
99 * between physical addresses and absolute addresses) and
100 * to the pidhash table (also used by the debugger)
101 */
102 .llong mschunks_map-KERNELBASE
103 .llong 0 /* pidhash-KERNELBASE SFRXXX */
104
105 /* Offset 0x38 - Pointer to start of embedded System.map */
106 .globl embedded_sysmap_start
107embedded_sysmap_start:
108 .llong 0
109 /* Offset 0x40 - Pointer to end of embedded System.map */
110 .globl embedded_sysmap_end
111embedded_sysmap_end:
112 .llong 0
113
114#endif /* CONFIG_PPC_ISERIES */
115
116 /* Secondary processors spin on this value until it goes to 1. */ 88 /* Secondary processors spin on this value until it goes to 1. */
117 .globl __secondary_hold_spinloop 89 .globl __secondary_hold_spinloop
118__secondary_hold_spinloop: 90__secondary_hold_spinloop:
@@ -124,6 +96,15 @@ __secondary_hold_spinloop:
124__secondary_hold_acknowledge: 96__secondary_hold_acknowledge:
125 .llong 0x0 97 .llong 0x0
126 98
99#ifdef CONFIG_PPC_ISERIES
100 /*
101 * At offset 0x20, there is a pointer to iSeries LPAR data.
102 * This is required by the hypervisor
103 */
104 . = 0x20
105 .llong hvReleaseData-KERNELBASE
106#endif /* CONFIG_PPC_ISERIES */
107
127 . = 0x60 108 . = 0x60
128/* 109/*
129 * The following code is used on pSeries to hold secondary processors 110 * The following code is used on pSeries to hold secondary processors
@@ -1602,9 +1583,6 @@ _GLOBAL(__start_initialization_multiplatform)
1602 /* Setup some critical 970 SPRs before switching MMU off */ 1583 /* Setup some critical 970 SPRs before switching MMU off */
1603 bl .__970_cpu_preinit 1584 bl .__970_cpu_preinit
1604 1585
1605 /* cpu # */
1606 li r24,0
1607
1608 /* Switch off MMU if not already */ 1586 /* Switch off MMU if not already */
1609 LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE) 1587 LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE)
1610 add r4,r4,r30 1588 add r4,r4,r30
@@ -1683,6 +1661,9 @@ _STATIC(__after_prom_start)
1683 /* i.e. where we are running */ 1661 /* i.e. where we are running */
1684 /* the source addr */ 1662 /* the source addr */
1685 1663
1664 cmpdi r4,0 /* In some cases the loader may */
1665 beq .start_here_multiplatform /* have already put us at zero */
1666 /* so we can skip the copy. */
1686 LOAD_REG_IMMEDIATE(r5,copy_to_here) /* # bytes of memory to copy */ 1667 LOAD_REG_IMMEDIATE(r5,copy_to_here) /* # bytes of memory to copy */
1687 sub r5,r5,r27 1668 sub r5,r5,r27
1688 1669
@@ -1962,14 +1943,6 @@ _STATIC(start_here_common)
1962 li r3,0 1943 li r3,0
1963 bl .do_cpu_ftr_fixups 1944 bl .do_cpu_ftr_fixups
1964 1945
1965 LOAD_REG_IMMEDIATE(r26, boot_cpuid)
1966 lwz r26,0(r26)
1967
1968 LOAD_REG_IMMEDIATE(r24, paca) /* Get base vaddr of paca array */
1969 mulli r13,r26,PACA_SIZE /* Calculate vaddr of right paca */
1970 add r13,r13,r24 /* for this processor. */
1971 mtspr SPRN_SPRG3,r13
1972
1973 /* ptr to current */ 1946 /* ptr to current */
1974 LOAD_REG_IMMEDIATE(r4, init_task) 1947 LOAD_REG_IMMEDIATE(r4, init_task)
1975 std r4,PACACURRENT(r13) 1948 std r4,PACACURRENT(r13)
@@ -1995,17 +1968,6 @@ _STATIC(start_here_common)
1995 /* Not reached */ 1968 /* Not reached */
1996 BUG_OPCODE 1969 BUG_OPCODE
1997 1970
1998/* Put the paca pointer into r13 and SPRG3 */
1999_GLOBAL(setup_boot_paca)
2000 LOAD_REG_IMMEDIATE(r3, boot_cpuid)
2001 lwz r3,0(r3)
2002 LOAD_REG_IMMEDIATE(r4, paca) /* Get base vaddr of paca array */
2003 mulli r3,r3,PACA_SIZE /* Calculate vaddr of right paca */
2004 add r13,r3,r4 /* for this processor. */
2005 mtspr SPRN_SPRG3,r13
2006
2007 blr
2008
2009/* 1971/*
2010 * We put a few things here that have to be page-aligned. 1972 * We put a few things here that have to be page-aligned.
2011 * This stuff goes at the beginning of the bss, which is page-aligned. 1973 * This stuff goes at the beginning of the bss, which is page-aligned.
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 7cb77c20fc5d..3d677ac99659 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -38,6 +38,7 @@
38#include <asm/iommu.h> 38#include <asm/iommu.h>
39#include <asm/pci-bridge.h> 39#include <asm/pci-bridge.h>
40#include <asm/machdep.h> 40#include <asm/machdep.h>
41#include <asm/kdump.h>
41 42
42#define DBG(...) 43#define DBG(...)
43 44
@@ -440,8 +441,37 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
440 tbl->it_largehint = tbl->it_halfpoint; 441 tbl->it_largehint = tbl->it_halfpoint;
441 spin_lock_init(&tbl->it_lock); 442 spin_lock_init(&tbl->it_lock);
442 443
444#ifdef CONFIG_CRASH_DUMP
445 if (ppc_md.tce_get) {
446 unsigned long index, tceval;
447 unsigned long tcecount = 0;
448
449 /*
450 * Reserve the existing mappings left by the first kernel.
451 */
452 for (index = 0; index < tbl->it_size; index++) {
453 tceval = ppc_md.tce_get(tbl, index + tbl->it_offset);
454 /*
455 * Freed TCE entry contains 0x7fffffffffffffff on JS20
456 */
457 if (tceval && (tceval != 0x7fffffffffffffffUL)) {
458 __set_bit(index, tbl->it_map);
459 tcecount++;
460 }
461 }
462 if ((tbl->it_size - tcecount) < KDUMP_MIN_TCE_ENTRIES) {
463 printk(KERN_WARNING "TCE table is full; ");
464 printk(KERN_WARNING "freeing %d entries for the kdump boot\n",
465 KDUMP_MIN_TCE_ENTRIES);
466 for (index = tbl->it_size - KDUMP_MIN_TCE_ENTRIES;
467 index < tbl->it_size; index++)
468 __clear_bit(index, tbl->it_map);
469 }
470 }
471#else
443 /* Clear the hardware table in case firmware left allocations in it */ 472 /* Clear the hardware table in case firmware left allocations in it */
444 ppc_md.tce_free(tbl, tbl->it_offset, tbl->it_size); 473 ppc_md.tce_free(tbl, tbl->it_offset, tbl->it_size);
474#endif
445 475
446 if (!welcomed) { 476 if (!welcomed) {
447 printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n", 477 printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 40d4c14fde8f..24f6050aa4ab 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -120,8 +120,8 @@ int show_interrupts(struct seq_file *p, void *v)
120#else 120#else
121 seq_printf(p, "%10u ", kstat_irqs(i)); 121 seq_printf(p, "%10u ", kstat_irqs(i));
122#endif /* CONFIG_SMP */ 122#endif /* CONFIG_SMP */
123 if (desc->handler) 123 if (desc->chip)
124 seq_printf(p, " %s ", desc->handler->typename); 124 seq_printf(p, " %s ", desc->chip->typename);
125 else 125 else
126 seq_puts(p, " None "); 126 seq_puts(p, " None ");
127 seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge "); 127 seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge ");
@@ -164,13 +164,13 @@ void fixup_irqs(cpumask_t map)
164 if (irq_desc[irq].status & IRQ_PER_CPU) 164 if (irq_desc[irq].status & IRQ_PER_CPU)
165 continue; 165 continue;
166 166
167 cpus_and(mask, irq_affinity[irq], map); 167 cpus_and(mask, irq_desc[irq].affinity, map);
168 if (any_online_cpu(mask) == NR_CPUS) { 168 if (any_online_cpu(mask) == NR_CPUS) {
169 printk("Breaking affinity for irq %i\n", irq); 169 printk("Breaking affinity for irq %i\n", irq);
170 mask = map; 170 mask = map;
171 } 171 }
172 if (irq_desc[irq].handler->set_affinity) 172 if (irq_desc[irq].chip->set_affinity)
173 irq_desc[irq].handler->set_affinity(irq, mask); 173 irq_desc[irq].chip->set_affinity(irq, mask);
174 else if (irq_desc[irq].action && !(warned++)) 174 else if (irq_desc[irq].action && !(warned++))
175 printk("Cannot set affinity for irq %i\n", irq); 175 printk("Cannot set affinity for irq %i\n", irq);
176 } 176 }
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 6e67b5b49ba1..3a9b78d03542 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -302,6 +302,17 @@ void __init find_legacy_serial_ports(void)
302 of_node_put(isa); 302 of_node_put(isa);
303 } 303 }
304 304
305 /* First fill our array with tsi-bridge ports */
306 for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16550")) != NULL;) {
307 struct device_node *tsi = of_get_parent(np);
308 if (tsi && !strcmp(tsi->type, "tsi-bridge")) {
309 index = add_legacy_soc_port(np, np);
310 if (index >= 0 && np == stdout)
311 legacy_serial_console = index;
312 }
313 of_node_put(tsi);
314 }
315
305#ifdef CONFIG_PCI 316#ifdef CONFIG_PCI
306 /* Next, try to locate PCI ports */ 317 /* Next, try to locate PCI ports */
307 for (np = NULL; (np = of_find_all_nodes(np));) { 318 for (np = NULL; (np = of_find_all_nodes(np));) {
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index c02deaab26c7..73edc3c16137 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -45,11 +45,9 @@
45static struct proc_dir_entry *proc_ppc64_lparcfg; 45static struct proc_dir_entry *proc_ppc64_lparcfg;
46#define LPARCFG_BUFF_SIZE 4096 46#define LPARCFG_BUFF_SIZE 4096
47 47
48#ifdef CONFIG_PPC_ISERIES
49
50/* 48/*
51 * For iSeries legacy systems, the PPA purr function is available from the 49 * Track sum of all purrs across all processors. This is used to further
52 * emulated_time_base field in the paca. 50 * calculate usage values by different applications
53 */ 51 */
54static unsigned long get_purr(void) 52static unsigned long get_purr(void)
55{ 53{
@@ -57,48 +55,31 @@ static unsigned long get_purr(void)
57 int cpu; 55 int cpu;
58 56
59 for_each_possible_cpu(cpu) { 57 for_each_possible_cpu(cpu) {
60 sum_purr += lppaca[cpu].emulated_time_base; 58 if (firmware_has_feature(FW_FEATURE_ISERIES))
59 sum_purr += lppaca[cpu].emulated_time_base;
60 else {
61 struct cpu_usage *cu;
61 62
62#ifdef PURR_DEBUG 63 cu = &per_cpu(cpu_usage_array, cpu);
63 printk(KERN_INFO "get_purr for cpu (%d) has value (%ld) \n", 64 sum_purr += cu->current_tb;
64 cpu, lppaca[cpu].emulated_time_base); 65 }
65#endif
66 } 66 }
67 return sum_purr; 67 return sum_purr;
68} 68}
69 69
70#define lparcfg_write NULL 70#ifdef CONFIG_PPC_ISERIES
71 71
72/* 72/*
73 * Methods used to fetch LPAR data when running on an iSeries platform. 73 * Methods used to fetch LPAR data when running on an iSeries platform.
74 */ 74 */
75static int lparcfg_data(struct seq_file *m, void *v) 75static int iseries_lparcfg_data(struct seq_file *m, void *v)
76{ 76{
77 unsigned long pool_id, lp_index; 77 unsigned long pool_id;
78 int shared, entitled_capacity, max_entitled_capacity; 78 int shared, entitled_capacity, max_entitled_capacity;
79 int processors, max_processors; 79 int processors, max_processors;
80 unsigned long purr = get_purr(); 80 unsigned long purr = get_purr();
81 81
82 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
83
84 shared = (int)(get_lppaca()->shared_proc); 82 shared = (int)(get_lppaca()->shared_proc);
85 seq_printf(m, "serial_number=%c%c%c%c%c%c%c\n",
86 e2a(xItExtVpdPanel.mfgID[2]),
87 e2a(xItExtVpdPanel.mfgID[3]),
88 e2a(xItExtVpdPanel.systemSerial[1]),
89 e2a(xItExtVpdPanel.systemSerial[2]),
90 e2a(xItExtVpdPanel.systemSerial[3]),
91 e2a(xItExtVpdPanel.systemSerial[4]),
92 e2a(xItExtVpdPanel.systemSerial[5]));
93
94 seq_printf(m, "system_type=%c%c%c%c\n",
95 e2a(xItExtVpdPanel.machineType[0]),
96 e2a(xItExtVpdPanel.machineType[1]),
97 e2a(xItExtVpdPanel.machineType[2]),
98 e2a(xItExtVpdPanel.machineType[3]));
99
100 lp_index = HvLpConfig_getLpIndex();
101 seq_printf(m, "partition_id=%d\n", (int)lp_index);
102 83
103 seq_printf(m, "system_active_processors=%d\n", 84 seq_printf(m, "system_active_processors=%d\n",
104 (int)HvLpConfig_getSystemPhysicalProcessors()); 85 (int)HvLpConfig_getSystemPhysicalProcessors());
@@ -137,6 +118,14 @@ static int lparcfg_data(struct seq_file *m, void *v)
137 118
138 return 0; 119 return 0;
139} 120}
121
122#else /* CONFIG_PPC_ISERIES */
123
124static int iseries_lparcfg_data(struct seq_file *m, void *v)
125{
126 return 0;
127}
128
140#endif /* CONFIG_PPC_ISERIES */ 129#endif /* CONFIG_PPC_ISERIES */
141 130
142#ifdef CONFIG_PPC_PSERIES 131#ifdef CONFIG_PPC_PSERIES
@@ -213,22 +202,6 @@ static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs)
213 log_plpar_hcall_return(rc, "H_PIC"); 202 log_plpar_hcall_return(rc, "H_PIC");
214} 203}
215 204
216/* Track sum of all purrs across all processors. This is used to further */
217/* calculate usage values by different applications */
218
219static unsigned long get_purr(void)
220{
221 unsigned long sum_purr = 0;
222 int cpu;
223 struct cpu_usage *cu;
224
225 for_each_possible_cpu(cpu) {
226 cu = &per_cpu(cpu_usage_array, cpu);
227 sum_purr += cu->current_tb;
228 }
229 return sum_purr;
230}
231
232#define SPLPAR_CHARACTERISTICS_TOKEN 20 205#define SPLPAR_CHARACTERISTICS_TOKEN 20
233#define SPLPAR_MAXLENGTH 1026*(sizeof(char)) 206#define SPLPAR_MAXLENGTH 1026*(sizeof(char))
234 207
@@ -333,35 +306,13 @@ static int lparcfg_count_active_processors(void)
333 return count; 306 return count;
334} 307}
335 308
336static int lparcfg_data(struct seq_file *m, void *v) 309static int pseries_lparcfg_data(struct seq_file *m, void *v)
337{ 310{
338 int partition_potential_processors; 311 int partition_potential_processors;
339 int partition_active_processors; 312 int partition_active_processors;
340 struct device_node *rootdn;
341 const char *model = "";
342 const char *system_id = "";
343 unsigned int *lp_index_ptr, lp_index = 0;
344 struct device_node *rtas_node; 313 struct device_node *rtas_node;
345 int *lrdrp = NULL; 314 int *lrdrp = NULL;
346 315
347 rootdn = find_path_device("/");
348 if (rootdn) {
349 model = get_property(rootdn, "model", NULL);
350 system_id = get_property(rootdn, "system-id", NULL);
351 lp_index_ptr = (unsigned int *)
352 get_property(rootdn, "ibm,partition-no", NULL);
353 if (lp_index_ptr)
354 lp_index = *lp_index_ptr;
355 }
356
357 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
358
359 seq_printf(m, "serial_number=%s\n", system_id);
360
361 seq_printf(m, "system_type=%s\n", model);
362
363 seq_printf(m, "partition_id=%d\n", (int)lp_index);
364
365 rtas_node = find_path_device("/rtas"); 316 rtas_node = find_path_device("/rtas");
366 if (rtas_node) 317 if (rtas_node)
367 lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity", 318 lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity",
@@ -549,8 +500,61 @@ out:
549 return retval; 500 return retval;
550} 501}
551 502
503#else /* CONFIG_PPC_PSERIES */
504
505static int pseries_lparcfg_data(struct seq_file *m, void *v)
506{
507 return 0;
508}
509
510static ssize_t lparcfg_write(struct file *file, const char __user * buf,
511 size_t count, loff_t * off)
512{
513 return count;
514}
515
552#endif /* CONFIG_PPC_PSERIES */ 516#endif /* CONFIG_PPC_PSERIES */
553 517
518static int lparcfg_data(struct seq_file *m, void *v)
519{
520 struct device_node *rootdn;
521 const char *model = "";
522 const char *system_id = "";
523 const char *tmp;
524 unsigned int *lp_index_ptr, lp_index = 0;
525
526 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
527
528 rootdn = find_path_device("/");
529 if (rootdn) {
530 tmp = get_property(rootdn, "model", NULL);
531 if (tmp) {
532 model = tmp;
533 /* Skip "IBM," - see platforms/iseries/dt.c */
534 if (firmware_has_feature(FW_FEATURE_ISERIES))
535 model += 4;
536 }
537 tmp = get_property(rootdn, "system-id", NULL);
538 if (tmp) {
539 system_id = tmp;
540 /* Skip "IBM," - see platforms/iseries/dt.c */
541 if (firmware_has_feature(FW_FEATURE_ISERIES))
542 system_id += 4;
543 }
544 lp_index_ptr = (unsigned int *)
545 get_property(rootdn, "ibm,partition-no", NULL);
546 if (lp_index_ptr)
547 lp_index = *lp_index_ptr;
548 }
549 seq_printf(m, "serial_number=%s\n", system_id);
550 seq_printf(m, "system_type=%s\n", model);
551 seq_printf(m, "partition_id=%d\n", (int)lp_index);
552
553 if (firmware_has_feature(FW_FEATURE_ISERIES))
554 return iseries_lparcfg_data(m, v);
555 return pseries_lparcfg_data(m, v);
556}
557
554static int lparcfg_open(struct inode *inode, struct file *file) 558static int lparcfg_open(struct inode *inode, struct file *file)
555{ 559{
556 return single_open(file, lparcfg_data, NULL); 560 return single_open(file, lparcfg_data, NULL);
@@ -569,7 +573,8 @@ int __init lparcfg_init(void)
569 mode_t mode = S_IRUSR | S_IRGRP | S_IROTH; 573 mode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
570 574
571 /* Allow writing if we have FW_FEATURE_SPLPAR */ 575 /* Allow writing if we have FW_FEATURE_SPLPAR */
572 if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 576 if (firmware_has_feature(FW_FEATURE_SPLPAR) &&
577 !firmware_has_feature(FW_FEATURE_ISERIES)) {
573 lparcfg_fops.write = lparcfg_write; 578 lparcfg_fops.write = lparcfg_write;
574 mode |= S_IWUSR; 579 mode |= S_IWUSR;
575 } 580 }
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index a8fa04ef27cd..b438d45a068c 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -378,11 +378,13 @@ static void __init export_crashk_values(void)
378 of_node_put(node); 378 of_node_put(node);
379} 379}
380 380
381void __init kexec_setup(void) 381static int __init kexec_setup(void)
382{ 382{
383 export_htab_values(); 383 export_htab_values();
384 export_crashk_values(); 384 export_crashk_values();
385 return 0;
385} 386}
387__initcall(kexec_setup);
386 388
387static int __init early_parse_crashk(char *p) 389static int __init early_parse_crashk(char *p)
388{ 390{
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
new file mode 100644
index 000000000000..fc23040d5a26
--- /dev/null
+++ b/arch/powerpc/kernel/misc.S
@@ -0,0 +1,203 @@
1/*
2 * This file contains miscellaneous low-level functions.
3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
4 *
5 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
6 * and Paul Mackerras.
7 *
8 * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
9 * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16#include <asm/ppc_asm.h>
17
18 .text
19
20#ifdef CONFIG_PPC64
21#define IN_SYNC twi 0,r5,0; isync
22#define EIEIO_32
23#define SYNC_64 sync
24#else /* CONFIG_PPC32 */
25#define IN_SYNC
26#define EIEIO_32 eieio
27#define SYNC_64
28#endif
29/*
30 * Returns (address we are running at) - (address we were linked at)
31 * for use before the text and data are mapped to KERNELBASE.
32 */
33
34_GLOBAL(reloc_offset)
35 mflr r0
36 bl 1f
371: mflr r3
38 LOAD_REG_IMMEDIATE(r4,1b)
39 subf r3,r4,r3
40 mtlr r0
41 blr
42
43/*
44 * add_reloc_offset(x) returns x + reloc_offset().
45 */
46_GLOBAL(add_reloc_offset)
47 mflr r0
48 bl 1f
491: mflr r5
50 LOAD_REG_IMMEDIATE(r4,1b)
51 subf r5,r4,r5
52 add r3,r3,r5
53 mtlr r0
54 blr
55
56/*
57 * I/O string operations
58 *
59 * insb(port, buf, len)
60 * outsb(port, buf, len)
61 * insw(port, buf, len)
62 * outsw(port, buf, len)
63 * insl(port, buf, len)
64 * outsl(port, buf, len)
65 * insw_ns(port, buf, len)
66 * outsw_ns(port, buf, len)
67 * insl_ns(port, buf, len)
68 * outsl_ns(port, buf, len)
69 *
70 * The *_ns versions don't do byte-swapping.
71 */
72_GLOBAL(_insb)
73 cmpwi 0,r5,0
74 mtctr r5
75 subi r4,r4,1
76 blelr-
7700: lbz r5,0(r3)
78 eieio
79 stbu r5,1(r4)
80 bdnz 00b
81 IN_SYNC
82 blr
83
84_GLOBAL(_outsb)
85 cmpwi 0,r5,0
86 mtctr r5
87 subi r4,r4,1
88 blelr-
8900: lbzu r5,1(r4)
90 stb r5,0(r3)
91 EIEIO_32
92 bdnz 00b
93 SYNC_64
94 blr
95
96_GLOBAL(_insw)
97 cmpwi 0,r5,0
98 mtctr r5
99 subi r4,r4,2
100 blelr-
10100: lhbrx r5,0,r3
102 eieio
103 sthu r5,2(r4)
104 bdnz 00b
105 IN_SYNC
106 blr
107
108_GLOBAL(_outsw)
109 cmpwi 0,r5,0
110 mtctr r5
111 subi r4,r4,2
112 blelr-
11300: lhzu r5,2(r4)
114 EIEIO_32
115 sthbrx r5,0,r3
116 bdnz 00b
117 SYNC_64
118 blr
119
120_GLOBAL(_insl)
121 cmpwi 0,r5,0
122 mtctr r5
123 subi r4,r4,4
124 blelr-
12500: lwbrx r5,0,r3
126 eieio
127 stwu r5,4(r4)
128 bdnz 00b
129 IN_SYNC
130 blr
131
132_GLOBAL(_outsl)
133 cmpwi 0,r5,0
134 mtctr r5
135 subi r4,r4,4
136 blelr-
13700: lwzu r5,4(r4)
138 stwbrx r5,0,r3
139 EIEIO_32
140 bdnz 00b
141 SYNC_64
142 blr
143
144#ifdef CONFIG_PPC32
145_GLOBAL(__ide_mm_insw)
146#endif
147_GLOBAL(_insw_ns)
148 cmpwi 0,r5,0
149 mtctr r5
150 subi r4,r4,2
151 blelr-
15200: lhz r5,0(r3)
153 eieio
154 sthu r5,2(r4)
155 bdnz 00b
156 IN_SYNC
157 blr
158
159#ifdef CONFIG_PPC32
160_GLOBAL(__ide_mm_outsw)
161#endif
162_GLOBAL(_outsw_ns)
163 cmpwi 0,r5,0
164 mtctr r5
165 subi r4,r4,2
166 blelr-
16700: lhzu r5,2(r4)
168 sth r5,0(r3)
169 EIEIO_32
170 bdnz 00b
171 SYNC_64
172 blr
173
174#ifdef CONFIG_PPC32
175_GLOBAL(__ide_mm_insl)
176#endif
177_GLOBAL(_insl_ns)
178 cmpwi 0,r5,0
179 mtctr r5
180 subi r4,r4,4
181 blelr-
18200: lwz r5,0(r3)
183 eieio
184 stwu r5,4(r4)
185 bdnz 00b
186 IN_SYNC
187 blr
188
189#ifdef CONFIG_PPC32
190_GLOBAL(__ide_mm_outsl)
191#endif
192_GLOBAL(_outsl_ns)
193 cmpwi 0,r5,0
194 mtctr r5
195 subi r4,r4,4
196 blelr-
19700: lwzu r5,4(r4)
198 stw r5,0(r3)
199 EIEIO_32
200 bdnz 00b
201 SYNC_64
202 blr
203
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 01d3916c4cb1..c74774e2175d 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -61,32 +61,6 @@ _GLOBAL(mulhdu)
61 blr 61 blr
62 62
63/* 63/*
64 * Returns (address we're running at) - (address we were linked at)
65 * for use before the text and data are mapped to KERNELBASE.
66 */
67_GLOBAL(reloc_offset)
68 mflr r0
69 bl 1f
701: mflr r3
71 LOAD_REG_IMMEDIATE(r4,1b)
72 subf r3,r4,r3
73 mtlr r0
74 blr
75
76/*
77 * add_reloc_offset(x) returns x + reloc_offset().
78 */
79_GLOBAL(add_reloc_offset)
80 mflr r0
81 bl 1f
821: mflr r5
83 LOAD_REG_IMMEDIATE(r4,1b)
84 subf r5,r4,r5
85 add r3,r3,r5
86 mtlr r0
87 blr
88
89/*
90 * sub_reloc_offset(x) returns x - reloc_offset(). 64 * sub_reloc_offset(x) returns x - reloc_offset().
91 */ 65 */
92_GLOBAL(sub_reloc_offset) 66_GLOBAL(sub_reloc_offset)
@@ -781,136 +755,6 @@ _GLOBAL(atomic_set_mask)
781 blr 755 blr
782 756
783/* 757/*
784 * I/O string operations
785 *
786 * insb(port, buf, len)
787 * outsb(port, buf, len)
788 * insw(port, buf, len)
789 * outsw(port, buf, len)
790 * insl(port, buf, len)
791 * outsl(port, buf, len)
792 * insw_ns(port, buf, len)
793 * outsw_ns(port, buf, len)
794 * insl_ns(port, buf, len)
795 * outsl_ns(port, buf, len)
796 *
797 * The *_ns versions don't do byte-swapping.
798 */
799_GLOBAL(_insb)
800 cmpwi 0,r5,0
801 mtctr r5
802 subi r4,r4,1
803 blelr-
80400: lbz r5,0(r3)
805 eieio
806 stbu r5,1(r4)
807 bdnz 00b
808 blr
809
810_GLOBAL(_outsb)
811 cmpwi 0,r5,0
812 mtctr r5
813 subi r4,r4,1
814 blelr-
81500: lbzu r5,1(r4)
816 stb r5,0(r3)
817 eieio
818 bdnz 00b
819 blr
820
821_GLOBAL(_insw)
822 cmpwi 0,r5,0
823 mtctr r5
824 subi r4,r4,2
825 blelr-
82600: lhbrx r5,0,r3
827 eieio
828 sthu r5,2(r4)
829 bdnz 00b
830 blr
831
832_GLOBAL(_outsw)
833 cmpwi 0,r5,0
834 mtctr r5
835 subi r4,r4,2
836 blelr-
83700: lhzu r5,2(r4)
838 eieio
839 sthbrx r5,0,r3
840 bdnz 00b
841 blr
842
843_GLOBAL(_insl)
844 cmpwi 0,r5,0
845 mtctr r5
846 subi r4,r4,4
847 blelr-
84800: lwbrx r5,0,r3
849 eieio
850 stwu r5,4(r4)
851 bdnz 00b
852 blr
853
854_GLOBAL(_outsl)
855 cmpwi 0,r5,0
856 mtctr r5
857 subi r4,r4,4
858 blelr-
85900: lwzu r5,4(r4)
860 stwbrx r5,0,r3
861 eieio
862 bdnz 00b
863 blr
864
865_GLOBAL(__ide_mm_insw)
866_GLOBAL(_insw_ns)
867 cmpwi 0,r5,0
868 mtctr r5
869 subi r4,r4,2
870 blelr-
87100: lhz r5,0(r3)
872 eieio
873 sthu r5,2(r4)
874 bdnz 00b
875 blr
876
877_GLOBAL(__ide_mm_outsw)
878_GLOBAL(_outsw_ns)
879 cmpwi 0,r5,0
880 mtctr r5
881 subi r4,r4,2
882 blelr-
88300: lhzu r5,2(r4)
884 sth r5,0(r3)
885 eieio
886 bdnz 00b
887 blr
888
889_GLOBAL(__ide_mm_insl)
890_GLOBAL(_insl_ns)
891 cmpwi 0,r5,0
892 mtctr r5
893 subi r4,r4,4
894 blelr-
89500: lwz r5,0(r3)
896 eieio
897 stwu r5,4(r4)
898 bdnz 00b
899 blr
900
901_GLOBAL(__ide_mm_outsl)
902_GLOBAL(_outsl_ns)
903 cmpwi 0,r5,0
904 mtctr r5
905 subi r4,r4,4
906 blelr-
90700: lwzu r5,4(r4)
908 stw r5,0(r3)
909 eieio
910 bdnz 00b
911 blr
912
913/*
914 * Extended precision shifts. 758 * Extended precision shifts.
915 * 759 *
916 * Updated to be valid for shift counts from 0 to 63 inclusive. 760 * Updated to be valid for shift counts from 0 to 63 inclusive.
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index e8883d42c43c..580891cb8ccb 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -1,14 +1,12 @@
1/* 1/*
2 * arch/powerpc/kernel/misc64.S
3 *
4 * This file contains miscellaneous low-level functions. 2 * This file contains miscellaneous low-level functions.
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * 4 *
7 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu) 5 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
8 * and Paul Mackerras. 6 * and Paul Mackerras.
9 * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com) 7 * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
10 * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com) 8 * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
11 * 9 *
12 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 12 * as published by the Free Software Foundation; either version
@@ -30,41 +28,10 @@
30 28
31 .text 29 .text
32 30
33/*
34 * Returns (address we are running at) - (address we were linked at)
35 * for use before the text and data are mapped to KERNELBASE.
36 */
37
38_GLOBAL(reloc_offset)
39 mflr r0
40 bl 1f
411: mflr r3
42 LOAD_REG_IMMEDIATE(r4,1b)
43 subf r3,r4,r3
44 mtlr r0
45 blr
46
47/*
48 * add_reloc_offset(x) returns x + reloc_offset().
49 */
50_GLOBAL(add_reloc_offset)
51 mflr r0
52 bl 1f
531: mflr r5
54 LOAD_REG_IMMEDIATE(r4,1b)
55 subf r5,r4,r5
56 add r3,r3,r5
57 mtlr r0
58 blr
59
60_GLOBAL(get_msr) 31_GLOBAL(get_msr)
61 mfmsr r3 32 mfmsr r3
62 blr 33 blr
63 34
64_GLOBAL(get_dar)
65 mfdar r3
66 blr
67
68_GLOBAL(get_srr0) 35_GLOBAL(get_srr0)
69 mfsrr0 r3 36 mfsrr0 r3
70 blr 37 blr
@@ -72,10 +39,6 @@ _GLOBAL(get_srr0)
72_GLOBAL(get_srr1) 39_GLOBAL(get_srr1)
73 mfsrr1 r3 40 mfsrr1 r3
74 blr 41 blr
75
76_GLOBAL(get_sp)
77 mr r3,r1
78 blr
79 42
80#ifdef CONFIG_IRQSTACKS 43#ifdef CONFIG_IRQSTACKS
81_GLOBAL(call_do_softirq) 44_GLOBAL(call_do_softirq)
@@ -101,48 +64,6 @@ _GLOBAL(call___do_IRQ)
101 blr 64 blr
102#endif /* CONFIG_IRQSTACKS */ 65#endif /* CONFIG_IRQSTACKS */
103 66
104 /*
105 * To be called by C code which needs to do some operations with MMU
106 * disabled. Note that interrupts have to be disabled by the caller
107 * prior to calling us. The code called _MUST_ be in the RMO of course
108 * and part of the linear mapping as we don't attempt to translate the
109 * stack pointer at all. The function is called with the stack switched
110 * to this CPU emergency stack
111 *
112 * prototype is void *call_with_mmu_off(void *func, void *data);
113 *
114 * the called function is expected to be of the form
115 *
116 * void *called(void *data);
117 */
118_GLOBAL(call_with_mmu_off)
119 mflr r0 /* get link, save it on stackframe */
120 std r0,16(r1)
121 mr r1,r5 /* save old stack ptr */
122 ld r1,PACAEMERGSP(r13) /* get emerg. stack */
123 subi r1,r1,STACK_FRAME_OVERHEAD
124 std r0,16(r1) /* save link on emerg. stack */
125 std r5,0(r1) /* save old stack ptr in backchain */
126 ld r3,0(r3) /* get to real function ptr (assume same TOC) */
127 bl 2f /* we need LR to return, continue at label 2 */
128
129 ld r0,16(r1) /* we return here from the call, get LR and */
130 ld r1,0(r1) /* .. old stack ptr */
131 mtspr SPRN_SRR0,r0 /* and get back to virtual mode with these */
132 mfmsr r4
133 ori r4,r4,MSR_IR|MSR_DR
134 mtspr SPRN_SRR1,r4
135 rfid
136
1372: mtspr SPRN_SRR0,r3 /* coming from above, enter real mode */
138 mr r3,r4 /* get parameter */
139 mfmsr r0
140 ori r0,r0,MSR_IR|MSR_DR
141 xori r0,r0,MSR_IR|MSR_DR
142 mtspr SPRN_SRR1,r0
143 rfid
144
145
146 .section ".toc","aw" 67 .section ".toc","aw"
147PPC64_CACHES: 68PPC64_CACHES:
148 .tc ppc64_caches[TC],ppc64_caches 69 .tc ppc64_caches[TC],ppc64_caches
@@ -323,144 +244,6 @@ _GLOBAL(__flush_dcache_icache)
323 bdnz 1b 244 bdnz 1b
324 isync 245 isync
325 blr 246 blr
326
327/*
328 * I/O string operations
329 *
330 * insb(port, buf, len)
331 * outsb(port, buf, len)
332 * insw(port, buf, len)
333 * outsw(port, buf, len)
334 * insl(port, buf, len)
335 * outsl(port, buf, len)
336 * insw_ns(port, buf, len)
337 * outsw_ns(port, buf, len)
338 * insl_ns(port, buf, len)
339 * outsl_ns(port, buf, len)
340 *
341 * The *_ns versions don't do byte-swapping.
342 */
343_GLOBAL(_insb)
344 cmpwi 0,r5,0
345 mtctr r5
346 subi r4,r4,1
347 blelr-
34800: lbz r5,0(r3)
349 eieio
350 stbu r5,1(r4)
351 bdnz 00b
352 twi 0,r5,0
353 isync
354 blr
355
356_GLOBAL(_outsb)
357 cmpwi 0,r5,0
358 mtctr r5
359 subi r4,r4,1
360 blelr-
36100: lbzu r5,1(r4)
362 stb r5,0(r3)
363 bdnz 00b
364 sync
365 blr
366
367_GLOBAL(_insw)
368 cmpwi 0,r5,0
369 mtctr r5
370 subi r4,r4,2
371 blelr-
37200: lhbrx r5,0,r3
373 eieio
374 sthu r5,2(r4)
375 bdnz 00b
376 twi 0,r5,0
377 isync
378 blr
379
380_GLOBAL(_outsw)
381 cmpwi 0,r5,0
382 mtctr r5
383 subi r4,r4,2
384 blelr-
38500: lhzu r5,2(r4)
386 sthbrx r5,0,r3
387 bdnz 00b
388 sync
389 blr
390
391_GLOBAL(_insl)
392 cmpwi 0,r5,0
393 mtctr r5
394 subi r4,r4,4
395 blelr-
39600: lwbrx r5,0,r3
397 eieio
398 stwu r5,4(r4)
399 bdnz 00b
400 twi 0,r5,0
401 isync
402 blr
403
404_GLOBAL(_outsl)
405 cmpwi 0,r5,0
406 mtctr r5
407 subi r4,r4,4
408 blelr-
40900: lwzu r5,4(r4)
410 stwbrx r5,0,r3
411 bdnz 00b
412 sync
413 blr
414
415/* _GLOBAL(ide_insw) now in drivers/ide/ide-iops.c */
416_GLOBAL(_insw_ns)
417 cmpwi 0,r5,0
418 mtctr r5
419 subi r4,r4,2
420 blelr-
42100: lhz r5,0(r3)
422 eieio
423 sthu r5,2(r4)
424 bdnz 00b
425 twi 0,r5,0
426 isync
427 blr
428
429/* _GLOBAL(ide_outsw) now in drivers/ide/ide-iops.c */
430_GLOBAL(_outsw_ns)
431 cmpwi 0,r5,0
432 mtctr r5
433 subi r4,r4,2
434 blelr-
43500: lhzu r5,2(r4)
436 sth r5,0(r3)
437 bdnz 00b
438 sync
439 blr
440
441_GLOBAL(_insl_ns)
442 cmpwi 0,r5,0
443 mtctr r5
444 subi r4,r4,4
445 blelr-
44600: lwz r5,0(r3)
447 eieio
448 stwu r5,4(r4)
449 bdnz 00b
450 twi 0,r5,0
451 isync
452 blr
453
454_GLOBAL(_outsl_ns)
455 cmpwi 0,r5,0
456 mtctr r5
457 subi r4,r4,4
458 blelr-
45900: lwzu r5,4(r4)
460 stw r5,0(r3)
461 bdnz 00b
462 sync
463 blr
464 247
465/* 248/*
466 * identify_cpu and calls setup_cpu 249 * identify_cpu and calls setup_cpu
@@ -605,6 +388,7 @@ _GLOBAL(real_writeb)
605 blr 388 blr
606#endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */ 389#endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */
607 390
391#ifdef CONFIG_CPU_FREQ_PMAC64
608/* 392/*
609 * SCOM access functions for 970 (FX only for now) 393 * SCOM access functions for 970 (FX only for now)
610 * 394 *
@@ -673,6 +457,7 @@ _GLOBAL(scom970_write)
673 /* restore interrupts */ 457 /* restore interrupts */
674 mtmsrd r5,1 458 mtmsrd r5,1
675 blr 459 blr
460#endif /* CONFIG_CPU_FREQ_PMAC64 */
676 461
677 462
678/* 463/*
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index f505a8827e3e..a0bb354c1c08 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -16,7 +16,6 @@
16#include <asm/ptrace.h> 16#include <asm/ptrace.h>
17#include <asm/page.h> 17#include <asm/page.h>
18#include <asm/lppaca.h> 18#include <asm/lppaca.h>
19#include <asm/iseries/it_lp_queue.h>
20#include <asm/iseries/it_lp_reg_save.h> 19#include <asm/iseries/it_lp_reg_save.h>
21#include <asm/paca.h> 20#include <asm/paca.h>
22 21
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index b5431ccf1147..8474355a1a4f 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -99,7 +99,7 @@ pcibios_fixup_resources(struct pci_dev *dev)
99 if (!res->flags) 99 if (!res->flags)
100 continue; 100 continue;
101 if (res->end == 0xffffffff) { 101 if (res->end == 0xffffffff) {
102 DBG("PCI:%s Resource %d [%08lx-%08lx] is unassigned\n", 102 DBG("PCI:%s Resource %d [%016llx-%016llx] is unassigned\n",
103 pci_name(dev), i, res->start, res->end); 103 pci_name(dev), i, res->start, res->end);
104 res->end -= res->start; 104 res->end -= res->start;
105 res->start = 0; 105 res->start = 0;
@@ -117,7 +117,7 @@ pcibios_fixup_resources(struct pci_dev *dev)
117 res->start += offset; 117 res->start += offset;
118 res->end += offset; 118 res->end += offset;
119#ifdef DEBUG 119#ifdef DEBUG
120 printk("Fixup res %d (%lx) of dev %s: %lx -> %lx\n", 120 printk("Fixup res %d (%lx) of dev %s: %llx -> %llx\n",
121 i, res->flags, pci_name(dev), 121 i, res->flags, pci_name(dev),
122 res->start - offset, res->start); 122 res->start - offset, res->start);
123#endif 123#endif
@@ -173,18 +173,18 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
173 * but we want to try to avoid allocating at 0x2900-0x2bff 173 * but we want to try to avoid allocating at 0x2900-0x2bff
174 * which might have be mirrored at 0x0100-0x03ff.. 174 * which might have be mirrored at 0x0100-0x03ff..
175 */ 175 */
176void pcibios_align_resource(void *data, struct resource *res, unsigned long size, 176void pcibios_align_resource(void *data, struct resource *res,
177 unsigned long align) 177 resource_size_t size, resource_size_t align)
178{ 178{
179 struct pci_dev *dev = data; 179 struct pci_dev *dev = data;
180 180
181 if (res->flags & IORESOURCE_IO) { 181 if (res->flags & IORESOURCE_IO) {
182 unsigned long start = res->start; 182 resource_size_t start = res->start;
183 183
184 if (size > 0x100) { 184 if (size > 0x100) {
185 printk(KERN_ERR "PCI: I/O Region %s/%d too large" 185 printk(KERN_ERR "PCI: I/O Region %s/%d too large"
186 " (%ld bytes)\n", pci_name(dev), 186 " (%lld bytes)\n", pci_name(dev),
187 dev->resource - res, size); 187 dev->resource - res, (unsigned long long)size);
188 } 188 }
189 189
190 if (start & 0x300) { 190 if (start & 0x300) {
@@ -255,8 +255,8 @@ pcibios_allocate_bus_resources(struct list_head *bus_list)
255 } 255 }
256 } 256 }
257 257
258 DBG("PCI: bridge rsrc %lx..%lx (%lx), parent %p\n", 258 DBG("PCI: bridge rsrc %llx..%llx (%lx), parent %p\n",
259 res->start, res->end, res->flags, pr); 259 res->start, res->end, res->flags, pr);
260 if (pr) { 260 if (pr) {
261 if (request_resource(pr, res) == 0) 261 if (request_resource(pr, res) == 0)
262 continue; 262 continue;
@@ -306,7 +306,7 @@ reparent_resources(struct resource *parent, struct resource *res)
306 *pp = NULL; 306 *pp = NULL;
307 for (p = res->child; p != NULL; p = p->sibling) { 307 for (p = res->child; p != NULL; p = p->sibling) {
308 p->parent = res; 308 p->parent = res;
309 DBG(KERN_INFO "PCI: reparented %s [%lx..%lx] under %s\n", 309 DBG(KERN_INFO "PCI: reparented %s [%llx..%llx] under %s\n",
310 p->name, p->start, p->end, res->name); 310 p->name, p->start, p->end, res->name);
311 } 311 }
312 return 0; 312 return 0;
@@ -362,13 +362,14 @@ pci_relocate_bridge_resource(struct pci_bus *bus, int i)
362 try = conflict->start - 1; 362 try = conflict->start - 1;
363 } 363 }
364 if (request_resource(pr, res)) { 364 if (request_resource(pr, res)) {
365 DBG(KERN_ERR "PCI: huh? couldn't move to %lx..%lx\n", 365 DBG(KERN_ERR "PCI: huh? couldn't move to %llx..%llx\n",
366 res->start, res->end); 366 res->start, res->end);
367 return -1; /* "can't happen" */ 367 return -1; /* "can't happen" */
368 } 368 }
369 update_bridge_base(bus, i); 369 update_bridge_base(bus, i);
370 printk(KERN_INFO "PCI: bridge %d resource %d moved to %lx..%lx\n", 370 printk(KERN_INFO "PCI: bridge %d resource %d moved to %llx..%llx\n",
371 bus->number, i, res->start, res->end); 371 bus->number, i, (unsigned long long)res->start,
372 (unsigned long long)res->end);
372 return 0; 373 return 0;
373} 374}
374 375
@@ -479,14 +480,14 @@ static inline void alloc_resource(struct pci_dev *dev, int idx)
479{ 480{
480 struct resource *pr, *r = &dev->resource[idx]; 481 struct resource *pr, *r = &dev->resource[idx];
481 482
482 DBG("PCI:%s: Resource %d: %08lx-%08lx (f=%lx)\n", 483 DBG("PCI:%s: Resource %d: %016llx-%016llx (f=%lx)\n",
483 pci_name(dev), idx, r->start, r->end, r->flags); 484 pci_name(dev), idx, r->start, r->end, r->flags);
484 pr = pci_find_parent_resource(dev, r); 485 pr = pci_find_parent_resource(dev, r);
485 if (!pr || request_resource(pr, r) < 0) { 486 if (!pr || request_resource(pr, r) < 0) {
486 printk(KERN_ERR "PCI: Cannot allocate resource region %d" 487 printk(KERN_ERR "PCI: Cannot allocate resource region %d"
487 " of device %s\n", idx, pci_name(dev)); 488 " of device %s\n", idx, pci_name(dev));
488 if (pr) 489 if (pr)
489 DBG("PCI: parent is %p: %08lx-%08lx (f=%lx)\n", 490 DBG("PCI: parent is %p: %016llx-%016llx (f=%lx)\n",
490 pr, pr->start, pr->end, pr->flags); 491 pr, pr->start, pr->end, pr->flags);
491 /* We'll assign a new address later */ 492 /* We'll assign a new address later */
492 r->flags |= IORESOURCE_UNSET; 493 r->flags |= IORESOURCE_UNSET;
@@ -956,7 +957,7 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
956 res = &hose->io_resource; 957 res = &hose->io_resource;
957 res->flags = IORESOURCE_IO; 958 res->flags = IORESOURCE_IO;
958 res->start = ranges[2]; 959 res->start = ranges[2];
959 DBG("PCI: IO 0x%lx -> 0x%lx\n", 960 DBG("PCI: IO 0x%llx -> 0x%llx\n",
960 res->start, res->start + size - 1); 961 res->start, res->start + size - 1);
961 break; 962 break;
962 case 2: /* memory space */ 963 case 2: /* memory space */
@@ -978,7 +979,7 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
978 if(ranges[0] & 0x40000000) 979 if(ranges[0] & 0x40000000)
979 res->flags |= IORESOURCE_PREFETCH; 980 res->flags |= IORESOURCE_PREFETCH;
980 res->start = ranges[na+2]; 981 res->start = ranges[na+2];
981 DBG("PCI: MEM[%d] 0x%lx -> 0x%lx\n", memno, 982 DBG("PCI: MEM[%d] 0x%llx -> 0x%llx\n", memno,
982 res->start, res->start + size - 1); 983 res->start, res->start + size - 1);
983 } 984 }
984 break; 985 break;
@@ -1074,7 +1075,7 @@ do_update_p2p_io_resource(struct pci_bus *bus, int enable_vga)
1074 DBG("Remapping Bus %d, bridge: %s\n", bus->number, pci_name(bridge)); 1075 DBG("Remapping Bus %d, bridge: %s\n", bus->number, pci_name(bridge));
1075 res.start -= ((unsigned long) hose->io_base_virt - isa_io_base); 1076 res.start -= ((unsigned long) hose->io_base_virt - isa_io_base);
1076 res.end -= ((unsigned long) hose->io_base_virt - isa_io_base); 1077 res.end -= ((unsigned long) hose->io_base_virt - isa_io_base);
1077 DBG(" IO window: %08lx-%08lx\n", res.start, res.end); 1078 DBG(" IO window: %016llx-%016llx\n", res.start, res.end);
1078 1079
1079 /* Set up the top and bottom of the PCI I/O segment for this bus. */ 1080 /* Set up the top and bottom of the PCI I/O segment for this bus. */
1080 pci_read_config_dword(bridge, PCI_IO_BASE, &l); 1081 pci_read_config_dword(bridge, PCI_IO_BASE, &l);
@@ -1223,8 +1224,8 @@ do_fixup_p2p_level(struct pci_bus *bus)
1223 continue; 1224 continue;
1224 if ((r->flags & IORESOURCE_IO) == 0) 1225 if ((r->flags & IORESOURCE_IO) == 0)
1225 continue; 1226 continue;
1226 DBG("Trying to allocate from %08lx, size %08lx from parent" 1227 DBG("Trying to allocate from %016llx, size %016llx from parent"
1227 " res %d: %08lx -> %08lx\n", 1228 " res %d: %016llx -> %016llx\n",
1228 res->start, res->end, i, r->start, r->end); 1229 res->start, res->end, i, r->start, r->end);
1229 1230
1230 if (allocate_resource(r, res, res->end + 1, res->start, max, 1231 if (allocate_resource(r, res, res->end + 1, res->start, max,
@@ -1574,8 +1575,8 @@ static pgprot_t __pci_mmap_set_pgprot(struct pci_dev *dev, struct resource *rp,
1574 else 1575 else
1575 prot |= _PAGE_GUARDED; 1576 prot |= _PAGE_GUARDED;
1576 1577
1577 printk("PCI map for %s:%lx, prot: %lx\n", pci_name(dev), rp->start, 1578 printk("PCI map for %s:%llx, prot: %lx\n", pci_name(dev),
1578 prot); 1579 (unsigned long long)rp->start, prot);
1579 1580
1580 return __pgprot(prot); 1581 return __pgprot(prot);
1581} 1582}
@@ -1755,7 +1756,7 @@ long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
1755 1756
1756void pci_resource_to_user(const struct pci_dev *dev, int bar, 1757void pci_resource_to_user(const struct pci_dev *dev, int bar,
1757 const struct resource *rsrc, 1758 const struct resource *rsrc,
1758 u64 *start, u64 *end) 1759 resource_size_t *start, resource_size_t *end)
1759{ 1760{
1760 struct pci_controller *hose = pci_bus_to_hose(dev->bus->number); 1761 struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
1761 unsigned long offset = 0; 1762 unsigned long offset = 0;
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 247937dd8b73..286aa52aae33 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -138,11 +138,11 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
138 * which might have be mirrored at 0x0100-0x03ff.. 138 * which might have be mirrored at 0x0100-0x03ff..
139 */ 139 */
140void pcibios_align_resource(void *data, struct resource *res, 140void pcibios_align_resource(void *data, struct resource *res,
141 unsigned long size, unsigned long align) 141 resource_size_t size, resource_size_t align)
142{ 142{
143 struct pci_dev *dev = data; 143 struct pci_dev *dev = data;
144 struct pci_controller *hose = pci_bus_to_host(dev->bus); 144 struct pci_controller *hose = pci_bus_to_host(dev->bus);
145 unsigned long start = res->start; 145 resource_size_t start = res->start;
146 unsigned long alignto; 146 unsigned long alignto;
147 147
148 if (res->flags & IORESOURCE_IO) { 148 if (res->flags & IORESOURCE_IO) {
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 483455c5bb02..320c913435cd 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -30,6 +30,7 @@
30#include <linux/bitops.h> 30#include <linux/bitops.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/kexec.h> 32#include <linux/kexec.h>
33#include <linux/debugfs.h>
33 34
34#include <asm/prom.h> 35#include <asm/prom.h>
35#include <asm/rtas.h> 36#include <asm/rtas.h>
@@ -952,6 +953,7 @@ static struct ibm_pa_feature {
952 /* put this back once we know how to test if firmware does 64k IO */ 953 /* put this back once we know how to test if firmware does 64k IO */
953 {CPU_FTR_CI_LARGE_PAGE, 0, 1, 2, 0}, 954 {CPU_FTR_CI_LARGE_PAGE, 0, 1, 2, 0},
954#endif 955#endif
956 {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
955}; 957};
956 958
957static void __init check_cpu_pa_features(unsigned long node) 959static void __init check_cpu_pa_features(unsigned long node)
@@ -1124,24 +1126,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
1124 tce_alloc_end = *lprop; 1126 tce_alloc_end = *lprop;
1125#endif 1127#endif
1126 1128
1127#ifdef CONFIG_PPC_RTAS
1128 /* To help early debugging via the front panel, we retrieve a minimal
1129 * set of RTAS infos now if available
1130 */
1131 {
1132 u64 *basep, *entryp, *sizep;
1133
1134 basep = of_get_flat_dt_prop(node, "linux,rtas-base", NULL);
1135 entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL);
1136 sizep = of_get_flat_dt_prop(node, "linux,rtas-size", NULL);
1137 if (basep && entryp && sizep) {
1138 rtas.base = *basep;
1139 rtas.entry = *entryp;
1140 rtas.size = *sizep;
1141 }
1142 }
1143#endif /* CONFIG_PPC_RTAS */
1144
1145#ifdef CONFIG_KEXEC 1129#ifdef CONFIG_KEXEC
1146 lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL); 1130 lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
1147 if (lprop) 1131 if (lprop)
@@ -1326,6 +1310,11 @@ void __init early_init_devtree(void *params)
1326 /* Setup flat device-tree pointer */ 1310 /* Setup flat device-tree pointer */
1327 initial_boot_params = params; 1311 initial_boot_params = params;
1328 1312
1313#ifdef CONFIG_PPC_RTAS
1314 /* Some machines might need RTAS info for debugging, grab it now. */
1315 of_scan_flat_dt(early_init_dt_scan_rtas, NULL);
1316#endif
1317
1329 /* Retrieve various informations from the /chosen node of the 1318 /* Retrieve various informations from the /chosen node of the
1330 * device-tree, including the platform type, initrd location and 1319 * device-tree, including the platform type, initrd location and
1331 * size, TCE reserve, and more ... 1320 * size, TCE reserve, and more ...
@@ -2148,3 +2137,27 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
2148 } 2137 }
2149 return NULL; 2138 return NULL;
2150} 2139}
2140
2141#ifdef DEBUG
2142static struct debugfs_blob_wrapper flat_dt_blob;
2143
2144static int __init export_flat_device_tree(void)
2145{
2146 struct dentry *d;
2147
2148 d = debugfs_create_dir("powerpc", NULL);
2149 if (!d)
2150 return 1;
2151
2152 flat_dt_blob.data = initial_boot_params;
2153 flat_dt_blob.size = initial_boot_params->totalsize;
2154
2155 d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
2156 d, &flat_dt_blob);
2157 if (!d)
2158 return 1;
2159
2160 return 0;
2161}
2162__initcall(export_flat_device_tree);
2163#endif
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 17dc79198515..4a4cb5598402 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -38,16 +38,19 @@
38struct rtas_t rtas = { 38struct rtas_t rtas = {
39 .lock = SPIN_LOCK_UNLOCKED 39 .lock = SPIN_LOCK_UNLOCKED
40}; 40};
41EXPORT_SYMBOL(rtas);
41 42
42struct rtas_suspend_me_data { 43struct rtas_suspend_me_data {
43 long waiting; 44 long waiting;
44 struct rtas_args *args; 45 struct rtas_args *args;
45}; 46};
46 47
47EXPORT_SYMBOL(rtas);
48
49DEFINE_SPINLOCK(rtas_data_buf_lock); 48DEFINE_SPINLOCK(rtas_data_buf_lock);
49EXPORT_SYMBOL(rtas_data_buf_lock);
50
50char rtas_data_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned; 51char rtas_data_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned;
52EXPORT_SYMBOL(rtas_data_buf);
53
51unsigned long rtas_rmo_buf; 54unsigned long rtas_rmo_buf;
52 55
53/* 56/*
@@ -106,11 +109,71 @@ static void call_rtas_display_status_delay(char c)
106 } 109 }
107} 110}
108 111
109void __init udbg_init_rtas(void) 112void __init udbg_init_rtas_panel(void)
110{ 113{
111 udbg_putc = call_rtas_display_status_delay; 114 udbg_putc = call_rtas_display_status_delay;
112} 115}
113 116
117#ifdef CONFIG_UDBG_RTAS_CONSOLE
118
119/* If you think you're dying before early_init_dt_scan_rtas() does its
120 * work, you can hard code the token values for your firmware here and
121 * hardcode rtas.base/entry etc.
122 */
123static unsigned int rtas_putchar_token = RTAS_UNKNOWN_SERVICE;
124static unsigned int rtas_getchar_token = RTAS_UNKNOWN_SERVICE;
125
126static void udbg_rtascon_putc(char c)
127{
128 int tries;
129
130 if (!rtas.base)
131 return;
132
133 /* Add CRs before LFs */
134 if (c == '\n')
135 udbg_rtascon_putc('\r');
136
137 /* if there is more than one character to be displayed, wait a bit */
138 for (tries = 0; tries < 16; tries++) {
139 if (rtas_call(rtas_putchar_token, 1, 1, NULL, c) == 0)
140 break;
141 udelay(1000);
142 }
143}
144
145static int udbg_rtascon_getc_poll(void)
146{
147 int c;
148
149 if (!rtas.base)
150 return -1;
151
152 if (rtas_call(rtas_getchar_token, 0, 2, &c))
153 return -1;
154
155 return c;
156}
157
158static int udbg_rtascon_getc(void)
159{
160 int c;
161
162 while ((c = udbg_rtascon_getc_poll()) == -1)
163 ;
164
165 return c;
166}
167
168
169void __init udbg_init_rtas_console(void)
170{
171 udbg_putc = udbg_rtascon_putc;
172 udbg_getc = udbg_rtascon_getc;
173 udbg_getc_poll = udbg_rtascon_getc_poll;
174}
175#endif /* CONFIG_UDBG_RTAS_CONSOLE */
176
114void rtas_progress(char *s, unsigned short hex) 177void rtas_progress(char *s, unsigned short hex)
115{ 178{
116 struct device_node *root; 179 struct device_node *root;
@@ -236,6 +299,7 @@ int rtas_token(const char *service)
236 tokp = (int *) get_property(rtas.dev, service, NULL); 299 tokp = (int *) get_property(rtas.dev, service, NULL);
237 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; 300 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
238} 301}
302EXPORT_SYMBOL(rtas_token);
239 303
240#ifdef CONFIG_RTAS_ERROR_LOGGING 304#ifdef CONFIG_RTAS_ERROR_LOGGING
241/* 305/*
@@ -328,7 +392,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
328 char *buff_copy = NULL; 392 char *buff_copy = NULL;
329 int ret; 393 int ret;
330 394
331 if (token == RTAS_UNKNOWN_SERVICE) 395 if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
332 return -1; 396 return -1;
333 397
334 /* Gotta do something different here, use global lock for now... */ 398 /* Gotta do something different here, use global lock for now... */
@@ -369,6 +433,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
369 } 433 }
370 return ret; 434 return ret;
371} 435}
436EXPORT_SYMBOL(rtas_call);
372 437
373/* For RTAS_BUSY (-2), delay for 1 millisecond. For an extended busy status 438/* For RTAS_BUSY (-2), delay for 1 millisecond. For an extended busy status
374 * code of 990n, perform the hinted delay of 10^n (last digit) milliseconds. 439 * code of 990n, perform the hinted delay of 10^n (last digit) milliseconds.
@@ -388,6 +453,7 @@ unsigned int rtas_busy_delay_time(int status)
388 453
389 return ms; 454 return ms;
390} 455}
456EXPORT_SYMBOL(rtas_busy_delay_time);
391 457
392/* For an RTAS busy status code, perform the hinted delay. */ 458/* For an RTAS busy status code, perform the hinted delay. */
393unsigned int rtas_busy_delay(int status) 459unsigned int rtas_busy_delay(int status)
@@ -401,6 +467,7 @@ unsigned int rtas_busy_delay(int status)
401 467
402 return ms; 468 return ms;
403} 469}
470EXPORT_SYMBOL(rtas_busy_delay);
404 471
405int rtas_error_rc(int rtas_rc) 472int rtas_error_rc(int rtas_rc)
406{ 473{
@@ -446,6 +513,7 @@ int rtas_get_power_level(int powerdomain, int *level)
446 return rtas_error_rc(rc); 513 return rtas_error_rc(rc);
447 return rc; 514 return rc;
448} 515}
516EXPORT_SYMBOL(rtas_get_power_level);
449 517
450int rtas_set_power_level(int powerdomain, int level, int *setlevel) 518int rtas_set_power_level(int powerdomain, int level, int *setlevel)
451{ 519{
@@ -463,6 +531,7 @@ int rtas_set_power_level(int powerdomain, int level, int *setlevel)
463 return rtas_error_rc(rc); 531 return rtas_error_rc(rc);
464 return rc; 532 return rc;
465} 533}
534EXPORT_SYMBOL(rtas_set_power_level);
466 535
467int rtas_get_sensor(int sensor, int index, int *state) 536int rtas_get_sensor(int sensor, int index, int *state)
468{ 537{
@@ -480,6 +549,7 @@ int rtas_get_sensor(int sensor, int index, int *state)
480 return rtas_error_rc(rc); 549 return rtas_error_rc(rc);
481 return rc; 550 return rc;
482} 551}
552EXPORT_SYMBOL(rtas_get_sensor);
483 553
484int rtas_set_indicator(int indicator, int index, int new_value) 554int rtas_set_indicator(int indicator, int index, int new_value)
485{ 555{
@@ -497,6 +567,7 @@ int rtas_set_indicator(int indicator, int index, int new_value)
497 return rtas_error_rc(rc); 567 return rtas_error_rc(rc);
498 return rc; 568 return rc;
499} 569}
570EXPORT_SYMBOL(rtas_set_indicator);
500 571
501void rtas_restart(char *cmd) 572void rtas_restart(char *cmd)
502{ 573{
@@ -791,14 +862,34 @@ void __init rtas_initialize(void)
791#endif 862#endif
792} 863}
793 864
865int __init early_init_dt_scan_rtas(unsigned long node,
866 const char *uname, int depth, void *data)
867{
868 u32 *basep, *entryp, *sizep;
794 869
795EXPORT_SYMBOL(rtas_token); 870 if (depth != 1 || strcmp(uname, "rtas") != 0)
796EXPORT_SYMBOL(rtas_call); 871 return 0;
797EXPORT_SYMBOL(rtas_data_buf); 872
798EXPORT_SYMBOL(rtas_data_buf_lock); 873 basep = of_get_flat_dt_prop(node, "linux,rtas-base", NULL);
799EXPORT_SYMBOL(rtas_busy_delay_time); 874 entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL);
800EXPORT_SYMBOL(rtas_busy_delay); 875 sizep = of_get_flat_dt_prop(node, "rtas-size", NULL);
801EXPORT_SYMBOL(rtas_get_sensor); 876
802EXPORT_SYMBOL(rtas_get_power_level); 877 if (basep && entryp && sizep) {
803EXPORT_SYMBOL(rtas_set_power_level); 878 rtas.base = *basep;
804EXPORT_SYMBOL(rtas_set_indicator); 879 rtas.entry = *entryp;
880 rtas.size = *sizep;
881 }
882
883#ifdef CONFIG_UDBG_RTAS_CONSOLE
884 basep = of_get_flat_dt_prop(node, "put-term-char", NULL);
885 if (basep)
886 rtas_putchar_token = *basep;
887
888 basep = of_get_flat_dt_prop(node, "get-term-char", NULL);
889 if (basep)
890 rtas_getchar_token = *basep;
891#endif
892
893 /* break now */
894 return 1;
895}
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index e5a44812441a..0932a62a1c96 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -215,7 +215,7 @@ int __init ppc_init(void)
215 215
216 /* register CPU devices */ 216 /* register CPU devices */
217 for_each_possible_cpu(i) 217 for_each_possible_cpu(i)
218 register_cpu(&cpu_devices[i], i, NULL); 218 register_cpu(&cpu_devices[i], i);
219 219
220 /* call platform init */ 220 /* call platform init */
221 if (ppc_md.init != NULL) { 221 if (ppc_md.init != NULL) {
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 78f3a5fd43f6..175539c9afa0 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -149,6 +149,13 @@ early_param("smt-enabled", early_smt_enabled);
149#define check_smt_enabled() 149#define check_smt_enabled()
150#endif /* CONFIG_SMP */ 150#endif /* CONFIG_SMP */
151 151
152/* Put the paca pointer into r13 and SPRG3 */
153void __init setup_paca(int cpu)
154{
155 local_paca = &paca[cpu];
156 mtspr(SPRN_SPRG3, local_paca);
157}
158
152/* 159/*
153 * Early initialization entry point. This is called by head.S 160 * Early initialization entry point. This is called by head.S
154 * with MMU translation disabled. We rely on the "feature" of 161 * with MMU translation disabled. We rely on the "feature" of
@@ -170,6 +177,9 @@ early_param("smt-enabled", early_smt_enabled);
170 177
171void __init early_setup(unsigned long dt_ptr) 178void __init early_setup(unsigned long dt_ptr)
172{ 179{
180 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */
181 setup_paca(0);
182
173 /* Enable early debugging if any specified (see udbg.h) */ 183 /* Enable early debugging if any specified (see udbg.h) */
174 udbg_early_init(); 184 udbg_early_init();
175 185
@@ -183,7 +193,7 @@ void __init early_setup(unsigned long dt_ptr)
183 early_init_devtree(__va(dt_ptr)); 193 early_init_devtree(__va(dt_ptr));
184 194
185 /* Now we know the logical id of our boot cpu, setup the paca. */ 195 /* Now we know the logical id of our boot cpu, setup the paca. */
186 setup_boot_paca(); 196 setup_paca(boot_cpuid);
187 197
188 /* Fix up paca fields required for the boot cpu */ 198 /* Fix up paca fields required for the boot cpu */
189 get_paca()->cpu_start = 1; 199 get_paca()->cpu_start = 1;
@@ -350,19 +360,11 @@ void __init setup_system(void)
350 */ 360 */
351 unflatten_device_tree(); 361 unflatten_device_tree();
352 362
353#ifdef CONFIG_KEXEC
354 kexec_setup(); /* requires unflattened device tree. */
355#endif
356
357 /* 363 /*
358 * Fill the ppc64_caches & systemcfg structures with informations 364 * Fill the ppc64_caches & systemcfg structures with informations
359 * retrieved from the device-tree. Need to be called before 365 * retrieved from the device-tree. Need to be called before
360 * finish_device_tree() since the later requires some of the 366 * finish_device_tree() since the later requires some of the
361 * informations filled up here to properly parse the interrupt 367 * informations filled up here to properly parse the interrupt tree.
362 * tree.
363 * It also sets up the cache line sizes which allows to call
364 * routines like flush_icache_range (used by the hash init
365 * later on).
366 */ 368 */
367 initialize_cache_info(); 369 initialize_cache_info();
368 370
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 5bc2585c8036..4662b580efa1 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -279,7 +279,7 @@ static void unregister_cpu_online(unsigned int cpu)
279} 279}
280#endif /* CONFIG_HOTPLUG_CPU */ 280#endif /* CONFIG_HOTPLUG_CPU */
281 281
282static int sysfs_cpu_notify(struct notifier_block *self, 282static int __devinit sysfs_cpu_notify(struct notifier_block *self,
283 unsigned long action, void *hcpu) 283 unsigned long action, void *hcpu)
284{ 284{
285 unsigned int cpu = (unsigned int)(long)hcpu; 285 unsigned int cpu = (unsigned int)(long)hcpu;
@@ -297,30 +297,19 @@ static int sysfs_cpu_notify(struct notifier_block *self,
297 return NOTIFY_OK; 297 return NOTIFY_OK;
298} 298}
299 299
300static struct notifier_block sysfs_cpu_nb = { 300static struct notifier_block __devinitdata sysfs_cpu_nb = {
301 .notifier_call = sysfs_cpu_notify, 301 .notifier_call = sysfs_cpu_notify,
302}; 302};
303 303
304/* NUMA stuff */ 304/* NUMA stuff */
305 305
306#ifdef CONFIG_NUMA 306#ifdef CONFIG_NUMA
307static struct node node_devices[MAX_NUMNODES];
308
309static void register_nodes(void) 307static void register_nodes(void)
310{ 308{
311 int i; 309 int i;
312 310
313 for (i = 0; i < MAX_NUMNODES; i++) { 311 for (i = 0; i < MAX_NUMNODES; i++)
314 if (node_online(i)) { 312 register_one_node(i);
315 int p_node = parent_node(i);
316 struct node *parent = NULL;
317
318 if (p_node != i)
319 parent = &node_devices[p_node];
320
321 register_node(&node_devices[i], i, parent);
322 }
323 }
324} 313}
325 314
326int sysfs_add_device_to_node(struct sys_device *dev, int nid) 315int sysfs_add_device_to_node(struct sys_device *dev, int nid)
@@ -359,23 +348,13 @@ static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
359static int __init topology_init(void) 348static int __init topology_init(void)
360{ 349{
361 int cpu; 350 int cpu;
362 struct node *parent = NULL;
363 351
364 register_nodes(); 352 register_nodes();
365
366 register_cpu_notifier(&sysfs_cpu_nb); 353 register_cpu_notifier(&sysfs_cpu_nb);
367 354
368 for_each_possible_cpu(cpu) { 355 for_each_possible_cpu(cpu) {
369 struct cpu *c = &per_cpu(cpu_devices, cpu); 356 struct cpu *c = &per_cpu(cpu_devices, cpu);
370 357
371#ifdef CONFIG_NUMA
372 /* The node to which a cpu belongs can't be known
373 * until the cpu is made present.
374 */
375 parent = NULL;
376 if (cpu_present(cpu))
377 parent = &node_devices[cpu_to_node(cpu)];
378#endif
379 /* 358 /*
380 * For now, we just see if the system supports making 359 * For now, we just see if the system supports making
381 * the RTAS calls for CPU hotplug. But, there may be a 360 * the RTAS calls for CPU hotplug. But, there may be a
@@ -387,7 +366,7 @@ static int __init topology_init(void)
387 c->no_control = 1; 366 c->no_control = 1;
388 367
389 if (cpu_online(cpu) || (c->no_control == 0)) { 368 if (cpu_online(cpu) || (c->no_control == 0)) {
390 register_cpu(c, cpu, parent); 369 register_cpu(c, cpu);
391 370
392 sysdev_create_file(&c->sysdev, &attr_physical_id); 371 sysdev_create_file(&c->sysdev, &attr_physical_id);
393 } 372 }
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 52f5659534f4..fa6bd97b6b9d 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -52,9 +52,13 @@
52#include <asm/firmware.h> 52#include <asm/firmware.h>
53#include <asm/processor.h> 53#include <asm/processor.h>
54#endif 54#endif
55#include <asm/kexec.h>
55 56
56#ifdef CONFIG_PPC64 /* XXX */ 57#ifdef CONFIG_PPC64 /* XXX */
57#define _IO_BASE pci_io_base 58#define _IO_BASE pci_io_base
59#ifdef CONFIG_KEXEC
60cpumask_t cpus_in_sr = CPU_MASK_NONE;
61#endif
58#endif 62#endif
59 63
60#ifdef CONFIG_DEBUGGER 64#ifdef CONFIG_DEBUGGER
@@ -97,7 +101,7 @@ static DEFINE_SPINLOCK(die_lock);
97 101
98int die(const char *str, struct pt_regs *regs, long err) 102int die(const char *str, struct pt_regs *regs, long err)
99{ 103{
100 static int die_counter, crash_dump_start = 0; 104 static int die_counter;
101 105
102 if (debugger(regs)) 106 if (debugger(regs))
103 return 1; 107 return 1;
@@ -137,21 +141,12 @@ int die(const char *str, struct pt_regs *regs, long err)
137 print_modules(); 141 print_modules();
138 show_regs(regs); 142 show_regs(regs);
139 bust_spinlocks(0); 143 bust_spinlocks(0);
144 spin_unlock_irq(&die_lock);
140 145
141 if (!crash_dump_start && kexec_should_crash(current)) { 146 if (kexec_should_crash(current) ||
142 crash_dump_start = 1; 147 kexec_sr_activated(smp_processor_id()))
143 spin_unlock_irq(&die_lock);
144 crash_kexec(regs); 148 crash_kexec(regs);
145 /* NOTREACHED */ 149 crash_kexec_secondary(regs);
146 }
147 spin_unlock_irq(&die_lock);
148 if (crash_dump_start)
149 /*
150 * Only for soft-reset: Other CPUs will be responded to an IPI
151 * sent by first kexec CPU.
152 */
153 for(;;)
154 ;
155 150
156 if (in_interrupt()) 151 if (in_interrupt())
157 panic("Fatal exception in interrupt"); 152 panic("Fatal exception in interrupt");
@@ -215,6 +210,10 @@ void system_reset_exception(struct pt_regs *regs)
215 return; 210 return;
216 } 211 }
217 212
213#ifdef CONFIG_KEXEC
214 cpu_set(smp_processor_id(), cpus_in_sr);
215#endif
216
218 die("System Reset", regs, SIGABRT); 217 die("System Reset", regs, SIGABRT);
219 218
220 /* Must die if the interrupt is not recoverable */ 219 /* Must die if the interrupt is not recoverable */
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index 67d9fd9ae2b5..759afd5e0d8a 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -34,9 +34,12 @@ void __init udbg_early_init(void)
34#elif defined(CONFIG_PPC_EARLY_DEBUG_G5) 34#elif defined(CONFIG_PPC_EARLY_DEBUG_G5)
35 /* For use on Apple G5 machines */ 35 /* For use on Apple G5 machines */
36 udbg_init_pmac_realmode(); 36 udbg_init_pmac_realmode();
37#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS) 37#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS_PANEL)
38 /* RTAS panel debug */ 38 /* RTAS panel debug */
39 udbg_init_rtas(); 39 udbg_init_rtas_panel();
40#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS_CONSOLE)
41 /* RTAS console debug */
42 udbg_init_rtas_console();
40#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE) 43#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE)
41 /* Maple real mode debug */ 44 /* Maple real mode debug */
42 udbg_init_maple_realmode(); 45 udbg_init_maple_realmode();
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index a0f3cbd00d39..c90f124f3c71 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -520,7 +520,7 @@ static inline int tlb_batching_enabled(void)
520} 520}
521#endif 521#endif
522 522
523void hpte_init_native(void) 523void __init hpte_init_native(void)
524{ 524{
525 ppc_md.hpte_invalidate = native_hpte_invalidate; 525 ppc_md.hpte_invalidate = native_hpte_invalidate;
526 ppc_md.hpte_updatepp = native_hpte_updatepp; 526 ppc_md.hpte_updatepp = native_hpte_updatepp;
@@ -530,5 +530,4 @@ void hpte_init_native(void)
530 ppc_md.hpte_clear_all = native_hpte_clear; 530 ppc_md.hpte_clear_all = native_hpte_clear;
531 if (tlb_batching_enabled()) 531 if (tlb_batching_enabled())
532 ppc_md.flush_hash_range = native_flush_hash_range; 532 ppc_md.flush_hash_range = native_flush_hash_range;
533 htab_finish_init();
534} 533}
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index d03fd2b4445e..3cc6d68f7117 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -167,34 +167,12 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
167 hash = hpt_hash(va, shift); 167 hash = hpt_hash(va, shift);
168 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); 168 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP);
169 169
170 /* The crap below can be cleaned once ppd_md.probe() can 170 DBG("htab_bolt_mapping: calling %p\n", ppc_md.hpte_insert);
171 * set up the hash callbacks, thus we can just used the 171
172 * normal insert callback here. 172 BUG_ON(!ppc_md.hpte_insert);
173 */ 173 ret = ppc_md.hpte_insert(hpteg, va, paddr,
174#ifdef CONFIG_PPC_ISERIES 174 tmp_mode, HPTE_V_BOLTED, psize);
175 if (machine_is(iseries)) 175
176 ret = iSeries_hpte_insert(hpteg, va,
177 paddr,
178 tmp_mode,
179 HPTE_V_BOLTED,
180 psize);
181 else
182#endif
183#ifdef CONFIG_PPC_PSERIES
184 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR))
185 ret = pSeries_lpar_hpte_insert(hpteg, va,
186 paddr,
187 tmp_mode,
188 HPTE_V_BOLTED,
189 psize);
190 else
191#endif
192#ifdef CONFIG_PPC_MULTIPLATFORM
193 ret = native_hpte_insert(hpteg, va,
194 paddr,
195 tmp_mode, HPTE_V_BOLTED,
196 psize);
197#endif
198 if (ret < 0) 176 if (ret < 0)
199 break; 177 break;
200 } 178 }
@@ -413,6 +391,41 @@ void create_section_mapping(unsigned long start, unsigned long end)
413} 391}
414#endif /* CONFIG_MEMORY_HOTPLUG */ 392#endif /* CONFIG_MEMORY_HOTPLUG */
415 393
394static inline void make_bl(unsigned int *insn_addr, void *func)
395{
396 unsigned long funcp = *((unsigned long *)func);
397 int offset = funcp - (unsigned long)insn_addr;
398
399 *insn_addr = (unsigned int)(0x48000001 | (offset & 0x03fffffc));
400 flush_icache_range((unsigned long)insn_addr, 4+
401 (unsigned long)insn_addr);
402}
403
404static void __init htab_finish_init(void)
405{
406 extern unsigned int *htab_call_hpte_insert1;
407 extern unsigned int *htab_call_hpte_insert2;
408 extern unsigned int *htab_call_hpte_remove;
409 extern unsigned int *htab_call_hpte_updatepp;
410
411#ifdef CONFIG_PPC_64K_PAGES
412 extern unsigned int *ht64_call_hpte_insert1;
413 extern unsigned int *ht64_call_hpte_insert2;
414 extern unsigned int *ht64_call_hpte_remove;
415 extern unsigned int *ht64_call_hpte_updatepp;
416
417 make_bl(ht64_call_hpte_insert1, ppc_md.hpte_insert);
418 make_bl(ht64_call_hpte_insert2, ppc_md.hpte_insert);
419 make_bl(ht64_call_hpte_remove, ppc_md.hpte_remove);
420 make_bl(ht64_call_hpte_updatepp, ppc_md.hpte_updatepp);
421#endif /* CONFIG_PPC_64K_PAGES */
422
423 make_bl(htab_call_hpte_insert1, ppc_md.hpte_insert);
424 make_bl(htab_call_hpte_insert2, ppc_md.hpte_insert);
425 make_bl(htab_call_hpte_remove, ppc_md.hpte_remove);
426 make_bl(htab_call_hpte_updatepp, ppc_md.hpte_updatepp);
427}
428
416void __init htab_initialize(void) 429void __init htab_initialize(void)
417{ 430{
418 unsigned long table; 431 unsigned long table;
@@ -525,6 +538,8 @@ void __init htab_initialize(void)
525 mmu_linear_psize)); 538 mmu_linear_psize));
526 } 539 }
527 540
541 htab_finish_init();
542
528 DBG(" <- htab_initialize()\n"); 543 DBG(" <- htab_initialize()\n");
529} 544}
530#undef KB 545#undef KB
@@ -787,16 +802,6 @@ void flush_hash_range(unsigned long number, int local)
787 } 802 }
788} 803}
789 804
790static inline void make_bl(unsigned int *insn_addr, void *func)
791{
792 unsigned long funcp = *((unsigned long *)func);
793 int offset = funcp - (unsigned long)insn_addr;
794
795 *insn_addr = (unsigned int)(0x48000001 | (offset & 0x03fffffc));
796 flush_icache_range((unsigned long)insn_addr, 4+
797 (unsigned long)insn_addr);
798}
799
800/* 805/*
801 * low_hash_fault is called when we the low level hash code failed 806 * low_hash_fault is called when we the low level hash code failed
802 * to instert a PTE due to an hypervisor error 807 * to instert a PTE due to an hypervisor error
@@ -815,28 +820,3 @@ void low_hash_fault(struct pt_regs *regs, unsigned long address)
815 } 820 }
816 bad_page_fault(regs, address, SIGBUS); 821 bad_page_fault(regs, address, SIGBUS);
817} 822}
818
819void __init htab_finish_init(void)
820{
821 extern unsigned int *htab_call_hpte_insert1;
822 extern unsigned int *htab_call_hpte_insert2;
823 extern unsigned int *htab_call_hpte_remove;
824 extern unsigned int *htab_call_hpte_updatepp;
825
826#ifdef CONFIG_PPC_64K_PAGES
827 extern unsigned int *ht64_call_hpte_insert1;
828 extern unsigned int *ht64_call_hpte_insert2;
829 extern unsigned int *ht64_call_hpte_remove;
830 extern unsigned int *ht64_call_hpte_updatepp;
831
832 make_bl(ht64_call_hpte_insert1, ppc_md.hpte_insert);
833 make_bl(ht64_call_hpte_insert2, ppc_md.hpte_insert);
834 make_bl(ht64_call_hpte_remove, ppc_md.hpte_remove);
835 make_bl(ht64_call_hpte_updatepp, ppc_md.hpte_updatepp);
836#endif /* CONFIG_PPC_64K_PAGES */
837
838 make_bl(htab_call_hpte_insert1, ppc_md.hpte_insert);
839 make_bl(htab_call_hpte_insert2, ppc_md.hpte_insert);
840 make_bl(htab_call_hpte_remove, ppc_md.hpte_remove);
841 make_bl(htab_call_hpte_updatepp, ppc_md.hpte_updatepp);
842}
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 9e30f968c184..d454caada265 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -41,6 +41,7 @@
41#include <linux/idr.h> 41#include <linux/idr.h>
42#include <linux/nodemask.h> 42#include <linux/nodemask.h>
43#include <linux/module.h> 43#include <linux/module.h>
44#include <linux/poison.h>
44 45
45#include <asm/pgalloc.h> 46#include <asm/pgalloc.h>
46#include <asm/page.h> 47#include <asm/page.h>
@@ -90,7 +91,7 @@ void free_initmem(void)
90 91
91 addr = (unsigned long)__init_begin; 92 addr = (unsigned long)__init_begin;
92 for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) { 93 for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
93 memset((void *)addr, 0xcc, PAGE_SIZE); 94 memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
94 ClearPageReserved(virt_to_page(addr)); 95 ClearPageReserved(virt_to_page(addr));
95 init_page_count(virt_to_page(addr)); 96 init_page_count(virt_to_page(addr));
96 free_page(addr); 97 free_page(addr);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 69f3b9a20beb..089d939a0b3e 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -114,15 +114,20 @@ void online_page(struct page *page)
114 num_physpages++; 114 num_physpages++;
115} 115}
116 116
117int __devinit add_memory(u64 start, u64 size) 117#ifdef CONFIG_NUMA
118int memory_add_physaddr_to_nid(u64 start)
119{
120 return hot_add_scn_to_nid(start);
121}
122#endif
123
124int __devinit arch_add_memory(int nid, u64 start, u64 size)
118{ 125{
119 struct pglist_data *pgdata; 126 struct pglist_data *pgdata;
120 struct zone *zone; 127 struct zone *zone;
121 int nid;
122 unsigned long start_pfn = start >> PAGE_SHIFT; 128 unsigned long start_pfn = start >> PAGE_SHIFT;
123 unsigned long nr_pages = size >> PAGE_SHIFT; 129 unsigned long nr_pages = size >> PAGE_SHIFT;
124 130
125 nid = hot_add_scn_to_nid(start);
126 pgdata = NODE_DATA(nid); 131 pgdata = NODE_DATA(nid);
127 132
128 start = (unsigned long)__va(start); 133 start = (unsigned long)__va(start);
diff --git a/arch/powerpc/mm/mmu_context_64.c b/arch/powerpc/mm/mmu_context_64.c
index 65d18dca266f..e2051efa09c5 100644
--- a/arch/powerpc/mm/mmu_context_64.c
+++ b/arch/powerpc/mm/mmu_context_64.c
@@ -44,7 +44,9 @@ again:
44 return err; 44 return err;
45 45
46 if (index > MAX_CONTEXT) { 46 if (index > MAX_CONTEXT) {
47 spin_lock(&mmu_context_lock);
47 idr_remove(&mmu_context_idr, index); 48 idr_remove(&mmu_context_idr, index);
49 spin_unlock(&mmu_context_lock);
48 return -ENOMEM; 50 return -ENOMEM;
49 } 51 }
50 52
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index aa98cb3b59d8..fbe23933f731 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -334,7 +334,7 @@ out:
334 return nid; 334 return nid;
335} 335}
336 336
337static int cpu_numa_callback(struct notifier_block *nfb, 337static int __cpuinit cpu_numa_callback(struct notifier_block *nfb,
338 unsigned long action, 338 unsigned long action,
339 void *hcpu) 339 void *hcpu)
340{ 340{
@@ -609,14 +609,15 @@ static void __init *careful_allocation(int nid, unsigned long size,
609 return (void *)ret; 609 return (void *)ret;
610} 610}
611 611
612static struct notifier_block __cpuinitdata ppc64_numa_nb = {
613 .notifier_call = cpu_numa_callback,
614 .priority = 1 /* Must run before sched domains notifier. */
615};
616
612void __init do_init_bootmem(void) 617void __init do_init_bootmem(void)
613{ 618{
614 int nid; 619 int nid;
615 unsigned int i; 620 unsigned int i;
616 static struct notifier_block ppc64_numa_nb = {
617 .notifier_call = cpu_numa_callback,
618 .priority = 1 /* Must run before sched domains notifier. */
619 };
620 621
621 min_low_pfn = 0; 622 min_low_pfn = 0;
622 max_low_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT; 623 max_low_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 16f7d3b30e1d..3baceb00fefa 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -91,9 +91,10 @@ int __init add_bridge(struct device_node *dev)
91 mpc83xx_pci2_busno = hose->first_busno; 91 mpc83xx_pci2_busno = hose->first_busno;
92 } 92 }
93 93
94 printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%08lx. " 94 printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%016llx. "
95 "Firmware bus number: %d->%d\n", 95 "Firmware bus number: %d->%d\n",
96 rsrc.start, hose->first_busno, hose->last_busno); 96 (unsigned long long)rsrc.start, hose->first_busno,
97 hose->last_busno);
97 98
98 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n", 99 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
99 hose, hose->cfg_addr, hose->cfg_data); 100 hose, hose->cfg_addr, hose->cfg_data);
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
index bad290110ed1..48c8849c07ca 100644
--- a/arch/powerpc/platforms/85xx/pci.c
+++ b/arch/powerpc/platforms/85xx/pci.c
@@ -79,9 +79,10 @@ int __init add_bridge(struct device_node *dev)
79 mpc85xx_pci2_busno = hose->first_busno; 79 mpc85xx_pci2_busno = hose->first_busno;
80 } 80 }
81 81
82 printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%08lx. " 82 printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%016llx. "
83 "Firmware bus number: %d->%d\n", 83 "Firmware bus number: %d->%d\n",
84 rsrc.start, hose->first_busno, hose->last_busno); 84 (unsigned long long)rsrc.start, hose->first_busno,
85 hose->last_busno);
85 86
86 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n", 87 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
87 hose, hose->cfg_addr, hose->cfg_data); 88 hose, hose->cfg_addr, hose->cfg_data);
diff --git a/arch/powerpc/platforms/86xx/Kconfig b/arch/powerpc/platforms/86xx/Kconfig
index 3a87863d2876..d1ecc0f9ab58 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -7,6 +7,7 @@ choice
7 7
8config MPC8641_HPCN 8config MPC8641_HPCN
9 bool "Freescale MPC8641 HPCN" 9 bool "Freescale MPC8641 HPCN"
10 select PPC_I8259
10 help 11 help
11 This option enables support for the MPC8641 HPCN board. 12 This option enables support for the MPC8641 HPCN board.
12 13
@@ -28,9 +29,4 @@ config PPC_INDIRECT_PCI_BE
28 depends on PPC_86xx 29 depends on PPC_86xx
29 default y 30 default y
30 31
31config PPC_STD_MMU
32 bool
33 depends on PPC_86xx
34 default y
35
36endmenu 32endmenu
diff --git a/arch/powerpc/platforms/86xx/Makefile b/arch/powerpc/platforms/86xx/Makefile
index 7be796c5d5c9..476a6eeee710 100644
--- a/arch/powerpc/platforms/86xx/Makefile
+++ b/arch/powerpc/platforms/86xx/Makefile
@@ -2,9 +2,6 @@
2# Makefile for the PowerPC 86xx linux kernel. 2# Makefile for the PowerPC 86xx linux kernel.
3# 3#
4 4
5
6ifeq ($(CONFIG_PPC_86xx),y)
7obj-$(CONFIG_SMP) += mpc86xx_smp.o 5obj-$(CONFIG_SMP) += mpc86xx_smp.o
8endif
9obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o 6obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
10obj-$(CONFIG_PCI) += pci.o mpc86xx_pcie.o 7obj-$(CONFIG_PCI) += pci.o mpc86xx_pcie.o
diff --git a/arch/powerpc/platforms/86xx/mpc8641_hpcn.h b/arch/powerpc/platforms/86xx/mpc8641_hpcn.h
index 5042253758b7..5d2bcf78cef7 100644
--- a/arch/powerpc/platforms/86xx/mpc8641_hpcn.h
+++ b/arch/powerpc/platforms/86xx/mpc8641_hpcn.h
@@ -14,7 +14,6 @@
14#ifndef __MPC8641_HPCN_H__ 14#ifndef __MPC8641_HPCN_H__
15#define __MPC8641_HPCN_H__ 15#define __MPC8641_HPCN_H__
16 16
17#include <linux/config.h>
18#include <linux/init.h> 17#include <linux/init.h>
19 18
20/* PCI interrupt controller */ 19/* PCI interrupt controller */
diff --git a/arch/powerpc/platforms/86xx/mpc86xx.h b/arch/powerpc/platforms/86xx/mpc86xx.h
index e3c9e4f417d3..2834462590b8 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx.h
+++ b/arch/powerpc/platforms/86xx/mpc86xx.h
@@ -15,11 +15,13 @@
15 * mpc86xx_* files. Mostly for use by mpc86xx_setup(). 15 * mpc86xx_* files. Mostly for use by mpc86xx_setup().
16 */ 16 */
17 17
18extern int __init add_bridge(struct device_node *dev); 18extern int add_bridge(struct device_node *dev);
19 19
20extern void __init setup_indirect_pcie(struct pci_controller *hose, 20extern int mpc86xx_exclude_device(u_char bus, u_char devfn);
21
22extern void setup_indirect_pcie(struct pci_controller *hose,
21 u32 cfg_addr, u32 cfg_data); 23 u32 cfg_addr, u32 cfg_data);
22extern void __init setup_indirect_pcie_nomap(struct pci_controller *hose, 24extern void setup_indirect_pcie_nomap(struct pci_controller *hose,
23 void __iomem *cfg_addr, 25 void __iomem *cfg_addr,
24 void __iomem *cfg_data); 26 void __iomem *cfg_data);
25 27
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 483c21df181e..ebae73eb0063 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -12,7 +12,6 @@
12 * option) any later version. 12 * option) any later version.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/stddef.h> 15#include <linux/stddef.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/pci.h> 17#include <linux/pci.h>
@@ -36,6 +35,7 @@
36#include <sysdev/fsl_soc.h> 35#include <sysdev/fsl_soc.h>
37 36
38#include "mpc86xx.h" 37#include "mpc86xx.h"
38#include "mpc8641_hpcn.h"
39 39
40#ifndef CONFIG_PCI 40#ifndef CONFIG_PCI
41unsigned long isa_io_base = 0; 41unsigned long isa_io_base = 0;
@@ -186,17 +186,130 @@ mpc86xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
186 return PCI_IRQ_TABLE_LOOKUP + I8259_OFFSET; 186 return PCI_IRQ_TABLE_LOOKUP + I8259_OFFSET;
187} 187}
188 188
189static void __devinit quirk_ali1575(struct pci_dev *dev)
190{
191 unsigned short temp;
192
193 /*
194 * ALI1575 interrupts route table setup:
195 *
196 * IRQ pin IRQ#
197 * PIRQA ---- 3
198 * PIRQB ---- 4
199 * PIRQC ---- 5
200 * PIRQD ---- 6
201 * PIRQE ---- 9
202 * PIRQF ---- 10
203 * PIRQG ---- 11
204 * PIRQH ---- 12
205 *
206 * interrupts for PCI slot0 -- PIRQA / PIRQB / PIRQC / PIRQD
207 * PCI slot1 -- PIRQB / PIRQC / PIRQD / PIRQA
208 */
209 pci_write_config_dword(dev, 0x48, 0xb9317542);
210
211 /* USB 1.1 OHCI controller 1, interrupt: PIRQE */
212 pci_write_config_byte(dev, 0x86, 0x0c);
213
214 /* USB 1.1 OHCI controller 2, interrupt: PIRQF */
215 pci_write_config_byte(dev, 0x87, 0x0d);
216
217 /* USB 1.1 OHCI controller 3, interrupt: PIRQH */
218 pci_write_config_byte(dev, 0x88, 0x0f);
219
220 /* USB 2.0 controller, interrupt: PIRQ7 */
221 pci_write_config_byte(dev, 0x74, 0x06);
222
223 /* Audio controller, interrupt: PIRQE */
224 pci_write_config_byte(dev, 0x8a, 0x0c);
225
226 /* Modem controller, interrupt: PIRQF */
227 pci_write_config_byte(dev, 0x8b, 0x0d);
228
229 /* HD audio controller, interrupt: PIRQG */
230 pci_write_config_byte(dev, 0x8c, 0x0e);
231
232 /* Serial ATA interrupt: PIRQD */
233 pci_write_config_byte(dev, 0x8d, 0x0b);
234
235 /* SMB interrupt: PIRQH */
236 pci_write_config_byte(dev, 0x8e, 0x0f);
237
238 /* PMU ACPI SCI interrupt: PIRQH */
239 pci_write_config_byte(dev, 0x8f, 0x0f);
240
241 /* Primary PATA IDE IRQ: 14
242 * Secondary PATA IDE IRQ: 15
243 */
244 pci_write_config_byte(dev, 0x44, 0x3d);
245 pci_write_config_byte(dev, 0x75, 0x0f);
246
247 /* Set IRQ14 and IRQ15 to legacy IRQs */
248 pci_read_config_word(dev, 0x46, &temp);
249 temp |= 0xc000;
250 pci_write_config_word(dev, 0x46, temp);
251
252 /* Set i8259 interrupt trigger
253 * IRQ 3: Level
254 * IRQ 4: Level
255 * IRQ 5: Level
256 * IRQ 6: Level
257 * IRQ 7: Level
258 * IRQ 9: Level
259 * IRQ 10: Level
260 * IRQ 11: Level
261 * IRQ 12: Level
262 * IRQ 14: Edge
263 * IRQ 15: Edge
264 */
265 outb(0xfa, 0x4d0);
266 outb(0x1e, 0x4d1);
267}
189 268
190int 269static void __devinit quirk_uli5288(struct pci_dev *dev)
191mpc86xx_exclude_device(u_char bus, u_char devfn)
192{ 270{
193#if !defined(CONFIG_PCI) 271 unsigned char c;
194 if (bus == 0 && PCI_SLOT(devfn) == 0) 272
195 return PCIBIOS_DEVICE_NOT_FOUND; 273 pci_read_config_byte(dev,0x83,&c);
196#endif 274 c |= 0x80;
275 pci_write_config_byte(dev, 0x83, c);
276
277 pci_write_config_byte(dev, 0x09, 0x01);
278 pci_write_config_byte(dev, 0x0a, 0x06);
279
280 pci_read_config_byte(dev,0x83,&c);
281 c &= 0x7f;
282 pci_write_config_byte(dev, 0x83, c);
197 283
198 return PCIBIOS_SUCCESSFUL; 284 pci_read_config_byte(dev,0x84,&c);
285 c |= 0x01;
286 pci_write_config_byte(dev, 0x84, c);
199} 287}
288
289static void __devinit quirk_uli5229(struct pci_dev *dev)
290{
291 unsigned short temp;
292 pci_write_config_word(dev, 0x04, 0x0405);
293 pci_read_config_word(dev, 0x4a, &temp);
294 temp |= 0x1000;
295 pci_write_config_word(dev, 0x4a, temp);
296}
297
298static void __devinit early_uli5249(struct pci_dev *dev)
299{
300 unsigned char temp;
301 pci_write_config_word(dev, 0x04, 0x0007);
302 pci_read_config_byte(dev, 0x7c, &temp);
303 pci_write_config_byte(dev, 0x7c, 0x80);
304 pci_write_config_byte(dev, 0x09, 0x01);
305 pci_write_config_byte(dev, 0x7c, temp);
306 dev->class |= 0x1;
307}
308
309DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_ali1575);
310DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
311DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
312DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, 0x5249, early_uli5249);
200#endif /* CONFIG_PCI */ 313#endif /* CONFIG_PCI */
201 314
202 315
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_smp.c b/arch/powerpc/platforms/86xx/mpc86xx_smp.c
index 944ec4b71416..bb7fb41933ad 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_smp.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_smp.c
@@ -10,7 +10,6 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13#include <linux/config.h>
14#include <linux/stddef.h> 13#include <linux/stddef.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/init.h> 15#include <linux/init.h>
@@ -34,8 +33,8 @@ extern unsigned long __secondary_hold_acknowledge;
34static void __init 33static void __init
35smp_86xx_release_core(int nr) 34smp_86xx_release_core(int nr)
36{ 35{
37 void *mcm_vaddr; 36 __be32 __iomem *mcm_vaddr;
38 unsigned long vaddr, pcr; 37 unsigned long pcr;
39 38
40 if (nr < 0 || nr >= NR_CPUS) 39 if (nr < 0 || nr >= NR_CPUS)
41 return; 40 return;
@@ -45,10 +44,9 @@ smp_86xx_release_core(int nr)
45 */ 44 */
46 mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET, 45 mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET,
47 MPC86xx_MCM_SIZE); 46 MPC86xx_MCM_SIZE);
48 vaddr = (unsigned long)mcm_vaddr + MCM_PORT_CONFIG_OFFSET; 47 pcr = in_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2));
49 pcr = in_be32((volatile unsigned *)vaddr);
50 pcr |= 1 << (nr + 24); 48 pcr |= 1 << (nr + 24);
51 out_be32((volatile unsigned *)vaddr, pcr); 49 out_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2), pcr);
52} 50}
53 51
54 52
diff --git a/arch/powerpc/platforms/86xx/pci.c b/arch/powerpc/platforms/86xx/pci.c
index 5180df7c75bc..bc5139043112 100644
--- a/arch/powerpc/platforms/86xx/pci.c
+++ b/arch/powerpc/platforms/86xx/pci.c
@@ -12,7 +12,6 @@
12 * option) any later version. 12 * option) any later version.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/types.h> 15#include <linux/types.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/init.h> 17#include <linux/init.h>
@@ -122,15 +121,12 @@ static void __init setup_pcie_atmu(struct pci_controller *hose, struct resource
122static void __init 121static void __init
123mpc86xx_setup_pcie(struct pci_controller *hose, u32 pcie_offset, u32 pcie_size) 122mpc86xx_setup_pcie(struct pci_controller *hose, u32 pcie_offset, u32 pcie_size)
124{ 123{
125 volatile struct ccsr_pex *pcie;
126 u16 cmd; 124 u16 cmd;
127 unsigned int temps; 125 unsigned int temps;
128 126
129 DBG("PCIE host controller register offset 0x%08x, size 0x%08x.\n", 127 DBG("PCIE host controller register offset 0x%08x, size 0x%08x.\n",
130 pcie_offset, pcie_size); 128 pcie_offset, pcie_size);
131 129
132 pcie = ioremap(pcie_offset, pcie_size);
133
134 early_read_config_word(hose, 0, 0, PCI_COMMAND, &cmd); 130 early_read_config_word(hose, 0, 0, PCI_COMMAND, &cmd);
135 cmd |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY 131 cmd |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY
136 | PCI_COMMAND_IO; 132 | PCI_COMMAND_IO;
@@ -144,6 +140,14 @@ mpc86xx_setup_pcie(struct pci_controller *hose, u32 pcie_offset, u32 pcie_size)
144 early_write_config_dword(hose, 0, 0, PCI_PRIMARY_BUS, temps); 140 early_write_config_dword(hose, 0, 0, PCI_PRIMARY_BUS, temps);
145} 141}
146 142
143int mpc86xx_exclude_device(u_char bus, u_char devfn)
144{
145 if (bus == 0 && PCI_SLOT(devfn) == 0)
146 return PCIBIOS_DEVICE_NOT_FOUND;
147
148 return PCIBIOS_SUCCESSFUL;
149}
150
147int __init add_bridge(struct device_node *dev) 151int __init add_bridge(struct device_node *dev)
148{ 152{
149 int len; 153 int len;
@@ -198,128 +202,3 @@ int __init add_bridge(struct device_node *dev)
198 202
199 return 0; 203 return 0;
200} 204}
201
202static void __devinit quirk_ali1575(struct pci_dev *dev)
203{
204 unsigned short temp;
205
206 /*
207 * ALI1575 interrupts route table setup:
208 *
209 * IRQ pin IRQ#
210 * PIRQA ---- 3
211 * PIRQB ---- 4
212 * PIRQC ---- 5
213 * PIRQD ---- 6
214 * PIRQE ---- 9
215 * PIRQF ---- 10
216 * PIRQG ---- 11
217 * PIRQH ---- 12
218 *
219 * interrupts for PCI slot0 -- PIRQA / PIRQB / PIRQC / PIRQD
220 * PCI slot1 -- PIRQB / PIRQC / PIRQD / PIRQA
221 */
222 pci_write_config_dword(dev, 0x48, 0xb9317542);
223
224 /* USB 1.1 OHCI controller 1, interrupt: PIRQE */
225 pci_write_config_byte(dev, 0x86, 0x0c);
226
227 /* USB 1.1 OHCI controller 2, interrupt: PIRQF */
228 pci_write_config_byte(dev, 0x87, 0x0d);
229
230 /* USB 1.1 OHCI controller 3, interrupt: PIRQH */
231 pci_write_config_byte(dev, 0x88, 0x0f);
232
233 /* USB 2.0 controller, interrupt: PIRQ7 */
234 pci_write_config_byte(dev, 0x74, 0x06);
235
236 /* Audio controller, interrupt: PIRQE */
237 pci_write_config_byte(dev, 0x8a, 0x0c);
238
239 /* Modem controller, interrupt: PIRQF */
240 pci_write_config_byte(dev, 0x8b, 0x0d);
241
242 /* HD audio controller, interrupt: PIRQG */
243 pci_write_config_byte(dev, 0x8c, 0x0e);
244
245 /* Serial ATA interrupt: PIRQD */
246 pci_write_config_byte(dev, 0x8d, 0x0b);
247
248 /* SMB interrupt: PIRQH */
249 pci_write_config_byte(dev, 0x8e, 0x0f);
250
251 /* PMU ACPI SCI interrupt: PIRQH */
252 pci_write_config_byte(dev, 0x8f, 0x0f);
253
254 /* Primary PATA IDE IRQ: 14
255 * Secondary PATA IDE IRQ: 15
256 */
257 pci_write_config_byte(dev, 0x44, 0x3d);
258 pci_write_config_byte(dev, 0x75, 0x0f);
259
260 /* Set IRQ14 and IRQ15 to legacy IRQs */
261 pci_read_config_word(dev, 0x46, &temp);
262 temp |= 0xc000;
263 pci_write_config_word(dev, 0x46, temp);
264
265 /* Set i8259 interrupt trigger
266 * IRQ 3: Level
267 * IRQ 4: Level
268 * IRQ 5: Level
269 * IRQ 6: Level
270 * IRQ 7: Level
271 * IRQ 9: Level
272 * IRQ 10: Level
273 * IRQ 11: Level
274 * IRQ 12: Level
275 * IRQ 14: Edge
276 * IRQ 15: Edge
277 */
278 outb(0xfa, 0x4d0);
279 outb(0x1e, 0x4d1);
280}
281
282static void __devinit quirk_uli5288(struct pci_dev *dev)
283{
284 unsigned char c;
285
286 pci_read_config_byte(dev,0x83,&c);
287 c |= 0x80;
288 pci_write_config_byte(dev, 0x83, c);
289
290 pci_write_config_byte(dev, 0x09, 0x01);
291 pci_write_config_byte(dev, 0x0a, 0x06);
292
293 pci_read_config_byte(dev,0x83,&c);
294 c &= 0x7f;
295 pci_write_config_byte(dev, 0x83, c);
296
297 pci_read_config_byte(dev,0x84,&c);
298 c |= 0x01;
299 pci_write_config_byte(dev, 0x84, c);
300}
301
302static void __devinit quirk_uli5229(struct pci_dev *dev)
303{
304 unsigned short temp;
305 pci_write_config_word(dev, 0x04, 0x0405);
306 pci_read_config_word(dev, 0x4a, &temp);
307 temp |= 0x1000;
308 pci_write_config_word(dev, 0x4a, temp);
309}
310
311static void __devinit early_uli5249(struct pci_dev *dev)
312{
313 unsigned char temp;
314 pci_write_config_word(dev, 0x04, 0x0007);
315 pci_read_config_byte(dev, 0x7c, &temp);
316 pci_write_config_byte(dev, 0x7c, 0x80);
317 pci_write_config_byte(dev, 0x09, 0x01);
318 pci_write_config_byte(dev, 0x7c, temp);
319 dev->class |= 0x1;
320}
321
322DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_ali1575);
323DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
324DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
325DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, 0x5249, early_uli5249);
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 292863694562..5cf46dc57895 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_PPC_PSERIES) += pseries/
14obj-$(CONFIG_PPC_ISERIES) += iseries/ 14obj-$(CONFIG_PPC_ISERIES) += iseries/
15obj-$(CONFIG_PPC_MAPLE) += maple/ 15obj-$(CONFIG_PPC_MAPLE) += maple/
16obj-$(CONFIG_PPC_CELL) += cell/ 16obj-$(CONFIG_PPC_CELL) += cell/
17obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
index 352bbbacde9a..0c8c7b6ab897 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -6,6 +6,7 @@ config SPU_FS
6 default m 6 default m
7 depends on PPC_CELL 7 depends on PPC_CELL
8 select SPU_BASE 8 select SPU_BASE
9 select MEMORY_HOTPLUG
9 help 10 help
10 The SPU file system is used to access Synergistic Processing 11 The SPU file system is used to access Synergistic Processing
11 Units on machines implementing the Broadband Processor 12 Units on machines implementing the Broadband Processor
@@ -18,7 +19,6 @@ config SPU_BASE
18config SPUFS_MMAP 19config SPUFS_MMAP
19 bool 20 bool
20 depends on SPU_FS && SPARSEMEM 21 depends on SPU_FS && SPARSEMEM
21 select MEMORY_HOTPLUG
22 default y 22 default y
23 23
24config CBE_RAS 24config CBE_RAS
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index 1bbf822b4efc..7bff3cbc5723 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -307,7 +307,7 @@ static void iic_request_ipi(int ipi, const char *name)
307 irq = iic_ipi_to_irq(ipi); 307 irq = iic_ipi_to_irq(ipi);
308 /* IPIs are marked SA_INTERRUPT as they must run with irqs 308 /* IPIs are marked SA_INTERRUPT as they must run with irqs
309 * disabled */ 309 * disabled */
310 get_irq_desc(irq)->handler = &iic_pic; 310 get_irq_desc(irq)->chip = &iic_pic;
311 get_irq_desc(irq)->status |= IRQ_PER_CPU; 311 get_irq_desc(irq)->status |= IRQ_PER_CPU;
312 request_irq(irq, iic_ipi_action, SA_INTERRUPT, name, NULL); 312 request_irq(irq, iic_ipi_action, SA_INTERRUPT, name, NULL);
313} 313}
@@ -330,7 +330,7 @@ static void iic_setup_spe_handlers(void)
330 for (be=0; be < num_present_cpus() / 2; be++) { 330 for (be=0; be < num_present_cpus() / 2; be++) {
331 for (isrc = 0; isrc < IIC_CLASS_STRIDE * 3; isrc++) { 331 for (isrc = 0; isrc < IIC_CLASS_STRIDE * 3; isrc++) {
332 int irq = IIC_NODE_STRIDE * be + IIC_SPE_OFFSET + isrc; 332 int irq = IIC_NODE_STRIDE * be + IIC_SPE_OFFSET + isrc;
333 get_irq_desc(irq)->handler = &iic_pic; 333 get_irq_desc(irq)->chip = &iic_pic;
334 } 334 }
335 } 335 }
336} 336}
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 3d1831d331e5..00d112f92272 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -125,8 +125,6 @@ static void __init cell_init_early(void)
125{ 125{
126 DBG(" -> cell_init_early()\n"); 126 DBG(" -> cell_init_early()\n");
127 127
128 hpte_init_native();
129
130 cell_init_iommu(); 128 cell_init_iommu();
131 129
132 ppc64_interrupt_controller = IC_CELL_PIC; 130 ppc64_interrupt_controller = IC_CELL_PIC;
@@ -139,11 +137,17 @@ static int __init cell_probe(void)
139{ 137{
140 unsigned long root = of_get_flat_dt_root(); 138 unsigned long root = of_get_flat_dt_root();
141 139
142 if (of_flat_dt_is_compatible(root, "IBM,CBEA") || 140 if (!of_flat_dt_is_compatible(root, "IBM,CBEA") &&
143 of_flat_dt_is_compatible(root, "IBM,CPBW-1.0")) 141 !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
144 return 1; 142 return 0;
143
144#ifdef CONFIG_UDBG_RTAS_CONSOLE
145 udbg_init_rtas_console();
146#endif
147
148 hpte_init_native();
145 149
146 return 0; 150 return 1;
147} 151}
148 152
149/* 153/*
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index 55cbdd77a62d..7c3a0b6d34fd 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -162,7 +162,7 @@ void spider_init_IRQ_hardcoded(void)
162 spider_pics[node] = ioremap(spiderpic, 0x800); 162 spider_pics[node] = ioremap(spiderpic, 0x800);
163 for (n = 0; n < IIC_NUM_EXT; n++) { 163 for (n = 0; n < IIC_NUM_EXT; n++) {
164 int irq = n + IIC_EXT_OFFSET + node * IIC_NODE_STRIDE; 164 int irq = n + IIC_EXT_OFFSET + node * IIC_NODE_STRIDE;
165 get_irq_desc(irq)->handler = &spider_pic; 165 get_irq_desc(irq)->chip = &spider_pic;
166 } 166 }
167 167
168 /* do not mask any interrupts because of level */ 168 /* do not mask any interrupts because of level */
@@ -217,7 +217,7 @@ void spider_init_IRQ(void)
217 217
218 for (n = 0; n < IIC_NUM_EXT; n++) { 218 for (n = 0; n < IIC_NUM_EXT; n++) {
219 int irq = n + IIC_EXT_OFFSET + node * IIC_NODE_STRIDE; 219 int irq = n + IIC_EXT_OFFSET + node * IIC_NODE_STRIDE;
220 get_irq_desc(irq)->handler = &spider_pic; 220 get_irq_desc(irq)->chip = &spider_pic;
221 } 221 }
222 222
223 /* do not mask any interrupts because of level */ 223 /* do not mask any interrupts because of level */
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index db82f503ba2c..b306723abb87 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -168,12 +168,12 @@ spu_irq_class_0_bottom(struct spu *spu)
168 168
169 stat &= mask; 169 stat &= mask;
170 170
171 if (stat & 1) /* invalid MFC DMA */ 171 if (stat & 1) /* invalid DMA alignment */
172 __spu_trap_invalid_dma(spu);
173
174 if (stat & 2) /* invalid DMA alignment */
175 __spu_trap_dma_align(spu); 172 __spu_trap_dma_align(spu);
176 173
174 if (stat & 2) /* invalid MFC DMA */
175 __spu_trap_invalid_dma(spu);
176
177 if (stat & 4) /* error on SPU */ 177 if (stat & 4) /* error on SPU */
178 __spu_trap_error(spu); 178 __spu_trap_error(spu);
179 179
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 7854a380dce2..58e794f9da1b 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -204,7 +204,7 @@ static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
204 204
205 vma->vm_flags |= VM_RESERVED; 205 vma->vm_flags |= VM_RESERVED;
206 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 206 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
207 | _PAGE_NO_CACHE); 207 | _PAGE_NO_CACHE | _PAGE_GUARDED);
208 208
209 vma->vm_ops = &spufs_cntl_mmap_vmops; 209 vma->vm_ops = &spufs_cntl_mmap_vmops;
210 return 0; 210 return 0;
@@ -675,7 +675,7 @@ static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
675 675
676 vma->vm_flags |= VM_RESERVED; 676 vma->vm_flags |= VM_RESERVED;
677 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 677 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
678 | _PAGE_NO_CACHE); 678 | _PAGE_NO_CACHE | _PAGE_GUARDED);
679 679
680 vma->vm_ops = &spufs_signal1_mmap_vmops; 680 vma->vm_ops = &spufs_signal1_mmap_vmops;
681 return 0; 681 return 0;
@@ -762,7 +762,7 @@ static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
762 /* FIXME: */ 762 /* FIXME: */
763 vma->vm_flags |= VM_RESERVED; 763 vma->vm_flags |= VM_RESERVED;
764 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 764 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
765 | _PAGE_NO_CACHE); 765 | _PAGE_NO_CACHE | _PAGE_GUARDED);
766 766
767 vma->vm_ops = &spufs_signal2_mmap_vmops; 767 vma->vm_ops = &spufs_signal2_mmap_vmops;
768 return 0; 768 return 0;
@@ -850,7 +850,7 @@ static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
850 850
851 vma->vm_flags |= VM_RESERVED; 851 vma->vm_flags |= VM_RESERVED;
852 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 852 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
853 | _PAGE_NO_CACHE); 853 | _PAGE_NO_CACHE | _PAGE_GUARDED);
854 854
855 vma->vm_ops = &spufs_mss_mmap_vmops; 855 vma->vm_ops = &spufs_mss_mmap_vmops;
856 return 0; 856 return 0;
@@ -899,7 +899,7 @@ static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
899 899
900 vma->vm_flags |= VM_RESERVED; 900 vma->vm_flags |= VM_RESERVED;
901 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 901 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
902 | _PAGE_NO_CACHE); 902 | _PAGE_NO_CACHE | _PAGE_GUARDED);
903 903
904 vma->vm_ops = &spufs_mfc_mmap_vmops; 904 vma->vm_ops = &spufs_mfc_mmap_vmops;
905 return 0; 905 return 0;
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index 3068b429b031..c7fea2cca534 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -464,7 +464,8 @@ static inline void wait_purge_complete(struct spu_state *csa, struct spu *spu)
464 * Poll MFC_CNTL[Ps] until value '11' is read 464 * Poll MFC_CNTL[Ps] until value '11' is read
465 * (purge complete). 465 * (purge complete).
466 */ 466 */
467 POLL_WHILE_FALSE(in_be64(&priv2->mfc_control_RW) & 467 POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
468 MFC_CNTL_PURGE_DMA_STATUS_MASK) ==
468 MFC_CNTL_PURGE_DMA_COMPLETE); 469 MFC_CNTL_PURGE_DMA_COMPLETE);
469} 470}
470 471
@@ -1028,7 +1029,8 @@ static inline void wait_suspend_mfc_complete(struct spu_state *csa,
1028 * Restore, Step 47. 1029 * Restore, Step 47.
1029 * Poll MFC_CNTL[Ss] until 11 is returned. 1030 * Poll MFC_CNTL[Ss] until 11 is returned.
1030 */ 1031 */
1031 POLL_WHILE_FALSE(in_be64(&priv2->mfc_control_RW) & 1032 POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
1033 MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
1032 MFC_CNTL_SUSPEND_COMPLETE); 1034 MFC_CNTL_SUSPEND_COMPLETE);
1033} 1035}
1034 1036
@@ -2203,7 +2205,7 @@ void spu_init_csa(struct spu_state *csa)
2203 2205
2204 memset(lscsa, 0, sizeof(struct spu_lscsa)); 2206 memset(lscsa, 0, sizeof(struct spu_lscsa));
2205 csa->lscsa = lscsa; 2207 csa->lscsa = lscsa;
2206 csa->register_lock = SPIN_LOCK_UNLOCKED; 2208 spin_lock_init(&csa->register_lock);
2207 2209
2208 /* Set LS pages reserved to allow for user-space mapping. */ 2210 /* Set LS pages reserved to allow for user-space mapping. */
2209 for (p = lscsa->ls; p < lscsa->ls + LS_SIZE; p += PAGE_SIZE) 2211 for (p = lscsa->ls; p < lscsa->ls + LS_SIZE; p += PAGE_SIZE)
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index ac224876ce59..53515daf01b1 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -143,7 +143,7 @@ hydra_init(void)
143 if (np == NULL || of_address_to_resource(np, 0, &r)) 143 if (np == NULL || of_address_to_resource(np, 0, &r))
144 return 0; 144 return 0;
145 Hydra = ioremap(r.start, r.end-r.start); 145 Hydra = ioremap(r.start, r.end-r.start);
146 printk("Hydra Mac I/O at %lx\n", r.start); 146 printk("Hydra Mac I/O at %llx\n", (unsigned long long)r.start);
147 printk("Hydra Feature_Control was %x", 147 printk("Hydra Feature_Control was %x",
148 in_le32(&Hydra->Feature_Control)); 148 in_le32(&Hydra->Feature_Control));
149 out_le32(&Hydra->Feature_Control, (HYDRA_FC_SCC_CELL_EN | 149 out_le32(&Hydra->Feature_Control, (HYDRA_FC_SCC_CELL_EN |
@@ -267,7 +267,7 @@ chrp_find_bridges(void)
267 bus_range[0], bus_range[1]); 267 bus_range[0], bus_range[1]);
268 printk(" controlled by %s", dev->type); 268 printk(" controlled by %s", dev->type);
269 if (!is_longtrail) 269 if (!is_longtrail)
270 printk(" at %lx", r.start); 270 printk(" at %llx", (unsigned long long)r.start);
271 printk("\n"); 271 printk("\n");
272 272
273 hose = pcibios_alloc_controller(); 273 hose = pcibios_alloc_controller();
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 4fdbc9ae876b..ba07a9a7c039 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -74,6 +74,16 @@ config SANDPOINT
74 Select SANDPOINT if configuring for a Motorola Sandpoint X3 74 Select SANDPOINT if configuring for a Motorola Sandpoint X3
75 (any flavor). 75 (any flavor).
76 76
77config MPC7448HPC2
78 bool "Freescale MPC7448HPC2(Taiga)"
79 select TSI108_BRIDGE
80 select DEFAULT_UIMAGE
81 select PPC_UDBG_16550
82 select MPIC
83 help
84 Select MPC7448HPC2 if configuring for Freescale MPC7448HPC2 (Taiga)
85 platform
86
77config RADSTONE_PPC7D 87config RADSTONE_PPC7D
78 bool "Radstone Technology PPC7D board" 88 bool "Radstone Technology PPC7D board"
79 select PPC_I8259 89 select PPC_I8259
@@ -221,6 +231,11 @@ config MV64X60
221 select PPC_INDIRECT_PCI 231 select PPC_INDIRECT_PCI
222 default y 232 default y
223 233
234config TSI108_BRIDGE
235 bool
236 depends on MPC7448HPC2
237 default y
238
224menu "Set bridge options" 239menu "Set bridge options"
225 depends on MV64X60 240 depends on MV64X60
226 241
diff --git a/arch/powerpc/platforms/embedded6xx/Makefile b/arch/powerpc/platforms/embedded6xx/Makefile
new file mode 100644
index 000000000000..fa499fe59291
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/Makefile
@@ -0,0 +1,4 @@
1#
2# Makefile for the 6xx/7xx/7xxxx linux kernel.
3#
4obj-$(CONFIG_MPC7448HPC2) += mpc7448_hpc2.o
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
new file mode 100644
index 000000000000..d7a4fc7ca238
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -0,0 +1,335 @@
1/*
2 * mpc7448_hpc2.c
3 *
4 * Board setup routines for the Freescale Taiga platform
5 *
6 * Author: Jacob Pan
7 * jacob.pan@freescale.com
8 * Author: Xianghua Xiao
9 * x.xiao@freescale.com
10 * Maintainer: Roy Zang <tie-fei.zang@freescale.com>
11 * Add Flat Device Tree support fot mpc7448hpc2 board
12 *
13 * Copyright 2004-2006 Freescale Semiconductor, Inc.
14 *
15 * This file is licensed under
16 * the terms of the GNU General Public License version 2. This program
17 * is licensed "as is" without any warranty of any kind, whether express
18 * or implied.
19 */
20
21#include <linux/config.h>
22#include <linux/stddef.h>
23#include <linux/kernel.h>
24#include <linux/pci.h>
25#include <linux/kdev_t.h>
26#include <linux/console.h>
27#include <linux/delay.h>
28#include <linux/irq.h>
29#include <linux/ide.h>
30#include <linux/seq_file.h>
31#include <linux/root_dev.h>
32#include <linux/serial.h>
33#include <linux/tty.h>
34#include <linux/serial_core.h>
35
36#include <asm/system.h>
37#include <asm/time.h>
38#include <asm/machdep.h>
39#include <asm/prom.h>
40#include <asm/udbg.h>
41#include <asm/tsi108.h>
42#include <asm/pci-bridge.h>
43#include <asm/reg.h>
44#include <mm/mmu_decl.h>
45#include "mpc7448_hpc2.h"
46#include <asm/tsi108_irq.h>
47#include <asm/mpic.h>
48
49#undef DEBUG
50#ifdef DEBUG
51#define DBG(fmt...) do { printk(fmt); } while(0)
52#else
53#define DBG(fmt...) do { } while(0)
54#endif
55
56#ifndef CONFIG_PCI
57isa_io_base = MPC7448_HPC2_ISA_IO_BASE;
58isa_mem_base = MPC7448_HPC2_ISA_MEM_BASE;
59pci_dram_offset = MPC7448_HPC2_PCI_MEM_OFFSET;
60#endif
61
62extern int tsi108_setup_pci(struct device_node *dev);
63extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
64extern void tsi108_pci_int_init(void);
65extern int tsi108_irq_cascade(struct pt_regs *regs, void *unused);
66
67/*
68 * Define all of the IRQ senses and polarities. Taken from the
69 * mpc7448hpc manual.
70 * Note: Likely, this table and the following function should be
71 * obtained and derived from the OF Device Tree.
72 */
73
74static u_char mpc7448_hpc2_pic_initsenses[] __initdata = {
75 /* External on-board sources */
76 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* INT[0] XINT0 from FPGA */
77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* INT[1] XINT1 from FPGA */
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* INT[2] PHY_INT from both GIGE */
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* INT[3] RESERVED */
80 /* Internal Tsi108/109 interrupt sources */
81 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Reserved IRQ */
82 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Reserved IRQ */
83 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Reserved IRQ */
84 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Reserved IRQ */
85 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* DMA0 */
86 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* DMA1 */
87 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* DMA2 */
88 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* DMA3 */
89 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* UART0 */
90 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* UART1 */
91 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* I2C */
92 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* GPIO */
93 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* GIGE0 */
94 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* GIGE1 */
95 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Reserved IRQ */
96 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* HLP */
97 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* SDC */
98 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Processor IF */
99 (IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE), /* Reserved IRQ */
100 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* PCI/X block */
101};
102
103int mpc7448_hpc2_exclude_device(u_char bus, u_char devfn)
104{
105 if (bus == 0 && PCI_SLOT(devfn) == 0)
106 return PCIBIOS_DEVICE_NOT_FOUND;
107 else
108 return PCIBIOS_SUCCESSFUL;
109}
110
111/*
112 * find pci slot by devfn in interrupt map of OF tree
113 */
114u8 find_slot_by_devfn(unsigned int *interrupt_map, unsigned int devfn)
115{
116 int i;
117 unsigned int tmp;
118 for (i = 0; i < 4; i++){
119 tmp = interrupt_map[i*4*7];
120 if ((tmp >> 11) == (devfn >> 3))
121 return i;
122 }
123 return i;
124}
125
126/*
127 * Scans the interrupt map for pci device
128 */
129void mpc7448_hpc2_fixup_irq(struct pci_dev *dev)
130{
131 struct pci_controller *hose;
132 struct device_node *node;
133 unsigned int *interrupt;
134 int busnr;
135 int len;
136 u8 slot;
137 u8 pin;
138
139 /* Lookup the hose */
140 busnr = dev->bus->number;
141 hose = pci_bus_to_hose(busnr);
142 if (!hose)
143 printk(KERN_ERR "No pci hose found\n");
144
145 /* Check it has an OF node associated */
146 node = (struct device_node *) hose->arch_data;
147 if (!node)
148 printk(KERN_ERR "No pci node found\n");
149
150 interrupt = (unsigned int *) get_property(node, "interrupt-map", &len);
151 slot = find_slot_by_devfn(interrupt, dev->devfn);
152 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
153 if (pin == 0 || pin > 4)
154 pin = 1;
155 pin--;
156 dev->irq = interrupt[slot*4*7 + pin*7 + 5];
157 DBG("TSI_PCI: dev->irq = 0x%x\n", dev->irq);
158}
159/* temporary pci irq map fixup*/
160
161void __init mpc7448_hpc2_pcibios_fixup(void)
162{
163 struct pci_dev *dev = NULL;
164 for_each_pci_dev(dev) {
165 mpc7448_hpc2_fixup_irq(dev);
166 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
167 }
168}
169
170static void __init mpc7448_hpc2_setup_arch(void)
171{
172 struct device_node *cpu;
173 struct device_node *np;
174 if (ppc_md.progress)
175 ppc_md.progress("mpc7448_hpc2_setup_arch():set_bridge", 0);
176
177 cpu = of_find_node_by_type(NULL, "cpu");
178 if (cpu != 0) {
179 unsigned int *fp;
180
181 fp = (int *)get_property(cpu, "clock-frequency", NULL);
182 if (fp != 0)
183 loops_per_jiffy = *fp / HZ;
184 else
185 loops_per_jiffy = 50000000 / HZ;
186 of_node_put(cpu);
187 }
188 tsi108_csr_vir_base = get_vir_csrbase();
189
190#ifdef CONFIG_ROOT_NFS
191 ROOT_DEV = Root_NFS;
192#else
193 ROOT_DEV = Root_HDA1;
194#endif
195
196#ifdef CONFIG_BLK_DEV_INITRD
197 ROOT_DEV = Root_RAM0;
198#endif
199
200 /* setup PCI host bridge */
201#ifdef CONFIG_PCI
202 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
203 tsi108_setup_pci(np);
204
205 ppc_md.pci_exclude_device = mpc7448_hpc2_exclude_device;
206 if (ppc_md.progress)
207 ppc_md.progress("tsi108: resources set", 0x100);
208#endif
209
210 printk(KERN_INFO "MPC7448HPC2 (TAIGA) Platform\n");
211 printk(KERN_INFO
212 "Jointly ported by Freescale and Tundra Semiconductor\n");
213 printk(KERN_INFO
214 "Enabling L2 cache then enabling the HID0 prefetch engine.\n");
215}
216
217/*
218 * Interrupt setup and service. Interrrupts on the mpc7448_hpc2 come
219 * from the four external INT pins, PCI interrupts are routed via
220 * PCI interrupt control registers, it generates internal IRQ23
221 *
222 * Interrupt routing on the Taiga Board:
223 * TSI108:PB_INT[0] -> CPU0:INT#
224 * TSI108:PB_INT[1] -> CPU0:MCP#
225 * TSI108:PB_INT[2] -> N/C
226 * TSI108:PB_INT[3] -> N/C
227 */
228static void __init mpc7448_hpc2_init_IRQ(void)
229{
230 struct mpic *mpic;
231 phys_addr_t mpic_paddr = 0;
232 struct device_node *tsi_pic;
233
234 tsi_pic = of_find_node_by_type(NULL, "open-pic");
235 if (tsi_pic) {
236 unsigned int size;
237 void *prop = get_property(tsi_pic, "reg", &size);
238 mpic_paddr = of_translate_address(tsi_pic, prop);
239 }
240
241 if (mpic_paddr == 0) {
242 printk("%s: No tsi108 PIC found !\n", __FUNCTION__);
243 return;
244 }
245
246 DBG("%s: tsi108pic phys_addr = 0x%x\n", __FUNCTION__,
247 (u32) mpic_paddr);
248
249 mpic = mpic_alloc(mpic_paddr,
250 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
251 MPIC_SPV_EOI | MPIC_MOD_ID(MPIC_ID_TSI108),
252 0, /* num_sources used */
253 TSI108_IRQ_BASE,
254 0, /* num_sources used */
255 NR_IRQS - 4 /* XXXX */,
256 mpc7448_hpc2_pic_initsenses,
257 sizeof(mpc7448_hpc2_pic_initsenses), "Tsi108_PIC");
258
259 BUG_ON(mpic == NULL); /* XXXX */
260
261 mpic_init(mpic);
262 mpic_setup_cascade(IRQ_TSI108_PCI, tsi108_irq_cascade, mpic);
263 tsi108_pci_int_init();
264
265 /* Configure MPIC outputs to CPU0 */
266 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
267}
268
269void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)
270{
271 seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
272 seq_printf(m, "machine\t\t: MPC7448hpc2\n");
273}
274
275void mpc7448_hpc2_restart(char *cmd)
276{
277 local_irq_disable();
278
279 /* Set exception prefix high - to the firmware */
280 _nmask_and_or_msr(0, MSR_IP);
281
282 for (;;) ; /* Spin until reset happens */
283}
284
285void mpc7448_hpc2_power_off(void)
286{
287 local_irq_disable();
288 for (;;) ; /* No way to shut power off with software */
289}
290
291void mpc7448_hpc2_halt(void)
292{
293 mpc7448_hpc2_power_off();
294}
295
296/*
297 * Called very early, device-tree isn't unflattened
298 */
299static int __init mpc7448_hpc2_probe(void)
300{
301 unsigned long root = of_get_flat_dt_root();
302
303 if (!of_flat_dt_is_compatible(root, "mpc74xx"))
304 return 0;
305 return 1;
306}
307
308static int mpc7448_machine_check_exception(struct pt_regs *regs)
309{
310 extern void tsi108_clear_pci_cfg_error(void);
311 const struct exception_table_entry *entry;
312
313 /* Are we prepared to handle this fault */
314 if ((entry = search_exception_tables(regs->nip)) != NULL) {
315 tsi108_clear_pci_cfg_error();
316 regs->msr |= MSR_RI;
317 regs->nip = entry->fixup;
318 return 1;
319 }
320 return 0;
321
322}
323define_machine(mpc7448_hpc2){
324 .name = "MPC7448 HPC2",
325 .probe = mpc7448_hpc2_probe,
326 .setup_arch = mpc7448_hpc2_setup_arch,
327 .init_IRQ = mpc7448_hpc2_init_IRQ,
328 .show_cpuinfo = mpc7448_hpc2_show_cpuinfo,
329 .get_irq = mpic_get_irq,
330 .pcibios_fixup = mpc7448_hpc2_pcibios_fixup,
331 .restart = mpc7448_hpc2_restart,
332 .calibrate_decr = generic_calibrate_decr,
333 .machine_check_exception= mpc7448_machine_check_exception,
334 .progress = udbg_progress,
335};
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.h b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.h
new file mode 100644
index 000000000000..a543a5242e34
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.h
@@ -0,0 +1,26 @@
1/*
2 * mpc7448_hpc2.h
3 *
4 * Definitions for Freescale MPC7448_HPC2 platform
5 *
6 * Author: Jacob Pan
7 * jacob.pan@freescale.com
8 * Maintainer: Roy Zang <roy.zang@freescale.com>
9 *
10 * 2006 (c) Freescale Semiconductor, Inc. This file is licensed under
11 * the terms of the GNU General Public License version 2. This program
12 * is licensed "as is" without any warranty of any kind, whether express
13 * or implied.
14 */
15
16#ifndef __PPC_PLATFORMS_MPC7448_HPC2_H
17#define __PPC_PLATFORMS_MPC7448_HPC2_H
18
19#include <asm/ppcboot.h>
20
21/* Base Addresses for the PCI bus
22 */
23#define MPC7448_HPC2_PCI_MEM_OFFSET (0x00000000)
24#define MPC7448_HPC2_ISA_IO_BASE (0x00000000)
25#define MPC7448_HPC2_ISA_MEM_BASE (0x00000000)
26#endif /* __PPC_PLATFORMS_MPC7448_HPC2_H */
diff --git a/arch/powerpc/platforms/iseries/dt.c b/arch/powerpc/platforms/iseries/dt.c
index d3444aabe76e..d194140c1ebf 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -252,6 +252,7 @@ static void __init dt_model(struct iseries_flat_dt *dt)
252{ 252{
253 char buf[16] = "IBM,"; 253 char buf[16] = "IBM,";
254 254
255 /* N.B. lparcfg.c knows about the "IBM," prefixes ... */
255 /* "IBM," + mfgId[2:3] + systemSerial[1:5] */ 256 /* "IBM," + mfgId[2:3] + systemSerial[1:5] */
256 strne2a(buf + 4, xItExtVpdPanel.mfgID + 2, 2); 257 strne2a(buf + 4, xItExtVpdPanel.mfgID + 2, 2);
257 strne2a(buf + 6, xItExtVpdPanel.systemSerial + 1, 5); 258 strne2a(buf + 6, xItExtVpdPanel.systemSerial + 1, 5);
@@ -264,6 +265,7 @@ static void __init dt_model(struct iseries_flat_dt *dt)
264 dt_prop_str(dt, "model", buf); 265 dt_prop_str(dt, "model", buf);
265 266
266 dt_prop_str(dt, "compatible", "IBM,iSeries"); 267 dt_prop_str(dt, "compatible", "IBM,iSeries");
268 dt_prop_u32(dt, "ibm,partition-no", HvLpConfig_getLpIndex());
267} 269}
268 270
269static void __init dt_do_vdevice(struct iseries_flat_dt *dt, 271static void __init dt_do_vdevice(struct iseries_flat_dt *dt,
diff --git a/arch/powerpc/platforms/iseries/htab.c b/arch/powerpc/platforms/iseries/htab.c
index 30bdcf3925d9..ed44dfceaa45 100644
--- a/arch/powerpc/platforms/iseries/htab.c
+++ b/arch/powerpc/platforms/iseries/htab.c
@@ -242,13 +242,11 @@ static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va,
242 local_irq_restore(flags); 242 local_irq_restore(flags);
243} 243}
244 244
245void hpte_init_iSeries(void) 245void __init hpte_init_iSeries(void)
246{ 246{
247 ppc_md.hpte_invalidate = iSeries_hpte_invalidate; 247 ppc_md.hpte_invalidate = iSeries_hpte_invalidate;
248 ppc_md.hpte_updatepp = iSeries_hpte_updatepp; 248 ppc_md.hpte_updatepp = iSeries_hpte_updatepp;
249 ppc_md.hpte_updateboltedpp = iSeries_hpte_updateboltedpp; 249 ppc_md.hpte_updateboltedpp = iSeries_hpte_updateboltedpp;
250 ppc_md.hpte_insert = iSeries_hpte_insert; 250 ppc_md.hpte_insert = iSeries_hpte_insert;
251 ppc_md.hpte_remove = iSeries_hpte_remove; 251 ppc_md.hpte_remove = iSeries_hpte_remove;
252
253 htab_finish_init();
254} 252}
diff --git a/arch/powerpc/platforms/iseries/irq.c b/arch/powerpc/platforms/iseries/irq.c
index 62bbbcf5ded3..33bb4aa0e1e8 100644
--- a/arch/powerpc/platforms/iseries/irq.c
+++ b/arch/powerpc/platforms/iseries/irq.c
@@ -242,9 +242,9 @@ void __init iSeries_activate_IRQs()
242 for_each_irq (irq) { 242 for_each_irq (irq) {
243 irq_desc_t *desc = get_irq_desc(irq); 243 irq_desc_t *desc = get_irq_desc(irq);
244 244
245 if (desc && desc->handler && desc->handler->startup) { 245 if (desc && desc->chip && desc->chip->startup) {
246 spin_lock_irqsave(&desc->lock, flags); 246 spin_lock_irqsave(&desc->lock, flags);
247 desc->handler->startup(irq); 247 desc->chip->startup(irq);
248 spin_unlock_irqrestore(&desc->lock, flags); 248 spin_unlock_irqrestore(&desc->lock, flags);
249 } 249 }
250 } 250 }
@@ -324,7 +324,7 @@ int __init iSeries_allocate_IRQ(HvBusNumber bus,
324 + function; 324 + function;
325 virtirq = virt_irq_create_mapping(realirq); 325 virtirq = virt_irq_create_mapping(realirq);
326 326
327 irq_desc[virtirq].handler = &iSeries_IRQ_handler; 327 irq_desc[virtirq].chip = &iSeries_IRQ_handler;
328 return virtirq; 328 return virtirq;
329} 329}
330 330
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c
index 8ca7b9396355..2a9f81ea27d6 100644
--- a/arch/powerpc/platforms/iseries/lpevents.c
+++ b/arch/powerpc/platforms/iseries/lpevents.c
@@ -51,20 +51,21 @@ static unsigned lpEventHandlerPaths[HvLpEvent_Type_NumTypes];
51static struct HvLpEvent * get_next_hvlpevent(void) 51static struct HvLpEvent * get_next_hvlpevent(void)
52{ 52{
53 struct HvLpEvent * event; 53 struct HvLpEvent * event;
54 event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr; 54 event = (struct HvLpEvent *)hvlpevent_queue.hq_current_event;
55 55
56 if (hvlpevent_is_valid(event)) { 56 if (hvlpevent_is_valid(event)) {
57 /* rmb() needed only for weakly consistent machines (regatta) */ 57 /* rmb() needed only for weakly consistent machines (regatta) */
58 rmb(); 58 rmb();
59 /* Set pointer to next potential event */ 59 /* Set pointer to next potential event */
60 hvlpevent_queue.xSlicCurEventPtr += ((event->xSizeMinus1 + 60 hvlpevent_queue.hq_current_event += ((event->xSizeMinus1 +
61 LpEventAlign) / LpEventAlign) * LpEventAlign; 61 IT_LP_EVENT_ALIGN) / IT_LP_EVENT_ALIGN) *
62 IT_LP_EVENT_ALIGN;
62 63
63 /* Wrap to beginning if no room at end */ 64 /* Wrap to beginning if no room at end */
64 if (hvlpevent_queue.xSlicCurEventPtr > 65 if (hvlpevent_queue.hq_current_event >
65 hvlpevent_queue.xSlicLastValidEventPtr) { 66 hvlpevent_queue.hq_last_event) {
66 hvlpevent_queue.xSlicCurEventPtr = 67 hvlpevent_queue.hq_current_event =
67 hvlpevent_queue.xSlicEventStackPtr; 68 hvlpevent_queue.hq_event_stack;
68 } 69 }
69 } else { 70 } else {
70 event = NULL; 71 event = NULL;
@@ -82,10 +83,10 @@ int hvlpevent_is_pending(void)
82 if (smp_processor_id() >= spread_lpevents) 83 if (smp_processor_id() >= spread_lpevents)
83 return 0; 84 return 0;
84 85
85 next_event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr; 86 next_event = (struct HvLpEvent *)hvlpevent_queue.hq_current_event;
86 87
87 return hvlpevent_is_valid(next_event) || 88 return hvlpevent_is_valid(next_event) ||
88 hvlpevent_queue.xPlicOverflowIntPending; 89 hvlpevent_queue.hq_overflow_pending;
89} 90}
90 91
91static void hvlpevent_clear_valid(struct HvLpEvent * event) 92static void hvlpevent_clear_valid(struct HvLpEvent * event)
@@ -95,18 +96,18 @@ static void hvlpevent_clear_valid(struct HvLpEvent * event)
95 * ie. on 64-byte boundaries. 96 * ie. on 64-byte boundaries.
96 */ 97 */
97 struct HvLpEvent *tmp; 98 struct HvLpEvent *tmp;
98 unsigned extra = ((event->xSizeMinus1 + LpEventAlign) / 99 unsigned extra = ((event->xSizeMinus1 + IT_LP_EVENT_ALIGN) /
99 LpEventAlign) - 1; 100 IT_LP_EVENT_ALIGN) - 1;
100 101
101 switch (extra) { 102 switch (extra) {
102 case 3: 103 case 3:
103 tmp = (struct HvLpEvent*)((char*)event + 3 * LpEventAlign); 104 tmp = (struct HvLpEvent*)((char*)event + 3 * IT_LP_EVENT_ALIGN);
104 hvlpevent_invalidate(tmp); 105 hvlpevent_invalidate(tmp);
105 case 2: 106 case 2:
106 tmp = (struct HvLpEvent*)((char*)event + 2 * LpEventAlign); 107 tmp = (struct HvLpEvent*)((char*)event + 2 * IT_LP_EVENT_ALIGN);
107 hvlpevent_invalidate(tmp); 108 hvlpevent_invalidate(tmp);
108 case 1: 109 case 1:
109 tmp = (struct HvLpEvent*)((char*)event + 1 * LpEventAlign); 110 tmp = (struct HvLpEvent*)((char*)event + 1 * IT_LP_EVENT_ALIGN);
110 hvlpevent_invalidate(tmp); 111 hvlpevent_invalidate(tmp);
111 } 112 }
112 113
@@ -120,7 +121,7 @@ void process_hvlpevents(struct pt_regs *regs)
120 struct HvLpEvent * event; 121 struct HvLpEvent * event;
121 122
122 /* If we have recursed, just return */ 123 /* If we have recursed, just return */
123 if (!spin_trylock(&hvlpevent_queue.lock)) 124 if (!spin_trylock(&hvlpevent_queue.hq_lock))
124 return; 125 return;
125 126
126 for (;;) { 127 for (;;) {
@@ -148,17 +149,17 @@ void process_hvlpevents(struct pt_regs *regs)
148 printk(KERN_INFO "Unexpected Lp Event type=%d\n", event->xType ); 149 printk(KERN_INFO "Unexpected Lp Event type=%d\n", event->xType );
149 150
150 hvlpevent_clear_valid(event); 151 hvlpevent_clear_valid(event);
151 } else if (hvlpevent_queue.xPlicOverflowIntPending) 152 } else if (hvlpevent_queue.hq_overflow_pending)
152 /* 153 /*
153 * No more valid events. If overflow events are 154 * No more valid events. If overflow events are
154 * pending process them 155 * pending process them
155 */ 156 */
156 HvCallEvent_getOverflowLpEvents(hvlpevent_queue.xIndex); 157 HvCallEvent_getOverflowLpEvents(hvlpevent_queue.hq_index);
157 else 158 else
158 break; 159 break;
159 } 160 }
160 161
161 spin_unlock(&hvlpevent_queue.lock); 162 spin_unlock(&hvlpevent_queue.hq_lock);
162} 163}
163 164
164static int set_spread_lpevents(char *str) 165static int set_spread_lpevents(char *str)
@@ -184,20 +185,20 @@ void setup_hvlpevent_queue(void)
184{ 185{
185 void *eventStack; 186 void *eventStack;
186 187
187 spin_lock_init(&hvlpevent_queue.lock); 188 spin_lock_init(&hvlpevent_queue.hq_lock);
188 189
189 /* Allocate a page for the Event Stack. */ 190 /* Allocate a page for the Event Stack. */
190 eventStack = alloc_bootmem_pages(LpEventStackSize); 191 eventStack = alloc_bootmem_pages(IT_LP_EVENT_STACK_SIZE);
191 memset(eventStack, 0, LpEventStackSize); 192 memset(eventStack, 0, IT_LP_EVENT_STACK_SIZE);
192 193
193 /* Invoke the hypervisor to initialize the event stack */ 194 /* Invoke the hypervisor to initialize the event stack */
194 HvCallEvent_setLpEventStack(0, eventStack, LpEventStackSize); 195 HvCallEvent_setLpEventStack(0, eventStack, IT_LP_EVENT_STACK_SIZE);
195 196
196 hvlpevent_queue.xSlicEventStackPtr = (char *)eventStack; 197 hvlpevent_queue.hq_event_stack = eventStack;
197 hvlpevent_queue.xSlicCurEventPtr = (char *)eventStack; 198 hvlpevent_queue.hq_current_event = eventStack;
198 hvlpevent_queue.xSlicLastValidEventPtr = (char *)eventStack + 199 hvlpevent_queue.hq_last_event = (char *)eventStack +
199 (LpEventStackSize - LpEventMaxSize); 200 (IT_LP_EVENT_STACK_SIZE - IT_LP_EVENT_MAX_SIZE);
200 hvlpevent_queue.xIndex = 0; 201 hvlpevent_queue.hq_index = 0;
201} 202}
202 203
203/* Register a handler for an LpEvent type */ 204/* Register a handler for an LpEvent type */
diff --git a/arch/powerpc/platforms/iseries/proc.c b/arch/powerpc/platforms/iseries/proc.c
index e68b6b5fa89f..c241413629ac 100644
--- a/arch/powerpc/platforms/iseries/proc.c
+++ b/arch/powerpc/platforms/iseries/proc.c
@@ -24,7 +24,6 @@
24#include <asm/processor.h> 24#include <asm/processor.h>
25#include <asm/time.h> 25#include <asm/time.h>
26#include <asm/lppaca.h> 26#include <asm/lppaca.h>
27#include <asm/iseries/it_lp_queue.h>
28#include <asm/iseries/hv_call_xm.h> 27#include <asm/iseries/hv_call_xm.h>
29 28
30#include "processor_vpd.h" 29#include "processor_vpd.h"
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index 617c724c4590..66c77e4f8ec2 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -81,8 +81,6 @@ static void iSeries_pci_final_fixup(void) { }
81#endif 81#endif
82 82
83extern int rd_size; /* Defined in drivers/block/rd.c */ 83extern int rd_size; /* Defined in drivers/block/rd.c */
84extern unsigned long embedded_sysmap_start;
85extern unsigned long embedded_sysmap_end;
86 84
87extern unsigned long iSeries_recal_tb; 85extern unsigned long iSeries_recal_tb;
88extern unsigned long iSeries_recal_titan; 86extern unsigned long iSeries_recal_titan;
@@ -321,11 +319,6 @@ static void __init iSeries_init_early(void)
321 iSeries_recal_titan = HvCallXm_loadTod(); 319 iSeries_recal_titan = HvCallXm_loadTod();
322 320
323 /* 321 /*
324 * Initialize the hash table management pointers
325 */
326 hpte_init_iSeries();
327
328 /*
329 * Initialize the DMA/TCE management 322 * Initialize the DMA/TCE management
330 */ 323 */
331 iommu_init_early_iSeries(); 324 iommu_init_early_iSeries();
@@ -563,16 +556,6 @@ static void __init iSeries_fixup_klimit(void)
563 if (naca.xRamDisk) 556 if (naca.xRamDisk)
564 klimit = KERNELBASE + (u64)naca.xRamDisk + 557 klimit = KERNELBASE + (u64)naca.xRamDisk +
565 (naca.xRamDiskSize * HW_PAGE_SIZE); 558 (naca.xRamDiskSize * HW_PAGE_SIZE);
566 else {
567 /*
568 * No ram disk was included - check and see if there
569 * was an embedded system map. Change klimit to take
570 * into account any embedded system map
571 */
572 if (embedded_sysmap_end)
573 klimit = KERNELBASE + ((embedded_sysmap_end + 4095) &
574 0xfffffffffffff000);
575 }
576} 559}
577 560
578static int __init iSeries_src_init(void) 561static int __init iSeries_src_init(void)
@@ -683,6 +666,8 @@ static int __init iseries_probe(void)
683 */ 666 */
684 virt_irq_max = 255; 667 virt_irq_max = 255;
685 668
669 hpte_init_iSeries();
670
686 return 1; 671 return 1;
687} 672}
688 673
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 9a4efc0c3b29..f7170ff86dab 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -376,9 +376,10 @@ static void __init maple_fixup_phb_resources(void)
376 unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base; 376 unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
377 hose->io_resource.start += offset; 377 hose->io_resource.start += offset;
378 hose->io_resource.end += offset; 378 hose->io_resource.end += offset;
379 printk(KERN_INFO "PCI Host %d, io start: %lx; io end: %lx\n", 379 printk(KERN_INFO "PCI Host %d, io start: %llx; io end: %llx\n",
380 hose->global_number, 380 hose->global_number,
381 hose->io_resource.start, hose->io_resource.end); 381 (unsigned long long)hose->io_resource.start,
382 (unsigned long long)hose->io_resource.end);
382 } 383 }
383} 384}
384 385
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index a0505ea48a86..4e32a5417fd1 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -199,11 +199,6 @@ static void __init maple_init_early(void)
199{ 199{
200 DBG(" -> maple_init_early\n"); 200 DBG(" -> maple_init_early\n");
201 201
202 /* Initialize hash table, from now on, we can take hash faults
203 * and call ioremap
204 */
205 hpte_init_native();
206
207 /* Setup interrupt mapping options */ 202 /* Setup interrupt mapping options */
208 ppc64_interrupt_controller = IC_OPEN_PIC; 203 ppc64_interrupt_controller = IC_OPEN_PIC;
209 204
@@ -272,6 +267,8 @@ static int __init maple_probe(void)
272 */ 267 */
273 alloc_dart_table(); 268 alloc_dart_table();
274 269
270 hpte_init_native();
271
275 return 1; 272 return 1;
276} 273}
277 274
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 498b042e1837..c7a27eddca6d 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -119,7 +119,14 @@ int pmac_backlight_set_legacy_brightness(int brightness)
119 down(&pmac_backlight->sem); 119 down(&pmac_backlight->sem);
120 props = pmac_backlight->props; 120 props = pmac_backlight->props;
121 props->brightness = brightness * 121 props->brightness = brightness *
122 props->max_brightness / OLD_BACKLIGHT_MAX; 122 (props->max_brightness + 1) /
123 (OLD_BACKLIGHT_MAX + 1);
124
125 if (props->brightness > props->max_brightness)
126 props->brightness = props->max_brightness;
127 else if (props->brightness < 0)
128 props->brightness = 0;
129
123 props->update_status(pmac_backlight); 130 props->update_status(pmac_backlight);
124 up(&pmac_backlight->sem); 131 up(&pmac_backlight->sem);
125 132
@@ -140,8 +147,11 @@ int pmac_backlight_get_legacy_brightness()
140 147
141 down(&pmac_backlight->sem); 148 down(&pmac_backlight->sem);
142 props = pmac_backlight->props; 149 props = pmac_backlight->props;
150
143 result = props->brightness * 151 result = props->brightness *
144 OLD_BACKLIGHT_MAX / props->max_brightness; 152 (OLD_BACKLIGHT_MAX + 1) /
153 (props->max_brightness + 1);
154
145 up(&pmac_backlight->sem); 155 up(&pmac_backlight->sem);
146 } 156 }
147 mutex_unlock(&pmac_backlight_mutex); 157 mutex_unlock(&pmac_backlight_mutex);
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 80035853467b..d524a915aa86 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -939,9 +939,10 @@ static int __init add_bridge(struct device_node *dev)
939 disp_name = "Chaos"; 939 disp_name = "Chaos";
940 primary = 0; 940 primary = 0;
941 } 941 }
942 printk(KERN_INFO "Found %s PCI host bridge at 0x%08lx. " 942 printk(KERN_INFO "Found %s PCI host bridge at 0x%016llx. "
943 "Firmware bus number: %d->%d\n", 943 "Firmware bus number: %d->%d\n",
944 disp_name, rsrc.start, hose->first_busno, hose->last_busno); 944 disp_name, (unsigned long long)rsrc.start, hose->first_busno,
945 hose->last_busno);
945#endif /* CONFIG_PPC32 */ 946#endif /* CONFIG_PPC32 */
946 947
947 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n", 948 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index 047f954a89eb..93e7505debc5 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -546,7 +546,7 @@ struct pmf_device {
546}; 546};
547 547
548static LIST_HEAD(pmf_devices); 548static LIST_HEAD(pmf_devices);
549static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED; 549static DEFINE_SPINLOCK(pmf_lock);
550static DEFINE_MUTEX(pmf_irq_mutex); 550static DEFINE_MUTEX(pmf_irq_mutex);
551 551
552static void pmf_release_device(struct kref *kref) 552static void pmf_release_device(struct kref *kref)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 18bf3011d1e3..9f6189af6dd6 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -446,7 +446,7 @@ static void __init pmac_pic_probe_oldstyle(void)
446 446
447 /* Set the handler for the main PIC */ 447 /* Set the handler for the main PIC */
448 for ( i = 0; i < max_real_irqs ; i++ ) 448 for ( i = 0; i < max_real_irqs ; i++ )
449 irq_desc[i].handler = &pmac_pic; 449 irq_desc[i].chip = &pmac_pic;
450 450
451 /* Get addresses of first controller if we have a node for it */ 451 /* Get addresses of first controller if we have a node for it */
452 BUG_ON(of_address_to_resource(master, 0, &r)); 452 BUG_ON(of_address_to_resource(master, 0, &r));
@@ -493,7 +493,7 @@ static void __init pmac_pic_probe_oldstyle(void)
493 /* Setup handlers for secondary controller and hook cascade irq*/ 493 /* Setup handlers for secondary controller and hook cascade irq*/
494 if (slave) { 494 if (slave) {
495 for ( i = max_real_irqs ; i < max_irqs ; i++ ) 495 for ( i = max_real_irqs ; i < max_irqs ; i++ )
496 irq_desc[i].handler = &gatwick_pic; 496 irq_desc[i].chip = &gatwick_pic;
497 setup_irq(irq_cascade, &gatwick_cascade_action); 497 setup_irq(irq_cascade, &gatwick_cascade_action);
498 } 498 }
499 printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs); 499 printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs);
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 9cc7db7a8bdc..89c5775f83be 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -600,13 +600,6 @@ pmac_halt(void)
600 */ 600 */
601static void __init pmac_init_early(void) 601static void __init pmac_init_early(void)
602{ 602{
603#ifdef CONFIG_PPC64
604 /* Initialize hash table, from now on, we can take hash faults
605 * and call ioremap
606 */
607 hpte_init_native();
608#endif
609
610 /* Enable early btext debug if requested */ 603 /* Enable early btext debug if requested */
611 if (strstr(cmd_line, "btextdbg")) { 604 if (strstr(cmd_line, "btextdbg")) {
612 udbg_adb_init_early(); 605 udbg_adb_init_early();
@@ -683,6 +676,8 @@ static int __init pmac_probe(void)
683 * part of the cacheable linar mapping 676 * part of the cacheable linar mapping
684 */ 677 */
685 alloc_dart_table(); 678 alloc_dart_table();
679
680 hpte_init_native();
686#endif 681#endif
687 682
688#ifdef CONFIG_PPC32 683#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 8f2d12935b99..45ccc687e57c 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37/* EEH event workqueue setup. */ 37/* EEH event workqueue setup. */
38static spinlock_t eeh_eventlist_lock = SPIN_LOCK_UNLOCKED; 38static DEFINE_SPINLOCK(eeh_eventlist_lock);
39LIST_HEAD(eeh_eventlist); 39LIST_HEAD(eeh_eventlist);
40static void eeh_thread_launcher(void *); 40static void eeh_thread_launcher(void *);
41DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL); 41DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL);
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index d03a8b078f9d..8cfb5706790e 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -92,6 +92,15 @@ static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages)
92 *(tcep++) = 0; 92 *(tcep++) = 0;
93} 93}
94 94
95static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
96{
97 u64 *tcep;
98
99 index <<= TCE_PAGE_FACTOR;
100 tcep = ((u64 *)tbl->it_base) + index;
101
102 return *tcep;
103}
95 104
96static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum, 105static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
97 long npages, unsigned long uaddr, 106 long npages, unsigned long uaddr,
@@ -235,6 +244,25 @@ static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long n
235 } 244 }
236} 245}
237 246
247static unsigned long tce_get_pSeriesLP(struct iommu_table *tbl, long tcenum)
248{
249 u64 rc;
250 unsigned long tce_ret;
251
252 tcenum <<= TCE_PAGE_FACTOR;
253 rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret);
254
255 if (rc && printk_ratelimit()) {
256 printk("tce_get_pSeriesLP: plpar_tce_get failed. rc=%ld\n",
257 rc);
258 printk("\tindex = 0x%lx\n", (u64)tbl->it_index);
259 printk("\ttcenum = 0x%lx\n", (u64)tcenum);
260 show_stack(current, (unsigned long *)__get_SP());
261 }
262
263 return tce_ret;
264}
265
238static void iommu_table_setparms(struct pci_controller *phb, 266static void iommu_table_setparms(struct pci_controller *phb,
239 struct device_node *dn, 267 struct device_node *dn,
240 struct iommu_table *tbl) 268 struct iommu_table *tbl)
@@ -254,7 +282,10 @@ static void iommu_table_setparms(struct pci_controller *phb,
254 } 282 }
255 283
256 tbl->it_base = (unsigned long)__va(*basep); 284 tbl->it_base = (unsigned long)__va(*basep);
285
286#ifndef CONFIG_CRASH_DUMP
257 memset((void *)tbl->it_base, 0, *sizep); 287 memset((void *)tbl->it_base, 0, *sizep);
288#endif
258 289
259 tbl->it_busno = phb->bus->number; 290 tbl->it_busno = phb->bus->number;
260 291
@@ -560,11 +591,13 @@ void iommu_init_early_pSeries(void)
560 ppc_md.tce_build = tce_build_pSeriesLP; 591 ppc_md.tce_build = tce_build_pSeriesLP;
561 ppc_md.tce_free = tce_free_pSeriesLP; 592 ppc_md.tce_free = tce_free_pSeriesLP;
562 } 593 }
594 ppc_md.tce_get = tce_get_pSeriesLP;
563 ppc_md.iommu_bus_setup = iommu_bus_setup_pSeriesLP; 595 ppc_md.iommu_bus_setup = iommu_bus_setup_pSeriesLP;
564 ppc_md.iommu_dev_setup = iommu_dev_setup_pSeriesLP; 596 ppc_md.iommu_dev_setup = iommu_dev_setup_pSeriesLP;
565 } else { 597 } else {
566 ppc_md.tce_build = tce_build_pSeries; 598 ppc_md.tce_build = tce_build_pSeries;
567 ppc_md.tce_free = tce_free_pSeries; 599 ppc_md.tce_free = tce_free_pSeries;
600 ppc_md.tce_get = tce_get_pseries;
568 ppc_md.iommu_bus_setup = iommu_bus_setup_pSeries; 601 ppc_md.iommu_bus_setup = iommu_bus_setup_pSeries;
569 ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries; 602 ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries;
570 } 603 }
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 634b7d06d3cc..27480705996f 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -513,7 +513,7 @@ void pSeries_lpar_flush_hash_range(unsigned long number, int local)
513 spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags); 513 spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags);
514} 514}
515 515
516void hpte_init_lpar(void) 516void __init hpte_init_lpar(void)
517{ 517{
518 ppc_md.hpte_invalidate = pSeries_lpar_hpte_invalidate; 518 ppc_md.hpte_invalidate = pSeries_lpar_hpte_invalidate;
519 ppc_md.hpte_updatepp = pSeries_lpar_hpte_updatepp; 519 ppc_md.hpte_updatepp = pSeries_lpar_hpte_updatepp;
@@ -522,6 +522,4 @@ void hpte_init_lpar(void)
522 ppc_md.hpte_remove = pSeries_lpar_hpte_remove; 522 ppc_md.hpte_remove = pSeries_lpar_hpte_remove;
523 ppc_md.flush_hash_range = pSeries_lpar_flush_hash_range; 523 ppc_md.flush_hash_range = pSeries_lpar_flush_hash_range;
524 ppc_md.hpte_clear_all = pSeries_lpar_hptab_clear; 524 ppc_md.hpte_clear_all = pSeries_lpar_hptab_clear;
525
526 htab_finish_init();
527} 525}
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 1e28518c6121..b3197ff156c6 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -322,11 +322,6 @@ static void __init pSeries_init_early(void)
322 DBG(" -> pSeries_init_early()\n"); 322 DBG(" -> pSeries_init_early()\n");
323 323
324 fw_feature_init(); 324 fw_feature_init();
325
326 if (firmware_has_feature(FW_FEATURE_LPAR))
327 hpte_init_lpar();
328 else
329 hpte_init_native();
330 325
331 if (firmware_has_feature(FW_FEATURE_LPAR)) 326 if (firmware_has_feature(FW_FEATURE_LPAR))
332 find_udbg_vterm(); 327 find_udbg_vterm();
@@ -384,6 +379,11 @@ static int __init pSeries_probe_hypertas(unsigned long node,
384 if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL) != NULL) 379 if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL) != NULL)
385 powerpc_firmware_features |= FW_FEATURE_LPAR; 380 powerpc_firmware_features |= FW_FEATURE_LPAR;
386 381
382 if (firmware_has_feature(FW_FEATURE_LPAR))
383 hpte_init_lpar();
384 else
385 hpte_init_native();
386
387 return 1; 387 return 1;
388} 388}
389 389
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index b14f9b5c114e..19c03dd43000 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -238,7 +238,7 @@ static int get_irq_server(unsigned int irq)
238{ 238{
239 unsigned int server; 239 unsigned int server;
240 /* For the moment only implement delivery to all cpus or one cpu */ 240 /* For the moment only implement delivery to all cpus or one cpu */
241 cpumask_t cpumask = irq_affinity[irq]; 241 cpumask_t cpumask = irq_desc[irq].affinity;
242 cpumask_t tmp = CPU_MASK_NONE; 242 cpumask_t tmp = CPU_MASK_NONE;
243 243
244 if (!distribute_irqs) 244 if (!distribute_irqs)
@@ -558,7 +558,7 @@ nextnode:
558 } 558 }
559 559
560 for (i = irq_offset_value(); i < NR_IRQS; ++i) 560 for (i = irq_offset_value(); i < NR_IRQS; ++i)
561 get_irq_desc(i)->handler = &xics_pic; 561 get_irq_desc(i)->chip = &xics_pic;
562 562
563 xics_setup_cpu(); 563 xics_setup_cpu();
564 564
@@ -701,9 +701,9 @@ void xics_migrate_irqs_away(void)
701 continue; 701 continue;
702 702
703 /* We only need to migrate enabled IRQS */ 703 /* We only need to migrate enabled IRQS */
704 if (desc == NULL || desc->handler == NULL 704 if (desc == NULL || desc->chip == NULL
705 || desc->action == NULL 705 || desc->action == NULL
706 || desc->handler->set_affinity == NULL) 706 || desc->chip->set_affinity == NULL)
707 continue; 707 continue;
708 708
709 spin_lock_irqsave(&desc->lock, flags); 709 spin_lock_irqsave(&desc->lock, flags);
@@ -728,8 +728,8 @@ void xics_migrate_irqs_away(void)
728 virq, cpu); 728 virq, cpu);
729 729
730 /* Reset affinity to all cpus */ 730 /* Reset affinity to all cpus */
731 desc->handler->set_affinity(virq, CPU_MASK_ALL); 731 desc->chip->set_affinity(virq, CPU_MASK_ALL);
732 irq_affinity[virq] = CPU_MASK_ALL; 732 irq_desc[irq].affinity = CPU_MASK_ALL;
733unlock: 733unlock:
734 spin_unlock_irqrestore(&desc->lock, flags); 734 spin_unlock_irqrestore(&desc->lock, flags);
735 } 735 }
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index cef95b023730..054bd8b41ef5 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -12,3 +12,5 @@ obj-$(CONFIG_U3_DART) += dart_iommu.o
12obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o 12obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
13obj-$(CONFIG_PPC_83xx) += ipic.o 13obj-$(CONFIG_PPC_83xx) += ipic.o
14obj-$(CONFIG_FSL_SOC) += fsl_soc.o 14obj-$(CONFIG_FSL_SOC) += fsl_soc.o
15obj-$(CONFIG_PPC_TODC) += todc.o
16obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o
diff --git a/arch/powerpc/sysdev/dart.h b/arch/powerpc/sysdev/dart.h
index c2d05763ccbe..1c8817c4835e 100644
--- a/arch/powerpc/sysdev/dart.h
+++ b/arch/powerpc/sysdev/dart.h
@@ -47,8 +47,12 @@
47/* U4 registers */ 47/* U4 registers */
48#define DART_BASE_U4_BASE_MASK 0xffffff 48#define DART_BASE_U4_BASE_MASK 0xffffff
49#define DART_BASE_U4_BASE_SHIFT 0 49#define DART_BASE_U4_BASE_SHIFT 0
50#define DART_CNTL_U4_FLUSHTLB 0x20000000
51#define DART_CNTL_U4_ENABLE 0x80000000 50#define DART_CNTL_U4_ENABLE 0x80000000
51#define DART_CNTL_U4_IONE 0x40000000
52#define DART_CNTL_U4_FLUSHTLB 0x20000000
53#define DART_CNTL_U4_IDLE 0x10000000
54#define DART_CNTL_U4_PAR_EN 0x08000000
55#define DART_CNTL_U4_IONE_MASK 0x07ffffff
52#define DART_SIZE_U4_SIZE_MASK 0x1fff 56#define DART_SIZE_U4_SIZE_MASK 0x1fff
53#define DART_SIZE_U4_SIZE_SHIFT 0 57#define DART_SIZE_U4_SIZE_SHIFT 0
54 58
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 6232091cc72b..7c7f34ce4986 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -101,8 +101,8 @@ retry:
101 if (l == (1L << limit)) { 101 if (l == (1L << limit)) {
102 if (limit < 4) { 102 if (limit < 4) {
103 limit++; 103 limit++;
104 reg = DART_IN(DART_CNTL); 104 reg = DART_IN(DART_CNTL);
105 reg &= ~inv_bit; 105 reg &= ~inv_bit;
106 DART_OUT(DART_CNTL, reg); 106 DART_OUT(DART_CNTL, reg);
107 goto retry; 107 goto retry;
108 } else 108 } else
@@ -111,11 +111,39 @@ retry:
111 } 111 }
112} 112}
113 113
114static inline void dart_tlb_invalidate_one(unsigned long bus_rpn)
115{
116 unsigned int reg;
117 unsigned int l, limit;
118
119 reg = DART_CNTL_U4_ENABLE | DART_CNTL_U4_IONE |
120 (bus_rpn & DART_CNTL_U4_IONE_MASK);
121 DART_OUT(DART_CNTL, reg);
122
123 limit = 0;
124wait_more:
125 l = 0;
126 while ((DART_IN(DART_CNTL) & DART_CNTL_U4_IONE) && l < (1L << limit)) {
127 rmb();
128 l++;
129 }
130
131 if (l == (1L << limit)) {
132 if (limit < 4) {
133 limit++;
134 goto wait_more;
135 } else
136 panic("DART: TLB did not flush after waiting a long "
137 "time. Buggy U4 ?");
138 }
139}
140
114static void dart_flush(struct iommu_table *tbl) 141static void dart_flush(struct iommu_table *tbl)
115{ 142{
116 if (dart_dirty) 143 if (dart_dirty) {
117 dart_tlb_invalidate_all(); 144 dart_tlb_invalidate_all();
118 dart_dirty = 0; 145 dart_dirty = 0;
146 }
119} 147}
120 148
121static void dart_build(struct iommu_table *tbl, long index, 149static void dart_build(struct iommu_table *tbl, long index,
@@ -124,6 +152,7 @@ static void dart_build(struct iommu_table *tbl, long index,
124{ 152{
125 unsigned int *dp; 153 unsigned int *dp;
126 unsigned int rpn; 154 unsigned int rpn;
155 long l;
127 156
128 DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr); 157 DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr);
129 158
@@ -135,7 +164,8 @@ static void dart_build(struct iommu_table *tbl, long index,
135 /* On U3, all memory is contigous, so we can move this 164 /* On U3, all memory is contigous, so we can move this
136 * out of the loop. 165 * out of the loop.
137 */ 166 */
138 while (npages--) { 167 l = npages;
168 while (l--) {
139 rpn = virt_to_abs(uaddr) >> DART_PAGE_SHIFT; 169 rpn = virt_to_abs(uaddr) >> DART_PAGE_SHIFT;
140 170
141 *(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK); 171 *(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK);
@@ -143,7 +173,14 @@ static void dart_build(struct iommu_table *tbl, long index,
143 uaddr += DART_PAGE_SIZE; 173 uaddr += DART_PAGE_SIZE;
144 } 174 }
145 175
146 dart_dirty = 1; 176 if (dart_is_u4) {
177 rpn = index;
178 mb(); /* make sure all updates have reached memory */
179 while (npages--)
180 dart_tlb_invalidate_one(rpn++);
181 } else {
182 dart_dirty = 1;
183 }
147} 184}
148 185
149 186
diff --git a/arch/powerpc/sysdev/i8259.c b/arch/powerpc/sysdev/i8259.c
index b7ac32fdd776..2bff30f6d635 100644
--- a/arch/powerpc/sysdev/i8259.c
+++ b/arch/powerpc/sysdev/i8259.c
@@ -208,7 +208,7 @@ void __init i8259_init(unsigned long intack_addr, int offset)
208 spin_unlock_irqrestore(&i8259_lock, flags); 208 spin_unlock_irqrestore(&i8259_lock, flags);
209 209
210 for (i = 0; i < NUM_ISA_INTERRUPTS; ++i) 210 for (i = 0; i < NUM_ISA_INTERRUPTS; ++i)
211 irq_desc[offset + i].handler = &i8259_pic; 211 irq_desc[offset + i].chip = &i8259_pic;
212 212
213 /* reserve our resources */ 213 /* reserve our resources */
214 setup_irq(offset + 2, &i8259_irqaction); 214 setup_irq(offset + 2, &i8259_irqaction);
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 8f01e0f1d847..46801f5ec03f 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -472,7 +472,7 @@ void __init ipic_init(phys_addr_t phys_addr,
472 ipic_write(primary_ipic->regs, IPIC_SEMSR, temp); 472 ipic_write(primary_ipic->regs, IPIC_SEMSR, temp);
473 473
474 for (i = 0 ; i < NR_IPIC_INTS ; i++) { 474 for (i = 0 ; i < NR_IPIC_INTS ; i++) {
475 irq_desc[i+irq_offset].handler = &ipic; 475 irq_desc[i+irq_offset].chip = &ipic;
476 irq_desc[i+irq_offset].status = IRQ_LEVEL; 476 irq_desc[i+irq_offset].status = IRQ_LEVEL;
477 } 477 }
478 478
diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c
index 74e0d31a3559..615350d46b52 100644
--- a/arch/powerpc/sysdev/mmio_nvram.c
+++ b/arch/powerpc/sysdev/mmio_nvram.c
@@ -32,7 +32,7 @@
32 32
33static void __iomem *mmio_nvram_start; 33static void __iomem *mmio_nvram_start;
34static long mmio_nvram_len; 34static long mmio_nvram_len;
35static spinlock_t mmio_nvram_lock = SPIN_LOCK_UNLOCKED; 35static DEFINE_SPINLOCK(mmio_nvram_lock);
36 36
37static ssize_t mmio_nvram_read(char *buf, size_t count, loff_t *index) 37static ssize_t mmio_nvram_read(char *buf, size_t count, loff_t *index)
38{ 38{
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index bffe50d02c99..28df9c827ca6 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -379,14 +379,14 @@ static inline u32 mpic_physmask(u32 cpumask)
379/* Get the mpic structure from the IPI number */ 379/* Get the mpic structure from the IPI number */
380static inline struct mpic * mpic_from_ipi(unsigned int ipi) 380static inline struct mpic * mpic_from_ipi(unsigned int ipi)
381{ 381{
382 return container_of(irq_desc[ipi].handler, struct mpic, hc_ipi); 382 return container_of(irq_desc[ipi].chip, struct mpic, hc_ipi);
383} 383}
384#endif 384#endif
385 385
386/* Get the mpic structure from the irq number */ 386/* Get the mpic structure from the irq number */
387static inline struct mpic * mpic_from_irq(unsigned int irq) 387static inline struct mpic * mpic_from_irq(unsigned int irq)
388{ 388{
389 return container_of(irq_desc[irq].handler, struct mpic, hc_irq); 389 return container_of(irq_desc[irq].chip, struct mpic, hc_irq);
390} 390}
391 391
392/* Send an EOI */ 392/* Send an EOI */
@@ -752,7 +752,7 @@ void __init mpic_init(struct mpic *mpic)
752 if (!(mpic->flags & MPIC_PRIMARY)) 752 if (!(mpic->flags & MPIC_PRIMARY))
753 continue; 753 continue;
754 irq_desc[mpic->ipi_offset+i].status |= IRQ_PER_CPU; 754 irq_desc[mpic->ipi_offset+i].status |= IRQ_PER_CPU;
755 irq_desc[mpic->ipi_offset+i].handler = &mpic->hc_ipi; 755 irq_desc[mpic->ipi_offset+i].chip = &mpic->hc_ipi;
756#endif /* CONFIG_SMP */ 756#endif /* CONFIG_SMP */
757 } 757 }
758 758
@@ -813,7 +813,7 @@ void __init mpic_init(struct mpic *mpic)
813 /* init linux descriptors */ 813 /* init linux descriptors */
814 if (i < mpic->irq_count) { 814 if (i < mpic->irq_count) {
815 irq_desc[mpic->irq_offset+i].status = level ? IRQ_LEVEL : 0; 815 irq_desc[mpic->irq_offset+i].status = level ? IRQ_LEVEL : 0;
816 irq_desc[mpic->irq_offset+i].handler = &mpic->hc_irq; 816 irq_desc[mpic->irq_offset+i].chip = &mpic->hc_irq;
817 } 817 }
818 } 818 }
819 819
@@ -906,7 +906,7 @@ void mpic_setup_this_cpu(void)
906 /* let the mpic know we want intrs. default affinity is 0xffffffff 906 /* let the mpic know we want intrs. default affinity is 0xffffffff
907 * until changed via /proc. That's how it's done on x86. If we want 907 * until changed via /proc. That's how it's done on x86. If we want
908 * it differently, then we should make sure we also change the default 908 * it differently, then we should make sure we also change the default
909 * values of irq_affinity in irq.c. 909 * values of irq_desc[].affinity in irq.c.
910 */ 910 */
911 if (distribute_irqs) { 911 if (distribute_irqs) {
912 for (i = 0; i < mpic->num_sources ; i++) 912 for (i = 0; i < mpic->num_sources ; i++)
diff --git a/arch/powerpc/sysdev/todc.c b/arch/powerpc/sysdev/todc.c
new file mode 100644
index 000000000000..0a65980efb50
--- /dev/null
+++ b/arch/powerpc/sysdev/todc.c
@@ -0,0 +1,392 @@
1/*
2 * Time of Day Clock support for the M48T35, M48T37, M48T59, and MC146818
3 * Real Time Clocks/Timekeepers.
4 *
5 * Author: Mark A. Greer <mgreer@mvista.com>
6 *
7 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12#include <linux/errno.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/time.h>
16#include <linux/timex.h>
17#include <linux/bcd.h>
18#include <linux/mc146818rtc.h>
19
20#include <asm/machdep.h>
21#include <asm/io.h>
22#include <asm/time.h>
23#include <asm/todc.h>
24
25/*
26 * Depending on the hardware on your board and your board design, the
27 * RTC/NVRAM may be accessed either directly (like normal memory) or via
28 * address/data registers. If your board uses the direct method, set
29 * 'nvram_data' to the base address of your nvram and leave 'nvram_as0' and
30 * 'nvram_as1' NULL. If your board uses address/data regs to access nvram,
31 * set 'nvram_as0' to the address of the lower byte, set 'nvram_as1' to the
32 * address of the upper byte (leave NULL if using mc146818), and set
33 * 'nvram_data' to the address of the 8-bit data register.
34 *
35 * Note: Even though the documentation for the various RTC chips say that it
36 * take up to a second before it starts updating once the 'R' bit is
37 * cleared, they always seem to update even though we bang on it many
38 * times a second. This is true, except for the Dallas Semi 1746/1747
39 * (possibly others). Those chips seem to have a real problem whenever
40 * we set the 'R' bit before reading them, they basically stop counting.
41 * --MAG
42 */
43
44/*
45 * 'todc_info' should be initialized in your *_setup.c file to
46 * point to a fully initialized 'todc_info_t' structure.
47 * This structure holds all the register offsets for your particular
48 * TODC/RTC chip.
49 * TODC_ALLOC()/TODC_INIT() will allocate and initialize this table for you.
50 */
51
52#ifdef RTC_FREQ_SELECT
53#undef RTC_FREQ_SELECT
54#define RTC_FREQ_SELECT control_b /* Register A */
55#endif
56
57#ifdef RTC_CONTROL
58#undef RTC_CONTROL
59#define RTC_CONTROL control_a /* Register B */
60#endif
61
62#ifdef RTC_INTR_FLAGS
63#undef RTC_INTR_FLAGS
64#define RTC_INTR_FLAGS watchdog /* Register C */
65#endif
66
67#ifdef RTC_VALID
68#undef RTC_VALID
69#define RTC_VALID interrupts /* Register D */
70#endif
71
72/* Access routines when RTC accessed directly (like normal memory) */
73u_char
74todc_direct_read_val(int addr)
75{
76 return readb((void __iomem *)(todc_info->nvram_data + addr));
77}
78
79void
80todc_direct_write_val(int addr, unsigned char val)
81{
82 writeb(val, (void __iomem *)(todc_info->nvram_data + addr));
83 return;
84}
85
86/* Access routines for accessing m48txx type chips via addr/data regs */
87u_char
88todc_m48txx_read_val(int addr)
89{
90 outb(addr, todc_info->nvram_as0);
91 outb(addr>>todc_info->as0_bits, todc_info->nvram_as1);
92 return inb(todc_info->nvram_data);
93}
94
95void
96todc_m48txx_write_val(int addr, unsigned char val)
97{
98 outb(addr, todc_info->nvram_as0);
99 outb(addr>>todc_info->as0_bits, todc_info->nvram_as1);
100 outb(val, todc_info->nvram_data);
101 return;
102}
103
104/* Access routines for accessing mc146818 type chips via addr/data regs */
105u_char
106todc_mc146818_read_val(int addr)
107{
108 outb_p(addr, todc_info->nvram_as0);
109 return inb_p(todc_info->nvram_data);
110}
111
112void
113todc_mc146818_write_val(int addr, unsigned char val)
114{
115 outb_p(addr, todc_info->nvram_as0);
116 outb_p(val, todc_info->nvram_data);
117}
118
119
120/*
121 * Routines to make RTC chips with NVRAM buried behind an addr/data pair
122 * have the NVRAM and clock regs appear at the same level.
123 * The NVRAM will appear to start at addr 0 and the clock regs will appear
124 * to start immediately after the NVRAM (actually, start at offset
125 * todc_info->nvram_size).
126 */
127static inline u_char
128todc_read_val(int addr)
129{
130 u_char val;
131
132 if (todc_info->sw_flags & TODC_FLAG_2_LEVEL_NVRAM) {
133 if (addr < todc_info->nvram_size) { /* NVRAM */
134 ppc_md.rtc_write_val(todc_info->nvram_addr_reg, addr);
135 val = ppc_md.rtc_read_val(todc_info->nvram_data_reg);
136 } else { /* Clock Reg */
137 addr -= todc_info->nvram_size;
138 val = ppc_md.rtc_read_val(addr);
139 }
140 } else
141 val = ppc_md.rtc_read_val(addr);
142
143 return val;
144}
145
146static inline void
147todc_write_val(int addr, u_char val)
148{
149 if (todc_info->sw_flags & TODC_FLAG_2_LEVEL_NVRAM) {
150 if (addr < todc_info->nvram_size) { /* NVRAM */
151 ppc_md.rtc_write_val(todc_info->nvram_addr_reg, addr);
152 ppc_md.rtc_write_val(todc_info->nvram_data_reg, val);
153 } else { /* Clock Reg */
154 addr -= todc_info->nvram_size;
155 ppc_md.rtc_write_val(addr, val);
156 }
157 } else
158 ppc_md.rtc_write_val(addr, val);
159}
160
161/*
162 * TODC routines
163 *
164 * There is some ugly stuff in that there are assumptions for the mc146818.
165 *
166 * Assumptions:
167 * - todc_info->control_a has the offset as mc146818 Register B reg
168 * - todc_info->control_b has the offset as mc146818 Register A reg
169 * - m48txx control reg's write enable or 'W' bit is same as
170 * mc146818 Register B 'SET' bit (i.e., 0x80)
171 *
172 * These assumptions were made to make the code simpler.
173 */
174long __init
175todc_time_init(void)
176{
177 u_char cntl_b;
178
179 if (!ppc_md.rtc_read_val)
180 ppc_md.rtc_read_val = ppc_md.nvram_read_val;
181 if (!ppc_md.rtc_write_val)
182 ppc_md.rtc_write_val = ppc_md.nvram_write_val;
183
184 cntl_b = todc_read_val(todc_info->control_b);
185
186 if (todc_info->rtc_type == TODC_TYPE_MC146818) {
187 if ((cntl_b & 0x70) != 0x20) {
188 printk(KERN_INFO "TODC real-time-clock was stopped."
189 " Now starting...");
190 cntl_b &= ~0x70;
191 cntl_b |= 0x20;
192 }
193
194 todc_write_val(todc_info->control_b, cntl_b);
195 } else if (todc_info->rtc_type == TODC_TYPE_DS17285) {
196 u_char mode;
197
198 mode = todc_read_val(TODC_TYPE_DS17285_CNTL_A);
199 /* Make sure countdown clear is not set */
200 mode &= ~0x40;
201 /* Enable oscillator, extended register set */
202 mode |= 0x30;
203 todc_write_val(TODC_TYPE_DS17285_CNTL_A, mode);
204
205 } else if (todc_info->rtc_type == TODC_TYPE_DS1501) {
206 u_char month;
207
208 todc_info->enable_read = TODC_DS1501_CNTL_B_TE;
209 todc_info->enable_write = TODC_DS1501_CNTL_B_TE;
210
211 month = todc_read_val(todc_info->month);
212
213 if ((month & 0x80) == 0x80) {
214 printk(KERN_INFO "TODC %s %s\n",
215 "real-time-clock was stopped.",
216 "Now starting...");
217 month &= ~0x80;
218 todc_write_val(todc_info->month, month);
219 }
220
221 cntl_b &= ~TODC_DS1501_CNTL_B_TE;
222 todc_write_val(todc_info->control_b, cntl_b);
223 } else { /* must be a m48txx type */
224 u_char cntl_a;
225
226 todc_info->enable_read = TODC_MK48TXX_CNTL_A_R;
227 todc_info->enable_write = TODC_MK48TXX_CNTL_A_W;
228
229 cntl_a = todc_read_val(todc_info->control_a);
230
231 /* Check & clear STOP bit in control B register */
232 if (cntl_b & TODC_MK48TXX_DAY_CB) {
233 printk(KERN_INFO "TODC %s %s\n",
234 "real-time-clock was stopped.",
235 "Now starting...");
236
237 cntl_a |= todc_info->enable_write;
238 cntl_b &= ~TODC_MK48TXX_DAY_CB;/* Start Oscil */
239
240 todc_write_val(todc_info->control_a, cntl_a);
241 todc_write_val(todc_info->control_b, cntl_b);
242 }
243
244 /* Make sure READ & WRITE bits are cleared. */
245 cntl_a &= ~(todc_info->enable_write | todc_info->enable_read);
246 todc_write_val(todc_info->control_a, cntl_a);
247 }
248
249 return 0;
250}
251
252/*
253 * There is some ugly stuff in that there are assumptions that for a mc146818,
254 * the todc_info->control_a has the offset of the mc146818 Register B reg and
255 * that the register'ss 'SET' bit is the same as the m48txx's write enable
256 * bit in the control register of the m48txx (i.e., 0x80).
257 *
258 * It was done to make the code look simpler.
259 */
260void
261todc_get_rtc_time(struct rtc_time *tm)
262{
263 uint year = 0, mon = 0, mday = 0, hour = 0, min = 0, sec = 0;
264 uint limit, i;
265 u_char save_control, uip = 0;
266 extern void GregorianDay(struct rtc_time *);
267
268 spin_lock(&rtc_lock);
269 save_control = todc_read_val(todc_info->control_a);
270
271 if (todc_info->rtc_type != TODC_TYPE_MC146818) {
272 limit = 1;
273
274 switch (todc_info->rtc_type) {
275 case TODC_TYPE_DS1553:
276 case TODC_TYPE_DS1557:
277 case TODC_TYPE_DS1743:
278 case TODC_TYPE_DS1746: /* XXXX BAD HACK -> FIX */
279 case TODC_TYPE_DS1747:
280 case TODC_TYPE_DS17285:
281 break;
282 default:
283 todc_write_val(todc_info->control_a,
284 (save_control | todc_info->enable_read));
285 }
286 } else
287 limit = 100000000;
288
289 for (i=0; i<limit; i++) {
290 if (todc_info->rtc_type == TODC_TYPE_MC146818)
291 uip = todc_read_val(todc_info->RTC_FREQ_SELECT);
292
293 sec = todc_read_val(todc_info->seconds) & 0x7f;
294 min = todc_read_val(todc_info->minutes) & 0x7f;
295 hour = todc_read_val(todc_info->hours) & 0x3f;
296 mday = todc_read_val(todc_info->day_of_month) & 0x3f;
297 mon = todc_read_val(todc_info->month) & 0x1f;
298 year = todc_read_val(todc_info->year) & 0xff;
299
300 if (todc_info->rtc_type == TODC_TYPE_MC146818) {
301 uip |= todc_read_val(todc_info->RTC_FREQ_SELECT);
302 if ((uip & RTC_UIP) == 0)
303 break;
304 }
305 }
306
307 if (todc_info->rtc_type != TODC_TYPE_MC146818) {
308 switch (todc_info->rtc_type) {
309 case TODC_TYPE_DS1553:
310 case TODC_TYPE_DS1557:
311 case TODC_TYPE_DS1743:
312 case TODC_TYPE_DS1746: /* XXXX BAD HACK -> FIX */
313 case TODC_TYPE_DS1747:
314 case TODC_TYPE_DS17285:
315 break;
316 default:
317 save_control &= ~(todc_info->enable_read);
318 todc_write_val(todc_info->control_a, save_control);
319 }
320 }
321 spin_unlock(&rtc_lock);
322
323 if ((todc_info->rtc_type != TODC_TYPE_MC146818)
324 || ((save_control & RTC_DM_BINARY) == 0)
325 || RTC_ALWAYS_BCD) {
326 BCD_TO_BIN(sec);
327 BCD_TO_BIN(min);
328 BCD_TO_BIN(hour);
329 BCD_TO_BIN(mday);
330 BCD_TO_BIN(mon);
331 BCD_TO_BIN(year);
332 }
333
334 if ((year + 1900) < 1970) {
335 year += 100;
336 }
337
338 tm->tm_sec = sec;
339 tm->tm_min = min;
340 tm->tm_hour = hour;
341 tm->tm_mday = mday;
342 tm->tm_mon = mon;
343 tm->tm_year = year;
344
345 GregorianDay(tm);
346}
347
348int
349todc_set_rtc_time(struct rtc_time *tm)
350{
351 u_char save_control, save_freq_select = 0;
352
353 spin_lock(&rtc_lock);
354 save_control = todc_read_val(todc_info->control_a);
355
356 /* Assuming MK48T59_RTC_CA_WRITE & RTC_SET are equal */
357 todc_write_val(todc_info->control_a,
358 (save_control | todc_info->enable_write));
359 save_control &= ~(todc_info->enable_write); /* in case it was set */
360
361 if (todc_info->rtc_type == TODC_TYPE_MC146818) {
362 save_freq_select = todc_read_val(todc_info->RTC_FREQ_SELECT);
363 todc_write_val(todc_info->RTC_FREQ_SELECT,
364 save_freq_select | RTC_DIV_RESET2);
365 }
366
367 if ((todc_info->rtc_type != TODC_TYPE_MC146818)
368 || ((save_control & RTC_DM_BINARY) == 0)
369 || RTC_ALWAYS_BCD) {
370 BIN_TO_BCD(tm->tm_sec);
371 BIN_TO_BCD(tm->tm_min);
372 BIN_TO_BCD(tm->tm_hour);
373 BIN_TO_BCD(tm->tm_mon);
374 BIN_TO_BCD(tm->tm_mday);
375 BIN_TO_BCD(tm->tm_year);
376 }
377
378 todc_write_val(todc_info->seconds, tm->tm_sec);
379 todc_write_val(todc_info->minutes, tm->tm_min);
380 todc_write_val(todc_info->hours, tm->tm_hour);
381 todc_write_val(todc_info->month, tm->tm_mon);
382 todc_write_val(todc_info->day_of_month, tm->tm_mday);
383 todc_write_val(todc_info->year, tm->tm_year);
384
385 todc_write_val(todc_info->control_a, save_control);
386
387 if (todc_info->rtc_type == TODC_TYPE_MC146818)
388 todc_write_val(todc_info->RTC_FREQ_SELECT, save_freq_select);
389
390 spin_unlock(&rtc_lock);
391 return 0;
392}
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c
new file mode 100644
index 000000000000..26a0cc820cde
--- /dev/null
+++ b/arch/powerpc/sysdev/tsi108_dev.c
@@ -0,0 +1,145 @@
1/*
2 * tsi108/109 device setup code
3 *
4 * Maintained by Roy Zang < tie-fei.zang@freescale.com >
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/major.h>
18#include <linux/delay.h>
19#include <linux/irq.h>
20#include <linux/module.h>
21#include <linux/device.h>
22#include <linux/platform_device.h>
23#include <asm/tsi108.h>
24
25#include <asm/system.h>
26#include <asm/atomic.h>
27#include <asm/io.h>
28#include <asm/irq.h>
29#include <asm/prom.h>
30#include <mm/mmu_decl.h>
31
32#undef DEBUG
33
34#ifdef DEBUG
35#define DBG(fmt...) do { printk(fmt); } while(0)
36#else
37#define DBG(fmt...) do { } while(0)
38#endif
39
40static phys_addr_t tsi108_csr_base = -1;
41
42phys_addr_t get_csrbase(void)
43{
44 struct device_node *tsi;
45
46 if (tsi108_csr_base != -1)
47 return tsi108_csr_base;
48
49 tsi = of_find_node_by_type(NULL, "tsi-bridge");
50 if (tsi) {
51 unsigned int size;
52 void *prop = get_property(tsi, "reg", &size);
53 tsi108_csr_base = of_translate_address(tsi, prop);
54 of_node_put(tsi);
55 };
56 return tsi108_csr_base;
57}
58
59u32 get_vir_csrbase(void)
60{
61 return (u32) (ioremap(get_csrbase(), 0x10000));
62}
63
64EXPORT_SYMBOL(get_csrbase);
65EXPORT_SYMBOL(get_vir_csrbase);
66
67static int __init tsi108_eth_of_init(void)
68{
69 struct device_node *np;
70 unsigned int i;
71 struct platform_device *tsi_eth_dev;
72 struct resource res;
73 int ret;
74
75 for (np = NULL, i = 0;
76 (np = of_find_compatible_node(np, "network", "tsi-ethernet")) != NULL;
77 i++) {
78 struct resource r[2];
79 struct device_node *phy;
80 hw_info tsi_eth_data;
81 unsigned int *id;
82 unsigned int *phy_id;
83 void *mac_addr;
84 phandle *ph;
85
86 memset(r, 0, sizeof(r));
87 memset(&tsi_eth_data, 0, sizeof(tsi_eth_data));
88
89 ret = of_address_to_resource(np, 0, &r[0]);
90 DBG("%s: name:start->end = %s:0x%lx-> 0x%lx\n",
91 __FUNCTION__,r[0].name, r[0].start, r[0].end);
92 if (ret)
93 goto err;
94
95 r[1].name = "tx";
96 r[1].start = np->intrs[0].line;
97 r[1].end = np->intrs[0].line;
98 r[1].flags = IORESOURCE_IRQ;
99
100 tsi_eth_dev =
101 platform_device_register_simple("tsi-ethernet", i, &r[0],
102 np->n_intrs + 1);
103
104 if (IS_ERR(tsi_eth_dev)) {
105 ret = PTR_ERR(tsi_eth_dev);
106 goto err;
107 }
108
109 mac_addr = get_property(np, "address", NULL);
110 memcpy(tsi_eth_data.mac_addr, mac_addr, 6);
111
112 ph = (phandle *) get_property(np, "phy-handle", NULL);
113 phy = of_find_node_by_phandle(*ph);
114
115 if (phy == NULL) {
116 ret = -ENODEV;
117 goto unreg;
118 }
119
120 id = (u32 *) get_property(phy, "reg", NULL);
121 phy_id = (u32 *) get_property(phy, "phy-id", NULL);
122 ret = of_address_to_resource(phy, 0, &res);
123 if (ret) {
124 of_node_put(phy);
125 goto unreg;
126 }
127 tsi_eth_data.regs = r[0].start;
128 tsi_eth_data.phyregs = res.start;
129 tsi_eth_data.phy = *phy_id;
130 tsi_eth_data.irq_num = np->intrs[0].line;
131 of_node_put(phy);
132 ret =
133 platform_device_add_data(tsi_eth_dev, &tsi_eth_data,
134 sizeof(hw_info));
135 if (ret)
136 goto unreg;
137 }
138 return 0;
139unreg:
140 platform_device_unregister(tsi_eth_dev);
141err:
142 return ret;
143}
144
145arch_initcall(tsi108_eth_of_init);
diff --git a/arch/powerpc/sysdev/tsi108_pci.c b/arch/powerpc/sysdev/tsi108_pci.c
new file mode 100644
index 000000000000..3265d54c82ed
--- /dev/null
+++ b/arch/powerpc/sysdev/tsi108_pci.c
@@ -0,0 +1,412 @@
1/*
2 * Common routines for Tundra Semiconductor TSI108 host bridge.
3 *
4 * 2004-2005 (c) Tundra Semiconductor Corp.
5 * Author: Alex Bounine (alexandreb@tundra.com)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59
19 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/pci.h>
25#include <linux/slab.h>
26#include <linux/irq.h>
27#include <linux/interrupt.h>
28
29
30#include <asm/byteorder.h>
31#include <asm/io.h>
32#include <asm/irq.h>
33#include <asm/uaccess.h>
34#include <asm/machdep.h>
35#include <asm/pci-bridge.h>
36#include <asm/tsi108.h>
37#include <asm/tsi108_irq.h>
38#include <asm/prom.h>
39
40#undef DEBUG
41#ifdef DEBUG
42#define DBG(x...) printk(x)
43#else
44#define DBG(x...)
45#endif
46
47#define tsi_mk_config_addr(bus, devfunc, offset) \
48 ((((bus)<<16) | ((devfunc)<<8) | (offset & 0xfc)) + tsi108_pci_cfg_base)
49
50u32 tsi108_pci_cfg_base;
51u32 tsi108_csr_vir_base;
52
53extern u32 get_vir_csrbase(void);
54extern u32 tsi108_read_reg(u32 reg_offset);
55extern void tsi108_write_reg(u32 reg_offset, u32 val);
56
57int
58tsi108_direct_write_config(struct pci_bus *bus, unsigned int devfunc,
59 int offset, int len, u32 val)
60{
61 volatile unsigned char *cfg_addr;
62
63 if (ppc_md.pci_exclude_device)
64 if (ppc_md.pci_exclude_device(bus->number, devfunc))
65 return PCIBIOS_DEVICE_NOT_FOUND;
66
67 cfg_addr = (unsigned char *)(tsi_mk_config_addr(bus->number,
68 devfunc, offset) |
69 (offset & 0x03));
70
71#ifdef DEBUG
72 printk("PCI CFG write : ");
73 printk("%d:0x%x:0x%x ", bus->number, devfunc, offset);
74 printk("%d ADDR=0x%08x ", len, (uint) cfg_addr);
75 printk("data = 0x%08x\n", val);
76#endif
77
78 switch (len) {
79 case 1:
80 out_8((u8 *) cfg_addr, val);
81 break;
82 case 2:
83 out_le16((u16 *) cfg_addr, val);
84 break;
85 default:
86 out_le32((u32 *) cfg_addr, val);
87 break;
88 }
89
90 return PCIBIOS_SUCCESSFUL;
91}
92
93void tsi108_clear_pci_error(u32 pci_cfg_base)
94{
95 u32 err_stat, err_addr, pci_stat;
96
97 /*
98 * Quietly clear PB and PCI error flags set as result
99 * of PCI/X configuration read requests.
100 */
101
102 /* Read PB Error Log Registers */
103
104 err_stat = tsi108_read_reg(TSI108_PB_OFFSET + TSI108_PB_ERRCS);
105 err_addr = tsi108_read_reg(TSI108_PB_OFFSET + TSI108_PB_AERR);
106
107 if (err_stat & TSI108_PB_ERRCS_ES) {
108 /* Clear error flag */
109 tsi108_write_reg(TSI108_PB_OFFSET + TSI108_PB_ERRCS,
110 TSI108_PB_ERRCS_ES);
111
112 /* Clear read error reported in PB_ISR */
113 tsi108_write_reg(TSI108_PB_OFFSET + TSI108_PB_ISR,
114 TSI108_PB_ISR_PBS_RD_ERR);
115
116 /* Clear PCI/X bus cfg errors if applicable */
117 if ((err_addr & 0xFF000000) == pci_cfg_base) {
118 pci_stat =
119 tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_CSR);
120 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_CSR,
121 pci_stat);
122 }
123 }
124
125 return;
126}
127
128#define __tsi108_read_pci_config(x, addr, op) \
129 __asm__ __volatile__( \
130 " "op" %0,0,%1\n" \
131 "1: eieio\n" \
132 "2:\n" \
133 ".section .fixup,\"ax\"\n" \
134 "3: li %0,-1\n" \
135 " b 2b\n" \
136 ".section __ex_table,\"a\"\n" \
137 " .align 2\n" \
138 " .long 1b,3b\n" \
139 ".text" \
140 : "=r"(x) : "r"(addr))
141
142int
143tsi108_direct_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
144 int len, u32 * val)
145{
146 volatile unsigned char *cfg_addr;
147 u32 temp;
148
149 if (ppc_md.pci_exclude_device)
150 if (ppc_md.pci_exclude_device(bus->number, devfn))
151 return PCIBIOS_DEVICE_NOT_FOUND;
152
153 cfg_addr = (unsigned char *)(tsi_mk_config_addr(bus->number,
154 devfn,
155 offset) | (offset &
156 0x03));
157
158 switch (len) {
159 case 1:
160 __tsi108_read_pci_config(temp, cfg_addr, "lbzx");
161 break;
162 case 2:
163 __tsi108_read_pci_config(temp, cfg_addr, "lhbrx");
164 break;
165 default:
166 __tsi108_read_pci_config(temp, cfg_addr, "lwbrx");
167 break;
168 }
169
170 *val = temp;
171
172#ifdef DEBUG
173 if ((0xFFFFFFFF != temp) && (0xFFFF != temp) && (0xFF != temp)) {
174 printk("PCI CFG read : ");
175 printk("%d:0x%x:0x%x ", bus->number, devfn, offset);
176 printk("%d ADDR=0x%08x ", len, (uint) cfg_addr);
177 printk("data = 0x%x\n", *val);
178 }
179#endif
180 return PCIBIOS_SUCCESSFUL;
181}
182
183void tsi108_clear_pci_cfg_error(void)
184{
185 tsi108_clear_pci_error(TSI108_PCI_CFG_BASE_PHYS);
186}
187
188static struct pci_ops tsi108_direct_pci_ops = {
189 tsi108_direct_read_config,
190 tsi108_direct_write_config
191};
192
193int __init tsi108_setup_pci(struct device_node *dev)
194{
195 int len;
196 struct pci_controller *hose;
197 struct resource rsrc;
198 int *bus_range;
199 int primary = 0, has_address = 0;
200
201 /* PCI Config mapping */
202 tsi108_pci_cfg_base = (u32)ioremap(TSI108_PCI_CFG_BASE_PHYS,
203 TSI108_PCI_CFG_SIZE);
204 DBG("TSI_PCI: %s tsi108_pci_cfg_base=0x%x\n", __FUNCTION__,
205 tsi108_pci_cfg_base);
206
207 /* Fetch host bridge registers address */
208 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
209
210 /* Get bus range if any */
211 bus_range = (int *)get_property(dev, "bus-range", &len);
212 if (bus_range == NULL || len < 2 * sizeof(int)) {
213 printk(KERN_WARNING "Can't get bus-range for %s, assume"
214 " bus 0\n", dev->full_name);
215 }
216
217 hose = pcibios_alloc_controller();
218
219 if (!hose) {
220 printk("PCI Host bridge init failed\n");
221 return -ENOMEM;
222 }
223 hose->arch_data = dev;
224 hose->set_cfg_type = 1;
225
226 hose->first_busno = bus_range ? bus_range[0] : 0;
227 hose->last_busno = bus_range ? bus_range[1] : 0xff;
228
229 (hose)->ops = &tsi108_direct_pci_ops;
230
231 printk(KERN_INFO "Found tsi108 PCI host bridge at 0x%08lx. "
232 "Firmware bus number: %d->%d\n",
233 rsrc.start, hose->first_busno, hose->last_busno);
234
235 /* Interpret the "ranges" property */
236 /* This also maps the I/O region and sets isa_io/mem_base */
237 pci_process_bridge_OF_ranges(hose, dev, primary);
238 return 0;
239}
240
241/*
242 * Low level utility functions
243 */
244
245static void tsi108_pci_int_mask(u_int irq)
246{
247 u_int irp_cfg;
248 int int_line = (irq - IRQ_PCI_INTAD_BASE);
249
250 irp_cfg = tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL);
251 mb();
252 irp_cfg |= (1 << int_line); /* INTx_DIR = output */
253 irp_cfg &= ~(3 << (8 + (int_line * 2))); /* INTx_TYPE = unused */
254 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL, irp_cfg);
255 mb();
256 irp_cfg = tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL);
257}
258
259static void tsi108_pci_int_unmask(u_int irq)
260{
261 u_int irp_cfg;
262 int int_line = (irq - IRQ_PCI_INTAD_BASE);
263
264 irp_cfg = tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL);
265 mb();
266 irp_cfg &= ~(1 << int_line);
267 irp_cfg |= (3 << (8 + (int_line * 2)));
268 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL, irp_cfg);
269 mb();
270}
271
272static void init_pci_source(void)
273{
274 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL,
275 0x0000ff00);
276 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE,
277 TSI108_PCI_IRP_ENABLE_P_INT);
278 mb();
279}
280
281static inline int get_pci_source(void)
282{
283 u_int temp = 0;
284 int irq = -1;
285 int i;
286 u_int pci_irp_stat;
287 static int mask = 0;
288
289 /* Read PCI/X block interrupt status register */
290 pci_irp_stat = tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_STAT);
291 mb();
292
293 if (pci_irp_stat & TSI108_PCI_IRP_STAT_P_INT) {
294 /* Process Interrupt from PCI bus INTA# - INTD# lines */
295 temp =
296 tsi108_read_reg(TSI108_PCI_OFFSET +
297 TSI108_PCI_IRP_INTAD) & 0xf;
298 mb();
299 for (i = 0; i < 4; i++, mask++) {
300 if (temp & (1 << mask % 4)) {
301 irq = IRQ_PCI_INTA + mask % 4;
302 mask++;
303 break;
304 }
305 }
306
307 /* Disable interrupts from PCI block */
308 temp = tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE);
309 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE,
310 temp & ~TSI108_PCI_IRP_ENABLE_P_INT);
311 mb();
312 (void)tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE);
313 mb();
314 }
315#ifdef DEBUG
316 else {
317 printk("TSI108_PIC: error in TSI108_PCI_IRP_STAT\n");
318 pci_irp_stat =
319 tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_STAT);
320 temp =
321 tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_INTAD);
322 mb();
323 printk(">> stat=0x%08x intad=0x%08x ", pci_irp_stat, temp);
324 temp =
325 tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL);
326 mb();
327 printk("cfg_ctl=0x%08x ", temp);
328 temp =
329 tsi108_read_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE);
330 mb();
331 printk("irp_enable=0x%08x\n", temp);
332 }
333#endif /* end of DEBUG */
334
335 return irq;
336}
337
338
339/*
340 * Linux descriptor level callbacks
341 */
342
343static void tsi108_pci_irq_enable(u_int irq)
344{
345 tsi108_pci_int_unmask(irq);
346}
347
348static void tsi108_pci_irq_disable(u_int irq)
349{
350 tsi108_pci_int_mask(irq);
351}
352
353static void tsi108_pci_irq_ack(u_int irq)
354{
355 tsi108_pci_int_mask(irq);
356}
357
358static void tsi108_pci_irq_end(u_int irq)
359{
360 tsi108_pci_int_unmask(irq);
361
362 /* Enable interrupts from PCI block */
363 tsi108_write_reg(TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE,
364 tsi108_read_reg(TSI108_PCI_OFFSET +
365 TSI108_PCI_IRP_ENABLE) |
366 TSI108_PCI_IRP_ENABLE_P_INT);
367 mb();
368}
369
370/*
371 * Interrupt controller descriptor for cascaded PCI interrupt controller.
372 */
373
374struct hw_interrupt_type tsi108_pci_irq = {
375 .typename = "tsi108_PCI_int",
376 .enable = tsi108_pci_irq_enable,
377 .disable = tsi108_pci_irq_disable,
378 .ack = tsi108_pci_irq_ack,
379 .end = tsi108_pci_irq_end,
380};
381
382/*
383 * Exported functions
384 */
385
386/*
387 * The Tsi108 PCI interrupts initialization routine.
388 *
389 * The INTA# - INTD# interrupts on the PCI bus are reported by the PCI block
390 * to the MPIC using single interrupt source (IRQ_TSI108_PCI). Therefore the
391 * PCI block has to be treated as a cascaded interrupt controller connected
392 * to the MPIC.
393 */
394
395void __init tsi108_pci_int_init(void)
396{
397 u_int i;
398
399 DBG("Tsi108_pci_int_init: initializing PCI interrupts\n");
400
401 for (i = 0; i < NUM_PCI_IRQS; i++) {
402 irq_desc[i + IRQ_PCI_INTAD_BASE].handler = &tsi108_pci_irq;
403 irq_desc[i + IRQ_PCI_INTAD_BASE].status |= IRQ_LEVEL;
404 }
405
406 init_pci_source();
407}
408
409int tsi108_irq_cascade(struct pt_regs *regs, void *unused)
410{
411 return get_pci_source();
412}
diff --git a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
index 98b25fa0049a..1e113d0f59b8 100644
--- a/arch/ppc/4xx_io/serial_sicc.c
+++ b/arch/ppc/4xx_io/serial_sicc.c
@@ -1758,7 +1758,7 @@ int __init siccuart_init(void)
1758 siccnormal_driver->subtype = SERIAL_TYPE_NORMAL; 1758 siccnormal_driver->subtype = SERIAL_TYPE_NORMAL;
1759 siccnormal_driver->init_termios = tty_std_termios; 1759 siccnormal_driver->init_termios = tty_std_termios;
1760 siccnormal_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1760 siccnormal_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1761 siccnormal_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 1761 siccnormal_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1762 tty_set_operations(siccnormal_driver, &sicc_ops); 1762 tty_set_operations(siccnormal_driver, &sicc_ops);
1763 1763
1764 if (tty_register_driver(siccnormal_driver)) 1764 if (tty_register_driver(siccnormal_driver))
diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index 12b84ca51327..9b3ace26280c 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -187,7 +187,7 @@ cpm_interrupt_init(void)
187 * interrupt vectors 187 * interrupt vectors
188 */ 188 */
189 for ( i = CPM_IRQ_OFFSET ; i < CPM_IRQ_OFFSET + NR_CPM_INTS ; i++ ) 189 for ( i = CPM_IRQ_OFFSET ; i < CPM_IRQ_OFFSET + NR_CPM_INTS ; i++ )
190 irq_desc[i].handler = &cpm_pic; 190 irq_desc[i].chip = &cpm_pic;
191 191
192 /* Set our interrupt handler with the core CPU. */ 192 /* Set our interrupt handler with the core CPU. */
193 if (setup_irq(CPM_INTERRUPT, &cpm_interrupt_irqaction)) 193 if (setup_irq(CPM_INTERRUPT, &cpm_interrupt_irqaction))
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index b55de4f42aec..a04cdf01596b 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -219,10 +219,10 @@ config KEXEC
219 help 219 help
220 kexec is a system call that implements the ability to shutdown your 220 kexec is a system call that implements the ability to shutdown your
221 current kernel, and to start another kernel. It is like a reboot 221 current kernel, and to start another kernel. It is like a reboot
222 but it is indepedent of the system firmware. And like a reboot 222 but it is independent of the system firmware. And like a reboot
223 you can start any kernel with it, not just Linux. 223 you can start any kernel with it, not just Linux.
224 224
225 The name comes from the similiarity to the exec system call. 225 The name comes from the similarity to the exec system call.
226 226
227 It is an ongoing process to be certain the hardware in a machine 227 It is an ongoing process to be certain the hardware in a machine
228 is properly shutdown, so do not be surprised if this code does not 228 is properly shutdown, so do not be surprised if this code does not
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index d20accf9650d..242bb052be67 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -95,8 +95,10 @@ pcibios_fixup_resources(struct pci_dev *dev)
95 if (!res->flags) 95 if (!res->flags)
96 continue; 96 continue;
97 if (res->end == 0xffffffff) { 97 if (res->end == 0xffffffff) {
98 DBG("PCI:%s Resource %d [%08lx-%08lx] is unassigned\n", 98 DBG("PCI:%s Resource %d [%016llx-%016llx] is unassigned\n",
99 pci_name(dev), i, res->start, res->end); 99 pci_name(dev), i,
100 (unsigned long long)res->start,
101 (unsigned long long)res->end);
100 res->end -= res->start; 102 res->end -= res->start;
101 res->start = 0; 103 res->start = 0;
102 res->flags |= IORESOURCE_UNSET; 104 res->flags |= IORESOURCE_UNSET;
@@ -169,18 +171,18 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
169 * but we want to try to avoid allocating at 0x2900-0x2bff 171 * but we want to try to avoid allocating at 0x2900-0x2bff
170 * which might have be mirrored at 0x0100-0x03ff.. 172 * which might have be mirrored at 0x0100-0x03ff..
171 */ 173 */
172void pcibios_align_resource(void *data, struct resource *res, unsigned long size, 174void pcibios_align_resource(void *data, struct resource *res,
173 unsigned long align) 175 resource_size_t size, resource_size_t align)
174{ 176{
175 struct pci_dev *dev = data; 177 struct pci_dev *dev = data;
176 178
177 if (res->flags & IORESOURCE_IO) { 179 if (res->flags & IORESOURCE_IO) {
178 unsigned long start = res->start; 180 resource_size_t start = res->start;
179 181
180 if (size > 0x100) { 182 if (size > 0x100) {
181 printk(KERN_ERR "PCI: I/O Region %s/%d too large" 183 printk(KERN_ERR "PCI: I/O Region %s/%d too large"
182 " (%ld bytes)\n", pci_name(dev), 184 " (%lld bytes)\n", pci_name(dev),
183 dev->resource - res, size); 185 dev->resource - res, (unsigned long long)size);
184 } 186 }
185 187
186 if (start & 0x300) { 188 if (start & 0x300) {
@@ -251,8 +253,9 @@ pcibios_allocate_bus_resources(struct list_head *bus_list)
251 } 253 }
252 } 254 }
253 255
254 DBG("PCI: bridge rsrc %lx..%lx (%lx), parent %p\n", 256 DBG("PCI: bridge rsrc %llx..%llx (%lx), parent %p\n",
255 res->start, res->end, res->flags, pr); 257 (unsigned long long)res->start,
258 (unsigned long long)res->end, res->flags, pr);
256 if (pr) { 259 if (pr) {
257 if (request_resource(pr, res) == 0) 260 if (request_resource(pr, res) == 0)
258 continue; 261 continue;
@@ -302,8 +305,9 @@ reparent_resources(struct resource *parent, struct resource *res)
302 *pp = NULL; 305 *pp = NULL;
303 for (p = res->child; p != NULL; p = p->sibling) { 306 for (p = res->child; p != NULL; p = p->sibling) {
304 p->parent = res; 307 p->parent = res;
305 DBG(KERN_INFO "PCI: reparented %s [%lx..%lx] under %s\n", 308 DBG(KERN_INFO "PCI: reparented %s [%llx..%llx] under %s\n",
306 p->name, p->start, p->end, res->name); 309 p->name, (unsigned long long)p->start,
310 (unsigned long long)p->end, res->name);
307 } 311 }
308 return 0; 312 return 0;
309} 313}
@@ -358,13 +362,15 @@ pci_relocate_bridge_resource(struct pci_bus *bus, int i)
358 try = conflict->start - 1; 362 try = conflict->start - 1;
359 } 363 }
360 if (request_resource(pr, res)) { 364 if (request_resource(pr, res)) {
361 DBG(KERN_ERR "PCI: huh? couldn't move to %lx..%lx\n", 365 DBG(KERN_ERR "PCI: huh? couldn't move to %llx..%llx\n",
362 res->start, res->end); 366 (unsigned long long)res->start,
367 (unsigned long long)res->end);
363 return -1; /* "can't happen" */ 368 return -1; /* "can't happen" */
364 } 369 }
365 update_bridge_base(bus, i); 370 update_bridge_base(bus, i);
366 printk(KERN_INFO "PCI: bridge %d resource %d moved to %lx..%lx\n", 371 printk(KERN_INFO "PCI: bridge %d resource %d moved to %llx..%llx\n",
367 bus->number, i, res->start, res->end); 372 bus->number, i, (unsigned long long)res->start,
373 (unsigned long long)res->end);
368 return 0; 374 return 0;
369} 375}
370 376
@@ -475,15 +481,17 @@ static inline void alloc_resource(struct pci_dev *dev, int idx)
475{ 481{
476 struct resource *pr, *r = &dev->resource[idx]; 482 struct resource *pr, *r = &dev->resource[idx];
477 483
478 DBG("PCI:%s: Resource %d: %08lx-%08lx (f=%lx)\n", 484 DBG("PCI:%s: Resource %d: %016llx-%016llx (f=%lx)\n",
479 pci_name(dev), idx, r->start, r->end, r->flags); 485 pci_name(dev), idx, (unsigned long long)r->start,
486 (unsigned long long)r->end, r->flags);
480 pr = pci_find_parent_resource(dev, r); 487 pr = pci_find_parent_resource(dev, r);
481 if (!pr || request_resource(pr, r) < 0) { 488 if (!pr || request_resource(pr, r) < 0) {
482 printk(KERN_ERR "PCI: Cannot allocate resource region %d" 489 printk(KERN_ERR "PCI: Cannot allocate resource region %d"
483 " of device %s\n", idx, pci_name(dev)); 490 " of device %s\n", idx, pci_name(dev));
484 if (pr) 491 if (pr)
485 DBG("PCI: parent is %p: %08lx-%08lx (f=%lx)\n", 492 DBG("PCI: parent is %p: %016llx-%016llx (f=%lx)\n",
486 pr, pr->start, pr->end, pr->flags); 493 pr, (unsigned long long)pr->start,
494 (unsigned long long)pr->end, pr->flags);
487 /* We'll assign a new address later */ 495 /* We'll assign a new address later */
488 r->flags |= IORESOURCE_UNSET; 496 r->flags |= IORESOURCE_UNSET;
489 r->end -= r->start; 497 r->end -= r->start;
@@ -952,8 +960,8 @@ static pgprot_t __pci_mmap_set_pgprot(struct pci_dev *dev, struct resource *rp,
952 else 960 else
953 prot |= _PAGE_GUARDED; 961 prot |= _PAGE_GUARDED;
954 962
955 printk("PCI map for %s:%lx, prot: %lx\n", pci_name(dev), rp->start, 963 printk("PCI map for %s:%llx, prot: %lx\n", pci_name(dev),
956 prot); 964 (unsigned long long)rp->start, prot);
957 965
958 return __pgprot(prot); 966 return __pgprot(prot);
959} 967}
@@ -1122,7 +1130,7 @@ long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
1122 1130
1123void pci_resource_to_user(const struct pci_dev *dev, int bar, 1131void pci_resource_to_user(const struct pci_dev *dev, int bar,
1124 const struct resource *rsrc, 1132 const struct resource *rsrc,
1125 u64 *start, u64 *end) 1133 resource_size_t *start, resource_size_t *end)
1126{ 1134{
1127 struct pci_controller *hose = pci_bus_to_hose(dev->bus->number); 1135 struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
1128 unsigned long offset = 0; 1136 unsigned long offset = 0;
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index 1f79e84ab464..4b4607d89bfa 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -475,7 +475,7 @@ int __init ppc_init(void)
475 475
476 /* register CPU devices */ 476 /* register CPU devices */
477 for_each_possible_cpu(i) 477 for_each_possible_cpu(i)
478 register_cpu(&cpu_devices[i], i, NULL); 478 register_cpu(&cpu_devices[i], i);
479 479
480 /* call platform init */ 480 /* call platform init */
481 if (ppc_md.init != NULL) { 481 if (ppc_md.init != NULL) {
diff --git a/arch/ppc/platforms/apus_setup.c b/arch/ppc/platforms/apus_setup.c
index fe0cdc04d436..5c4118a459f3 100644
--- a/arch/ppc/platforms/apus_setup.c
+++ b/arch/ppc/platforms/apus_setup.c
@@ -734,9 +734,9 @@ void apus_init_IRQ(void)
734 for ( i = 0 ; i < AMI_IRQS; i++ ) { 734 for ( i = 0 ; i < AMI_IRQS; i++ ) {
735 irq_desc[i].status = IRQ_LEVEL; 735 irq_desc[i].status = IRQ_LEVEL;
736 if (i < IRQ_AMIGA_AUTO) { 736 if (i < IRQ_AMIGA_AUTO) {
737 irq_desc[i].handler = &amiga_irqctrl; 737 irq_desc[i].chip = &amiga_irqctrl;
738 } else { 738 } else {
739 irq_desc[i].handler = &amiga_sys_irqctrl; 739 irq_desc[i].chip = &amiga_sys_irqctrl;
740 action = &amiga_sys_irqaction[i-IRQ_AMIGA_AUTO]; 740 action = &amiga_sys_irqaction[i-IRQ_AMIGA_AUTO];
741 if (action->name) 741 if (action->name)
742 setup_irq(i, action); 742 setup_irq(i, action);
diff --git a/arch/ppc/platforms/sbc82xx.c b/arch/ppc/platforms/sbc82xx.c
index 866807b4ad0b..41006d2b4b38 100644
--- a/arch/ppc/platforms/sbc82xx.c
+++ b/arch/ppc/platforms/sbc82xx.c
@@ -172,7 +172,7 @@ void __init sbc82xx_init_IRQ(void)
172 172
173 /* Set up the interrupt handlers for the i8259 IRQs */ 173 /* Set up the interrupt handlers for the i8259 IRQs */
174 for (i = NR_SIU_INTS; i < NR_SIU_INTS + 8; i++) { 174 for (i = NR_SIU_INTS; i < NR_SIU_INTS + 8; i++) {
175 irq_desc[i].handler = &sbc82xx_i8259_ic; 175 irq_desc[i].chip = &sbc82xx_i8259_ic;
176 irq_desc[i].status |= IRQ_LEVEL; 176 irq_desc[i].status |= IRQ_LEVEL;
177 } 177 }
178 178
diff --git a/arch/ppc/syslib/cpc700_pic.c b/arch/ppc/syslib/cpc700_pic.c
index 5add0a919ef6..172aa215fdb0 100644
--- a/arch/ppc/syslib/cpc700_pic.c
+++ b/arch/ppc/syslib/cpc700_pic.c
@@ -140,12 +140,12 @@ cpc700_init_IRQ(void)
140 /* IRQ 0 is highest */ 140 /* IRQ 0 is highest */
141 141
142 for (i = 0; i < 17; i++) { 142 for (i = 0; i < 17; i++) {
143 irq_desc[i].handler = &cpc700_pic; 143 irq_desc[i].chip = &cpc700_pic;
144 cpc700_pic_init_irq(i); 144 cpc700_pic_init_irq(i);
145 } 145 }
146 146
147 for (i = 20; i < 32; i++) { 147 for (i = 20; i < 32; i++) {
148 irq_desc[i].handler = &cpc700_pic; 148 irq_desc[i].chip = &cpc700_pic;
149 cpc700_pic_init_irq(i); 149 cpc700_pic_init_irq(i);
150 } 150 }
151 151
diff --git a/arch/ppc/syslib/cpm2_pic.c b/arch/ppc/syslib/cpm2_pic.c
index 29d95d415ceb..c0fee0beb815 100644
--- a/arch/ppc/syslib/cpm2_pic.c
+++ b/arch/ppc/syslib/cpm2_pic.c
@@ -171,7 +171,7 @@ void cpm2_init_IRQ(void)
171 /* Enable chaining to OpenPIC, and make everything level 171 /* Enable chaining to OpenPIC, and make everything level
172 */ 172 */
173 for (i = 0; i < NR_CPM_INTS; i++) { 173 for (i = 0; i < NR_CPM_INTS; i++) {
174 irq_desc[i+CPM_IRQ_OFFSET].handler = &cpm2_pic; 174 irq_desc[i+CPM_IRQ_OFFSET].chip = &cpm2_pic;
175 irq_desc[i+CPM_IRQ_OFFSET].status |= IRQ_LEVEL; 175 irq_desc[i+CPM_IRQ_OFFSET].status |= IRQ_LEVEL;
176 } 176 }
177} 177}
diff --git a/arch/ppc/syslib/gt64260_pic.c b/arch/ppc/syslib/gt64260_pic.c
index dc3bd9ecbbf6..91096b38ae70 100644
--- a/arch/ppc/syslib/gt64260_pic.c
+++ b/arch/ppc/syslib/gt64260_pic.c
@@ -98,7 +98,7 @@ gt64260_init_irq(void)
98 98
99 /* use the gt64260 for all (possible) interrupt sources */ 99 /* use the gt64260 for all (possible) interrupt sources */
100 for (i = gt64260_irq_base; i < (gt64260_irq_base + 96); i++) 100 for (i = gt64260_irq_base; i < (gt64260_irq_base + 96); i++)
101 irq_desc[i].handler = &gt64260_pic; 101 irq_desc[i].chip = &gt64260_pic;
102 102
103 if (ppc_md.progress) 103 if (ppc_md.progress)
104 ppc_md.progress("gt64260_init_irq: exit", 0x0); 104 ppc_md.progress("gt64260_init_irq: exit", 0x0);
diff --git a/arch/ppc/syslib/m82xx_pci.c b/arch/ppc/syslib/m82xx_pci.c
index 1941a8c7ca9a..63fa5b313396 100644
--- a/arch/ppc/syslib/m82xx_pci.c
+++ b/arch/ppc/syslib/m82xx_pci.c
@@ -159,7 +159,7 @@ pq2pci_init_irq(void)
159 immap->im_memctl.memc_or8 = 0xffff8010; 159 immap->im_memctl.memc_or8 = 0xffff8010;
160#endif 160#endif
161 for (irq = NR_CPM_INTS; irq < NR_CPM_INTS + 4; irq++) 161 for (irq = NR_CPM_INTS; irq < NR_CPM_INTS + 4; irq++)
162 irq_desc[irq].handler = &pq2pci_ic; 162 irq_desc[irq].chip = &pq2pci_ic;
163 163
164 /* make PCI IRQ level sensitive */ 164 /* make PCI IRQ level sensitive */
165 immap->im_intctl.ic_siexr &= 165 immap->im_intctl.ic_siexr &=
diff --git a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
index dae9af78bde1..0c4c0de7c59f 100644
--- a/arch/ppc/syslib/m8xx_setup.c
+++ b/arch/ppc/syslib/m8xx_setup.c
@@ -347,13 +347,13 @@ m8xx_init_IRQ(void)
347 int i; 347 int i;
348 348
349 for (i = SIU_IRQ_OFFSET ; i < SIU_IRQ_OFFSET + NR_SIU_INTS ; i++) 349 for (i = SIU_IRQ_OFFSET ; i < SIU_IRQ_OFFSET + NR_SIU_INTS ; i++)
350 irq_desc[i].handler = &ppc8xx_pic; 350 irq_desc[i].chip = &ppc8xx_pic;
351 351
352 cpm_interrupt_init(); 352 cpm_interrupt_init();
353 353
354#if defined(CONFIG_PCI) 354#if defined(CONFIG_PCI)
355 for (i = I8259_IRQ_OFFSET ; i < I8259_IRQ_OFFSET + NR_8259_INTS ; i++) 355 for (i = I8259_IRQ_OFFSET ; i < I8259_IRQ_OFFSET + NR_8259_INTS ; i++)
356 irq_desc[i].handler = &i8259_pic; 356 irq_desc[i].chip = &i8259_pic;
357 357
358 i8259_pic_irq_offset = I8259_IRQ_OFFSET; 358 i8259_pic_irq_offset = I8259_IRQ_OFFSET;
359 i8259_init(0); 359 i8259_init(0);
diff --git a/arch/ppc/syslib/mpc52xx_pic.c b/arch/ppc/syslib/mpc52xx_pic.c
index c4406f9dc6a3..6425b5cee7db 100644
--- a/arch/ppc/syslib/mpc52xx_pic.c
+++ b/arch/ppc/syslib/mpc52xx_pic.c
@@ -204,9 +204,9 @@ mpc52xx_init_irq(void)
204 out_be32(&intr->main_pri1, 0); 204 out_be32(&intr->main_pri1, 0);
205 out_be32(&intr->main_pri2, 0); 205 out_be32(&intr->main_pri2, 0);
206 206
207 /* Initialize irq_desc[i].handler's with mpc52xx_ic. */ 207 /* Initialize irq_desc[i].chip's with mpc52xx_ic. */
208 for (i = 0; i < NR_IRQS; i++) { 208 for (i = 0; i < NR_IRQS; i++) {
209 irq_desc[i].handler = &mpc52xx_ic; 209 irq_desc[i].chip = &mpc52xx_ic;
210 irq_desc[i].status = IRQ_LEVEL; 210 irq_desc[i].status = IRQ_LEVEL;
211 } 211 }
212 212
diff --git a/arch/ppc/syslib/mv64360_pic.c b/arch/ppc/syslib/mv64360_pic.c
index 5a19697060f0..a4244d468381 100644
--- a/arch/ppc/syslib/mv64360_pic.c
+++ b/arch/ppc/syslib/mv64360_pic.c
@@ -119,7 +119,7 @@ mv64360_init_irq(void)
119 /* All interrupts are level interrupts */ 119 /* All interrupts are level interrupts */
120 for (i = mv64360_irq_base; i < (mv64360_irq_base + 96); i++) { 120 for (i = mv64360_irq_base; i < (mv64360_irq_base + 96); i++) {
121 irq_desc[i].status |= IRQ_LEVEL; 121 irq_desc[i].status |= IRQ_LEVEL;
122 irq_desc[i].handler = &mv64360_pic; 122 irq_desc[i].chip = &mv64360_pic;
123 } 123 }
124 124
125 if (ppc_md.progress) 125 if (ppc_md.progress)
diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
index 70456c8f998c..767a0bc95817 100644
--- a/arch/ppc/syslib/open_pic.c
+++ b/arch/ppc/syslib/open_pic.c
@@ -373,7 +373,7 @@ void __init openpic_init(int offset)
373 OPENPIC_VEC_IPI+i+offset); 373 OPENPIC_VEC_IPI+i+offset);
374 /* IPIs are per-CPU */ 374 /* IPIs are per-CPU */
375 irq_desc[OPENPIC_VEC_IPI+i+offset].status |= IRQ_PER_CPU; 375 irq_desc[OPENPIC_VEC_IPI+i+offset].status |= IRQ_PER_CPU;
376 irq_desc[OPENPIC_VEC_IPI+i+offset].handler = &open_pic_ipi; 376 irq_desc[OPENPIC_VEC_IPI+i+offset].chip = &open_pic_ipi;
377 } 377 }
378#endif 378#endif
379 379
@@ -408,7 +408,7 @@ void __init openpic_init(int offset)
408 408
409 /* Init descriptors */ 409 /* Init descriptors */
410 for (i = offset; i < NumSources + offset; i++) 410 for (i = offset; i < NumSources + offset; i++)
411 irq_desc[i].handler = &open_pic; 411 irq_desc[i].chip = &open_pic;
412 412
413 /* Initialize the spurious interrupt */ 413 /* Initialize the spurious interrupt */
414 if (ppc_md.progress) ppc_md.progress("openpic: spurious",0x3bd); 414 if (ppc_md.progress) ppc_md.progress("openpic: spurious",0x3bd);
@@ -615,8 +615,8 @@ void __devinit do_openpic_setup_cpu(void)
615 /* let the openpic know we want intrs. default affinity 615 /* let the openpic know we want intrs. default affinity
616 * is 0xffffffff until changed via /proc 616 * is 0xffffffff until changed via /proc
617 * That's how it's done on x86. If we want it differently, then 617 * That's how it's done on x86. If we want it differently, then
618 * we should make sure we also change the default values of irq_affinity 618 * we should make sure we also change the default values of
619 * in irq.c. 619 * irq_desc[].affinity in irq.c.
620 */ 620 */
621 for (i = 0; i < NumSources; i++) 621 for (i = 0; i < NumSources; i++)
622 openpic_mapirq(i, msk, CPU_MASK_ALL); 622 openpic_mapirq(i, msk, CPU_MASK_ALL);
diff --git a/arch/ppc/syslib/open_pic2.c b/arch/ppc/syslib/open_pic2.c
index bcbe40de26fe..b8154efff6ed 100644
--- a/arch/ppc/syslib/open_pic2.c
+++ b/arch/ppc/syslib/open_pic2.c
@@ -290,7 +290,7 @@ void __init openpic2_init(int offset)
290 290
291 /* Init descriptors */ 291 /* Init descriptors */
292 for (i = offset; i < NumSources + offset; i++) 292 for (i = offset; i < NumSources + offset; i++)
293 irq_desc[i].handler = &open_pic2; 293 irq_desc[i].chip = &open_pic2;
294 294
295 /* Initialize the spurious interrupt */ 295 /* Initialize the spurious interrupt */
296 if (ppc_md.progress) ppc_md.progress("openpic2: spurious",0x3bd); 296 if (ppc_md.progress) ppc_md.progress("openpic2: spurious",0x3bd);
diff --git a/arch/ppc/syslib/ppc403_pic.c b/arch/ppc/syslib/ppc403_pic.c
index c46043c47225..1584c8b1229f 100644
--- a/arch/ppc/syslib/ppc403_pic.c
+++ b/arch/ppc/syslib/ppc403_pic.c
@@ -121,5 +121,5 @@ ppc4xx_pic_init(void)
121 ppc_md.get_irq = ppc403_pic_get_irq; 121 ppc_md.get_irq = ppc403_pic_get_irq;
122 122
123 for (i = 0; i < NR_IRQS; i++) 123 for (i = 0; i < NR_IRQS; i++)
124 irq_desc[i].handler = &ppc403_aic; 124 irq_desc[i].chip = &ppc403_aic;
125} 125}
diff --git a/arch/ppc/syslib/ppc4xx_pic.c b/arch/ppc/syslib/ppc4xx_pic.c
index fd9af0fc0e9f..e669c1335d47 100644
--- a/arch/ppc/syslib/ppc4xx_pic.c
+++ b/arch/ppc/syslib/ppc4xx_pic.c
@@ -276,7 +276,7 @@ void __init ppc4xx_pic_init(void)
276 276
277 /* Attach low-level handlers */ 277 /* Attach low-level handlers */
278 for (i = 0; i < (NR_UICS << 5); ++i) { 278 for (i = 0; i < (NR_UICS << 5); ++i) {
279 irq_desc[i].handler = &__uic[i >> 5].decl; 279 irq_desc[i].chip = &__uic[i >> 5].decl;
280 if (is_level_sensitive(i)) 280 if (is_level_sensitive(i))
281 irq_desc[i].status |= IRQ_LEVEL; 281 irq_desc[i].status |= IRQ_LEVEL;
282 } 282 }
diff --git a/arch/ppc/syslib/xilinx_pic.c b/arch/ppc/syslib/xilinx_pic.c
index e672b600f315..39a93dc6375b 100644
--- a/arch/ppc/syslib/xilinx_pic.c
+++ b/arch/ppc/syslib/xilinx_pic.c
@@ -143,7 +143,7 @@ ppc4xx_pic_init(void)
143 ppc_md.get_irq = xilinx_pic_get_irq; 143 ppc_md.get_irq = xilinx_pic_get_irq;
144 144
145 for (i = 0; i < NR_IRQS; ++i) { 145 for (i = 0; i < NR_IRQS; ++i) {
146 irq_desc[i].handler = &xilinx_intc; 146 irq_desc[i].chip = &xilinx_intc;
147 147
148 if (XPAR_INTC_0_KIND_OF_INTR & (0x00000001 << i)) 148 if (XPAR_INTC_0_KIND_OF_INTR & (0x00000001 << i))
149 irq_desc[i].status &= ~IRQ_LEVEL; 149 irq_desc[i].status &= ~IRQ_LEVEL;
diff --git a/arch/s390/appldata/appldata.h b/arch/s390/appldata/appldata.h
index e806a8922bbb..71d65eb30650 100644
--- a/arch/s390/appldata/appldata.h
+++ b/arch/s390/appldata/appldata.h
@@ -3,9 +3,9 @@
3 * 3 *
4 * Definitions and interface for Linux - z/VM Monitor Stream. 4 * Definitions and interface for Linux - z/VM Monitor Stream.
5 * 5 *
6 * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH. 6 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH.
7 * 7 *
8 * Author: Gerald Schaefer <geraldsc@de.ibm.com> 8 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
9 */ 9 */
10 10
11//#define APPLDATA_DEBUG /* Debug messages on/off */ 11//#define APPLDATA_DEBUG /* Debug messages on/off */
@@ -29,6 +29,22 @@
29#define CTL_APPLDATA_NET_SUM 2125 29#define CTL_APPLDATA_NET_SUM 2125
30#define CTL_APPLDATA_PROC 2126 30#define CTL_APPLDATA_PROC 2126
31 31
32#ifndef CONFIG_64BIT
33
34#define APPLDATA_START_INTERVAL_REC 0x00 /* Function codes for */
35#define APPLDATA_STOP_REC 0x01 /* DIAG 0xDC */
36#define APPLDATA_GEN_EVENT_RECORD 0x02
37#define APPLDATA_START_CONFIG_REC 0x03
38
39#else
40
41#define APPLDATA_START_INTERVAL_REC 0x80
42#define APPLDATA_STOP_REC 0x81
43#define APPLDATA_GEN_EVENT_RECORD 0x82
44#define APPLDATA_START_CONFIG_REC 0x83
45
46#endif /* CONFIG_64BIT */
47
32#define P_INFO(x...) printk(KERN_INFO MY_PRINT_NAME " info: " x) 48#define P_INFO(x...) printk(KERN_INFO MY_PRINT_NAME " info: " x)
33#define P_ERROR(x...) printk(KERN_ERR MY_PRINT_NAME " error: " x) 49#define P_ERROR(x...) printk(KERN_ERR MY_PRINT_NAME " error: " x)
34#define P_WARNING(x...) printk(KERN_WARNING MY_PRINT_NAME " status: " x) 50#define P_WARNING(x...) printk(KERN_WARNING MY_PRINT_NAME " status: " x)
@@ -53,7 +69,11 @@ struct appldata_ops {
53 void *data; /* record data */ 69 void *data; /* record data */
54 unsigned int size; /* size of record */ 70 unsigned int size; /* size of record */
55 struct module *owner; /* THIS_MODULE */ 71 struct module *owner; /* THIS_MODULE */
72 char mod_lvl[2]; /* modification level, EBCDIC */
56}; 73};
57 74
58extern int appldata_register_ops(struct appldata_ops *ops); 75extern int appldata_register_ops(struct appldata_ops *ops);
59extern void appldata_unregister_ops(struct appldata_ops *ops); 76extern void appldata_unregister_ops(struct appldata_ops *ops);
77extern int appldata_diag(char record_nr, u16 function, unsigned long buffer,
78 u16 length, char *mod_lvl);
79
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 9a22434a580c..61bc44626c04 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -5,9 +5,9 @@
5 * Exports appldata_register_ops() and appldata_unregister_ops() for the 5 * Exports appldata_register_ops() and appldata_unregister_ops() for the
6 * data gathering modules. 6 * data gathering modules.
7 * 7 *
8 * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH. 8 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH.
9 * 9 *
10 * Author: Gerald Schaefer <geraldsc@de.ibm.com> 10 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -40,22 +40,6 @@
40 40
41#define TOD_MICRO 0x01000 /* nr. of TOD clock units 41#define TOD_MICRO 0x01000 /* nr. of TOD clock units
42 for 1 microsecond */ 42 for 1 microsecond */
43#ifndef CONFIG_64BIT
44
45#define APPLDATA_START_INTERVAL_REC 0x00 /* Function codes for */
46#define APPLDATA_STOP_REC 0x01 /* DIAG 0xDC */
47#define APPLDATA_GEN_EVENT_RECORD 0x02
48#define APPLDATA_START_CONFIG_REC 0x03
49
50#else
51
52#define APPLDATA_START_INTERVAL_REC 0x80
53#define APPLDATA_STOP_REC 0x81
54#define APPLDATA_GEN_EVENT_RECORD 0x82
55#define APPLDATA_START_CONFIG_REC 0x83
56
57#endif /* CONFIG_64BIT */
58
59 43
60/* 44/*
61 * Parameter list for DIAGNOSE X'DC' 45 * Parameter list for DIAGNOSE X'DC'
@@ -195,8 +179,8 @@ static void appldata_work_fn(void *data)
195 * 179 *
196 * prepare parameter list, issue DIAG 0xDC 180 * prepare parameter list, issue DIAG 0xDC
197 */ 181 */
198static int appldata_diag(char record_nr, u16 function, unsigned long buffer, 182int appldata_diag(char record_nr, u16 function, unsigned long buffer,
199 u16 length) 183 u16 length, char *mod_lvl)
200{ 184{
201 unsigned long ry; 185 unsigned long ry;
202 struct appldata_product_id { 186 struct appldata_product_id {
@@ -214,7 +198,7 @@ static int appldata_diag(char record_nr, u16 function, unsigned long buffer,
214 .record_nr = record_nr, 198 .record_nr = record_nr,
215 .version_nr = {0xF2, 0xF6}, /* "26" */ 199 .version_nr = {0xF2, 0xF6}, /* "26" */
216 .release_nr = {0xF0, 0xF1}, /* "01" */ 200 .release_nr = {0xF0, 0xF1}, /* "01" */
217 .mod_lvl = {0xF0, 0xF0}, /* "00" */ 201 .mod_lvl = {mod_lvl[0], mod_lvl[1]},
218 }; 202 };
219 struct appldata_parameter_list appldata_parameter_list = { 203 struct appldata_parameter_list appldata_parameter_list = {
220 .diag = 0xDC, 204 .diag = 0xDC,
@@ -467,24 +451,25 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp,
467 module_put(ops->owner); 451 module_put(ops->owner);
468 return -ENODEV; 452 return -ENODEV;
469 } 453 }
470 ops->active = 1;
471 ops->callback(ops->data); // init record 454 ops->callback(ops->data); // init record
472 rc = appldata_diag(ops->record_nr, 455 rc = appldata_diag(ops->record_nr,
473 APPLDATA_START_INTERVAL_REC, 456 APPLDATA_START_INTERVAL_REC,
474 (unsigned long) ops->data, ops->size); 457 (unsigned long) ops->data, ops->size,
458 ops->mod_lvl);
475 if (rc != 0) { 459 if (rc != 0) {
476 P_ERROR("START DIAG 0xDC for %s failed, " 460 P_ERROR("START DIAG 0xDC for %s failed, "
477 "return code: %d\n", ops->name, rc); 461 "return code: %d\n", ops->name, rc);
478 module_put(ops->owner); 462 module_put(ops->owner);
479 ops->active = 0;
480 } else { 463 } else {
481 P_INFO("Monitoring %s data enabled, " 464 P_INFO("Monitoring %s data enabled, "
482 "DIAG 0xDC started.\n", ops->name); 465 "DIAG 0xDC started.\n", ops->name);
466 ops->active = 1;
483 } 467 }
484 } else if ((buf[0] == '0') && (ops->active == 1)) { 468 } else if ((buf[0] == '0') && (ops->active == 1)) {
485 ops->active = 0; 469 ops->active = 0;
486 rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, 470 rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
487 (unsigned long) ops->data, ops->size); 471 (unsigned long) ops->data, ops->size,
472 ops->mod_lvl);
488 if (rc != 0) { 473 if (rc != 0) {
489 P_ERROR("STOP DIAG 0xDC for %s failed, " 474 P_ERROR("STOP DIAG 0xDC for %s failed, "
490 "return code: %d\n", ops->name, rc); 475 "return code: %d\n", ops->name, rc);
@@ -633,7 +618,7 @@ appldata_offline_cpu(int cpu)
633 spin_unlock(&appldata_timer_lock); 618 spin_unlock(&appldata_timer_lock);
634} 619}
635 620
636static int 621static int __cpuinit
637appldata_cpu_notify(struct notifier_block *self, 622appldata_cpu_notify(struct notifier_block *self,
638 unsigned long action, void *hcpu) 623 unsigned long action, void *hcpu)
639{ 624{
@@ -652,7 +637,7 @@ appldata_cpu_notify(struct notifier_block *self,
652 return NOTIFY_OK; 637 return NOTIFY_OK;
653} 638}
654 639
655static struct notifier_block appldata_nb = { 640static struct notifier_block __devinitdata appldata_nb = {
656 .notifier_call = appldata_cpu_notify, 641 .notifier_call = appldata_cpu_notify,
657}; 642};
658 643
@@ -710,7 +695,8 @@ static void __exit appldata_exit(void)
710 list_for_each(lh, &appldata_ops_list) { 695 list_for_each(lh, &appldata_ops_list) {
711 ops = list_entry(lh, struct appldata_ops, list); 696 ops = list_entry(lh, struct appldata_ops, list);
712 rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, 697 rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
713 (unsigned long) ops->data, ops->size); 698 (unsigned long) ops->data, ops->size,
699 ops->mod_lvl);
714 if (rc != 0) { 700 if (rc != 0) {
715 P_ERROR("STOP DIAG 0xDC for %s failed, " 701 P_ERROR("STOP DIAG 0xDC for %s failed, "
716 "return code: %d\n", ops->name, rc); 702 "return code: %d\n", ops->name, rc);
@@ -739,6 +725,7 @@ MODULE_DESCRIPTION("Linux-VM Monitor Stream, base infrastructure");
739 725
740EXPORT_SYMBOL_GPL(appldata_register_ops); 726EXPORT_SYMBOL_GPL(appldata_register_ops);
741EXPORT_SYMBOL_GPL(appldata_unregister_ops); 727EXPORT_SYMBOL_GPL(appldata_unregister_ops);
728EXPORT_SYMBOL_GPL(appldata_diag);
742 729
743#ifdef MODULE 730#ifdef MODULE
744/* 731/*
@@ -779,7 +766,6 @@ unsigned long nr_iowait(void)
779#endif /* MODULE */ 766#endif /* MODULE */
780EXPORT_SYMBOL_GPL(si_swapinfo); 767EXPORT_SYMBOL_GPL(si_swapinfo);
781EXPORT_SYMBOL_GPL(nr_threads); 768EXPORT_SYMBOL_GPL(nr_threads);
782EXPORT_SYMBOL_GPL(avenrun);
783EXPORT_SYMBOL_GPL(get_full_page_state); 769EXPORT_SYMBOL_GPL(get_full_page_state);
784EXPORT_SYMBOL_GPL(nr_running); 770EXPORT_SYMBOL_GPL(nr_running);
785EXPORT_SYMBOL_GPL(nr_iowait); 771EXPORT_SYMBOL_GPL(nr_iowait);
diff --git a/arch/s390/appldata/appldata_mem.c b/arch/s390/appldata/appldata_mem.c
index f0e2fbed3d4c..7915a197d96d 100644
--- a/arch/s390/appldata/appldata_mem.c
+++ b/arch/s390/appldata/appldata_mem.c
@@ -4,9 +4,9 @@
4 * Data gathering module for Linux-VM Monitor Stream, Stage 1. 4 * Data gathering module for Linux-VM Monitor Stream, Stage 1.
5 * Collects data related to memory management. 5 * Collects data related to memory management.
6 * 6 *
7 * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH. 7 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH.
8 * 8 *
9 * Author: Gerald Schaefer <geraldsc@de.ibm.com> 9 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
10 */ 10 */
11 11
12#include <linux/config.h> 12#include <linux/config.h>
@@ -152,6 +152,7 @@ static struct appldata_ops ops = {
152 .callback = &appldata_get_mem_data, 152 .callback = &appldata_get_mem_data,
153 .data = &appldata_mem_data, 153 .data = &appldata_mem_data,
154 .owner = THIS_MODULE, 154 .owner = THIS_MODULE,
155 .mod_lvl = {0xF0, 0xF0}, /* EBCDIC "00" */
155}; 156};
156 157
157 158
diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c
index 2a4c7432db4a..39b7bdecbf05 100644
--- a/arch/s390/appldata/appldata_net_sum.c
+++ b/arch/s390/appldata/appldata_net_sum.c
@@ -5,9 +5,9 @@
5 * Collects accumulated network statistics (Packets received/transmitted, 5 * Collects accumulated network statistics (Packets received/transmitted,
6 * dropped, errors, ...). 6 * dropped, errors, ...).
7 * 7 *
8 * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH. 8 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH.
9 * 9 *
10 * Author: Gerald Schaefer <geraldsc@de.ibm.com> 10 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -152,6 +152,7 @@ static struct appldata_ops ops = {
152 .callback = &appldata_get_net_sum_data, 152 .callback = &appldata_get_net_sum_data,
153 .data = &appldata_net_sum_data, 153 .data = &appldata_net_sum_data,
154 .owner = THIS_MODULE, 154 .owner = THIS_MODULE,
155 .mod_lvl = {0xF0, 0xF0}, /* EBCDIC "00" */
155}; 156};
156 157
157 158
diff --git a/arch/s390/appldata/appldata_os.c b/arch/s390/appldata/appldata_os.c
index 99ddd3bf2fba..f2b44a2f1dec 100644
--- a/arch/s390/appldata/appldata_os.c
+++ b/arch/s390/appldata/appldata_os.c
@@ -4,9 +4,9 @@
4 * Data gathering module for Linux-VM Monitor Stream, Stage 1. 4 * Data gathering module for Linux-VM Monitor Stream, Stage 1.
5 * Collects misc. OS related data (CPU utilization, running processes). 5 * Collects misc. OS related data (CPU utilization, running processes).
6 * 6 *
7 * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH. 7 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH.
8 * 8 *
9 * Author: Gerald Schaefer <geraldsc@de.ibm.com> 9 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
10 */ 10 */
11 11
12#include <linux/config.h> 12#include <linux/config.h>
@@ -44,11 +44,14 @@ struct appldata_os_per_cpu {
44 u32 per_cpu_system; /* ... spent in kernel mode */ 44 u32 per_cpu_system; /* ... spent in kernel mode */
45 u32 per_cpu_idle; /* ... spent in idle mode */ 45 u32 per_cpu_idle; /* ... spent in idle mode */
46 46
47// New in 2.6 --> 47 /* New in 2.6 */
48 u32 per_cpu_irq; /* ... spent in interrupts */ 48 u32 per_cpu_irq; /* ... spent in interrupts */
49 u32 per_cpu_softirq; /* ... spent in softirqs */ 49 u32 per_cpu_softirq; /* ... spent in softirqs */
50 u32 per_cpu_iowait; /* ... spent while waiting for I/O */ 50 u32 per_cpu_iowait; /* ... spent while waiting for I/O */
51// <-- New in 2.6 51
52 /* New in modification level 01 */
53 u32 per_cpu_steal; /* ... stolen by hypervisor */
54 u32 cpu_id; /* number of this CPU */
52} __attribute__((packed)); 55} __attribute__((packed));
53 56
54struct appldata_os_data { 57struct appldata_os_data {
@@ -68,10 +71,9 @@ struct appldata_os_data {
68 u32 avenrun[3]; /* average nr. of running processes during */ 71 u32 avenrun[3]; /* average nr. of running processes during */
69 /* the last 1, 5 and 15 minutes */ 72 /* the last 1, 5 and 15 minutes */
70 73
71// New in 2.6 --> 74 /* New in 2.6 */
72 u32 nr_iowait; /* number of blocked threads 75 u32 nr_iowait; /* number of blocked threads
73 (waiting for I/O) */ 76 (waiting for I/O) */
74// <-- New in 2.6
75 77
76 /* per cpu data */ 78 /* per cpu data */
77 struct appldata_os_per_cpu os_cpu[0]; 79 struct appldata_os_per_cpu os_cpu[0];
@@ -79,6 +81,14 @@ struct appldata_os_data {
79 81
80static struct appldata_os_data *appldata_os_data; 82static struct appldata_os_data *appldata_os_data;
81 83
84static struct appldata_ops ops = {
85 .ctl_nr = CTL_APPLDATA_OS,
86 .name = "os",
87 .record_nr = APPLDATA_RECORD_OS_ID,
88 .owner = THIS_MODULE,
89 .mod_lvl = {0xF0, 0xF1}, /* EBCDIC "01" */
90};
91
82 92
83static inline void appldata_print_debug(struct appldata_os_data *os_data) 93static inline void appldata_print_debug(struct appldata_os_data *os_data)
84{ 94{
@@ -100,15 +110,17 @@ static inline void appldata_print_debug(struct appldata_os_data *os_data)
100 P_DEBUG("nr_cpus = %u\n", os_data->nr_cpus); 110 P_DEBUG("nr_cpus = %u\n", os_data->nr_cpus);
101 for (i = 0; i < os_data->nr_cpus; i++) { 111 for (i = 0; i < os_data->nr_cpus; i++) {
102 P_DEBUG("cpu%u : user = %u, nice = %u, system = %u, " 112 P_DEBUG("cpu%u : user = %u, nice = %u, system = %u, "
103 "idle = %u, irq = %u, softirq = %u, iowait = %u\n", 113 "idle = %u, irq = %u, softirq = %u, iowait = %u, "
104 i, 114 "steal = %u\n",
115 os_data->os_cpu[i].cpu_id,
105 os_data->os_cpu[i].per_cpu_user, 116 os_data->os_cpu[i].per_cpu_user,
106 os_data->os_cpu[i].per_cpu_nice, 117 os_data->os_cpu[i].per_cpu_nice,
107 os_data->os_cpu[i].per_cpu_system, 118 os_data->os_cpu[i].per_cpu_system,
108 os_data->os_cpu[i].per_cpu_idle, 119 os_data->os_cpu[i].per_cpu_idle,
109 os_data->os_cpu[i].per_cpu_irq, 120 os_data->os_cpu[i].per_cpu_irq,
110 os_data->os_cpu[i].per_cpu_softirq, 121 os_data->os_cpu[i].per_cpu_softirq,
111 os_data->os_cpu[i].per_cpu_iowait); 122 os_data->os_cpu[i].per_cpu_iowait,
123 os_data->os_cpu[i].per_cpu_steal);
112 } 124 }
113 125
114 P_DEBUG("sync_count_1 = %u\n", os_data->sync_count_1); 126 P_DEBUG("sync_count_1 = %u\n", os_data->sync_count_1);
@@ -123,14 +135,13 @@ static inline void appldata_print_debug(struct appldata_os_data *os_data)
123 */ 135 */
124static void appldata_get_os_data(void *data) 136static void appldata_get_os_data(void *data)
125{ 137{
126 int i, j; 138 int i, j, rc;
127 struct appldata_os_data *os_data; 139 struct appldata_os_data *os_data;
140 unsigned int new_size;
128 141
129 os_data = data; 142 os_data = data;
130 os_data->sync_count_1++; 143 os_data->sync_count_1++;
131 144
132 os_data->nr_cpus = num_online_cpus();
133
134 os_data->nr_threads = nr_threads; 145 os_data->nr_threads = nr_threads;
135 os_data->nr_running = nr_running(); 146 os_data->nr_running = nr_running();
136 os_data->nr_iowait = nr_iowait(); 147 os_data->nr_iowait = nr_iowait();
@@ -154,9 +165,44 @@ static void appldata_get_os_data(void *data)
154 cputime_to_jiffies(kstat_cpu(i).cpustat.softirq); 165 cputime_to_jiffies(kstat_cpu(i).cpustat.softirq);
155 os_data->os_cpu[j].per_cpu_iowait = 166 os_data->os_cpu[j].per_cpu_iowait =
156 cputime_to_jiffies(kstat_cpu(i).cpustat.iowait); 167 cputime_to_jiffies(kstat_cpu(i).cpustat.iowait);
168 os_data->os_cpu[j].per_cpu_steal =
169 cputime_to_jiffies(kstat_cpu(i).cpustat.steal);
170 os_data->os_cpu[j].cpu_id = i;
157 j++; 171 j++;
158 } 172 }
159 173
174 os_data->nr_cpus = j;
175
176 new_size = sizeof(struct appldata_os_data) +
177 (os_data->nr_cpus * sizeof(struct appldata_os_per_cpu));
178 if (ops.size != new_size) {
179 if (ops.active) {
180 rc = appldata_diag(APPLDATA_RECORD_OS_ID,
181 APPLDATA_START_INTERVAL_REC,
182 (unsigned long) ops.data, new_size,
183 ops.mod_lvl);
184 if (rc != 0) {
185 P_ERROR("os: START NEW DIAG 0xDC failed, "
186 "return code: %d, new size = %i\n", rc,
187 new_size);
188 P_INFO("os: stopping old record now\n");
189 } else
190 P_INFO("os: new record size = %i\n", new_size);
191
192 rc = appldata_diag(APPLDATA_RECORD_OS_ID,
193 APPLDATA_STOP_REC,
194 (unsigned long) ops.data, ops.size,
195 ops.mod_lvl);
196 if (rc != 0)
197 P_ERROR("os: STOP OLD DIAG 0xDC failed, "
198 "return code: %d, old size = %i\n", rc,
199 ops.size);
200 else
201 P_INFO("os: old record size = %i stopped\n",
202 ops.size);
203 }
204 ops.size = new_size;
205 }
160 os_data->timestamp = get_clock(); 206 os_data->timestamp = get_clock();
161 os_data->sync_count_2++; 207 os_data->sync_count_2++;
162#ifdef APPLDATA_DEBUG 208#ifdef APPLDATA_DEBUG
@@ -165,15 +211,6 @@ static void appldata_get_os_data(void *data)
165} 211}
166 212
167 213
168static struct appldata_ops ops = {
169 .ctl_nr = CTL_APPLDATA_OS,
170 .name = "os",
171 .record_nr = APPLDATA_RECORD_OS_ID,
172 .callback = &appldata_get_os_data,
173 .owner = THIS_MODULE,
174};
175
176
177/* 214/*
178 * appldata_os_init() 215 * appldata_os_init()
179 * 216 *
@@ -181,26 +218,25 @@ static struct appldata_ops ops = {
181 */ 218 */
182static int __init appldata_os_init(void) 219static int __init appldata_os_init(void)
183{ 220{
184 int rc, size; 221 int rc, max_size;
185 222
186 size = sizeof(struct appldata_os_data) + 223 max_size = sizeof(struct appldata_os_data) +
187 (NR_CPUS * sizeof(struct appldata_os_per_cpu)); 224 (NR_CPUS * sizeof(struct appldata_os_per_cpu));
188 if (size > APPLDATA_MAX_REC_SIZE) { 225 if (max_size > APPLDATA_MAX_REC_SIZE) {
189 P_ERROR("Size of record = %i, bigger than maximum (%i)!\n", 226 P_ERROR("Max. size of OS record = %i, bigger than maximum "
190 size, APPLDATA_MAX_REC_SIZE); 227 "record size (%i)\n", max_size, APPLDATA_MAX_REC_SIZE);
191 rc = -ENOMEM; 228 rc = -ENOMEM;
192 goto out; 229 goto out;
193 } 230 }
194 P_DEBUG("sizeof(os) = %i, sizeof(os_cpu) = %lu\n", size, 231 P_DEBUG("max. sizeof(os) = %i, sizeof(os_cpu) = %lu\n", max_size,
195 sizeof(struct appldata_os_per_cpu)); 232 sizeof(struct appldata_os_per_cpu));
196 233
197 appldata_os_data = kmalloc(size, GFP_DMA); 234 appldata_os_data = kzalloc(max_size, GFP_DMA);
198 if (appldata_os_data == NULL) { 235 if (appldata_os_data == NULL) {
199 P_ERROR("No memory for %s!\n", ops.name); 236 P_ERROR("No memory for %s!\n", ops.name);
200 rc = -ENOMEM; 237 rc = -ENOMEM;
201 goto out; 238 goto out;
202 } 239 }
203 memset(appldata_os_data, 0, size);
204 240
205 appldata_os_data->per_cpu_size = sizeof(struct appldata_os_per_cpu); 241 appldata_os_data->per_cpu_size = sizeof(struct appldata_os_per_cpu);
206 appldata_os_data->cpu_offset = offsetof(struct appldata_os_data, 242 appldata_os_data->cpu_offset = offsetof(struct appldata_os_data,
@@ -208,7 +244,7 @@ static int __init appldata_os_init(void)
208 P_DEBUG("cpu offset = %u\n", appldata_os_data->cpu_offset); 244 P_DEBUG("cpu offset = %u\n", appldata_os_data->cpu_offset);
209 245
210 ops.data = appldata_os_data; 246 ops.data = appldata_os_data;
211 ops.size = size; 247 ops.callback = &appldata_get_os_data;
212 rc = appldata_register_ops(&ops); 248 rc = appldata_register_ops(&ops);
213 if (rc != 0) { 249 if (rc != 0) {
214 P_ERROR("Error registering ops, rc = %i\n", rc); 250 P_ERROR("Error registering ops, rc = %i\n", rc);
diff --git a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c
index 1f451c2cb071..12a6311e9838 100644
--- a/arch/s390/kernel/binfmt_elf32.c
+++ b/arch/s390/kernel/binfmt_elf32.c
@@ -177,11 +177,6 @@ struct elf_prpsinfo32
177 177
178#include <linux/highuid.h> 178#include <linux/highuid.h>
179 179
180#undef NEW_TO_OLD_UID
181#undef NEW_TO_OLD_GID
182#define NEW_TO_OLD_UID(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
183#define NEW_TO_OLD_GID(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
184
185#define elf_addr_t u32 180#define elf_addr_t u32
186/* 181/*
187#define init_elf_binfmt init_elf32_binfmt 182#define init_elf_binfmt init_elf32_binfmt
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index b2448487854c..aa8b52c2140f 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -93,13 +93,22 @@ STACK_SIZE = 1 << STACK_SHIFT
93 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13 93 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
94 .endm 94 .endm
95 95
96 .macro SAVE_ALL psworg,savearea,sync 96 .macro SAVE_ALL_SYNC psworg,savearea
97 la %r12,\psworg 97 la %r12,\psworg
98 .if \sync
99 tm \psworg+1,0x01 # test problem state bit 98 tm \psworg+1,0x01 # test problem state bit
100 bz BASED(2f) # skip stack setup save 99 bz BASED(2f) # skip stack setup save
101 l %r15,__LC_KERNEL_STACK # problem state -> load ksp 100 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
102 .else 101#ifdef CONFIG_CHECK_STACK
102 b BASED(3f)
1032: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
104 bz BASED(stack_overflow)
1053:
106#endif
1072:
108 .endm
109
110 .macro SAVE_ALL_ASYNC psworg,savearea
111 la %r12,\psworg
103 tm \psworg+1,0x01 # test problem state bit 112 tm \psworg+1,0x01 # test problem state bit
104 bnz BASED(1f) # from user -> load async stack 113 bnz BASED(1f) # from user -> load async stack
105 clc \psworg+4(4),BASED(.Lcritical_end) 114 clc \psworg+4(4),BASED(.Lcritical_end)
@@ -115,7 +124,6 @@ STACK_SIZE = 1 << STACK_SHIFT
115 sra %r14,STACK_SHIFT 124 sra %r14,STACK_SHIFT
116 be BASED(2f) 125 be BASED(2f)
1171: l %r15,__LC_ASYNC_STACK 1261: l %r15,__LC_ASYNC_STACK
118 .endif
119#ifdef CONFIG_CHECK_STACK 127#ifdef CONFIG_CHECK_STACK
120 b BASED(3f) 128 b BASED(3f)
1212: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD 1292: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
@@ -196,7 +204,7 @@ system_call:
196 STORE_TIMER __LC_SYNC_ENTER_TIMER 204 STORE_TIMER __LC_SYNC_ENTER_TIMER
197sysc_saveall: 205sysc_saveall:
198 SAVE_ALL_BASE __LC_SAVE_AREA 206 SAVE_ALL_BASE __LC_SAVE_AREA
199 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1 207 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
200 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA 208 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
201 lh %r7,0x8a # get svc number from lowcore 209 lh %r7,0x8a # get svc number from lowcore
202#ifdef CONFIG_VIRT_CPU_ACCOUNTING 210#ifdef CONFIG_VIRT_CPU_ACCOUNTING
@@ -425,7 +433,7 @@ pgm_check_handler:
425 SAVE_ALL_BASE __LC_SAVE_AREA 433 SAVE_ALL_BASE __LC_SAVE_AREA
426 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception 434 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
427 bnz BASED(pgm_per) # got per exception -> special case 435 bnz BASED(pgm_per) # got per exception -> special case
428 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1 436 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
429 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA 437 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
430#ifdef CONFIG_VIRT_CPU_ACCOUNTING 438#ifdef CONFIG_VIRT_CPU_ACCOUNTING
431 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 439 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -464,7 +472,7 @@ pgm_per:
464# Normal per exception 472# Normal per exception
465# 473#
466pgm_per_std: 474pgm_per_std:
467 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1 475 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
468 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA 476 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
469#ifdef CONFIG_VIRT_CPU_ACCOUNTING 477#ifdef CONFIG_VIRT_CPU_ACCOUNTING
470 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 478 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -490,7 +498,7 @@ pgm_no_vtime2:
490# it was a single stepped SVC that is causing all the trouble 498# it was a single stepped SVC that is causing all the trouble
491# 499#
492pgm_svcper: 500pgm_svcper:
493 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1 501 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
494 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA 502 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
495#ifdef CONFIG_VIRT_CPU_ACCOUNTING 503#ifdef CONFIG_VIRT_CPU_ACCOUNTING
496 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 504 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -519,7 +527,7 @@ io_int_handler:
519 STORE_TIMER __LC_ASYNC_ENTER_TIMER 527 STORE_TIMER __LC_ASYNC_ENTER_TIMER
520 stck __LC_INT_CLOCK 528 stck __LC_INT_CLOCK
521 SAVE_ALL_BASE __LC_SAVE_AREA+16 529 SAVE_ALL_BASE __LC_SAVE_AREA+16
522 SAVE_ALL __LC_IO_OLD_PSW,__LC_SAVE_AREA+16,0 530 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
523 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16 531 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
524#ifdef CONFIG_VIRT_CPU_ACCOUNTING 532#ifdef CONFIG_VIRT_CPU_ACCOUNTING
525 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 533 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -631,7 +639,7 @@ ext_int_handler:
631 STORE_TIMER __LC_ASYNC_ENTER_TIMER 639 STORE_TIMER __LC_ASYNC_ENTER_TIMER
632 stck __LC_INT_CLOCK 640 stck __LC_INT_CLOCK
633 SAVE_ALL_BASE __LC_SAVE_AREA+16 641 SAVE_ALL_BASE __LC_SAVE_AREA+16
634 SAVE_ALL __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16,0 642 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
635 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16 643 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
636#ifdef CONFIG_VIRT_CPU_ACCOUNTING 644#ifdef CONFIG_VIRT_CPU_ACCOUNTING
637 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 645 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -657,21 +665,31 @@ __critical_end:
657 .globl mcck_int_handler 665 .globl mcck_int_handler
658mcck_int_handler: 666mcck_int_handler:
659 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer 667 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
660 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
661 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs 668 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
662 SAVE_ALL_BASE __LC_SAVE_AREA+32 669 SAVE_ALL_BASE __LC_SAVE_AREA+32
663 la %r12,__LC_MCK_OLD_PSW 670 la %r12,__LC_MCK_OLD_PSW
664 tm __LC_MCCK_CODE,0x80 # system damage? 671 tm __LC_MCCK_CODE,0x80 # system damage?
665 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid 672 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
666 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
667 bo BASED(0f)
668 spt __LC_LAST_UPDATE_TIMER # revalidate cpu timer
669#ifdef CONFIG_VIRT_CPU_ACCOUNTING 673#ifdef CONFIG_VIRT_CPU_ACCOUNTING
670 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER 674 mvc __LC_SAVE_AREA+52(8),__LC_ASYNC_ENTER_TIMER
671 mvc __LC_SYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER 675 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
672 mvc __LC_EXIT_TIMER(8),__LC_LAST_UPDATE_TIMER 676 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
677 bo BASED(1f)
678 la %r14,__LC_SYNC_ENTER_TIMER
679 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
680 bl BASED(0f)
681 la %r14,__LC_ASYNC_ENTER_TIMER
6820: clc 0(8,%r14),__LC_EXIT_TIMER
683 bl BASED(0f)
684 la %r14,__LC_EXIT_TIMER
6850: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
686 bl BASED(0f)
687 la %r14,__LC_LAST_UPDATE_TIMER
6880: spt 0(%r14)
689 mvc __LC_ASYNC_ENTER_TIMER(8),0(%r14)
6901:
673#endif 691#endif
6740: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid? 692 tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
675 bno BASED(mcck_int_main) # no -> skip cleanup critical 693 bno BASED(mcck_int_main) # no -> skip cleanup critical
676 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit 694 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
677 bnz BASED(mcck_int_main) # from user -> load async stack 695 bnz BASED(mcck_int_main) # from user -> load async stack
@@ -691,7 +709,7 @@ mcck_int_main:
691#ifdef CONFIG_VIRT_CPU_ACCOUNTING 709#ifdef CONFIG_VIRT_CPU_ACCOUNTING
692 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid? 710 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
693 bno BASED(mcck_no_vtime) # no -> skip cleanup critical 711 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
694 tm __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ? 712 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
695 bz BASED(mcck_no_vtime) 713 bz BASED(mcck_no_vtime)
696 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER 714 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
697 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER 715 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
@@ -715,6 +733,20 @@ mcck_no_vtime:
715 l %r1,BASED(.Ls390_handle_mcck) 733 l %r1,BASED(.Ls390_handle_mcck)
716 basr %r14,%r1 # call machine check handler 734 basr %r14,%r1 # call machine check handler
717mcck_return: 735mcck_return:
736 mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
737 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
738#ifdef CONFIG_VIRT_CPU_ACCOUNTING
739 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_SAVE_AREA+52
740 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
741 bno BASED(0f)
742 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
743 stpt __LC_EXIT_TIMER
744 lpsw __LC_RETURN_MCCK_PSW # back to caller
7450:
746#endif
747 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
748 lpsw __LC_RETURN_MCCK_PSW # back to caller
749
718 RESTORE_ALL __LC_RETURN_MCCK_PSW,0 750 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
719 751
720#ifdef CONFIG_SMP 752#ifdef CONFIG_SMP
@@ -781,6 +813,8 @@ cleanup_table_sysc_leave:
781 .long sysc_leave + 0x80000000, sysc_work_loop + 0x80000000 813 .long sysc_leave + 0x80000000, sysc_work_loop + 0x80000000
782cleanup_table_sysc_work_loop: 814cleanup_table_sysc_work_loop:
783 .long sysc_work_loop + 0x80000000, sysc_reschedule + 0x80000000 815 .long sysc_work_loop + 0x80000000, sysc_reschedule + 0x80000000
816cleanup_table_io_return:
817 .long io_return + 0x80000000, io_leave + 0x80000000
784cleanup_table_io_leave: 818cleanup_table_io_leave:
785 .long io_leave + 0x80000000, io_done + 0x80000000 819 .long io_leave + 0x80000000, io_done + 0x80000000
786cleanup_table_io_work_loop: 820cleanup_table_io_work_loop:
@@ -807,6 +841,11 @@ cleanup_critical:
807 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop+4) 841 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop+4)
808 bl BASED(cleanup_sysc_return) 842 bl BASED(cleanup_sysc_return)
8090: 8430:
844 clc 4(4,%r12),BASED(cleanup_table_io_return)
845 bl BASED(0f)
846 clc 4(4,%r12),BASED(cleanup_table_io_return+4)
847 bl BASED(cleanup_io_return)
8480:
810 clc 4(4,%r12),BASED(cleanup_table_io_leave) 849 clc 4(4,%r12),BASED(cleanup_table_io_leave)
811 bl BASED(0f) 850 bl BASED(0f)
812 clc 4(4,%r12),BASED(cleanup_table_io_leave+4) 851 clc 4(4,%r12),BASED(cleanup_table_io_leave+4)
@@ -839,7 +878,7 @@ cleanup_system_call:
839 mvc __LC_SAVE_AREA(16),0(%r12) 878 mvc __LC_SAVE_AREA(16),0(%r12)
8400: st %r13,4(%r12) 8790: st %r13,4(%r12)
841 st %r12,__LC_SAVE_AREA+48 # argh 880 st %r12,__LC_SAVE_AREA+48 # argh
842 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1 881 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
843 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA 882 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
844 l %r12,__LC_SAVE_AREA+48 # argh 883 l %r12,__LC_SAVE_AREA+48 # argh
845 st %r15,12(%r12) 884 st %r15,12(%r12)
@@ -980,7 +1019,6 @@ cleanup_io_leave_insn:
980 .long cleanup_critical 1019 .long cleanup_critical
981 1020
982#define SYSCALL(esa,esame,emu) .long esa 1021#define SYSCALL(esa,esame,emu) .long esa
983 .globl sys_call_table
984sys_call_table: 1022sys_call_table:
985#include "syscalls.S" 1023#include "syscalls.S"
986#undef SYSCALL 1024#undef SYSCALL
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 2ac095bc0e25..f3222a1b2861 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -87,13 +87,22 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
87 larl %r13,system_call 87 larl %r13,system_call
88 .endm 88 .endm
89 89
90 .macro SAVE_ALL psworg,savearea,sync 90 .macro SAVE_ALL_SYNC psworg,savearea
91 la %r12,\psworg 91 la %r12,\psworg
92 .if \sync
93 tm \psworg+1,0x01 # test problem state bit 92 tm \psworg+1,0x01 # test problem state bit
94 jz 2f # skip stack setup save 93 jz 2f # skip stack setup save
95 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp 94 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
96 .else 95#ifdef CONFIG_CHECK_STACK
96 j 3f
972: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
98 jz stack_overflow
993:
100#endif
1012:
102 .endm
103
104 .macro SAVE_ALL_ASYNC psworg,savearea
105 la %r12,\psworg
97 tm \psworg+1,0x01 # test problem state bit 106 tm \psworg+1,0x01 # test problem state bit
98 jnz 1f # from user -> load kernel stack 107 jnz 1f # from user -> load kernel stack
99 clc \psworg+8(8),BASED(.Lcritical_end) 108 clc \psworg+8(8),BASED(.Lcritical_end)
@@ -108,7 +117,6 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
108 srag %r14,%r14,STACK_SHIFT 117 srag %r14,%r14,STACK_SHIFT
109 jz 2f 118 jz 2f
1101: lg %r15,__LC_ASYNC_STACK # load async stack 1191: lg %r15,__LC_ASYNC_STACK # load async stack
111 .endif
112#ifdef CONFIG_CHECK_STACK 120#ifdef CONFIG_CHECK_STACK
113 j 3f 121 j 3f
1142: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD 1222: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
@@ -187,7 +195,7 @@ system_call:
187 STORE_TIMER __LC_SYNC_ENTER_TIMER 195 STORE_TIMER __LC_SYNC_ENTER_TIMER
188sysc_saveall: 196sysc_saveall:
189 SAVE_ALL_BASE __LC_SAVE_AREA 197 SAVE_ALL_BASE __LC_SAVE_AREA
190 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1 198 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
191 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA 199 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
192 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore 200 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
193#ifdef CONFIG_VIRT_CPU_ACCOUNTING 201#ifdef CONFIG_VIRT_CPU_ACCOUNTING
@@ -446,7 +454,7 @@ pgm_check_handler:
446 SAVE_ALL_BASE __LC_SAVE_AREA 454 SAVE_ALL_BASE __LC_SAVE_AREA
447 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception 455 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
448 jnz pgm_per # got per exception -> special case 456 jnz pgm_per # got per exception -> special case
449 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1 457 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
450 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA 458 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
451#ifdef CONFIG_VIRT_CPU_ACCOUNTING 459#ifdef CONFIG_VIRT_CPU_ACCOUNTING
452 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 460 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -485,7 +493,7 @@ pgm_per:
485# Normal per exception 493# Normal per exception
486# 494#
487pgm_per_std: 495pgm_per_std:
488 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1 496 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
489 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA 497 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
490#ifdef CONFIG_VIRT_CPU_ACCOUNTING 498#ifdef CONFIG_VIRT_CPU_ACCOUNTING
491 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 499 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -511,7 +519,7 @@ pgm_no_vtime2:
511# it was a single stepped SVC that is causing all the trouble 519# it was a single stepped SVC that is causing all the trouble
512# 520#
513pgm_svcper: 521pgm_svcper:
514 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1 522 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
515 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA 523 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
516#ifdef CONFIG_VIRT_CPU_ACCOUNTING 524#ifdef CONFIG_VIRT_CPU_ACCOUNTING
517 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 525 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -539,7 +547,7 @@ io_int_handler:
539 STORE_TIMER __LC_ASYNC_ENTER_TIMER 547 STORE_TIMER __LC_ASYNC_ENTER_TIMER
540 stck __LC_INT_CLOCK 548 stck __LC_INT_CLOCK
541 SAVE_ALL_BASE __LC_SAVE_AREA+32 549 SAVE_ALL_BASE __LC_SAVE_AREA+32
542 SAVE_ALL __LC_IO_OLD_PSW,__LC_SAVE_AREA+32,0 550 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
543 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32 551 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
544#ifdef CONFIG_VIRT_CPU_ACCOUNTING 552#ifdef CONFIG_VIRT_CPU_ACCOUNTING
545 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 553 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -647,7 +655,7 @@ ext_int_handler:
647 STORE_TIMER __LC_ASYNC_ENTER_TIMER 655 STORE_TIMER __LC_ASYNC_ENTER_TIMER
648 stck __LC_INT_CLOCK 656 stck __LC_INT_CLOCK
649 SAVE_ALL_BASE __LC_SAVE_AREA+32 657 SAVE_ALL_BASE __LC_SAVE_AREA+32
650 SAVE_ALL __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32,0 658 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
651 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32 659 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
652#ifdef CONFIG_VIRT_CPU_ACCOUNTING 660#ifdef CONFIG_VIRT_CPU_ACCOUNTING
653 tm SP_PSW+1(%r15),0x01 # interrupting from user ? 661 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
@@ -672,21 +680,32 @@ __critical_end:
672mcck_int_handler: 680mcck_int_handler:
673 la %r1,4095 # revalidate r1 681 la %r1,4095 # revalidate r1
674 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer 682 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
675 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r1)
676 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs 683 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
677 SAVE_ALL_BASE __LC_SAVE_AREA+64 684 SAVE_ALL_BASE __LC_SAVE_AREA+64
678 la %r12,__LC_MCK_OLD_PSW 685 la %r12,__LC_MCK_OLD_PSW
679 tm __LC_MCCK_CODE,0x80 # system damage? 686 tm __LC_MCCK_CODE,0x80 # system damage?
680 jo mcck_int_main # yes -> rest of mcck code invalid 687 jo mcck_int_main # yes -> rest of mcck code invalid
681 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
682 jo 0f
683 spt __LC_LAST_UPDATE_TIMER
684#ifdef CONFIG_VIRT_CPU_ACCOUNTING 688#ifdef CONFIG_VIRT_CPU_ACCOUNTING
685 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER 689 la %r14,4095
686 mvc __LC_SYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER 690 mvc __LC_SAVE_AREA+104(8),__LC_ASYNC_ENTER_TIMER
687 mvc __LC_EXIT_TIMER(8),__LC_LAST_UPDATE_TIMER 691 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r14)
692 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
693 jo 1f
694 la %r14,__LC_SYNC_ENTER_TIMER
695 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
696 jl 0f
697 la %r14,__LC_ASYNC_ENTER_TIMER
6980: clc 0(8,%r14),__LC_EXIT_TIMER
699 jl 0f
700 la %r14,__LC_EXIT_TIMER
7010: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
702 jl 0f
703 la %r14,__LC_LAST_UPDATE_TIMER
7040: spt 0(%r14)
705 mvc __LC_ASYNC_ENTER_TIMER(8),0(%r14)
7061:
688#endif 707#endif
6890: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid? 708 tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
690 jno mcck_int_main # no -> skip cleanup critical 709 jno mcck_int_main # no -> skip cleanup critical
691 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit 710 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
692 jnz mcck_int_main # from user -> load kernel stack 711 jnz mcck_int_main # from user -> load kernel stack
@@ -705,7 +724,7 @@ mcck_int_main:
705#ifdef CONFIG_VIRT_CPU_ACCOUNTING 724#ifdef CONFIG_VIRT_CPU_ACCOUNTING
706 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid? 725 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
707 jno mcck_no_vtime # no -> no timer update 726 jno mcck_no_vtime # no -> no timer update
708 tm __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ? 727 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
709 jz mcck_no_vtime 728 jz mcck_no_vtime
710 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER 729 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
711 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER 730 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
@@ -727,7 +746,17 @@ mcck_no_vtime:
727 jno mcck_return 746 jno mcck_return
728 brasl %r14,s390_handle_mcck 747 brasl %r14,s390_handle_mcck
729mcck_return: 748mcck_return:
730 RESTORE_ALL __LC_RETURN_MCCK_PSW,0 749 mvc __LC_RETURN_MCCK_PSW(16),SP_PSW(%r15) # move return PSW
750 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
751 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15
752#ifdef CONFIG_VIRT_CPU_ACCOUNTING
753 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_SAVE_AREA+104
754 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
755 jno 0f
756 stpt __LC_EXIT_TIMER
7570:
758#endif
759 lpswe __LC_RETURN_MCCK_PSW # back to caller
731 760
732#ifdef CONFIG_SMP 761#ifdef CONFIG_SMP
733/* 762/*
@@ -789,6 +818,8 @@ cleanup_table_sysc_leave:
789 .quad sysc_leave, sysc_work_loop 818 .quad sysc_leave, sysc_work_loop
790cleanup_table_sysc_work_loop: 819cleanup_table_sysc_work_loop:
791 .quad sysc_work_loop, sysc_reschedule 820 .quad sysc_work_loop, sysc_reschedule
821cleanup_table_io_return:
822 .quad io_return, io_leave
792cleanup_table_io_leave: 823cleanup_table_io_leave:
793 .quad io_leave, io_done 824 .quad io_leave, io_done
794cleanup_table_io_work_loop: 825cleanup_table_io_work_loop:
@@ -815,6 +846,11 @@ cleanup_critical:
815 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop+8) 846 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop+8)
816 jl cleanup_sysc_return 847 jl cleanup_sysc_return
8170: 8480:
849 clc 8(8,%r12),BASED(cleanup_table_io_return)
850 jl 0f
851 clc 8(8,%r12),BASED(cleanup_table_io_return+8)
852 jl cleanup_io_return
8530:
818 clc 8(8,%r12),BASED(cleanup_table_io_leave) 854 clc 8(8,%r12),BASED(cleanup_table_io_leave)
819 jl 0f 855 jl 0f
820 clc 8(8,%r12),BASED(cleanup_table_io_leave+8) 856 clc 8(8,%r12),BASED(cleanup_table_io_leave+8)
@@ -847,7 +883,7 @@ cleanup_system_call:
847 mvc __LC_SAVE_AREA(32),0(%r12) 883 mvc __LC_SAVE_AREA(32),0(%r12)
8480: stg %r13,8(%r12) 8840: stg %r13,8(%r12)
849 stg %r12,__LC_SAVE_AREA+96 # argh 885 stg %r12,__LC_SAVE_AREA+96 # argh
850 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1 886 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
851 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA 887 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
852 lg %r12,__LC_SAVE_AREA+96 # argh 888 lg %r12,__LC_SAVE_AREA+96 # argh
853 stg %r15,24(%r12) 889 stg %r15,24(%r12)
@@ -957,7 +993,6 @@ cleanup_io_leave_insn:
957 .quad __critical_end 993 .quad __critical_end
958 994
959#define SYSCALL(esa,esame,emu) .long esame 995#define SYSCALL(esa,esame,emu) .long esame
960 .globl sys_call_table
961sys_call_table: 996sys_call_table:
962#include "syscalls.S" 997#include "syscalls.S"
963#undef SYSCALL 998#undef SYSCALL
@@ -965,7 +1000,6 @@ sys_call_table:
965#ifdef CONFIG_COMPAT 1000#ifdef CONFIG_COMPAT
966 1001
967#define SYSCALL(esa,esame,emu) .long emu 1002#define SYSCALL(esa,esame,emu) .long emu
968 .globl sys_call_table_emu
969sys_call_table_emu: 1003sys_call_table_emu:
970#include "syscalls.S" 1004#include "syscalls.S"
971#undef SYSCALL 1005#undef SYSCALL
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index ea88d066bf04..538c82da49b1 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/head.S 2 * arch/s390/kernel/head.S
3 * 3 *
4 * (C) Copyright IBM Corp. 1999, 2005 4 * Copyright (C) IBM Corp. 1999,2006
5 * 5 *
6 * Author(s): Hartmut Penner <hp@de.ibm.com> 6 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky <schwidefsky@de.ibm.com> 7 * Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -482,24 +482,23 @@ start:
482 482
483.macro GET_IPL_DEVICE 483.macro GET_IPL_DEVICE
484.Lget_ipl_device: 484.Lget_ipl_device:
485 basr %r12,0 485 l %r1,0xb8 # get sid
486.LGID: l %r1,0xb8 # get sid
487 sll %r1,15 # test if subchannel is enabled 486 sll %r1,15 # test if subchannel is enabled
488 srl %r1,31 487 srl %r1,31
489 ltr %r1,%r1 488 ltr %r1,%r1
490 bz 0(%r14) # subchannel disabled 489 bz 2f-.LPG1(%r13) # subchannel disabled
491 l %r1,0xb8 490 l %r1,0xb8
492 la %r5,.Lipl_schib-.LGID(%r12) 491 la %r5,.Lipl_schib-.LPG1(%r13)
493 stsch 0(%r5) # get schib of subchannel 492 stsch 0(%r5) # get schib of subchannel
494 bnz 0(%r14) # schib not available 493 bnz 2f-.LPG1(%r13) # schib not available
495 tm 5(%r5),0x01 # devno valid? 494 tm 5(%r5),0x01 # devno valid?
496 bno 0(%r14) 495 bno 2f-.LPG1(%r13)
497 la %r6,ipl_parameter_flags-.LGID(%r12) 496 la %r6,ipl_parameter_flags-.LPG1(%r13)
498 oi 3(%r6),0x01 # set flag 497 oi 3(%r6),0x01 # set flag
499 la %r2,ipl_devno-.LGID(%r12) 498 la %r2,ipl_devno-.LPG1(%r13)
500 mvc 0(2,%r2),6(%r5) # store devno 499 mvc 0(2,%r2),6(%r5) # store devno
501 tm 4(%r5),0x80 # qdio capable device? 500 tm 4(%r5),0x80 # qdio capable device?
502 bno 0(%r14) 501 bno 2f-.LPG1(%r13)
503 oi 3(%r6),0x02 # set flag 502 oi 3(%r6),0x02 # set flag
504 503
505 # copy ipl parameters 504 # copy ipl parameters
@@ -523,7 +522,7 @@ start:
523 ar %r2,%r1 522 ar %r2,%r1
524 sr %r0,%r4 523 sr %r0,%r4
525 jne 1b 524 jne 1b
526 b 0(%r14) 525 b 2f-.LPG1(%r13)
527 526
528 .align 4 527 .align 4
529.Lipl_schib: 528.Lipl_schib:
@@ -537,6 +536,7 @@ ipl_parameter_flags:
537 .globl ipl_devno 536 .globl ipl_devno
538ipl_devno: 537ipl_devno:
539 .word 0 538 .word 0
5392:
540.endm 540.endm
541 541
542#ifdef CONFIG_64BIT 542#ifdef CONFIG_64BIT
diff --git a/arch/s390/kernel/head31.S b/arch/s390/kernel/head31.S
index 2d3b089bfb83..d00de17b3778 100644
--- a/arch/s390/kernel/head31.S
+++ b/arch/s390/kernel/head31.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/head31.S 2 * arch/s390/kernel/head31.S
3 * 3 *
4 * (C) Copyright IBM Corp. 2005 4 * Copyright (C) IBM Corp. 2005,2006
5 * 5 *
6 * Author(s): Hartmut Penner <hp@de.ibm.com> 6 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky <schwidefsky@de.ibm.com> 7 * Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -16,12 +16,31 @@
16# or linload or SALIPL 16# or linload or SALIPL
17# 17#
18 .org 0x10000 18 .org 0x10000
19startup:basr %r13,0 # get base 19startup:basr %r13,0 # get base
20.LPG1: l %r1, .Lget_ipl_device_addr-.LPG1(%r13) 20.LPG0: l %r13,0f-.LPG0(%r13)
21 basr %r14, %r1 21 b 0(%r13)
220: .long startup_continue
23
24#
25# params at 10400 (setup.h)
26#
27 .org PARMAREA
28 .long 0,0 # IPL_DEVICE
29 .long 0,RAMDISK_ORIGIN # INITRD_START
30 .long 0,RAMDISK_SIZE # INITRD_SIZE
31
32 .org COMMAND_LINE
33 .byte "root=/dev/ram0 ro"
34 .byte 0
35
36 .org 0x11000
37
38startup_continue:
39 basr %r13,0 # get base
40.LPG1: GET_IPL_DEVICE
22 lctl %c0,%c15,.Lctl-.LPG1(%r13) # load control registers 41 lctl %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
23 la %r12,_pstart-.LPG1(%r13) # pointer to parameter area 42 l %r12,.Lparmaddr-.LPG1(%r13) # pointer to parameter area
24 # move IPL device to lowcore 43 # move IPL device to lowcore
25 mvc __LC_IPLDEV(4),IPL_DEVICE-PARMAREA(%r12) 44 mvc __LC_IPLDEV(4),IPL_DEVICE-PARMAREA(%r12)
26 45
27# 46#
@@ -51,8 +70,8 @@ startup:basr %r13,0 # get base
51 a %r1,__LC_EXT_NEW_PSW+4 # set handler 70 a %r1,__LC_EXT_NEW_PSW+4 # set handler
52 st %r1,__LC_EXT_NEW_PSW+4 71 st %r1,__LC_EXT_NEW_PSW+4
53 72
54 la %r4,_pstart-.LPG1(%r13) # %r4 is our index for sccb stuff 73 l %r4,.Lsccbaddr-.LPG1(%r13) # %r4 is our index for sccb stuff
55 la %r1, .Lsccb-PARMAREA(%r4) # our sccb 74 lr %r1,%r4 # our sccb
56 .insn rre,0xb2200000,%r2,%r1 # service call 75 .insn rre,0xb2200000,%r2,%r1 # service call
57 ipm %r1 76 ipm %r1
58 srl %r1,28 # get cc code 77 srl %r1,28 # get cc code
@@ -63,7 +82,7 @@ startup:basr %r13,0 # get base
63 be .Lservicecall-.LPG1(%r13) 82 be .Lservicecall-.LPG1(%r13)
64 lpsw .Lwaitsclp-.LPG1(%r13) 83 lpsw .Lwaitsclp-.LPG1(%r13)
65.Lsclph: 84.Lsclph:
66 lh %r1,.Lsccbr-PARMAREA(%r4) 85 lh %r1,.Lsccbr-.Lsccb(%r4)
67 chi %r1,0x10 # 0x0010 is the sucess code 86 chi %r1,0x10 # 0x0010 is the sucess code
68 je .Lprocsccb # let's process the sccb 87 je .Lprocsccb # let's process the sccb
69 chi %r1,0x1f0 88 chi %r1,0x1f0
@@ -74,7 +93,7 @@ startup:basr %r13,0 # get base
74 b .Lservicecall-.LPG1(%r13) 93 b .Lservicecall-.LPG1(%r13)
75.Lprocsccb: 94.Lprocsccb:
76 lhi %r1,0 95 lhi %r1,0
77 icm %r1,3,.Lscpincr1-PARMAREA(%r4) # use this one if != 0 96 icm %r1,3,.Lscpincr1-.Lsccb(%r4) # use this one if != 0
78 jnz .Lscnd 97 jnz .Lscnd
79 lhi %r1,0x800 # otherwise report 2GB 98 lhi %r1,0x800 # otherwise report 2GB
80.Lscnd: 99.Lscnd:
@@ -84,10 +103,10 @@ startup:basr %r13,0 # get base
84 lr %r1,%r3 103 lr %r1,%r3
85.Lno2gb: 104.Lno2gb:
86 xr %r3,%r3 # same logic 105 xr %r3,%r3 # same logic
87 ic %r3,.Lscpa1-PARMAREA(%r4) 106 ic %r3,.Lscpa1-.Lsccb(%r4)
88 chi %r3,0x00 107 chi %r3,0x00
89 jne .Lcompmem 108 jne .Lcompmem
90 l %r3,.Lscpa2-PARMAREA(%r13) 109 l %r3,.Lscpa2-.Lsccb(%r4)
91.Lcompmem: 110.Lcompmem:
92 mr %r2,%r1 # mem in MB on 128-bit 111 mr %r2,%r1 # mem in MB on 128-bit
93 l %r1,.Lonemb-.LPG1(%r13) 112 l %r1,.Lonemb-.LPG1(%r13)
@@ -95,8 +114,6 @@ startup:basr %r13,0 # get base
95 b .Lfchunk-.LPG1(%r13) 114 b .Lfchunk-.LPG1(%r13)
96 115
97 .align 4 116 .align 4
98.Lget_ipl_device_addr:
99 .long .Lget_ipl_device
100.Lpmask: 117.Lpmask:
101 .byte 0 118 .byte 0
102.align 8 119.align 8
@@ -242,6 +259,8 @@ startup:basr %r13,0 # get base
242 .long 0 # cr13: home space segment table 259 .long 0 # cr13: home space segment table
243 .long 0xc0000000 # cr14: machine check handling off 260 .long 0xc0000000 # cr14: machine check handling off
244 .long 0 # cr15: linkage stack operations 261 .long 0 # cr15: linkage stack operations
262.Lduct: .long 0,0,0,0,0,0,0,0
263 .long 0,0,0,0,0,0,0,0
245.Lpcmem:.long 0x00080000,0x80000000 + .Lchkmem 264.Lpcmem:.long 0x00080000,0x80000000 + .Lchkmem
246.Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu 265.Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu
247.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp 266.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
@@ -252,25 +271,9 @@ startup:basr %r13,0 # get base
252.Lmflags:.long machine_flags 271.Lmflags:.long machine_flags
253.Lbss_bgn: .long __bss_start 272.Lbss_bgn: .long __bss_start
254.Lbss_end: .long _end 273.Lbss_end: .long _end
255 274.Lparmaddr: .long PARMAREA
256 .org PARMAREA-64 275.Lsccbaddr: .long .Lsccb
257.Lduct: .long 0,0,0,0,0,0,0,0 276 .align 4096
258 .long 0,0,0,0,0,0,0,0
259
260#
261# params at 10400 (setup.h)
262#
263 .org PARMAREA
264 .global _pstart
265_pstart:
266 .long 0,0 # IPL_DEVICE
267 .long 0,RAMDISK_ORIGIN # INITRD_START
268 .long 0,RAMDISK_SIZE # INITRD_SIZE
269
270 .org COMMAND_LINE
271 .byte "root=/dev/ram0 ro"
272 .byte 0
273 .org 0x11000
274.Lsccb: 277.Lsccb:
275 .hword 0x1000 # length, one page 278 .hword 0x1000 # length, one page
276 .byte 0x00,0x00,0x00 279 .byte 0x00,0x00,0x00
@@ -287,18 +290,14 @@ _pstart:
287.Lscpincr2: 290.Lscpincr2:
288 .quad 0x00 291 .quad 0x00
289 .fill 3984,1,0 292 .fill 3984,1,0
290 .org 0x12000 293 .align 4096
291 .global _pend
292_pend:
293
294 GET_IPL_DEVICE
295 294
296#ifdef CONFIG_SHARED_KERNEL 295#ifdef CONFIG_SHARED_KERNEL
297 .org 0x100000 296 .org 0x100000
298#endif 297#endif
299 298
300# 299#
301# startup-code, running in virtual mode 300# startup-code, running in absolute addressing mode
302# 301#
303 .globl _stext 302 .globl _stext
304_stext: basr %r13,0 # get base 303_stext: basr %r13,0 # get base
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index f08c06f45d5c..47744fcca930 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/head64.S 2 * arch/s390/kernel/head64.S
3 * 3 *
4 * (C) Copyright IBM Corp. 1999,2005 4 * Copyright (C) IBM Corp. 1999,2006
5 * 5 *
6 * Author(s): Hartmut Penner <hp@de.ibm.com> 6 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky <schwidefsky@de.ibm.com> 7 * Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -15,18 +15,37 @@
15# this is called either by the ipl loader or directly by PSW restart 15# this is called either by the ipl loader or directly by PSW restart
16# or linload or SALIPL 16# or linload or SALIPL
17# 17#
18 .org 0x10000 18 .org 0x10000
19startup:basr %r13,0 # get base 19startup:basr %r13,0 # get base
20.LPG0: l %r13,0f-.LPG0(%r13)
21 b 0(%r13)
220: .long startup_continue
23
24#
25# params at 10400 (setup.h)
26#
27 .org PARMAREA
28 .quad 0 # IPL_DEVICE
29 .quad RAMDISK_ORIGIN # INITRD_START
30 .quad RAMDISK_SIZE # INITRD_SIZE
31
32 .org COMMAND_LINE
33 .byte "root=/dev/ram0 ro"
34 .byte 0
35
36 .org 0x11000
37
38startup_continue:
39 basr %r13,0 # get base
20.LPG1: sll %r13,1 # remove high order bit 40.LPG1: sll %r13,1 # remove high order bit
21 srl %r13,1 41 srl %r13,1
22 l %r1,.Lget_ipl_device_addr-.LPG1(%r13) 42 GET_IPL_DEVICE
23 basr %r14,%r1
24 lhi %r1,1 # mode 1 = esame 43 lhi %r1,1 # mode 1 = esame
25 slr %r0,%r0 # set cpuid to zero 44 slr %r0,%r0 # set cpuid to zero
26 sigp %r1,%r0,0x12 # switch to esame mode 45 sigp %r1,%r0,0x12 # switch to esame mode
27 sam64 # switch to 64 bit mode 46 sam64 # switch to 64 bit mode
28 lctlg %c0,%c15,.Lctl-.LPG1(%r13) # load control registers 47 lctlg %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
29 larl %r12,_pstart # pointer to parameter area 48 lg %r12,.Lparmaddr-.LPG1(%r13)# pointer to parameter area
30 # move IPL device to lowcore 49 # move IPL device to lowcore
31 mvc __LC_IPLDEV(4),IPL_DEVICE+4-PARMAREA(%r12) 50 mvc __LC_IPLDEV(4),IPL_DEVICE+4-PARMAREA(%r12)
32 51
@@ -55,8 +74,8 @@ startup:basr %r13,0 # get base
55 larl %r1,.Lsclph 74 larl %r1,.Lsclph
56 stg %r1,__LC_EXT_NEW_PSW+8 # set handler 75 stg %r1,__LC_EXT_NEW_PSW+8 # set handler
57 76
58 larl %r4,_pstart # %r4 is our index for sccb stuff 77 larl %r4,.Lsccb # %r4 is our index for sccb stuff
59 la %r1,.Lsccb-PARMAREA(%r4) # our sccb 78 lgr %r1,%r4 # our sccb
60 .insn rre,0xb2200000,%r2,%r1 # service call 79 .insn rre,0xb2200000,%r2,%r1 # service call
61 ipm %r1 80 ipm %r1
62 srl %r1,28 # get cc code 81 srl %r1,28 # get cc code
@@ -67,7 +86,7 @@ startup:basr %r13,0 # get base
67 be .Lservicecall-.LPG1(%r13) 86 be .Lservicecall-.LPG1(%r13)
68 lpswe .Lwaitsclp-.LPG1(%r13) 87 lpswe .Lwaitsclp-.LPG1(%r13)
69.Lsclph: 88.Lsclph:
70 lh %r1,.Lsccbr-PARMAREA(%r4) 89 lh %r1,.Lsccbr-.Lsccb(%r4)
71 chi %r1,0x10 # 0x0010 is the sucess code 90 chi %r1,0x10 # 0x0010 is the sucess code
72 je .Lprocsccb # let's process the sccb 91 je .Lprocsccb # let's process the sccb
73 chi %r1,0x1f0 92 chi %r1,0x1f0
@@ -78,15 +97,15 @@ startup:basr %r13,0 # get base
78 b .Lservicecall-.LPG1(%r13) 97 b .Lservicecall-.LPG1(%r13)
79.Lprocsccb: 98.Lprocsccb:
80 lghi %r1,0 99 lghi %r1,0
81 icm %r1,3,.Lscpincr1-PARMAREA(%r4) # use this one if != 0 100 icm %r1,3,.Lscpincr1-.Lsccb(%r4) # use this one if != 0
82 jnz .Lscnd 101 jnz .Lscnd
83 lg %r1,.Lscpincr2-PARMAREA(%r4) # otherwise use this one 102 lg %r1,.Lscpincr2-.Lsccb(%r4) # otherwise use this one
84.Lscnd: 103.Lscnd:
85 xr %r3,%r3 # same logic 104 xr %r3,%r3 # same logic
86 ic %r3,.Lscpa1-PARMAREA(%r4) 105 ic %r3,.Lscpa1-.Lsccb(%r4)
87 chi %r3,0x00 106 chi %r3,0x00
88 jne .Lcompmem 107 jne .Lcompmem
89 l %r3,.Lscpa2-PARMAREA(%r13) 108 l %r3,.Lscpa2-.Lsccb(%r4)
90.Lcompmem: 109.Lcompmem:
91 mlgr %r2,%r1 # mem in MB on 128-bit 110 mlgr %r2,%r1 # mem in MB on 128-bit
92 l %r1,.Lonemb-.LPG1(%r13) 111 l %r1,.Lonemb-.LPG1(%r13)
@@ -94,8 +113,6 @@ startup:basr %r13,0 # get base
94 b .Lfchunk-.LPG1(%r13) 113 b .Lfchunk-.LPG1(%r13)
95 114
96 .align 4 115 .align 4
97.Lget_ipl_device_addr:
98 .long .Lget_ipl_device
99.Lpmask: 116.Lpmask:
100 .byte 0 117 .byte 0
101 .align 8 118 .align 8
@@ -242,29 +259,16 @@ startup:basr %r13,0 # get base
242 .quad 0 # cr13: home space segment table 259 .quad 0 # cr13: home space segment table
243 .quad 0xc0000000 # cr14: machine check handling off 260 .quad 0xc0000000 # cr14: machine check handling off
244 .quad 0 # cr15: linkage stack operations 261 .quad 0 # cr15: linkage stack operations
262.Lduct: .long 0,0,0,0,0,0,0,0
263 .long 0,0,0,0,0,0,0,0
245.Lpcmsk:.quad 0x0000000180000000 264.Lpcmsk:.quad 0x0000000180000000
246.L4malign:.quad 0xffffffffffc00000 265.L4malign:.quad 0xffffffffffc00000
247.Lscan2g:.quad 0x80000000 + 0x20000 - 8 # 2GB + 128K - 8 266.Lscan2g:.quad 0x80000000 + 0x20000 - 8 # 2GB + 128K - 8
248.Lnop: .long 0x07000700 267.Lnop: .long 0x07000700
268.Lparmaddr:
269 .quad PARMAREA
249 270
250 .org PARMAREA-64 271 .align 4096
251.Lduct: .long 0,0,0,0,0,0,0,0
252 .long 0,0,0,0,0,0,0,0
253
254#
255# params at 10400 (setup.h)
256#
257 .org PARMAREA
258 .global _pstart
259_pstart:
260 .quad 0 # IPL_DEVICE
261 .quad RAMDISK_ORIGIN # INITRD_START
262 .quad RAMDISK_SIZE # INITRD_SIZE
263
264 .org COMMAND_LINE
265 .byte "root=/dev/ram0 ro"
266 .byte 0
267 .org 0x11000
268.Lsccb: 272.Lsccb:
269 .hword 0x1000 # length, one page 273 .hword 0x1000 # length, one page
270 .byte 0x00,0x00,0x00 274 .byte 0x00,0x00,0x00
@@ -281,18 +285,14 @@ _pstart:
281.Lscpincr2: 285.Lscpincr2:
282 .quad 0x00 286 .quad 0x00
283 .fill 3984,1,0 287 .fill 3984,1,0
284 .org 0x12000 288 .align 4096
285 .global _pend
286_pend:
287
288 GET_IPL_DEVICE
289 289
290#ifdef CONFIG_SHARED_KERNEL 290#ifdef CONFIG_SHARED_KERNEL
291 .org 0x100000 291 .org 0x100000
292#endif 292#endif
293 293
294# 294#
295# startup-code, running in virtual mode 295# startup-code, running in absolute addressing mode
296# 296#
297 .globl _stext 297 .globl _stext
298_stext: basr %r13,0 # get base 298_stext: basr %r13,0 # get base
@@ -326,4 +326,3 @@ _stext: basr %r13,0 # get base
326 .align 8 326 .align 8
327.Ldw: .quad 0x0002000180000000,0x0000000000000000 327.Ldw: .quad 0x0002000180000000,0x0000000000000000
328.Laregs: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 328.Laregs: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
329
diff --git a/arch/s390/kernel/s390_ksyms.c b/arch/s390/kernel/s390_ksyms.c
index 4176c77670c4..0886e739d122 100644
--- a/arch/s390/kernel/s390_ksyms.c
+++ b/arch/s390/kernel/s390_ksyms.c
@@ -46,8 +46,6 @@ EXPORT_SYMBOL(__down_interruptible);
46 */ 46 */
47extern int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs); 47extern int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs);
48EXPORT_SYMBOL(dump_fpu); 48EXPORT_SYMBOL(dump_fpu);
49EXPORT_SYMBOL(overflowuid);
50EXPORT_SYMBOL(overflowgid);
51EXPORT_SYMBOL(empty_zero_page); 49EXPORT_SYMBOL(empty_zero_page);
52 50
53/* 51/*
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index b282034452a4..2b2551e3510b 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -37,6 +37,7 @@
37#include <linux/seq_file.h> 37#include <linux/seq_file.h>
38#include <linux/kernel_stat.h> 38#include <linux/kernel_stat.h>
39#include <linux/device.h> 39#include <linux/device.h>
40#include <linux/notifier.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/system.h> 43#include <asm/system.h>
@@ -115,6 +116,7 @@ void __devinit cpu_init (void)
115 */ 116 */
116char vmhalt_cmd[128] = ""; 117char vmhalt_cmd[128] = "";
117char vmpoff_cmd[128] = ""; 118char vmpoff_cmd[128] = "";
119char vmpanic_cmd[128] = "";
118 120
119static inline void strncpy_skip_quote(char *dst, char *src, int n) 121static inline void strncpy_skip_quote(char *dst, char *src, int n)
120{ 122{
@@ -146,6 +148,38 @@ static int __init vmpoff_setup(char *str)
146 148
147__setup("vmpoff=", vmpoff_setup); 149__setup("vmpoff=", vmpoff_setup);
148 150
151static int vmpanic_notify(struct notifier_block *self, unsigned long event,
152 void *data)
153{
154 if (MACHINE_IS_VM && strlen(vmpanic_cmd) > 0)
155 cpcmd(vmpanic_cmd, NULL, 0, NULL);
156
157 return NOTIFY_OK;
158}
159
160#define PANIC_PRI_VMPANIC 0
161
162static struct notifier_block vmpanic_nb = {
163 .notifier_call = vmpanic_notify,
164 .priority = PANIC_PRI_VMPANIC
165};
166
167static int __init vmpanic_setup(char *str)
168{
169 static int register_done __initdata = 0;
170
171 strncpy_skip_quote(vmpanic_cmd, str, 127);
172 vmpanic_cmd[127] = 0;
173 if (!register_done) {
174 register_done = 1;
175 atomic_notifier_chain_register(&panic_notifier_list,
176 &vmpanic_nb);
177 }
178 return 1;
179}
180
181__setup("vmpanic=", vmpanic_setup);
182
149/* 183/*
150 * condev= and conmode= setup parameter. 184 * condev= and conmode= setup parameter.
151 */ 185 */
@@ -289,19 +323,34 @@ void (*_machine_power_off)(void) = do_machine_power_off_nonsmp;
289 323
290void machine_restart(char *command) 324void machine_restart(char *command)
291{ 325{
292 console_unblank(); 326 if (!in_interrupt() || oops_in_progress)
327 /*
328 * Only unblank the console if we are called in enabled
329 * context or a bust_spinlocks cleared the way for us.
330 */
331 console_unblank();
293 _machine_restart(command); 332 _machine_restart(command);
294} 333}
295 334
296void machine_halt(void) 335void machine_halt(void)
297{ 336{
298 console_unblank(); 337 if (!in_interrupt() || oops_in_progress)
338 /*
339 * Only unblank the console if we are called in enabled
340 * context or a bust_spinlocks cleared the way for us.
341 */
342 console_unblank();
299 _machine_halt(); 343 _machine_halt();
300} 344}
301 345
302void machine_power_off(void) 346void machine_power_off(void)
303{ 347{
304 console_unblank(); 348 if (!in_interrupt() || oops_in_progress)
349 /*
350 * Only unblank the console if we are called in enabled
351 * context or a bust_spinlocks cleared the way for us.
352 */
353 console_unblank();
305 _machine_power_off(); 354 _machine_power_off();
306} 355}
307 356
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 343120c9223d..8e03219eea76 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -869,7 +869,7 @@ static int __init topology_init(void)
869 int ret; 869 int ret;
870 870
871 for_each_possible_cpu(cpu) { 871 for_each_possible_cpu(cpu) {
872 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL); 872 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu);
873 if (ret) 873 if (ret)
874 printk(KERN_WARNING "topology_init: register_cpu %d " 874 printk(KERN_WARNING "topology_init: register_cpu %d "
875 "failed (%d)\n", cpu, ret); 875 "failed (%d)\n", cpu, ret);
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index a46793beeddd..b7630436f693 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -150,13 +150,11 @@ void show_stack(struct task_struct *task, unsigned long *sp)
150 unsigned long *stack; 150 unsigned long *stack;
151 int i; 151 int i;
152 152
153 // debugging aid: "show_stack(NULL);" prints the
154 // back trace for this cpu.
155
156 if (!sp) 153 if (!sp)
157 sp = task ? (unsigned long *) task->thread.ksp : __r15; 154 stack = task ? (unsigned long *) task->thread.ksp : __r15;
155 else
156 stack = sp;
158 157
159 stack = sp;
160 for (i = 0; i < kstack_depth_to_print; i++) { 158 for (i = 0; i < kstack_depth_to_print; i++) {
161 if (((addr_t) stack & (THREAD_SIZE-1)) == 0) 159 if (((addr_t) stack & (THREAD_SIZE-1)) == 0)
162 break; 160 break;
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 2bcecf422573..1a0db1d4c952 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -465,10 +465,10 @@ config KEXEC
465 help 465 help
466 kexec is a system call that implements the ability to shutdown your 466 kexec is a system call that implements the ability to shutdown your
467 current kernel, and to start another kernel. It is like a reboot 467 current kernel, and to start another kernel. It is like a reboot
468 but it is indepedent of the system firmware. And like a reboot 468 but it is independent of the system firmware. And like a reboot
469 you can start any kernel with it, not just Linux. 469 you can start any kernel with it, not just Linux.
470 470
471 The name comes from the similiarity to the exec system call. 471 The name comes from the similarity to the exec system call.
472 472
473 It is an ongoing process to be certain the hardware in a machine 473 It is an ongoing process to be certain the hardware in a machine
474 is properly shutdown, so do not be surprised if this code does not 474 is properly shutdown, so do not be surprised if this code does not
diff --git a/arch/sh/boards/adx/irq_maskreg.c b/arch/sh/boards/adx/irq_maskreg.c
index c0973f8d57ba..357fab1bac2b 100644
--- a/arch/sh/boards/adx/irq_maskreg.c
+++ b/arch/sh/boards/adx/irq_maskreg.c
@@ -102,6 +102,6 @@ static void end_maskreg_irq(unsigned int irq)
102void make_maskreg_irq(unsigned int irq) 102void make_maskreg_irq(unsigned int irq)
103{ 103{
104 disable_irq_nosync(irq); 104 disable_irq_nosync(irq);
105 irq_desc[irq].handler = &maskreg_irq_type; 105 irq_desc[irq].chip = &maskreg_irq_type;
106 disable_maskreg_irq(irq); 106 disable_maskreg_irq(irq);
107} 107}
diff --git a/arch/sh/boards/bigsur/irq.c b/arch/sh/boards/bigsur/irq.c
index 6ddbcc77244d..1d32425782c0 100644
--- a/arch/sh/boards/bigsur/irq.c
+++ b/arch/sh/boards/bigsur/irq.c
@@ -253,7 +253,7 @@ static void make_bigsur_l1isr(unsigned int irq) {
253 /* sanity check first */ 253 /* sanity check first */
254 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) { 254 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
255 /* save the handler in the main description table */ 255 /* save the handler in the main description table */
256 irq_desc[irq].handler = &bigsur_l1irq_type; 256 irq_desc[irq].chip = &bigsur_l1irq_type;
257 irq_desc[irq].status = IRQ_DISABLED; 257 irq_desc[irq].status = IRQ_DISABLED;
258 irq_desc[irq].action = 0; 258 irq_desc[irq].action = 0;
259 irq_desc[irq].depth = 1; 259 irq_desc[irq].depth = 1;
@@ -270,7 +270,7 @@ static void make_bigsur_l2isr(unsigned int irq) {
270 /* sanity check first */ 270 /* sanity check first */
271 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) { 271 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
272 /* save the handler in the main description table */ 272 /* save the handler in the main description table */
273 irq_desc[irq].handler = &bigsur_l2irq_type; 273 irq_desc[irq].chip = &bigsur_l2irq_type;
274 irq_desc[irq].status = IRQ_DISABLED; 274 irq_desc[irq].status = IRQ_DISABLED;
275 irq_desc[irq].action = 0; 275 irq_desc[irq].action = 0;
276 irq_desc[irq].depth = 1; 276 irq_desc[irq].depth = 1;
diff --git a/arch/sh/boards/cqreek/irq.c b/arch/sh/boards/cqreek/irq.c
index d1da0d844567..2955adc52310 100644
--- a/arch/sh/boards/cqreek/irq.c
+++ b/arch/sh/boards/cqreek/irq.c
@@ -103,7 +103,7 @@ void __init init_cqreek_IRQ(void)
103 cqreek_irq_data[14].stat_port = BRIDGE_IDE_INTR_STAT; 103 cqreek_irq_data[14].stat_port = BRIDGE_IDE_INTR_STAT;
104 cqreek_irq_data[14].bit = 1; 104 cqreek_irq_data[14].bit = 1;
105 105
106 irq_desc[14].handler = &cqreek_irq_type; 106 irq_desc[14].chip = &cqreek_irq_type;
107 irq_desc[14].status = IRQ_DISABLED; 107 irq_desc[14].status = IRQ_DISABLED;
108 irq_desc[14].action = 0; 108 irq_desc[14].action = 0;
109 irq_desc[14].depth = 1; 109 irq_desc[14].depth = 1;
@@ -117,7 +117,7 @@ void __init init_cqreek_IRQ(void)
117 cqreek_irq_data[10].bit = (1 << 10); 117 cqreek_irq_data[10].bit = (1 << 10);
118 118
119 /* XXX: Err... we may need demultiplexer for ISA irq... */ 119 /* XXX: Err... we may need demultiplexer for ISA irq... */
120 irq_desc[10].handler = &cqreek_irq_type; 120 irq_desc[10].chip = &cqreek_irq_type;
121 irq_desc[10].status = IRQ_DISABLED; 121 irq_desc[10].status = IRQ_DISABLED;
122 irq_desc[10].action = 0; 122 irq_desc[10].action = 0;
123 irq_desc[10].depth = 1; 123 irq_desc[10].depth = 1;
diff --git a/arch/sh/boards/dreamcast/setup.c b/arch/sh/boards/dreamcast/setup.c
index 55dece35cde5..0027b80a2343 100644
--- a/arch/sh/boards/dreamcast/setup.c
+++ b/arch/sh/boards/dreamcast/setup.c
@@ -70,7 +70,7 @@ int __init platform_setup(void)
70 70
71 /* Assign all virtual IRQs to the System ASIC int. handler */ 71 /* Assign all virtual IRQs to the System ASIC int. handler */
72 for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++) 72 for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++)
73 irq_desc[i].handler = &systemasic_int; 73 irq_desc[i].chip = &systemasic_int;
74 74
75 board_time_init = aica_time_init; 75 board_time_init = aica_time_init;
76 76
diff --git a/arch/sh/boards/ec3104/setup.c b/arch/sh/boards/ec3104/setup.c
index 5130ba2b6ff1..4b3ef16a0e96 100644
--- a/arch/sh/boards/ec3104/setup.c
+++ b/arch/sh/boards/ec3104/setup.c
@@ -63,7 +63,7 @@ int __init platform_setup(void)
63 str[i] = ctrl_readb(EC3104_BASE + i); 63 str[i] = ctrl_readb(EC3104_BASE + i);
64 64
65 for (i = EC3104_IRQBASE; i < EC3104_IRQBASE + 32; i++) 65 for (i = EC3104_IRQBASE; i < EC3104_IRQBASE + 32; i++)
66 irq_desc[i].handler = &ec3104_int; 66 irq_desc[i].chip = &ec3104_int;
67 67
68 printk("initializing EC3104 \"%.8s\" at %08x, IRQ %d, IRQ base %d\n", 68 printk("initializing EC3104 \"%.8s\" at %08x, IRQ %d, IRQ base %d\n",
69 str, EC3104_BASE, EC3104_IRQ, EC3104_IRQBASE); 69 str, EC3104_BASE, EC3104_IRQ, EC3104_IRQBASE);
diff --git a/arch/sh/boards/harp/irq.c b/arch/sh/boards/harp/irq.c
index 52d0ba39031b..701fa55d5297 100644
--- a/arch/sh/boards/harp/irq.c
+++ b/arch/sh/boards/harp/irq.c
@@ -114,7 +114,7 @@ static void enable_harp_irq(unsigned int irq)
114static void __init make_harp_irq(unsigned int irq) 114static void __init make_harp_irq(unsigned int irq)
115{ 115{
116 disable_irq_nosync(irq); 116 disable_irq_nosync(irq);
117 irq_desc[irq].handler = &harp_irq_type; 117 irq_desc[irq].chip = &harp_irq_type;
118 disable_harp_irq(irq); 118 disable_harp_irq(irq);
119} 119}
120 120
diff --git a/arch/sh/boards/mpc1211/pci.c b/arch/sh/boards/mpc1211/pci.c
index ba3a65439752..9f7ccd33ffb6 100644
--- a/arch/sh/boards/mpc1211/pci.c
+++ b/arch/sh/boards/mpc1211/pci.c
@@ -273,9 +273,9 @@ void __init pcibios_fixup_irqs(void)
273} 273}
274 274
275void pcibios_align_resource(void *data, struct resource *res, 275void pcibios_align_resource(void *data, struct resource *res,
276 unsigned long size, unsigned long align) 276 resource_size_t size, resource_size_t align)
277{ 277{
278 unsigned long start = res->start; 278 resource_size_t start = res->start;
279 279
280 if (res->flags & IORESOURCE_IO) { 280 if (res->flags & IORESOURCE_IO) {
281 if (start >= 0x10000UL) { 281 if (start >= 0x10000UL) {
diff --git a/arch/sh/boards/mpc1211/setup.c b/arch/sh/boards/mpc1211/setup.c
index 2bb581b91683..b72f009c52c2 100644
--- a/arch/sh/boards/mpc1211/setup.c
+++ b/arch/sh/boards/mpc1211/setup.c
@@ -194,7 +194,7 @@ static struct hw_interrupt_type mpc1211_irq_type = {
194 194
195static void make_mpc1211_irq(unsigned int irq) 195static void make_mpc1211_irq(unsigned int irq)
196{ 196{
197 irq_desc[irq].handler = &mpc1211_irq_type; 197 irq_desc[irq].chip = &mpc1211_irq_type;
198 irq_desc[irq].status = IRQ_DISABLED; 198 irq_desc[irq].status = IRQ_DISABLED;
199 irq_desc[irq].action = 0; 199 irq_desc[irq].action = 0;
200 irq_desc[irq].depth = 1; 200 irq_desc[irq].depth = 1;
diff --git a/arch/sh/boards/overdrive/galileo.c b/arch/sh/boards/overdrive/galileo.c
index 276fa11ee4ce..b055809d2ac1 100644
--- a/arch/sh/boards/overdrive/galileo.c
+++ b/arch/sh/boards/overdrive/galileo.c
@@ -536,7 +536,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
536} 536}
537 537
538void pcibios_align_resource(void *data, struct resource *res, 538void pcibios_align_resource(void *data, struct resource *res,
539 unsigned long size) 539 resource_size_t size)
540{ 540{
541} 541}
542 542
diff --git a/arch/sh/boards/overdrive/irq.c b/arch/sh/boards/overdrive/irq.c
index 715e8feb3a68..2c13a7de6b22 100644
--- a/arch/sh/boards/overdrive/irq.c
+++ b/arch/sh/boards/overdrive/irq.c
@@ -150,7 +150,7 @@ static void enable_od_irq(unsigned int irq)
150static void __init make_od_irq(unsigned int irq) 150static void __init make_od_irq(unsigned int irq)
151{ 151{
152 disable_irq_nosync(irq); 152 disable_irq_nosync(irq);
153 irq_desc[irq].handler = &od_irq_type; 153 irq_desc[irq].chip = &od_irq_type;
154 disable_od_irq(irq); 154 disable_od_irq(irq);
155} 155}
156 156
diff --git a/arch/sh/boards/renesas/hs7751rvoip/irq.c b/arch/sh/boards/renesas/hs7751rvoip/irq.c
index ed4c5b50ea45..52a98b524e1f 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/irq.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/irq.c
@@ -86,7 +86,7 @@ static struct hw_interrupt_type hs7751rvoip_irq_type = {
86static void make_hs7751rvoip_irq(unsigned int irq) 86static void make_hs7751rvoip_irq(unsigned int irq)
87{ 87{
88 disable_irq_nosync(irq); 88 disable_irq_nosync(irq);
89 irq_desc[irq].handler = &hs7751rvoip_irq_type; 89 irq_desc[irq].chip = &hs7751rvoip_irq_type;
90 disable_hs7751rvoip_irq(irq); 90 disable_hs7751rvoip_irq(irq);
91} 91}
92 92
diff --git a/arch/sh/boards/renesas/rts7751r2d/irq.c b/arch/sh/boards/renesas/rts7751r2d/irq.c
index d36c9374aed1..e16915d9cda4 100644
--- a/arch/sh/boards/renesas/rts7751r2d/irq.c
+++ b/arch/sh/boards/renesas/rts7751r2d/irq.c
@@ -100,7 +100,7 @@ static struct hw_interrupt_type rts7751r2d_irq_type = {
100static void make_rts7751r2d_irq(unsigned int irq) 100static void make_rts7751r2d_irq(unsigned int irq)
101{ 101{
102 disable_irq_nosync(irq); 102 disable_irq_nosync(irq);
103 irq_desc[irq].handler = &rts7751r2d_irq_type; 103 irq_desc[irq].chip = &rts7751r2d_irq_type;
104 disable_rts7751r2d_irq(irq); 104 disable_rts7751r2d_irq(irq);
105} 105}
106 106
diff --git a/arch/sh/boards/renesas/systemh/irq.c b/arch/sh/boards/renesas/systemh/irq.c
index 7a2eb10edb56..845979181059 100644
--- a/arch/sh/boards/renesas/systemh/irq.c
+++ b/arch/sh/boards/renesas/systemh/irq.c
@@ -105,7 +105,7 @@ static void end_systemh_irq(unsigned int irq)
105void make_systemh_irq(unsigned int irq) 105void make_systemh_irq(unsigned int irq)
106{ 106{
107 disable_irq_nosync(irq); 107 disable_irq_nosync(irq);
108 irq_desc[irq].handler = &systemh_irq_type; 108 irq_desc[irq].chip = &systemh_irq_type;
109 disable_systemh_irq(irq); 109 disable_systemh_irq(irq);
110} 110}
111 111
diff --git a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c
index 70f04caad9a4..402735c7c898 100644
--- a/arch/sh/boards/se/73180/irq.c
+++ b/arch/sh/boards/se/73180/irq.c
@@ -85,7 +85,7 @@ void
85make_intreq_irq(unsigned int irq) 85make_intreq_irq(unsigned int irq)
86{ 86{
87 disable_irq_nosync(irq); 87 disable_irq_nosync(irq);
88 irq_desc[irq].handler = &intreq_irq_type; 88 irq_desc[irq].chip = &intreq_irq_type;
89 disable_intreq_irq(irq); 89 disable_intreq_irq(irq);
90} 90}
91 91
diff --git a/arch/sh/boards/superh/microdev/irq.c b/arch/sh/boards/superh/microdev/irq.c
index efcbd86b7cd2..cb5999425d16 100644
--- a/arch/sh/boards/superh/microdev/irq.c
+++ b/arch/sh/boards/superh/microdev/irq.c
@@ -147,7 +147,7 @@ static void enable_microdev_irq(unsigned int irq)
147static void __init make_microdev_irq(unsigned int irq) 147static void __init make_microdev_irq(unsigned int irq)
148{ 148{
149 disable_irq_nosync(irq); 149 disable_irq_nosync(irq);
150 irq_desc[irq].handler = &microdev_irq_type; 150 irq_desc[irq].chip = &microdev_irq_type;
151 disable_microdev_irq(irq); 151 disable_microdev_irq(irq);
152} 152}
153 153
diff --git a/arch/sh/cchips/hd6446x/hd64461/setup.c b/arch/sh/cchips/hd6446x/hd64461/setup.c
index f014b9bf6922..724db04cb392 100644
--- a/arch/sh/cchips/hd6446x/hd64461/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64461/setup.c
@@ -154,7 +154,7 @@ int __init setup_hd64461(void)
154 outw(0xffff, HD64461_NIMR); 154 outw(0xffff, HD64461_NIMR);
155 155
156 for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++) { 156 for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++) {
157 irq_desc[i].handler = &hd64461_irq_type; 157 irq_desc[i].chip = &hd64461_irq_type;
158 } 158 }
159 159
160 setup_irq(CONFIG_HD64461_IRQ, &irq0); 160 setup_irq(CONFIG_HD64461_IRQ, &irq0);
diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
index 68e4c4e4283d..cf9142c620b7 100644
--- a/arch/sh/cchips/hd6446x/hd64465/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64465/setup.c
@@ -182,7 +182,7 @@ static int __init setup_hd64465(void)
182 outw(0xffff, HD64465_REG_NIMR); /* mask all interrupts */ 182 outw(0xffff, HD64465_REG_NIMR); /* mask all interrupts */
183 183
184 for (i = 0; i < HD64465_IRQ_NUM ; i++) { 184 for (i = 0; i < HD64465_IRQ_NUM ; i++) {
185 irq_desc[HD64465_IRQ_BASE + i].handler = &hd64465_irq_type; 185 irq_desc[HD64465_IRQ_BASE + i].chip = &hd64465_irq_type;
186 } 186 }
187 187
188 setup_irq(CONFIG_HD64465_IRQ, &irq0); 188 setup_irq(CONFIG_HD64465_IRQ, &irq0);
diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c
index 2ee330b3c38f..892214bade19 100644
--- a/arch/sh/cchips/voyagergx/irq.c
+++ b/arch/sh/cchips/voyagergx/irq.c
@@ -191,7 +191,7 @@ void __init setup_voyagergx_irq(void)
191 flag = 1; 191 flag = 1;
192 } 192 }
193 if (flag == 1) 193 if (flag == 1)
194 irq_desc[VOYAGER_IRQ_BASE + i].handler = &voyagergx_irq_type; 194 irq_desc[VOYAGER_IRQ_BASE + i].chip = &voyagergx_irq_type;
195 } 195 }
196 196
197 setup_irq(IRQ_VOYAGER, &irq0); 197 setup_irq(IRQ_VOYAGER, &irq0);
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index c1669905abe4..3d546ba329cf 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -75,7 +75,7 @@ pcibios_update_resource(struct pci_dev *dev, struct resource *root,
75} 75}
76 76
77void pcibios_align_resource(void *data, struct resource *res, 77void pcibios_align_resource(void *data, struct resource *res,
78 unsigned long size, unsigned long align) 78 resource_size_t size, resource_size_t align)
79 __attribute__ ((weak)); 79 __attribute__ ((weak));
80 80
81/* 81/*
@@ -85,10 +85,10 @@ void pcibios_align_resource(void *data, struct resource *res,
85 * modulo 0x400. 85 * modulo 0x400.
86 */ 86 */
87void pcibios_align_resource(void *data, struct resource *res, 87void pcibios_align_resource(void *data, struct resource *res,
88 unsigned long size, unsigned long align) 88 resource_size_t size, resource_size_t align)
89{ 89{
90 if (res->flags & IORESOURCE_IO) { 90 if (res->flags & IORESOURCE_IO) {
91 unsigned long start = res->start; 91 resource_size_t start = res->start;
92 92
93 if (start & 0x300) { 93 if (start & 0x300) {
94 start = (start + 0x3ff) & ~0x3ff; 94 start = (start + 0x3ff) & ~0x3ff;
diff --git a/arch/sh/kernel/cpu/irq/imask.c b/arch/sh/kernel/cpu/irq/imask.c
index baed9a550d39..a33ae3e0a5a5 100644
--- a/arch/sh/kernel/cpu/irq/imask.c
+++ b/arch/sh/kernel/cpu/irq/imask.c
@@ -105,6 +105,6 @@ static void shutdown_imask_irq(unsigned int irq)
105void make_imask_irq(unsigned int irq) 105void make_imask_irq(unsigned int irq)
106{ 106{
107 disable_irq_nosync(irq); 107 disable_irq_nosync(irq);
108 irq_desc[irq].handler = &imask_irq_type; 108 irq_desc[irq].chip = &imask_irq_type;
109 enable_irq(irq); 109 enable_irq(irq);
110} 110}
diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c
index 06e8afab32e4..30064bf6e154 100644
--- a/arch/sh/kernel/cpu/irq/intc2.c
+++ b/arch/sh/kernel/cpu/irq/intc2.c
@@ -137,7 +137,7 @@ void make_intc2_irq(unsigned int irq,
137 137
138 local_irq_restore(flags); 138 local_irq_restore(flags);
139 139
140 irq_desc[irq].handler = &intc2_irq_type; 140 irq_desc[irq].chip = &intc2_irq_type;
141 141
142 disable_intc2_irq(irq); 142 disable_intc2_irq(irq);
143} 143}
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index e55150ed0856..0373b65c77f9 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -115,7 +115,7 @@ void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority)
115 ipr_data[irq].shift = pos*4; /* POSition (0-3) x 4 means shift */ 115 ipr_data[irq].shift = pos*4; /* POSition (0-3) x 4 means shift */
116 ipr_data[irq].priority = priority; 116 ipr_data[irq].priority = priority;
117 117
118 irq_desc[irq].handler = &ipr_irq_type; 118 irq_desc[irq].chip = &ipr_irq_type;
119 disable_ipr_irq(irq); 119 disable_ipr_irq(irq);
120} 120}
121 121
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 95d6024fe1ae..714963a25bba 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -85,7 +85,7 @@ static void end_pint_irq(unsigned int irq)
85void make_pint_irq(unsigned int irq) 85void make_pint_irq(unsigned int irq)
86{ 86{
87 disable_irq_nosync(irq); 87 disable_irq_nosync(irq);
88 irq_desc[irq].handler = &pint_irq_type; 88 irq_desc[irq].chip = &pint_irq_type;
89 disable_pint_irq(irq); 89 disable_pint_irq(irq);
90} 90}
91 91
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index 8437ea7430fe..83a4f91bce5a 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -417,7 +417,6 @@ static struct file_operations sq_fops = {
417static struct miscdevice sq_dev = { 417static struct miscdevice sq_dev = {
418 .minor = STORE_QUEUE_MINOR, 418 .minor = STORE_QUEUE_MINOR,
419 .name = "sq", 419 .name = "sq",
420 .devfs_name = "cpu/sq",
421 .fops = &sq_fops, 420 .fops = &sq_fops,
422}; 421};
423 422
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index b56e79632f24..c2e07f7f3496 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -47,7 +47,7 @@ int show_interrupts(struct seq_file *p, void *v)
47 goto unlock; 47 goto unlock;
48 seq_printf(p, "%3d: ",i); 48 seq_printf(p, "%3d: ",i);
49 seq_printf(p, "%10u ", kstat_irqs(i)); 49 seq_printf(p, "%10u ", kstat_irqs(i));
50 seq_printf(p, " %14s", irq_desc[i].handler->typename); 50 seq_printf(p, " %14s", irq_desc[i].chip->typename);
51 seq_printf(p, " %s", action->name); 51 seq_printf(p, " %s", action->name);
52 52
53 for (action=action->next; action; action = action->next) 53 for (action=action->next; action; action = action->next)
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index bb229ef030f3..9af22116c9a2 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -402,7 +402,7 @@ static int __init topology_init(void)
402 int cpu_id; 402 int cpu_id;
403 403
404 for_each_possible_cpu(cpu_id) 404 for_each_possible_cpu(cpu_id)
405 register_cpu(&cpu[cpu_id], cpu_id, NULL); 405 register_cpu(&cpu[cpu_id], cpu_id);
406 406
407 return 0; 407 return 0;
408} 408}
diff --git a/arch/sh64/kernel/irq.c b/arch/sh64/kernel/irq.c
index d69879c0e063..675776a5477e 100644
--- a/arch/sh64/kernel/irq.c
+++ b/arch/sh64/kernel/irq.c
@@ -65,7 +65,7 @@ int show_interrupts(struct seq_file *p, void *v)
65 goto unlock; 65 goto unlock;
66 seq_printf(p, "%3d: ",i); 66 seq_printf(p, "%3d: ",i);
67 seq_printf(p, "%10u ", kstat_irqs(i)); 67 seq_printf(p, "%10u ", kstat_irqs(i));
68 seq_printf(p, " %14s", irq_desc[i].handler->typename); 68 seq_printf(p, " %14s", irq_desc[i].chip->typename);
69 seq_printf(p, " %s", action->name); 69 seq_printf(p, " %s", action->name);
70 70
71 for (action=action->next; action; action = action->next) 71 for (action=action->next; action; action = action->next)
diff --git a/arch/sh64/kernel/irq_intc.c b/arch/sh64/kernel/irq_intc.c
index fc99bf4e362c..fa730f5fe2e6 100644
--- a/arch/sh64/kernel/irq_intc.c
+++ b/arch/sh64/kernel/irq_intc.c
@@ -178,7 +178,7 @@ static void end_intc_irq(unsigned int irq)
178void make_intc_irq(unsigned int irq) 178void make_intc_irq(unsigned int irq)
179{ 179{
180 disable_irq_nosync(irq); 180 disable_irq_nosync(irq);
181 irq_desc[irq].handler = &intc_irq_type; 181 irq_desc[irq].chip = &intc_irq_type;
182 disable_intc_irq(irq); 182 disable_intc_irq(irq);
183} 183}
184 184
@@ -208,7 +208,7 @@ void __init init_IRQ(void)
208 /* Set default: per-line enable/disable, priority driven ack/eoi */ 208 /* Set default: per-line enable/disable, priority driven ack/eoi */
209 for (i = 0; i < NR_INTC_IRQS; i++) { 209 for (i = 0; i < NR_INTC_IRQS; i++) {
210 if (platform_int_priority[i] != NO_PRIORITY) { 210 if (platform_int_priority[i] != NO_PRIORITY) {
211 irq_desc[i].handler = &intc_irq_type; 211 irq_desc[i].chip = &intc_irq_type;
212 } 212 }
213 } 213 }
214 214
diff --git a/arch/sh64/kernel/pcibios.c b/arch/sh64/kernel/pcibios.c
index 50c61dcb9fae..945920bc24db 100644
--- a/arch/sh64/kernel/pcibios.c
+++ b/arch/sh64/kernel/pcibios.c
@@ -69,10 +69,10 @@ pcibios_update_resource(struct pci_dev *dev, struct resource *root,
69 * modulo 0x400. 69 * modulo 0x400.
70 */ 70 */
71void pcibios_align_resource(void *data, struct resource *res, 71void pcibios_align_resource(void *data, struct resource *res,
72 unsigned long size, unsigned long align) 72 resource_size_t size, resource_size_t align)
73{ 73{
74 if (res->flags & IORESOURCE_IO) { 74 if (res->flags & IORESOURCE_IO) {
75 unsigned long start = res->start; 75 resource_size_t start = res->start;
76 76
77 if (start & 0x300) { 77 if (start & 0x300) {
78 start = (start + 0x3ff) & ~0x3ff; 78 start = (start + 0x3ff) & ~0x3ff;
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
index d2711c9c9d13..da98d8dbcf95 100644
--- a/arch/sh64/kernel/setup.c
+++ b/arch/sh64/kernel/setup.c
@@ -309,7 +309,7 @@ static struct cpu cpu[1];
309 309
310static int __init topology_init(void) 310static int __init topology_init(void)
311{ 311{
312 return register_cpu(cpu, 0, NULL); 312 return register_cpu(cpu, 0);
313} 313}
314 314
315subsys_initcall(topology_init); 315subsys_initcall(topology_init);
diff --git a/arch/sh64/mach-cayman/irq.c b/arch/sh64/mach-cayman/irq.c
index f797c84bfdd1..05eb7cdc26f0 100644
--- a/arch/sh64/mach-cayman/irq.c
+++ b/arch/sh64/mach-cayman/irq.c
@@ -187,7 +187,7 @@ void init_cayman_irq(void)
187 } 187 }
188 188
189 for (i=0; i<NR_EXT_IRQS; i++) { 189 for (i=0; i<NR_EXT_IRQS; i++) {
190 irq_desc[START_EXT_IRQS + i].handler = &cayman_irq_type; 190 irq_desc[START_EXT_IRQS + i].chip = &cayman_irq_type;
191 } 191 }
192 192
193 /* Setup the SMSC interrupt */ 193 /* Setup the SMSC interrupt */
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index ae4c667c906f..79d177149fdb 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -208,7 +208,7 @@ _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz)
208 pa &= PAGE_MASK; 208 pa &= PAGE_MASK;
209 sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1); 209 sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1);
210 210
211 return (void __iomem *) (res->start + offset); 211 return (void __iomem *)(unsigned long)(res->start + offset);
212} 212}
213 213
214/* 214/*
@@ -325,7 +325,7 @@ void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp)
325 res->name = sdev->prom_name; 325 res->name = sdev->prom_name;
326 } 326 }
327 327
328 return (void *)res->start; 328 return (void *)(unsigned long)res->start;
329 329
330err_noiommu: 330err_noiommu:
331 release_resource(res); 331 release_resource(res);
@@ -819,7 +819,9 @@ _sparc_io_get_info(char *buf, char **start, off_t fpos, int length, int *eof,
819 if (p + 32 >= e) /* Better than nothing */ 819 if (p + 32 >= e) /* Better than nothing */
820 break; 820 break;
821 if ((nm = r->name) == 0) nm = "???"; 821 if ((nm = r->name) == 0) nm = "???";
822 p += sprintf(p, "%08lx-%08lx: %s\n", r->start, r->end, nm); 822 p += sprintf(p, "%016llx-%016llx: %s\n",
823 (unsigned long long)r->start,
824 (unsigned long long)r->end, nm);
823 } 825 }
824 826
825 return p-buf; 827 return p-buf;
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index bcfdddd0418a..5df3ebdc0ab1 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -860,7 +860,7 @@ char * __init pcibios_setup(char *str)
860} 860}
861 861
862void pcibios_align_resource(void *data, struct resource *res, 862void pcibios_align_resource(void *data, struct resource *res,
863 unsigned long size, unsigned long align) 863 resource_size_t size, resource_size_t align)
864{ 864{
865} 865}
866 866
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index a893a9cc9534..2e5d08ce217b 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -496,7 +496,7 @@ static int __init topology_init(void)
496 if (!p) 496 if (!p)
497 err = -ENOMEM; 497 err = -ENOMEM;
498 else 498 else
499 register_cpu(p, i, NULL); 499 register_cpu(p, i);
500 } 500 }
501 501
502 return err; 502 return err;
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index cc89b06d0178..ab9e640df228 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -151,7 +151,7 @@ int show_interrupts(struct seq_file *p, void *v)
151 for_each_online_cpu(j) 151 for_each_online_cpu(j)
152 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 152 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
153#endif 153#endif
154 seq_printf(p, " %9s", irq_desc[i].handler->typename); 154 seq_printf(p, " %9s", irq_desc[i].chip->typename);
155 seq_printf(p, " %s", action->name); 155 seq_printf(p, " %s", action->name);
156 156
157 for (action=action->next; action; action = action->next) 157 for (action=action->next; action; action = action->next)
@@ -224,7 +224,7 @@ static inline struct ino_bucket *virt_irq_to_bucket(unsigned int virt_irq)
224#ifdef CONFIG_SMP 224#ifdef CONFIG_SMP
225static int irq_choose_cpu(unsigned int virt_irq) 225static int irq_choose_cpu(unsigned int virt_irq)
226{ 226{
227 cpumask_t mask = irq_affinity[virt_irq]; 227 cpumask_t mask = irq_desc[virt_irq].affinity;
228 int cpuid; 228 int cpuid;
229 229
230 if (cpus_equal(mask, CPU_MASK_ALL)) { 230 if (cpus_equal(mask, CPU_MASK_ALL)) {
@@ -414,8 +414,8 @@ void irq_install_pre_handler(int virt_irq,
414 data->pre_handler_arg1 = arg1; 414 data->pre_handler_arg1 = arg1;
415 data->pre_handler_arg2 = arg2; 415 data->pre_handler_arg2 = arg2;
416 416
417 desc->handler = (desc->handler == &sun4u_irq ? 417 desc->chip = (desc->chip == &sun4u_irq ?
418 &sun4u_irq_ack : &sun4v_irq_ack); 418 &sun4u_irq_ack : &sun4v_irq_ack);
419} 419}
420 420
421unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap) 421unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap)
@@ -431,7 +431,7 @@ unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap)
431 bucket = &ivector_table[ino]; 431 bucket = &ivector_table[ino];
432 if (!bucket->virt_irq) { 432 if (!bucket->virt_irq) {
433 bucket->virt_irq = virt_irq_alloc(__irq(bucket)); 433 bucket->virt_irq = virt_irq_alloc(__irq(bucket));
434 irq_desc[bucket->virt_irq].handler = &sun4u_irq; 434 irq_desc[bucket->virt_irq].chip = &sun4u_irq;
435 } 435 }
436 436
437 desc = irq_desc + bucket->virt_irq; 437 desc = irq_desc + bucket->virt_irq;
@@ -465,7 +465,7 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino)
465 bucket = &ivector_table[sysino]; 465 bucket = &ivector_table[sysino];
466 if (!bucket->virt_irq) { 466 if (!bucket->virt_irq) {
467 bucket->virt_irq = virt_irq_alloc(__irq(bucket)); 467 bucket->virt_irq = virt_irq_alloc(__irq(bucket));
468 irq_desc[bucket->virt_irq].handler = &sun4v_irq; 468 irq_desc[bucket->virt_irq].chip = &sun4v_irq;
469 } 469 }
470 470
471 desc = irq_desc + bucket->virt_irq; 471 desc = irq_desc + bucket->virt_irq;
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 6c9e3e94abaa..20ca9ec8fd3b 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -357,7 +357,7 @@ void pcibios_update_irq(struct pci_dev *pdev, int irq)
357} 357}
358 358
359void pcibios_align_resource(void *data, struct resource *res, 359void pcibios_align_resource(void *data, struct resource *res,
360 unsigned long size, unsigned long align) 360 resource_size_t size, resource_size_t align)
361{ 361{
362} 362}
363 363
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index a6a7d8168346..116d9632002d 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -537,7 +537,7 @@ static int __init topology_init(void)
537 for_each_possible_cpu(i) { 537 for_each_possible_cpu(i) {
538 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); 538 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
539 if (p) { 539 if (p) {
540 register_cpu(p, i, NULL); 540 register_cpu(p, i);
541 err = 0; 541 err = 0;
542 } 542 }
543 } 543 }
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 5c2bcf354ce6..cb75a27adb51 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -18,6 +18,7 @@
18#include <linux/initrd.h> 18#include <linux/initrd.h>
19#include <linux/swap.h> 19#include <linux/swap.h>
20#include <linux/pagemap.h> 20#include <linux/pagemap.h>
21#include <linux/poison.h>
21#include <linux/fs.h> 22#include <linux/fs.h>
22#include <linux/seq_file.h> 23#include <linux/seq_file.h>
23#include <linux/kprobes.h> 24#include <linux/kprobes.h>
@@ -1520,7 +1521,7 @@ void free_initmem(void)
1520 page = (addr + 1521 page = (addr +
1521 ((unsigned long) __va(kern_base)) - 1522 ((unsigned long) __va(kern_base)) -
1522 ((unsigned long) KERNBASE)); 1523 ((unsigned long) KERNBASE));
1523 memset((void *)addr, 0xcc, PAGE_SIZE); 1524 memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
1524 p = virt_to_page(page); 1525 p = virt_to_page(page);
1525 1526
1526 ClearPageReserved(p); 1527 ClearPageReserved(p);
diff --git a/arch/sparc64/solaris/socksys.c b/arch/sparc64/solaris/socksys.c
index fc6669e8dde1..bc3df95bc057 100644
--- a/arch/sparc64/solaris/socksys.c
+++ b/arch/sparc64/solaris/socksys.c
@@ -26,7 +26,6 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/syscalls.h> 27#include <linux/syscalls.h>
28#include <linux/in.h> 28#include <linux/in.h>
29#include <linux/devfs_fs_kernel.h>
30 29
31#include <net/sock.h> 30#include <net/sock.h>
32 31
@@ -190,8 +189,6 @@ init_socksys(void)
190 return ret; 189 return ret;
191 } 190 }
192 191
193 devfs_mk_cdev(MKDEV(30, 0), S_IFCHR|S_IRUSR|S_IWUSR, "socksys");
194
195 file = fcheck(ret); 192 file = fcheck(ret);
196 /* N.B. Is this valid? Suppose the f_ops are in a module ... */ 193 /* N.B. Is this valid? Suppose the f_ops are in a module ... */
197 socksys_file_ops = *file->f_op; 194 socksys_file_ops = *file->f_op;
@@ -207,5 +204,4 @@ cleanup_socksys(void)
207{ 204{
208 if (unregister_chrdev(30, "socksys")) 205 if (unregister_chrdev(30, "socksys"))
209 printk ("Couldn't unregister socksys character device\n"); 206 printk ("Couldn't unregister socksys character device\n");
210 devfs_remove ("socksys");
211} 207}
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 6c2d4ccaf20f..5ca57ca33713 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -8,7 +8,6 @@
8#include "linux/list.h" 8#include "linux/list.h"
9#include "linux/kd.h" 9#include "linux/kd.h"
10#include "linux/interrupt.h" 10#include "linux/interrupt.h"
11#include "linux/devfs_fs_kernel.h"
12#include "asm/uaccess.h" 11#include "asm/uaccess.h"
13#include "chan_kern.h" 12#include "chan_kern.h"
14#include "irq_user.h" 13#include "irq_user.h"
@@ -655,7 +654,6 @@ struct tty_driver *line_register_devfs(struct lines *set,
655 654
656 driver->driver_name = line_driver->name; 655 driver->driver_name = line_driver->name;
657 driver->name = line_driver->device_name; 656 driver->name = line_driver->device_name;
658 driver->devfs_name = line_driver->devfs_name;
659 driver->major = line_driver->major; 657 driver->major = line_driver->major;
660 driver->minor_start = line_driver->minor_start; 658 driver->minor_start = line_driver->minor_start;
661 driver->type = line_driver->type; 659 driver->type = line_driver->type;
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index a4d6415bc8c4..6dafd6fbfdae 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -54,7 +54,6 @@ static int ssl_remove(int n);
54static struct line_driver driver = { 54static struct line_driver driver = {
55 .name = "UML serial line", 55 .name = "UML serial line",
56 .device_name = "ttyS", 56 .device_name = "ttyS",
57 .devfs_name = "tts/",
58 .major = TTY_MAJOR, 57 .major = TTY_MAJOR,
59 .minor_start = 64, 58 .minor_start = 64,
60 .type = TTY_DRIVER_TYPE_SERIAL, 59 .type = TTY_DRIVER_TYPE_SERIAL,
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 61db8b2fc83f..856f568c2687 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -60,7 +60,6 @@ static int con_remove(int n);
60static struct line_driver driver = { 60static struct line_driver driver = {
61 .name = "UML console", 61 .name = "UML console",
62 .device_name = "tty", 62 .device_name = "tty",
63 .devfs_name = "vc/",
64 .major = TTY_MAJOR, 63 .major = TTY_MAJOR,
65 .minor_start = 0, 64 .minor_start = 0,
66 .type = TTY_DRIVER_TYPE_CONSOLE, 65 .type = TTY_DRIVER_TYPE_CONSOLE,
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 290cec6d69e2..0345e2551247 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -25,7 +25,6 @@
25#include "linux/blkdev.h" 25#include "linux/blkdev.h"
26#include "linux/hdreg.h" 26#include "linux/hdreg.h"
27#include "linux/init.h" 27#include "linux/init.h"
28#include "linux/devfs_fs_kernel.h"
29#include "linux/cdrom.h" 28#include "linux/cdrom.h"
30#include "linux/proc_fs.h" 29#include "linux/proc_fs.h"
31#include "linux/ctype.h" 30#include "linux/ctype.h"
@@ -628,7 +627,6 @@ static int ubd_new_disk(int major, u64 size, int unit,
628 627
629{ 628{
630 struct gendisk *disk; 629 struct gendisk *disk;
631 char from[sizeof("ubd/nnnnn\0")], to[sizeof("discnnnnn/disc\0")];
632 int err; 630 int err;
633 631
634 disk = alloc_disk(1 << UBD_SHIFT); 632 disk = alloc_disk(1 << UBD_SHIFT);
@@ -639,20 +637,10 @@ static int ubd_new_disk(int major, u64 size, int unit,
639 disk->first_minor = unit << UBD_SHIFT; 637 disk->first_minor = unit << UBD_SHIFT;
640 disk->fops = &ubd_blops; 638 disk->fops = &ubd_blops;
641 set_capacity(disk, size / 512); 639 set_capacity(disk, size / 512);
642 if(major == MAJOR_NR){ 640 if(major == MAJOR_NR)
643 sprintf(disk->disk_name, "ubd%c", 'a' + unit); 641 sprintf(disk->disk_name, "ubd%c", 'a' + unit);
644 sprintf(disk->devfs_name, "ubd/disc%d", unit); 642 else
645 sprintf(from, "ubd/%d", unit);
646 sprintf(to, "disc%d/disc", unit);
647 err = devfs_mk_symlink(from, to);
648 if(err)
649 printk("ubd_new_disk failed to make link from %s to "
650 "%s, error = %d\n", from, to, err);
651 }
652 else {
653 sprintf(disk->disk_name, "ubd_fake%d", unit); 643 sprintf(disk->disk_name, "ubd_fake%d", unit);
654 sprintf(disk->devfs_name, "ubd_fake/disc%d", unit);
655 }
656 644
657 /* sysfs register (not for ide fake devices) */ 645 /* sysfs register (not for ide fake devices) */
658 if (major == MAJOR_NR) { 646 if (major == MAJOR_NR) {
@@ -841,7 +829,6 @@ int ubd_init(void)
841{ 829{
842 int i; 830 int i;
843 831
844 devfs_mk_dir("ubd");
845 if (register_blkdev(MAJOR_NR, "ubd")) 832 if (register_blkdev(MAJOR_NR, "ubd"))
846 return -1; 833 return -1;
847 834
@@ -855,7 +842,6 @@ int ubd_init(void)
855 char name[sizeof("ubd_nnn\0")]; 842 char name[sizeof("ubd_nnn\0")];
856 843
857 snprintf(name, sizeof(name), "ubd_%d", fake_major); 844 snprintf(name, sizeof(name), "ubd_%d", fake_major);
858 devfs_mk_dir(name);
859 if (register_blkdev(fake_major, "ubd")) 845 if (register_blkdev(fake_major, "ubd"))
860 return -1; 846 return -1;
861 } 847 }
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 6ac0f8252e21..27bf2f6fbc05 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -17,7 +17,6 @@
17struct line_driver { 17struct line_driver {
18 char *name; 18 char *name;
19 char *device_name; 19 char *device_name;
20 char *devfs_name;
21 short major; 20 short major;
22 short minor_start; 21 short minor_start;
23 short type; 22 short type;
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 2ffda012385e..fae43a3054a0 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -63,7 +63,7 @@ int show_interrupts(struct seq_file *p, void *v)
63 for_each_online_cpu(j) 63 for_each_online_cpu(j)
64 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 64 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
65#endif 65#endif
66 seq_printf(p, " %14s", irq_desc[i].handler->typename); 66 seq_printf(p, " %14s", irq_desc[i].chip->typename);
67 seq_printf(p, " %s", action->name); 67 seq_printf(p, " %s", action->name);
68 68
69 for (action=action->next; action; action = action->next) 69 for (action=action->next; action; action = action->next)
@@ -451,13 +451,13 @@ void __init init_IRQ(void)
451 irq_desc[TIMER_IRQ].status = IRQ_DISABLED; 451 irq_desc[TIMER_IRQ].status = IRQ_DISABLED;
452 irq_desc[TIMER_IRQ].action = NULL; 452 irq_desc[TIMER_IRQ].action = NULL;
453 irq_desc[TIMER_IRQ].depth = 1; 453 irq_desc[TIMER_IRQ].depth = 1;
454 irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type; 454 irq_desc[TIMER_IRQ].chip = &SIGVTALRM_irq_type;
455 enable_irq(TIMER_IRQ); 455 enable_irq(TIMER_IRQ);
456 for (i = 1; i < NR_IRQS; i++) { 456 for (i = 1; i < NR_IRQS; i++) {
457 irq_desc[i].status = IRQ_DISABLED; 457 irq_desc[i].status = IRQ_DISABLED;
458 irq_desc[i].action = NULL; 458 irq_desc[i].action = NULL;
459 irq_desc[i].depth = 1; 459 irq_desc[i].depth = 1;
460 irq_desc[i].handler = &normal_irq_type; 460 irq_desc[i].chip = &normal_irq_type;
461 enable_irq(i); 461 enable_irq(i);
462 } 462 }
463} 463}
diff --git a/arch/v850/kernel/irq.c b/arch/v850/kernel/irq.c
index 7a151c26f82e..858c45819aab 100644
--- a/arch/v850/kernel/irq.c
+++ b/arch/v850/kernel/irq.c
@@ -65,10 +65,10 @@ int show_interrupts(struct seq_file *p, void *v)
65 int j; 65 int j;
66 int count = 0; 66 int count = 0;
67 int num = -1; 67 int num = -1;
68 const char *type_name = irq_desc[irq].handler->typename; 68 const char *type_name = irq_desc[irq].chip->typename;
69 69
70 for (j = 0; j < NR_IRQS; j++) 70 for (j = 0; j < NR_IRQS; j++)
71 if (irq_desc[j].handler->typename == type_name){ 71 if (irq_desc[j].chip->typename == type_name){
72 if (irq == j) 72 if (irq == j)
73 num = count; 73 num = count;
74 count++; 74 count++;
@@ -117,7 +117,7 @@ init_irq_handlers (int base_irq, int num, int interval,
117 irq_desc[base_irq].status = IRQ_DISABLED; 117 irq_desc[base_irq].status = IRQ_DISABLED;
118 irq_desc[base_irq].action = NULL; 118 irq_desc[base_irq].action = NULL;
119 irq_desc[base_irq].depth = 1; 119 irq_desc[base_irq].depth = 1;
120 irq_desc[base_irq].handler = irq_type; 120 irq_desc[base_irq].chip = irq_type;
121 base_irq += interval; 121 base_irq += interval;
122 } 122 }
123} 123}
diff --git a/arch/v850/kernel/rte_mb_a_pci.c b/arch/v850/kernel/rte_mb_a_pci.c
index ffbb6d073bf2..3a7c5c9c3ac6 100644
--- a/arch/v850/kernel/rte_mb_a_pci.c
+++ b/arch/v850/kernel/rte_mb_a_pci.c
@@ -329,7 +329,7 @@ void pcibios_fixup_bus(struct pci_bus *b)
329 329
330void 330void
331pcibios_align_resource (void *data, struct resource *res, 331pcibios_align_resource (void *data, struct resource *res,
332 unsigned long size, unsigned long align) 332 resource_size_t size, resource_size_t align)
333{ 333{
334} 334}
335 335
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index ccc4a7fb97a3..e856804c447f 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -370,6 +370,8 @@ config HOTPLUG_CPU
370 can be controlled through /sys/devices/system/cpu/cpu#. 370 can be controlled through /sys/devices/system/cpu/cpu#.
371 Say N if you want to disable CPU hotplug. 371 Say N if you want to disable CPU hotplug.
372 372
373config ARCH_ENABLE_MEMORY_HOTPLUG
374 def_bool y
373 375
374config HPET_TIMER 376config HPET_TIMER
375 bool 377 bool
@@ -459,10 +461,10 @@ config KEXEC
459 help 461 help
460 kexec is a system call that implements the ability to shutdown your 462 kexec is a system call that implements the ability to shutdown your
461 current kernel, and to start another kernel. It is like a reboot 463 current kernel, and to start another kernel. It is like a reboot
462 but it is indepedent of the system firmware. And like a reboot 464 but it is independent of the system firmware. And like a reboot
463 you can start any kernel with it, not just Linux. 465 you can start any kernel with it, not just Linux.
464 466
465 The name comes from the similiarity to the exec system call. 467 The name comes from the similarity to the exec system call.
466 468
467 It is an ongoing process to be certain the hardware in a machine 469 It is an ongoing process to be certain the hardware in a machine
468 is properly shutdown, so do not be surprised if this code does not 470 is properly shutdown, so do not be surprised if this code does not
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 7290e72b9a34..22cac4487b57 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -588,7 +588,7 @@ END(common_interrupt)
588 */ 588 */
589 .macro apicinterrupt num,func 589 .macro apicinterrupt num,func
590 INTR_FRAME 590 INTR_FRAME
591 pushq $\num-256 591 pushq $~(\num)
592 CFI_ADJUST_CFA_OFFSET 8 592 CFI_ADJUST_CFA_OFFSET 8
593 interrupt \func 593 interrupt \func
594 jmp ret_from_intr 594 jmp ret_from_intr
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 86b2c1e197aa..3dd1659427dc 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -235,7 +235,7 @@ void make_8259A_irq(unsigned int irq)
235{ 235{
236 disable_irq_nosync(irq); 236 disable_irq_nosync(irq);
237 io_apic_irqs &= ~(1<<irq); 237 io_apic_irqs &= ~(1<<irq);
238 irq_desc[irq].handler = &i8259A_irq_type; 238 irq_desc[irq].chip = &i8259A_irq_type;
239 enable_irq(irq); 239 enable_irq(irq);
240} 240}
241 241
@@ -468,12 +468,12 @@ void __init init_ISA_irqs (void)
468 /* 468 /*
469 * 16 old-style INTA-cycle interrupts: 469 * 16 old-style INTA-cycle interrupts:
470 */ 470 */
471 irq_desc[i].handler = &i8259A_irq_type; 471 irq_desc[i].chip = &i8259A_irq_type;
472 } else { 472 } else {
473 /* 473 /*
474 * 'high' PCI IRQs filled in on demand 474 * 'high' PCI IRQs filled in on demand
475 */ 475 */
476 irq_desc[i].handler = &no_irq_type; 476 irq_desc[i].chip = &no_irq_type;
477 } 477 }
478 } 478 }
479} 479}
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index c768d8a036d0..401b687fef21 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -876,15 +876,17 @@ static struct hw_interrupt_type ioapic_edge_type;
876#define IOAPIC_EDGE 0 876#define IOAPIC_EDGE 0
877#define IOAPIC_LEVEL 1 877#define IOAPIC_LEVEL 1
878 878
879static inline void ioapic_register_intr(int irq, int vector, unsigned long trigger) 879static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
880{ 880{
881 unsigned idx = use_pci_vector() && !platform_legacy_irq(irq) ? vector : irq; 881 unsigned idx;
882
883 idx = use_pci_vector() && !platform_legacy_irq(irq) ? vector : irq;
882 884
883 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || 885 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
884 trigger == IOAPIC_LEVEL) 886 trigger == IOAPIC_LEVEL)
885 irq_desc[idx].handler = &ioapic_level_type; 887 irq_desc[idx].chip = &ioapic_level_type;
886 else 888 else
887 irq_desc[idx].handler = &ioapic_edge_type; 889 irq_desc[idx].chip = &ioapic_edge_type;
888 set_intr_gate(vector, interrupt[idx]); 890 set_intr_gate(vector, interrupt[idx]);
889} 891}
890 892
@@ -986,7 +988,7 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, in
986 * The timer IRQ doesn't have to know that behind the 988 * The timer IRQ doesn't have to know that behind the
987 * scene we have a 8259A-master in AEOI mode ... 989 * scene we have a 8259A-master in AEOI mode ...
988 */ 990 */
989 irq_desc[0].handler = &ioapic_edge_type; 991 irq_desc[0].chip = &ioapic_edge_type;
990 992
991 /* 993 /*
992 * Add it to the IO-APIC irq-routing table: 994 * Add it to the IO-APIC irq-routing table:
@@ -1616,6 +1618,13 @@ static void set_ioapic_affinity_vector (unsigned int vector,
1616#endif // CONFIG_SMP 1618#endif // CONFIG_SMP
1617#endif // CONFIG_PCI_MSI 1619#endif // CONFIG_PCI_MSI
1618 1620
1621static int ioapic_retrigger(unsigned int irq)
1622{
1623 send_IPI_self(IO_APIC_VECTOR(irq));
1624
1625 return 1;
1626}
1627
1619/* 1628/*
1620 * Level and edge triggered IO-APIC interrupts need different handling, 1629 * Level and edge triggered IO-APIC interrupts need different handling,
1621 * so we use two separate IRQ descriptors. Edge triggered IRQs can be 1630 * so we use two separate IRQ descriptors. Edge triggered IRQs can be
@@ -1636,6 +1645,7 @@ static struct hw_interrupt_type ioapic_edge_type __read_mostly = {
1636#ifdef CONFIG_SMP 1645#ifdef CONFIG_SMP
1637 .set_affinity = set_ioapic_affinity, 1646 .set_affinity = set_ioapic_affinity,
1638#endif 1647#endif
1648 .retrigger = ioapic_retrigger,
1639}; 1649};
1640 1650
1641static struct hw_interrupt_type ioapic_level_type __read_mostly = { 1651static struct hw_interrupt_type ioapic_level_type __read_mostly = {
@@ -1649,6 +1659,7 @@ static struct hw_interrupt_type ioapic_level_type __read_mostly = {
1649#ifdef CONFIG_SMP 1659#ifdef CONFIG_SMP
1650 .set_affinity = set_ioapic_affinity, 1660 .set_affinity = set_ioapic_affinity,
1651#endif 1661#endif
1662 .retrigger = ioapic_retrigger,
1652}; 1663};
1653 1664
1654static inline void init_IO_APIC_traps(void) 1665static inline void init_IO_APIC_traps(void)
@@ -1683,7 +1694,7 @@ static inline void init_IO_APIC_traps(void)
1683 make_8259A_irq(irq); 1694 make_8259A_irq(irq);
1684 else 1695 else
1685 /* Strange. Oh, well.. */ 1696 /* Strange. Oh, well.. */
1686 irq_desc[irq].handler = &no_irq_type; 1697 irq_desc[irq].chip = &no_irq_type;
1687 } 1698 }
1688 } 1699 }
1689} 1700}
@@ -1900,7 +1911,7 @@ static inline void check_timer(void)
1900 apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as Virtual Wire IRQ..."); 1911 apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
1901 1912
1902 disable_8259A_irq(0); 1913 disable_8259A_irq(0);
1903 irq_desc[0].handler = &lapic_irq_type; 1914 irq_desc[0].chip = &lapic_irq_type;
1904 apic_write(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */ 1915 apic_write(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */
1905 enable_8259A_irq(0); 1916 enable_8259A_irq(0);
1906 1917
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index 59518d4d4358..a1f1df5f7bfc 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -79,7 +79,7 @@ int show_interrupts(struct seq_file *p, void *v)
79 for_each_online_cpu(j) 79 for_each_online_cpu(j)
80 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 80 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
81#endif 81#endif
82 seq_printf(p, " %14s", irq_desc[i].handler->typename); 82 seq_printf(p, " %14s", irq_desc[i].chip->typename);
83 83
84 seq_printf(p, " %s", action->name); 84 seq_printf(p, " %s", action->name);
85 for (action=action->next; action; action = action->next) 85 for (action=action->next; action; action = action->next)
@@ -115,8 +115,14 @@ skip:
115 */ 115 */
116asmlinkage unsigned int do_IRQ(struct pt_regs *regs) 116asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
117{ 117{
118 /* high bits used in ret_from_ code */ 118 /* high bit used in ret_from_ code */
119 unsigned irq = regs->orig_rax & 0xff; 119 unsigned irq = ~regs->orig_rax;
120
121 if (unlikely(irq >= NR_IRQS)) {
122 printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
123 __FUNCTION__, irq);
124 BUG();
125 }
120 126
121 exit_idle(); 127 exit_idle();
122 irq_enter(); 128 irq_enter();
@@ -140,13 +146,13 @@ void fixup_irqs(cpumask_t map)
140 if (irq == 2) 146 if (irq == 2)
141 continue; 147 continue;
142 148
143 cpus_and(mask, irq_affinity[irq], map); 149 cpus_and(mask, irq_desc[irq].affinity, map);
144 if (any_online_cpu(mask) == NR_CPUS) { 150 if (any_online_cpu(mask) == NR_CPUS) {
145 printk("Breaking affinity for irq %i\n", irq); 151 printk("Breaking affinity for irq %i\n", irq);
146 mask = map; 152 mask = map;
147 } 153 }
148 if (irq_desc[irq].handler->set_affinity) 154 if (irq_desc[irq].chip->set_affinity)
149 irq_desc[irq].handler->set_affinity(irq, mask); 155 irq_desc[irq].chip->set_affinity(irq, mask);
150 else if (irq_desc[irq].action && !(warned++)) 156 else if (irq_desc[irq].action && !(warned++))
151 printk("Cannot set affinity for irq %i\n", irq); 157 printk("Cannot set affinity for irq %i\n", irq);
152 } 158 }
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index acd5816b1a6f..88845674c661 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -629,7 +629,7 @@ static __cpuinit void mce_remove_device(unsigned int cpu)
629#endif 629#endif
630 630
631/* Get notified when a cpu comes on/off. Be hotplug friendly. */ 631/* Get notified when a cpu comes on/off. Be hotplug friendly. */
632static int 632static __cpuinit int
633mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 633mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
634{ 634{
635 unsigned int cpu = (unsigned long)hcpu; 635 unsigned int cpu = (unsigned long)hcpu;
@@ -647,7 +647,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
647 return NOTIFY_OK; 647 return NOTIFY_OK;
648} 648}
649 649
650static struct notifier_block mce_cpu_notifier = { 650static struct notifier_block __cpuinitdata mce_cpu_notifier = {
651 .notifier_call = mce_cpu_callback, 651 .notifier_call = mce_cpu_callback,
652}; 652};
653 653
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 399489c93132..0ef9cf2bc45e 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -607,11 +607,13 @@ void set_nmi_callback(nmi_callback_t callback)
607 vmalloc_sync_all(); 607 vmalloc_sync_all();
608 rcu_assign_pointer(nmi_callback, callback); 608 rcu_assign_pointer(nmi_callback, callback);
609} 609}
610EXPORT_SYMBOL_GPL(set_nmi_callback);
610 611
611void unset_nmi_callback(void) 612void unset_nmi_callback(void)
612{ 613{
613 nmi_callback = dummy_nmi_callback; 614 nmi_callback = dummy_nmi_callback;
614} 615}
616EXPORT_SYMBOL_GPL(unset_nmi_callback);
615 617
616#ifdef CONFIG_SYSCTL 618#ifdef CONFIG_SYSCTL
617 619
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index acee4bc3f6fa..5a1c0a3bf872 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -135,10 +135,10 @@ asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs)
135 135
136 cpu = smp_processor_id(); 136 cpu = smp_processor_id();
137 /* 137 /*
138 * orig_rax contains the interrupt vector - 256. 138 * orig_rax contains the negated interrupt vector.
139 * Use that to determine where the sender put the data. 139 * Use that to determine where the sender put the data.
140 */ 140 */
141 sender = regs->orig_rax + 256 - INVALIDATE_TLB_VECTOR_START; 141 sender = ~regs->orig_rax - INVALIDATE_TLB_VECTOR_START;
142 f = &per_cpu(flush_state, sender); 142 f = &per_cpu(flush_state, sender);
143 143
144 if (!cpu_isset(cpu, f->flush_cpumask)) 144 if (!cpu_isset(cpu, f->flush_cpumask))
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 4e9755179ecf..540c0ccbcccc 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -455,10 +455,12 @@ cpumask_t cpu_coregroup_map(int cpu)
455 struct cpuinfo_x86 *c = cpu_data + cpu; 455 struct cpuinfo_x86 *c = cpu_data + cpu;
456 /* 456 /*
457 * For perf, we return last level cache shared map. 457 * For perf, we return last level cache shared map.
458 * TBD: when power saving sched policy is added, we will return 458 * And for power savings, we return cpu_core_map
459 * cpu_core_map when power saving policy is enabled
460 */ 459 */
461 return c->llc_shared_map; 460 if (sched_mc_power_savings || sched_smt_power_savings)
461 return cpu_core_map[cpu];
462 else
463 return c->llc_shared_map;
462} 464}
463 465
464/* representing cpus for which sibling maps can be computed */ 466/* representing cpus for which sibling maps can be computed */
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 02add1d1dfa8..95bd232ff0cf 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -23,6 +23,7 @@
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/poison.h>
26#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
27#include <linux/module.h> 28#include <linux/module.h>
28#include <linux/memory_hotplug.h> 29#include <linux/memory_hotplug.h>
@@ -506,8 +507,6 @@ void __init clear_kernel_mapping(unsigned long address, unsigned long size)
506/* 507/*
507 * Memory hotplug specific functions 508 * Memory hotplug specific functions
508 */ 509 */
509#if defined(CONFIG_ACPI_HOTPLUG_MEMORY) || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)
510
511void online_page(struct page *page) 510void online_page(struct page *page)
512{ 511{
513 ClearPageReserved(page); 512 ClearPageReserved(page);
@@ -517,31 +516,17 @@ void online_page(struct page *page)
517 num_physpages++; 516 num_physpages++;
518} 517}
519 518
520#ifndef CONFIG_MEMORY_HOTPLUG 519#ifdef CONFIG_MEMORY_HOTPLUG
521/* 520/*
522 * Memory Hotadd without sparsemem. The mem_maps have been allocated in advance, 521 * XXX: memory_add_physaddr_to_nid() is to find node id from physical address
523 * just online the pages. 522 * via probe interface of sysfs. If acpi notifies hot-add event, then it
523 * can tell node id by searching dsdt. But, probe interface doesn't have
524 * node id. So, return 0 as node id at this time.
524 */ 525 */
525int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages) 526#ifdef CONFIG_NUMA
527int memory_add_physaddr_to_nid(u64 start)
526{ 528{
527 int err = -EIO; 529 return 0;
528 unsigned long pfn;
529 unsigned long total = 0, mem = 0;
530 for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) {
531 if (pfn_valid(pfn)) {
532 online_page(pfn_to_page(pfn));
533 err = 0;
534 mem++;
535 }
536 total++;
537 }
538 if (!err) {
539 z->spanned_pages += total;
540 z->present_pages += mem;
541 z->zone_pgdat->node_spanned_pages += total;
542 z->zone_pgdat->node_present_pages += mem;
543 }
544 return err;
545} 530}
546#endif 531#endif
547 532
@@ -549,9 +534,9 @@ int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
549 * Memory is added always to NORMAL zone. This means you will never get 534 * Memory is added always to NORMAL zone. This means you will never get
550 * additional DMA/DMA32 memory. 535 * additional DMA/DMA32 memory.
551 */ 536 */
552int add_memory(u64 start, u64 size) 537int arch_add_memory(int nid, u64 start, u64 size)
553{ 538{
554 struct pglist_data *pgdat = NODE_DATA(0); 539 struct pglist_data *pgdat = NODE_DATA(nid);
555 struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2; 540 struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2;
556 unsigned long start_pfn = start >> PAGE_SHIFT; 541 unsigned long start_pfn = start >> PAGE_SHIFT;
557 unsigned long nr_pages = size >> PAGE_SHIFT; 542 unsigned long nr_pages = size >> PAGE_SHIFT;
@@ -568,7 +553,7 @@ error:
568 printk("%s: Problem encountered in __add_pages!\n", __func__); 553 printk("%s: Problem encountered in __add_pages!\n", __func__);
569 return ret; 554 return ret;
570} 555}
571EXPORT_SYMBOL_GPL(add_memory); 556EXPORT_SYMBOL_GPL(arch_add_memory);
572 557
573int remove_memory(u64 start, u64 size) 558int remove_memory(u64 start, u64 size)
574{ 559{
@@ -576,7 +561,33 @@ int remove_memory(u64 start, u64 size)
576} 561}
577EXPORT_SYMBOL_GPL(remove_memory); 562EXPORT_SYMBOL_GPL(remove_memory);
578 563
579#endif 564#else /* CONFIG_MEMORY_HOTPLUG */
565/*
566 * Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
567 * just online the pages.
568 */
569int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
570{
571 int err = -EIO;
572 unsigned long pfn;
573 unsigned long total = 0, mem = 0;
574 for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) {
575 if (pfn_valid(pfn)) {
576 online_page(pfn_to_page(pfn));
577 err = 0;
578 mem++;
579 }
580 total++;
581 }
582 if (!err) {
583 z->spanned_pages += total;
584 z->present_pages += mem;
585 z->zone_pgdat->node_spanned_pages += total;
586 z->zone_pgdat->node_present_pages += mem;
587 }
588 return err;
589}
590#endif /* CONFIG_MEMORY_HOTPLUG */
580 591
581static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules, 592static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
582 kcore_vsyscall; 593 kcore_vsyscall;
@@ -650,7 +661,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
650 for (addr = begin; addr < end; addr += PAGE_SIZE) { 661 for (addr = begin; addr < end; addr += PAGE_SIZE) {
651 ClearPageReserved(virt_to_page(addr)); 662 ClearPageReserved(virt_to_page(addr));
652 init_page_count(virt_to_page(addr)); 663 init_page_count(virt_to_page(addr));
653 memset((void *)(addr & ~(PAGE_SIZE-1)), 0xcc, PAGE_SIZE); 664 memset((void *)(addr & ~(PAGE_SIZE-1)),
665 POISON_FREE_INITMEM, PAGE_SIZE);
654 free_page(addr); 666 free_page(addr);
655 totalram_pages++; 667 totalram_pages++;
656 } 668 }
@@ -658,7 +670,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
658 670
659void free_initmem(void) 671void free_initmem(void)
660{ 672{
661 memset(__initdata_begin, 0xba, __initdata_end - __initdata_begin); 673 memset(__initdata_begin, POISON_FREE_INITDATA,
674 __initdata_end - __initdata_begin);
662 free_init_pages("unused kernel memory", 675 free_init_pages("unused kernel memory",
663 (unsigned long)(&__init_begin), 676 (unsigned long)(&__init_begin),
664 (unsigned long)(&__init_end)); 677 (unsigned long)(&__init_end));
diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
index 51f9bed455fa..1cf744ee0959 100644
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -100,7 +100,7 @@ int show_interrupts(struct seq_file *p, void *v)
100 for_each_online_cpu(j) 100 for_each_online_cpu(j)
101 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 101 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
102#endif 102#endif
103 seq_printf(p, " %14s", irq_desc[i].handler->typename); 103 seq_printf(p, " %14s", irq_desc[i].chip->typename);
104 seq_printf(p, " %s", action->name); 104 seq_printf(p, " %s", action->name);
105 105
106 for (action=action->next; action; action = action->next) 106 for (action=action->next; action; action = action->next)
@@ -181,7 +181,7 @@ void __init init_IRQ(void)
181 int i; 181 int i;
182 182
183 for (i=0; i < XTENSA_NR_IRQS; i++) 183 for (i=0; i < XTENSA_NR_IRQS; i++)
184 irq_desc[i].handler = &xtensa_irq_type; 184 irq_desc[i].chip = &xtensa_irq_type;
185 185
186 cached_irq_mask = 0; 186 cached_irq_mask = 0;
187 187
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index c6f471b9eaa0..eda029fc8972 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -71,13 +71,13 @@ static int pci_bus_count;
71 * which might have be mirrored at 0x0100-0x03ff.. 71 * which might have be mirrored at 0x0100-0x03ff..
72 */ 72 */
73void 73void
74pcibios_align_resource(void *data, struct resource *res, unsigned long size, 74pcibios_align_resource(void *data, struct resource *res, resource_size_t size,
75 unsigned long align) 75 resource_size_t align)
76{ 76{
77 struct pci_dev *dev = data; 77 struct pci_dev *dev = data;
78 78
79 if (res->flags & IORESOURCE_IO) { 79 if (res->flags & IORESOURCE_IO) {
80 unsigned long start = res->start; 80 resource_size_t start = res->start;
81 81
82 if (size > 0x100) { 82 if (size > 0x100) {
83 printk(KERN_ERR "PCI: I/O Region %s/%d too large" 83 printk(KERN_ERR "PCI: I/O Region %s/%d too large"
diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index 937d81f62f43..fe14909f45e0 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -29,7 +29,7 @@
29 29
30extern volatile unsigned long wall_jiffies; 30extern volatile unsigned long wall_jiffies;
31 31
32spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; 32DEFINE_SPINLOCK(rtc_lock);
33EXPORT_SYMBOL(rtc_lock); 33EXPORT_SYMBOL(rtc_lock);
34 34
35 35
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index 225d64d73f04..27e409089a7b 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -461,7 +461,7 @@ void show_code(unsigned int *pc)
461 } 461 }
462} 462}
463 463
464spinlock_t die_lock = SPIN_LOCK_UNLOCKED; 464DEFINE_SPINLOCK(die_lock);
465 465
466void die(const char * str, struct pt_regs * regs, long err) 466void die(const char * str, struct pt_regs * regs, long err)
467{ 467{
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index c04422a502da..eee03a3876a3 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -3403,7 +3403,7 @@ static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
3403} 3403}
3404 3404
3405 3405
3406static struct notifier_block blk_cpu_notifier = { 3406static struct notifier_block __devinitdata blk_cpu_notifier = {
3407 .notifier_call = blk_cpu_notify, 3407 .notifier_call = blk_cpu_notify,
3408}; 3408};
3409 3409
@@ -3541,9 +3541,7 @@ int __init blk_dev_init(void)
3541 INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i)); 3541 INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i));
3542 3542
3543 open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL); 3543 open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL);
3544#ifdef CONFIG_HOTPLUG_CPU 3544 register_hotcpu_notifier(&blk_cpu_notifier);
3545 register_cpu_notifier(&blk_cpu_notifier);
3546#endif
3547 3545
3548 blk_max_low_pfn = max_low_pfn; 3546 blk_max_low_pfn = max_low_pfn;
3549 blk_max_pfn = max_pfn; 3547 blk_max_pfn = max_pfn;
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index ce15aed1df3f..bc2652d72fdc 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -335,7 +335,7 @@ config ACPI_CONTAINER
335config ACPI_HOTPLUG_MEMORY 335config ACPI_HOTPLUG_MEMORY
336 tristate "Memory Hotplug" 336 tristate "Memory Hotplug"
337 depends on ACPI 337 depends on ACPI
338 depends on MEMORY_HOTPLUG || X86_64 338 depends on MEMORY_HOTPLUG
339 default n 339 default n
340 help 340 help
341 This driver adds supports for ACPI Memory Hotplug. This driver 341 This driver adds supports for ACPI Memory Hotplug. This driver
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index b05469513842..6f5e395c78af 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -57,6 +57,7 @@ MODULE_LICENSE("GPL");
57 57
58static int acpi_memory_device_add(struct acpi_device *device); 58static int acpi_memory_device_add(struct acpi_device *device);
59static int acpi_memory_device_remove(struct acpi_device *device, int type); 59static int acpi_memory_device_remove(struct acpi_device *device, int type);
60static int acpi_memory_device_start(struct acpi_device *device);
60 61
61static struct acpi_driver acpi_memory_device_driver = { 62static struct acpi_driver acpi_memory_device_driver = {
62 .name = ACPI_MEMORY_DEVICE_DRIVER_NAME, 63 .name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
@@ -65,46 +66,77 @@ static struct acpi_driver acpi_memory_device_driver = {
65 .ops = { 66 .ops = {
66 .add = acpi_memory_device_add, 67 .add = acpi_memory_device_add,
67 .remove = acpi_memory_device_remove, 68 .remove = acpi_memory_device_remove,
69 .start = acpi_memory_device_start,
68 }, 70 },
69}; 71};
70 72
73struct acpi_memory_info {
74 struct list_head list;
75 u64 start_addr; /* Memory Range start physical addr */
76 u64 length; /* Memory Range length */
77 unsigned short caching; /* memory cache attribute */
78 unsigned short write_protect; /* memory read/write attribute */
79 unsigned int enabled:1;
80};
81
71struct acpi_memory_device { 82struct acpi_memory_device {
72 acpi_handle handle; 83 acpi_handle handle;
73 unsigned int state; /* State of the memory device */ 84 unsigned int state; /* State of the memory device */
74 unsigned short caching; /* memory cache attribute */ 85 struct list_head res_list;
75 unsigned short write_protect; /* memory read/write attribute */
76 u64 start_addr; /* Memory Range start physical addr */
77 u64 length; /* Memory Range length */
78}; 86};
79 87
88static acpi_status
89acpi_memory_get_resource(struct acpi_resource *resource, void *context)
90{
91 struct acpi_memory_device *mem_device = context;
92 struct acpi_resource_address64 address64;
93 struct acpi_memory_info *info, *new;
94 acpi_status status;
95
96 status = acpi_resource_to_address64(resource, &address64);
97 if (ACPI_FAILURE(status) ||
98 (address64.resource_type != ACPI_MEMORY_RANGE))
99 return AE_OK;
100
101 list_for_each_entry(info, &mem_device->res_list, list) {
102 /* Can we combine the resource range information? */
103 if ((info->caching == address64.info.mem.caching) &&
104 (info->write_protect == address64.info.mem.write_protect) &&
105 (info->start_addr + info->length == address64.minimum)) {
106 info->length += address64.address_length;
107 return AE_OK;
108 }
109 }
110
111 new = kzalloc(sizeof(struct acpi_memory_info), GFP_KERNEL);
112 if (!new)
113 return AE_ERROR;
114
115 INIT_LIST_HEAD(&new->list);
116 new->caching = address64.info.mem.caching;
117 new->write_protect = address64.info.mem.write_protect;
118 new->start_addr = address64.minimum;
119 new->length = address64.address_length;
120 list_add_tail(&new->list, &mem_device->res_list);
121
122 return AE_OK;
123}
124
80static int 125static int
81acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) 126acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
82{ 127{
83 acpi_status status; 128 acpi_status status;
84 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 129 struct acpi_memory_info *info, *n;
85 struct acpi_resource *resource = NULL;
86 struct acpi_resource_address64 address64;
87 130
88 131
89 /* Get the range from the _CRS */ 132 status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
90 status = acpi_get_current_resources(mem_device->handle, &buffer); 133 acpi_memory_get_resource, mem_device);
91 if (ACPI_FAILURE(status)) 134 if (ACPI_FAILURE(status)) {
135 list_for_each_entry_safe(info, n, &mem_device->res_list, list)
136 kfree(info);
92 return -EINVAL; 137 return -EINVAL;
93
94 resource = (struct acpi_resource *)buffer.pointer;
95 status = acpi_resource_to_address64(resource, &address64);
96 if (ACPI_SUCCESS(status)) {
97 if (address64.resource_type == ACPI_MEMORY_RANGE) {
98 /* Populate the structure */
99 mem_device->caching = address64.info.mem.caching;
100 mem_device->write_protect =
101 address64.info.mem.write_protect;
102 mem_device->start_addr = address64.minimum;
103 mem_device->length = address64.address_length;
104 }
105 } 138 }
106 139
107 acpi_os_free(buffer.pointer);
108 return 0; 140 return 0;
109} 141}
110 142
@@ -177,7 +209,9 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
177 209
178static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) 210static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
179{ 211{
180 int result; 212 int result, num_enabled = 0;
213 struct acpi_memory_info *info;
214 int node;
181 215
182 216
183 /* Get the range from the _CRS */ 217 /* Get the range from the _CRS */
@@ -188,15 +222,35 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
188 return result; 222 return result;
189 } 223 }
190 224
225 node = acpi_get_node(mem_device->handle);
191 /* 226 /*
192 * Tell the VM there is more memory here... 227 * Tell the VM there is more memory here...
193 * Note: Assume that this function returns zero on success 228 * Note: Assume that this function returns zero on success
229 * We don't have memory-hot-add rollback function,now.
230 * (i.e. memory-hot-remove function)
194 */ 231 */
195 result = add_memory(mem_device->start_addr, mem_device->length); 232 list_for_each_entry(info, &mem_device->res_list, list) {
196 if (result) { 233 u64 start_pfn, end_pfn;
197 printk(KERN_ERR PREFIX "add_memory failed\n"); 234
235 start_pfn = info->start_addr >> PAGE_SHIFT;
236 end_pfn = (info->start_addr + info->length - 1) >> PAGE_SHIFT;
237
238 if (pfn_valid(start_pfn) || pfn_valid(end_pfn)) {
239 /* already enabled. try next area */
240 num_enabled++;
241 continue;
242 }
243
244 result = add_memory(node, info->start_addr, info->length);
245 if (result)
246 continue;
247 info->enabled = 1;
248 num_enabled++;
249 }
250 if (!num_enabled) {
251 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n"));
198 mem_device->state = MEMORY_INVALID_STATE; 252 mem_device->state = MEMORY_INVALID_STATE;
199 return result; 253 return -EINVAL;
200 } 254 }
201 255
202 return result; 256 return result;
@@ -239,17 +293,21 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
239static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) 293static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
240{ 294{
241 int result; 295 int result;
242 u64 start = mem_device->start_addr; 296 struct acpi_memory_info *info, *n;
243 u64 len = mem_device->length;
244 297
245 298
246 /* 299 /*
247 * Ask the VM to offline this memory range. 300 * Ask the VM to offline this memory range.
248 * Note: Assume that this function returns zero on success 301 * Note: Assume that this function returns zero on success
249 */ 302 */
250 result = remove_memory(start, len); 303 list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
251 if (result) 304 if (info->enabled) {
252 return result; 305 result = remove_memory(info->start_addr, info->length);
306 if (result)
307 return result;
308 }
309 kfree(info);
310 }
253 311
254 /* Power-off and eject the device */ 312 /* Power-off and eject the device */
255 result = acpi_memory_powerdown_device(mem_device); 313 result = acpi_memory_powerdown_device(mem_device);
@@ -339,6 +397,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
339 return -ENOMEM; 397 return -ENOMEM;
340 memset(mem_device, 0, sizeof(struct acpi_memory_device)); 398 memset(mem_device, 0, sizeof(struct acpi_memory_device));
341 399
400 INIT_LIST_HEAD(&mem_device->res_list);
342 mem_device->handle = device->handle; 401 mem_device->handle = device->handle;
343 sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME); 402 sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
344 sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS); 403 sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
@@ -373,6 +432,23 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
373 return 0; 432 return 0;
374} 433}
375 434
435static int acpi_memory_device_start (struct acpi_device *device)
436{
437 struct acpi_memory_device *mem_device;
438 int result = 0;
439
440 mem_device = acpi_driver_data(device);
441
442 if (!acpi_memory_check_device(mem_device)) {
443 /* call add_memory func */
444 result = acpi_memory_enable_device(mem_device);
445 if (result)
446 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
447 "Error in acpi_memory_enable_device\n"));
448 }
449 return result;
450}
451
376/* 452/*
377 * Helper function to check for memory device 453 * Helper function to check for memory device
378 */ 454 */
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index e2c1a16078c9..13d6d5bdea26 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -254,5 +254,18 @@ int acpi_get_pxm(acpi_handle h)
254 } while (ACPI_SUCCESS(status)); 254 } while (ACPI_SUCCESS(status));
255 return -1; 255 return -1;
256} 256}
257
258EXPORT_SYMBOL(acpi_get_pxm); 257EXPORT_SYMBOL(acpi_get_pxm);
258
259int acpi_get_node(acpi_handle *handle)
260{
261 int pxm, node = -1;
262
263 ACPI_FUNCTION_TRACE("acpi_get_node");
264
265 pxm = acpi_get_pxm(handle);
266 if (pxm >= 0)
267 node = acpi_map_pxm_to_node(pxm);
268
269 return_VALUE(node);
270}
271EXPORT_SYMBOL(acpi_get_node);
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 889855d8d9f9..9e3e2a69c03a 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -180,8 +180,9 @@ static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
180amba_attr(id, "%08x\n", dev->periphid); 180amba_attr(id, "%08x\n", dev->periphid);
181amba_attr(irq0, "%u\n", dev->irq[0]); 181amba_attr(irq0, "%u\n", dev->irq[0]);
182amba_attr(irq1, "%u\n", dev->irq[1]); 182amba_attr(irq1, "%u\n", dev->irq[1]);
183amba_attr(resource, "\t%08lx\t%08lx\t%08lx\n", 183amba_attr(resource, "\t%016llx\t%016llx\t%016lx\n",
184 dev->res.start, dev->res.end, dev->res.flags); 184 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
185 dev->res.flags);
185 186
186/** 187/**
187 * amba_device_register - register an AMBA device 188 * amba_device_register - register an AMBA device
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 4b6bf19c39c0..4048681f36d5 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -2257,7 +2257,8 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
2257 } 2257 }
2258 2258
2259 PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at" 2259 PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at"
2260 " IO %lx, IRQ %u, MEM %p", pci_resource_start(pci_dev, 1), 2260 " IO %llx, IRQ %u, MEM %p",
2261 (unsigned long long)pci_resource_start(pci_dev, 1),
2261 irq, bus_to_virt(pci_resource_start(pci_dev, 0))); 2262 irq, bus_to_virt(pci_resource_start(pci_dev, 0)));
2262 2263
2263 // check IO region 2264 // check IO region
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index f2eeaf9dc56a..d40605c1af73 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -33,6 +33,7 @@
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/poison.h>
36#include <linux/errno.h> 37#include <linux/errno.h>
37#include <linux/atm.h> 38#include <linux/atm.h>
38#include <linux/atmdev.h> 39#include <linux/atmdev.h>
@@ -754,7 +755,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
754 fs_kfree_skb (skb); 755 fs_kfree_skb (skb);
755 756
756 fs_dprintk (FS_DEBUG_ALLOC, "Free trans-d: %p\n", td); 757 fs_dprintk (FS_DEBUG_ALLOC, "Free trans-d: %p\n", td);
757 memset (td, 0x12, sizeof (struct FS_BPENTRY)); 758 memset (td, ATM_POISON_FREE, sizeof(struct FS_BPENTRY));
758 kfree (td); 759 kfree (td);
759 break; 760 break;
760 default: 761 default:
@@ -1657,9 +1658,10 @@ static int __devinit fs_init (struct fs_dev *dev)
1657 func_enter (); 1658 func_enter ();
1658 pci_dev = dev->pci_dev; 1659 pci_dev = dev->pci_dev;
1659 1660
1660 printk (KERN_INFO "found a FireStream %d card, base %08lx, irq%d.\n", 1661 printk (KERN_INFO "found a FireStream %d card, base %16llx, irq%d.\n",
1661 IS_FS50(dev)?50:155, 1662 IS_FS50(dev)?50:155,
1662 pci_resource_start(pci_dev, 0), dev->pci_dev->irq); 1663 (unsigned long long)pci_resource_start(pci_dev, 0),
1664 dev->pci_dev->irq);
1663 1665
1664 if (fs_debug & FS_DEBUG_INIT) 1666 if (fs_debug & FS_DEBUG_INIT)
1665 my_hd ((unsigned char *) dev, sizeof (*dev)); 1667 my_hd ((unsigned char *) dev, sizeof (*dev));
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index dd712b24ec91..4bef76a2f3f2 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -8,6 +8,7 @@
8#include <linux/cpu.h> 8#include <linux/cpu.h>
9#include <linux/topology.h> 9#include <linux/topology.h>
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/node.h>
11 12
12#include "base.h" 13#include "base.h"
13 14
@@ -57,13 +58,12 @@ static void __devinit register_cpu_control(struct cpu *cpu)
57{ 58{
58 sysdev_create_file(&cpu->sysdev, &attr_online); 59 sysdev_create_file(&cpu->sysdev, &attr_online);
59} 60}
60void unregister_cpu(struct cpu *cpu, struct node *root) 61void unregister_cpu(struct cpu *cpu)
61{ 62{
62 int logical_cpu = cpu->sysdev.id; 63 int logical_cpu = cpu->sysdev.id;
63 64
64 if (root) 65 unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu));
65 sysfs_remove_link(&root->sysdev.kobj, 66
66 kobject_name(&cpu->sysdev.kobj));
67 sysdev_remove_file(&cpu->sysdev, &attr_online); 67 sysdev_remove_file(&cpu->sysdev, &attr_online);
68 68
69 sysdev_unregister(&cpu->sysdev); 69 sysdev_unregister(&cpu->sysdev);
@@ -109,23 +109,21 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
109 * 109 *
110 * Initialize and register the CPU device. 110 * Initialize and register the CPU device.
111 */ 111 */
112int __devinit register_cpu(struct cpu *cpu, int num, struct node *root) 112int __devinit register_cpu(struct cpu *cpu, int num)
113{ 113{
114 int error; 114 int error;
115
116 cpu->node_id = cpu_to_node(num); 115 cpu->node_id = cpu_to_node(num);
117 cpu->sysdev.id = num; 116 cpu->sysdev.id = num;
118 cpu->sysdev.cls = &cpu_sysdev_class; 117 cpu->sysdev.cls = &cpu_sysdev_class;
119 118
120 error = sysdev_register(&cpu->sysdev); 119 error = sysdev_register(&cpu->sysdev);
121 if (!error && root) 120
122 error = sysfs_create_link(&root->sysdev.kobj,
123 &cpu->sysdev.kobj,
124 kobject_name(&cpu->sysdev.kobj));
125 if (!error && !cpu->no_control) 121 if (!error && !cpu->no_control)
126 register_cpu_control(cpu); 122 register_cpu_control(cpu);
127 if (!error) 123 if (!error)
128 cpu_sys_devices[num] = &cpu->sysdev; 124 cpu_sys_devices[num] = &cpu->sysdev;
125 if (!error)
126 register_cpu_under_node(num, cpu_to_node(num));
129 127
130#ifdef CONFIG_KEXEC 128#ifdef CONFIG_KEXEC
131 if (!error) 129 if (!error)
@@ -145,5 +143,13 @@ EXPORT_SYMBOL_GPL(get_cpu_sysdev);
145 143
146int __init cpu_dev_init(void) 144int __init cpu_dev_init(void)
147{ 145{
148 return sysdev_class_register(&cpu_sysdev_class); 146 int err;
147
148 err = sysdev_class_register(&cpu_sysdev_class);
149#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
150 if (!err)
151 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
152#endif
153
154 return err;
149} 155}
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index e2f64f91ed05..33c5cce1560b 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -7,6 +7,7 @@
7#include <linux/dmapool.h> 7#include <linux/dmapool.h>
8#include <linux/slab.h> 8#include <linux/slab.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/poison.h>
10 11
11/* 12/*
12 * Pool allocator ... wraps the dma_alloc_coherent page allocator, so 13 * Pool allocator ... wraps the dma_alloc_coherent page allocator, so
@@ -35,8 +36,6 @@ struct dma_page { /* cacheable header for 'allocation' bytes */
35}; 36};
36 37
37#define POOL_TIMEOUT_JIFFIES ((100 /* msec */ * HZ) / 1000) 38#define POOL_TIMEOUT_JIFFIES ((100 /* msec */ * HZ) / 1000)
38#define POOL_POISON_FREED 0xa7 /* !inuse */
39#define POOL_POISON_ALLOCATED 0xa9 /* !initted */
40 39
41static DECLARE_MUTEX (pools_lock); 40static DECLARE_MUTEX (pools_lock);
42 41
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index dd547af4681a..c6b7d9c4b651 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -306,11 +306,13 @@ static ssize_t
306memory_probe_store(struct class *class, const char *buf, size_t count) 306memory_probe_store(struct class *class, const char *buf, size_t count)
307{ 307{
308 u64 phys_addr; 308 u64 phys_addr;
309 int nid;
309 int ret; 310 int ret;
310 311
311 phys_addr = simple_strtoull(buf, NULL, 0); 312 phys_addr = simple_strtoull(buf, NULL, 0);
312 313
313 ret = add_memory(phys_addr, PAGES_PER_SECTION << PAGE_SHIFT); 314 nid = memory_add_physaddr_to_nid(phys_addr);
315 ret = add_memory(nid, phys_addr, PAGES_PER_SECTION << PAGE_SHIFT);
314 316
315 if (ret) 317 if (ret)
316 count = ret; 318 count = ret;
diff --git a/drivers/base/node.c b/drivers/base/node.c
index c80c3aeed004..eae2bdc183bb 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -11,6 +11,7 @@
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include <linux/topology.h> 12#include <linux/topology.h>
13#include <linux/nodemask.h> 13#include <linux/nodemask.h>
14#include <linux/cpu.h>
14 15
15static struct sysdev_class node_class = { 16static struct sysdev_class node_class = {
16 set_kset_name("node"), 17 set_kset_name("node"),
@@ -190,6 +191,66 @@ void unregister_node(struct node *node)
190 sysdev_unregister(&node->sysdev); 191 sysdev_unregister(&node->sysdev);
191} 192}
192 193
194struct node node_devices[MAX_NUMNODES];
195
196/*
197 * register cpu under node
198 */
199int register_cpu_under_node(unsigned int cpu, unsigned int nid)
200{
201 if (node_online(nid)) {
202 struct sys_device *obj = get_cpu_sysdev(cpu);
203 if (!obj)
204 return 0;
205 return sysfs_create_link(&node_devices[nid].sysdev.kobj,
206 &obj->kobj,
207 kobject_name(&obj->kobj));
208 }
209
210 return 0;
211}
212
213int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
214{
215 if (node_online(nid)) {
216 struct sys_device *obj = get_cpu_sysdev(cpu);
217 if (obj)
218 sysfs_remove_link(&node_devices[nid].sysdev.kobj,
219 kobject_name(&obj->kobj));
220 }
221 return 0;
222}
223
224int register_one_node(int nid)
225{
226 int error = 0;
227 int cpu;
228
229 if (node_online(nid)) {
230 int p_node = parent_node(nid);
231 struct node *parent = NULL;
232
233 if (p_node != nid)
234 parent = &node_devices[p_node];
235
236 error = register_node(&node_devices[nid], nid, parent);
237
238 /* link cpu under this node */
239 for_each_present_cpu(cpu) {
240 if (cpu_to_node(cpu) == nid)
241 register_cpu_under_node(cpu, nid);
242 }
243 }
244
245 return error;
246
247}
248
249void unregister_one_node(int nid)
250{
251 unregister_node(&node_devices[nid]);
252}
253
193static int __init register_node_type(void) 254static int __init register_node_type(void)
194{ 255{
195 return sysdev_class_register(&node_class); 256 return sysdev_class_register(&node_class);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 8c52421cbc54..c2d621632383 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -107,7 +107,7 @@ static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
107 return 0; 107 return 0;
108} 108}
109 109
110static int topology_cpu_callback(struct notifier_block *nfb, 110static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
111 unsigned long action, void *hcpu) 111 unsigned long action, void *hcpu)
112{ 112{
113 unsigned int cpu = (unsigned long)hcpu; 113 unsigned int cpu = (unsigned long)hcpu;
@@ -125,7 +125,7 @@ static int topology_cpu_callback(struct notifier_block *nfb,
125 return NOTIFY_OK; 125 return NOTIFY_OK;
126} 126}
127 127
128static struct notifier_block topology_cpu_notifier = 128static struct notifier_block __cpuinitdata topology_cpu_notifier =
129{ 129{
130 .notifier_call = topology_cpu_callback, 130 .notifier_call = topology_cpu_callback,
131}; 131};
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index dd8a1501142f..50ca1aa4ee3b 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -2530,7 +2530,6 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2530 blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand); 2530 blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
2531 disk->queue = RequestQueue; 2531 disk->queue = RequestQueue;
2532 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n); 2532 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
2533 sprintf(disk->devfs_name, "rd/host%d/target%d", Controller->ControllerNumber, n);
2534 disk->major = MajorNumber; 2533 disk->major = MajorNumber;
2535 disk->first_minor = n << DAC960_MaxPartitionsBits; 2534 disk->first_minor = n << DAC960_MaxPartitionsBits;
2536 disk->fops = &DAC960_BlockDeviceOperations; 2535 disk->fops = &DAC960_BlockDeviceOperations;
diff --git a/drivers/block/acsi.c b/drivers/block/acsi.c
index 196c0ec9cd54..a317e4303952 100644
--- a/drivers/block/acsi.c
+++ b/drivers/block/acsi.c
@@ -1732,13 +1732,10 @@ int acsi_init( void )
1732 struct gendisk *disk = acsi_gendisk[i]; 1732 struct gendisk *disk = acsi_gendisk[i];
1733 sprintf(disk->disk_name, "ad%c", 'a'+i); 1733 sprintf(disk->disk_name, "ad%c", 'a'+i);
1734 aip = &acsi_info[NDevices]; 1734 aip = &acsi_info[NDevices];
1735 sprintf(disk->devfs_name, "ad/target%d/lun%d", aip->target, aip->lun);
1736 disk->major = ACSI_MAJOR; 1735 disk->major = ACSI_MAJOR;
1737 disk->first_minor = i << 4; 1736 disk->first_minor = i << 4;
1738 if (acsi_info[i].type != HARDDISK) { 1737 if (acsi_info[i].type != HARDDISK)
1739 disk->minors = 1; 1738 disk->minors = 1;
1740 strcat(disk->devfs_name, "/disc");
1741 }
1742 disk->fops = &acsi_fops; 1739 disk->fops = &acsi_fops;
1743 disk->private_data = &acsi_info[i]; 1740 disk->private_data = &acsi_info[i];
1744 set_capacity(disk, acsi_info[i].size); 1741 set_capacity(disk, acsi_info[i].size);
diff --git a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c
index 4cb9c1336287..4030a8fd1187 100644
--- a/drivers/block/acsi_slm.c
+++ b/drivers/block/acsi_slm.c
@@ -65,7 +65,6 @@ not be guaranteed. There are several ways to assure this:
65#include <linux/time.h> 65#include <linux/time.h>
66#include <linux/mm.h> 66#include <linux/mm.h>
67#include <linux/slab.h> 67#include <linux/slab.h>
68#include <linux/devfs_fs_kernel.h>
69#include <linux/smp_lock.h> 68#include <linux/smp_lock.h>
70 69
71#include <asm/pgtable.h> 70#include <asm/pgtable.h>
@@ -1005,11 +1004,6 @@ int slm_init( void )
1005 BufferP = SLMBuffer; 1004 BufferP = SLMBuffer;
1006 SLMState = IDLE; 1005 SLMState = IDLE;
1007 1006
1008 devfs_mk_dir("slm");
1009 for (i = 0; i < MAX_SLM; i++) {
1010 devfs_mk_cdev(MKDEV(ACSI_MAJOR, i),
1011 S_IFCHR|S_IRUSR|S_IWUSR, "slm/%d", i);
1012 }
1013 return 0; 1007 return 0;
1014} 1008}
1015 1009
@@ -1032,10 +1026,6 @@ int init_module(void)
1032 1026
1033void cleanup_module(void) 1027void cleanup_module(void)
1034{ 1028{
1035 int i;
1036 for (i = 0; i < MAX_SLM; i++)
1037 devfs_remove("slm/%d", i);
1038 devfs_remove("slm");
1039 if (unregister_chrdev( ACSI_MAJOR, "slm" ) != 0) 1029 if (unregister_chrdev( ACSI_MAJOR, "slm" ) != 0)
1040 printk( KERN_ERR "acsi_slm: cleanup_module failed\n"); 1030 printk( KERN_ERR "acsi_slm: cleanup_module failed\n");
1041 atari_stram_free( SLMBuffer ); 1031 atari_stram_free( SLMBuffer );
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 39b0f53186e8..05fb08312c01 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3248,7 +3248,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3248 3248
3249 q->queuedata = hba[i]; 3249 q->queuedata = hba[i];
3250 sprintf(disk->disk_name, "cciss/c%dd%d", i, j); 3250 sprintf(disk->disk_name, "cciss/c%dd%d", i, j);
3251 sprintf(disk->devfs_name, "cciss/host%d/target%d", i, j);
3252 disk->major = hba[i]->major; 3251 disk->major = hba[i]->major;
3253 disk->first_minor = j << NWD_SHIFT; 3252 disk->first_minor = j << NWD_SHIFT;
3254 disk->fops = &cciss_fops; 3253 disk->fops = &cciss_fops;
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 5eb6fb7b5cfa..bfd245df0a8c 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -33,7 +33,6 @@
33#include <linux/blkpg.h> 33#include <linux/blkpg.h>
34#include <linux/timer.h> 34#include <linux/timer.h>
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/devfs_fs_kernel.h>
37#include <linux/init.h> 36#include <linux/init.h>
38#include <linux/hdreg.h> 37#include <linux/hdreg.h>
39#include <linux/spinlock.h> 38#include <linux/spinlock.h>
@@ -348,7 +347,6 @@ static void __devexit cpqarray_remove_one(int i)
348 for(j = 0; j < NWD; j++) { 347 for(j = 0; j < NWD; j++) {
349 if (ida_gendisk[i][j]->flags & GENHD_FL_UP) 348 if (ida_gendisk[i][j]->flags & GENHD_FL_UP)
350 del_gendisk(ida_gendisk[i][j]); 349 del_gendisk(ida_gendisk[i][j]);
351 devfs_remove("ida/c%dd%d",i,j);
352 put_disk(ida_gendisk[i][j]); 350 put_disk(ida_gendisk[i][j]);
353 } 351 }
354 blk_cleanup_queue(hba[i]->queue); 352 blk_cleanup_queue(hba[i]->queue);
@@ -1807,8 +1805,6 @@ static void getgeometry(int ctlr)
1807 1805
1808 } 1806 }
1809 1807
1810 sprintf(disk->devfs_name, "ida/c%dd%d", ctlr, log_unit);
1811
1812 info_p->phys_drives = 1808 info_p->phys_drives =
1813 sense_config_buf->ctlr_phys_drv; 1809 sense_config_buf->ctlr_phys_drv;
1814 info_p->drv_assign_map 1810 info_p->drv_assign_map
@@ -1844,7 +1840,6 @@ static void __exit cpqarray_exit(void)
1844 } 1840 }
1845 } 1841 }
1846 1842
1847 devfs_remove("ida");
1848 remove_proc_entry("cpqarray", proc_root_driver); 1843 remove_proc_entry("cpqarray", proc_root_driver);
1849} 1844}
1850 1845
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index dff1e67b1dd4..0242cbb86a87 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -177,7 +177,6 @@ static int print_unex = 1;
177#include <linux/ioport.h> 177#include <linux/ioport.h>
178#include <linux/interrupt.h> 178#include <linux/interrupt.h>
179#include <linux/init.h> 179#include <linux/init.h>
180#include <linux/devfs_fs_kernel.h>
181#include <linux/platform_device.h> 180#include <linux/platform_device.h>
182#include <linux/buffer_head.h> /* for invalidate_buffers() */ 181#include <linux/buffer_head.h> /* for invalidate_buffers() */
183#include <linux/mutex.h> 182#include <linux/mutex.h>
@@ -224,7 +223,6 @@ static struct completion device_release;
224static unsigned short virtual_dma_port = 0x3f0; 223static unsigned short virtual_dma_port = 0x3f0;
225irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs); 224irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
226static int set_dor(int fdc, char mask, char data); 225static int set_dor(int fdc, char mask, char data);
227static void register_devfs_entries(int drive) __init;
228 226
229#define K_64 0x10000 /* 64KB */ 227#define K_64 0x10000 /* 64KB */
230 228
@@ -3676,7 +3674,6 @@ static void __init config_types(void)
3676 first = 0; 3674 first = 0;
3677 } 3675 }
3678 printk("%s fd%d is %s", prepend, drive, name); 3676 printk("%s fd%d is %s", prepend, drive, name);
3679 register_devfs_entries(drive);
3680 } 3677 }
3681 *UDP = *params; 3678 *UDP = *params;
3682 } 3679 }
@@ -3954,37 +3951,6 @@ static struct block_device_operations floppy_fops = {
3954 .media_changed = check_floppy_change, 3951 .media_changed = check_floppy_change,
3955 .revalidate_disk = floppy_revalidate, 3952 .revalidate_disk = floppy_revalidate,
3956}; 3953};
3957static char *table[] = {
3958 "", "d360", "h1200", "u360", "u720", "h360", "h720",
3959 "u1440", "u2880", "CompaQ", "h1440", "u1680", "h410",
3960 "u820", "h1476", "u1722", "h420", "u830", "h1494", "u1743",
3961 "h880", "u1040", "u1120", "h1600", "u1760", "u1920",
3962 "u3200", "u3520", "u3840", "u1840", "u800", "u1600",
3963 NULL
3964};
3965static int t360[] = { 1, 0 },
3966 t1200[] = { 2, 5, 6, 10, 12, 14, 16, 18, 20, 23, 0 },
3967 t3in[] = { 8, 9, 26, 27, 28, 7, 11, 15, 19, 24, 25, 29, 31, 3, 4, 13,
3968 17, 21, 22, 30, 0 };
3969static int *table_sup[] =
3970 { NULL, t360, t1200, t3in + 5 + 8, t3in + 5, t3in, t3in };
3971
3972static void __init register_devfs_entries(int drive)
3973{
3974 int base_minor = (drive < 4) ? drive : (124 + drive);
3975
3976 if (UDP->cmos < ARRAY_SIZE(default_drive_params)) {
3977 int i = 0;
3978 do {
3979 int minor = base_minor + (table_sup[UDP->cmos][i] << 2);
3980
3981 devfs_mk_bdev(MKDEV(FLOPPY_MAJOR, minor),
3982 S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP |
3983 S_IWGRP, "floppy/%d%s", drive,
3984 table[table_sup[UDP->cmos][i]]);
3985 } while (table_sup[UDP->cmos][i++]);
3986 }
3987}
3988 3954
3989/* 3955/*
3990 * Floppy Driver initialization 3956 * Floppy Driver initialization
@@ -4261,11 +4227,9 @@ static int __init floppy_init(void)
4261 motor_off_timer[dr].function = motor_off_callback; 4227 motor_off_timer[dr].function = motor_off_callback;
4262 } 4228 }
4263 4229
4264 devfs_mk_dir("floppy");
4265
4266 err = register_blkdev(FLOPPY_MAJOR, "fd"); 4230 err = register_blkdev(FLOPPY_MAJOR, "fd");
4267 if (err) 4231 if (err)
4268 goto out_devfs_remove; 4232 goto out_put_disk;
4269 4233
4270 floppy_queue = blk_init_queue(do_fd_request, &floppy_lock); 4234 floppy_queue = blk_init_queue(do_fd_request, &floppy_lock);
4271 if (!floppy_queue) { 4235 if (!floppy_queue) {
@@ -4424,8 +4388,6 @@ out_unreg_region:
4424 blk_cleanup_queue(floppy_queue); 4388 blk_cleanup_queue(floppy_queue);
4425out_unreg_blkdev: 4389out_unreg_blkdev:
4426 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4390 unregister_blkdev(FLOPPY_MAJOR, "fd");
4427out_devfs_remove:
4428 devfs_remove("floppy");
4429out_put_disk: 4391out_put_disk:
4430 while (dr--) { 4392 while (dr--) {
4431 del_timer(&motor_off_timer[dr]); 4393 del_timer(&motor_off_timer[dr]);
@@ -4586,19 +4548,6 @@ static void floppy_release_irq_and_dma(void)
4586 4548
4587static char *floppy; 4549static char *floppy;
4588 4550
4589static void unregister_devfs_entries(int drive)
4590{
4591 int i;
4592
4593 if (UDP->cmos < ARRAY_SIZE(default_drive_params)) {
4594 i = 0;
4595 do {
4596 devfs_remove("floppy/%d%s", drive,
4597 table[table_sup[UDP->cmos][i]]);
4598 } while (table_sup[UDP->cmos][i++]);
4599 }
4600}
4601
4602static void __init parse_floppy_cfg_string(char *cfg) 4551static void __init parse_floppy_cfg_string(char *cfg)
4603{ 4552{
4604 char *ptr; 4553 char *ptr;
@@ -4635,13 +4584,11 @@ void cleanup_module(void)
4635 if ((allowed_drive_mask & (1 << drive)) && 4584 if ((allowed_drive_mask & (1 << drive)) &&
4636 fdc_state[FDC(drive)].version != FDC_NONE) { 4585 fdc_state[FDC(drive)].version != FDC_NONE) {
4637 del_gendisk(disks[drive]); 4586 del_gendisk(disks[drive]);
4638 unregister_devfs_entries(drive);
4639 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); 4587 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos);
4640 platform_device_unregister(&floppy_device[drive]); 4588 platform_device_unregister(&floppy_device[drive]);
4641 } 4589 }
4642 put_disk(disks[drive]); 4590 put_disk(disks[drive]);
4643 } 4591 }
4644 devfs_remove("floppy");
4645 4592
4646 del_timer_sync(&fd_timeout); 4593 del_timer_sync(&fd_timeout);
4647 del_timer_sync(&fd_timer); 4594 del_timer_sync(&fd_timer);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 3c74ea729fc7..013c5daddb0b 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -63,7 +63,6 @@
63#include <linux/blkdev.h> 63#include <linux/blkdev.h>
64#include <linux/blkpg.h> 64#include <linux/blkpg.h>
65#include <linux/init.h> 65#include <linux/init.h>
66#include <linux/devfs_fs_kernel.h>
67#include <linux/smp_lock.h> 66#include <linux/smp_lock.h>
68#include <linux/swap.h> 67#include <linux/swap.h>
69#include <linux/slab.h> 68#include <linux/slab.h>
@@ -210,7 +209,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
210{ 209{
211 struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */ 210 struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
212 struct address_space *mapping = file->f_mapping; 211 struct address_space *mapping = file->f_mapping;
213 struct address_space_operations *aops = mapping->a_ops; 212 const struct address_space_operations *aops = mapping->a_ops;
214 pgoff_t index; 213 pgoff_t index;
215 unsigned offset, bv_offs; 214 unsigned offset, bv_offs;
216 int len, ret; 215 int len, ret;
@@ -784,7 +783,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
784 783
785 error = -EINVAL; 784 error = -EINVAL;
786 if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) { 785 if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) {
787 struct address_space_operations *aops = mapping->a_ops; 786 const struct address_space_operations *aops = mapping->a_ops;
788 /* 787 /*
789 * If we can't read - sorry. If we only can't write - well, 788 * If we can't read - sorry. If we only can't write - well,
790 * it's going to be read-only. 789 * it's going to be read-only.
@@ -1277,8 +1276,6 @@ static int __init loop_init(void)
1277 goto out_mem3; 1276 goto out_mem3;
1278 } 1277 }
1279 1278
1280 devfs_mk_dir("loop");
1281
1282 for (i = 0; i < max_loop; i++) { 1279 for (i = 0; i < max_loop; i++) {
1283 struct loop_device *lo = &loop_dev[i]; 1280 struct loop_device *lo = &loop_dev[i];
1284 struct gendisk *disk = disks[i]; 1281 struct gendisk *disk = disks[i];
@@ -1296,7 +1293,6 @@ static int __init loop_init(void)
1296 disk->first_minor = i; 1293 disk->first_minor = i;
1297 disk->fops = &lo_fops; 1294 disk->fops = &lo_fops;
1298 sprintf(disk->disk_name, "loop%d", i); 1295 sprintf(disk->disk_name, "loop%d", i);
1299 sprintf(disk->devfs_name, "loop/%d", i);
1300 disk->private_data = lo; 1296 disk->private_data = lo;
1301 disk->queue = lo->lo_queue; 1297 disk->queue = lo->lo_queue;
1302 } 1298 }
@@ -1310,7 +1306,6 @@ static int __init loop_init(void)
1310out_mem4: 1306out_mem4:
1311 while (i--) 1307 while (i--)
1312 blk_cleanup_queue(loop_dev[i].lo_queue); 1308 blk_cleanup_queue(loop_dev[i].lo_queue);
1313 devfs_remove("loop");
1314 i = max_loop; 1309 i = max_loop;
1315out_mem3: 1310out_mem3:
1316 while (i--) 1311 while (i--)
@@ -1333,7 +1328,6 @@ static void loop_exit(void)
1333 blk_cleanup_queue(loop_dev[i].lo_queue); 1328 blk_cleanup_queue(loop_dev[i].lo_queue);
1334 put_disk(disks[i]); 1329 put_disk(disks[i]);
1335 } 1330 }
1336 devfs_remove("loop");
1337 if (unregister_blkdev(LOOP_MAJOR, "loop")) 1331 if (unregister_blkdev(LOOP_MAJOR, "loop"))
1338 printk(KERN_WARNING "loop: cannot unregister blkdev\n"); 1332 printk(KERN_WARNING "loop: cannot unregister blkdev\n");
1339 1333
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7f554f2ed079..39662f0c9cce 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -29,8 +29,6 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <net/sock.h> 30#include <net/sock.h>
31 31
32#include <linux/devfs_fs_kernel.h>
33
34#include <asm/uaccess.h> 32#include <asm/uaccess.h>
35#include <asm/system.h> 33#include <asm/system.h>
36#include <asm/types.h> 34#include <asm/types.h>
@@ -642,7 +640,6 @@ static int __init nbd_init(void)
642 printk(KERN_INFO "nbd: registered device at major %d\n", NBD_MAJOR); 640 printk(KERN_INFO "nbd: registered device at major %d\n", NBD_MAJOR);
643 dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags); 641 dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags);
644 642
645 devfs_mk_dir("nbd");
646 for (i = 0; i < nbds_max; i++) { 643 for (i = 0; i < nbds_max; i++) {
647 struct gendisk *disk = nbd_dev[i].disk; 644 struct gendisk *disk = nbd_dev[i].disk;
648 nbd_dev[i].file = NULL; 645 nbd_dev[i].file = NULL;
@@ -660,7 +657,6 @@ static int __init nbd_init(void)
660 disk->private_data = &nbd_dev[i]; 657 disk->private_data = &nbd_dev[i];
661 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; 658 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
662 sprintf(disk->disk_name, "nbd%d", i); 659 sprintf(disk->disk_name, "nbd%d", i);
663 sprintf(disk->devfs_name, "nbd/%d", i);
664 set_capacity(disk, 0x7ffffc00ULL << 1); /* 2 TB */ 660 set_capacity(disk, 0x7ffffc00ULL << 1); /* 2 TB */
665 add_disk(disk); 661 add_disk(disk);
666 } 662 }
@@ -686,7 +682,6 @@ static void __exit nbd_cleanup(void)
686 put_disk(disk); 682 put_disk(disk);
687 } 683 }
688 } 684 }
689 devfs_remove("nbd");
690 unregister_blkdev(NBD_MAJOR, "nbd"); 685 unregister_blkdev(NBD_MAJOR, "nbd");
691 printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR); 686 printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR);
692} 687}
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 852b564e903a..1a9dee19efcf 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -707,7 +707,7 @@ static int pf_detect(void)
707 if (pi_init(pf->pi, 0, conf[D_PRT], conf[D_MOD], 707 if (pi_init(pf->pi, 0, conf[D_PRT], conf[D_MOD],
708 conf[D_UNI], conf[D_PRO], conf[D_DLY], 708 conf[D_UNI], conf[D_PRO], conf[D_DLY],
709 pf_scratch, PI_PF, verbose, pf->name)) { 709 pf_scratch, PI_PF, verbose, pf->name)) {
710 if (!pf_probe(pf) && pf->disk) { 710 if (pf->disk && !pf_probe(pf)) {
711 pf->present = 1; 711 pf->present = 1;
712 k++; 712 k++;
713 } else 713 } else
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 79b868254032..13f998aa1cd3 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -156,7 +156,6 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
156#include <linux/module.h> 156#include <linux/module.h>
157#include <linux/init.h> 157#include <linux/init.h>
158#include <linux/fs.h> 158#include <linux/fs.h>
159#include <linux/devfs_fs_kernel.h>
160#include <linux/delay.h> 159#include <linux/delay.h>
161#include <linux/slab.h> 160#include <linux/slab.h>
162#include <linux/mtio.h> 161#include <linux/mtio.h>
@@ -674,25 +673,15 @@ static int __init pg_init(void)
674 err = PTR_ERR(pg_class); 673 err = PTR_ERR(pg_class);
675 goto out_chrdev; 674 goto out_chrdev;
676 } 675 }
677 devfs_mk_dir("pg");
678 for (unit = 0; unit < PG_UNITS; unit++) { 676 for (unit = 0; unit < PG_UNITS; unit++) {
679 struct pg *dev = &devices[unit]; 677 struct pg *dev = &devices[unit];
680 if (dev->present) { 678 if (dev->present)
681 class_device_create(pg_class, NULL, MKDEV(major, unit), 679 class_device_create(pg_class, NULL, MKDEV(major, unit),
682 NULL, "pg%u", unit); 680 NULL, "pg%u", unit);
683 err = devfs_mk_cdev(MKDEV(major, unit),
684 S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u",
685 unit);
686 if (err)
687 goto out_class;
688 }
689 } 681 }
690 err = 0; 682 err = 0;
691 goto out; 683 goto out;
692 684
693out_class:
694 class_device_destroy(pg_class, MKDEV(major, unit));
695 class_destroy(pg_class);
696out_chrdev: 685out_chrdev:
697 unregister_chrdev(major, "pg"); 686 unregister_chrdev(major, "pg");
698out: 687out:
@@ -705,13 +694,10 @@ static void __exit pg_exit(void)
705 694
706 for (unit = 0; unit < PG_UNITS; unit++) { 695 for (unit = 0; unit < PG_UNITS; unit++) {
707 struct pg *dev = &devices[unit]; 696 struct pg *dev = &devices[unit];
708 if (dev->present) { 697 if (dev->present)
709 class_device_destroy(pg_class, MKDEV(major, unit)); 698 class_device_destroy(pg_class, MKDEV(major, unit));
710 devfs_remove("pg/%u", unit);
711 }
712 } 699 }
713 class_destroy(pg_class); 700 class_destroy(pg_class);
714 devfs_remove("pg");
715 unregister_chrdev(major, name); 701 unregister_chrdev(major, name);
716 702
717 for (unit = 0; unit < PG_UNITS; unit++) { 703 for (unit = 0; unit < PG_UNITS; unit++) {
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index d2013d362403..35fb26636721 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -141,7 +141,6 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
141#include <linux/module.h> 141#include <linux/module.h>
142#include <linux/init.h> 142#include <linux/init.h>
143#include <linux/fs.h> 143#include <linux/fs.h>
144#include <linux/devfs_fs_kernel.h>
145#include <linux/delay.h> 144#include <linux/delay.h>
146#include <linux/slab.h> 145#include <linux/slab.h>
147#include <linux/mtio.h> 146#include <linux/mtio.h>
@@ -971,32 +970,15 @@ static int __init pt_init(void)
971 goto out_chrdev; 970 goto out_chrdev;
972 } 971 }
973 972
974 devfs_mk_dir("pt");
975 for (unit = 0; unit < PT_UNITS; unit++) 973 for (unit = 0; unit < PT_UNITS; unit++)
976 if (pt[unit].present) { 974 if (pt[unit].present) {
977 class_device_create(pt_class, NULL, MKDEV(major, unit), 975 class_device_create(pt_class, NULL, MKDEV(major, unit),
978 NULL, "pt%d", unit); 976 NULL, "pt%d", unit);
979 err = devfs_mk_cdev(MKDEV(major, unit),
980 S_IFCHR | S_IRUSR | S_IWUSR,
981 "pt/%d", unit);
982 if (err) {
983 class_device_destroy(pt_class, MKDEV(major, unit));
984 goto out_class;
985 }
986 class_device_create(pt_class, NULL, MKDEV(major, unit + 128), 977 class_device_create(pt_class, NULL, MKDEV(major, unit + 128),
987 NULL, "pt%dn", unit); 978 NULL, "pt%dn", unit);
988 err = devfs_mk_cdev(MKDEV(major, unit + 128),
989 S_IFCHR | S_IRUSR | S_IWUSR,
990 "pt/%dn", unit);
991 if (err) {
992 class_device_destroy(pt_class, MKDEV(major, unit + 128));
993 goto out_class;
994 }
995 } 979 }
996 goto out; 980 goto out;
997 981
998out_class:
999 class_destroy(pt_class);
1000out_chrdev: 982out_chrdev:
1001 unregister_chrdev(major, "pt"); 983 unregister_chrdev(major, "pt");
1002out: 984out:
@@ -1009,12 +991,9 @@ static void __exit pt_exit(void)
1009 for (unit = 0; unit < PT_UNITS; unit++) 991 for (unit = 0; unit < PT_UNITS; unit++)
1010 if (pt[unit].present) { 992 if (pt[unit].present) {
1011 class_device_destroy(pt_class, MKDEV(major, unit)); 993 class_device_destroy(pt_class, MKDEV(major, unit));
1012 devfs_remove("pt/%d", unit);
1013 class_device_destroy(pt_class, MKDEV(major, unit + 128)); 994 class_device_destroy(pt_class, MKDEV(major, unit + 128));
1014 devfs_remove("pt/%dn", unit);
1015 } 995 }
1016 class_destroy(pt_class); 996 class_destroy(pt_class);
1017 devfs_remove("pt");
1018 unregister_chrdev(major, name); 997 unregister_chrdev(major, name);
1019 for (unit = 0; unit < PT_UNITS; unit++) 998 for (unit = 0; unit < PT_UNITS; unit++)
1020 if (pt[unit].present) 999 if (pt[unit].present)
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index a04f60693c39..3e4cce5e4736 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2612,7 +2612,6 @@ static struct file_operations pkt_ctl_fops = {
2612static struct miscdevice pkt_misc = { 2612static struct miscdevice pkt_misc = {
2613 .minor = MISC_DYNAMIC_MINOR, 2613 .minor = MISC_DYNAMIC_MINOR,
2614 .name = "pktcdvd", 2614 .name = "pktcdvd",
2615 .devfs_name = "pktcdvd/control",
2616 .fops = &pkt_ctl_fops 2615 .fops = &pkt_ctl_fops
2617}; 2616};
2618 2617
diff --git a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c
index bea75f2cb211..a729013a3973 100644
--- a/drivers/block/ps2esdi.c
+++ b/drivers/block/ps2esdi.c
@@ -421,7 +421,6 @@ static int __init ps2esdi_geninit(void)
421 disk->major = PS2ESDI_MAJOR; 421 disk->major = PS2ESDI_MAJOR;
422 disk->first_minor = i<<6; 422 disk->first_minor = i<<6;
423 sprintf(disk->disk_name, "ed%c", 'a'+i); 423 sprintf(disk->disk_name, "ed%c", 'a'+i);
424 sprintf(disk->devfs_name, "ed/target%d", i);
425 disk->fops = &ps2esdi_fops; 424 disk->fops = &ps2esdi_fops;
426 ps2esdi_gendisk[i] = disk; 425 ps2esdi_gendisk[i] = disk;
427 } 426 }
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 940bfd7951e5..a9e1c2524c2a 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -50,7 +50,6 @@
50#include <linux/module.h> 50#include <linux/module.h>
51#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/devfs_fs_kernel.h>
54#include <linux/pagemap.h> 53#include <linux/pagemap.h>
55#include <linux/blkdev.h> 54#include <linux/blkdev.h>
56#include <linux/genhd.h> 55#include <linux/genhd.h>
@@ -191,7 +190,7 @@ static int ramdisk_set_page_dirty(struct page *page)
191 return 0; 190 return 0;
192} 191}
193 192
194static struct address_space_operations ramdisk_aops = { 193static const struct address_space_operations ramdisk_aops = {
195 .readpage = ramdisk_readpage, 194 .readpage = ramdisk_readpage,
196 .prepare_write = ramdisk_prepare_write, 195 .prepare_write = ramdisk_prepare_write,
197 .commit_write = ramdisk_commit_write, 196 .commit_write = ramdisk_commit_write,
@@ -412,7 +411,6 @@ static void __exit rd_cleanup(void)
412 put_disk(rd_disks[i]); 411 put_disk(rd_disks[i]);
413 blk_cleanup_queue(rd_queue[i]); 412 blk_cleanup_queue(rd_queue[i]);
414 } 413 }
415 devfs_remove("rd");
416 unregister_blkdev(RAMDISK_MAJOR, "ramdisk"); 414 unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
417} 415}
418 416
@@ -442,8 +440,6 @@ static int __init rd_init(void)
442 goto out; 440 goto out;
443 } 441 }
444 442
445 devfs_mk_dir("rd");
446
447 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) { 443 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
448 struct gendisk *disk = rd_disks[i]; 444 struct gendisk *disk = rd_disks[i];
449 445
@@ -461,7 +457,6 @@ static int __init rd_init(void)
461 disk->queue = rd_queue[i]; 457 disk->queue = rd_queue[i];
462 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; 458 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
463 sprintf(disk->disk_name, "ram%d", i); 459 sprintf(disk->disk_name, "ram%d", i);
464 sprintf(disk->devfs_name, "rd/%d", i);
465 set_capacity(disk, rd_size * 2); 460 set_capacity(disk, rd_size * 2);
466 add_disk(rd_disks[i]); 461 add_disk(rd_disks[i]);
467 } 462 }
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 01f042f6f1c4..628877945f9b 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -25,7 +25,6 @@
25#include <linux/fd.h> 25#include <linux/fd.h>
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/blkdev.h> 27#include <linux/blkdev.h>
28#include <linux/devfs_fs_kernel.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/spinlock.h> 30#include <linux/spinlock.h>
@@ -1019,8 +1018,6 @@ int swim3_init(void)
1019 int err = -ENOMEM; 1018 int err = -ENOMEM;
1020 int i; 1019 int i;
1021 1020
1022 devfs_mk_dir("floppy");
1023
1024 swim = find_devices("floppy"); 1021 swim = find_devices("floppy");
1025 while (swim && (floppy_count < MAX_FLOPPIES)) 1022 while (swim && (floppy_count < MAX_FLOPPIES))
1026 { 1023 {
@@ -1064,7 +1061,6 @@ int swim3_init(void)
1064 disk->queue = swim3_queue; 1061 disk->queue = swim3_queue;
1065 disk->flags |= GENHD_FL_REMOVABLE; 1062 disk->flags |= GENHD_FL_REMOVABLE;
1066 sprintf(disk->disk_name, "fd%d", i); 1063 sprintf(disk->disk_name, "fd%d", i);
1067 sprintf(disk->devfs_name, "floppy/%d", i);
1068 set_capacity(disk, 2880); 1064 set_capacity(disk, 2880);
1069 add_disk(disk); 1065 add_disk(disk);
1070 } 1066 }
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 2ae08b343b93..10a4aa5fb54d 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -18,7 +18,6 @@
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/blkdev.h> 19#include <linux/blkdev.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/devfs_fs_kernel.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23#include <linux/compiler.h> 22#include <linux/compiler.h>
24#include <linux/workqueue.h> 23#include <linux/workqueue.h>
@@ -1510,7 +1509,6 @@ static int carm_init_disks(struct carm_host *host)
1510 port->disk = disk; 1509 port->disk = disk;
1511 sprintf(disk->disk_name, DRV_NAME "/%u", 1510 sprintf(disk->disk_name, DRV_NAME "/%u",
1512 (unsigned int) (host->id * CARM_MAX_PORTS) + i); 1511 (unsigned int) (host->id * CARM_MAX_PORTS) + i);
1513 sprintf(disk->devfs_name, DRV_NAME "/%u_%u", host->id, i);
1514 disk->major = host->major; 1512 disk->major = host->major;
1515 disk->first_minor = i * CARM_MINORS_PER_MAJOR; 1513 disk->first_minor = i * CARM_MINORS_PER_MAJOR;
1516 disk->fops = &carm_bd_ops; 1514 disk->fops = &carm_bd_ops;
@@ -1672,8 +1670,6 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1672 if (host->flags & FL_DYN_MAJOR) 1670 if (host->flags & FL_DYN_MAJOR)
1673 host->major = rc; 1671 host->major = rc;
1674 1672
1675 devfs_mk_dir(DRV_NAME);
1676
1677 rc = carm_init_disks(host); 1673 rc = carm_init_disks(host);
1678 if (rc) 1674 if (rc)
1679 goto err_out_blkdev_disks; 1675 goto err_out_blkdev_disks;
@@ -1694,9 +1690,10 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1694 DPRINTK("waiting for probe_comp\n"); 1690 DPRINTK("waiting for probe_comp\n");
1695 wait_for_completion(&host->probe_comp); 1691 wait_for_completion(&host->probe_comp);
1696 1692
1697 printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n", 1693 printk(KERN_INFO "%s: pci %s, ports %d, io %llx, irq %u, major %d\n",
1698 host->name, pci_name(pdev), (int) CARM_MAX_PORTS, 1694 host->name, pci_name(pdev), (int) CARM_MAX_PORTS,
1699 pci_resource_start(pdev, 0), pdev->irq, host->major); 1695 (unsigned long long)pci_resource_start(pdev, 0),
1696 pdev->irq, host->major);
1700 1697
1701 carm_host_id++; 1698 carm_host_id++;
1702 pci_set_drvdata(pdev, host); 1699 pci_set_drvdata(pdev, host);
@@ -1738,7 +1735,6 @@ static void carm_remove_one (struct pci_dev *pdev)
1738 1735
1739 free_irq(pdev->irq, host); 1736 free_irq(pdev->irq, host);
1740 carm_free_disks(host); 1737 carm_free_disks(host);
1741 devfs_remove(DRV_NAME);
1742 unregister_blkdev(host->major, host->name); 1738 unregister_blkdev(host->major, host->name);
1743 if (host->major == 160) 1739 if (host->major == 160)
1744 clear_bit(0, &carm_major_alloc); 1740 clear_bit(0, &carm_major_alloc);
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 60e9a9457c6b..d62b49fbf10c 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -24,12 +24,10 @@
24#include <linux/usb.h> 24#include <linux/usb.h>
25#include <linux/usb_usual.h> 25#include <linux/usb_usual.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/devfs_fs_kernel.h>
28#include <linux/timer.h> 27#include <linux/timer.h>
29#include <scsi/scsi.h> 28#include <scsi/scsi.h>
30 29
31#define DRV_NAME "ub" 30#define DRV_NAME "ub"
32#define DEVFS_NAME DRV_NAME
33 31
34#define UB_MAJOR 180 32#define UB_MAJOR 180
35 33
@@ -2291,7 +2289,6 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
2291 goto err_diskalloc; 2289 goto err_diskalloc;
2292 2290
2293 sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a'); 2291 sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a');
2294 sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a');
2295 disk->major = UB_MAJOR; 2292 disk->major = UB_MAJOR;
2296 disk->first_minor = lun->id * UB_PARTS_PER_LUN; 2293 disk->first_minor = lun->id * UB_PARTS_PER_LUN;
2297 disk->fops = &ub_bd_fops; 2294 disk->fops = &ub_bd_fops;
@@ -2445,7 +2442,6 @@ static int __init ub_init(void)
2445 2442
2446 if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) 2443 if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0)
2447 goto err_regblkdev; 2444 goto err_regblkdev;
2448 devfs_mk_dir(DEVFS_NAME);
2449 2445
2450 if ((rc = usb_register(&ub_driver)) != 0) 2446 if ((rc = usb_register(&ub_driver)) != 0)
2451 goto err_register; 2447 goto err_register;
@@ -2454,7 +2450,6 @@ static int __init ub_init(void)
2454 return 0; 2450 return 0;
2455 2451
2456err_register: 2452err_register:
2457 devfs_remove(DEVFS_NAME);
2458 unregister_blkdev(UB_MAJOR, DRV_NAME); 2453 unregister_blkdev(UB_MAJOR, DRV_NAME);
2459err_regblkdev: 2454err_regblkdev:
2460 return rc; 2455 return rc;
@@ -2464,7 +2459,6 @@ static void __exit ub_exit(void)
2464{ 2459{
2465 usb_deregister(&ub_driver); 2460 usb_deregister(&ub_driver);
2466 2461
2467 devfs_remove(DEVFS_NAME);
2468 unregister_blkdev(UB_MAJOR, DRV_NAME); 2462 unregister_blkdev(UB_MAJOR, DRV_NAME);
2469 usb_usual_clear_present(USB_US_TYPE_UB); 2463 usb_usual_clear_present(USB_US_TYPE_UB);
2470} 2464}
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index f7d4c65a7b8c..585197b95af7 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -1192,7 +1192,6 @@ static int __init mm_init(void)
1192 for (i = 0; i < num_cards; i++) { 1192 for (i = 0; i < num_cards; i++) {
1193 struct gendisk *disk = mm_gendisk[i]; 1193 struct gendisk *disk = mm_gendisk[i];
1194 sprintf(disk->disk_name, "umem%c", 'a'+i); 1194 sprintf(disk->disk_name, "umem%c", 'a'+i);
1195 sprintf(disk->devfs_name, "umem/card%d", i);
1196 spin_lock_init(&cards[i].lock); 1195 spin_lock_init(&cards[i].lock);
1197 disk->major = major_nr; 1196 disk->major = major_nr;
1198 disk->first_minor = i << MM_SHIFT; 1197 disk->first_minor = i << MM_SHIFT;
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index b0df4f5ab97a..ec5a1b90a0a2 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -59,7 +59,6 @@ MODULE_LICENSE("GPL");
59 * numbers 0-255 we get a maximum of 32 disks. 59 * numbers 0-255 we get a maximum of 32 disks.
60 */ 60 */
61#define VIOD_GENHD_NAME "iseries/vd" 61#define VIOD_GENHD_NAME "iseries/vd"
62#define VIOD_GENHD_DEVFS_NAME "iseries/disc"
63 62
64#define VIOD_VERS "1.64" 63#define VIOD_VERS "1.64"
65 64
@@ -523,8 +522,6 @@ retry:
523 else 522 else
524 snprintf(g->disk_name, sizeof(g->disk_name), 523 snprintf(g->disk_name, sizeof(g->disk_name),
525 VIOD_GENHD_NAME "%c", 'a' + (dev_no % 26)); 524 VIOD_GENHD_NAME "%c", 'a' + (dev_no % 26));
526 snprintf(g->devfs_name, sizeof(g->devfs_name),
527 "%s%d", VIOD_GENHD_DEVFS_NAME, dev_no);
528 g->fops = &viodasd_fops; 525 g->fops = &viodasd_fops;
529 g->queue = q; 526 g->queue = q;
530 g->private_data = d; 527 g->private_data = d;
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index cbce7c5e9445..e828e4cbd3e1 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -215,7 +215,6 @@ static int __init xd_init(void)
215 disk->major = XT_DISK_MAJOR; 215 disk->major = XT_DISK_MAJOR;
216 disk->first_minor = i<<6; 216 disk->first_minor = i<<6;
217 sprintf(disk->disk_name, "xd%c", i+'a'); 217 sprintf(disk->disk_name, "xd%c", i+'a');
218 sprintf(disk->devfs_name, "xd/target%d", i);
219 disk->fops = &xd_fops; 218 disk->fops = &xd_fops;
220 disk->private_data = p; 219 disk->private_data = p;
221 disk->queue = xd_queue; 220 disk->queue = xd_queue;
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index bb5e8d665a2a..82ddbdd7bd4b 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -354,7 +354,6 @@ z2_init(void)
354 z2ram_gendisk->first_minor = 0; 354 z2ram_gendisk->first_minor = 0;
355 z2ram_gendisk->fops = &z2_fops; 355 z2ram_gendisk->fops = &z2_fops;
356 sprintf(z2ram_gendisk->disk_name, "z2ram"); 356 sprintf(z2ram_gendisk->disk_name, "z2ram");
357 strcpy(z2ram_gendisk->devfs_name, z2ram_gendisk->disk_name);
358 357
359 z2ram_gendisk->queue = z2_queue; 358 z2ram_gendisk->queue = z2_queue;
360 add_disk(z2ram_gendisk); 359 add_disk(z2ram_gendisk);
diff --git a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c
index ec004897b634..ec469497c10f 100644
--- a/drivers/cdrom/aztcd.c
+++ b/drivers/cdrom/aztcd.c
@@ -1918,7 +1918,6 @@ static int __init aztcd_init(void)
1918 azt_disk->first_minor = 0; 1918 azt_disk->first_minor = 0;
1919 azt_disk->fops = &azt_fops; 1919 azt_disk->fops = &azt_fops;
1920 sprintf(azt_disk->disk_name, "aztcd"); 1920 sprintf(azt_disk->disk_name, "aztcd");
1921 sprintf(azt_disk->devfs_name, "aztcd");
1922 azt_disk->queue = azt_queue; 1921 azt_disk->queue = azt_queue;
1923 add_disk(azt_disk); 1922 add_disk(azt_disk);
1924 azt_invalidate_buffers(); 1923 azt_invalidate_buffers();
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
index 72ffd64e8b1e..5f0f2027f29e 100644
--- a/drivers/cdrom/cdu31a.c
+++ b/drivers/cdrom/cdu31a.c
@@ -161,7 +161,6 @@
161#include <linux/hdreg.h> 161#include <linux/hdreg.h>
162#include <linux/genhd.h> 162#include <linux/genhd.h>
163#include <linux/ioport.h> 163#include <linux/ioport.h>
164#include <linux/devfs_fs_kernel.h>
165#include <linux/string.h> 164#include <linux/string.h>
166#include <linux/slab.h> 165#include <linux/slab.h>
167#include <linux/init.h> 166#include <linux/init.h>
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
index f43a988dd413..4ee288688fed 100644
--- a/drivers/cdrom/cm206.c
+++ b/drivers/cdrom/cm206.c
@@ -187,7 +187,6 @@ History:
187#include <linux/interrupt.h> 187#include <linux/interrupt.h>
188#include <linux/timer.h> 188#include <linux/timer.h>
189#include <linux/cdrom.h> 189#include <linux/cdrom.h>
190#include <linux/devfs_fs_kernel.h>
191#include <linux/ioport.h> 190#include <linux/ioport.h>
192#include <linux/mm.h> 191#include <linux/mm.h>
193#include <linux/slab.h> 192#include <linux/slab.h>
diff --git a/drivers/cdrom/gscd.c b/drivers/cdrom/gscd.c
index ad5464ab99bc..b6ee50a2916d 100644
--- a/drivers/cdrom/gscd.c
+++ b/drivers/cdrom/gscd.c
@@ -955,7 +955,6 @@ static int __init gscd_init(void)
955 gscd_disk->first_minor = 0; 955 gscd_disk->first_minor = 0;
956 gscd_disk->fops = &gscd_fops; 956 gscd_disk->fops = &gscd_fops;
957 sprintf(gscd_disk->disk_name, "gscd"); 957 sprintf(gscd_disk->disk_name, "gscd");
958 sprintf(gscd_disk->devfs_name, "gscd");
959 958
960 if (register_blkdev(MAJOR_NR, "gscd")) { 959 if (register_blkdev(MAJOR_NR, "gscd")) {
961 ret = -EIO; 960 ret = -EIO;
diff --git a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
index 0f6e7aab8d2c..788c7a0b2fe3 100644
--- a/drivers/cdrom/mcdx.c
+++ b/drivers/cdrom/mcdx.c
@@ -74,7 +74,6 @@ static const char *mcdx_c_version
74#include <linux/major.h> 74#include <linux/major.h>
75#define MAJOR_NR MITSUMI_X_CDROM_MAJOR 75#define MAJOR_NR MITSUMI_X_CDROM_MAJOR
76#include <linux/blkdev.h> 76#include <linux/blkdev.h>
77#include <linux/devfs_fs_kernel.h>
78 77
79#include "mcdx.h" 78#include "mcdx.h"
80 79
diff --git a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c
index 0b0eab4f40fa..25032d7edc55 100644
--- a/drivers/cdrom/optcd.c
+++ b/drivers/cdrom/optcd.c
@@ -2033,7 +2033,6 @@ static int __init optcd_init(void)
2033 optcd_disk->first_minor = 0; 2033 optcd_disk->first_minor = 0;
2034 optcd_disk->fops = &opt_fops; 2034 optcd_disk->fops = &opt_fops;
2035 sprintf(optcd_disk->disk_name, "optcd"); 2035 sprintf(optcd_disk->disk_name, "optcd");
2036 sprintf(optcd_disk->devfs_name, "optcd");
2037 2036
2038 if (!request_region(optcd_port, 4, "optcd")) { 2037 if (!request_region(optcd_port, 4, "optcd")) {
2039 printk(KERN_ERR "optcd: conflict, I/O port 0x%x already used\n", 2038 printk(KERN_ERR "optcd: conflict, I/O port 0x%x already used\n",
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index 05c9e865ecaf..2fc966c65a0e 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -371,7 +371,6 @@
371#include <linux/kernel.h> 371#include <linux/kernel.h>
372#include <linux/cdrom.h> 372#include <linux/cdrom.h>
373#include <linux/ioport.h> 373#include <linux/ioport.h>
374#include <linux/devfs_fs_kernel.h>
375#include <linux/major.h> 374#include <linux/major.h>
376#include <linux/string.h> 375#include <linux/string.h>
377#include <linux/vmalloc.h> 376#include <linux/vmalloc.h>
@@ -5808,8 +5807,6 @@ int __init sbpcd_init(void)
5808 return -ENOMEM; 5807 return -ENOMEM;
5809 } 5808 }
5810 5809
5811 devfs_mk_dir("sbp");
5812
5813 for (j=0;j<NR_SBPCD;j++) 5810 for (j=0;j<NR_SBPCD;j++)
5814 { 5811 {
5815 struct cdrom_device_info * sbpcd_infop; 5812 struct cdrom_device_info * sbpcd_infop;
@@ -5871,7 +5868,6 @@ int __init sbpcd_init(void)
5871 disk->fops = &sbpcd_bdops; 5868 disk->fops = &sbpcd_bdops;
5872 strcpy(disk->disk_name, sbpcd_infop->name); 5869 strcpy(disk->disk_name, sbpcd_infop->name);
5873 disk->flags = GENHD_FL_CD; 5870 disk->flags = GENHD_FL_CD;
5874 sprintf(disk->devfs_name, "sbp/c0t%d", p->drv_id);
5875 p->disk = disk; 5871 p->disk = disk;
5876 if (register_cdrom(sbpcd_infop)) 5872 if (register_cdrom(sbpcd_infop))
5877 { 5873 {
@@ -5906,7 +5902,6 @@ static void sbpcd_exit(void)
5906 if (D_S[j].drv_id==-1) continue; 5902 if (D_S[j].drv_id==-1) continue;
5907 del_gendisk(D_S[j].disk); 5903 del_gendisk(D_S[j].disk);
5908 put_disk(D_S[j].disk); 5904 put_disk(D_S[j].disk);
5909 devfs_remove("sbp/c0t%d", j);
5910 vfree(D_S[j].sbp_buf); 5905 vfree(D_S[j].sbp_buf);
5911 if (D_S[j].sbp_audsiz>0) 5906 if (D_S[j].sbp_audsiz>0)
5912 vfree(D_S[j].aud_buf); 5907 vfree(D_S[j].aud_buf);
@@ -5917,7 +5912,6 @@ static void sbpcd_exit(void)
5917 } 5912 }
5918 vfree(D_S[j].sbpcd_infop); 5913 vfree(D_S[j].sbpcd_infop);
5919 } 5914 }
5920 devfs_remove("sbp");
5921 msg(DBG_INF, "%s module released.\n", major_name); 5915 msg(DBG_INF, "%s module released.\n", major_name);
5922} 5916}
5923 5917
diff --git a/drivers/cdrom/sjcd.c b/drivers/cdrom/sjcd.c
index 74b1cadbf161..bf5aef4e555b 100644
--- a/drivers/cdrom/sjcd.c
+++ b/drivers/cdrom/sjcd.c
@@ -1695,7 +1695,6 @@ static int __init sjcd_init(void)
1695 sjcd_disk->first_minor = 0, 1695 sjcd_disk->first_minor = 0,
1696 sjcd_disk->fops = &sjcd_fops, 1696 sjcd_disk->fops = &sjcd_fops,
1697 sprintf(sjcd_disk->disk_name, "sjcd"); 1697 sprintf(sjcd_disk->disk_name, "sjcd");
1698 sprintf(sjcd_disk->devfs_name, "sjcd");
1699 1698
1700 if (!request_region(sjcd_base, 4,"sjcd")) { 1699 if (!request_region(sjcd_base, 4,"sjcd")) {
1701 printk 1700 printk
diff --git a/drivers/cdrom/sonycd535.c b/drivers/cdrom/sonycd535.c
index e65659926432..8f7cc452af8d 100644
--- a/drivers/cdrom/sonycd535.c
+++ b/drivers/cdrom/sonycd535.c
@@ -1589,7 +1589,6 @@ static int __init sony535_init(void)
1589 cdu_disk->first_minor = 0; 1589 cdu_disk->first_minor = 0;
1590 cdu_disk->fops = &cdu_fops; 1590 cdu_disk->fops = &cdu_fops;
1591 sprintf(cdu_disk->disk_name, "cdu"); 1591 sprintf(cdu_disk->disk_name, "cdu");
1592 sprintf(cdu_disk->devfs_name, "cdu535");
1593 1592
1594 if (!request_region(sony535_cd_base_io, 4, CDU535_HANDLE)) { 1593 if (!request_region(sony535_cd_base_io, 4, CDU535_HANDLE)) {
1595 printk(KERN_WARNING"sonycd535: Unable to request region 0x%x\n", 1594 printk(KERN_WARNING"sonycd535: Unable to request region 0x%x\n",
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index af6b3bfd169b..54ca931e19ea 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -49,7 +49,6 @@
49#include <asm/iseries/vio.h> 49#include <asm/iseries/vio.h>
50 50
51#define VIOCD_DEVICE "iseries/vcd" 51#define VIOCD_DEVICE "iseries/vcd"
52#define VIOCD_DEVICE_DEVFS "iseries/vcd"
53 52
54#define VIOCD_VERS "1.06" 53#define VIOCD_VERS "1.06"
55 54
@@ -688,8 +687,6 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
688 gendisk->first_minor = deviceno; 687 gendisk->first_minor = deviceno;
689 strncpy(gendisk->disk_name, c->name, 688 strncpy(gendisk->disk_name, c->name,
690 sizeof(gendisk->disk_name)); 689 sizeof(gendisk->disk_name));
691 snprintf(gendisk->devfs_name, sizeof(gendisk->devfs_name),
692 VIOCD_DEVICE_DEVFS "%d", deviceno);
693 blk_queue_max_hw_segments(q, 1); 690 blk_queue_max_hw_segments(q, 1);
694 blk_queue_max_phys_segments(q, 1); 691 blk_queue_max_phys_segments(q, 1);
695 blk_queue_max_sectors(q, 4096 / 512); 692 blk_queue_max_sectors(q, 4096 / 512);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 3610c5729553..c40e487d9f5c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -939,12 +939,36 @@ config MWAVE
939config SCx200_GPIO 939config SCx200_GPIO
940 tristate "NatSemi SCx200 GPIO Support" 940 tristate "NatSemi SCx200 GPIO Support"
941 depends on SCx200 941 depends on SCx200
942 select NSC_GPIO
942 help 943 help
943 Give userspace access to the GPIO pins on the National 944 Give userspace access to the GPIO pins on the National
944 Semiconductor SCx200 processors. 945 Semiconductor SCx200 processors.
945 946
946 If compiled as a module, it will be called scx200_gpio. 947 If compiled as a module, it will be called scx200_gpio.
947 948
949config PC8736x_GPIO
950 tristate "NatSemi PC8736x GPIO Support"
951 depends on X86
952 default SCx200_GPIO # mostly N
953 select NSC_GPIO # needed for support routines
954 help
955 Give userspace access to the GPIO pins on the National
956 Semiconductor PC-8736x (x=[03456]) SuperIO chip. The chip
957 has multiple functional units, inc several managed by
958 hwmon/pc87360 driver. Tested with PC-87366
959
960 If compiled as a module, it will be called pc8736x_gpio.
961
962config NSC_GPIO
963 tristate "NatSemi Base GPIO Support"
964 depends on X86_32
965 # selected by SCx200_GPIO and PC8736x_GPIO
966 # what about 2 selectors differing: m != y
967 help
968 Common support used (and needed) by scx200_gpio and
969 pc8736x_gpio drivers. If those drivers are built as
970 modules, this one will be too, named nsc_gpio
971
948config CS5535_GPIO 972config CS5535_GPIO
949 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)" 973 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)"
950 depends on X86_32 974 depends on X86_32
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 524105597ea7..6e0f4469d8bb 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -82,6 +82,8 @@ obj-$(CONFIG_PPDEV) += ppdev.o
82obj-$(CONFIG_NWBUTTON) += nwbutton.o 82obj-$(CONFIG_NWBUTTON) += nwbutton.o
83obj-$(CONFIG_NWFLASH) += nwflash.o 83obj-$(CONFIG_NWFLASH) += nwflash.o
84obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 84obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
85obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
86obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
85obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o 87obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
86obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o 88obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
87obj-$(CONFIG_TANBAC_TB0219) += tb0219.o 89obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 9826a399fa02..22f8cf218cc6 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -1,6 +1,7 @@
1config AGP 1config AGP
2 tristate "/dev/agpgart (AGP Support)" 2 tristate "/dev/agpgart (AGP Support)"
3 depends on ALPHA || IA64 || PPC || X86 3 depends on ALPHA || IA64 || PPC || X86
4 depends on PCI
4 ---help--- 5 ---help---
5 AGP (Accelerated Graphics Port) is a bus system mainly used to 6 AGP (Accelerated Graphics Port) is a bus system mainly used to
6 connect graphics cards to the rest of the system. 7 connect graphics cards to the rest of the system.
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index f690ee8cb732..f74eeeb8e377 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -734,7 +734,7 @@ int __init agp_amd64_init(void)
734 734
735 if (agp_off) 735 if (agp_off)
736 return -EINVAL; 736 return -EINVAL;
737 if (pci_register_driver(&agp_amd64_pci_driver) > 0) { 737 if (pci_register_driver(&agp_amd64_pci_driver) < 0) {
738 struct pci_dev *dev; 738 struct pci_dev *dev;
739 if (!agp_try_unsupported && !agp_try_unsupported_boot) { 739 if (!agp_try_unsupported && !agp_try_unsupported_boot) {
740 printk(KERN_INFO PFX "No supported AGP bridge found.\n"); 740 printk(KERN_INFO PFX "No supported AGP bridge found.\n");
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 160564345993..f244c6682738 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -41,7 +41,6 @@ static struct gatt_mask ati_generic_masks[] =
41}; 41};
42 42
43 43
44
45typedef struct _ati_page_map { 44typedef struct _ati_page_map {
46 unsigned long *real; 45 unsigned long *real;
47 unsigned long __iomem *remapped; 46 unsigned long __iomem *remapped;
@@ -141,7 +140,8 @@ static int ati_create_gatt_pages(int nr_tables)
141 ati_generic_private.num_tables = nr_tables; 140 ati_generic_private.num_tables = nr_tables;
142 ati_generic_private.gatt_pages = tables; 141 ati_generic_private.gatt_pages = tables;
143 142
144 if (retval != 0) ati_free_gatt_pages(); 143 if (retval != 0)
144 ati_free_gatt_pages();
145 145
146 return retval; 146 return retval;
147} 147}
@@ -219,16 +219,16 @@ static int ati_configure(void)
219 ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); 219 ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
220 220
221 if (is_r200()) 221 if (is_r200())
222 pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000); 222 pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000);
223 else 223 else
224 pci_write_config_dword(agp_bridge->dev, ATI_RS300_IG_AGPMODE, 0x20000); 224 pci_write_config_dword(agp_bridge->dev, ATI_RS300_IG_AGPMODE, 0x20000);
225 225
226 /* address to map too */ 226 /* address to map too */
227 /* 227 /*
228 pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp); 228 pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp);
229 agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 229 agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
230 printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr); 230 printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
231 */ 231 */
232 writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID); 232 writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID);
233 readl(ati_generic_private.registers+ATI_GART_FEATURE_ID); /* PCI Posting.*/ 233 readl(ati_generic_private.registers+ATI_GART_FEATURE_ID); /* PCI Posting.*/
234 234
@@ -245,18 +245,20 @@ static int ati_configure(void)
245 245
246 246
247#ifdef CONFIG_PM 247#ifdef CONFIG_PM
248static int agp_ati_resume(struct pci_dev *dev) 248static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state)
249{ 249{
250 pci_restore_state(dev); 250 pci_save_state(dev);
251 pci_set_power_state(dev, 3);
251 252
252 return ati_configure(); 253 return 0;
253} 254}
254 255
255static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state) 256static int agp_ati_resume(struct pci_dev *dev)
256{ 257{
257 pci_save_state(dev); 258 pci_set_power_state(dev, 0);
259 pci_restore_state(dev);
258 260
259 return 0; 261 return ati_configure();
260} 262}
261#endif 263#endif
262 264
@@ -321,9 +323,9 @@ static int ati_remove_memory(struct agp_memory * mem, off_t pg_start,
321 unsigned long __iomem *cur_gatt; 323 unsigned long __iomem *cur_gatt;
322 unsigned long addr; 324 unsigned long addr;
323 325
324 if (type != 0 || mem->type != 0) { 326 if (type != 0 || mem->type != 0)
325 return -EINVAL; 327 return -EINVAL;
326 } 328
327 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 329 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
328 addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr; 330 addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr;
329 cur_gatt = GET_GATT(addr); 331 cur_gatt = GET_GATT(addr);
@@ -502,9 +504,8 @@ found:
502 504
503 bridge->dev = pdev; 505 bridge->dev = pdev;
504 bridge->capndx = cap_ptr; 506 bridge->capndx = cap_ptr;
505
506 bridge->driver = &ati_generic_bridge;
507 507
508 bridge->driver = &ati_generic_bridge;
508 509
509 printk(KERN_INFO PFX "Detected Ati %s chipset\n", 510 printk(KERN_INFO PFX "Detected Ati %s chipset\n",
510 devs[j].chipset_name); 511 devs[j].chipset_name);
@@ -546,8 +547,8 @@ static struct pci_driver agp_ati_pci_driver = {
546 .probe = agp_ati_probe, 547 .probe = agp_ati_probe,
547 .remove = agp_ati_remove, 548 .remove = agp_ati_remove,
548#ifdef CONFIG_PM 549#ifdef CONFIG_PM
549 .resume = agp_ati_resume,
550 .suspend = agp_ati_suspend, 550 .suspend = agp_ati_suspend,
551 .resume = agp_ati_resume,
551#endif 552#endif
552}; 553};
553 554
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 4c67135c12d8..df7f37b2739a 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -376,6 +376,29 @@ static void __devexit agp_nvidia_remove(struct pci_dev *pdev)
376 agp_put_bridge(bridge); 376 agp_put_bridge(bridge);
377} 377}
378 378
379#ifdef CONFIG_PM
380static int agp_nvidia_suspend(struct pci_dev *pdev, pm_message_t state)
381{
382 pci_save_state (pdev);
383 pci_set_power_state (pdev, 3);
384
385 return 0;
386}
387
388static int agp_nvidia_resume(struct pci_dev *pdev)
389{
390 /* set power state 0 and restore PCI space */
391 pci_set_power_state (pdev, 0);
392 pci_restore_state(pdev);
393
394 /* reconfigure AGP hardware again */
395 nvidia_configure();
396
397 return 0;
398}
399#endif
400
401
379static struct pci_device_id agp_nvidia_pci_table[] = { 402static struct pci_device_id agp_nvidia_pci_table[] = {
380 { 403 {
381 .class = (PCI_CLASS_BRIDGE_HOST << 8), 404 .class = (PCI_CLASS_BRIDGE_HOST << 8),
@@ -403,6 +426,10 @@ static struct pci_driver agp_nvidia_pci_driver = {
403 .id_table = agp_nvidia_pci_table, 426 .id_table = agp_nvidia_pci_table,
404 .probe = agp_nvidia_probe, 427 .probe = agp_nvidia_probe,
405 .remove = agp_nvidia_remove, 428 .remove = agp_nvidia_remove,
429#ifdef CONFIG_PM
430 .suspend = agp_nvidia_suspend,
431 .resume = agp_nvidia_resume,
432#endif
406}; 433};
407 434
408static int __init agp_nvidia_init(void) 435static int __init agp_nvidia_init(void)
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index cfa7922cb431..d73be4c2db8a 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void)
329 329
330static void __devexit agp_sgi_cleanup(void) 330static void __devexit agp_sgi_cleanup(void)
331{ 331{
332 if (sgi_tioca_agp_bridges) 332 kfree(sgi_tioca_agp_bridges);
333 kfree(sgi_tioca_agp_bridges); 333 sgi_tioca_agp_bridges = NULL;
334 sgi_tioca_agp_bridges=NULL;
335} 334}
336 335
337module_init(agp_sgi_init); 336module_init(agp_sgi_init);
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index 9275d5e52e6d..72fb60765c45 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -209,13 +209,16 @@ static int __init applicom_init(void)
209 RamIO = ioremap(dev->resource[0].start, LEN_RAM_IO); 209 RamIO = ioremap(dev->resource[0].start, LEN_RAM_IO);
210 210
211 if (!RamIO) { 211 if (!RamIO) {
212 printk(KERN_INFO "ac.o: Failed to ioremap PCI memory space at 0x%lx\n", dev->resource[0].start); 212 printk(KERN_INFO "ac.o: Failed to ioremap PCI memory "
213 "space at 0x%llx\n",
214 (unsigned long long)dev->resource[0].start);
213 pci_disable_device(dev); 215 pci_disable_device(dev);
214 return -EIO; 216 return -EIO;
215 } 217 }
216 218
217 printk(KERN_INFO "Applicom %s found at mem 0x%lx, irq %d\n", 219 printk(KERN_INFO "Applicom %s found at mem 0x%llx, irq %d\n",
218 applicom_pci_devnames[dev->device-1], dev->resource[0].start, 220 applicom_pci_devnames[dev->device-1],
221 (unsigned long long)dev->resource[0].start,
219 dev->irq); 222 dev->irq);
220 223
221 boardno = ac_register_board(dev->resource[0].start, RamIO,0); 224 boardno = ac_register_board(dev->resource[0].start, RamIO,0);
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 122e7a72a4e1..2657eeba7da6 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -5250,7 +5250,6 @@ cy_init(void)
5250 cy_serial_driver->owner = THIS_MODULE; 5250 cy_serial_driver->owner = THIS_MODULE;
5251 cy_serial_driver->driver_name = "cyclades"; 5251 cy_serial_driver->driver_name = "cyclades";
5252 cy_serial_driver->name = "ttyC"; 5252 cy_serial_driver->name = "ttyC";
5253 cy_serial_driver->devfs_name = "tts/C";
5254 cy_serial_driver->major = CYCLADES_MAJOR; 5253 cy_serial_driver->major = CYCLADES_MAJOR;
5255 cy_serial_driver->minor_start = 0; 5254 cy_serial_driver->minor_start = 0;
5256 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 5255 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h
index 6543b9a14c42..d117cc997192 100644
--- a/drivers/char/drm/drm_memory_debug.h
+++ b/drivers/char/drm/drm_memory_debug.h
@@ -43,7 +43,7 @@ typedef struct drm_mem_stats {
43 unsigned long bytes_freed; 43 unsigned long bytes_freed;
44} drm_mem_stats_t; 44} drm_mem_stats_t;
45 45
46static spinlock_t drm_mem_lock = SPIN_LOCK_UNLOCKED; 46static DEFINE_SPINLOCK(drm_mem_lock);
47static unsigned long drm_ram_available = 0; /* In pages */ 47static unsigned long drm_ram_available = 0; /* In pages */
48static unsigned long drm_ram_used = 0; 48static unsigned long drm_ram_used = 0;
49static drm_mem_stats_t drm_mem_stats[] = 49static drm_mem_stats_t drm_mem_stats[] =
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index b7f17457b424..78a81a4a99c5 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -557,7 +557,7 @@ via_init_dmablit(drm_device_t *dev)
557 blitq->num_outstanding = 0; 557 blitq->num_outstanding = 0;
558 blitq->is_active = 0; 558 blitq->is_active = 0;
559 blitq->aborting = 0; 559 blitq->aborting = 0;
560 blitq->blit_lock = SPIN_LOCK_UNLOCKED; 560 spin_lock_init(&blitq->blit_lock);
561 for (j=0; j<VIA_NUM_BLIT_SLOTS; ++j) { 561 for (j=0; j<VIA_NUM_BLIT_SLOTS; ++j) {
562 DRM_INIT_WAITQUEUE(blitq->blit_queue + j); 562 DRM_INIT_WAITQUEUE(blitq->blit_queue + j);
563 } 563 }
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index e233cf280bc0..09b413618b57 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -33,7 +33,6 @@
33#include <linux/fs.h> 33#include <linux/fs.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/devfs_fs_kernel.h>
37#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
38#include <linux/device.h> 37#include <linux/device.h>
39 38
@@ -518,17 +517,9 @@ static int __init dsp56k_init_driver(void)
518 } 517 }
519 class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); 518 class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
520 519
521 err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
522 S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
523 if(err)
524 goto out_class;
525
526 printk(banner); 520 printk(banner);
527 goto out; 521 goto out;
528 522
529out_class:
530 class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
531 class_destroy(dsp56k_class);
532out_chrdev: 523out_chrdev:
533 unregister_chrdev(DSP56K_MAJOR, "dsp56k"); 524 unregister_chrdev(DSP56K_MAJOR, "dsp56k");
534out: 525out:
@@ -541,7 +532,6 @@ static void __exit dsp56k_cleanup_driver(void)
541 class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); 532 class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
542 class_destroy(dsp56k_class); 533 class_destroy(dsp56k_class);
543 unregister_chrdev(DSP56K_MAJOR, "dsp56k"); 534 unregister_chrdev(DSP56K_MAJOR, "dsp56k");
544 devfs_remove("dsp56k");
545} 535}
546module_exit(dsp56k_cleanup_driver); 536module_exit(dsp56k_cleanup_driver);
547 537
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 87dcaa237f07..da2c89f1b8bc 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -62,7 +62,6 @@
62#include <linux/init.h> /* for __init, module_{init,exit} */ 62#include <linux/init.h> /* for __init, module_{init,exit} */
63#include <linux/poll.h> /* for POLLIN, etc. */ 63#include <linux/poll.h> /* for POLLIN, etc. */
64#include <linux/dtlk.h> /* local header file for DoubleTalk values */ 64#include <linux/dtlk.h> /* local header file for DoubleTalk values */
65#include <linux/devfs_fs_kernel.h>
66#include <linux/smp_lock.h> 65#include <linux/smp_lock.h>
67 66
68#ifdef TRACING 67#ifdef TRACING
@@ -337,9 +336,6 @@ static int __init dtlk_init(void)
337 if (dtlk_dev_probe() == 0) 336 if (dtlk_dev_probe() == 0)
338 printk(", MAJOR %d\n", dtlk_major); 337 printk(", MAJOR %d\n", dtlk_major);
339 338
340 devfs_mk_cdev(MKDEV(dtlk_major, DTLK_MINOR),
341 S_IFCHR | S_IRUSR | S_IWUSR, "dtlk");
342
343 init_timer(&dtlk_timer); 339 init_timer(&dtlk_timer);
344 dtlk_timer.function = dtlk_timer_tick; 340 dtlk_timer.function = dtlk_timer_tick;
345 init_waitqueue_head(&dtlk_process_list); 341 init_waitqueue_head(&dtlk_process_list);
@@ -357,7 +353,6 @@ static void __exit dtlk_cleanup (void)
357 353
358 dtlk_write_tts(DTLK_CLEAR); 354 dtlk_write_tts(DTLK_CLEAR);
359 unregister_chrdev(dtlk_major, "dtlk"); 355 unregister_chrdev(dtlk_major, "dtlk");
360 devfs_remove("dtlk");
361 release_region(dtlk_port_lpc, DTLK_IO_EXTENT); 356 release_region(dtlk_port_lpc, DTLK_IO_EXTENT);
362} 357}
363 358
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 9cad8501d62c..d0b3890d9302 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -80,7 +80,7 @@ static int invalid_lilo_config;
80/* The ISA boards do window flipping into the same spaces so its only sane 80/* The ISA boards do window flipping into the same spaces so its only sane
81 with a single lock. It's still pretty efficient */ 81 with a single lock. It's still pretty efficient */
82 82
83static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED; 83static DEFINE_SPINLOCK(epca_lock);
84 84
85/* ----------------------------------------------------------------------- 85/* -----------------------------------------------------------------------
86 MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 86 MAXBOARDS is typically 12, but ISA and EISA cards are restricted to
@@ -1232,7 +1232,6 @@ static int __init pc_init(void)
1232 1232
1233 pc_driver->owner = THIS_MODULE; 1233 pc_driver->owner = THIS_MODULE;
1234 pc_driver->name = "ttyD"; 1234 pc_driver->name = "ttyD";
1235 pc_driver->devfs_name = "tts/D";
1236 pc_driver->major = DIGI_MAJOR; 1235 pc_driver->major = DIGI_MAJOR;
1237 pc_driver->minor_start = 0; 1236 pc_driver->minor_start = 0;
1238 pc_driver->type = TTY_DRIVER_TYPE_SERIAL; 1237 pc_driver->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 922174d527ae..9827d170ca17 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -2449,7 +2449,6 @@ static int __init espserial_init(void)
2449 2449
2450 esp_driver->owner = THIS_MODULE; 2450 esp_driver->owner = THIS_MODULE;
2451 esp_driver->name = "ttyP"; 2451 esp_driver->name = "ttyP";
2452 esp_driver->devfs_name = "tts/P";
2453 esp_driver->major = ESP_IN_MAJOR; 2452 esp_driver->major = ESP_IN_MAJOR;
2454 esp_driver->minor_start = 0; 2453 esp_driver->minor_start = 0;
2455 esp_driver->type = TTY_DRIVER_TYPE_SERIAL; 2454 esp_driver->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
index 821357ce7e0e..3eeb869a9a11 100644
--- a/drivers/char/ftape/zftape/zftape-init.c
+++ b/drivers/char/ftape/zftape/zftape-init.c
@@ -33,7 +33,6 @@
33#endif 33#endif
34#include <linux/fcntl.h> 34#include <linux/fcntl.h>
35#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
36#include <linux/devfs_fs_kernel.h>
37 36
38#include <linux/zftape.h> 37#include <linux/zftape.h>
39#include <linux/init.h> 38#include <linux/init.h>
@@ -332,29 +331,11 @@ KERN_INFO
332 zft_class = class_create(THIS_MODULE, "zft"); 331 zft_class = class_create(THIS_MODULE, "zft");
333 for (i = 0; i < 4; i++) { 332 for (i = 0; i < 4; i++) {
334 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i); 333 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
335 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
336 S_IFCHR | S_IRUSR | S_IWUSR,
337 "qft%i", i);
338 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i); 334 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
339 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
340 S_IFCHR | S_IRUSR | S_IWUSR,
341 "nqft%i", i);
342 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i); 335 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
343 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
344 S_IFCHR | S_IRUSR | S_IWUSR,
345 "zqft%i", i);
346 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i); 336 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
347 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
348 S_IFCHR | S_IRUSR | S_IWUSR,
349 "nzqft%i", i);
350 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i); 337 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
351 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
352 S_IFCHR | S_IRUSR | S_IWUSR,
353 "rawqft%i", i);
354 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i); 338 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
355 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
356 S_IFCHR | S_IRUSR | S_IWUSR,
357 "nrawqft%i", i);
358 } 339 }
359 340
360#ifdef CONFIG_ZFT_COMPRESSOR 341#ifdef CONFIG_ZFT_COMPRESSOR
@@ -380,17 +361,11 @@ static void zft_exit(void)
380 TRACE(ft_t_info, "successful"); 361 TRACE(ft_t_info, "successful");
381 } 362 }
382 for (i = 0; i < 4; i++) { 363 for (i = 0; i < 4; i++) {
383 devfs_remove("qft%i", i);
384 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i)); 364 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i));
385 devfs_remove("nqft%i", i);
386 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4)); 365 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4));
387 devfs_remove("zqft%i", i);
388 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16)); 366 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16));
389 devfs_remove("nzqft%i", i);
390 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20)); 367 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20));
391 devfs_remove("rawqft%i", i);
392 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32)); 368 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32));
393 devfs_remove("nrawqft%i", i);
394 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36)); 369 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36));
395 } 370 }
396 class_destroy(zft_class); 371 class_destroy(zft_class);
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index a5c6a9d7ff08..6e380aecea6a 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -820,7 +820,6 @@ int __init hvc_init(void)
820 return -ENOMEM; 820 return -ENOMEM;
821 821
822 drv->owner = THIS_MODULE; 822 drv->owner = THIS_MODULE;
823 drv->devfs_name = "hvc/";
824 drv->driver_name = "hvc"; 823 drv->driver_name = "hvc";
825 drv->name = "hvc"; 824 drv->name = "hvc";
826 drv->major = HVC_MAJOR; 825 drv->major = HVC_MAJOR;
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 8d97b3911293..130dedc37568 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = {
1320static int hvcs_alloc_index_list(int n) 1320static int hvcs_alloc_index_list(int n)
1321{ 1321{
1322 int i; 1322 int i;
1323
1323 hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL); 1324 hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
1324 if (!hvcs_index_list) 1325 if (!hvcs_index_list)
1325 return -ENOMEM; 1326 return -ENOMEM;
1326 hvcs_index_count = n; 1327 hvcs_index_count = n;
1327 for(i = 0; i < hvcs_index_count; i++) 1328 for (i = 0; i < hvcs_index_count; i++)
1328 hvcs_index_list[i] = -1; 1329 hvcs_index_list[i] = -1;
1329 return 0; 1330 return 0;
1330} 1331}
@@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n)
1332static void hvcs_free_index_list(void) 1333static void hvcs_free_index_list(void)
1333{ 1334{
1334 /* Paranoia check to be thorough. */ 1335 /* Paranoia check to be thorough. */
1335 if (hvcs_index_list) { 1336 kfree(hvcs_index_list);
1336 kfree(hvcs_index_list); 1337 hvcs_index_list = NULL;
1337 hvcs_index_list = NULL; 1338 hvcs_index_count = 0;
1338 hvcs_index_count = 0;
1339 }
1340} 1339}
1341 1340
1342static int __init hvcs_module_init(void) 1341static int __init hvcs_module_init(void)
@@ -1364,7 +1363,6 @@ static int __init hvcs_module_init(void)
1364 1363
1365 hvcs_tty_driver->driver_name = hvcs_driver_name; 1364 hvcs_tty_driver->driver_name = hvcs_driver_name;
1366 hvcs_tty_driver->name = hvcs_device_node; 1365 hvcs_tty_driver->name = hvcs_device_node;
1367 hvcs_tty_driver->devfs_name = hvcs_device_node;
1368 1366
1369 /* 1367 /*
1370 * We'll let the system assign us a major number, indicated by leaving 1368 * We'll let the system assign us a major number, indicated by leaving
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index a0370ed752ce..7b04eb153205 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -1154,7 +1154,6 @@ static int __init hvsi_init(void)
1154 return -ENOMEM; 1154 return -ENOMEM;
1155 1155
1156 hvsi_driver->owner = THIS_MODULE; 1156 hvsi_driver->owner = THIS_MODULE;
1157 hvsi_driver->devfs_name = "hvsi/";
1158 hvsi_driver->driver_name = "hvsi"; 1157 hvsi_driver->driver_name = "hvsi";
1159 hvsi_driver->name = "hvsi"; 1158 hvsi_driver->name = "hvsi";
1160 hvsi_driver->major = HVSI_MAJOR; 1159 hvsi_driver->major = HVSI_MAJOR;
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 9ab33c3d359f..8619542766cb 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -91,7 +91,6 @@
91#include <linux/module.h> 91#include <linux/module.h>
92#include <linux/signal.h> 92#include <linux/signal.h>
93#include <linux/sched.h> 93#include <linux/sched.h>
94#include <linux/devfs_fs_kernel.h>
95#include <linux/timer.h> 94#include <linux/timer.h>
96#include <linux/interrupt.h> 95#include <linux/interrupt.h>
97#include <linux/pci.h> 96#include <linux/pci.h>
@@ -414,9 +413,7 @@ cleanup_module(void)
414 /* free io addresses and Tibet */ 413 /* free io addresses and Tibet */
415 release_region( ip2config.addr[i], 8 ); 414 release_region( ip2config.addr[i], 8 );
416 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i)); 415 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
417 devfs_remove("ip2/ipl%d", i);
418 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1)); 416 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
419 devfs_remove("ip2/stat%d", i);
420 } 417 }
421 /* Disable and remove interrupt handler. */ 418 /* Disable and remove interrupt handler. */
422 if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) { 419 if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) {
@@ -425,7 +422,6 @@ cleanup_module(void)
425 } 422 }
426 } 423 }
427 class_destroy(ip2_class); 424 class_destroy(ip2_class);
428 devfs_remove("ip2");
429 if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) { 425 if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) {
430 printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err); 426 printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err);
431 } 427 }
@@ -675,7 +671,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
675 671
676 ip2_tty_driver->owner = THIS_MODULE; 672 ip2_tty_driver->owner = THIS_MODULE;
677 ip2_tty_driver->name = "ttyF"; 673 ip2_tty_driver->name = "ttyF";
678 ip2_tty_driver->devfs_name = "tts/F";
679 ip2_tty_driver->driver_name = pcDriver_name; 674 ip2_tty_driver->driver_name = pcDriver_name;
680 ip2_tty_driver->major = IP2_TTY_MAJOR; 675 ip2_tty_driver->major = IP2_TTY_MAJOR;
681 ip2_tty_driver->minor_start = 0; 676 ip2_tty_driver->minor_start = 0;
@@ -683,7 +678,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
683 ip2_tty_driver->subtype = SERIAL_TYPE_NORMAL; 678 ip2_tty_driver->subtype = SERIAL_TYPE_NORMAL;
684 ip2_tty_driver->init_termios = tty_std_termios; 679 ip2_tty_driver->init_termios = tty_std_termios;
685 ip2_tty_driver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL; 680 ip2_tty_driver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
686 ip2_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 681 ip2_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
687 tty_set_operations(ip2_tty_driver, &ip2_ops); 682 tty_set_operations(ip2_tty_driver, &ip2_ops);
688 683
689 ip2trace (ITRC_NO_PORT, ITRC_INIT, 3, 0 ); 684 ip2trace (ITRC_NO_PORT, ITRC_INIT, 3, 0 );
@@ -724,26 +719,9 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
724 class_device_create(ip2_class, NULL, 719 class_device_create(ip2_class, NULL,
725 MKDEV(IP2_IPL_MAJOR, 4 * i), 720 MKDEV(IP2_IPL_MAJOR, 4 * i),
726 NULL, "ipl%d", i); 721 NULL, "ipl%d", i);
727 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
728 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
729 "ip2/ipl%d", i);
730 if (err) {
731 class_device_destroy(ip2_class,
732 MKDEV(IP2_IPL_MAJOR, 4 * i));
733 goto out_class;
734 }
735
736 class_device_create(ip2_class, NULL, 722 class_device_create(ip2_class, NULL,
737 MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 723 MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
738 NULL, "stat%d", i); 724 NULL, "stat%d", i);
739 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
740 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
741 "ip2/stat%d", i);
742 if (err) {
743 class_device_destroy(ip2_class,
744 MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
745 goto out_class;
746 }
747 725
748 for ( box = 0; box < ABS_MAX_BOXES; ++box ) 726 for ( box = 0; box < ABS_MAX_BOXES; ++box )
749 { 727 {
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index e1c95374984c..da637adbbfaa 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -40,7 +40,6 @@
40#include <linux/poll.h> 40#include <linux/poll.h>
41#include <linux/spinlock.h> 41#include <linux/spinlock.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/devfs_fs_kernel.h>
44#include <linux/ipmi.h> 43#include <linux/ipmi.h>
45#include <linux/mutex.h> 44#include <linux/mutex.h>
46#include <linux/init.h> 45#include <linux/init.h>
@@ -804,9 +803,6 @@ static void ipmi_new_smi(int if_num, struct device *device)
804 dev_t dev = MKDEV(ipmi_major, if_num); 803 dev_t dev = MKDEV(ipmi_major, if_num);
805 struct ipmi_reg_list *entry; 804 struct ipmi_reg_list *entry;
806 805
807 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
808 "ipmidev/%d", if_num);
809
810 entry = kmalloc(sizeof(*entry), GFP_KERNEL); 806 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
811 if (!entry) { 807 if (!entry) {
812 printk(KERN_ERR "ipmi_devintf: Unable to create the" 808 printk(KERN_ERR "ipmi_devintf: Unable to create the"
@@ -836,7 +832,6 @@ static void ipmi_smi_gone(int if_num)
836 } 832 }
837 class_device_destroy(ipmi_class, dev); 833 class_device_destroy(ipmi_class, dev);
838 mutex_unlock(&reg_list_mutex); 834 mutex_unlock(&reg_list_mutex);
839 devfs_remove("ipmidev/%d", if_num);
840} 835}
841 836
842static struct ipmi_smi_watcher smi_watcher = 837static struct ipmi_smi_watcher smi_watcher =
@@ -872,8 +867,6 @@ static __init int init_ipmi_devintf(void)
872 ipmi_major = rv; 867 ipmi_major = rv;
873 } 868 }
874 869
875 devfs_mk_dir(DEVICE_NAME);
876
877 rv = ipmi_smi_watcher_register(&smi_watcher); 870 rv = ipmi_smi_watcher_register(&smi_watcher);
878 if (rv) { 871 if (rv) {
879 unregister_chrdev(ipmi_major, DEVICE_NAME); 872 unregister_chrdev(ipmi_major, DEVICE_NAME);
@@ -898,7 +891,6 @@ static __exit void cleanup_ipmi(void)
898 mutex_unlock(&reg_list_mutex); 891 mutex_unlock(&reg_list_mutex);
899 class_destroy(ipmi_class); 892 class_destroy(ipmi_class);
900 ipmi_smi_watcher_unregister(&smi_watcher); 893 ipmi_smi_watcher_unregister(&smi_watcher);
901 devfs_remove(DEVICE_NAME);
902 unregister_chrdev(ipmi_major, DEVICE_NAME); 894 unregister_chrdev(ipmi_major, DEVICE_NAME);
903} 895}
904module_exit(cleanup_ipmi); 896module_exit(cleanup_ipmi);
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index b03ddab1bef5..ad26f4b997c5 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -57,8 +57,7 @@ static int ipmi_init_msghandler(void);
57static int initialized = 0; 57static int initialized = 0;
58 58
59#ifdef CONFIG_PROC_FS 59#ifdef CONFIG_PROC_FS
60struct proc_dir_entry *proc_ipmi_root = NULL; 60static struct proc_dir_entry *proc_ipmi_root = NULL;
61EXPORT_SYMBOL(proc_ipmi_root);
62#endif /* CONFIG_PROC_FS */ 61#endif /* CONFIG_PROC_FS */
63 62
64#define MAX_EVENTS_IN_QUEUE 25 63#define MAX_EVENTS_IN_QUEUE 25
@@ -3739,11 +3738,8 @@ static int ipmi_init_msghandler(void)
3739 proc_ipmi_root->owner = THIS_MODULE; 3738 proc_ipmi_root->owner = THIS_MODULE;
3740#endif /* CONFIG_PROC_FS */ 3739#endif /* CONFIG_PROC_FS */
3741 3740
3742 init_timer(&ipmi_timer); 3741 setup_timer(&ipmi_timer, ipmi_timeout, 0);
3743 ipmi_timer.data = 0; 3742 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
3744 ipmi_timer.function = ipmi_timeout;
3745 ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES;
3746 add_timer(&ipmi_timer);
3747 3743
3748 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 3744 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
3749 3745
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 02a7dd7a8a55..bd4f2248b758 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -55,23 +55,6 @@
55#include <linux/mutex.h> 55#include <linux/mutex.h>
56#include <linux/kthread.h> 56#include <linux/kthread.h>
57#include <asm/irq.h> 57#include <asm/irq.h>
58#ifdef CONFIG_HIGH_RES_TIMERS
59#include <linux/hrtime.h>
60# if defined(schedule_next_int)
61/* Old high-res timer code, do translations. */
62# define get_arch_cycles(a) quick_update_jiffies_sub(a)
63# define arch_cycles_per_jiffy cycles_per_jiffies
64# endif
65static inline void add_usec_to_timer(struct timer_list *t, long v)
66{
67 t->arch_cycle_expires += nsec_to_arch_cycle(v * 1000);
68 while (t->arch_cycle_expires >= arch_cycles_per_jiffy)
69 {
70 t->expires++;
71 t->arch_cycle_expires -= arch_cycles_per_jiffy;
72 }
73}
74#endif
75#include <linux/interrupt.h> 58#include <linux/interrupt.h>
76#include <linux/rcupdate.h> 59#include <linux/rcupdate.h>
77#include <linux/ipmi_smi.h> 60#include <linux/ipmi_smi.h>
@@ -243,8 +226,6 @@ static int register_xaction_notifier(struct notifier_block * nb)
243 return atomic_notifier_chain_register(&xaction_notifier_list, nb); 226 return atomic_notifier_chain_register(&xaction_notifier_list, nb);
244} 227}
245 228
246static void si_restart_short_timer(struct smi_info *smi_info);
247
248static void deliver_recv_msg(struct smi_info *smi_info, 229static void deliver_recv_msg(struct smi_info *smi_info,
249 struct ipmi_smi_msg *msg) 230 struct ipmi_smi_msg *msg)
250{ 231{
@@ -768,7 +749,6 @@ static void sender(void *send_info,
768 && (smi_info->curr_msg == NULL)) 749 && (smi_info->curr_msg == NULL))
769 { 750 {
770 start_next_msg(smi_info); 751 start_next_msg(smi_info);
771 si_restart_short_timer(smi_info);
772 } 752 }
773 spin_unlock_irqrestore(&(smi_info->si_lock), flags); 753 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
774} 754}
@@ -809,7 +789,7 @@ static int ipmi_thread(void *data)
809 /* do nothing */ 789 /* do nothing */
810 } 790 }
811 else if (smi_result == SI_SM_CALL_WITH_DELAY) 791 else if (smi_result == SI_SM_CALL_WITH_DELAY)
812 udelay(1); 792 schedule();
813 else 793 else
814 schedule_timeout_interruptible(1); 794 schedule_timeout_interruptible(1);
815 } 795 }
@@ -833,37 +813,6 @@ static void request_events(void *send_info)
833 813
834static int initialized = 0; 814static int initialized = 0;
835 815
836/* Must be called with interrupts off and with the si_lock held. */
837static void si_restart_short_timer(struct smi_info *smi_info)
838{
839#if defined(CONFIG_HIGH_RES_TIMERS)
840 unsigned long flags;
841 unsigned long jiffies_now;
842 unsigned long seq;
843
844 if (del_timer(&(smi_info->si_timer))) {
845 /* If we don't delete the timer, then it will go off
846 immediately, anyway. So we only process if we
847 actually delete the timer. */
848
849 do {
850 seq = read_seqbegin_irqsave(&xtime_lock, flags);
851 jiffies_now = jiffies;
852 smi_info->si_timer.expires = jiffies_now;
853 smi_info->si_timer.arch_cycle_expires
854 = get_arch_cycles(jiffies_now);
855 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
856
857 add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
858
859 add_timer(&(smi_info->si_timer));
860 spin_lock_irqsave(&smi_info->count_lock, flags);
861 smi_info->timeout_restarts++;
862 spin_unlock_irqrestore(&smi_info->count_lock, flags);
863 }
864#endif
865}
866
867static void smi_timeout(unsigned long data) 816static void smi_timeout(unsigned long data)
868{ 817{
869 struct smi_info *smi_info = (struct smi_info *) data; 818 struct smi_info *smi_info = (struct smi_info *) data;
@@ -904,31 +853,15 @@ static void smi_timeout(unsigned long data)
904 /* If the state machine asks for a short delay, then shorten 853 /* If the state machine asks for a short delay, then shorten
905 the timer timeout. */ 854 the timer timeout. */
906 if (smi_result == SI_SM_CALL_WITH_DELAY) { 855 if (smi_result == SI_SM_CALL_WITH_DELAY) {
907#if defined(CONFIG_HIGH_RES_TIMERS)
908 unsigned long seq;
909#endif
910 spin_lock_irqsave(&smi_info->count_lock, flags); 856 spin_lock_irqsave(&smi_info->count_lock, flags);
911 smi_info->short_timeouts++; 857 smi_info->short_timeouts++;
912 spin_unlock_irqrestore(&smi_info->count_lock, flags); 858 spin_unlock_irqrestore(&smi_info->count_lock, flags);
913#if defined(CONFIG_HIGH_RES_TIMERS)
914 do {
915 seq = read_seqbegin_irqsave(&xtime_lock, flags);
916 smi_info->si_timer.expires = jiffies;
917 smi_info->si_timer.arch_cycle_expires
918 = get_arch_cycles(smi_info->si_timer.expires);
919 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
920 add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
921#else
922 smi_info->si_timer.expires = jiffies + 1; 859 smi_info->si_timer.expires = jiffies + 1;
923#endif
924 } else { 860 } else {
925 spin_lock_irqsave(&smi_info->count_lock, flags); 861 spin_lock_irqsave(&smi_info->count_lock, flags);
926 smi_info->long_timeouts++; 862 smi_info->long_timeouts++;
927 spin_unlock_irqrestore(&smi_info->count_lock, flags); 863 spin_unlock_irqrestore(&smi_info->count_lock, flags);
928 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; 864 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
929#if defined(CONFIG_HIGH_RES_TIMERS)
930 smi_info->si_timer.arch_cycle_expires = 0;
931#endif
932 } 865 }
933 866
934 do_add_timer: 867 do_add_timer:
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 8f8867170973..1a0a19c53605 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -949,9 +949,10 @@ static int wdog_reboot_handler(struct notifier_block *this,
949 /* Disable the WDT if we are shutting down. */ 949 /* Disable the WDT if we are shutting down. */
950 ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 950 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
951 panic_halt_ipmi_set_timeout(); 951 panic_halt_ipmi_set_timeout();
952 } else { 952 } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
953 /* Set a long timer to let the reboot happens, but 953 /* Set a long timer to let the reboot happens, but
954 reboot if it hangs. */ 954 reboot if it hangs, but only if the watchdog
955 timer was already running. */
955 timeout = 120; 956 timeout = 120;
956 pretimeout = 0; 957 pretimeout = 0;
957 ipmi_watchdog_state = WDOG_TIMEOUT_RESET; 958 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
@@ -973,16 +974,17 @@ static int wdog_panic_handler(struct notifier_block *this,
973{ 974{
974 static int panic_event_handled = 0; 975 static int panic_event_handled = 0;
975 976
976 /* On a panic, if we have a panic timeout, make sure that the thing 977 /* On a panic, if we have a panic timeout, make sure to extend
977 reboots, even if it hangs during that panic. */ 978 the watchdog timer to a reasonable value to complete the
978 if (watchdog_user && !panic_event_handled) { 979 panic, if the watchdog timer is running. Plus the
979 /* Make sure the panic doesn't hang, and make sure we 980 pretimeout is meaningless at panic time. */
980 do this only once. */ 981 if (watchdog_user && !panic_event_handled &&
982 ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
983 /* Make sure we do this only once. */
981 panic_event_handled = 1; 984 panic_event_handled = 1;
982 985
983 timeout = 255; 986 timeout = 255;
984 pretimeout = 0; 987 pretimeout = 0;
985 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
986 panic_halt_ipmi_set_timeout(); 988 panic_halt_ipmi_set_timeout();
987 } 989 }
988 990
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index efaaa1937ab6..478bf4d7d065 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -1581,7 +1581,6 @@ static int __devinit isicom_register_tty_driver(void)
1581 1581
1582 isicom_normal->owner = THIS_MODULE; 1582 isicom_normal->owner = THIS_MODULE;
1583 isicom_normal->name = "ttyM"; 1583 isicom_normal->name = "ttyM";
1584 isicom_normal->devfs_name = "isicom/";
1585 isicom_normal->major = ISICOM_NMAJOR; 1584 isicom_normal->major = ISICOM_NMAJOR;
1586 isicom_normal->minor_start = 0; 1585 isicom_normal->minor_start = 0;
1587 isicom_normal->type = TTY_DRIVER_TYPE_SERIAL; 1586 isicom_normal->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ef20c1fc9c4c..c74e5660a9b7 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -39,16 +39,14 @@
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/devfs_fs_kernel.h>
43#include <linux/device.h> 42#include <linux/device.h>
44#include <linux/wait.h> 43#include <linux/wait.h>
44#include <linux/eisa.h>
45 45
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48 48
49#ifdef CONFIG_PCI
50#include <linux/pci.h> 49#include <linux/pci.h>
51#endif
52 50
53/*****************************************************************************/ 51/*****************************************************************************/
54 52
@@ -137,6 +135,10 @@ static stlconf_t stli_brdconf[] = {
137 135
138static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); 136static int stli_nrbrds = ARRAY_SIZE(stli_brdconf);
139 137
138/* stli_lock must NOT be taken holding brd_lock */
139static spinlock_t stli_lock; /* TTY logic lock */
140static spinlock_t brd_lock; /* Board logic lock */
141
140/* 142/*
141 * There is some experimental EISA board detection code in this driver. 143 * There is some experimental EISA board detection code in this driver.
142 * By default it is disabled, but for those that want to try it out, 144 * By default it is disabled, but for those that want to try it out,
@@ -173,14 +175,6 @@ static char *stli_serialname = "ttyE";
173 175
174static struct tty_driver *stli_serial; 176static struct tty_driver *stli_serial;
175 177
176/*
177 * We will need to allocate a temporary write buffer for chars that
178 * come direct from user space. The problem is that a copy from user
179 * space might cause a page fault (typically on a system that is
180 * swapping!). All ports will share one buffer - since if the system
181 * is already swapping a shared buffer won't make things any worse.
182 */
183static char *stli_tmpwritebuf;
184 178
185#define STLI_TXBUFSIZE 4096 179#define STLI_TXBUFSIZE 4096
186 180
@@ -419,7 +413,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);
419#endif 413#endif
420 414
421static struct pci_device_id istallion_pci_tbl[] = { 415static struct pci_device_id istallion_pci_tbl[] = {
422 { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 416 { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA), },
423 { 0 } 417 { 0 }
424}; 418};
425MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); 419MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
@@ -682,7 +676,7 @@ static int stli_startbrd(stlibrd_t *brdp);
682static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); 676static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp);
683static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); 677static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp);
684static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); 678static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
685static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp); 679static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp);
686static void stli_poll(unsigned long arg); 680static void stli_poll(unsigned long arg);
687static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); 681static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp);
688static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); 682static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
@@ -693,7 +687,8 @@ static void stli_dohangup(void *arg);
693static int stli_setport(stliport_t *portp); 687static int stli_setport(stliport_t *portp);
694static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 688static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
695static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 689static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
696static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp); 690static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
691static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
697static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); 692static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
698static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); 693static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
699static long stli_mktiocm(unsigned long sigvalue); 694static long stli_mktiocm(unsigned long sigvalue);
@@ -799,18 +794,8 @@ static struct class *istallion_class;
799 794
800static int __init istallion_module_init(void) 795static int __init istallion_module_init(void)
801{ 796{
802 unsigned long flags;
803
804#ifdef DEBUG
805 printk("init_module()\n");
806#endif
807
808 save_flags(flags);
809 cli();
810 stli_init(); 797 stli_init();
811 restore_flags(flags); 798 return 0;
812
813 return(0);
814} 799}
815 800
816/*****************************************************************************/ 801/*****************************************************************************/
@@ -819,56 +804,43 @@ static void __exit istallion_module_exit(void)
819{ 804{
820 stlibrd_t *brdp; 805 stlibrd_t *brdp;
821 stliport_t *portp; 806 stliport_t *portp;
822 unsigned long flags;
823 int i, j; 807 int i, j;
824 808
825#ifdef DEBUG
826 printk("cleanup_module()\n");
827#endif
828
829 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, 809 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
830 stli_drvversion); 810 stli_drvversion);
831 811
832 save_flags(flags); 812 /*
833 cli(); 813 * Free up all allocated resources used by the ports. This includes
834 814 * memory and interrupts.
835/* 815 */
836 * Free up all allocated resources used by the ports. This includes
837 * memory and interrupts.
838 */
839 if (stli_timeron) { 816 if (stli_timeron) {
840 stli_timeron = 0; 817 stli_timeron = 0;
841 del_timer(&stli_timerlist); 818 del_timer_sync(&stli_timerlist);
842 } 819 }
843 820
844 i = tty_unregister_driver(stli_serial); 821 i = tty_unregister_driver(stli_serial);
845 if (i) { 822 if (i) {
846 printk("STALLION: failed to un-register tty driver, " 823 printk("STALLION: failed to un-register tty driver, "
847 "errno=%d\n", -i); 824 "errno=%d\n", -i);
848 restore_flags(flags);
849 return; 825 return;
850 } 826 }
851 put_tty_driver(stli_serial); 827 put_tty_driver(stli_serial);
852 for (i = 0; i < 4; i++) { 828 for (i = 0; i < 4; i++)
853 devfs_remove("staliomem/%d", i);
854 class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 829 class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, i));
855 }
856 devfs_remove("staliomem");
857 class_destroy(istallion_class); 830 class_destroy(istallion_class);
858 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) 831 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
859 printk("STALLION: failed to un-register serial memory device, " 832 printk("STALLION: failed to un-register serial memory device, "
860 "errno=%d\n", -i); 833 "errno=%d\n", -i);
861 834
862 kfree(stli_tmpwritebuf);
863 kfree(stli_txcookbuf); 835 kfree(stli_txcookbuf);
864 836
865 for (i = 0; (i < stli_nrbrds); i++) { 837 for (i = 0; (i < stli_nrbrds); i++) {
866 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) 838 if ((brdp = stli_brds[i]) == NULL)
867 continue; 839 continue;
868 for (j = 0; (j < STL_MAXPORTS); j++) { 840 for (j = 0; (j < STL_MAXPORTS); j++) {
869 portp = brdp->ports[j]; 841 portp = brdp->ports[j];
870 if (portp != (stliport_t *) NULL) { 842 if (portp != NULL) {
871 if (portp->tty != (struct tty_struct *) NULL) 843 if (portp->tty != NULL)
872 tty_hangup(portp->tty); 844 tty_hangup(portp->tty);
873 kfree(portp); 845 kfree(portp);
874 } 846 }
@@ -878,10 +850,8 @@ static void __exit istallion_module_exit(void)
878 if (brdp->iosize > 0) 850 if (brdp->iosize > 0)
879 release_region(brdp->iobase, brdp->iosize); 851 release_region(brdp->iobase, brdp->iosize);
880 kfree(brdp); 852 kfree(brdp);
881 stli_brds[i] = (stlibrd_t *) NULL; 853 stli_brds[i] = NULL;
882 } 854 }
883
884 restore_flags(flags);
885} 855}
886 856
887module_init(istallion_module_init); 857module_init(istallion_module_init);
@@ -895,19 +865,15 @@ module_exit(istallion_module_exit);
895 865
896static void stli_argbrds(void) 866static void stli_argbrds(void)
897{ 867{
898 stlconf_t conf; 868 stlconf_t conf;
899 stlibrd_t *brdp; 869 stlibrd_t *brdp;
900 int i; 870 int i;
901
902#ifdef DEBUG
903 printk("stli_argbrds()\n");
904#endif
905 871
906 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { 872 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
907 memset(&conf, 0, sizeof(conf)); 873 memset(&conf, 0, sizeof(conf));
908 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) 874 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
909 continue; 875 continue;
910 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 876 if ((brdp = stli_allocbrd()) == NULL)
911 continue; 877 continue;
912 stli_nrbrds = i + 1; 878 stli_nrbrds = i + 1;
913 brdp->brdnr = i; 879 brdp->brdnr = i;
@@ -926,9 +892,9 @@ static void stli_argbrds(void)
926 892
927static unsigned long stli_atol(char *str) 893static unsigned long stli_atol(char *str)
928{ 894{
929 unsigned long val; 895 unsigned long val;
930 int base, c; 896 int base, c;
931 char *sp; 897 char *sp;
932 898
933 val = 0; 899 val = 0;
934 sp = str; 900 sp = str;
@@ -962,15 +928,11 @@ static unsigned long stli_atol(char *str)
962 928
963static int stli_parsebrd(stlconf_t *confp, char **argp) 929static int stli_parsebrd(stlconf_t *confp, char **argp)
964{ 930{
965 char *sp; 931 char *sp;
966 int i; 932 int i;
967
968#ifdef DEBUG
969 printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp);
970#endif
971 933
972 if ((argp[0] == (char *) NULL) || (*argp[0] == 0)) 934 if (argp[0] == NULL || *argp[0] == 0)
973 return(0); 935 return 0;
974 936
975 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) 937 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
976 *sp = TOLOWER(*sp); 938 *sp = TOLOWER(*sp);
@@ -985,9 +947,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
985 } 947 }
986 948
987 confp->brdtype = stli_brdstr[i].type; 949 confp->brdtype = stli_brdstr[i].type;
988 if ((argp[1] != (char *) NULL) && (*argp[1] != 0)) 950 if (argp[1] != NULL && *argp[1] != 0)
989 confp->ioaddr1 = stli_atol(argp[1]); 951 confp->ioaddr1 = stli_atol(argp[1]);
990 if ((argp[2] != (char *) NULL) && (*argp[2] != 0)) 952 if (argp[2] != NULL && *argp[2] != 0)
991 confp->memaddr = stli_atol(argp[2]); 953 confp->memaddr = stli_atol(argp[2]);
992 return(1); 954 return(1);
993} 955}
@@ -998,34 +960,29 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
998 960
999static int stli_open(struct tty_struct *tty, struct file *filp) 961static int stli_open(struct tty_struct *tty, struct file *filp)
1000{ 962{
1001 stlibrd_t *brdp; 963 stlibrd_t *brdp;
1002 stliport_t *portp; 964 stliport_t *portp;
1003 unsigned int minordev; 965 unsigned int minordev;
1004 int brdnr, portnr, rc; 966 int brdnr, portnr, rc;
1005
1006#ifdef DEBUG
1007 printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty,
1008 (int) filp, tty->name);
1009#endif
1010 967
1011 minordev = tty->index; 968 minordev = tty->index;
1012 brdnr = MINOR2BRD(minordev); 969 brdnr = MINOR2BRD(minordev);
1013 if (brdnr >= stli_nrbrds) 970 if (brdnr >= stli_nrbrds)
1014 return(-ENODEV); 971 return -ENODEV;
1015 brdp = stli_brds[brdnr]; 972 brdp = stli_brds[brdnr];
1016 if (brdp == (stlibrd_t *) NULL) 973 if (brdp == NULL)
1017 return(-ENODEV); 974 return -ENODEV;
1018 if ((brdp->state & BST_STARTED) == 0) 975 if ((brdp->state & BST_STARTED) == 0)
1019 return(-ENODEV); 976 return -ENODEV;
1020 portnr = MINOR2PORT(minordev); 977 portnr = MINOR2PORT(minordev);
1021 if ((portnr < 0) || (portnr > brdp->nrports)) 978 if ((portnr < 0) || (portnr > brdp->nrports))
1022 return(-ENODEV); 979 return -ENODEV;
1023 980
1024 portp = brdp->ports[portnr]; 981 portp = brdp->ports[portnr];
1025 if (portp == (stliport_t *) NULL) 982 if (portp == NULL)
1026 return(-ENODEV); 983 return -ENODEV;
1027 if (portp->devnr < 1) 984 if (portp->devnr < 1)
1028 return(-ENODEV); 985 return -ENODEV;
1029 986
1030 987
1031/* 988/*
@@ -1037,8 +994,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1037 if (portp->flags & ASYNC_CLOSING) { 994 if (portp->flags & ASYNC_CLOSING) {
1038 interruptible_sleep_on(&portp->close_wait); 995 interruptible_sleep_on(&portp->close_wait);
1039 if (portp->flags & ASYNC_HUP_NOTIFY) 996 if (portp->flags & ASYNC_HUP_NOTIFY)
1040 return(-EAGAIN); 997 return -EAGAIN;
1041 return(-ERESTARTSYS); 998 return -ERESTARTSYS;
1042 } 999 }
1043 1000
1044/* 1001/*
@@ -1054,7 +1011,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1054 wait_event_interruptible(portp->raw_wait, 1011 wait_event_interruptible(portp->raw_wait,
1055 !test_bit(ST_INITIALIZING, &portp->state)); 1012 !test_bit(ST_INITIALIZING, &portp->state));
1056 if (signal_pending(current)) 1013 if (signal_pending(current))
1057 return(-ERESTARTSYS); 1014 return -ERESTARTSYS;
1058 1015
1059 if ((portp->flags & ASYNC_INITIALIZED) == 0) { 1016 if ((portp->flags & ASYNC_INITIALIZED) == 0) {
1060 set_bit(ST_INITIALIZING, &portp->state); 1017 set_bit(ST_INITIALIZING, &portp->state);
@@ -1065,7 +1022,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1065 clear_bit(ST_INITIALIZING, &portp->state); 1022 clear_bit(ST_INITIALIZING, &portp->state);
1066 wake_up_interruptible(&portp->raw_wait); 1023 wake_up_interruptible(&portp->raw_wait);
1067 if (rc < 0) 1024 if (rc < 0)
1068 return(rc); 1025 return rc;
1069 } 1026 }
1070 1027
1071/* 1028/*
@@ -1077,8 +1034,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1077 if (portp->flags & ASYNC_CLOSING) { 1034 if (portp->flags & ASYNC_CLOSING) {
1078 interruptible_sleep_on(&portp->close_wait); 1035 interruptible_sleep_on(&portp->close_wait);
1079 if (portp->flags & ASYNC_HUP_NOTIFY) 1036 if (portp->flags & ASYNC_HUP_NOTIFY)
1080 return(-EAGAIN); 1037 return -EAGAIN;
1081 return(-ERESTARTSYS); 1038 return -ERESTARTSYS;
1082 } 1039 }
1083 1040
1084/* 1041/*
@@ -1088,38 +1045,33 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1088 */ 1045 */
1089 if (!(filp->f_flags & O_NONBLOCK)) { 1046 if (!(filp->f_flags & O_NONBLOCK)) {
1090 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0) 1047 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0)
1091 return(rc); 1048 return rc;
1092 } 1049 }
1093 portp->flags |= ASYNC_NORMAL_ACTIVE; 1050 portp->flags |= ASYNC_NORMAL_ACTIVE;
1094 return(0); 1051 return 0;
1095} 1052}
1096 1053
1097/*****************************************************************************/ 1054/*****************************************************************************/
1098 1055
1099static void stli_close(struct tty_struct *tty, struct file *filp) 1056static void stli_close(struct tty_struct *tty, struct file *filp)
1100{ 1057{
1101 stlibrd_t *brdp; 1058 stlibrd_t *brdp;
1102 stliport_t *portp; 1059 stliport_t *portp;
1103 unsigned long flags; 1060 unsigned long flags;
1104
1105#ifdef DEBUG
1106 printk("stli_close(tty=%x,filp=%x)\n", (int) tty, (int) filp);
1107#endif
1108 1061
1109 portp = tty->driver_data; 1062 portp = tty->driver_data;
1110 if (portp == (stliport_t *) NULL) 1063 if (portp == NULL)
1111 return; 1064 return;
1112 1065
1113 save_flags(flags); 1066 spin_lock_irqsave(&stli_lock, flags);
1114 cli();
1115 if (tty_hung_up_p(filp)) { 1067 if (tty_hung_up_p(filp)) {
1116 restore_flags(flags); 1068 spin_unlock_irqrestore(&stli_lock, flags);
1117 return; 1069 return;
1118 } 1070 }
1119 if ((tty->count == 1) && (portp->refcount != 1)) 1071 if ((tty->count == 1) && (portp->refcount != 1))
1120 portp->refcount = 1; 1072 portp->refcount = 1;
1121 if (portp->refcount-- > 1) { 1073 if (portp->refcount-- > 1) {
1122 restore_flags(flags); 1074 spin_unlock_irqrestore(&stli_lock, flags);
1123 return; 1075 return;
1124 } 1076 }
1125 1077
@@ -1134,6 +1086,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1134 if (tty == stli_txcooktty) 1086 if (tty == stli_txcooktty)
1135 stli_flushchars(tty); 1087 stli_flushchars(tty);
1136 tty->closing = 1; 1088 tty->closing = 1;
1089 spin_unlock_irqrestore(&stli_lock, flags);
1090
1137 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1091 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1138 tty_wait_until_sent(tty, portp->closing_wait); 1092 tty_wait_until_sent(tty, portp->closing_wait);
1139 1093
@@ -1157,7 +1111,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1157 stli_flushbuffer(tty); 1111 stli_flushbuffer(tty);
1158 1112
1159 tty->closing = 0; 1113 tty->closing = 0;
1160 portp->tty = (struct tty_struct *) NULL; 1114 portp->tty = NULL;
1161 1115
1162 if (portp->openwaitcnt) { 1116 if (portp->openwaitcnt) {
1163 if (portp->close_delay) 1117 if (portp->close_delay)
@@ -1167,7 +1121,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1167 1121
1168 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1122 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1169 wake_up_interruptible(&portp->close_wait); 1123 wake_up_interruptible(&portp->close_wait);
1170 restore_flags(flags);
1171} 1124}
1172 1125
1173/*****************************************************************************/ 1126/*****************************************************************************/
@@ -1182,45 +1135,41 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1182 1135
1183static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) 1136static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1184{ 1137{
1185 struct tty_struct *tty; 1138 struct tty_struct *tty;
1186 asynotify_t nt; 1139 asynotify_t nt;
1187 asyport_t aport; 1140 asyport_t aport;
1188 int rc; 1141 int rc;
1189
1190#ifdef DEBUG
1191 printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp, (int) portp);
1192#endif
1193 1142
1194 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0) 1143 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0)
1195 return(rc); 1144 return rc;
1196 1145
1197 memset(&nt, 0, sizeof(asynotify_t)); 1146 memset(&nt, 0, sizeof(asynotify_t));
1198 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK); 1147 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK);
1199 nt.signal = SG_DCD; 1148 nt.signal = SG_DCD;
1200 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt, 1149 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt,
1201 sizeof(asynotify_t), 0)) < 0) 1150 sizeof(asynotify_t), 0)) < 0)
1202 return(rc); 1151 return rc;
1203 1152
1204 tty = portp->tty; 1153 tty = portp->tty;
1205 if (tty == (struct tty_struct *) NULL) 1154 if (tty == NULL)
1206 return(-ENODEV); 1155 return -ENODEV;
1207 stli_mkasyport(portp, &aport, tty->termios); 1156 stli_mkasyport(portp, &aport, tty->termios);
1208 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport, 1157 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport,
1209 sizeof(asyport_t), 0)) < 0) 1158 sizeof(asyport_t), 0)) < 0)
1210 return(rc); 1159 return rc;
1211 1160
1212 set_bit(ST_GETSIGS, &portp->state); 1161 set_bit(ST_GETSIGS, &portp->state);
1213 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, 1162 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig,
1214 sizeof(asysigs_t), 1)) < 0) 1163 sizeof(asysigs_t), 1)) < 0)
1215 return(rc); 1164 return rc;
1216 if (test_and_clear_bit(ST_GETSIGS, &portp->state)) 1165 if (test_and_clear_bit(ST_GETSIGS, &portp->state))
1217 portp->sigs = stli_mktiocm(portp->asig.sigvalue); 1166 portp->sigs = stli_mktiocm(portp->asig.sigvalue);
1218 stli_mkasysigs(&portp->asig, 1, 1); 1167 stli_mkasysigs(&portp->asig, 1, 1);
1219 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, 1168 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
1220 sizeof(asysigs_t), 0)) < 0) 1169 sizeof(asysigs_t), 0)) < 0)
1221 return(rc); 1170 return rc;
1222 1171
1223 return(0); 1172 return 0;
1224} 1173}
1225 1174
1226/*****************************************************************************/ 1175/*****************************************************************************/
@@ -1234,22 +1183,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1234 1183
1235static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1184static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1236{ 1185{
1237 volatile cdkhdr_t *hdrp; 1186 cdkhdr_t __iomem *hdrp;
1238 volatile cdkctrl_t *cp; 1187 cdkctrl_t __iomem *cp;
1239 volatile unsigned char *bits; 1188 unsigned char __iomem *bits;
1240 unsigned long flags; 1189 unsigned long flags;
1241 int rc; 1190 int rc;
1242
1243#ifdef DEBUG
1244 printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1245 (int) brdp, (int) portp, (int) arg, wait);
1246#endif
1247 1191
1248/* 1192/*
1249 * Send a message to the slave to open this port. 1193 * Send a message to the slave to open this port.
1250 */ 1194 */
1251 save_flags(flags);
1252 cli();
1253 1195
1254/* 1196/*
1255 * Slave is already closing this port. This can happen if a hangup 1197 * Slave is already closing this port. This can happen if a hangup
@@ -1260,7 +1202,6 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1260 wait_event_interruptible(portp->raw_wait, 1202 wait_event_interruptible(portp->raw_wait,
1261 !test_bit(ST_CLOSING, &portp->state)); 1203 !test_bit(ST_CLOSING, &portp->state));
1262 if (signal_pending(current)) { 1204 if (signal_pending(current)) {
1263 restore_flags(flags);
1264 return -ERESTARTSYS; 1205 return -ERESTARTSYS;
1265 } 1206 }
1266 1207
@@ -1269,19 +1210,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1269 * memory. Once the message is in set the service bits to say that 1210 * memory. Once the message is in set the service bits to say that
1270 * this port wants service. 1211 * this port wants service.
1271 */ 1212 */
1213 spin_lock_irqsave(&brd_lock, flags);
1272 EBRDENABLE(brdp); 1214 EBRDENABLE(brdp);
1273 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1215 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1274 cp->openarg = arg; 1216 writel(arg, &cp->openarg);
1275 cp->open = 1; 1217 writeb(1, &cp->open);
1276 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1218 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1277 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1219 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1278 portp->portidx; 1220 portp->portidx;
1279 *bits |= portp->portbit; 1221 writeb(readb(bits) | portp->portbit, bits);
1280 EBRDDISABLE(brdp); 1222 EBRDDISABLE(brdp);
1281 1223
1282 if (wait == 0) { 1224 if (wait == 0) {
1283 restore_flags(flags); 1225 spin_unlock_irqrestore(&brd_lock, flags);
1284 return(0); 1226 return 0;
1285 } 1227 }
1286 1228
1287/* 1229/*
@@ -1290,15 +1232,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1290 */ 1232 */
1291 rc = 0; 1233 rc = 0;
1292 set_bit(ST_OPENING, &portp->state); 1234 set_bit(ST_OPENING, &portp->state);
1235 spin_unlock_irqrestore(&brd_lock, flags);
1236
1293 wait_event_interruptible(portp->raw_wait, 1237 wait_event_interruptible(portp->raw_wait,
1294 !test_bit(ST_OPENING, &portp->state)); 1238 !test_bit(ST_OPENING, &portp->state));
1295 if (signal_pending(current)) 1239 if (signal_pending(current))
1296 rc = -ERESTARTSYS; 1240 rc = -ERESTARTSYS;
1297 restore_flags(flags);
1298 1241
1299 if ((rc == 0) && (portp->rc != 0)) 1242 if ((rc == 0) && (portp->rc != 0))
1300 rc = -EIO; 1243 rc = -EIO;
1301 return(rc); 1244 return rc;
1302} 1245}
1303 1246
1304/*****************************************************************************/ 1247/*****************************************************************************/
@@ -1311,19 +1254,11 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1311 1254
1312static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1255static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1313{ 1256{
1314 volatile cdkhdr_t *hdrp; 1257 cdkhdr_t __iomem *hdrp;
1315 volatile cdkctrl_t *cp; 1258 cdkctrl_t __iomem *cp;
1316 volatile unsigned char *bits; 1259 unsigned char __iomem *bits;
1317 unsigned long flags; 1260 unsigned long flags;
1318 int rc; 1261 int rc;
1319
1320#ifdef DEBUG
1321 printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1322 (int) brdp, (int) portp, (int) arg, wait);
1323#endif
1324
1325 save_flags(flags);
1326 cli();
1327 1262
1328/* 1263/*
1329 * Slave is already closing this port. This can happen if a hangup 1264 * Slave is already closing this port. This can happen if a hangup
@@ -1333,7 +1268,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1333 wait_event_interruptible(portp->raw_wait, 1268 wait_event_interruptible(portp->raw_wait,
1334 !test_bit(ST_CLOSING, &portp->state)); 1269 !test_bit(ST_CLOSING, &portp->state));
1335 if (signal_pending(current)) { 1270 if (signal_pending(current)) {
1336 restore_flags(flags);
1337 return -ERESTARTSYS; 1271 return -ERESTARTSYS;
1338 } 1272 }
1339 } 1273 }
@@ -1341,21 +1275,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1341/* 1275/*
1342 * Write the close command into shared memory. 1276 * Write the close command into shared memory.
1343 */ 1277 */
1278 spin_lock_irqsave(&brd_lock, flags);
1344 EBRDENABLE(brdp); 1279 EBRDENABLE(brdp);
1345 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1280 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1346 cp->closearg = arg; 1281 writel(arg, &cp->closearg);
1347 cp->close = 1; 1282 writeb(1, &cp->close);
1348 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1283 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1349 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1284 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1350 portp->portidx; 1285 portp->portidx;
1351 *bits |= portp->portbit; 1286 writeb(readb(bits) |portp->portbit, bits);
1352 EBRDDISABLE(brdp); 1287 EBRDDISABLE(brdp);
1353 1288
1354 set_bit(ST_CLOSING, &portp->state); 1289 set_bit(ST_CLOSING, &portp->state);
1355 if (wait == 0) { 1290 spin_unlock_irqrestore(&brd_lock, flags);
1356 restore_flags(flags); 1291
1357 return(0); 1292 if (wait == 0)
1358 } 1293 return 0;
1359 1294
1360/* 1295/*
1361 * Slave is in action, so now we must wait for the open acknowledgment 1296 * Slave is in action, so now we must wait for the open acknowledgment
@@ -1366,11 +1301,10 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1366 !test_bit(ST_CLOSING, &portp->state)); 1301 !test_bit(ST_CLOSING, &portp->state));
1367 if (signal_pending(current)) 1302 if (signal_pending(current))
1368 rc = -ERESTARTSYS; 1303 rc = -ERESTARTSYS;
1369 restore_flags(flags);
1370 1304
1371 if ((rc == 0) && (portp->rc != 0)) 1305 if ((rc == 0) && (portp->rc != 0))
1372 rc = -EIO; 1306 rc = -EIO;
1373 return(rc); 1307 return rc;
1374} 1308}
1375 1309
1376/*****************************************************************************/ 1310/*****************************************************************************/
@@ -1384,36 +1318,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1384 1318
1385static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 1319static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
1386{ 1320{
1387 unsigned long flags;
1388
1389#ifdef DEBUG
1390 printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
1391 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
1392 (int) arg, size, copyback);
1393#endif
1394
1395 save_flags(flags);
1396 cli();
1397 wait_event_interruptible(portp->raw_wait, 1321 wait_event_interruptible(portp->raw_wait,
1398 !test_bit(ST_CMDING, &portp->state)); 1322 !test_bit(ST_CMDING, &portp->state));
1399 if (signal_pending(current)) { 1323 if (signal_pending(current))
1400 restore_flags(flags);
1401 return -ERESTARTSYS; 1324 return -ERESTARTSYS;
1402 }
1403 1325
1404 stli_sendcmd(brdp, portp, cmd, arg, size, copyback); 1326 stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
1405 1327
1406 wait_event_interruptible(portp->raw_wait, 1328 wait_event_interruptible(portp->raw_wait,
1407 !test_bit(ST_CMDING, &portp->state)); 1329 !test_bit(ST_CMDING, &portp->state));
1408 if (signal_pending(current)) { 1330 if (signal_pending(current))
1409 restore_flags(flags);
1410 return -ERESTARTSYS; 1331 return -ERESTARTSYS;
1411 }
1412 restore_flags(flags);
1413 1332
1414 if (portp->rc != 0) 1333 if (portp->rc != 0)
1415 return(-EIO); 1334 return -EIO;
1416 return(0); 1335 return 0;
1417} 1336}
1418 1337
1419/*****************************************************************************/ 1338/*****************************************************************************/
@@ -1425,22 +1344,18 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v
1425 1344
1426static int stli_setport(stliport_t *portp) 1345static int stli_setport(stliport_t *portp)
1427{ 1346{
1428 stlibrd_t *brdp; 1347 stlibrd_t *brdp;
1429 asyport_t aport; 1348 asyport_t aport;
1430
1431#ifdef DEBUG
1432 printk("stli_setport(portp=%x)\n", (int) portp);
1433#endif
1434 1349
1435 if (portp == (stliport_t *) NULL) 1350 if (portp == NULL)
1436 return(-ENODEV); 1351 return -ENODEV;
1437 if (portp->tty == (struct tty_struct *) NULL) 1352 if (portp->tty == NULL)
1438 return(-ENODEV); 1353 return -ENODEV;
1439 if ((portp->brdnr < 0) && (portp->brdnr >= stli_nrbrds)) 1354 if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds)
1440 return(-ENODEV); 1355 return -ENODEV;
1441 brdp = stli_brds[portp->brdnr]; 1356 brdp = stli_brds[portp->brdnr];
1442 if (brdp == (stlibrd_t *) NULL) 1357 if (brdp == NULL)
1443 return(-ENODEV); 1358 return -ENODEV;
1444 1359
1445 stli_mkasyport(portp, &aport, portp->tty->termios); 1360 stli_mkasyport(portp, &aport, portp->tty->termios);
1446 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)); 1361 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0));
@@ -1455,13 +1370,8 @@ static int stli_setport(stliport_t *portp)
1455 1370
1456static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp) 1371static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp)
1457{ 1372{
1458 unsigned long flags; 1373 unsigned long flags;
1459 int rc, doclocal; 1374 int rc, doclocal;
1460
1461#ifdef DEBUG
1462 printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n",
1463 (int) brdp, (int) portp, (int) filp);
1464#endif
1465 1375
1466 rc = 0; 1376 rc = 0;
1467 doclocal = 0; 1377 doclocal = 0;
@@ -1469,11 +1379,11 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1469 if (portp->tty->termios->c_cflag & CLOCAL) 1379 if (portp->tty->termios->c_cflag & CLOCAL)
1470 doclocal++; 1380 doclocal++;
1471 1381
1472 save_flags(flags); 1382 spin_lock_irqsave(&stli_lock, flags);
1473 cli();
1474 portp->openwaitcnt++; 1383 portp->openwaitcnt++;
1475 if (! tty_hung_up_p(filp)) 1384 if (! tty_hung_up_p(filp))
1476 portp->refcount--; 1385 portp->refcount--;
1386 spin_unlock_irqrestore(&stli_lock, flags);
1477 1387
1478 for (;;) { 1388 for (;;) {
1479 stli_mkasysigs(&portp->asig, 1, 1); 1389 stli_mkasysigs(&portp->asig, 1, 1);
@@ -1499,12 +1409,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1499 interruptible_sleep_on(&portp->open_wait); 1409 interruptible_sleep_on(&portp->open_wait);
1500 } 1410 }
1501 1411
1412 spin_lock_irqsave(&stli_lock, flags);
1502 if (! tty_hung_up_p(filp)) 1413 if (! tty_hung_up_p(filp))
1503 portp->refcount++; 1414 portp->refcount++;
1504 portp->openwaitcnt--; 1415 portp->openwaitcnt--;
1505 restore_flags(flags); 1416 spin_unlock_irqrestore(&stli_lock, flags);
1506 1417
1507 return(rc); 1418 return rc;
1508} 1419}
1509 1420
1510/*****************************************************************************/ 1421/*****************************************************************************/
@@ -1517,46 +1428,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1517 1428
1518static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count) 1429static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count)
1519{ 1430{
1520 volatile cdkasy_t *ap; 1431 cdkasy_t __iomem *ap;
1521 volatile cdkhdr_t *hdrp; 1432 cdkhdr_t __iomem *hdrp;
1522 volatile unsigned char *bits; 1433 unsigned char __iomem *bits;
1523 unsigned char *shbuf, *chbuf; 1434 unsigned char __iomem *shbuf;
1524 stliport_t *portp; 1435 unsigned char *chbuf;
1525 stlibrd_t *brdp; 1436 stliport_t *portp;
1526 unsigned int len, stlen, head, tail, size; 1437 stlibrd_t *brdp;
1527 unsigned long flags; 1438 unsigned int len, stlen, head, tail, size;
1528 1439 unsigned long flags;
1529#ifdef DEBUG
1530 printk("stli_write(tty=%x,buf=%x,count=%d)\n",
1531 (int) tty, (int) buf, count);
1532#endif
1533 1440
1534 if ((tty == (struct tty_struct *) NULL) ||
1535 (stli_tmpwritebuf == (char *) NULL))
1536 return(0);
1537 if (tty == stli_txcooktty) 1441 if (tty == stli_txcooktty)
1538 stli_flushchars(tty); 1442 stli_flushchars(tty);
1539 portp = tty->driver_data; 1443 portp = tty->driver_data;
1540 if (portp == (stliport_t *) NULL) 1444 if (portp == NULL)
1541 return(0); 1445 return 0;
1542 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1446 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1543 return(0); 1447 return 0;
1544 brdp = stli_brds[portp->brdnr]; 1448 brdp = stli_brds[portp->brdnr];
1545 if (brdp == (stlibrd_t *) NULL) 1449 if (brdp == NULL)
1546 return(0); 1450 return 0;
1547 chbuf = (unsigned char *) buf; 1451 chbuf = (unsigned char *) buf;
1548 1452
1549/* 1453/*
1550 * All data is now local, shove as much as possible into shared memory. 1454 * All data is now local, shove as much as possible into shared memory.
1551 */ 1455 */
1552 save_flags(flags); 1456 spin_lock_irqsave(&brd_lock, flags);
1553 cli();
1554 EBRDENABLE(brdp); 1457 EBRDENABLE(brdp);
1555 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1458 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1556 head = (unsigned int) ap->txq.head; 1459 head = (unsigned int) readw(&ap->txq.head);
1557 tail = (unsigned int) ap->txq.tail; 1460 tail = (unsigned int) readw(&ap->txq.tail);
1558 if (tail != ((unsigned int) ap->txq.tail)) 1461 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1559 tail = (unsigned int) ap->txq.tail; 1462 tail = (unsigned int) readw(&ap->txq.tail);
1560 size = portp->txsize; 1463 size = portp->txsize;
1561 if (head >= tail) { 1464 if (head >= tail) {
1562 len = size - (head - tail) - 1; 1465 len = size - (head - tail) - 1;
@@ -1568,11 +1471,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1568 1471
1569 len = MIN(len, count); 1472 len = MIN(len, count);
1570 count = 0; 1473 count = 0;
1571 shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); 1474 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
1572 1475
1573 while (len > 0) { 1476 while (len > 0) {
1574 stlen = MIN(len, stlen); 1477 stlen = MIN(len, stlen);
1575 memcpy((shbuf + head), chbuf, stlen); 1478 memcpy_toio(shbuf + head, chbuf, stlen);
1576 chbuf += stlen; 1479 chbuf += stlen;
1577 len -= stlen; 1480 len -= stlen;
1578 count += stlen; 1481 count += stlen;
@@ -1583,20 +1486,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1583 } 1486 }
1584 } 1487 }
1585 1488
1586 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1489 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1587 ap->txq.head = head; 1490 writew(head, &ap->txq.head);
1588 if (test_bit(ST_TXBUSY, &portp->state)) { 1491 if (test_bit(ST_TXBUSY, &portp->state)) {
1589 if (ap->changed.data & DT_TXEMPTY) 1492 if (readl(&ap->changed.data) & DT_TXEMPTY)
1590 ap->changed.data &= ~DT_TXEMPTY; 1493 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1591 } 1494 }
1592 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1495 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1593 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1496 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1594 portp->portidx; 1497 portp->portidx;
1595 *bits |= portp->portbit; 1498 writeb(readb(bits) | portp->portbit, bits);
1596 set_bit(ST_TXBUSY, &portp->state); 1499 set_bit(ST_TXBUSY, &portp->state);
1597 EBRDDISABLE(brdp); 1500 EBRDDISABLE(brdp);
1598 1501 spin_unlock_irqrestore(&brd_lock, flags);
1599 restore_flags(flags);
1600 1502
1601 return(count); 1503 return(count);
1602} 1504}
@@ -1613,14 +1515,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1613 1515
1614static void stli_putchar(struct tty_struct *tty, unsigned char ch) 1516static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1615{ 1517{
1616#ifdef DEBUG
1617 printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch);
1618#endif
1619
1620 if (tty == (struct tty_struct *) NULL)
1621 return;
1622 if (tty != stli_txcooktty) { 1518 if (tty != stli_txcooktty) {
1623 if (stli_txcooktty != (struct tty_struct *) NULL) 1519 if (stli_txcooktty != NULL)
1624 stli_flushchars(stli_txcooktty); 1520 stli_flushchars(stli_txcooktty);
1625 stli_txcooktty = tty; 1521 stli_txcooktty = tty;
1626 } 1522 }
@@ -1640,29 +1536,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1640 1536
1641static void stli_flushchars(struct tty_struct *tty) 1537static void stli_flushchars(struct tty_struct *tty)
1642{ 1538{
1643 volatile cdkhdr_t *hdrp; 1539 cdkhdr_t __iomem *hdrp;
1644 volatile unsigned char *bits; 1540 unsigned char __iomem *bits;
1645 volatile cdkasy_t *ap; 1541 cdkasy_t __iomem *ap;
1646 struct tty_struct *cooktty; 1542 struct tty_struct *cooktty;
1647 stliport_t *portp; 1543 stliport_t *portp;
1648 stlibrd_t *brdp; 1544 stlibrd_t *brdp;
1649 unsigned int len, stlen, head, tail, size, count, cooksize; 1545 unsigned int len, stlen, head, tail, size, count, cooksize;
1650 unsigned char *buf, *shbuf; 1546 unsigned char *buf;
1651 unsigned long flags; 1547 unsigned char __iomem *shbuf;
1652 1548 unsigned long flags;
1653#ifdef DEBUG
1654 printk("stli_flushchars(tty=%x)\n", (int) tty);
1655#endif
1656 1549
1657 cooksize = stli_txcooksize; 1550 cooksize = stli_txcooksize;
1658 cooktty = stli_txcooktty; 1551 cooktty = stli_txcooktty;
1659 stli_txcooksize = 0; 1552 stli_txcooksize = 0;
1660 stli_txcookrealsize = 0; 1553 stli_txcookrealsize = 0;
1661 stli_txcooktty = (struct tty_struct *) NULL; 1554 stli_txcooktty = NULL;
1662 1555
1663 if (tty == (struct tty_struct *) NULL) 1556 if (tty == NULL)
1664 return; 1557 return;
1665 if (cooktty == (struct tty_struct *) NULL) 1558 if (cooktty == NULL)
1666 return; 1559 return;
1667 if (tty != cooktty) 1560 if (tty != cooktty)
1668 tty = cooktty; 1561 tty = cooktty;
@@ -1670,23 +1563,22 @@ static void stli_flushchars(struct tty_struct *tty)
1670 return; 1563 return;
1671 1564
1672 portp = tty->driver_data; 1565 portp = tty->driver_data;
1673 if (portp == (stliport_t *) NULL) 1566 if (portp == NULL)
1674 return; 1567 return;
1675 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1568 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1676 return; 1569 return;
1677 brdp = stli_brds[portp->brdnr]; 1570 brdp = stli_brds[portp->brdnr];
1678 if (brdp == (stlibrd_t *) NULL) 1571 if (brdp == NULL)
1679 return; 1572 return;
1680 1573
1681 save_flags(flags); 1574 spin_lock_irqsave(&brd_lock, flags);
1682 cli();
1683 EBRDENABLE(brdp); 1575 EBRDENABLE(brdp);
1684 1576
1685 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1577 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1686 head = (unsigned int) ap->txq.head; 1578 head = (unsigned int) readw(&ap->txq.head);
1687 tail = (unsigned int) ap->txq.tail; 1579 tail = (unsigned int) readw(&ap->txq.tail);
1688 if (tail != ((unsigned int) ap->txq.tail)) 1580 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1689 tail = (unsigned int) ap->txq.tail; 1581 tail = (unsigned int) readw(&ap->txq.tail);
1690 size = portp->txsize; 1582 size = portp->txsize;
1691 if (head >= tail) { 1583 if (head >= tail) {
1692 len = size - (head - tail) - 1; 1584 len = size - (head - tail) - 1;
@@ -1703,7 +1595,7 @@ static void stli_flushchars(struct tty_struct *tty)
1703 1595
1704 while (len > 0) { 1596 while (len > 0) {
1705 stlen = MIN(len, stlen); 1597 stlen = MIN(len, stlen);
1706 memcpy((shbuf + head), buf, stlen); 1598 memcpy_toio(shbuf + head, buf, stlen);
1707 buf += stlen; 1599 buf += stlen;
1708 len -= stlen; 1600 len -= stlen;
1709 count += stlen; 1601 count += stlen;
@@ -1714,73 +1606,66 @@ static void stli_flushchars(struct tty_struct *tty)
1714 } 1606 }
1715 } 1607 }
1716 1608
1717 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1609 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1718 ap->txq.head = head; 1610 writew(head, &ap->txq.head);
1719 1611
1720 if (test_bit(ST_TXBUSY, &portp->state)) { 1612 if (test_bit(ST_TXBUSY, &portp->state)) {
1721 if (ap->changed.data & DT_TXEMPTY) 1613 if (readl(&ap->changed.data) & DT_TXEMPTY)
1722 ap->changed.data &= ~DT_TXEMPTY; 1614 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1723 } 1615 }
1724 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1616 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1725 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1617 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1726 portp->portidx; 1618 portp->portidx;
1727 *bits |= portp->portbit; 1619 writeb(readb(bits) | portp->portbit, bits);
1728 set_bit(ST_TXBUSY, &portp->state); 1620 set_bit(ST_TXBUSY, &portp->state);
1729 1621
1730 EBRDDISABLE(brdp); 1622 EBRDDISABLE(brdp);
1731 restore_flags(flags); 1623 spin_unlock_irqrestore(&brd_lock, flags);
1732} 1624}
1733 1625
1734/*****************************************************************************/ 1626/*****************************************************************************/
1735 1627
1736static int stli_writeroom(struct tty_struct *tty) 1628static int stli_writeroom(struct tty_struct *tty)
1737{ 1629{
1738 volatile cdkasyrq_t *rp; 1630 cdkasyrq_t __iomem *rp;
1739 stliport_t *portp; 1631 stliport_t *portp;
1740 stlibrd_t *brdp; 1632 stlibrd_t *brdp;
1741 unsigned int head, tail, len; 1633 unsigned int head, tail, len;
1742 unsigned long flags; 1634 unsigned long flags;
1743
1744#ifdef DEBUG
1745 printk("stli_writeroom(tty=%x)\n", (int) tty);
1746#endif
1747 1635
1748 if (tty == (struct tty_struct *) NULL)
1749 return(0);
1750 if (tty == stli_txcooktty) { 1636 if (tty == stli_txcooktty) {
1751 if (stli_txcookrealsize != 0) { 1637 if (stli_txcookrealsize != 0) {
1752 len = stli_txcookrealsize - stli_txcooksize; 1638 len = stli_txcookrealsize - stli_txcooksize;
1753 return(len); 1639 return len;
1754 } 1640 }
1755 } 1641 }
1756 1642
1757 portp = tty->driver_data; 1643 portp = tty->driver_data;
1758 if (portp == (stliport_t *) NULL) 1644 if (portp == NULL)
1759 return(0); 1645 return 0;
1760 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1646 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1761 return(0); 1647 return 0;
1762 brdp = stli_brds[portp->brdnr]; 1648 brdp = stli_brds[portp->brdnr];
1763 if (brdp == (stlibrd_t *) NULL) 1649 if (brdp == NULL)
1764 return(0); 1650 return 0;
1765 1651
1766 save_flags(flags); 1652 spin_lock_irqsave(&brd_lock, flags);
1767 cli();
1768 EBRDENABLE(brdp); 1653 EBRDENABLE(brdp);
1769 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1654 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1770 head = (unsigned int) rp->head; 1655 head = (unsigned int) readw(&rp->head);
1771 tail = (unsigned int) rp->tail; 1656 tail = (unsigned int) readw(&rp->tail);
1772 if (tail != ((unsigned int) rp->tail)) 1657 if (tail != ((unsigned int) readw(&rp->tail)))
1773 tail = (unsigned int) rp->tail; 1658 tail = (unsigned int) readw(&rp->tail);
1774 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head); 1659 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head);
1775 len--; 1660 len--;
1776 EBRDDISABLE(brdp); 1661 EBRDDISABLE(brdp);
1777 restore_flags(flags); 1662 spin_unlock_irqrestore(&brd_lock, flags);
1778 1663
1779 if (tty == stli_txcooktty) { 1664 if (tty == stli_txcooktty) {
1780 stli_txcookrealsize = len; 1665 stli_txcookrealsize = len;
1781 len -= stli_txcooksize; 1666 len -= stli_txcooksize;
1782 } 1667 }
1783 return(len); 1668 return len;
1784} 1669}
1785 1670
1786/*****************************************************************************/ 1671/*****************************************************************************/
@@ -1795,44 +1680,37 @@ static int stli_writeroom(struct tty_struct *tty)
1795 1680
1796static int stli_charsinbuffer(struct tty_struct *tty) 1681static int stli_charsinbuffer(struct tty_struct *tty)
1797{ 1682{
1798 volatile cdkasyrq_t *rp; 1683 cdkasyrq_t __iomem *rp;
1799 stliport_t *portp; 1684 stliport_t *portp;
1800 stlibrd_t *brdp; 1685 stlibrd_t *brdp;
1801 unsigned int head, tail, len; 1686 unsigned int head, tail, len;
1802 unsigned long flags; 1687 unsigned long flags;
1803
1804#ifdef DEBUG
1805 printk("stli_charsinbuffer(tty=%x)\n", (int) tty);
1806#endif
1807 1688
1808 if (tty == (struct tty_struct *) NULL)
1809 return(0);
1810 if (tty == stli_txcooktty) 1689 if (tty == stli_txcooktty)
1811 stli_flushchars(tty); 1690 stli_flushchars(tty);
1812 portp = tty->driver_data; 1691 portp = tty->driver_data;
1813 if (portp == (stliport_t *) NULL) 1692 if (portp == NULL)
1814 return(0); 1693 return 0;
1815 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1694 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1816 return(0); 1695 return 0;
1817 brdp = stli_brds[portp->brdnr]; 1696 brdp = stli_brds[portp->brdnr];
1818 if (brdp == (stlibrd_t *) NULL) 1697 if (brdp == NULL)
1819 return(0); 1698 return 0;
1820 1699
1821 save_flags(flags); 1700 spin_lock_irqsave(&brd_lock, flags);
1822 cli();
1823 EBRDENABLE(brdp); 1701 EBRDENABLE(brdp);
1824 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1702 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1825 head = (unsigned int) rp->head; 1703 head = (unsigned int) readw(&rp->head);
1826 tail = (unsigned int) rp->tail; 1704 tail = (unsigned int) readw(&rp->tail);
1827 if (tail != ((unsigned int) rp->tail)) 1705 if (tail != ((unsigned int) readw(&rp->tail)))
1828 tail = (unsigned int) rp->tail; 1706 tail = (unsigned int) readw(&rp->tail);
1829 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head)); 1707 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head));
1830 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state)) 1708 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state))
1831 len = 1; 1709 len = 1;
1832 EBRDDISABLE(brdp); 1710 EBRDDISABLE(brdp);
1833 restore_flags(flags); 1711 spin_unlock_irqrestore(&brd_lock, flags);
1834 1712
1835 return(len); 1713 return len;
1836} 1714}
1837 1715
1838/*****************************************************************************/ 1716/*****************************************************************************/
@@ -1843,12 +1721,8 @@ static int stli_charsinbuffer(struct tty_struct *tty)
1843 1721
1844static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) 1722static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1845{ 1723{
1846 struct serial_struct sio; 1724 struct serial_struct sio;
1847 stlibrd_t *brdp; 1725 stlibrd_t *brdp;
1848
1849#ifdef DEBUG
1850 printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
1851#endif
1852 1726
1853 memset(&sio, 0, sizeof(struct serial_struct)); 1727 memset(&sio, 0, sizeof(struct serial_struct));
1854 sio.type = PORT_UNKNOWN; 1728 sio.type = PORT_UNKNOWN;
@@ -1863,7 +1737,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1863 sio.hub6 = 0; 1737 sio.hub6 = 0;
1864 1738
1865 brdp = stli_brds[portp->brdnr]; 1739 brdp = stli_brds[portp->brdnr];
1866 if (brdp != (stlibrd_t *) NULL) 1740 if (brdp != NULL)
1867 sio.port = brdp->iobase; 1741 sio.port = brdp->iobase;
1868 1742
1869 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? 1743 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ?
@@ -1880,12 +1754,8 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1880 1754
1881static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) 1755static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1882{ 1756{
1883 struct serial_struct sio; 1757 struct serial_struct sio;
1884 int rc; 1758 int rc;
1885
1886#ifdef DEBUG
1887 printk("stli_setserial(portp=%p,sp=%p)\n", portp, sp);
1888#endif
1889 1759
1890 if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) 1760 if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
1891 return -EFAULT; 1761 return -EFAULT;
@@ -1894,7 +1764,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1894 (sio.close_delay != portp->close_delay) || 1764 (sio.close_delay != portp->close_delay) ||
1895 ((sio.flags & ~ASYNC_USR_MASK) != 1765 ((sio.flags & ~ASYNC_USR_MASK) !=
1896 (portp->flags & ~ASYNC_USR_MASK))) 1766 (portp->flags & ~ASYNC_USR_MASK)))
1897 return(-EPERM); 1767 return -EPERM;
1898 } 1768 }
1899 1769
1900 portp->flags = (portp->flags & ~ASYNC_USR_MASK) | 1770 portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
@@ -1905,8 +1775,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1905 portp->custom_divisor = sio.custom_divisor; 1775 portp->custom_divisor = sio.custom_divisor;
1906 1776
1907 if ((rc = stli_setport(portp)) < 0) 1777 if ((rc = stli_setport(portp)) < 0)
1908 return(rc); 1778 return rc;
1909 return(0); 1779 return 0;
1910} 1780}
1911 1781
1912/*****************************************************************************/ 1782/*****************************************************************************/
@@ -1917,19 +1787,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file)
1917 stlibrd_t *brdp; 1787 stlibrd_t *brdp;
1918 int rc; 1788 int rc;
1919 1789
1920 if (portp == (stliport_t *) NULL) 1790 if (portp == NULL)
1921 return(-ENODEV); 1791 return -ENODEV;
1922 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1792 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1923 return(0); 1793 return 0;
1924 brdp = stli_brds[portp->brdnr]; 1794 brdp = stli_brds[portp->brdnr];
1925 if (brdp == (stlibrd_t *) NULL) 1795 if (brdp == NULL)
1926 return(0); 1796 return 0;
1927 if (tty->flags & (1 << TTY_IO_ERROR)) 1797 if (tty->flags & (1 << TTY_IO_ERROR))
1928 return(-EIO); 1798 return -EIO;
1929 1799
1930 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, 1800 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS,
1931 &portp->asig, sizeof(asysigs_t), 1)) < 0) 1801 &portp->asig, sizeof(asysigs_t), 1)) < 0)
1932 return(rc); 1802 return rc;
1933 1803
1934 return stli_mktiocm(portp->asig.sigvalue); 1804 return stli_mktiocm(portp->asig.sigvalue);
1935} 1805}
@@ -1941,15 +1811,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1941 stlibrd_t *brdp; 1811 stlibrd_t *brdp;
1942 int rts = -1, dtr = -1; 1812 int rts = -1, dtr = -1;
1943 1813
1944 if (portp == (stliport_t *) NULL) 1814 if (portp == NULL)
1945 return(-ENODEV); 1815 return -ENODEV;
1946 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1816 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1947 return(0); 1817 return 0;
1948 brdp = stli_brds[portp->brdnr]; 1818 brdp = stli_brds[portp->brdnr];
1949 if (brdp == (stlibrd_t *) NULL) 1819 if (brdp == NULL)
1950 return(0); 1820 return 0;
1951 if (tty->flags & (1 << TTY_IO_ERROR)) 1821 if (tty->flags & (1 << TTY_IO_ERROR))
1952 return(-EIO); 1822 return -EIO;
1953 1823
1954 if (set & TIOCM_RTS) 1824 if (set & TIOCM_RTS)
1955 rts = 1; 1825 rts = 1;
@@ -1968,32 +1838,25 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1968 1838
1969static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1839static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
1970{ 1840{
1971 stliport_t *portp; 1841 stliport_t *portp;
1972 stlibrd_t *brdp; 1842 stlibrd_t *brdp;
1973 unsigned int ival; 1843 unsigned int ival;
1974 int rc; 1844 int rc;
1975 void __user *argp = (void __user *)arg; 1845 void __user *argp = (void __user *)arg;
1976 1846
1977#ifdef DEBUG
1978 printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
1979 (int) tty, (int) file, cmd, (int) arg);
1980#endif
1981
1982 if (tty == (struct tty_struct *) NULL)
1983 return(-ENODEV);
1984 portp = tty->driver_data; 1847 portp = tty->driver_data;
1985 if (portp == (stliport_t *) NULL) 1848 if (portp == NULL)
1986 return(-ENODEV); 1849 return -ENODEV;
1987 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1850 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1988 return(0); 1851 return 0;
1989 brdp = stli_brds[portp->brdnr]; 1852 brdp = stli_brds[portp->brdnr];
1990 if (brdp == (stlibrd_t *) NULL) 1853 if (brdp == NULL)
1991 return(0); 1854 return 0;
1992 1855
1993 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1856 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
1994 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { 1857 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) {
1995 if (tty->flags & (1 << TTY_IO_ERROR)) 1858 if (tty->flags & (1 << TTY_IO_ERROR))
1996 return(-EIO); 1859 return -EIO;
1997 } 1860 }
1998 1861
1999 rc = 0; 1862 rc = 0;
@@ -2040,7 +1903,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2040 break; 1903 break;
2041 } 1904 }
2042 1905
2043 return(rc); 1906 return rc;
2044} 1907}
2045 1908
2046/*****************************************************************************/ 1909/*****************************************************************************/
@@ -2052,24 +1915,20 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2052 1915
2053static void stli_settermios(struct tty_struct *tty, struct termios *old) 1916static void stli_settermios(struct tty_struct *tty, struct termios *old)
2054{ 1917{
2055 stliport_t *portp; 1918 stliport_t *portp;
2056 stlibrd_t *brdp; 1919 stlibrd_t *brdp;
2057 struct termios *tiosp; 1920 struct termios *tiosp;
2058 asyport_t aport; 1921 asyport_t aport;
2059
2060#ifdef DEBUG
2061 printk("stli_settermios(tty=%x,old=%x)\n", (int) tty, (int) old);
2062#endif
2063 1922
2064 if (tty == (struct tty_struct *) NULL) 1923 if (tty == NULL)
2065 return; 1924 return;
2066 portp = tty->driver_data; 1925 portp = tty->driver_data;
2067 if (portp == (stliport_t *) NULL) 1926 if (portp == NULL)
2068 return; 1927 return;
2069 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1928 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2070 return; 1929 return;
2071 brdp = stli_brds[portp->brdnr]; 1930 brdp = stli_brds[portp->brdnr];
2072 if (brdp == (stlibrd_t *) NULL) 1931 if (brdp == NULL)
2073 return; 1932 return;
2074 1933
2075 tiosp = tty->termios; 1934 tiosp = tty->termios;
@@ -2102,18 +1961,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
2102 1961
2103static void stli_throttle(struct tty_struct *tty) 1962static void stli_throttle(struct tty_struct *tty)
2104{ 1963{
2105 stliport_t *portp; 1964 stliport_t *portp = tty->driver_data;
2106 1965 if (portp == NULL)
2107#ifdef DEBUG
2108 printk("stli_throttle(tty=%x)\n", (int) tty);
2109#endif
2110
2111 if (tty == (struct tty_struct *) NULL)
2112 return; 1966 return;
2113 portp = tty->driver_data;
2114 if (portp == (stliport_t *) NULL)
2115 return;
2116
2117 set_bit(ST_RXSTOP, &portp->state); 1967 set_bit(ST_RXSTOP, &portp->state);
2118} 1968}
2119 1969
@@ -2127,88 +1977,30 @@ static void stli_throttle(struct tty_struct *tty)
2127 1977
2128static void stli_unthrottle(struct tty_struct *tty) 1978static void stli_unthrottle(struct tty_struct *tty)
2129{ 1979{
2130 stliport_t *portp; 1980 stliport_t *portp = tty->driver_data;
2131 1981 if (portp == NULL)
2132#ifdef DEBUG
2133 printk("stli_unthrottle(tty=%x)\n", (int) tty);
2134#endif
2135
2136 if (tty == (struct tty_struct *) NULL)
2137 return;
2138 portp = tty->driver_data;
2139 if (portp == (stliport_t *) NULL)
2140 return; 1982 return;
2141
2142 clear_bit(ST_RXSTOP, &portp->state); 1983 clear_bit(ST_RXSTOP, &portp->state);
2143} 1984}
2144 1985
2145/*****************************************************************************/ 1986/*****************************************************************************/
2146 1987
2147/* 1988/*
2148 * Stop the transmitter. Basically to do this we will just turn TX 1989 * Stop the transmitter.
2149 * interrupts off.
2150 */ 1990 */
2151 1991
2152static void stli_stop(struct tty_struct *tty) 1992static void stli_stop(struct tty_struct *tty)
2153{ 1993{
2154 stlibrd_t *brdp;
2155 stliport_t *portp;
2156 asyctrl_t actrl;
2157
2158#ifdef DEBUG
2159 printk("stli_stop(tty=%x)\n", (int) tty);
2160#endif
2161
2162 if (tty == (struct tty_struct *) NULL)
2163 return;
2164 portp = tty->driver_data;
2165 if (portp == (stliport_t *) NULL)
2166 return;
2167 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2168 return;
2169 brdp = stli_brds[portp->brdnr];
2170 if (brdp == (stlibrd_t *) NULL)
2171 return;
2172
2173 memset(&actrl, 0, sizeof(asyctrl_t));
2174 actrl.txctrl = CT_STOPFLOW;
2175#if 0
2176 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2177#endif
2178} 1994}
2179 1995
2180/*****************************************************************************/ 1996/*****************************************************************************/
2181 1997
2182/* 1998/*
2183 * Start the transmitter again. Just turn TX interrupts back on. 1999 * Start the transmitter again.
2184 */ 2000 */
2185 2001
2186static void stli_start(struct tty_struct *tty) 2002static void stli_start(struct tty_struct *tty)
2187{ 2003{
2188 stliport_t *portp;
2189 stlibrd_t *brdp;
2190 asyctrl_t actrl;
2191
2192#ifdef DEBUG
2193 printk("stli_start(tty=%x)\n", (int) tty);
2194#endif
2195
2196 if (tty == (struct tty_struct *) NULL)
2197 return;
2198 portp = tty->driver_data;
2199 if (portp == (stliport_t *) NULL)
2200 return;
2201 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2202 return;
2203 brdp = stli_brds[portp->brdnr];
2204 if (brdp == (stlibrd_t *) NULL)
2205 return;
2206
2207 memset(&actrl, 0, sizeof(asyctrl_t));
2208 actrl.txctrl = CT_STARTFLOW;
2209#if 0
2210 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2211#endif
2212} 2004}
2213 2005
2214/*****************************************************************************/ 2006/*****************************************************************************/
@@ -2224,22 +2016,9 @@ static void stli_start(struct tty_struct *tty)
2224 2016
2225static void stli_dohangup(void *arg) 2017static void stli_dohangup(void *arg)
2226{ 2018{
2227 stliport_t *portp; 2019 stliport_t *portp = (stliport_t *) arg;
2228 2020 if (portp->tty != NULL) {
2229#ifdef DEBUG 2021 tty_hangup(portp->tty);
2230 printk(KERN_DEBUG "stli_dohangup(portp=%x)\n", (int) arg);
2231#endif
2232
2233 /*
2234 * FIXME: There's a module removal race here: tty_hangup
2235 * calls schedule_work which will call into this
2236 * driver later.
2237 */
2238 portp = (stliport_t *) arg;
2239 if (portp != (stliport_t *) NULL) {
2240 if (portp->tty != (struct tty_struct *) NULL) {
2241 tty_hangup(portp->tty);
2242 }
2243 } 2022 }
2244} 2023}
2245 2024
@@ -2254,31 +2033,25 @@ static void stli_dohangup(void *arg)
2254 2033
2255static void stli_hangup(struct tty_struct *tty) 2034static void stli_hangup(struct tty_struct *tty)
2256{ 2035{
2257 stliport_t *portp; 2036 stliport_t *portp;
2258 stlibrd_t *brdp; 2037 stlibrd_t *brdp;
2259 unsigned long flags; 2038 unsigned long flags;
2260
2261#ifdef DEBUG
2262 printk(KERN_DEBUG "stli_hangup(tty=%x)\n", (int) tty);
2263#endif
2264 2039
2265 if (tty == (struct tty_struct *) NULL)
2266 return;
2267 portp = tty->driver_data; 2040 portp = tty->driver_data;
2268 if (portp == (stliport_t *) NULL) 2041 if (portp == NULL)
2269 return; 2042 return;
2270 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2043 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2271 return; 2044 return;
2272 brdp = stli_brds[portp->brdnr]; 2045 brdp = stli_brds[portp->brdnr];
2273 if (brdp == (stlibrd_t *) NULL) 2046 if (brdp == NULL)
2274 return; 2047 return;
2275 2048
2276 portp->flags &= ~ASYNC_INITIALIZED; 2049 portp->flags &= ~ASYNC_INITIALIZED;
2277 2050
2278 save_flags(flags); 2051 if (!test_bit(ST_CLOSING, &portp->state))
2279 cli();
2280 if (! test_bit(ST_CLOSING, &portp->state))
2281 stli_rawclose(brdp, portp, 0, 0); 2052 stli_rawclose(brdp, portp, 0, 0);
2053
2054 spin_lock_irqsave(&stli_lock, flags);
2282 if (tty->termios->c_cflag & HUPCL) { 2055 if (tty->termios->c_cflag & HUPCL) {
2283 stli_mkasysigs(&portp->asig, 0, 0); 2056 stli_mkasysigs(&portp->asig, 0, 0);
2284 if (test_bit(ST_CMDING, &portp->state)) { 2057 if (test_bit(ST_CMDING, &portp->state)) {
@@ -2290,14 +2063,15 @@ static void stli_hangup(struct tty_struct *tty)
2290 &portp->asig, sizeof(asysigs_t), 0); 2063 &portp->asig, sizeof(asysigs_t), 0);
2291 } 2064 }
2292 } 2065 }
2293 restore_flags(flags);
2294 2066
2295 clear_bit(ST_TXBUSY, &portp->state); 2067 clear_bit(ST_TXBUSY, &portp->state);
2296 clear_bit(ST_RXSTOP, &portp->state); 2068 clear_bit(ST_RXSTOP, &portp->state);
2297 set_bit(TTY_IO_ERROR, &tty->flags); 2069 set_bit(TTY_IO_ERROR, &tty->flags);
2298 portp->tty = (struct tty_struct *) NULL; 2070 portp->tty = NULL;
2299 portp->flags &= ~ASYNC_NORMAL_ACTIVE; 2071 portp->flags &= ~ASYNC_NORMAL_ACTIVE;
2300 portp->refcount = 0; 2072 portp->refcount = 0;
2073 spin_unlock_irqrestore(&stli_lock, flags);
2074
2301 wake_up_interruptible(&portp->open_wait); 2075 wake_up_interruptible(&portp->open_wait);
2302} 2076}
2303 2077
@@ -2312,29 +2086,22 @@ static void stli_hangup(struct tty_struct *tty)
2312 2086
2313static void stli_flushbuffer(struct tty_struct *tty) 2087static void stli_flushbuffer(struct tty_struct *tty)
2314{ 2088{
2315 stliport_t *portp; 2089 stliport_t *portp;
2316 stlibrd_t *brdp; 2090 stlibrd_t *brdp;
2317 unsigned long ftype, flags; 2091 unsigned long ftype, flags;
2318
2319#ifdef DEBUG
2320 printk(KERN_DEBUG "stli_flushbuffer(tty=%x)\n", (int) tty);
2321#endif
2322 2092
2323 if (tty == (struct tty_struct *) NULL)
2324 return;
2325 portp = tty->driver_data; 2093 portp = tty->driver_data;
2326 if (portp == (stliport_t *) NULL) 2094 if (portp == NULL)
2327 return; 2095 return;
2328 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2096 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2329 return; 2097 return;
2330 brdp = stli_brds[portp->brdnr]; 2098 brdp = stli_brds[portp->brdnr];
2331 if (brdp == (stlibrd_t *) NULL) 2099 if (brdp == NULL)
2332 return; 2100 return;
2333 2101
2334 save_flags(flags); 2102 spin_lock_irqsave(&brd_lock, flags);
2335 cli();
2336 if (tty == stli_txcooktty) { 2103 if (tty == stli_txcooktty) {
2337 stli_txcooktty = (struct tty_struct *) NULL; 2104 stli_txcooktty = NULL;
2338 stli_txcooksize = 0; 2105 stli_txcooksize = 0;
2339 stli_txcookrealsize = 0; 2106 stli_txcookrealsize = 0;
2340 } 2107 }
@@ -2346,15 +2113,10 @@ static void stli_flushbuffer(struct tty_struct *tty)
2346 ftype |= FLUSHRX; 2113 ftype |= FLUSHRX;
2347 clear_bit(ST_DOFLUSHRX, &portp->state); 2114 clear_bit(ST_DOFLUSHRX, &portp->state);
2348 } 2115 }
2349 stli_sendcmd(brdp, portp, A_FLUSH, &ftype, 2116 __stli_sendcmd(brdp, portp, A_FLUSH, &ftype, sizeof(u32), 0);
2350 sizeof(unsigned long), 0);
2351 } 2117 }
2352 restore_flags(flags); 2118 spin_unlock_irqrestore(&brd_lock, flags);
2353 2119 tty_wakeup(tty);
2354 wake_up_interruptible(&tty->write_wait);
2355 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
2356 tty->ldisc.write_wakeup)
2357 (tty->ldisc.write_wakeup)(tty);
2358} 2120}
2359 2121
2360/*****************************************************************************/ 2122/*****************************************************************************/
@@ -2364,55 +2126,31 @@ static void stli_breakctl(struct tty_struct *tty, int state)
2364 stlibrd_t *brdp; 2126 stlibrd_t *brdp;
2365 stliport_t *portp; 2127 stliport_t *portp;
2366 long arg; 2128 long arg;
2367 /* long savestate, savetime; */
2368 2129
2369#ifdef DEBUG
2370 printk(KERN_DEBUG "stli_breakctl(tty=%x,state=%d)\n", (int) tty, state);
2371#endif
2372
2373 if (tty == (struct tty_struct *) NULL)
2374 return;
2375 portp = tty->driver_data; 2130 portp = tty->driver_data;
2376 if (portp == (stliport_t *) NULL) 2131 if (portp == NULL)
2377 return; 2132 return;
2378 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2133 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2379 return; 2134 return;
2380 brdp = stli_brds[portp->brdnr]; 2135 brdp = stli_brds[portp->brdnr];
2381 if (brdp == (stlibrd_t *) NULL) 2136 if (brdp == NULL)
2382 return; 2137 return;
2383 2138
2384/*
2385 * Due to a bug in the tty send_break() code we need to preserve
2386 * the current process state and timeout...
2387 savetime = current->timeout;
2388 savestate = current->state;
2389 */
2390
2391 arg = (state == -1) ? BREAKON : BREAKOFF; 2139 arg = (state == -1) ? BREAKON : BREAKOFF;
2392 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); 2140 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0);
2393
2394/*
2395 *
2396 current->timeout = savetime;
2397 current->state = savestate;
2398 */
2399} 2141}
2400 2142
2401/*****************************************************************************/ 2143/*****************************************************************************/
2402 2144
2403static void stli_waituntilsent(struct tty_struct *tty, int timeout) 2145static void stli_waituntilsent(struct tty_struct *tty, int timeout)
2404{ 2146{
2405 stliport_t *portp; 2147 stliport_t *portp;
2406 unsigned long tend; 2148 unsigned long tend;
2407 2149
2408#ifdef DEBUG 2150 if (tty == NULL)
2409 printk(KERN_DEBUG "stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty, timeout);
2410#endif
2411
2412 if (tty == (struct tty_struct *) NULL)
2413 return; 2151 return;
2414 portp = tty->driver_data; 2152 portp = tty->driver_data;
2415 if (portp == (stliport_t *) NULL) 2153 if (portp == NULL)
2416 return; 2154 return;
2417 2155
2418 if (timeout == 0) 2156 if (timeout == 0)
@@ -2436,19 +2174,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2436 stliport_t *portp; 2174 stliport_t *portp;
2437 asyctrl_t actrl; 2175 asyctrl_t actrl;
2438 2176
2439#ifdef DEBUG
2440 printk(KERN_DEBUG "stli_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch);
2441#endif
2442
2443 if (tty == (struct tty_struct *) NULL)
2444 return;
2445 portp = tty->driver_data; 2177 portp = tty->driver_data;
2446 if (portp == (stliport_t *) NULL) 2178 if (portp == NULL)
2447 return; 2179 return;
2448 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2180 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2449 return; 2181 return;
2450 brdp = stli_brds[portp->brdnr]; 2182 brdp = stli_brds[portp->brdnr];
2451 if (brdp == (stlibrd_t *) NULL) 2183 if (brdp == NULL)
2452 return; 2184 return;
2453 2185
2454 memset(&actrl, 0, sizeof(asyctrl_t)); 2186 memset(&actrl, 0, sizeof(asyctrl_t));
@@ -2460,7 +2192,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2460 actrl.txctrl = CT_SENDCHR; 2192 actrl.txctrl = CT_SENDCHR;
2461 actrl.tximdch = ch; 2193 actrl.tximdch = ch;
2462 } 2194 }
2463
2464 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); 2195 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2465} 2196}
2466 2197
@@ -2476,17 +2207,17 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2476 2207
2477static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos) 2208static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos)
2478{ 2209{
2479 char *sp, *uart; 2210 char *sp, *uart;
2480 int rc, cnt; 2211 int rc, cnt;
2481 2212
2482 rc = stli_portcmdstats(portp); 2213 rc = stli_portcmdstats(portp);
2483 2214
2484 uart = "UNKNOWN"; 2215 uart = "UNKNOWN";
2485 if (brdp->state & BST_STARTED) { 2216 if (brdp->state & BST_STARTED) {
2486 switch (stli_comstats.hwid) { 2217 switch (stli_comstats.hwid) {
2487 case 0: uart = "2681"; break; 2218 case 0: uart = "2681"; break;
2488 case 1: uart = "SC26198"; break; 2219 case 1: uart = "SC26198"; break;
2489 default: uart = "CD1400"; break; 2220 default:uart = "CD1400"; break;
2490 } 2221 }
2491 } 2222 }
2492 2223
@@ -2537,17 +2268,11 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p
2537 2268
2538static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 2269static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
2539{ 2270{
2540 stlibrd_t *brdp; 2271 stlibrd_t *brdp;
2541 stliport_t *portp; 2272 stliport_t *portp;
2542 int brdnr, portnr, totalport; 2273 int brdnr, portnr, totalport;
2543 int curoff, maxoff; 2274 int curoff, maxoff;
2544 char *pos; 2275 char *pos;
2545
2546#ifdef DEBUG
2547 printk(KERN_DEBUG "stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
2548 "data=%x\n", (int) page, (int) start, (int) off, count,
2549 (int) eof, (int) data);
2550#endif
2551 2276
2552 pos = page; 2277 pos = page;
2553 totalport = 0; 2278 totalport = 0;
@@ -2568,7 +2293,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2568 */ 2293 */
2569 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2294 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
2570 brdp = stli_brds[brdnr]; 2295 brdp = stli_brds[brdnr];
2571 if (brdp == (stlibrd_t *) NULL) 2296 if (brdp == NULL)
2572 continue; 2297 continue;
2573 if (brdp->state == 0) 2298 if (brdp->state == 0)
2574 continue; 2299 continue;
@@ -2583,7 +2308,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2583 for (portnr = 0; (portnr < brdp->nrports); portnr++, 2308 for (portnr = 0; (portnr < brdp->nrports); portnr++,
2584 totalport++) { 2309 totalport++) {
2585 portp = brdp->ports[portnr]; 2310 portp = brdp->ports[portnr];
2586 if (portp == (stliport_t *) NULL) 2311 if (portp == NULL)
2587 continue; 2312 continue;
2588 if (off >= (curoff += MAXLINE)) 2313 if (off >= (curoff += MAXLINE))
2589 continue; 2314 continue;
@@ -2610,49 +2335,54 @@ stli_readdone:
2610 * a poll routine that does not have user context. Therefore you cannot 2335 * a poll routine that does not have user context. Therefore you cannot
2611 * copy back directly into user space, or to the kernel stack of a 2336 * copy back directly into user space, or to the kernel stack of a
2612 * process. This routine does not sleep, so can be called from anywhere. 2337 * process. This routine does not sleep, so can be called from anywhere.
2338 *
2339 * The caller must hold the brd_lock (see also stli_sendcmd the usual
2340 * entry point)
2613 */ 2341 */
2614 2342
2615static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 2343static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2616{ 2344{
2617 volatile cdkhdr_t *hdrp; 2345 cdkhdr_t __iomem *hdrp;
2618 volatile cdkctrl_t *cp; 2346 cdkctrl_t __iomem *cp;
2619 volatile unsigned char *bits; 2347 unsigned char __iomem *bits;
2620 unsigned long flags; 2348 unsigned long flags;
2621 2349
2622#ifdef DEBUG 2350 spin_lock_irqsave(&brd_lock, flags);
2623 printk(KERN_DEBUG "stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
2624 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
2625 (int) arg, size, copyback);
2626#endif
2627
2628 save_flags(flags);
2629 cli();
2630 2351
2631 if (test_bit(ST_CMDING, &portp->state)) { 2352 if (test_bit(ST_CMDING, &portp->state)) {
2632 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", 2353 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
2633 (int) cmd); 2354 (int) cmd);
2634 restore_flags(flags); 2355 spin_unlock_irqrestore(&brd_lock, flags);
2635 return; 2356 return;
2636 } 2357 }
2637 2358
2638 EBRDENABLE(brdp); 2359 EBRDENABLE(brdp);
2639 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 2360 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
2640 if (size > 0) { 2361 if (size > 0) {
2641 memcpy((void *) &(cp->args[0]), arg, size); 2362 memcpy_toio((void __iomem *) &(cp->args[0]), arg, size);
2642 if (copyback) { 2363 if (copyback) {
2643 portp->argp = arg; 2364 portp->argp = arg;
2644 portp->argsize = size; 2365 portp->argsize = size;
2645 } 2366 }
2646 } 2367 }
2647 cp->status = 0; 2368 writel(0, &cp->status);
2648 cp->cmd = cmd; 2369 writel(cmd, &cp->cmd);
2649 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2370 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2650 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 2371 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
2651 portp->portidx; 2372 portp->portidx;
2652 *bits |= portp->portbit; 2373 writeb(readb(bits) | portp->portbit, bits);
2653 set_bit(ST_CMDING, &portp->state); 2374 set_bit(ST_CMDING, &portp->state);
2654 EBRDDISABLE(brdp); 2375 EBRDDISABLE(brdp);
2655 restore_flags(flags); 2376 spin_unlock_irqrestore(&brd_lock, flags);
2377}
2378
2379static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2380{
2381 unsigned long flags;
2382
2383 spin_lock_irqsave(&brd_lock, flags);
2384 __stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
2385 spin_unlock_irqrestore(&brd_lock, flags);
2656} 2386}
2657 2387
2658/*****************************************************************************/ 2388/*****************************************************************************/
@@ -2667,28 +2397,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd,
2667 2397
2668static void stli_read(stlibrd_t *brdp, stliport_t *portp) 2398static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2669{ 2399{
2670 volatile cdkasyrq_t *rp; 2400 cdkasyrq_t __iomem *rp;
2671 volatile char *shbuf; 2401 char __iomem *shbuf;
2672 struct tty_struct *tty; 2402 struct tty_struct *tty;
2673 unsigned int head, tail, size; 2403 unsigned int head, tail, size;
2674 unsigned int len, stlen; 2404 unsigned int len, stlen;
2675
2676#ifdef DEBUG
2677 printk(KERN_DEBUG "stli_read(brdp=%x,portp=%d)\n",
2678 (int) brdp, (int) portp);
2679#endif
2680 2405
2681 if (test_bit(ST_RXSTOP, &portp->state)) 2406 if (test_bit(ST_RXSTOP, &portp->state))
2682 return; 2407 return;
2683 tty = portp->tty; 2408 tty = portp->tty;
2684 if (tty == (struct tty_struct *) NULL) 2409 if (tty == NULL)
2685 return; 2410 return;
2686 2411
2687 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2412 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2688 head = (unsigned int) rp->head; 2413 head = (unsigned int) readw(&rp->head);
2689 if (head != ((unsigned int) rp->head)) 2414 if (head != ((unsigned int) readw(&rp->head)))
2690 head = (unsigned int) rp->head; 2415 head = (unsigned int) readw(&rp->head);
2691 tail = (unsigned int) rp->tail; 2416 tail = (unsigned int) readw(&rp->tail);
2692 size = portp->rxsize; 2417 size = portp->rxsize;
2693 if (head >= tail) { 2418 if (head >= tail) {
2694 len = head - tail; 2419 len = head - tail;
@@ -2699,12 +2424,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2699 } 2424 }
2700 2425
2701 len = tty_buffer_request_room(tty, len); 2426 len = tty_buffer_request_room(tty, len);
2702 /* FIXME : iomap ? */ 2427
2703 shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); 2428 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->rxoffset);
2704 2429
2705 while (len > 0) { 2430 while (len > 0) {
2431 unsigned char *cptr;
2432
2706 stlen = MIN(len, stlen); 2433 stlen = MIN(len, stlen);
2707 tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); 2434 tty_prepare_flip_string(tty, &cptr, stlen);
2435 memcpy_fromio(cptr, shbuf + tail, stlen);
2708 len -= stlen; 2436 len -= stlen;
2709 tail += stlen; 2437 tail += stlen;
2710 if (tail >= size) { 2438 if (tail >= size) {
@@ -2712,8 +2440,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2712 stlen = head; 2440 stlen = head;
2713 } 2441 }
2714 } 2442 }
2715 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2443 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2716 rp->tail = tail; 2444 writew(tail, &rp->tail);
2717 2445
2718 if (head != tail) 2446 if (head != tail)
2719 set_bit(ST_RXING, &portp->state); 2447 set_bit(ST_RXING, &portp->state);
@@ -2729,9 +2457,9 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2729 * difficult to deal with them here. 2457 * difficult to deal with them here.
2730 */ 2458 */
2731 2459
2732static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) 2460static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
2733{ 2461{
2734 int cmd; 2462 int cmd;
2735 2463
2736 if (test_bit(ST_DOSIGS, &portp->state)) { 2464 if (test_bit(ST_DOSIGS, &portp->state)) {
2737 if (test_bit(ST_DOFLUSHTX, &portp->state) && 2465 if (test_bit(ST_DOFLUSHTX, &portp->state) &&
@@ -2746,10 +2474,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2746 clear_bit(ST_DOFLUSHTX, &portp->state); 2474 clear_bit(ST_DOFLUSHTX, &portp->state);
2747 clear_bit(ST_DOFLUSHRX, &portp->state); 2475 clear_bit(ST_DOFLUSHRX, &portp->state);
2748 clear_bit(ST_DOSIGS, &portp->state); 2476 clear_bit(ST_DOSIGS, &portp->state);
2749 memcpy((void *) &(cp->args[0]), (void *) &portp->asig, 2477 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &portp->asig,
2750 sizeof(asysigs_t)); 2478 sizeof(asysigs_t));
2751 cp->status = 0; 2479 writel(0, &cp->status);
2752 cp->cmd = cmd; 2480 writel(cmd, &cp->cmd);
2753 set_bit(ST_CMDING, &portp->state); 2481 set_bit(ST_CMDING, &portp->state);
2754 } else if (test_bit(ST_DOFLUSHTX, &portp->state) || 2482 } else if (test_bit(ST_DOFLUSHTX, &portp->state) ||
2755 test_bit(ST_DOFLUSHRX, &portp->state)) { 2483 test_bit(ST_DOFLUSHRX, &portp->state)) {
@@ -2757,9 +2485,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2757 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0); 2485 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0);
2758 clear_bit(ST_DOFLUSHTX, &portp->state); 2486 clear_bit(ST_DOFLUSHTX, &portp->state);
2759 clear_bit(ST_DOFLUSHRX, &portp->state); 2487 clear_bit(ST_DOFLUSHRX, &portp->state);
2760 memcpy((void *) &(cp->args[0]), (void *) &cmd, sizeof(int)); 2488 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &cmd, sizeof(int));
2761 cp->status = 0; 2489 writel(0, &cp->status);
2762 cp->cmd = A_FLUSH; 2490 writel(A_FLUSH, &cp->cmd);
2763 set_bit(ST_CMDING, &portp->state); 2491 set_bit(ST_CMDING, &portp->state);
2764 } 2492 }
2765} 2493}
@@ -2779,30 +2507,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2779 2507
2780static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) 2508static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2781{ 2509{
2782 volatile cdkasy_t *ap; 2510 cdkasy_t __iomem *ap;
2783 volatile cdkctrl_t *cp; 2511 cdkctrl_t __iomem *cp;
2784 struct tty_struct *tty; 2512 struct tty_struct *tty;
2785 asynotify_t nt; 2513 asynotify_t nt;
2786 unsigned long oldsigs; 2514 unsigned long oldsigs;
2787 int rc, donerx; 2515 int rc, donerx;
2788 2516
2789#ifdef DEBUG 2517 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
2790 printk(KERN_DEBUG "stli_hostcmd(brdp=%x,channr=%d)\n",
2791 (int) brdp, channr);
2792#endif
2793
2794 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
2795 cp = &ap->ctrl; 2518 cp = &ap->ctrl;
2796 2519
2797/* 2520/*
2798 * Check if we are waiting for an open completion message. 2521 * Check if we are waiting for an open completion message.
2799 */ 2522 */
2800 if (test_bit(ST_OPENING, &portp->state)) { 2523 if (test_bit(ST_OPENING, &portp->state)) {
2801 rc = (int) cp->openarg; 2524 rc = readl(&cp->openarg);
2802 if ((cp->open == 0) && (rc != 0)) { 2525 if (readb(&cp->open) == 0 && rc != 0) {
2803 if (rc > 0) 2526 if (rc > 0)
2804 rc--; 2527 rc--;
2805 cp->openarg = 0; 2528 writel(0, &cp->openarg);
2806 portp->rc = rc; 2529 portp->rc = rc;
2807 clear_bit(ST_OPENING, &portp->state); 2530 clear_bit(ST_OPENING, &portp->state);
2808 wake_up_interruptible(&portp->raw_wait); 2531 wake_up_interruptible(&portp->raw_wait);
@@ -2813,11 +2536,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2813 * Check if we are waiting for a close completion message. 2536 * Check if we are waiting for a close completion message.
2814 */ 2537 */
2815 if (test_bit(ST_CLOSING, &portp->state)) { 2538 if (test_bit(ST_CLOSING, &portp->state)) {
2816 rc = (int) cp->closearg; 2539 rc = (int) readl(&cp->closearg);
2817 if ((cp->close == 0) && (rc != 0)) { 2540 if (readb(&cp->close) == 0 && rc != 0) {
2818 if (rc > 0) 2541 if (rc > 0)
2819 rc--; 2542 rc--;
2820 cp->closearg = 0; 2543 writel(0, &cp->closearg);
2821 portp->rc = rc; 2544 portp->rc = rc;
2822 clear_bit(ST_CLOSING, &portp->state); 2545 clear_bit(ST_CLOSING, &portp->state);
2823 wake_up_interruptible(&portp->raw_wait); 2546 wake_up_interruptible(&portp->raw_wait);
@@ -2829,16 +2552,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2829 * need to copy out the command results associated with this command. 2552 * need to copy out the command results associated with this command.
2830 */ 2553 */
2831 if (test_bit(ST_CMDING, &portp->state)) { 2554 if (test_bit(ST_CMDING, &portp->state)) {
2832 rc = cp->status; 2555 rc = readl(&cp->status);
2833 if ((cp->cmd == 0) && (rc != 0)) { 2556 if (readl(&cp->cmd) == 0 && rc != 0) {
2834 if (rc > 0) 2557 if (rc > 0)
2835 rc--; 2558 rc--;
2836 if (portp->argp != (void *) NULL) { 2559 if (portp->argp != NULL) {
2837 memcpy(portp->argp, (void *) &(cp->args[0]), 2560 memcpy_fromio(portp->argp, (void __iomem *) &(cp->args[0]),
2838 portp->argsize); 2561 portp->argsize);
2839 portp->argp = (void *) NULL; 2562 portp->argp = NULL;
2840 } 2563 }
2841 cp->status = 0; 2564 writel(0, &cp->status);
2842 portp->rc = rc; 2565 portp->rc = rc;
2843 clear_bit(ST_CMDING, &portp->state); 2566 clear_bit(ST_CMDING, &portp->state);
2844 stli_dodelaycmd(portp, cp); 2567 stli_dodelaycmd(portp, cp);
@@ -2877,18 +2600,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2877 if (nt.data & DT_TXEMPTY) 2600 if (nt.data & DT_TXEMPTY)
2878 clear_bit(ST_TXBUSY, &portp->state); 2601 clear_bit(ST_TXBUSY, &portp->state);
2879 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) { 2602 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) {
2880 if (tty != (struct tty_struct *) NULL) { 2603 if (tty != NULL) {
2881 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 2604 tty_wakeup(tty);
2882 tty->ldisc.write_wakeup) { 2605 EBRDENABLE(brdp);
2883 (tty->ldisc.write_wakeup)(tty);
2884 EBRDENABLE(brdp);
2885 }
2886 wake_up_interruptible(&tty->write_wait); 2606 wake_up_interruptible(&tty->write_wait);
2887 } 2607 }
2888 } 2608 }
2889 2609
2890 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { 2610 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) {
2891 if (tty != (struct tty_struct *) NULL) { 2611 if (tty != NULL) {
2892 tty_insert_flip_char(tty, 0, TTY_BREAK); 2612 tty_insert_flip_char(tty, 0, TTY_BREAK);
2893 if (portp->flags & ASYNC_SAK) { 2613 if (portp->flags & ASYNC_SAK) {
2894 do_SAK(tty); 2614 do_SAK(tty);
@@ -2932,14 +2652,14 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2932 * at the cdk header structure. 2652 * at the cdk header structure.
2933 */ 2653 */
2934 2654
2935static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) 2655static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
2936{ 2656{
2937 stliport_t *portp; 2657 stliport_t *portp;
2938 unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; 2658 unsigned char hostbits[(STL_MAXCHANS / 8) + 1];
2939 unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; 2659 unsigned char slavebits[(STL_MAXCHANS / 8) + 1];
2940 unsigned char *slavep; 2660 unsigned char __iomem *slavep;
2941 int bitpos, bitat, bitsize; 2661 int bitpos, bitat, bitsize;
2942 int channr, nrdevs, slavebitchange; 2662 int channr, nrdevs, slavebitchange;
2943 2663
2944 bitsize = brdp->bitsize; 2664 bitsize = brdp->bitsize;
2945 nrdevs = brdp->nrdevs; 2665 nrdevs = brdp->nrdevs;
@@ -2951,7 +2671,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2951 * 8 service bits at a time in the inner loop, so we can bypass 2671 * 8 service bits at a time in the inner loop, so we can bypass
2952 * the lot if none of them want service. 2672 * the lot if none of them want service.
2953 */ 2673 */
2954 memcpy(&hostbits[0], (((unsigned char *) hdrp) + brdp->hostoffset), 2674 memcpy_fromio(&hostbits[0], (((unsigned char __iomem *) hdrp) + brdp->hostoffset),
2955 bitsize); 2675 bitsize);
2956 2676
2957 memset(&slavebits[0], 0, bitsize); 2677 memset(&slavebits[0], 0, bitsize);
@@ -2978,11 +2698,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2978 * service may initiate more slave requests. 2698 * service may initiate more slave requests.
2979 */ 2699 */
2980 if (slavebitchange) { 2700 if (slavebitchange) {
2981 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2701 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2982 slavep = ((unsigned char *) hdrp) + brdp->slaveoffset; 2702 slavep = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset;
2983 for (bitpos = 0; (bitpos < bitsize); bitpos++) { 2703 for (bitpos = 0; (bitpos < bitsize); bitpos++) {
2984 if (slavebits[bitpos]) 2704 if (readb(slavebits + bitpos))
2985 slavep[bitpos] &= ~slavebits[bitpos]; 2705 writeb(readb(slavep + bitpos) & ~slavebits[bitpos], slavebits + bitpos);
2986 } 2706 }
2987 } 2707 }
2988} 2708}
@@ -3000,9 +2720,9 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
3000 2720
3001static void stli_poll(unsigned long arg) 2721static void stli_poll(unsigned long arg)
3002{ 2722{
3003 volatile cdkhdr_t *hdrp; 2723 cdkhdr_t __iomem *hdrp;
3004 stlibrd_t *brdp; 2724 stlibrd_t *brdp;
3005 int brdnr; 2725 int brdnr;
3006 2726
3007 stli_timerlist.expires = STLI_TIMEOUT; 2727 stli_timerlist.expires = STLI_TIMEOUT;
3008 add_timer(&stli_timerlist); 2728 add_timer(&stli_timerlist);
@@ -3012,16 +2732,18 @@ static void stli_poll(unsigned long arg)
3012 */ 2732 */
3013 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2733 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
3014 brdp = stli_brds[brdnr]; 2734 brdp = stli_brds[brdnr];
3015 if (brdp == (stlibrd_t *) NULL) 2735 if (brdp == NULL)
3016 continue; 2736 continue;
3017 if ((brdp->state & BST_STARTED) == 0) 2737 if ((brdp->state & BST_STARTED) == 0)
3018 continue; 2738 continue;
3019 2739
2740 spin_lock(&brd_lock);
3020 EBRDENABLE(brdp); 2741 EBRDENABLE(brdp);
3021 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2742 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
3022 if (hdrp->hostreq) 2743 if (readb(&hdrp->hostreq))
3023 stli_brdpoll(brdp, hdrp); 2744 stli_brdpoll(brdp, hdrp);
3024 EBRDDISABLE(brdp); 2745 EBRDDISABLE(brdp);
2746 spin_unlock(&brd_lock);
3025 } 2747 }
3026} 2748}
3027 2749
@@ -3034,11 +2756,6 @@ static void stli_poll(unsigned long arg)
3034 2756
3035static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) 2757static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
3036{ 2758{
3037#ifdef DEBUG
3038 printk(KERN_DEBUG "stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n",
3039 (int) portp, (int) pp, (int) tiosp);
3040#endif
3041
3042 memset(pp, 0, sizeof(asyport_t)); 2759 memset(pp, 0, sizeof(asyport_t));
3043 2760
3044/* 2761/*
@@ -3157,11 +2874,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio
3157 2874
3158static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) 2875static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3159{ 2876{
3160#ifdef DEBUG
3161 printk(KERN_DEBUG "stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n",
3162 (int) sp, dtr, rts);
3163#endif
3164
3165 memset(sp, 0, sizeof(asysigs_t)); 2877 memset(sp, 0, sizeof(asysigs_t));
3166 if (dtr >= 0) { 2878 if (dtr >= 0) {
3167 sp->signal |= SG_DTR; 2879 sp->signal |= SG_DTR;
@@ -3182,13 +2894,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3182 2894
3183static long stli_mktiocm(unsigned long sigvalue) 2895static long stli_mktiocm(unsigned long sigvalue)
3184{ 2896{
3185 long tiocm; 2897 long tiocm = 0;
3186
3187#ifdef DEBUG
3188 printk(KERN_DEBUG "stli_mktiocm(sigvalue=%x)\n", (int) sigvalue);
3189#endif
3190
3191 tiocm = 0;
3192 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0); 2898 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0);
3193 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0); 2899 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0);
3194 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0); 2900 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0);
@@ -3210,10 +2916,6 @@ static int stli_initports(stlibrd_t *brdp)
3210 stliport_t *portp; 2916 stliport_t *portp;
3211 int i, panelnr, panelport; 2917 int i, panelnr, panelport;
3212 2918
3213#ifdef DEBUG
3214 printk(KERN_DEBUG "stli_initports(brdp=%x)\n", (int) brdp);
3215#endif
3216
3217 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { 2919 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) {
3218 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); 2920 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL);
3219 if (!portp) { 2921 if (!portp) {
@@ -3240,7 +2942,7 @@ static int stli_initports(stlibrd_t *brdp)
3240 brdp->ports[i] = portp; 2942 brdp->ports[i] = portp;
3241 } 2943 }
3242 2944
3243 return(0); 2945 return 0;
3244} 2946}
3245 2947
3246/*****************************************************************************/ 2948/*****************************************************************************/
@@ -3253,10 +2955,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3253{ 2955{
3254 unsigned long memconf; 2956 unsigned long memconf;
3255 2957
3256#ifdef DEBUG
3257 printk(KERN_DEBUG "stli_ecpinit(brdp=%d)\n", (int) brdp);
3258#endif
3259
3260 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 2958 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3261 udelay(10); 2959 udelay(10);
3262 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2960 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3270,9 +2968,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3270 2968
3271static void stli_ecpenable(stlibrd_t *brdp) 2969static void stli_ecpenable(stlibrd_t *brdp)
3272{ 2970{
3273#ifdef DEBUG
3274 printk(KERN_DEBUG "stli_ecpenable(brdp=%x)\n", (int) brdp);
3275#endif
3276 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); 2971 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR));
3277} 2972}
3278 2973
@@ -3280,9 +2975,6 @@ static void stli_ecpenable(stlibrd_t *brdp)
3280 2975
3281static void stli_ecpdisable(stlibrd_t *brdp) 2976static void stli_ecpdisable(stlibrd_t *brdp)
3282{ 2977{
3283#ifdef DEBUG
3284 printk(KERN_DEBUG "stli_ecpdisable(brdp=%x)\n", (int) brdp);
3285#endif
3286 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2978 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
3287} 2979}
3288 2980
@@ -3290,13 +2982,8 @@ static void stli_ecpdisable(stlibrd_t *brdp)
3290 2982
3291static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 2983static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3292{ 2984{
3293 void *ptr; 2985 void *ptr;
3294 unsigned char val; 2986 unsigned char val;
3295
3296#ifdef DEBUG
3297 printk(KERN_DEBUG "stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3298 (int) offset);
3299#endif
3300 2987
3301 if (offset > brdp->memsize) { 2988 if (offset > brdp->memsize) {
3302 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 2989 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3316,10 +3003,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3316 3003
3317static void stli_ecpreset(stlibrd_t *brdp) 3004static void stli_ecpreset(stlibrd_t *brdp)
3318{ 3005{
3319#ifdef DEBUG
3320 printk(KERN_DEBUG "stli_ecpreset(brdp=%x)\n", (int) brdp);
3321#endif
3322
3323 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 3006 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3324 udelay(10); 3007 udelay(10);
3325 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 3008 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3330,9 +3013,6 @@ static void stli_ecpreset(stlibrd_t *brdp)
3330 3013
3331static void stli_ecpintr(stlibrd_t *brdp) 3014static void stli_ecpintr(stlibrd_t *brdp)
3332{ 3015{
3333#ifdef DEBUG
3334 printk(KERN_DEBUG "stli_ecpintr(brdp=%x)\n", (int) brdp);
3335#endif
3336 outb(0x1, brdp->iobase); 3016 outb(0x1, brdp->iobase);
3337} 3017}
3338 3018
@@ -3346,10 +3026,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp)
3346{ 3026{
3347 unsigned long memconf; 3027 unsigned long memconf;
3348 3028
3349#ifdef DEBUG
3350 printk(KERN_DEBUG "stli_ecpeiinit(brdp=%x)\n", (int) brdp);
3351#endif
3352
3353 outb(0x1, (brdp->iobase + ECP_EIBRDENAB)); 3029 outb(0x1, (brdp->iobase + ECP_EIBRDENAB));
3354 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); 3030 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR));
3355 udelay(10); 3031 udelay(10);
@@ -3383,11 +3059,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line
3383 void *ptr; 3059 void *ptr;
3384 unsigned char val; 3060 unsigned char val;
3385 3061
3386#ifdef DEBUG
3387 printk(KERN_DEBUG "stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3388 (int) brdp, (int) offset, line);
3389#endif
3390
3391 if (offset > brdp->memsize) { 3062 if (offset > brdp->memsize) {
3392 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3063 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3393 "range at line=%d(%d), brd=%d\n", 3064 "range at line=%d(%d), brd=%d\n",
@@ -3437,8 +3108,8 @@ static void stli_ecpmcdisable(stlibrd_t *brdp)
3437 3108
3438static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3109static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3439{ 3110{
3440 void *ptr; 3111 void *ptr;
3441 unsigned char val; 3112 unsigned char val;
3442 3113
3443 if (offset > brdp->memsize) { 3114 if (offset > brdp->memsize) {
3444 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3115 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3472,10 +3143,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp)
3472 3143
3473static void stli_ecppciinit(stlibrd_t *brdp) 3144static void stli_ecppciinit(stlibrd_t *brdp)
3474{ 3145{
3475#ifdef DEBUG
3476 printk(KERN_DEBUG "stli_ecppciinit(brdp=%x)\n", (int) brdp);
3477#endif
3478
3479 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); 3146 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
3480 udelay(10); 3147 udelay(10);
3481 outb(0, (brdp->iobase + ECP_PCICONFR)); 3148 outb(0, (brdp->iobase + ECP_PCICONFR));
@@ -3489,11 +3156,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin
3489 void *ptr; 3156 void *ptr;
3490 unsigned char val; 3157 unsigned char val;
3491 3158
3492#ifdef DEBUG
3493 printk(KERN_DEBUG "stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3494 (int) brdp, (int) offset, line);
3495#endif
3496
3497 if (offset > brdp->memsize) { 3159 if (offset > brdp->memsize) {
3498 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3160 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3499 "range at line=%d(%d), board=%d\n", 3161 "range at line=%d(%d), board=%d\n",
@@ -3528,10 +3190,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3528{ 3190{
3529 unsigned long memconf; 3191 unsigned long memconf;
3530 3192
3531#ifdef DEBUG
3532 printk(KERN_DEBUG "stli_onbinit(brdp=%d)\n", (int) brdp);
3533#endif
3534
3535 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3193 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3536 udelay(10); 3194 udelay(10);
3537 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3195 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3547,9 +3205,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3547 3205
3548static void stli_onbenable(stlibrd_t *brdp) 3206static void stli_onbenable(stlibrd_t *brdp)
3549{ 3207{
3550#ifdef DEBUG
3551 printk(KERN_DEBUG "stli_onbenable(brdp=%x)\n", (int) brdp);
3552#endif
3553 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); 3208 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR));
3554} 3209}
3555 3210
@@ -3557,9 +3212,6 @@ static void stli_onbenable(stlibrd_t *brdp)
3557 3212
3558static void stli_onbdisable(stlibrd_t *brdp) 3213static void stli_onbdisable(stlibrd_t *brdp)
3559{ 3214{
3560#ifdef DEBUG
3561 printk(KERN_DEBUG "stli_onbdisable(brdp=%x)\n", (int) brdp);
3562#endif
3563 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); 3215 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR));
3564} 3216}
3565 3217
@@ -3569,11 +3221,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3569{ 3221{
3570 void *ptr; 3222 void *ptr;
3571 3223
3572#ifdef DEBUG
3573 printk(KERN_DEBUG "stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3574 (int) offset);
3575#endif
3576
3577 if (offset > brdp->memsize) { 3224 if (offset > brdp->memsize) {
3578 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3225 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3579 "range at line=%d(%d), brd=%d\n", 3226 "range at line=%d(%d), brd=%d\n",
@@ -3589,11 +3236,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3589 3236
3590static void stli_onbreset(stlibrd_t *brdp) 3237static void stli_onbreset(stlibrd_t *brdp)
3591{ 3238{
3592
3593#ifdef DEBUG
3594 printk(KERN_DEBUG "stli_onbreset(brdp=%x)\n", (int) brdp);
3595#endif
3596
3597 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3239 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3598 udelay(10); 3240 udelay(10);
3599 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3241 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3610,10 +3252,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3610{ 3252{
3611 unsigned long memconf; 3253 unsigned long memconf;
3612 3254
3613#ifdef DEBUG
3614 printk(KERN_DEBUG "stli_onbeinit(brdp=%d)\n", (int) brdp);
3615#endif
3616
3617 outb(0x1, (brdp->iobase + ONB_EIBRDENAB)); 3255 outb(0x1, (brdp->iobase + ONB_EIBRDENAB));
3618 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3256 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3619 udelay(10); 3257 udelay(10);
@@ -3632,9 +3270,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3632 3270
3633static void stli_onbeenable(stlibrd_t *brdp) 3271static void stli_onbeenable(stlibrd_t *brdp)
3634{ 3272{
3635#ifdef DEBUG
3636 printk(KERN_DEBUG "stli_onbeenable(brdp=%x)\n", (int) brdp);
3637#endif
3638 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); 3273 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR));
3639} 3274}
3640 3275
@@ -3642,9 +3277,6 @@ static void stli_onbeenable(stlibrd_t *brdp)
3642 3277
3643static void stli_onbedisable(stlibrd_t *brdp) 3278static void stli_onbedisable(stlibrd_t *brdp)
3644{ 3279{
3645#ifdef DEBUG
3646 printk(KERN_DEBUG "stli_onbedisable(brdp=%x)\n", (int) brdp);
3647#endif
3648 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3280 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
3649} 3281}
3650 3282
@@ -3652,13 +3284,8 @@ static void stli_onbedisable(stlibrd_t *brdp)
3652 3284
3653static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3285static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3654{ 3286{
3655 void *ptr; 3287 void *ptr;
3656 unsigned char val; 3288 unsigned char val;
3657
3658#ifdef DEBUG
3659 printk(KERN_DEBUG "stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n",
3660 (int) brdp, (int) offset, line);
3661#endif
3662 3289
3663 if (offset > brdp->memsize) { 3290 if (offset > brdp->memsize) {
3664 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3291 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3681,11 +3308,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3681 3308
3682static void stli_onbereset(stlibrd_t *brdp) 3309static void stli_onbereset(stlibrd_t *brdp)
3683{ 3310{
3684
3685#ifdef DEBUG
3686 printk(KERN_ERR "stli_onbereset(brdp=%x)\n", (int) brdp);
3687#endif
3688
3689 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3311 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3690 udelay(10); 3312 udelay(10);
3691 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3313 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
@@ -3700,11 +3322,6 @@ static void stli_onbereset(stlibrd_t *brdp)
3700 3322
3701static void stli_bbyinit(stlibrd_t *brdp) 3323static void stli_bbyinit(stlibrd_t *brdp)
3702{ 3324{
3703
3704#ifdef DEBUG
3705 printk(KERN_ERR "stli_bbyinit(brdp=%d)\n", (int) brdp);
3706#endif
3707
3708 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3325 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3709 udelay(10); 3326 udelay(10);
3710 outb(0, (brdp->iobase + BBY_ATCONFR)); 3327 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3717,24 +3334,13 @@ static void stli_bbyinit(stlibrd_t *brdp)
3717 3334
3718static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3335static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3719{ 3336{
3720 void *ptr; 3337 void *ptr;
3721 unsigned char val; 3338 unsigned char val;
3722 3339
3723#ifdef DEBUG 3340 BUG_ON(offset > brdp->memsize);
3724 printk(KERN_ERR "stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3725 (int) offset);
3726#endif
3727 3341
3728 if (offset > brdp->memsize) { 3342 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3729 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3343 val = (unsigned char) (offset / BBY_PAGESIZE);
3730 "range at line=%d(%d), brd=%d\n",
3731 (int) offset, line, __LINE__, brdp->brdnr);
3732 ptr = NULL;
3733 val = 0;
3734 } else {
3735 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3736 val = (unsigned char) (offset / BBY_PAGESIZE);
3737 }
3738 outb(val, (brdp->iobase + BBY_ATCONFR)); 3344 outb(val, (brdp->iobase + BBY_ATCONFR));
3739 return(ptr); 3345 return(ptr);
3740} 3346}
@@ -3743,11 +3349,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3743 3349
3744static void stli_bbyreset(stlibrd_t *brdp) 3350static void stli_bbyreset(stlibrd_t *brdp)
3745{ 3351{
3746
3747#ifdef DEBUG
3748 printk(KERN_DEBUG "stli_bbyreset(brdp=%x)\n", (int) brdp);
3749#endif
3750
3751 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3352 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3752 udelay(10); 3353 udelay(10);
3753 outb(0, (brdp->iobase + BBY_ATCONFR)); 3354 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3762,11 +3363,6 @@ static void stli_bbyreset(stlibrd_t *brdp)
3762 3363
3763static void stli_stalinit(stlibrd_t *brdp) 3364static void stli_stalinit(stlibrd_t *brdp)
3764{ 3365{
3765
3766#ifdef DEBUG
3767 printk(KERN_DEBUG "stli_stalinit(brdp=%d)\n", (int) brdp);
3768#endif
3769
3770 outb(0x1, brdp->iobase); 3366 outb(0x1, brdp->iobase);
3771 mdelay(1000); 3367 mdelay(1000);
3772} 3368}
@@ -3775,36 +3371,18 @@ static void stli_stalinit(stlibrd_t *brdp)
3775 3371
3776static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3372static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3777{ 3373{
3778 void *ptr; 3374 BUG_ON(offset > brdp->memsize);
3779 3375 return brdp->membase + (offset % STAL_PAGESIZE);
3780#ifdef DEBUG
3781 printk(KERN_DEBUG "stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3782 (int) offset);
3783#endif
3784
3785 if (offset > brdp->memsize) {
3786 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3787 "range at line=%d(%d), brd=%d\n",
3788 (int) offset, line, __LINE__, brdp->brdnr);
3789 ptr = NULL;
3790 } else {
3791 ptr = brdp->membase + (offset % STAL_PAGESIZE);
3792 }
3793 return(ptr);
3794} 3376}
3795 3377
3796/*****************************************************************************/ 3378/*****************************************************************************/
3797 3379
3798static void stli_stalreset(stlibrd_t *brdp) 3380static void stli_stalreset(stlibrd_t *brdp)
3799{ 3381{
3800 volatile unsigned long *vecp; 3382 u32 __iomem *vecp;
3801 3383
3802#ifdef DEBUG 3384 vecp = (u32 __iomem *) (brdp->membase + 0x30);
3803 printk(KERN_DEBUG "stli_stalreset(brdp=%x)\n", (int) brdp); 3385 writel(0xffff0000, vecp);
3804#endif
3805
3806 vecp = (volatile unsigned long *) (brdp->membase + 0x30);
3807 *vecp = 0xffff0000;
3808 outb(0, brdp->iobase); 3386 outb(0, brdp->iobase);
3809 mdelay(1000); 3387 mdelay(1000);
3810} 3388}
@@ -3818,15 +3396,11 @@ static void stli_stalreset(stlibrd_t *brdp)
3818 3396
3819static int stli_initecp(stlibrd_t *brdp) 3397static int stli_initecp(stlibrd_t *brdp)
3820{ 3398{
3821 cdkecpsig_t sig; 3399 cdkecpsig_t sig;
3822 cdkecpsig_t *sigsp; 3400 cdkecpsig_t __iomem *sigsp;
3823 unsigned int status, nxtid; 3401 unsigned int status, nxtid;
3824 char *name; 3402 char *name;
3825 int panelnr, nrports; 3403 int panelnr, nrports;
3826
3827#ifdef DEBUG
3828 printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp);
3829#endif
3830 3404
3831 if (!request_region(brdp->iobase, brdp->iosize, "istallion")) 3405 if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
3832 return -EIO; 3406 return -EIO;
@@ -3834,7 +3408,7 @@ static int stli_initecp(stlibrd_t *brdp)
3834 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3408 if ((brdp->iobase == 0) || (brdp->memaddr == 0))
3835 { 3409 {
3836 release_region(brdp->iobase, brdp->iosize); 3410 release_region(brdp->iobase, brdp->iosize);
3837 return(-ENODEV); 3411 return -ENODEV;
3838 } 3412 }
3839 3413
3840 brdp->iosize = ECP_IOSIZE; 3414 brdp->iosize = ECP_IOSIZE;
@@ -3903,7 +3477,7 @@ static int stli_initecp(stlibrd_t *brdp)
3903 3477
3904 default: 3478 default:
3905 release_region(brdp->iobase, brdp->iosize); 3479 release_region(brdp->iobase, brdp->iosize);
3906 return(-EINVAL); 3480 return -EINVAL;
3907 } 3481 }
3908 3482
3909/* 3483/*
@@ -3915,10 +3489,10 @@ static int stli_initecp(stlibrd_t *brdp)
3915 EBRDINIT(brdp); 3489 EBRDINIT(brdp);
3916 3490
3917 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3491 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
3918 if (brdp->membase == (void *) NULL) 3492 if (brdp->membase == NULL)
3919 { 3493 {
3920 release_region(brdp->iobase, brdp->iosize); 3494 release_region(brdp->iobase, brdp->iosize);
3921 return(-ENOMEM); 3495 return -ENOMEM;
3922 } 3496 }
3923 3497
3924/* 3498/*
@@ -3927,23 +3501,14 @@ static int stli_initecp(stlibrd_t *brdp)
3927 * this is, and what it is connected to it. 3501 * this is, and what it is connected to it.
3928 */ 3502 */
3929 EBRDENABLE(brdp); 3503 EBRDENABLE(brdp);
3930 sigsp = (cdkecpsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3504 sigsp = (cdkecpsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
3931 memcpy(&sig, sigsp, sizeof(cdkecpsig_t)); 3505 memcpy(&sig, sigsp, sizeof(cdkecpsig_t));
3932 EBRDDISABLE(brdp); 3506 EBRDDISABLE(brdp);
3933 3507
3934#if 0 3508 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3935 printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n",
3936 __FILE__, __LINE__, (int) sig.magic, sig.romver, sig.panelid[0],
3937 (int) sig.panelid[1], (int) sig.panelid[2],
3938 (int) sig.panelid[3], (int) sig.panelid[4],
3939 (int) sig.panelid[5], (int) sig.panelid[6],
3940 (int) sig.panelid[7]);
3941#endif
3942
3943 if (sig.magic != ECP_MAGIC)
3944 { 3509 {
3945 release_region(brdp->iobase, brdp->iosize); 3510 release_region(brdp->iobase, brdp->iosize);
3946 return(-ENODEV); 3511 return -ENODEV;
3947 } 3512 }
3948 3513
3949/* 3514/*
@@ -3967,7 +3532,7 @@ static int stli_initecp(stlibrd_t *brdp)
3967 3532
3968 3533
3969 brdp->state |= BST_FOUND; 3534 brdp->state |= BST_FOUND;
3970 return(0); 3535 return 0;
3971} 3536}
3972 3537
3973/*****************************************************************************/ 3538/*****************************************************************************/
@@ -3979,20 +3544,16 @@ static int stli_initecp(stlibrd_t *brdp)
3979 3544
3980static int stli_initonb(stlibrd_t *brdp) 3545static int stli_initonb(stlibrd_t *brdp)
3981{ 3546{
3982 cdkonbsig_t sig; 3547 cdkonbsig_t sig;
3983 cdkonbsig_t *sigsp; 3548 cdkonbsig_t __iomem *sigsp;
3984 char *name; 3549 char *name;
3985 int i; 3550 int i;
3986
3987#ifdef DEBUG
3988 printk(KERN_DEBUG "stli_initonb(brdp=%x)\n", (int) brdp);
3989#endif
3990 3551
3991/* 3552/*
3992 * Do a basic sanity check on the IO and memory addresses. 3553 * Do a basic sanity check on the IO and memory addresses.
3993 */ 3554 */
3994 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3555 if (brdp->iobase == 0 || brdp->memaddr == 0)
3995 return(-ENODEV); 3556 return -ENODEV;
3996 3557
3997 brdp->iosize = ONB_IOSIZE; 3558 brdp->iosize = ONB_IOSIZE;
3998 3559
@@ -4010,7 +3571,6 @@ static int stli_initonb(stlibrd_t *brdp)
4010 case BRD_ONBOARD2: 3571 case BRD_ONBOARD2:
4011 case BRD_ONBOARD2_32: 3572 case BRD_ONBOARD2_32:
4012 case BRD_ONBOARDRS: 3573 case BRD_ONBOARDRS:
4013 brdp->membase = (void *) brdp->memaddr;
4014 brdp->memsize = ONB_MEMSIZE; 3574 brdp->memsize = ONB_MEMSIZE;
4015 brdp->pagesize = ONB_ATPAGESIZE; 3575 brdp->pagesize = ONB_ATPAGESIZE;
4016 brdp->init = stli_onbinit; 3576 brdp->init = stli_onbinit;
@@ -4028,7 +3588,6 @@ static int stli_initonb(stlibrd_t *brdp)
4028 break; 3588 break;
4029 3589
4030 case BRD_ONBOARDE: 3590 case BRD_ONBOARDE:
4031 brdp->membase = (void *) brdp->memaddr;
4032 brdp->memsize = ONB_EIMEMSIZE; 3591 brdp->memsize = ONB_EIMEMSIZE;
4033 brdp->pagesize = ONB_EIPAGESIZE; 3592 brdp->pagesize = ONB_EIPAGESIZE;
4034 brdp->init = stli_onbeinit; 3593 brdp->init = stli_onbeinit;
@@ -4044,7 +3603,6 @@ static int stli_initonb(stlibrd_t *brdp)
4044 case BRD_BRUMBY4: 3603 case BRD_BRUMBY4:
4045 case BRD_BRUMBY8: 3604 case BRD_BRUMBY8:
4046 case BRD_BRUMBY16: 3605 case BRD_BRUMBY16:
4047 brdp->membase = (void *) brdp->memaddr;
4048 brdp->memsize = BBY_MEMSIZE; 3606 brdp->memsize = BBY_MEMSIZE;
4049 brdp->pagesize = BBY_PAGESIZE; 3607 brdp->pagesize = BBY_PAGESIZE;
4050 brdp->init = stli_bbyinit; 3608 brdp->init = stli_bbyinit;
@@ -4058,7 +3616,6 @@ static int stli_initonb(stlibrd_t *brdp)
4058 break; 3616 break;
4059 3617
4060 case BRD_STALLION: 3618 case BRD_STALLION:
4061 brdp->membase = (void *) brdp->memaddr;
4062 brdp->memsize = STAL_MEMSIZE; 3619 brdp->memsize = STAL_MEMSIZE;
4063 brdp->pagesize = STAL_PAGESIZE; 3620 brdp->pagesize = STAL_PAGESIZE;
4064 brdp->init = stli_stalinit; 3621 brdp->init = stli_stalinit;
@@ -4073,7 +3630,7 @@ static int stli_initonb(stlibrd_t *brdp)
4073 3630
4074 default: 3631 default:
4075 release_region(brdp->iobase, brdp->iosize); 3632 release_region(brdp->iobase, brdp->iosize);
4076 return(-EINVAL); 3633 return -EINVAL;
4077 } 3634 }
4078 3635
4079/* 3636/*
@@ -4085,10 +3642,10 @@ static int stli_initonb(stlibrd_t *brdp)
4085 EBRDINIT(brdp); 3642 EBRDINIT(brdp);
4086 3643
4087 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3644 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4088 if (brdp->membase == (void *) NULL) 3645 if (brdp->membase == NULL)
4089 { 3646 {
4090 release_region(brdp->iobase, brdp->iosize); 3647 release_region(brdp->iobase, brdp->iosize);
4091 return(-ENOMEM); 3648 return -ENOMEM;
4092 } 3649 }
4093 3650
4094/* 3651/*
@@ -4097,21 +3654,17 @@ static int stli_initonb(stlibrd_t *brdp)
4097 * this is, and how many ports. 3654 * this is, and how many ports.
4098 */ 3655 */
4099 EBRDENABLE(brdp); 3656 EBRDENABLE(brdp);
4100 sigsp = (cdkonbsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3657 sigsp = (cdkonbsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
4101 memcpy(&sig, sigsp, sizeof(cdkonbsig_t)); 3658 memcpy_fromio(&sig, sigsp, sizeof(cdkonbsig_t));
4102 EBRDDISABLE(brdp); 3659 EBRDDISABLE(brdp);
4103 3660
4104#if 0 3661 if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) ||
4105 printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n", 3662 sig.magic1 != cpu_to_le16(ONB_MAGIC1) ||
4106 __FILE__, __LINE__, sig.magic0, sig.magic1, sig.magic2, 3663 sig.magic2 != cpu_to_le16(ONB_MAGIC2) ||
4107 sig.magic3, sig.romver, sig.amask0, sig.amask1, sig.amask2); 3664 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
4108#endif
4109
4110 if ((sig.magic0 != ONB_MAGIC0) || (sig.magic1 != ONB_MAGIC1) ||
4111 (sig.magic2 != ONB_MAGIC2) || (sig.magic3 != ONB_MAGIC3))
4112 { 3665 {
4113 release_region(brdp->iobase, brdp->iosize); 3666 release_region(brdp->iobase, brdp->iosize);
4114 return(-ENODEV); 3667 return -ENODEV;
4115 } 3668 }
4116 3669
4117/* 3670/*
@@ -4132,7 +3685,7 @@ static int stli_initonb(stlibrd_t *brdp)
4132 3685
4133 3686
4134 brdp->state |= BST_FOUND; 3687 brdp->state |= BST_FOUND;
4135 return(0); 3688 return 0;
4136} 3689}
4137 3690
4138/*****************************************************************************/ 3691/*****************************************************************************/
@@ -4145,31 +3698,25 @@ static int stli_initonb(stlibrd_t *brdp)
4145 3698
4146static int stli_startbrd(stlibrd_t *brdp) 3699static int stli_startbrd(stlibrd_t *brdp)
4147{ 3700{
4148 volatile cdkhdr_t *hdrp; 3701 cdkhdr_t __iomem *hdrp;
4149 volatile cdkmem_t *memp; 3702 cdkmem_t __iomem *memp;
4150 volatile cdkasy_t *ap; 3703 cdkasy_t __iomem *ap;
4151 unsigned long flags; 3704 unsigned long flags;
4152 stliport_t *portp; 3705 stliport_t *portp;
4153 int portnr, nrdevs, i, rc; 3706 int portnr, nrdevs, i, rc = 0;
4154 3707 u32 memoff;
4155#ifdef DEBUG 3708
4156 printk(KERN_DEBUG "stli_startbrd(brdp=%x)\n", (int) brdp); 3709 spin_lock_irqsave(&brd_lock, flags);
4157#endif
4158
4159 rc = 0;
4160
4161 save_flags(flags);
4162 cli();
4163 EBRDENABLE(brdp); 3710 EBRDENABLE(brdp);
4164 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 3711 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
4165 nrdevs = hdrp->nrdevs; 3712 nrdevs = hdrp->nrdevs;
4166 3713
4167#if 0 3714#if 0
4168 printk("%s(%d): CDK version %d.%d.%d --> " 3715 printk("%s(%d): CDK version %d.%d.%d --> "
4169 "nrdevs=%d memp=%x hostp=%x slavep=%x\n", 3716 "nrdevs=%d memp=%x hostp=%x slavep=%x\n",
4170 __FILE__, __LINE__, hdrp->ver_release, hdrp->ver_modification, 3717 __FILE__, __LINE__, readb(&hdrp->ver_release), readb(&hdrp->ver_modification),
4171 hdrp->ver_fix, nrdevs, (int) hdrp->memp, (int) hdrp->hostp, 3718 readb(&hdrp->ver_fix), nrdevs, (int) readl(&hdrp->memp), readl(&hdrp->hostp),
4172 (int) hdrp->slavep); 3719 readl(&hdrp->slavep));
4173#endif 3720#endif
4174 3721
4175 if (nrdevs < (brdp->nrports + 1)) { 3722 if (nrdevs < (brdp->nrports + 1)) {
@@ -4181,14 +3728,14 @@ static int stli_startbrd(stlibrd_t *brdp)
4181 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR; 3728 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR;
4182 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR; 3729 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR;
4183 brdp->bitsize = (nrdevs + 7) / 8; 3730 brdp->bitsize = (nrdevs + 7) / 8;
4184 memp = (volatile cdkmem_t *) hdrp->memp; 3731 memoff = readl(&hdrp->memp);
4185 if (((unsigned long) memp) > brdp->memsize) { 3732 if (memoff > brdp->memsize) {
4186 printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); 3733 printk(KERN_ERR "STALLION: corrupted shared memory region?\n");
4187 rc = -EIO; 3734 rc = -EIO;
4188 goto stli_donestartup; 3735 goto stli_donestartup;
4189 } 3736 }
4190 memp = (volatile cdkmem_t *) EBRDGETMEMPTR(brdp, (unsigned long) memp); 3737 memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff);
4191 if (memp->dtype != TYP_ASYNCTRL) { 3738 if (readw(&memp->dtype) != TYP_ASYNCTRL) {
4192 printk(KERN_ERR "STALLION: no slave control device found\n"); 3739 printk(KERN_ERR "STALLION: no slave control device found\n");
4193 goto stli_donestartup; 3740 goto stli_donestartup;
4194 } 3741 }
@@ -4200,19 +3747,19 @@ static int stli_startbrd(stlibrd_t *brdp)
4200 * change pages while reading memory map. 3747 * change pages while reading memory map.
4201 */ 3748 */
4202 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) { 3749 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) {
4203 if (memp->dtype != TYP_ASYNC) 3750 if (readw(&memp->dtype) != TYP_ASYNC)
4204 break; 3751 break;
4205 portp = brdp->ports[portnr]; 3752 portp = brdp->ports[portnr];
4206 if (portp == (stliport_t *) NULL) 3753 if (portp == NULL)
4207 break; 3754 break;
4208 portp->devnr = i; 3755 portp->devnr = i;
4209 portp->addr = memp->offset; 3756 portp->addr = readl(&memp->offset);
4210 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs)); 3757 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs));
4211 portp->portidx = (unsigned char) (i / 8); 3758 portp->portidx = (unsigned char) (i / 8);
4212 portp->portbit = (unsigned char) (0x1 << (i % 8)); 3759 portp->portbit = (unsigned char) (0x1 << (i % 8));
4213 } 3760 }
4214 3761
4215 hdrp->slavereq = 0xff; 3762 writeb(0xff, &hdrp->slavereq);
4216 3763
4217/* 3764/*
4218 * For each port setup a local copy of the RX and TX buffer offsets 3765 * For each port setup a local copy of the RX and TX buffer offsets
@@ -4221,22 +3768,22 @@ static int stli_startbrd(stlibrd_t *brdp)
4221 */ 3768 */
4222 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) { 3769 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) {
4223 portp = brdp->ports[portnr]; 3770 portp = brdp->ports[portnr];
4224 if (portp == (stliport_t *) NULL) 3771 if (portp == NULL)
4225 break; 3772 break;
4226 if (portp->addr == 0) 3773 if (portp->addr == 0)
4227 break; 3774 break;
4228 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 3775 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
4229 if (ap != (volatile cdkasy_t *) NULL) { 3776 if (ap != NULL) {
4230 portp->rxsize = ap->rxq.size; 3777 portp->rxsize = readw(&ap->rxq.size);
4231 portp->txsize = ap->txq.size; 3778 portp->txsize = readw(&ap->txq.size);
4232 portp->rxoffset = ap->rxq.offset; 3779 portp->rxoffset = readl(&ap->rxq.offset);
4233 portp->txoffset = ap->txq.offset; 3780 portp->txoffset = readl(&ap->txq.offset);
4234 } 3781 }
4235 } 3782 }
4236 3783
4237stli_donestartup: 3784stli_donestartup:
4238 EBRDDISABLE(brdp); 3785 EBRDDISABLE(brdp);
4239 restore_flags(flags); 3786 spin_unlock_irqrestore(&brd_lock, flags);
4240 3787
4241 if (rc == 0) 3788 if (rc == 0)
4242 brdp->state |= BST_STARTED; 3789 brdp->state |= BST_STARTED;
@@ -4247,7 +3794,7 @@ stli_donestartup:
4247 add_timer(&stli_timerlist); 3794 add_timer(&stli_timerlist);
4248 } 3795 }
4249 3796
4250 return(rc); 3797 return rc;
4251} 3798}
4252 3799
4253/*****************************************************************************/ 3800/*****************************************************************************/
@@ -4258,10 +3805,6 @@ stli_donestartup:
4258 3805
4259static int __init stli_brdinit(stlibrd_t *brdp) 3806static int __init stli_brdinit(stlibrd_t *brdp)
4260{ 3807{
4261#ifdef DEBUG
4262 printk(KERN_DEBUG "stli_brdinit(brdp=%x)\n", (int) brdp);
4263#endif
4264
4265 stli_brds[brdp->brdnr] = brdp; 3808 stli_brds[brdp->brdnr] = brdp;
4266 3809
4267 switch (brdp->brdtype) { 3810 switch (brdp->brdtype) {
@@ -4289,11 +3832,11 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4289 case BRD_ECHPCI: 3832 case BRD_ECHPCI:
4290 printk(KERN_ERR "STALLION: %s board type not supported in " 3833 printk(KERN_ERR "STALLION: %s board type not supported in "
4291 "this driver\n", stli_brdnames[brdp->brdtype]); 3834 "this driver\n", stli_brdnames[brdp->brdtype]);
4292 return(ENODEV); 3835 return -ENODEV;
4293 default: 3836 default:
4294 printk(KERN_ERR "STALLION: board=%d is unknown board " 3837 printk(KERN_ERR "STALLION: board=%d is unknown board "
4295 "type=%d\n", brdp->brdnr, brdp->brdtype); 3838 "type=%d\n", brdp->brdnr, brdp->brdtype);
4296 return(ENODEV); 3839 return -ENODEV;
4297 } 3840 }
4298 3841
4299 if ((brdp->state & BST_FOUND) == 0) { 3842 if ((brdp->state & BST_FOUND) == 0) {
@@ -4301,7 +3844,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4301 "io=%x mem=%x\n", 3844 "io=%x mem=%x\n",
4302 stli_brdnames[brdp->brdtype], brdp->brdnr, 3845 stli_brdnames[brdp->brdtype], brdp->brdnr,
4303 brdp->iobase, (int) brdp->memaddr); 3846 brdp->iobase, (int) brdp->memaddr);
4304 return(ENODEV); 3847 return -ENODEV;
4305 } 3848 }
4306 3849
4307 stli_initports(brdp); 3850 stli_initports(brdp);
@@ -4309,7 +3852,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4309 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], 3852 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype],
4310 brdp->brdnr, brdp->iobase, (int) brdp->memaddr, 3853 brdp->brdnr, brdp->iobase, (int) brdp->memaddr,
4311 brdp->nrpanels, brdp->nrports); 3854 brdp->nrpanels, brdp->nrports);
4312 return(0); 3855 return 0;
4313} 3856}
4314 3857
4315/*****************************************************************************/ 3858/*****************************************************************************/
@@ -4321,14 +3864,10 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4321 3864
4322static int stli_eisamemprobe(stlibrd_t *brdp) 3865static int stli_eisamemprobe(stlibrd_t *brdp)
4323{ 3866{
4324 cdkecpsig_t ecpsig, *ecpsigp; 3867 cdkecpsig_t ecpsig, __iomem *ecpsigp;
4325 cdkonbsig_t onbsig, *onbsigp; 3868 cdkonbsig_t onbsig, __iomem *onbsigp;
4326 int i, foundit; 3869 int i, foundit;
4327 3870
4328#ifdef DEBUG
4329 printk(KERN_DEBUG "stli_eisamemprobe(brdp=%x)\n", (int) brdp);
4330#endif
4331
4332/* 3871/*
4333 * First up we reset the board, to get it into a known state. There 3872 * First up we reset the board, to get it into a known state. There
4334 * is only 2 board types here we need to worry about. Don;t use the 3873 * is only 2 board types here we need to worry about. Don;t use the
@@ -4352,7 +3891,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4352 mdelay(1); 3891 mdelay(1);
4353 stli_onbeenable(brdp); 3892 stli_onbeenable(brdp);
4354 } else { 3893 } else {
4355 return(-ENODEV); 3894 return -ENODEV;
4356 } 3895 }
4357 3896
4358 foundit = 0; 3897 foundit = 0;
@@ -4364,25 +3903,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4364 */ 3903 */
4365 for (i = 0; (i < stli_eisamempsize); i++) { 3904 for (i = 0; (i < stli_eisamempsize); i++) {
4366 brdp->memaddr = stli_eisamemprobeaddrs[i]; 3905 brdp->memaddr = stli_eisamemprobeaddrs[i];
4367 brdp->membase = (void *) brdp->memaddr;
4368 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3906 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4369 if (brdp->membase == (void *) NULL) 3907 if (brdp->membase == NULL)
4370 continue; 3908 continue;
4371 3909
4372 if (brdp->brdtype == BRD_ECPE) { 3910 if (brdp->brdtype == BRD_ECPE) {
4373 ecpsigp = (cdkecpsig_t *) stli_ecpeigetmemptr(brdp, 3911 ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp,
4374 CDK_SIGADDR, __LINE__); 3912 CDK_SIGADDR, __LINE__);
4375 memcpy(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); 3913 memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t));
4376 if (ecpsig.magic == ECP_MAGIC) 3914 if (ecpsig.magic == cpu_to_le32(ECP_MAGIC))
4377 foundit = 1; 3915 foundit = 1;
4378 } else { 3916 } else {
4379 onbsigp = (cdkonbsig_t *) stli_onbegetmemptr(brdp, 3917 onbsigp = (cdkonbsig_t __iomem *) stli_onbegetmemptr(brdp,
4380 CDK_SIGADDR, __LINE__); 3918 CDK_SIGADDR, __LINE__);
4381 memcpy(&onbsig, onbsigp, sizeof(cdkonbsig_t)); 3919 memcpy_fromio(&onbsig, onbsigp, sizeof(cdkonbsig_t));
4382 if ((onbsig.magic0 == ONB_MAGIC0) && 3920 if ((onbsig.magic0 == cpu_to_le16(ONB_MAGIC0)) &&
4383 (onbsig.magic1 == ONB_MAGIC1) && 3921 (onbsig.magic1 == cpu_to_le16(ONB_MAGIC1)) &&
4384 (onbsig.magic2 == ONB_MAGIC2) && 3922 (onbsig.magic2 == cpu_to_le16(ONB_MAGIC2)) &&
4385 (onbsig.magic3 == ONB_MAGIC3)) 3923 (onbsig.magic3 == cpu_to_le16(ONB_MAGIC3)))
4386 foundit = 1; 3924 foundit = 1;
4387 } 3925 }
4388 3926
@@ -4406,9 +3944,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4406 printk(KERN_ERR "STALLION: failed to probe shared memory " 3944 printk(KERN_ERR "STALLION: failed to probe shared memory "
4407 "region for %s in EISA slot=%d\n", 3945 "region for %s in EISA slot=%d\n",
4408 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); 3946 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12));
4409 return(-ENODEV); 3947 return -ENODEV;
4410 } 3948 }
4411 return(0); 3949 return 0;
4412} 3950}
4413 3951
4414static int stli_getbrdnr(void) 3952static int stli_getbrdnr(void)
@@ -4439,22 +3977,16 @@ static int stli_getbrdnr(void)
4439 3977
4440static int stli_findeisabrds(void) 3978static int stli_findeisabrds(void)
4441{ 3979{
4442 stlibrd_t *brdp; 3980 stlibrd_t *brdp;
4443 unsigned int iobase, eid; 3981 unsigned int iobase, eid;
4444 int i; 3982 int i;
4445
4446#ifdef DEBUG
4447 printk(KERN_DEBUG "stli_findeisabrds()\n");
4448#endif
4449 3983
4450/* 3984/*
4451 * Firstly check if this is an EISA system. Do this by probing for 3985 * Firstly check if this is an EISA system. If this is not an EISA system then
4452 * the system board EISA ID. If this is not an EISA system then
4453 * don't bother going any further! 3986 * don't bother going any further!
4454 */ 3987 */
4455 outb(0xff, 0xc80); 3988 if (EISA_bus)
4456 if (inb(0xc80) == 0xff) 3989 return 0;
4457 return(0);
4458 3990
4459/* 3991/*
4460 * Looks like an EISA system, so go searching for EISA boards. 3992 * Looks like an EISA system, so go searching for EISA boards.
@@ -4472,7 +4004,7 @@ static int stli_findeisabrds(void)
4472 */ 4004 */
4473 for (i = 0; (i < STL_MAXBRDS); i++) { 4005 for (i = 0; (i < STL_MAXBRDS); i++) {
4474 brdp = stli_brds[i]; 4006 brdp = stli_brds[i];
4475 if (brdp == (stlibrd_t *) NULL) 4007 if (brdp == NULL)
4476 continue; 4008 continue;
4477 if (brdp->iobase == iobase) 4009 if (brdp->iobase == iobase)
4478 break; 4010 break;
@@ -4484,10 +4016,10 @@ static int stli_findeisabrds(void)
4484 * We have found a Stallion board and it is not configured already. 4016 * We have found a Stallion board and it is not configured already.
4485 * Allocate a board structure and initialize it. 4017 * Allocate a board structure and initialize it.
4486 */ 4018 */
4487 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4019 if ((brdp = stli_allocbrd()) == NULL)
4488 return(-ENOMEM); 4020 return -ENOMEM;
4489 if ((brdp->brdnr = stli_getbrdnr()) < 0) 4021 if ((brdp->brdnr = stli_getbrdnr()) < 0)
4490 return(-ENOMEM); 4022 return -ENOMEM;
4491 eid = inb(iobase + 0xc82); 4023 eid = inb(iobase + 0xc82);
4492 if (eid == ECP_EISAID) 4024 if (eid == ECP_EISAID)
4493 brdp->brdtype = BRD_ECPE; 4025 brdp->brdtype = BRD_ECPE;
@@ -4502,7 +4034,7 @@ static int stli_findeisabrds(void)
4502 stli_brdinit(brdp); 4034 stli_brdinit(brdp);
4503 } 4035 }
4504 4036
4505 return(0); 4037 return 0;
4506} 4038}
4507 4039
4508/*****************************************************************************/ 4040/*****************************************************************************/
@@ -4523,32 +4055,18 @@ static int stli_findeisabrds(void)
4523 4055
4524static int stli_initpcibrd(int brdtype, struct pci_dev *devp) 4056static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4525{ 4057{
4526 stlibrd_t *brdp; 4058 stlibrd_t *brdp;
4527
4528#ifdef DEBUG
4529 printk(KERN_DEBUG "stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n",
4530 brdtype, dev->bus->number, dev->devfn);
4531#endif
4532 4059
4533 if (pci_enable_device(devp)) 4060 if (pci_enable_device(devp))
4534 return(-EIO); 4061 return -EIO;
4535 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4062 if ((brdp = stli_allocbrd()) == NULL)
4536 return(-ENOMEM); 4063 return -ENOMEM;
4537 if ((brdp->brdnr = stli_getbrdnr()) < 0) { 4064 if ((brdp->brdnr = stli_getbrdnr()) < 0) {
4538 printk(KERN_INFO "STALLION: too many boards found, " 4065 printk(KERN_INFO "STALLION: too many boards found, "
4539 "maximum supported %d\n", STL_MAXBRDS); 4066 "maximum supported %d\n", STL_MAXBRDS);
4540 return(0); 4067 return 0;
4541 } 4068 }
4542 brdp->brdtype = brdtype; 4069 brdp->brdtype = brdtype;
4543
4544#ifdef DEBUG
4545 printk(KERN_DEBUG "%s(%d): BAR[]=%lx,%lx,%lx,%lx\n", __FILE__, __LINE__,
4546 pci_resource_start(devp, 0),
4547 pci_resource_start(devp, 1),
4548 pci_resource_start(devp, 2),
4549 pci_resource_start(devp, 3));
4550#endif
4551
4552/* 4070/*
4553 * We have all resources from the board, so lets setup the actual 4071 * We have all resources from the board, so lets setup the actual
4554 * board structure now. 4072 * board structure now.
@@ -4557,7 +4075,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4557 brdp->memaddr = pci_resource_start(devp, 2); 4075 brdp->memaddr = pci_resource_start(devp, 2);
4558 stli_brdinit(brdp); 4076 stli_brdinit(brdp);
4559 4077
4560 return(0); 4078 return 0;
4561} 4079}
4562 4080
4563/*****************************************************************************/ 4081/*****************************************************************************/
@@ -4569,20 +4087,12 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4569 4087
4570static int stli_findpcibrds(void) 4088static int stli_findpcibrds(void)
4571{ 4089{
4572 struct pci_dev *dev = NULL; 4090 struct pci_dev *dev = NULL;
4573 int rc;
4574 4091
4575#ifdef DEBUG 4092 while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) {
4576 printk("stli_findpcibrds()\n"); 4093 stli_initpcibrd(BRD_ECPPCI, dev);
4577#endif
4578
4579 while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION,
4580 PCI_DEVICE_ID_ECRA, dev))) {
4581 if ((rc = stli_initpcibrd(BRD_ECPPCI, dev)))
4582 return(rc);
4583 } 4094 }
4584 4095 return 0;
4585 return(0);
4586} 4096}
4587 4097
4588#endif 4098#endif
@@ -4595,17 +4105,16 @@ static int stli_findpcibrds(void)
4595 4105
4596static stlibrd_t *stli_allocbrd(void) 4106static stlibrd_t *stli_allocbrd(void)
4597{ 4107{
4598 stlibrd_t *brdp; 4108 stlibrd_t *brdp;
4599 4109
4600 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); 4110 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL);
4601 if (!brdp) { 4111 if (!brdp) {
4602 printk(KERN_ERR "STALLION: failed to allocate memory " 4112 printk(KERN_ERR "STALLION: failed to allocate memory "
4603 "(size=%d)\n", sizeof(stlibrd_t)); 4113 "(size=%Zd)\n", sizeof(stlibrd_t));
4604 return NULL; 4114 return NULL;
4605 } 4115 }
4606
4607 brdp->magic = STLI_BOARDMAGIC; 4116 brdp->magic = STLI_BOARDMAGIC;
4608 return(brdp); 4117 return brdp;
4609} 4118}
4610 4119
4611/*****************************************************************************/ 4120/*****************************************************************************/
@@ -4617,13 +4126,9 @@ static stlibrd_t *stli_allocbrd(void)
4617 4126
4618static int stli_initbrds(void) 4127static int stli_initbrds(void)
4619{ 4128{
4620 stlibrd_t *brdp, *nxtbrdp; 4129 stlibrd_t *brdp, *nxtbrdp;
4621 stlconf_t *confp; 4130 stlconf_t *confp;
4622 int i, j; 4131 int i, j;
4623
4624#ifdef DEBUG
4625 printk(KERN_DEBUG "stli_initbrds()\n");
4626#endif
4627 4132
4628 if (stli_nrbrds > STL_MAXBRDS) { 4133 if (stli_nrbrds > STL_MAXBRDS) {
4629 printk(KERN_INFO "STALLION: too many boards in configuration " 4134 printk(KERN_INFO "STALLION: too many boards in configuration "
@@ -4638,11 +4143,9 @@ static int stli_initbrds(void)
4638 */ 4143 */
4639 for (i = 0; (i < stli_nrbrds); i++) { 4144 for (i = 0; (i < stli_nrbrds); i++) {
4640 confp = &stli_brdconf[i]; 4145 confp = &stli_brdconf[i];
4641#ifdef MODULE
4642 stli_parsebrd(confp, stli_brdsp[i]); 4146 stli_parsebrd(confp, stli_brdsp[i]);
4643#endif 4147 if ((brdp = stli_allocbrd()) == NULL)
4644 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4148 return -ENOMEM;
4645 return(-ENOMEM);
4646 brdp->brdnr = i; 4149 brdp->brdnr = i;
4647 brdp->brdtype = confp->brdtype; 4150 brdp->brdtype = confp->brdtype;
4648 brdp->iobase = confp->ioaddr1; 4151 brdp->iobase = confp->ioaddr1;
@@ -4654,9 +4157,7 @@ static int stli_initbrds(void)
4654 * Static configuration table done, so now use dynamic methods to 4157 * Static configuration table done, so now use dynamic methods to
4655 * see if any more boards should be configured. 4158 * see if any more boards should be configured.
4656 */ 4159 */
4657#ifdef MODULE
4658 stli_argbrds(); 4160 stli_argbrds();
4659#endif
4660 if (STLI_EISAPROBE) 4161 if (STLI_EISAPROBE)
4661 stli_findeisabrds(); 4162 stli_findeisabrds();
4662#ifdef CONFIG_PCI 4163#ifdef CONFIG_PCI
@@ -4672,11 +4173,11 @@ static int stli_initbrds(void)
4672 if (stli_nrbrds > 1) { 4173 if (stli_nrbrds > 1) {
4673 for (i = 0; (i < stli_nrbrds); i++) { 4174 for (i = 0; (i < stli_nrbrds); i++) {
4674 brdp = stli_brds[i]; 4175 brdp = stli_brds[i];
4675 if (brdp == (stlibrd_t *) NULL) 4176 if (brdp == NULL)
4676 continue; 4177 continue;
4677 for (j = i + 1; (j < stli_nrbrds); j++) { 4178 for (j = i + 1; (j < stli_nrbrds); j++) {
4678 nxtbrdp = stli_brds[j]; 4179 nxtbrdp = stli_brds[j];
4679 if (nxtbrdp == (stlibrd_t *) NULL) 4180 if (nxtbrdp == NULL)
4680 continue; 4181 continue;
4681 if ((brdp->membase >= nxtbrdp->membase) && 4182 if ((brdp->membase >= nxtbrdp->membase) &&
4682 (brdp->membase <= (nxtbrdp->membase + 4183 (brdp->membase <= (nxtbrdp->membase +
@@ -4691,7 +4192,7 @@ static int stli_initbrds(void)
4691 if (stli_shared == 0) { 4192 if (stli_shared == 0) {
4692 for (i = 0; (i < stli_nrbrds); i++) { 4193 for (i = 0; (i < stli_nrbrds); i++) {
4693 brdp = stli_brds[i]; 4194 brdp = stli_brds[i];
4694 if (brdp == (stlibrd_t *) NULL) 4195 if (brdp == NULL)
4695 continue; 4196 continue;
4696 if (brdp->state & BST_FOUND) { 4197 if (brdp->state & BST_FOUND) {
4697 EBRDENABLE(brdp); 4198 EBRDENABLE(brdp);
@@ -4701,7 +4202,7 @@ static int stli_initbrds(void)
4701 } 4202 }
4702 } 4203 }
4703 4204
4704 return(0); 4205 return 0;
4705} 4206}
4706 4207
4707/*****************************************************************************/ 4208/*****************************************************************************/
@@ -4714,48 +4215,55 @@ static int stli_initbrds(void)
4714 4215
4715static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) 4216static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp)
4716{ 4217{
4717 unsigned long flags; 4218 unsigned long flags;
4718 void *memptr; 4219 void *memptr;
4719 stlibrd_t *brdp; 4220 stlibrd_t *brdp;
4720 int brdnr, size, n; 4221 int brdnr, size, n;
4721 4222 void *p;
4722#ifdef DEBUG 4223 loff_t off = *offp;
4723 printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n",
4724 (int) fp, (int) buf, count, (int) offp);
4725#endif
4726 4224
4727 brdnr = iminor(fp->f_dentry->d_inode); 4225 brdnr = iminor(fp->f_dentry->d_inode);
4728 if (brdnr >= stli_nrbrds) 4226 if (brdnr >= stli_nrbrds)
4729 return(-ENODEV); 4227 return -ENODEV;
4730 brdp = stli_brds[brdnr]; 4228 brdp = stli_brds[brdnr];
4731 if (brdp == (stlibrd_t *) NULL) 4229 if (brdp == NULL)
4732 return(-ENODEV); 4230 return -ENODEV;
4733 if (brdp->state == 0) 4231 if (brdp->state == 0)
4734 return(-ENODEV); 4232 return -ENODEV;
4735 if (fp->f_pos >= brdp->memsize) 4233 if (off >= brdp->memsize || off + count < off)
4736 return(0); 4234 return 0;
4737 4235
4738 size = MIN(count, (brdp->memsize - fp->f_pos)); 4236 size = MIN(count, (brdp->memsize - off));
4237
4238 /*
4239 * Copy the data a page at a time
4240 */
4241
4242 p = (void *)__get_free_page(GFP_KERNEL);
4243 if(p == NULL)
4244 return -ENOMEM;
4739 4245
4740 save_flags(flags);
4741 cli();
4742 EBRDENABLE(brdp);
4743 while (size > 0) { 4246 while (size > 0) {
4744 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4247 spin_lock_irqsave(&brd_lock, flags);
4745 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4248 EBRDENABLE(brdp);
4746 if (copy_to_user(buf, memptr, n)) { 4249 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4250 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4251 n = MIN(n, PAGE_SIZE);
4252 memcpy_fromio(p, memptr, n);
4253 EBRDDISABLE(brdp);
4254 spin_unlock_irqrestore(&brd_lock, flags);
4255 if (copy_to_user(buf, p, n)) {
4747 count = -EFAULT; 4256 count = -EFAULT;
4748 goto out; 4257 goto out;
4749 } 4258 }
4750 fp->f_pos += n; 4259 off += n;
4751 buf += n; 4260 buf += n;
4752 size -= n; 4261 size -= n;
4753 } 4262 }
4754out: 4263out:
4755 EBRDDISABLE(brdp); 4264 *offp = off;
4756 restore_flags(flags); 4265 free_page((unsigned long)p);
4757 4266 return count;
4758 return(count);
4759} 4267}
4760 4268
4761/*****************************************************************************/ 4269/*****************************************************************************/
@@ -4764,54 +4272,65 @@ out:
4764 * Code to handle an "staliomem" write operation. This device is the 4272 * Code to handle an "staliomem" write operation. This device is the
4765 * contents of the board shared memory. It is used for down loading 4273 * contents of the board shared memory. It is used for down loading
4766 * the slave image (and debugging :-) 4274 * the slave image (and debugging :-)
4275 *
4276 * FIXME: copy under lock
4767 */ 4277 */
4768 4278
4769static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) 4279static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp)
4770{ 4280{
4771 unsigned long flags; 4281 unsigned long flags;
4772 void *memptr; 4282 void *memptr;
4773 stlibrd_t *brdp; 4283 stlibrd_t *brdp;
4774 char __user *chbuf; 4284 char __user *chbuf;
4775 int brdnr, size, n; 4285 int brdnr, size, n;
4776 4286 void *p;
4777#ifdef DEBUG 4287 loff_t off = *offp;
4778 printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n",
4779 (int) fp, (int) buf, count, (int) offp);
4780#endif
4781 4288
4782 brdnr = iminor(fp->f_dentry->d_inode); 4289 brdnr = iminor(fp->f_dentry->d_inode);
4290
4783 if (brdnr >= stli_nrbrds) 4291 if (brdnr >= stli_nrbrds)
4784 return(-ENODEV); 4292 return -ENODEV;
4785 brdp = stli_brds[brdnr]; 4293 brdp = stli_brds[brdnr];
4786 if (brdp == (stlibrd_t *) NULL) 4294 if (brdp == NULL)
4787 return(-ENODEV); 4295 return -ENODEV;
4788 if (brdp->state == 0) 4296 if (brdp->state == 0)
4789 return(-ENODEV); 4297 return -ENODEV;
4790 if (fp->f_pos >= brdp->memsize) 4298 if (off >= brdp->memsize || off + count < off)
4791 return(0); 4299 return 0;
4792 4300
4793 chbuf = (char __user *) buf; 4301 chbuf = (char __user *) buf;
4794 size = MIN(count, (brdp->memsize - fp->f_pos)); 4302 size = MIN(count, (brdp->memsize - off));
4303
4304 /*
4305 * Copy the data a page at a time
4306 */
4307
4308 p = (void *)__get_free_page(GFP_KERNEL);
4309 if(p == NULL)
4310 return -ENOMEM;
4795 4311
4796 save_flags(flags);
4797 cli();
4798 EBRDENABLE(brdp);
4799 while (size > 0) { 4312 while (size > 0) {
4800 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4313 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4801 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4314 n = MIN(n, PAGE_SIZE);
4802 if (copy_from_user(memptr, chbuf, n)) { 4315 if (copy_from_user(p, chbuf, n)) {
4803 count = -EFAULT; 4316 if (count == 0)
4317 count = -EFAULT;
4804 goto out; 4318 goto out;
4805 } 4319 }
4806 fp->f_pos += n; 4320 spin_lock_irqsave(&brd_lock, flags);
4321 EBRDENABLE(brdp);
4322 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4323 memcpy_toio(memptr, p, n);
4324 EBRDDISABLE(brdp);
4325 spin_unlock_irqrestore(&brd_lock, flags);
4326 off += n;
4807 chbuf += n; 4327 chbuf += n;
4808 size -= n; 4328 size -= n;
4809 } 4329 }
4810out: 4330out:
4811 EBRDDISABLE(brdp); 4331 free_page((unsigned long) p);
4812 restore_flags(flags); 4332 *offp = off;
4813 4333 return count;
4814 return(count);
4815} 4334}
4816 4335
4817/*****************************************************************************/ 4336/*****************************************************************************/
@@ -4822,16 +4341,16 @@ out:
4822 4341
4823static int stli_getbrdstats(combrd_t __user *bp) 4342static int stli_getbrdstats(combrd_t __user *bp)
4824{ 4343{
4825 stlibrd_t *brdp; 4344 stlibrd_t *brdp;
4826 int i; 4345 int i;
4827 4346
4828 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) 4347 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
4829 return -EFAULT; 4348 return -EFAULT;
4830 if (stli_brdstats.brd >= STL_MAXBRDS) 4349 if (stli_brdstats.brd >= STL_MAXBRDS)
4831 return(-ENODEV); 4350 return -ENODEV;
4832 brdp = stli_brds[stli_brdstats.brd]; 4351 brdp = stli_brds[stli_brdstats.brd];
4833 if (brdp == (stlibrd_t *) NULL) 4352 if (brdp == NULL)
4834 return(-ENODEV); 4353 return -ENODEV;
4835 4354
4836 memset(&stli_brdstats, 0, sizeof(combrd_t)); 4355 memset(&stli_brdstats, 0, sizeof(combrd_t));
4837 stli_brdstats.brd = brdp->brdnr; 4356 stli_brdstats.brd = brdp->brdnr;
@@ -4850,7 +4369,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
4850 4369
4851 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t))) 4370 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t)))
4852 return -EFAULT; 4371 return -EFAULT;
4853 return(0); 4372 return 0;
4854} 4373}
4855 4374
4856/*****************************************************************************/ 4375/*****************************************************************************/
@@ -4861,19 +4380,19 @@ static int stli_getbrdstats(combrd_t __user *bp)
4861 4380
4862static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) 4381static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
4863{ 4382{
4864 stlibrd_t *brdp; 4383 stlibrd_t *brdp;
4865 int i; 4384 int i;
4866 4385
4867 if ((brdnr < 0) || (brdnr >= STL_MAXBRDS)) 4386 if (brdnr < 0 || brdnr >= STL_MAXBRDS)
4868 return((stliport_t *) NULL); 4387 return NULL;
4869 brdp = stli_brds[brdnr]; 4388 brdp = stli_brds[brdnr];
4870 if (brdp == (stlibrd_t *) NULL) 4389 if (brdp == NULL)
4871 return((stliport_t *) NULL); 4390 return NULL;
4872 for (i = 0; (i < panelnr); i++) 4391 for (i = 0; (i < panelnr); i++)
4873 portnr += brdp->panels[i]; 4392 portnr += brdp->panels[i];
4874 if ((portnr < 0) || (portnr >= brdp->nrports)) 4393 if ((portnr < 0) || (portnr >= brdp->nrports))
4875 return((stliport_t *) NULL); 4394 return NULL;
4876 return(brdp->ports[portnr]); 4395 return brdp->ports[portnr];
4877} 4396}
4878 4397
4879/*****************************************************************************/ 4398/*****************************************************************************/
@@ -4892,16 +4411,16 @@ static int stli_portcmdstats(stliport_t *portp)
4892 4411
4893 memset(&stli_comstats, 0, sizeof(comstats_t)); 4412 memset(&stli_comstats, 0, sizeof(comstats_t));
4894 4413
4895 if (portp == (stliport_t *) NULL) 4414 if (portp == NULL)
4896 return(-ENODEV); 4415 return -ENODEV;
4897 brdp = stli_brds[portp->brdnr]; 4416 brdp = stli_brds[portp->brdnr];
4898 if (brdp == (stlibrd_t *) NULL) 4417 if (brdp == NULL)
4899 return(-ENODEV); 4418 return -ENODEV;
4900 4419
4901 if (brdp->state & BST_STARTED) { 4420 if (brdp->state & BST_STARTED) {
4902 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, 4421 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS,
4903 &stli_cdkstats, sizeof(asystats_t), 1)) < 0) 4422 &stli_cdkstats, sizeof(asystats_t), 1)) < 0)
4904 return(rc); 4423 return rc;
4905 } else { 4424 } else {
4906 memset(&stli_cdkstats, 0, sizeof(asystats_t)); 4425 memset(&stli_cdkstats, 0, sizeof(asystats_t));
4907 } 4426 }
@@ -4912,13 +4431,12 @@ static int stli_portcmdstats(stliport_t *portp)
4912 stli_comstats.state = portp->state; 4431 stli_comstats.state = portp->state;
4913 stli_comstats.flags = portp->flags; 4432 stli_comstats.flags = portp->flags;
4914 4433
4915 save_flags(flags); 4434 spin_lock_irqsave(&brd_lock, flags);
4916 cli(); 4435 if (portp->tty != NULL) {
4917 if (portp->tty != (struct tty_struct *) NULL) {
4918 if (portp->tty->driver_data == portp) { 4436 if (portp->tty->driver_data == portp) {
4919 stli_comstats.ttystate = portp->tty->flags; 4437 stli_comstats.ttystate = portp->tty->flags;
4920 stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; 4438 stli_comstats.rxbuffered = -1;
4921 if (portp->tty->termios != (struct termios *) NULL) { 4439 if (portp->tty->termios != NULL) {
4922 stli_comstats.cflags = portp->tty->termios->c_cflag; 4440 stli_comstats.cflags = portp->tty->termios->c_cflag;
4923 stli_comstats.iflags = portp->tty->termios->c_iflag; 4441 stli_comstats.iflags = portp->tty->termios->c_iflag;
4924 stli_comstats.oflags = portp->tty->termios->c_oflag; 4442 stli_comstats.oflags = portp->tty->termios->c_oflag;
@@ -4926,7 +4444,7 @@ static int stli_portcmdstats(stliport_t *portp)
4926 } 4444 }
4927 } 4445 }
4928 } 4446 }
4929 restore_flags(flags); 4447 spin_unlock_irqrestore(&brd_lock, flags);
4930 4448
4931 stli_comstats.txtotal = stli_cdkstats.txchars; 4449 stli_comstats.txtotal = stli_cdkstats.txchars;
4932 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover; 4450 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover;
@@ -4948,7 +4466,7 @@ static int stli_portcmdstats(stliport_t *portp)
4948 stli_comstats.hwid = stli_cdkstats.hwid; 4466 stli_comstats.hwid = stli_cdkstats.hwid;
4949 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); 4467 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals);
4950 4468
4951 return(0); 4469 return 0;
4952} 4470}
4953 4471
4954/*****************************************************************************/ 4472/*****************************************************************************/
@@ -4961,8 +4479,8 @@ static int stli_portcmdstats(stliport_t *portp)
4961 4479
4962static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) 4480static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4963{ 4481{
4964 stlibrd_t *brdp; 4482 stlibrd_t *brdp;
4965 int rc; 4483 int rc;
4966 4484
4967 if (!portp) { 4485 if (!portp) {
4968 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4486 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -4992,8 +4510,8 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4992 4510
4993static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) 4511static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
4994{ 4512{
4995 stlibrd_t *brdp; 4513 stlibrd_t *brdp;
4996 int rc; 4514 int rc;
4997 4515
4998 if (!portp) { 4516 if (!portp) {
4999 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4517 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -5031,7 +4549,7 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
5031 4549
5032static int stli_getportstruct(stliport_t __user *arg) 4550static int stli_getportstruct(stliport_t __user *arg)
5033{ 4551{
5034 stliport_t *portp; 4552 stliport_t *portp;
5035 4553
5036 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t))) 4554 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t)))
5037 return -EFAULT; 4555 return -EFAULT;
@@ -5052,7 +4570,7 @@ static int stli_getportstruct(stliport_t __user *arg)
5052 4570
5053static int stli_getbrdstruct(stlibrd_t __user *arg) 4571static int stli_getbrdstruct(stlibrd_t __user *arg)
5054{ 4572{
5055 stlibrd_t *brdp; 4573 stlibrd_t *brdp;
5056 4574
5057 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t))) 4575 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t)))
5058 return -EFAULT; 4576 return -EFAULT;
@@ -5076,15 +4594,10 @@ static int stli_getbrdstruct(stlibrd_t __user *arg)
5076 4594
5077static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) 4595static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
5078{ 4596{
5079 stlibrd_t *brdp; 4597 stlibrd_t *brdp;
5080 int brdnr, rc, done; 4598 int brdnr, rc, done;
5081 void __user *argp = (void __user *)arg; 4599 void __user *argp = (void __user *)arg;
5082 4600
5083#ifdef DEBUG
5084 printk(KERN_DEBUG "stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n",
5085 (int) ip, (int) fp, cmd, (int) arg);
5086#endif
5087
5088/* 4601/*
5089 * First up handle the board independent ioctls. 4602 * First up handle the board independent ioctls.
5090 */ 4603 */
@@ -5115,7 +4628,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5115 } 4628 }
5116 4629
5117 if (done) 4630 if (done)
5118 return(rc); 4631 return rc;
5119 4632
5120/* 4633/*
5121 * Now handle the board specific ioctls. These all depend on the 4634 * Now handle the board specific ioctls. These all depend on the
@@ -5123,12 +4636,12 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5123 */ 4636 */
5124 brdnr = iminor(ip); 4637 brdnr = iminor(ip);
5125 if (brdnr >= STL_MAXBRDS) 4638 if (brdnr >= STL_MAXBRDS)
5126 return(-ENODEV); 4639 return -ENODEV;
5127 brdp = stli_brds[brdnr]; 4640 brdp = stli_brds[brdnr];
5128 if (!brdp) 4641 if (!brdp)
5129 return(-ENODEV); 4642 return -ENODEV;
5130 if (brdp->state == 0) 4643 if (brdp->state == 0)
5131 return(-ENODEV); 4644 return -ENODEV;
5132 4645
5133 switch (cmd) { 4646 switch (cmd) {
5134 case STL_BINTR: 4647 case STL_BINTR:
@@ -5152,8 +4665,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5152 rc = -ENOIOCTLCMD; 4665 rc = -ENOIOCTLCMD;
5153 break; 4666 break;
5154 } 4667 }
5155 4668 return rc;
5156 return(rc);
5157} 4669}
5158 4670
5159static struct tty_operations stli_ops = { 4671static struct tty_operations stli_ops = {
@@ -5187,6 +4699,9 @@ int __init stli_init(void)
5187 int i; 4699 int i;
5188 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); 4700 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
5189 4701
4702 spin_lock_init(&stli_lock);
4703 spin_lock_init(&brd_lock);
4704
5190 stli_initbrds(); 4705 stli_initbrds();
5191 4706
5192 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 4707 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
@@ -5196,10 +4711,6 @@ int __init stli_init(void)
5196/* 4711/*
5197 * Allocate a temporary write buffer. 4712 * Allocate a temporary write buffer.
5198 */ 4713 */
5199 stli_tmpwritebuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5200 if (!stli_tmpwritebuf)
5201 printk(KERN_ERR "STALLION: failed to allocate memory "
5202 "(size=%d)\n", STLI_TXBUFSIZE);
5203 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); 4714 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5204 if (!stli_txcookbuf) 4715 if (!stli_txcookbuf)
5205 printk(KERN_ERR "STALLION: failed to allocate memory " 4716 printk(KERN_ERR "STALLION: failed to allocate memory "
@@ -5213,16 +4724,11 @@ int __init stli_init(void)
5213 printk(KERN_ERR "STALLION: failed to register serial memory " 4724 printk(KERN_ERR "STALLION: failed to register serial memory "
5214 "device\n"); 4725 "device\n");
5215 4726
5216 devfs_mk_dir("staliomem");
5217 istallion_class = class_create(THIS_MODULE, "staliomem"); 4727 istallion_class = class_create(THIS_MODULE, "staliomem");
5218 for (i = 0; i < 4; i++) { 4728 for (i = 0; i < 4; i++)
5219 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
5220 S_IFCHR | S_IRUSR | S_IWUSR,
5221 "staliomem/%d", i);
5222 class_device_create(istallion_class, NULL, 4729 class_device_create(istallion_class, NULL,
5223 MKDEV(STL_SIOMEMMAJOR, i), 4730 MKDEV(STL_SIOMEMMAJOR, i),
5224 NULL, "staliomem%d", i); 4731 NULL, "staliomem%d", i);
5225 }
5226 4732
5227/* 4733/*
5228 * Set up the tty driver structure and register us as a driver. 4734 * Set up the tty driver structure and register us as a driver.
@@ -5243,7 +4749,7 @@ int __init stli_init(void)
5243 printk(KERN_ERR "STALLION: failed to register serial driver\n"); 4749 printk(KERN_ERR "STALLION: failed to register serial driver\n");
5244 return -EBUSY; 4750 return -EBUSY;
5245 } 4751 }
5246 return(0); 4752 return 0;
5247} 4753}
5248 4754
5249/*****************************************************************************/ 4755/*****************************************************************************/
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index e57260525293..b11a390581ba 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -120,7 +120,6 @@
120#include <linux/major.h> 120#include <linux/major.h>
121#include <linux/sched.h> 121#include <linux/sched.h>
122#include <linux/smp_lock.h> 122#include <linux/smp_lock.h>
123#include <linux/devfs_fs_kernel.h>
124#include <linux/slab.h> 123#include <linux/slab.h>
125#include <linux/fcntl.h> 124#include <linux/fcntl.h>
126#include <linux/delay.h> 125#include <linux/delay.h>
@@ -807,8 +806,6 @@ static int lp_register(int nr, struct parport *port)
807 806
808 class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), NULL, 807 class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), NULL,
809 "lp%d", nr); 808 "lp%d", nr);
810 devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
811 "printers/%d", nr);
812 809
813 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 810 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
814 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); 811 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
@@ -907,7 +904,6 @@ static int __init lp_init (void)
907 return -EIO; 904 return -EIO;
908 } 905 }
909 906
910 devfs_mk_dir("printers");
911 lp_class = class_create(THIS_MODULE, "printer"); 907 lp_class = class_create(THIS_MODULE, "printer");
912 if (IS_ERR(lp_class)) { 908 if (IS_ERR(lp_class)) {
913 err = PTR_ERR(lp_class); 909 err = PTR_ERR(lp_class);
@@ -933,7 +929,6 @@ static int __init lp_init (void)
933out_class: 929out_class:
934 class_destroy(lp_class); 930 class_destroy(lp_class);
935out_devfs: 931out_devfs:
936 devfs_remove("printers");
937 unregister_chrdev(LP_MAJOR, "lp"); 932 unregister_chrdev(LP_MAJOR, "lp");
938 return err; 933 return err;
939} 934}
@@ -981,10 +976,8 @@ static void lp_cleanup_module (void)
981 if (lp_table[offset].dev == NULL) 976 if (lp_table[offset].dev == NULL)
982 continue; 977 continue;
983 parport_unregister_device(lp_table[offset].dev); 978 parport_unregister_device(lp_table[offset].dev);
984 devfs_remove("printers/%d", offset);
985 class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); 979 class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
986 } 980 }
987 devfs_remove("printers");
988 class_destroy(lp_class); 981 class_destroy(lp_class);
989} 982}
990 983
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 1fa9fa157c12..6fe7b6c6c462 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -20,7 +20,6 @@
20#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/capability.h> 21#include <linux/capability.h>
22#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
23#include <linux/devfs_fs_kernel.h>
24#include <linux/ptrace.h> 23#include <linux/ptrace.h>
25#include <linux/device.h> 24#include <linux/device.h>
26#include <linux/highmem.h> 25#include <linux/highmem.h>
@@ -941,13 +940,10 @@ static int __init chr_dev_init(void)
941 printk("unable to get major %d for memory devs\n", MEM_MAJOR); 940 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
942 941
943 mem_class = class_create(THIS_MODULE, "mem"); 942 mem_class = class_create(THIS_MODULE, "mem");
944 for (i = 0; i < ARRAY_SIZE(devlist); i++) { 943 for (i = 0; i < ARRAY_SIZE(devlist); i++)
945 class_device_create(mem_class, NULL, 944 class_device_create(mem_class, NULL,
946 MKDEV(MEM_MAJOR, devlist[i].minor), 945 MKDEV(MEM_MAJOR, devlist[i].minor),
947 NULL, devlist[i].name); 946 NULL, devlist[i].name);
948 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
949 S_IFCHR | devlist[i].mode, devlist[i].name);
950 }
951 947
952 return 0; 948 return 0;
953} 949}
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 96eb2a709e21..dfe1cede3916 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -44,7 +44,6 @@
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/proc_fs.h> 45#include <linux/proc_fs.h>
46#include <linux/seq_file.h> 46#include <linux/seq_file.h>
47#include <linux/devfs_fs_kernel.h>
48#include <linux/stat.h> 47#include <linux/stat.h>
49#include <linux/init.h> 48#include <linux/init.h>
50#include <linux/device.h> 49#include <linux/device.h>
@@ -204,7 +203,7 @@ int misc_register(struct miscdevice * misc)
204{ 203{
205 struct miscdevice *c; 204 struct miscdevice *c;
206 dev_t dev; 205 dev_t dev;
207 int err; 206 int err = 0;
208 207
209 down(&misc_sem); 208 down(&misc_sem);
210 list_for_each_entry(c, &misc_list, list) { 209 list_for_each_entry(c, &misc_list, list) {
@@ -228,10 +227,6 @@ int misc_register(struct miscdevice * misc)
228 227
229 if (misc->minor < DYNAMIC_MINORS) 228 if (misc->minor < DYNAMIC_MINORS)
230 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 229 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
231 if (misc->devfs_name[0] == '\0') {
232 snprintf(misc->devfs_name, sizeof(misc->devfs_name),
233 "misc/%s", misc->name);
234 }
235 dev = MKDEV(MISC_MAJOR, misc->minor); 230 dev = MKDEV(MISC_MAJOR, misc->minor);
236 231
237 misc->class = class_device_create(misc_class, NULL, dev, misc->dev, 232 misc->class = class_device_create(misc_class, NULL, dev, misc->dev,
@@ -241,13 +236,6 @@ int misc_register(struct miscdevice * misc)
241 goto out; 236 goto out;
242 } 237 }
243 238
244 err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP,
245 misc->devfs_name);
246 if (err) {
247 class_device_destroy(misc_class, dev);
248 goto out;
249 }
250
251 /* 239 /*
252 * Add it to the front, so that later devices can "override" 240 * Add it to the front, so that later devices can "override"
253 * earlier defaults 241 * earlier defaults
@@ -278,7 +266,6 @@ int misc_deregister(struct miscdevice * misc)
278 down(&misc_sem); 266 down(&misc_sem);
279 list_del(&misc->list); 267 list_del(&misc->list);
280 class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); 268 class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
281 devfs_remove(misc->devfs_name);
282 if (i < DYNAMIC_MINORS && i>0) { 269 if (i < DYNAMIC_MINORS && i>0) {
283 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 270 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
284 } 271 }
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index d65b3109318a..95e8122b8068 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/devfs_fs_kernel.h>
29#include <linux/mmtimer.h> 28#include <linux/mmtimer.h>
30#include <linux/miscdevice.h> 29#include <linux/miscdevice.h>
31#include <linux/posix-timers.h> 30#include <linux/posix-timers.h>
@@ -694,7 +693,6 @@ static int __init mmtimer_init(void)
694 return -1; 693 return -1;
695 } 694 }
696 695
697 strcpy(mmtimer_miscdev.devfs_name, MMTIMER_NAME);
698 if (misc_register(&mmtimer_miscdev)) { 696 if (misc_register(&mmtimer_miscdev)) {
699 printk(KERN_ERR "%s: failed to register device\n", 697 printk(KERN_ERR "%s: failed to register device\n",
700 MMTIMER_NAME); 698 MMTIMER_NAME);
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index f43c2e04eadd..52ef61f54ba0 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -301,7 +301,7 @@ static struct tty_operations moxa_ops = {
301 .tiocmset = moxa_tiocmset, 301 .tiocmset = moxa_tiocmset,
302}; 302};
303 303
304static spinlock_t moxa_lock = SPIN_LOCK_UNLOCKED; 304static DEFINE_SPINLOCK(moxa_lock);
305 305
306#ifdef CONFIG_PCI 306#ifdef CONFIG_PCI
307static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board) 307static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board)
@@ -342,7 +342,6 @@ static int __init moxa_init(void)
342 init_MUTEX(&moxaBuffSem); 342 init_MUTEX(&moxaBuffSem);
343 moxaDriver->owner = THIS_MODULE; 343 moxaDriver->owner = THIS_MODULE;
344 moxaDriver->name = "ttyMX"; 344 moxaDriver->name = "ttyMX";
345 moxaDriver->devfs_name = "tts/a";
346 moxaDriver->major = ttymajor; 345 moxaDriver->major = ttymajor;
347 moxaDriver->minor_start = 0; 346 moxaDriver->minor_start = 0;
348 moxaDriver->type = TTY_DRIVER_TYPE_SERIAL; 347 moxaDriver->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 645d9d713aec..72cfd09091e0 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -996,7 +996,6 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
996 996
997 info->session = current->signal->session; 997 info->session = current->signal->session;
998 info->pgrp = process_group(current); 998 info->pgrp = process_group(current);
999 clear_bit(TTY_DONT_FLIP, &tty->flags);
1000 999
1001 /* 1000 /*
1002 status = mxser_get_msr(info->base, 0, info->port); 1001 status = mxser_get_msr(info->base, 0, info->port);
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index b9371d5bf790..603b9ade5eb0 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -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_lock sem and with TTY_DONT_FLIP set 1135 * Called under the tty->atomic_read_lock sem
1136 * 1136 *
1137 */ 1137 */
1138 1138
@@ -1271,7 +1271,6 @@ do_it_again:
1271 } 1271 }
1272 1272
1273 add_wait_queue(&tty->read_wait, &wait); 1273 add_wait_queue(&tty->read_wait, &wait);
1274 set_bit(TTY_DONT_FLIP, &tty->flags);
1275 while (nr) { 1274 while (nr) {
1276 /* First test for status change. */ 1275 /* First test for status change. */
1277 if (tty->packet && tty->link->ctrl_status) { 1276 if (tty->packet && tty->link->ctrl_status) {
@@ -1315,9 +1314,7 @@ do_it_again:
1315 break; 1314 break;
1316 } 1315 }
1317 n_tty_set_room(tty); 1316 n_tty_set_room(tty);
1318 clear_bit(TTY_DONT_FLIP, &tty->flags);
1319 timeout = schedule_timeout(timeout); 1317 timeout = schedule_timeout(timeout);
1320 set_bit(TTY_DONT_FLIP, &tty->flags);
1321 continue; 1318 continue;
1322 } 1319 }
1323 __set_current_state(TASK_RUNNING); 1320 __set_current_state(TASK_RUNNING);
@@ -1394,7 +1391,6 @@ do_it_again:
1394 if (time) 1391 if (time)
1395 timeout = time; 1392 timeout = time;
1396 } 1393 }
1397 clear_bit(TTY_DONT_FLIP, &tty->flags);
1398 mutex_unlock(&tty->atomic_read_lock); 1394 mutex_unlock(&tty->atomic_read_lock);
1399 remove_wait_queue(&tty->read_wait, &wait); 1395 remove_wait_queue(&tty->read_wait, &wait);
1400 1396
diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c
new file mode 100644
index 000000000000..5b91e4e25641
--- /dev/null
+++ b/drivers/char/nsc_gpio.c
@@ -0,0 +1,142 @@
1/* linux/drivers/char/nsc_gpio.c
2
3 National Semiconductor common GPIO device-file/VFS methods.
4 Allows a user space process to control the GPIO pins.
5
6 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
7 Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com>
8*/
9
10#include <linux/config.h>
11#include <linux/fs.h>
12#include <linux/module.h>
13#include <linux/errno.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/nsc_gpio.h>
17#include <linux/platform_device.h>
18#include <asm/uaccess.h>
19#include <asm/io.h>
20
21#define NAME "nsc_gpio"
22
23void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
24{
25 /* retrieve current config w/o changing it */
26 u32 config = amp->gpio_config(index, ~0, 0);
27
28 /* user requested via 'v' command, so its INFO */
29 dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\tio:%d/%d\n",
30 index, config,
31 (config & 1) ? "OE" : "TS", /* output-enabled/tristate */
32 (config & 2) ? "PP" : "OD", /* push pull / open drain */
33 (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */
34 (config & 8) ? "LOCKED" : "", /* locked / unlocked */
35 (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */
36 (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */
37 (config & 64) ? "DEBOUNCE" : "", /* debounce */
38
39 amp->gpio_get(index), amp->gpio_current(index));
40}
41
42ssize_t nsc_gpio_write(struct file *file, const char __user *data,
43 size_t len, loff_t *ppos)
44{
45 unsigned m = iminor(file->f_dentry->d_inode);
46 struct nsc_gpio_ops *amp = file->private_data;
47 struct device *dev = amp->dev;
48 size_t i;
49 int err = 0;
50
51 for (i = 0; i < len; ++i) {
52 char c;
53 if (get_user(c, data + i))
54 return -EFAULT;
55 switch (c) {
56 case '0':
57 amp->gpio_set(m, 0);
58 break;
59 case '1':
60 amp->gpio_set(m, 1);
61 break;
62 case 'O':
63 dev_dbg(dev, "GPIO%d output enabled\n", m);
64 amp->gpio_config(m, ~1, 1);
65 break;
66 case 'o':
67 dev_dbg(dev, "GPIO%d output disabled\n", m);
68 amp->gpio_config(m, ~1, 0);
69 break;
70 case 'T':
71 dev_dbg(dev, "GPIO%d output is push pull\n",
72 m);
73 amp->gpio_config(m, ~2, 2);
74 break;
75 case 't':
76 dev_dbg(dev, "GPIO%d output is open drain\n",
77 m);
78 amp->gpio_config(m, ~2, 0);
79 break;
80 case 'P':
81 dev_dbg(dev, "GPIO%d pull up enabled\n", m);
82 amp->gpio_config(m, ~4, 4);
83 break;
84 case 'p':
85 dev_dbg(dev, "GPIO%d pull up disabled\n", m);
86 amp->gpio_config(m, ~4, 0);
87 break;
88 case 'v':
89 /* View Current pin settings */
90 amp->gpio_dump(amp, m);
91 break;
92 case '\n':
93 /* end of settings string, do nothing */
94 break;
95 default:
96 dev_err(dev, "io%2d bad setting: chr<0x%2x>\n",
97 m, (int)c);
98 err++;
99 }
100 }
101 if (err)
102 return -EINVAL; /* full string handled, report error */
103
104 return len;
105}
106
107ssize_t nsc_gpio_read(struct file *file, char __user * buf,
108 size_t len, loff_t * ppos)
109{
110 unsigned m = iminor(file->f_dentry->d_inode);
111 int value;
112 struct nsc_gpio_ops *amp = file->private_data;
113
114 value = amp->gpio_get(m);
115 if (put_user(value ? '1' : '0', buf))
116 return -EFAULT;
117
118 return 1;
119}
120
121/* common file-ops routines for both scx200_gpio and pc87360_gpio */
122EXPORT_SYMBOL(nsc_gpio_write);
123EXPORT_SYMBOL(nsc_gpio_read);
124EXPORT_SYMBOL(nsc_gpio_dump);
125
126static int __init nsc_gpio_init(void)
127{
128 printk(KERN_DEBUG NAME " initializing\n");
129 return 0;
130}
131
132static void __exit nsc_gpio_cleanup(void)
133{
134 printk(KERN_DEBUG NAME " cleanup\n");
135}
136
137module_init(nsc_gpio_init);
138module_exit(nsc_gpio_cleanup);
139
140MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>");
141MODULE_DESCRIPTION("NatSemi GPIO Common Methods");
142MODULE_LICENSE("GPL");
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
new file mode 100644
index 000000000000..1c706ccfdbb3
--- /dev/null
+++ b/drivers/char/pc8736x_gpio.c
@@ -0,0 +1,340 @@
1/* linux/drivers/char/pc8736x_gpio.c
2
3 National Semiconductor PC8736x GPIO driver. Allows a user space
4 process to play with the GPIO pins.
5
6 Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com>
7
8 adapted from linux/drivers/char/scx200_gpio.c
9 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>,
10*/
11
12#include <linux/config.h>
13#include <linux/fs.h>
14#include <linux/module.h>
15#include <linux/errno.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/io.h>
19#include <linux/ioport.h>
20#include <linux/mutex.h>
21#include <linux/nsc_gpio.h>
22#include <linux/platform_device.h>
23#include <asm/uaccess.h>
24
25#define DEVNAME "pc8736x_gpio"
26
27MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>");
28MODULE_DESCRIPTION("NatSemi PC-8736x GPIO Pin Driver");
29MODULE_LICENSE("GPL");
30
31static int major; /* default to dynamic major */
32module_param(major, int, 0);
33MODULE_PARM_DESC(major, "Major device number");
34
35static DEFINE_MUTEX(pc8736x_gpio_config_lock);
36static unsigned pc8736x_gpio_base;
37static u8 pc8736x_gpio_shadow[4];
38
39#define SIO_BASE1 0x2E /* 1st command-reg to check */
40#define SIO_BASE2 0x4E /* alt command-reg to check */
41#define SIO_BASE_OFFSET 0x20
42
43#define SIO_SID 0x20 /* SuperI/O ID Register */
44#define SIO_SID_VALUE 0xe9 /* Expected value in SuperI/O ID Register */
45
46#define SIO_CF1 0x21 /* chip config, bit0 is chip enable */
47
48#define PC8736X_GPIO_SIZE 16
49
50#define SIO_UNIT_SEL 0x7 /* unit select reg */
51#define SIO_UNIT_ACT 0x30 /* unit enable */
52#define SIO_GPIO_UNIT 0x7 /* unit number of GPIO */
53#define SIO_VLM_UNIT 0x0D
54#define SIO_TMS_UNIT 0x0E
55
56/* config-space addrs to read/write each unit's runtime addr */
57#define SIO_BASE_HADDR 0x60
58#define SIO_BASE_LADDR 0x61
59
60/* GPIO config-space pin-control addresses */
61#define SIO_GPIO_PIN_SELECT 0xF0
62#define SIO_GPIO_PIN_CONFIG 0xF1
63#define SIO_GPIO_PIN_EVENT 0xF2
64
65static unsigned char superio_cmd = 0;
66static unsigned char selected_device = 0xFF; /* bogus start val */
67
68/* GPIO port runtime access, functionality */
69static int port_offset[] = { 0, 4, 8, 10 }; /* non-uniform offsets ! */
70/* static int event_capable[] = { 1, 1, 0, 0 }; ports 2,3 are hobbled */
71
72#define PORT_OUT 0
73#define PORT_IN 1
74#define PORT_EVT_EN 2
75#define PORT_EVT_STST 3
76
77static struct platform_device *pdev; /* use in dev_*() */
78
79static inline void superio_outb(int addr, int val)
80{
81 outb_p(addr, superio_cmd);
82 outb_p(val, superio_cmd + 1);
83}
84
85static inline int superio_inb(int addr)
86{
87 outb_p(addr, superio_cmd);
88 return inb_p(superio_cmd + 1);
89}
90
91static int pc8736x_superio_present(void)
92{
93 /* try the 2 possible values, read a hardware reg to verify */
94 superio_cmd = SIO_BASE1;
95 if (superio_inb(SIO_SID) == SIO_SID_VALUE)
96 return superio_cmd;
97
98 superio_cmd = SIO_BASE2;
99 if (superio_inb(SIO_SID) == SIO_SID_VALUE)
100 return superio_cmd;
101
102 return 0;
103}
104
105static void device_select(unsigned devldn)
106{
107 superio_outb(SIO_UNIT_SEL, devldn);
108 selected_device = devldn;
109}
110
111static void select_pin(unsigned iminor)
112{
113 /* select GPIO port/pin from device minor number */
114 device_select(SIO_GPIO_UNIT);
115 superio_outb(SIO_GPIO_PIN_SELECT,
116 ((iminor << 1) & 0xF0) | (iminor & 0x7));
117}
118
119static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits,
120 u32 func_slct)
121{
122 u32 config, new_config;
123
124 mutex_lock(&pc8736x_gpio_config_lock);
125
126 device_select(SIO_GPIO_UNIT);
127 select_pin(index);
128
129 /* read current config value */
130 config = superio_inb(func_slct);
131
132 /* set new config */
133 new_config = (config & mask) | bits;
134 superio_outb(func_slct, new_config);
135
136 mutex_unlock(&pc8736x_gpio_config_lock);
137
138 return config;
139}
140
141static u32 pc8736x_gpio_configure(unsigned index, u32 mask, u32 bits)
142{
143 return pc8736x_gpio_configure_fn(index, mask, bits,
144 SIO_GPIO_PIN_CONFIG);
145}
146
147static int pc8736x_gpio_get(unsigned minor)
148{
149 int port, bit, val;
150
151 port = minor >> 3;
152 bit = minor & 7;
153 val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN);
154 val >>= bit;
155 val &= 1;
156
157 dev_dbg(&pdev->dev, "_gpio_get(%d from %x bit %d) == val %d\n",
158 minor, pc8736x_gpio_base + port_offset[port] + PORT_IN, bit,
159 val);
160
161 return val;
162}
163
164static void pc8736x_gpio_set(unsigned minor, int val)
165{
166 int port, bit, curval;
167
168 minor &= 0x1f;
169 port = minor >> 3;
170 bit = minor & 7;
171 curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT);
172
173 dev_dbg(&pdev->dev, "addr:%x cur:%x bit-pos:%d cur-bit:%x + new:%d -> bit-new:%d\n",
174 pc8736x_gpio_base + port_offset[port] + PORT_OUT,
175 curval, bit, (curval & ~(1 << bit)), val, (val << bit));
176
177 val = (curval & ~(1 << bit)) | (val << bit);
178
179 dev_dbg(&pdev->dev, "gpio_set(minor:%d port:%d bit:%d)"
180 " %2x -> %2x\n", minor, port, bit, curval, val);
181
182 outb_p(val, pc8736x_gpio_base + port_offset[port] + PORT_OUT);
183
184 curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT);
185 val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN);
186
187 dev_dbg(&pdev->dev, "wrote %x, read: %x\n", curval, val);
188 pc8736x_gpio_shadow[port] = val;
189}
190
191static void pc8736x_gpio_set_high(unsigned index)
192{
193 pc8736x_gpio_set(index, 1);
194}
195
196static void pc8736x_gpio_set_low(unsigned index)
197{
198 pc8736x_gpio_set(index, 0);
199}
200
201static int pc8736x_gpio_current(unsigned minor)
202{
203 int port, bit;
204 minor &= 0x1f;
205 port = minor >> 3;
206 bit = minor & 7;
207 return ((pc8736x_gpio_shadow[port] >> bit) & 0x01);
208}
209
210static void pc8736x_gpio_change(unsigned index)
211{
212 pc8736x_gpio_set(index, !pc8736x_gpio_current(index));
213}
214
215static struct nsc_gpio_ops pc8736x_access = {
216 .owner = THIS_MODULE,
217 .gpio_config = pc8736x_gpio_configure,
218 .gpio_dump = nsc_gpio_dump,
219 .gpio_get = pc8736x_gpio_get,
220 .gpio_set = pc8736x_gpio_set,
221 .gpio_set_high = pc8736x_gpio_set_high,
222 .gpio_set_low = pc8736x_gpio_set_low,
223 .gpio_change = pc8736x_gpio_change,
224 .gpio_current = pc8736x_gpio_current
225};
226
227static int pc8736x_gpio_open(struct inode *inode, struct file *file)
228{
229 unsigned m = iminor(inode);
230 file->private_data = &pc8736x_access;
231
232 dev_dbg(&pdev->dev, "open %d\n", m);
233
234 if (m > 63)
235 return -EINVAL;
236 return nonseekable_open(inode, file);
237}
238
239static struct file_operations pc8736x_gpio_fops = {
240 .owner = THIS_MODULE,
241 .open = pc8736x_gpio_open,
242 .write = nsc_gpio_write,
243 .read = nsc_gpio_read,
244};
245
246static void __init pc8736x_init_shadow(void)
247{
248 int port;
249
250 /* read the current values driven on the GPIO signals */
251 for (port = 0; port < 4; ++port)
252 pc8736x_gpio_shadow[port]
253 = inb_p(pc8736x_gpio_base + port_offset[port]
254 + PORT_OUT);
255
256}
257
258static int __init pc8736x_gpio_init(void)
259{
260 int rc = 0;
261
262 pdev = platform_device_alloc(DEVNAME, 0);
263 if (!pdev)
264 return -ENOMEM;
265
266 rc = platform_device_add(pdev);
267 if (rc) {
268 rc = -ENODEV;
269 goto undo_platform_dev_alloc;
270 }
271 dev_info(&pdev->dev, "NatSemi pc8736x GPIO Driver Initializing\n");
272
273 if (!pc8736x_superio_present()) {
274 rc = -ENODEV;
275 dev_err(&pdev->dev, "no device found\n");
276 goto undo_platform_dev_add;
277 }
278 pc8736x_access.dev = &pdev->dev;
279
280 /* Verify that chip and it's GPIO unit are both enabled.
281 My BIOS does this, so I take minimum action here
282 */
283 rc = superio_inb(SIO_CF1);
284 if (!(rc & 0x01)) {
285 rc = -ENODEV;
286 dev_err(&pdev->dev, "device not enabled\n");
287 goto undo_platform_dev_add;
288 }
289 device_select(SIO_GPIO_UNIT);
290 if (!superio_inb(SIO_UNIT_ACT)) {
291 rc = -ENODEV;
292 dev_err(&pdev->dev, "GPIO unit not enabled\n");
293 goto undo_platform_dev_add;
294 }
295
296 /* read the GPIO unit base addr that chip responds to */
297 pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8
298 | superio_inb(SIO_BASE_LADDR));
299
300 if (!request_region(pc8736x_gpio_base, 16, DEVNAME)) {
301 rc = -ENODEV;
302 dev_err(&pdev->dev, "GPIO ioport %x busy\n",
303 pc8736x_gpio_base);
304 goto undo_platform_dev_add;
305 }
306 dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base);
307
308 rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops);
309 if (rc < 0) {
310 dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc);
311 goto undo_platform_dev_add;
312 }
313 if (!major) {
314 major = rc;
315 dev_dbg(&pdev->dev, "got dynamic major %d\n", major);
316 }
317
318 pc8736x_init_shadow();
319 return 0;
320
321undo_platform_dev_add:
322 platform_device_put(pdev);
323undo_platform_dev_alloc:
324 kfree(pdev);
325 return rc;
326}
327
328static void __exit pc8736x_gpio_cleanup(void)
329{
330 dev_dbg(&pdev->dev, " cleanup\n");
331
332 release_region(pc8736x_gpio_base, 16);
333
334 unregister_chrdev(major, DEVNAME);
335}
336
337EXPORT_SYMBOL(pc8736x_access);
338
339module_init(pc8736x_gpio_init);
340module_exit(pc8736x_gpio_cleanup);
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index bee6c47b45bd..24231d9743dc 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -60,7 +60,6 @@
60#include <linux/init.h> 60#include <linux/init.h>
61#include <linux/sched.h> 61#include <linux/sched.h>
62#include <linux/device.h> 62#include <linux/device.h>
63#include <linux/devfs_fs_kernel.h>
64#include <linux/ioctl.h> 63#include <linux/ioctl.h>
65#include <linux/parport.h> 64#include <linux/parport.h>
66#include <linux/ctype.h> 65#include <linux/ctype.h>
@@ -770,7 +769,7 @@ static struct parport_driver pp_driver = {
770 769
771static int __init ppdev_init (void) 770static int __init ppdev_init (void)
772{ 771{
773 int i, err = 0; 772 int err = 0;
774 773
775 if (register_chrdev (PP_MAJOR, CHRDEV, &pp_fops)) { 774 if (register_chrdev (PP_MAJOR, CHRDEV, &pp_fops)) {
776 printk (KERN_WARNING CHRDEV ": unable to get major %d\n", 775 printk (KERN_WARNING CHRDEV ": unable to get major %d\n",
@@ -782,11 +781,6 @@ static int __init ppdev_init (void)
782 err = PTR_ERR(ppdev_class); 781 err = PTR_ERR(ppdev_class);
783 goto out_chrdev; 782 goto out_chrdev;
784 } 783 }
785 devfs_mk_dir("parports");
786 for (i = 0; i < PARPORT_MAX; i++) {
787 devfs_mk_cdev(MKDEV(PP_MAJOR, i),
788 S_IFCHR | S_IRUGO | S_IWUGO, "parports/%d", i);
789 }
790 if (parport_register_driver(&pp_driver)) { 784 if (parport_register_driver(&pp_driver)) {
791 printk (KERN_WARNING CHRDEV ": unable to register with parport\n"); 785 printk (KERN_WARNING CHRDEV ": unable to register with parport\n");
792 goto out_class; 786 goto out_class;
@@ -796,9 +790,6 @@ static int __init ppdev_init (void)
796 goto out; 790 goto out;
797 791
798out_class: 792out_class:
799 for (i = 0; i < PARPORT_MAX; i++)
800 devfs_remove("parports/%d", i);
801 devfs_remove("parports");
802 class_destroy(ppdev_class); 793 class_destroy(ppdev_class);
803out_chrdev: 794out_chrdev:
804 unregister_chrdev(PP_MAJOR, CHRDEV); 795 unregister_chrdev(PP_MAJOR, CHRDEV);
@@ -808,12 +799,8 @@ out:
808 799
809static void __exit ppdev_cleanup (void) 800static void __exit ppdev_cleanup (void)
810{ 801{
811 int i;
812 /* Clean up all parport stuff */ 802 /* Clean up all parport stuff */
813 for (i = 0; i < PARPORT_MAX; i++)
814 devfs_remove("parports/%d", i);
815 parport_unregister_driver(&pp_driver); 803 parport_unregister_driver(&pp_driver);
816 devfs_remove("parports");
817 class_destroy(ppdev_class); 804 class_destroy(ppdev_class);
818 unregister_chrdev (PP_MAJOR, CHRDEV); 805 unregister_chrdev (PP_MAJOR, CHRDEV);
819} 806}
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 9b5a2c0e7008..9491e4307566 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/devfs_fs_kernel.h>
28#include <linux/sysctl.h> 27#include <linux/sysctl.h>
29 28
30#include <asm/uaccess.h> 29#include <asm/uaccess.h>
@@ -101,7 +100,7 @@ static void pty_unthrottle(struct tty_struct * tty)
101 * 100 *
102 * FIXME: Our pty_write method is called with our ldisc lock held but 101 * FIXME: Our pty_write method is called with our ldisc lock held but
103 * not our partners. We can't just take the other one blindly without 102 * not our partners. We can't just take the other one blindly without
104 * risking deadlocks. There is also the small matter of TTY_DONT_FLIP 103 * risking deadlocks.
105 */ 104 */
106static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count) 105static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count)
107{ 106{
@@ -265,7 +264,6 @@ static void __init legacy_pty_init(void)
265 pty_driver->owner = THIS_MODULE; 264 pty_driver->owner = THIS_MODULE;
266 pty_driver->driver_name = "pty_master"; 265 pty_driver->driver_name = "pty_master";
267 pty_driver->name = "pty"; 266 pty_driver->name = "pty";
268 pty_driver->devfs_name = "pty/m";
269 pty_driver->major = PTY_MASTER_MAJOR; 267 pty_driver->major = PTY_MASTER_MAJOR;
270 pty_driver->minor_start = 0; 268 pty_driver->minor_start = 0;
271 pty_driver->type = TTY_DRIVER_TYPE_PTY; 269 pty_driver->type = TTY_DRIVER_TYPE_PTY;
@@ -283,7 +281,6 @@ static void __init legacy_pty_init(void)
283 pty_slave_driver->owner = THIS_MODULE; 281 pty_slave_driver->owner = THIS_MODULE;
284 pty_slave_driver->driver_name = "pty_slave"; 282 pty_slave_driver->driver_name = "pty_slave";
285 pty_slave_driver->name = "ttyp"; 283 pty_slave_driver->name = "ttyp";
286 pty_slave_driver->devfs_name = "pty/s";
287 pty_slave_driver->major = PTY_SLAVE_MAJOR; 284 pty_slave_driver->major = PTY_SLAVE_MAJOR;
288 pty_slave_driver->minor_start = 0; 285 pty_slave_driver->minor_start = 0;
289 pty_slave_driver->type = TTY_DRIVER_TYPE_PTY; 286 pty_slave_driver->type = TTY_DRIVER_TYPE_PTY;
@@ -351,7 +348,6 @@ static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
351 348
352static void __init unix98_pty_init(void) 349static void __init unix98_pty_init(void)
353{ 350{
354 devfs_mk_dir("pts");
355 ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX); 351 ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX);
356 if (!ptm_driver) 352 if (!ptm_driver)
357 panic("Couldn't allocate Unix98 ptm driver"); 353 panic("Couldn't allocate Unix98 ptm driver");
@@ -372,7 +368,7 @@ static void __init unix98_pty_init(void)
372 ptm_driver->init_termios.c_cflag = B38400 | CS8 | CREAD; 368 ptm_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
373 ptm_driver->init_termios.c_lflag = 0; 369 ptm_driver->init_termios.c_lflag = 0;
374 ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 370 ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
375 TTY_DRIVER_NO_DEVFS | TTY_DRIVER_DEVPTS_MEM; 371 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
376 ptm_driver->other = pts_driver; 372 ptm_driver->other = pts_driver;
377 tty_set_operations(ptm_driver, &pty_ops); 373 tty_set_operations(ptm_driver, &pty_ops);
378 ptm_driver->ioctl = pty_unix98_ioctl; 374 ptm_driver->ioctl = pty_unix98_ioctl;
@@ -387,7 +383,7 @@ static void __init unix98_pty_init(void)
387 pts_driver->init_termios = tty_std_termios; 383 pts_driver->init_termios = tty_std_termios;
388 pts_driver->init_termios.c_cflag = B38400 | CS8 | CREAD; 384 pts_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
389 pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 385 pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
390 TTY_DRIVER_NO_DEVFS | TTY_DRIVER_DEVPTS_MEM; 386 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
391 pts_driver->other = ptm_driver; 387 pts_driver->other = ptm_driver;
392 tty_set_operations(pts_driver, &pty_ops); 388 tty_set_operations(pts_driver, &pty_ops);
393 389
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 15a7b4086524..9bf97c5e38c0 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -10,7 +10,6 @@
10 10
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/devfs_fs_kernel.h>
14#include <linux/major.h> 13#include <linux/major.h>
15#include <linux/blkdev.h> 14#include <linux/blkdev.h>
16#include <linux/module.h> 15#include <linux/module.h>
@@ -288,7 +287,6 @@ static struct cdev raw_cdev = {
288 287
289static int __init raw_init(void) 288static int __init raw_init(void)
290{ 289{
291 int i;
292 dev_t dev = MKDEV(RAW_MAJOR, 0); 290 dev_t dev = MKDEV(RAW_MAJOR, 0);
293 291
294 if (register_chrdev_region(dev, MAX_RAW_MINORS, "raw")) 292 if (register_chrdev_region(dev, MAX_RAW_MINORS, "raw"))
@@ -310,13 +308,6 @@ static int __init raw_init(void)
310 } 308 }
311 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 309 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
312 310
313 devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
314 S_IFCHR | S_IRUGO | S_IWUGO,
315 "raw/rawctl");
316 for (i = 1; i < MAX_RAW_MINORS; i++)
317 devfs_mk_cdev(MKDEV(RAW_MAJOR, i),
318 S_IFCHR | S_IRUGO | S_IWUGO,
319 "raw/raw%d", i);
320 return 0; 311 return 0;
321 312
322error: 313error:
@@ -326,12 +317,6 @@ error:
326 317
327static void __exit raw_exit(void) 318static void __exit raw_exit(void)
328{ 319{
329 int i;
330
331 for (i = 1; i < MAX_RAW_MINORS; i++)
332 devfs_remove("raw/raw%d", i);
333 devfs_remove("raw/rawctl");
334 devfs_remove("raw");
335 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, 0)); 320 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, 0));
336 class_destroy(raw_class); 321 class_destroy(raw_class);
337 cdev_del(&raw_cdev); 322 cdev_del(&raw_cdev);
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 657c0d88f48c..c84c3c3f10c3 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1634,7 +1634,6 @@ static inline int rc_init_drivers(void)
1634 memset(IRQ_to_board, 0, sizeof(IRQ_to_board)); 1634 memset(IRQ_to_board, 0, sizeof(IRQ_to_board));
1635 riscom_driver->owner = THIS_MODULE; 1635 riscom_driver->owner = THIS_MODULE;
1636 riscom_driver->name = "ttyL"; 1636 riscom_driver->name = "ttyL";
1637 riscom_driver->devfs_name = "tts/L";
1638 riscom_driver->major = RISCOM8_NORMAL_MAJOR; 1637 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
1639 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL; 1638 riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
1640 riscom_driver->subtype = SERIAL_TYPE_NORMAL; 1639 riscom_driver->subtype = SERIAL_TYPE_NORMAL;
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 0708c5164c83..0ac131881322 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -2426,8 +2426,7 @@ static int __init rp_init(void)
2426 */ 2426 */
2427 2427
2428 rocket_driver->owner = THIS_MODULE; 2428 rocket_driver->owner = THIS_MODULE;
2429 rocket_driver->flags = TTY_DRIVER_NO_DEVFS; 2429 rocket_driver->flags = TTY_DRIVER_DYNAMIC_DEV;
2430 rocket_driver->devfs_name = "tts/R";
2431 rocket_driver->name = "ttyR"; 2430 rocket_driver->name = "ttyR";
2432 rocket_driver->driver_name = "Comtrol RocketPort"; 2431 rocket_driver->driver_name = "Comtrol RocketPort";
2433 rocket_driver->major = TTY_ROCKET_MAJOR; 2432 rocket_driver->major = TTY_ROCKET_MAJOR;
@@ -2438,7 +2437,7 @@ static int __init rp_init(void)
2438 rocket_driver->init_termios.c_cflag = 2437 rocket_driver->init_termios.c_cflag =
2439 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2438 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2440#ifdef ROCKET_SOFT_FLOW 2439#ifdef ROCKET_SOFT_FLOW
2441 rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 2440 rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
2442#endif 2441#endif
2443 tty_set_operations(rocket_driver, &rocket_ops); 2442 tty_set_operations(rocket_driver, &rocket_ops);
2444 2443
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 664a6e97eb1a..5a280a330401 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -1,4 +1,4 @@
1/* linux/drivers/char/scx200_gpio.c 1/* linux/drivers/char/scx200_gpio.c
2 2
3 National Semiconductor SCx200 GPIO driver. Allows a user space 3 National Semiconductor SCx200 GPIO driver. Allows a user space
4 process to play with the GPIO pins. 4 process to play with the GPIO pins.
@@ -6,17 +6,26 @@
6 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> */ 6 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> */
7 7
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/device.h>
9#include <linux/fs.h> 10#include <linux/fs.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/errno.h> 12#include <linux/errno.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h>
14#include <asm/uaccess.h> 16#include <asm/uaccess.h>
15#include <asm/io.h> 17#include <asm/io.h>
16 18
19#include <linux/types.h>
20#include <linux/cdev.h>
21
17#include <linux/scx200_gpio.h> 22#include <linux/scx200_gpio.h>
23#include <linux/nsc_gpio.h>
18 24
19#define NAME "scx200_gpio" 25#define NAME "scx200_gpio"
26#define DEVNAME NAME
27
28static struct platform_device *pdev;
20 29
21MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>"); 30MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
22MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver"); 31MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver");
@@ -26,70 +35,23 @@ static int major = 0; /* default to dynamic major */
26module_param(major, int, 0); 35module_param(major, int, 0);
27MODULE_PARM_DESC(major, "Major device number"); 36MODULE_PARM_DESC(major, "Major device number");
28 37
29static ssize_t scx200_gpio_write(struct file *file, const char __user *data, 38struct nsc_gpio_ops scx200_access = {
30 size_t len, loff_t *ppos) 39 .owner = THIS_MODULE,
31{ 40 .gpio_config = scx200_gpio_configure,
32 unsigned m = iminor(file->f_dentry->d_inode); 41 .gpio_dump = nsc_gpio_dump,
33 size_t i; 42 .gpio_get = scx200_gpio_get,
34 43 .gpio_set = scx200_gpio_set,
35 for (i = 0; i < len; ++i) { 44 .gpio_set_high = scx200_gpio_set_high,
36 char c; 45 .gpio_set_low = scx200_gpio_set_low,
37 if (get_user(c, data+i)) 46 .gpio_change = scx200_gpio_change,
38 return -EFAULT; 47 .gpio_current = scx200_gpio_current
39 switch (c) 48};
40 {
41 case '0':
42 scx200_gpio_set(m, 0);
43 break;
44 case '1':
45 scx200_gpio_set(m, 1);
46 break;
47 case 'O':
48 printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
49 scx200_gpio_configure(m, ~1, 1);
50 break;
51 case 'o':
52 printk(KERN_INFO NAME ": GPIO%d output disabled\n", m);
53 scx200_gpio_configure(m, ~1, 0);
54 break;
55 case 'T':
56 printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m);
57 scx200_gpio_configure(m, ~2, 2);
58 break;
59 case 't':
60 printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m);
61 scx200_gpio_configure(m, ~2, 0);
62 break;
63 case 'P':
64 printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m);
65 scx200_gpio_configure(m, ~4, 4);
66 break;
67 case 'p':
68 printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
69 scx200_gpio_configure(m, ~4, 0);
70 break;
71 }
72 }
73
74 return len;
75}
76
77static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
78 size_t len, loff_t *ppos)
79{
80 unsigned m = iminor(file->f_dentry->d_inode);
81 int value;
82
83 value = scx200_gpio_get(m);
84 if (put_user(value ? '1' : '0', buf))
85 return -EFAULT;
86
87 return 1;
88}
89 49
90static int scx200_gpio_open(struct inode *inode, struct file *file) 50static int scx200_gpio_open(struct inode *inode, struct file *file)
91{ 51{
92 unsigned m = iminor(inode); 52 unsigned m = iminor(inode);
53 file->private_data = &scx200_access;
54
93 if (m > 63) 55 if (m > 63)
94 return -EINVAL; 56 return -EINVAL;
95 return nonseekable_open(inode, file); 57 return nonseekable_open(inode, file);
@@ -103,47 +65,81 @@ static int scx200_gpio_release(struct inode *inode, struct file *file)
103 65
104static struct file_operations scx200_gpio_fops = { 66static struct file_operations scx200_gpio_fops = {
105 .owner = THIS_MODULE, 67 .owner = THIS_MODULE,
106 .write = scx200_gpio_write, 68 .write = nsc_gpio_write,
107 .read = scx200_gpio_read, 69 .read = nsc_gpio_read,
108 .open = scx200_gpio_open, 70 .open = scx200_gpio_open,
109 .release = scx200_gpio_release, 71 .release = scx200_gpio_release,
110}; 72};
111 73
74struct cdev *scx200_devices;
75static int num_pins = 32;
76
112static int __init scx200_gpio_init(void) 77static int __init scx200_gpio_init(void)
113{ 78{
114 int r; 79 int rc, i;
115 80 dev_t dev = MKDEV(major, 0);
116 printk(KERN_DEBUG NAME ": NatSemi SCx200 GPIO Driver\n");
117 81
118 if (!scx200_gpio_present()) { 82 if (!scx200_gpio_present()) {
119 printk(KERN_ERR NAME ": no SCx200 gpio pins available\n"); 83 printk(KERN_ERR NAME ": no SCx200 gpio present\n");
120 return -ENODEV; 84 return -ENODEV;
121 } 85 }
122 86
123 r = register_chrdev(major, NAME, &scx200_gpio_fops); 87 /* support dev_dbg() with pdev->dev */
124 if (r < 0) { 88 pdev = platform_device_alloc(DEVNAME, 0);
125 printk(KERN_ERR NAME ": unable to register character device\n"); 89 if (!pdev)
126 return r; 90 return -ENOMEM;
91
92 rc = platform_device_add(pdev);
93 if (rc)
94 goto undo_malloc;
95
96 /* nsc_gpio uses dev_dbg(), so needs this */
97 scx200_access.dev = &pdev->dev;
98
99 if (major)
100 rc = register_chrdev_region(dev, num_pins, "scx200_gpio");
101 else {
102 rc = alloc_chrdev_region(&dev, 0, num_pins, "scx200_gpio");
103 major = MAJOR(dev);
127 } 104 }
128 if (!major) { 105 if (rc < 0) {
129 major = r; 106 dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc);
130 printk(KERN_DEBUG NAME ": got dynamic major %d\n", major); 107 goto undo_platform_device_add;
108 }
109 scx200_devices = kzalloc(num_pins * sizeof(struct cdev), GFP_KERNEL);
110 if (!scx200_devices) {
111 rc = -ENOMEM;
112 goto undo_chrdev_region;
113 }
114 for (i = 0; i < num_pins; i++) {
115 struct cdev *cdev = &scx200_devices[i];
116 cdev_init(cdev, &scx200_gpio_fops);
117 cdev->owner = THIS_MODULE;
118 rc = cdev_add(cdev, MKDEV(major, i), 1);
119 /* tolerate 'minor' errors */
120 if (rc)
121 dev_err(&pdev->dev, "Error %d on minor %d", rc, i);
131 } 122 }
132 123
133 return 0; 124 return 0; /* succeed */
125
126undo_chrdev_region:
127 unregister_chrdev_region(dev, num_pins);
128undo_platform_device_add:
129 platform_device_put(pdev);
130undo_malloc:
131 kfree(pdev);
132 return rc;
134} 133}
135 134
136static void __exit scx200_gpio_cleanup(void) 135static void __exit scx200_gpio_cleanup(void)
137{ 136{
138 unregister_chrdev(major, NAME); 137 kfree(scx200_devices);
138 unregister_chrdev_region(MKDEV(major, 0), num_pins);
139 platform_device_put(pdev);
140 platform_device_unregister(pdev);
141 /* kfree(pdev); */
139} 142}
140 143
141module_init(scx200_gpio_init); 144module_init(scx200_gpio_init);
142module_exit(scx200_gpio_cleanup); 145module_exit(scx200_gpio_cleanup);
143
144/*
145 Local variables:
146 compile-command: "make -k -C ../.. SUBDIRS=drivers/char modules"
147 c-basic-offset: 8
148 End:
149*/
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 037c940ac71b..c851eeaa4069 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -2235,7 +2235,6 @@ scrn[1] = '\0';
2235 /* Initialize the tty_driver structure */ 2235 /* Initialize the tty_driver structure */
2236 2236
2237 cy_serial_driver->owner = THIS_MODULE; 2237 cy_serial_driver->owner = THIS_MODULE;
2238 cy_serial_driver->devfs_name = "tts/";
2239 cy_serial_driver->name = "ttyS"; 2238 cy_serial_driver->name = "ttyS";
2240 cy_serial_driver->major = TTY_MAJOR; 2239 cy_serial_driver->major = TTY_MAJOR;
2241 cy_serial_driver->minor_start = 64; 2240 cy_serial_driver->minor_start = 64;
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 1b5330299e30..d2d6b01dcd05 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2477,7 +2477,7 @@ static int __init specialix_init(void)
2477#endif 2477#endif
2478 2478
2479 for (i = 0; i < SX_NBOARD; i++) 2479 for (i = 0; i < SX_NBOARD; i++)
2480 sx_board[i].lock = SPIN_LOCK_UNLOCKED; 2480 spin_lock_init(&sx_board[i].lock);
2481 2481
2482 if (sx_init_drivers()) { 2482 if (sx_init_drivers()) {
2483 func_exit(); 2483 func_exit();
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index a9c5a7230f89..0f7a542d9041 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -40,7 +40,6 @@
40#include <linux/ioport.h> 40#include <linux/ioport.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/smp_lock.h> 42#include <linux/smp_lock.h>
43#include <linux/devfs_fs_kernel.h>
44#include <linux/device.h> 43#include <linux/device.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
46 45
@@ -141,15 +140,6 @@ static char *stl_drvversion = "5.6.0";
141static struct tty_driver *stl_serial; 140static struct tty_driver *stl_serial;
142 141
143/* 142/*
144 * We will need to allocate a temporary write buffer for chars that
145 * come direct from user space. The problem is that a copy from user
146 * space might cause a page fault (typically on a system that is
147 * swapping!). All ports will share one buffer - since if the system
148 * is already swapping a shared buffer won't make things any worse.
149 */
150static char *stl_tmpwritebuf;
151
152/*
153 * Define a local default termios struct. All ports will be created 143 * Define a local default termios struct. All ports will be created
154 * with this termios initially. Basically all it defines is a raw port 144 * with this termios initially. Basically all it defines is a raw port
155 * at 9600, 8 data bits, 1 stop bit. 145 * at 9600, 8 data bits, 1 stop bit.
@@ -363,6 +353,14 @@ static unsigned char stl_vecmap[] = {
363}; 353};
364 354
365/* 355/*
356 * Lock ordering is that you may not take stallion_lock holding
357 * brd_lock.
358 */
359
360static spinlock_t brd_lock; /* Guard the board mapping */
361static spinlock_t stallion_lock; /* Guard the tty driver */
362
363/*
366 * Set up enable and disable macros for the ECH boards. They require 364 * Set up enable and disable macros for the ECH boards. They require
367 * the secondary io address space to be activated and deactivated. 365 * the secondary io address space to be activated and deactivated.
368 * This way all ECH boards can share their secondary io region. 366 * This way all ECH boards can share their secondary io region.
@@ -725,17 +723,7 @@ static struct class *stallion_class;
725 723
726static int __init stallion_module_init(void) 724static int __init stallion_module_init(void)
727{ 725{
728 unsigned long flags;
729
730#ifdef DEBUG
731 printk("init_module()\n");
732#endif
733
734 save_flags(flags);
735 cli();
736 stl_init(); 726 stl_init();
737 restore_flags(flags);
738
739 return 0; 727 return 0;
740} 728}
741 729
@@ -746,7 +734,6 @@ static void __exit stallion_module_exit(void)
746 stlbrd_t *brdp; 734 stlbrd_t *brdp;
747 stlpanel_t *panelp; 735 stlpanel_t *panelp;
748 stlport_t *portp; 736 stlport_t *portp;
749 unsigned long flags;
750 int i, j, k; 737 int i, j, k;
751 738
752#ifdef DEBUG 739#ifdef DEBUG
@@ -756,9 +743,6 @@ static void __exit stallion_module_exit(void)
756 printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle, 743 printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
757 stl_drvversion); 744 stl_drvversion);
758 745
759 save_flags(flags);
760 cli();
761
762/* 746/*
763 * Free up all allocated resources used by the ports. This includes 747 * Free up all allocated resources used by the ports. This includes
764 * memory and interrupts. As part of this process we will also do 748 * memory and interrupts. As part of this process we will also do
@@ -770,21 +754,15 @@ static void __exit stallion_module_exit(void)
770 if (i) { 754 if (i) {
771 printk("STALLION: failed to un-register tty driver, " 755 printk("STALLION: failed to un-register tty driver, "
772 "errno=%d\n", -i); 756 "errno=%d\n", -i);
773 restore_flags(flags);
774 return; 757 return;
775 } 758 }
776 for (i = 0; i < 4; i++) { 759 for (i = 0; i < 4; i++)
777 devfs_remove("staliomem/%d", i);
778 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 760 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
779 }
780 devfs_remove("staliomem");
781 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) 761 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
782 printk("STALLION: failed to un-register serial memory device, " 762 printk("STALLION: failed to un-register serial memory device, "
783 "errno=%d\n", -i); 763 "errno=%d\n", -i);
784 class_destroy(stallion_class); 764 class_destroy(stallion_class);
785 765
786 kfree(stl_tmpwritebuf);
787
788 for (i = 0; (i < stl_nrbrds); i++) { 766 for (i = 0; (i < stl_nrbrds); i++) {
789 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) 767 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
790 continue; 768 continue;
@@ -814,8 +792,6 @@ static void __exit stallion_module_exit(void)
814 kfree(brdp); 792 kfree(brdp);
815 stl_brds[i] = (stlbrd_t *) NULL; 793 stl_brds[i] = (stlbrd_t *) NULL;
816 } 794 }
817
818 restore_flags(flags);
819} 795}
820 796
821module_init(stallion_module_init); 797module_init(stallion_module_init);
@@ -948,7 +924,7 @@ static stlbrd_t *stl_allocbrd(void)
948 924
949 brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL); 925 brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL);
950 if (!brdp) { 926 if (!brdp) {
951 printk("STALLION: failed to allocate memory (size=%d)\n", 927 printk("STALLION: failed to allocate memory (size=%Zd)\n",
952 sizeof(stlbrd_t)); 928 sizeof(stlbrd_t));
953 return NULL; 929 return NULL;
954 } 930 }
@@ -1066,16 +1042,17 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp)
1066 rc = 0; 1042 rc = 0;
1067 doclocal = 0; 1043 doclocal = 0;
1068 1044
1045 spin_lock_irqsave(&stallion_lock, flags);
1046
1069 if (portp->tty->termios->c_cflag & CLOCAL) 1047 if (portp->tty->termios->c_cflag & CLOCAL)
1070 doclocal++; 1048 doclocal++;
1071 1049
1072 save_flags(flags);
1073 cli();
1074 portp->openwaitcnt++; 1050 portp->openwaitcnt++;
1075 if (! tty_hung_up_p(filp)) 1051 if (! tty_hung_up_p(filp))
1076 portp->refcount--; 1052 portp->refcount--;
1077 1053
1078 for (;;) { 1054 for (;;) {
1055 /* Takes brd_lock internally */
1079 stl_setsignals(portp, 1, 1); 1056 stl_setsignals(portp, 1, 1);
1080 if (tty_hung_up_p(filp) || 1057 if (tty_hung_up_p(filp) ||
1081 ((portp->flags & ASYNC_INITIALIZED) == 0)) { 1058 ((portp->flags & ASYNC_INITIALIZED) == 0)) {
@@ -1093,13 +1070,14 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp)
1093 rc = -ERESTARTSYS; 1070 rc = -ERESTARTSYS;
1094 break; 1071 break;
1095 } 1072 }
1073 /* FIXME */
1096 interruptible_sleep_on(&portp->open_wait); 1074 interruptible_sleep_on(&portp->open_wait);
1097 } 1075 }
1098 1076
1099 if (! tty_hung_up_p(filp)) 1077 if (! tty_hung_up_p(filp))
1100 portp->refcount++; 1078 portp->refcount++;
1101 portp->openwaitcnt--; 1079 portp->openwaitcnt--;
1102 restore_flags(flags); 1080 spin_unlock_irqrestore(&stallion_lock, flags);
1103 1081
1104 return rc; 1082 return rc;
1105} 1083}
@@ -1119,16 +1097,15 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
1119 if (portp == (stlport_t *) NULL) 1097 if (portp == (stlport_t *) NULL)
1120 return; 1098 return;
1121 1099
1122 save_flags(flags); 1100 spin_lock_irqsave(&stallion_lock, flags);
1123 cli();
1124 if (tty_hung_up_p(filp)) { 1101 if (tty_hung_up_p(filp)) {
1125 restore_flags(flags); 1102 spin_unlock_irqrestore(&stallion_lock, flags);
1126 return; 1103 return;
1127 } 1104 }
1128 if ((tty->count == 1) && (portp->refcount != 1)) 1105 if ((tty->count == 1) && (portp->refcount != 1))
1129 portp->refcount = 1; 1106 portp->refcount = 1;
1130 if (portp->refcount-- > 1) { 1107 if (portp->refcount-- > 1) {
1131 restore_flags(flags); 1108 spin_unlock_irqrestore(&stallion_lock, flags);
1132 return; 1109 return;
1133 } 1110 }
1134 1111
@@ -1142,11 +1119,18 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
1142 * (The sc26198 has no "end-of-data" interrupt only empty FIFO) 1119 * (The sc26198 has no "end-of-data" interrupt only empty FIFO)
1143 */ 1120 */
1144 tty->closing = 1; 1121 tty->closing = 1;
1122
1123 spin_unlock_irqrestore(&stallion_lock, flags);
1124
1145 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1125 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1146 tty_wait_until_sent(tty, portp->closing_wait); 1126 tty_wait_until_sent(tty, portp->closing_wait);
1147 stl_waituntilsent(tty, (HZ / 2)); 1127 stl_waituntilsent(tty, (HZ / 2));
1148 1128
1129
1130 spin_lock_irqsave(&stallion_lock, flags);
1149 portp->flags &= ~ASYNC_INITIALIZED; 1131 portp->flags &= ~ASYNC_INITIALIZED;
1132 spin_unlock_irqrestore(&stallion_lock, flags);
1133
1150 stl_disableintrs(portp); 1134 stl_disableintrs(portp);
1151 if (tty->termios->c_cflag & HUPCL) 1135 if (tty->termios->c_cflag & HUPCL)
1152 stl_setsignals(portp, 0, 0); 1136 stl_setsignals(portp, 0, 0);
@@ -1173,7 +1157,6 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
1173 1157
1174 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1158 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1175 wake_up_interruptible(&portp->close_wait); 1159 wake_up_interruptible(&portp->close_wait);
1176 restore_flags(flags);
1177} 1160}
1178 1161
1179/*****************************************************************************/ 1162/*****************************************************************************/
@@ -1195,9 +1178,6 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count
1195 (int) tty, (int) buf, count); 1178 (int) tty, (int) buf, count);
1196#endif 1179#endif
1197 1180
1198 if ((tty == (struct tty_struct *) NULL) ||
1199 (stl_tmpwritebuf == (char *) NULL))
1200 return 0;
1201 portp = tty->driver_data; 1181 portp = tty->driver_data;
1202 if (portp == (stlport_t *) NULL) 1182 if (portp == (stlport_t *) NULL)
1203 return 0; 1183 return 0;
@@ -1302,11 +1282,6 @@ static void stl_flushchars(struct tty_struct *tty)
1302 if (portp->tx.buf == (char *) NULL) 1282 if (portp->tx.buf == (char *) NULL)
1303 return; 1283 return;
1304 1284
1305#if 0
1306 if (tty->stopped || tty->hw_stopped ||
1307 (portp->tx.head == portp->tx.tail))
1308 return;
1309#endif
1310 stl_startrxtx(portp, -1, 1); 1285 stl_startrxtx(portp, -1, 1);
1311} 1286}
1312 1287
@@ -1977,12 +1952,14 @@ static int stl_eiointr(stlbrd_t *brdp)
1977 unsigned int iobase; 1952 unsigned int iobase;
1978 int handled = 0; 1953 int handled = 0;
1979 1954
1955 spin_lock(&brd_lock);
1980 panelp = brdp->panels[0]; 1956 panelp = brdp->panels[0];
1981 iobase = panelp->iobase; 1957 iobase = panelp->iobase;
1982 while (inb(brdp->iostatus) & EIO_INTRPEND) { 1958 while (inb(brdp->iostatus) & EIO_INTRPEND) {
1983 handled = 1; 1959 handled = 1;
1984 (* panelp->isr)(panelp, iobase); 1960 (* panelp->isr)(panelp, iobase);
1985 } 1961 }
1962 spin_unlock(&brd_lock);
1986 return handled; 1963 return handled;
1987} 1964}
1988 1965
@@ -2168,7 +2145,7 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
2168 portp = kzalloc(sizeof(stlport_t), GFP_KERNEL); 2145 portp = kzalloc(sizeof(stlport_t), GFP_KERNEL);
2169 if (!portp) { 2146 if (!portp) {
2170 printk("STALLION: failed to allocate memory " 2147 printk("STALLION: failed to allocate memory "
2171 "(size=%d)\n", sizeof(stlport_t)); 2148 "(size=%Zd)\n", sizeof(stlport_t));
2172 break; 2149 break;
2173 } 2150 }
2174 2151
@@ -2304,7 +2281,7 @@ static inline int stl_initeio(stlbrd_t *brdp)
2304 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); 2281 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL);
2305 if (!panelp) { 2282 if (!panelp) {
2306 printk(KERN_WARNING "STALLION: failed to allocate memory " 2283 printk(KERN_WARNING "STALLION: failed to allocate memory "
2307 "(size=%d)\n", sizeof(stlpanel_t)); 2284 "(size=%Zd)\n", sizeof(stlpanel_t));
2308 return -ENOMEM; 2285 return -ENOMEM;
2309 } 2286 }
2310 2287
@@ -2478,7 +2455,7 @@ static inline int stl_initech(stlbrd_t *brdp)
2478 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); 2455 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL);
2479 if (!panelp) { 2456 if (!panelp) {
2480 printk("STALLION: failed to allocate memory " 2457 printk("STALLION: failed to allocate memory "
2481 "(size=%d)\n", sizeof(stlpanel_t)); 2458 "(size=%Zd)\n", sizeof(stlpanel_t));
2482 break; 2459 break;
2483 } 2460 }
2484 panelp->magic = STL_PANELMAGIC; 2461 panelp->magic = STL_PANELMAGIC;
@@ -2879,8 +2856,7 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
2879 portp->stats.lflags = 0; 2856 portp->stats.lflags = 0;
2880 portp->stats.rxbuffered = 0; 2857 portp->stats.rxbuffered = 0;
2881 2858
2882 save_flags(flags); 2859 spin_lock_irqsave(&stallion_lock, flags);
2883 cli();
2884 if (portp->tty != (struct tty_struct *) NULL) { 2860 if (portp->tty != (struct tty_struct *) NULL) {
2885 if (portp->tty->driver_data == portp) { 2861 if (portp->tty->driver_data == portp) {
2886 portp->stats.ttystate = portp->tty->flags; 2862 portp->stats.ttystate = portp->tty->flags;
@@ -2894,7 +2870,7 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
2894 } 2870 }
2895 } 2871 }
2896 } 2872 }
2897 restore_flags(flags); 2873 spin_unlock_irqrestore(&stallion_lock, flags);
2898 2874
2899 head = portp->tx.head; 2875 head = portp->tx.head;
2900 tail = portp->tx.tail; 2876 tail = portp->tx.tail;
@@ -3049,6 +3025,9 @@ static int __init stl_init(void)
3049 int i; 3025 int i;
3050 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); 3026 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
3051 3027
3028 spin_lock_init(&stallion_lock);
3029 spin_lock_init(&brd_lock);
3030
3052 stl_initbrds(); 3031 stl_initbrds();
3053 3032
3054 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 3033 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
@@ -3056,35 +3035,21 @@ static int __init stl_init(void)
3056 return -1; 3035 return -1;
3057 3036
3058/* 3037/*
3059 * Allocate a temporary write buffer.
3060 */
3061 stl_tmpwritebuf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL);
3062 if (!stl_tmpwritebuf)
3063 printk("STALLION: failed to allocate memory (size=%d)\n",
3064 STL_TXBUFSIZE);
3065
3066/*
3067 * Set up a character driver for per board stuff. This is mainly used 3038 * Set up a character driver for per board stuff. This is mainly used
3068 * to do stats ioctls on the ports. 3039 * to do stats ioctls on the ports.
3069 */ 3040 */
3070 if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stl_fsiomem)) 3041 if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stl_fsiomem))
3071 printk("STALLION: failed to register serial board device\n"); 3042 printk("STALLION: failed to register serial board device\n");
3072 devfs_mk_dir("staliomem");
3073 3043
3074 stallion_class = class_create(THIS_MODULE, "staliomem"); 3044 stallion_class = class_create(THIS_MODULE, "staliomem");
3075 for (i = 0; i < 4; i++) { 3045 for (i = 0; i < 4; i++)
3076 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
3077 S_IFCHR|S_IRUSR|S_IWUSR,
3078 "staliomem/%d", i);
3079 class_device_create(stallion_class, NULL, 3046 class_device_create(stallion_class, NULL,
3080 MKDEV(STL_SIOMEMMAJOR, i), NULL, 3047 MKDEV(STL_SIOMEMMAJOR, i), NULL,
3081 "staliomem%d", i); 3048 "staliomem%d", i);
3082 }
3083 3049
3084 stl_serial->owner = THIS_MODULE; 3050 stl_serial->owner = THIS_MODULE;
3085 stl_serial->driver_name = stl_drvname; 3051 stl_serial->driver_name = stl_drvname;
3086 stl_serial->name = "ttyE"; 3052 stl_serial->name = "ttyE";
3087 stl_serial->devfs_name = "tts/E";
3088 stl_serial->major = STL_SERIALMAJOR; 3053 stl_serial->major = STL_SERIALMAJOR;
3089 stl_serial->minor_start = 0; 3054 stl_serial->minor_start = 0;
3090 stl_serial->type = TTY_DRIVER_TYPE_SERIAL; 3055 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
@@ -3147,11 +3112,13 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
3147 unsigned int gfrcr; 3112 unsigned int gfrcr;
3148 int chipmask, i, j; 3113 int chipmask, i, j;
3149 int nrchips, uartaddr, ioaddr; 3114 int nrchips, uartaddr, ioaddr;
3115 unsigned long flags;
3150 3116
3151#ifdef DEBUG 3117#ifdef DEBUG
3152 printk("stl_panelinit(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp); 3118 printk("stl_panelinit(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp);
3153#endif 3119#endif
3154 3120
3121 spin_lock_irqsave(&brd_lock, flags);
3155 BRDENABLE(panelp->brdnr, panelp->pagenr); 3122 BRDENABLE(panelp->brdnr, panelp->pagenr);
3156 3123
3157/* 3124/*
@@ -3189,6 +3156,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
3189 } 3156 }
3190 3157
3191 BRDDISABLE(panelp->brdnr); 3158 BRDDISABLE(panelp->brdnr);
3159 spin_unlock_irqrestore(&brd_lock, flags);
3192 return chipmask; 3160 return chipmask;
3193} 3161}
3194 3162
@@ -3200,6 +3168,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
3200 3168
3201static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp) 3169static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp)
3202{ 3170{
3171 unsigned long flags;
3203#ifdef DEBUG 3172#ifdef DEBUG
3204 printk("stl_cd1400portinit(brdp=%x,panelp=%x,portp=%x)\n", 3173 printk("stl_cd1400portinit(brdp=%x,panelp=%x,portp=%x)\n",
3205 (int) brdp, (int) panelp, (int) portp); 3174 (int) brdp, (int) panelp, (int) portp);
@@ -3209,6 +3178,7 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po
3209 (portp == (stlport_t *) NULL)) 3178 (portp == (stlport_t *) NULL))
3210 return; 3179 return;
3211 3180
3181 spin_lock_irqsave(&brd_lock, flags);
3212 portp->ioaddr = panelp->iobase + (((brdp->brdtype == BRD_ECHPCI) || 3182 portp->ioaddr = panelp->iobase + (((brdp->brdtype == BRD_ECHPCI) ||
3213 (portp->portnr < 8)) ? 0 : EREG_BANKSIZE); 3183 (portp->portnr < 8)) ? 0 : EREG_BANKSIZE);
3214 portp->uartaddr = (portp->portnr & 0x04) << 5; 3184 portp->uartaddr = (portp->portnr & 0x04) << 5;
@@ -3219,6 +3189,7 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po
3219 stl_cd1400setreg(portp, LIVR, (portp->portnr << 3)); 3189 stl_cd1400setreg(portp, LIVR, (portp->portnr << 3));
3220 portp->hwid = stl_cd1400getreg(portp, GFRCR); 3190 portp->hwid = stl_cd1400getreg(portp, GFRCR);
3221 BRDDISABLE(portp->brdnr); 3191 BRDDISABLE(portp->brdnr);
3192 spin_unlock_irqrestore(&brd_lock, flags);
3222} 3193}
3223 3194
3224/*****************************************************************************/ 3195/*****************************************************************************/
@@ -3428,8 +3399,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
3428 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]); 3399 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
3429#endif 3400#endif
3430 3401
3431 save_flags(flags); 3402 spin_lock_irqsave(&brd_lock, flags);
3432 cli();
3433 BRDENABLE(portp->brdnr, portp->pagenr); 3403 BRDENABLE(portp->brdnr, portp->pagenr);
3434 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x3)); 3404 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x3));
3435 srer = stl_cd1400getreg(portp, SRER); 3405 srer = stl_cd1400getreg(portp, SRER);
@@ -3466,7 +3436,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
3466 portp->sigs &= ~TIOCM_CD; 3436 portp->sigs &= ~TIOCM_CD;
3467 stl_cd1400setreg(portp, SRER, ((srer & ~sreroff) | sreron)); 3437 stl_cd1400setreg(portp, SRER, ((srer & ~sreroff) | sreron));
3468 BRDDISABLE(portp->brdnr); 3438 BRDDISABLE(portp->brdnr);
3469 restore_flags(flags); 3439 spin_unlock_irqrestore(&brd_lock, flags);
3470} 3440}
3471 3441
3472/*****************************************************************************/ 3442/*****************************************************************************/
@@ -3492,8 +3462,7 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts)
3492 if (rts > 0) 3462 if (rts > 0)
3493 msvr2 = MSVR2_RTS; 3463 msvr2 = MSVR2_RTS;
3494 3464
3495 save_flags(flags); 3465 spin_lock_irqsave(&brd_lock, flags);
3496 cli();
3497 BRDENABLE(portp->brdnr, portp->pagenr); 3466 BRDENABLE(portp->brdnr, portp->pagenr);
3498 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3467 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3499 if (rts >= 0) 3468 if (rts >= 0)
@@ -3501,7 +3470,7 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts)
3501 if (dtr >= 0) 3470 if (dtr >= 0)
3502 stl_cd1400setreg(portp, MSVR1, msvr1); 3471 stl_cd1400setreg(portp, MSVR1, msvr1);
3503 BRDDISABLE(portp->brdnr); 3472 BRDDISABLE(portp->brdnr);
3504 restore_flags(flags); 3473 spin_unlock_irqrestore(&brd_lock, flags);
3505} 3474}
3506 3475
3507/*****************************************************************************/ 3476/*****************************************************************************/
@@ -3520,14 +3489,13 @@ static int stl_cd1400getsignals(stlport_t *portp)
3520 printk("stl_cd1400getsignals(portp=%x)\n", (int) portp); 3489 printk("stl_cd1400getsignals(portp=%x)\n", (int) portp);
3521#endif 3490#endif
3522 3491
3523 save_flags(flags); 3492 spin_lock_irqsave(&brd_lock, flags);
3524 cli();
3525 BRDENABLE(portp->brdnr, portp->pagenr); 3493 BRDENABLE(portp->brdnr, portp->pagenr);
3526 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3494 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3527 msvr1 = stl_cd1400getreg(portp, MSVR1); 3495 msvr1 = stl_cd1400getreg(portp, MSVR1);
3528 msvr2 = stl_cd1400getreg(portp, MSVR2); 3496 msvr2 = stl_cd1400getreg(portp, MSVR2);
3529 BRDDISABLE(portp->brdnr); 3497 BRDDISABLE(portp->brdnr);
3530 restore_flags(flags); 3498 spin_unlock_irqrestore(&brd_lock, flags);
3531 3499
3532 sigs = 0; 3500 sigs = 0;
3533 sigs |= (msvr1 & MSVR1_DCD) ? TIOCM_CD : 0; 3501 sigs |= (msvr1 & MSVR1_DCD) ? TIOCM_CD : 0;
@@ -3569,15 +3537,14 @@ static void stl_cd1400enablerxtx(stlport_t *portp, int rx, int tx)
3569 else if (rx > 0) 3537 else if (rx > 0)
3570 ccr |= CCR_RXENABLE; 3538 ccr |= CCR_RXENABLE;
3571 3539
3572 save_flags(flags); 3540 spin_lock_irqsave(&brd_lock, flags);
3573 cli();
3574 BRDENABLE(portp->brdnr, portp->pagenr); 3541 BRDENABLE(portp->brdnr, portp->pagenr);
3575 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3542 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3576 stl_cd1400ccrwait(portp); 3543 stl_cd1400ccrwait(portp);
3577 stl_cd1400setreg(portp, CCR, ccr); 3544 stl_cd1400setreg(portp, CCR, ccr);
3578 stl_cd1400ccrwait(portp); 3545 stl_cd1400ccrwait(portp);
3579 BRDDISABLE(portp->brdnr); 3546 BRDDISABLE(portp->brdnr);
3580 restore_flags(flags); 3547 spin_unlock_irqrestore(&brd_lock, flags);
3581} 3548}
3582 3549
3583/*****************************************************************************/ 3550/*****************************************************************************/
@@ -3609,8 +3576,7 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx)
3609 else if (rx > 0) 3576 else if (rx > 0)
3610 sreron |= SRER_RXDATA; 3577 sreron |= SRER_RXDATA;
3611 3578
3612 save_flags(flags); 3579 spin_lock_irqsave(&brd_lock, flags);
3613 cli();
3614 BRDENABLE(portp->brdnr, portp->pagenr); 3580 BRDENABLE(portp->brdnr, portp->pagenr);
3615 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3581 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3616 stl_cd1400setreg(portp, SRER, 3582 stl_cd1400setreg(portp, SRER,
@@ -3618,7 +3584,7 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx)
3618 BRDDISABLE(portp->brdnr); 3584 BRDDISABLE(portp->brdnr);
3619 if (tx > 0) 3585 if (tx > 0)
3620 set_bit(ASYI_TXBUSY, &portp->istate); 3586 set_bit(ASYI_TXBUSY, &portp->istate);
3621 restore_flags(flags); 3587 spin_unlock_irqrestore(&brd_lock, flags);
3622} 3588}
3623 3589
3624/*****************************************************************************/ 3590/*****************************************************************************/
@@ -3634,13 +3600,12 @@ static void stl_cd1400disableintrs(stlport_t *portp)
3634#ifdef DEBUG 3600#ifdef DEBUG
3635 printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp); 3601 printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp);
3636#endif 3602#endif
3637 save_flags(flags); 3603 spin_lock_irqsave(&brd_lock, flags);
3638 cli();
3639 BRDENABLE(portp->brdnr, portp->pagenr); 3604 BRDENABLE(portp->brdnr, portp->pagenr);
3640 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3605 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3641 stl_cd1400setreg(portp, SRER, 0); 3606 stl_cd1400setreg(portp, SRER, 0);
3642 BRDDISABLE(portp->brdnr); 3607 BRDDISABLE(portp->brdnr);
3643 restore_flags(flags); 3608 spin_unlock_irqrestore(&brd_lock, flags);
3644} 3609}
3645 3610
3646/*****************************************************************************/ 3611/*****************************************************************************/
@@ -3653,8 +3618,7 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len)
3653 printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len); 3618 printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len);
3654#endif 3619#endif
3655 3620
3656 save_flags(flags); 3621 spin_lock_irqsave(&brd_lock, flags);
3657 cli();
3658 BRDENABLE(portp->brdnr, portp->pagenr); 3622 BRDENABLE(portp->brdnr, portp->pagenr);
3659 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3623 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3660 stl_cd1400setreg(portp, SRER, 3624 stl_cd1400setreg(portp, SRER,
@@ -3664,7 +3628,7 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len)
3664 portp->brklen = len; 3628 portp->brklen = len;
3665 if (len == 1) 3629 if (len == 1)
3666 portp->stats.txbreaks++; 3630 portp->stats.txbreaks++;
3667 restore_flags(flags); 3631 spin_unlock_irqrestore(&brd_lock, flags);
3668} 3632}
3669 3633
3670/*****************************************************************************/ 3634/*****************************************************************************/
@@ -3688,8 +3652,7 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state)
3688 if (tty == (struct tty_struct *) NULL) 3652 if (tty == (struct tty_struct *) NULL)
3689 return; 3653 return;
3690 3654
3691 save_flags(flags); 3655 spin_lock_irqsave(&brd_lock, flags);
3692 cli();
3693 BRDENABLE(portp->brdnr, portp->pagenr); 3656 BRDENABLE(portp->brdnr, portp->pagenr);
3694 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3657 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3695 3658
@@ -3729,7 +3692,7 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state)
3729 } 3692 }
3730 3693
3731 BRDDISABLE(portp->brdnr); 3694 BRDDISABLE(portp->brdnr);
3732 restore_flags(flags); 3695 spin_unlock_irqrestore(&brd_lock, flags);
3733} 3696}
3734 3697
3735/*****************************************************************************/ 3698/*****************************************************************************/
@@ -3753,8 +3716,7 @@ static void stl_cd1400sendflow(stlport_t *portp, int state)
3753 if (tty == (struct tty_struct *) NULL) 3716 if (tty == (struct tty_struct *) NULL)
3754 return; 3717 return;
3755 3718
3756 save_flags(flags); 3719 spin_lock_irqsave(&brd_lock, flags);
3757 cli();
3758 BRDENABLE(portp->brdnr, portp->pagenr); 3720 BRDENABLE(portp->brdnr, portp->pagenr);
3759 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3721 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3760 if (state) { 3722 if (state) {
@@ -3769,7 +3731,7 @@ static void stl_cd1400sendflow(stlport_t *portp, int state)
3769 stl_cd1400ccrwait(portp); 3731 stl_cd1400ccrwait(portp);
3770 } 3732 }
3771 BRDDISABLE(portp->brdnr); 3733 BRDDISABLE(portp->brdnr);
3772 restore_flags(flags); 3734 spin_unlock_irqrestore(&brd_lock, flags);
3773} 3735}
3774 3736
3775/*****************************************************************************/ 3737/*****************************************************************************/
@@ -3785,8 +3747,7 @@ static void stl_cd1400flush(stlport_t *portp)
3785 if (portp == (stlport_t *) NULL) 3747 if (portp == (stlport_t *) NULL)
3786 return; 3748 return;
3787 3749
3788 save_flags(flags); 3750 spin_lock_irqsave(&brd_lock, flags);
3789 cli();
3790 BRDENABLE(portp->brdnr, portp->pagenr); 3751 BRDENABLE(portp->brdnr, portp->pagenr);
3791 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3752 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3792 stl_cd1400ccrwait(portp); 3753 stl_cd1400ccrwait(portp);
@@ -3794,7 +3755,7 @@ static void stl_cd1400flush(stlport_t *portp)
3794 stl_cd1400ccrwait(portp); 3755 stl_cd1400ccrwait(portp);
3795 portp->tx.tail = portp->tx.head; 3756 portp->tx.tail = portp->tx.head;
3796 BRDDISABLE(portp->brdnr); 3757 BRDDISABLE(portp->brdnr);
3797 restore_flags(flags); 3758 spin_unlock_irqrestore(&brd_lock, flags);
3798} 3759}
3799 3760
3800/*****************************************************************************/ 3761/*****************************************************************************/
@@ -3833,6 +3794,7 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase)
3833 (int) panelp, iobase); 3794 (int) panelp, iobase);
3834#endif 3795#endif
3835 3796
3797 spin_lock(&brd_lock);
3836 outb(SVRR, iobase); 3798 outb(SVRR, iobase);
3837 svrtype = inb(iobase + EREG_DATA); 3799 svrtype = inb(iobase + EREG_DATA);
3838 if (panelp->nrports > 4) { 3800 if (panelp->nrports > 4) {
@@ -3846,6 +3808,8 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase)
3846 stl_cd1400txisr(panelp, iobase); 3808 stl_cd1400txisr(panelp, iobase);
3847 else if (svrtype & SVRR_MDM) 3809 else if (svrtype & SVRR_MDM)
3848 stl_cd1400mdmisr(panelp, iobase); 3810 stl_cd1400mdmisr(panelp, iobase);
3811
3812 spin_unlock(&brd_lock);
3849} 3813}
3850 3814
3851/*****************************************************************************/ 3815/*****************************************************************************/
@@ -4433,8 +4397,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
4433 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]); 4397 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
4434#endif 4398#endif
4435 4399
4436 save_flags(flags); 4400 spin_lock_irqsave(&brd_lock, flags);
4437 cli();
4438 BRDENABLE(portp->brdnr, portp->pagenr); 4401 BRDENABLE(portp->brdnr, portp->pagenr);
4439 stl_sc26198setreg(portp, IMR, 0); 4402 stl_sc26198setreg(portp, IMR, 0);
4440 stl_sc26198updatereg(portp, MR0, mr0); 4403 stl_sc26198updatereg(portp, MR0, mr0);
@@ -4461,7 +4424,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
4461 portp->imr = (portp->imr & ~imroff) | imron; 4424 portp->imr = (portp->imr & ~imroff) | imron;
4462 stl_sc26198setreg(portp, IMR, portp->imr); 4425 stl_sc26198setreg(portp, IMR, portp->imr);
4463 BRDDISABLE(portp->brdnr); 4426 BRDDISABLE(portp->brdnr);
4464 restore_flags(flags); 4427 spin_unlock_irqrestore(&brd_lock, flags);
4465} 4428}
4466 4429
4467/*****************************************************************************/ 4430/*****************************************************************************/
@@ -4491,13 +4454,12 @@ static void stl_sc26198setsignals(stlport_t *portp, int dtr, int rts)
4491 else if (rts > 0) 4454 else if (rts > 0)
4492 iopioron |= IPR_RTS; 4455 iopioron |= IPR_RTS;
4493 4456
4494 save_flags(flags); 4457 spin_lock_irqsave(&brd_lock, flags);
4495 cli();
4496 BRDENABLE(portp->brdnr, portp->pagenr); 4458 BRDENABLE(portp->brdnr, portp->pagenr);
4497 stl_sc26198setreg(portp, IOPIOR, 4459 stl_sc26198setreg(portp, IOPIOR,
4498 ((stl_sc26198getreg(portp, IOPIOR) & ~iopioroff) | iopioron)); 4460 ((stl_sc26198getreg(portp, IOPIOR) & ~iopioroff) | iopioron));
4499 BRDDISABLE(portp->brdnr); 4461 BRDDISABLE(portp->brdnr);
4500 restore_flags(flags); 4462 spin_unlock_irqrestore(&brd_lock, flags);
4501} 4463}
4502 4464
4503/*****************************************************************************/ 4465/*****************************************************************************/
@@ -4516,12 +4478,11 @@ static int stl_sc26198getsignals(stlport_t *portp)
4516 printk("stl_sc26198getsignals(portp=%x)\n", (int) portp); 4478 printk("stl_sc26198getsignals(portp=%x)\n", (int) portp);
4517#endif 4479#endif
4518 4480
4519 save_flags(flags); 4481 spin_lock_irqsave(&brd_lock, flags);
4520 cli();
4521 BRDENABLE(portp->brdnr, portp->pagenr); 4482 BRDENABLE(portp->brdnr, portp->pagenr);
4522 ipr = stl_sc26198getreg(portp, IPR); 4483 ipr = stl_sc26198getreg(portp, IPR);
4523 BRDDISABLE(portp->brdnr); 4484 BRDDISABLE(portp->brdnr);
4524 restore_flags(flags); 4485 spin_unlock_irqrestore(&brd_lock, flags);
4525 4486
4526 sigs = 0; 4487 sigs = 0;
4527 sigs |= (ipr & IPR_DCD) ? 0 : TIOCM_CD; 4488 sigs |= (ipr & IPR_DCD) ? 0 : TIOCM_CD;
@@ -4558,13 +4519,12 @@ static void stl_sc26198enablerxtx(stlport_t *portp, int rx, int tx)
4558 else if (rx > 0) 4519 else if (rx > 0)
4559 ccr |= CR_RXENABLE; 4520 ccr |= CR_RXENABLE;
4560 4521
4561 save_flags(flags); 4522 spin_lock_irqsave(&brd_lock, flags);
4562 cli();
4563 BRDENABLE(portp->brdnr, portp->pagenr); 4523 BRDENABLE(portp->brdnr, portp->pagenr);
4564 stl_sc26198setreg(portp, SCCR, ccr); 4524 stl_sc26198setreg(portp, SCCR, ccr);
4565 BRDDISABLE(portp->brdnr); 4525 BRDDISABLE(portp->brdnr);
4566 portp->crenable = ccr; 4526 portp->crenable = ccr;
4567 restore_flags(flags); 4527 spin_unlock_irqrestore(&brd_lock, flags);
4568} 4528}
4569 4529
4570/*****************************************************************************/ 4530/*****************************************************************************/
@@ -4593,15 +4553,14 @@ static void stl_sc26198startrxtx(stlport_t *portp, int rx, int tx)
4593 else if (rx > 0) 4553 else if (rx > 0)
4594 imr |= IR_RXRDY | IR_RXBREAK | IR_RXWATCHDOG; 4554 imr |= IR_RXRDY | IR_RXBREAK | IR_RXWATCHDOG;
4595 4555
4596 save_flags(flags); 4556 spin_lock_irqsave(&brd_lock, flags);
4597 cli();
4598 BRDENABLE(portp->brdnr, portp->pagenr); 4557 BRDENABLE(portp->brdnr, portp->pagenr);
4599 stl_sc26198setreg(portp, IMR, imr); 4558 stl_sc26198setreg(portp, IMR, imr);
4600 BRDDISABLE(portp->brdnr); 4559 BRDDISABLE(portp->brdnr);
4601 portp->imr = imr; 4560 portp->imr = imr;
4602 if (tx > 0) 4561 if (tx > 0)
4603 set_bit(ASYI_TXBUSY, &portp->istate); 4562 set_bit(ASYI_TXBUSY, &portp->istate);
4604 restore_flags(flags); 4563 spin_unlock_irqrestore(&brd_lock, flags);
4605} 4564}
4606 4565
4607/*****************************************************************************/ 4566/*****************************************************************************/
@@ -4618,13 +4577,12 @@ static void stl_sc26198disableintrs(stlport_t *portp)
4618 printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp); 4577 printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp);
4619#endif 4578#endif
4620 4579
4621 save_flags(flags); 4580 spin_lock_irqsave(&brd_lock, flags);
4622 cli();
4623 BRDENABLE(portp->brdnr, portp->pagenr); 4581 BRDENABLE(portp->brdnr, portp->pagenr);
4624 portp->imr = 0; 4582 portp->imr = 0;
4625 stl_sc26198setreg(portp, IMR, 0); 4583 stl_sc26198setreg(portp, IMR, 0);
4626 BRDDISABLE(portp->brdnr); 4584 BRDDISABLE(portp->brdnr);
4627 restore_flags(flags); 4585 spin_unlock_irqrestore(&brd_lock, flags);
4628} 4586}
4629 4587
4630/*****************************************************************************/ 4588/*****************************************************************************/
@@ -4637,8 +4595,7 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len)
4637 printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len); 4595 printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len);
4638#endif 4596#endif
4639 4597
4640 save_flags(flags); 4598 spin_lock_irqsave(&brd_lock, flags);
4641 cli();
4642 BRDENABLE(portp->brdnr, portp->pagenr); 4599 BRDENABLE(portp->brdnr, portp->pagenr);
4643 if (len == 1) { 4600 if (len == 1) {
4644 stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK); 4601 stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK);
@@ -4647,7 +4604,7 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len)
4647 stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK); 4604 stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK);
4648 } 4605 }
4649 BRDDISABLE(portp->brdnr); 4606 BRDDISABLE(portp->brdnr);
4650 restore_flags(flags); 4607 spin_unlock_irqrestore(&brd_lock, flags);
4651} 4608}
4652 4609
4653/*****************************************************************************/ 4610/*****************************************************************************/
@@ -4672,8 +4629,7 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state)
4672 if (tty == (struct tty_struct *) NULL) 4629 if (tty == (struct tty_struct *) NULL)
4673 return; 4630 return;
4674 4631
4675 save_flags(flags); 4632 spin_lock_irqsave(&brd_lock, flags);
4676 cli();
4677 BRDENABLE(portp->brdnr, portp->pagenr); 4633 BRDENABLE(portp->brdnr, portp->pagenr);
4678 4634
4679 if (state) { 4635 if (state) {
@@ -4719,7 +4675,7 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state)
4719 } 4675 }
4720 4676
4721 BRDDISABLE(portp->brdnr); 4677 BRDDISABLE(portp->brdnr);
4722 restore_flags(flags); 4678 spin_unlock_irqrestore(&brd_lock, flags);
4723} 4679}
4724 4680
4725/*****************************************************************************/ 4681/*****************************************************************************/
@@ -4744,8 +4700,7 @@ static void stl_sc26198sendflow(stlport_t *portp, int state)
4744 if (tty == (struct tty_struct *) NULL) 4700 if (tty == (struct tty_struct *) NULL)
4745 return; 4701 return;
4746 4702
4747 save_flags(flags); 4703 spin_lock_irqsave(&brd_lock, flags);
4748 cli();
4749 BRDENABLE(portp->brdnr, portp->pagenr); 4704 BRDENABLE(portp->brdnr, portp->pagenr);
4750 if (state) { 4705 if (state) {
4751 mr0 = stl_sc26198getreg(portp, MR0); 4706 mr0 = stl_sc26198getreg(portp, MR0);
@@ -4765,7 +4720,7 @@ static void stl_sc26198sendflow(stlport_t *portp, int state)
4765 stl_sc26198setreg(portp, MR0, mr0); 4720 stl_sc26198setreg(portp, MR0, mr0);
4766 } 4721 }
4767 BRDDISABLE(portp->brdnr); 4722 BRDDISABLE(portp->brdnr);
4768 restore_flags(flags); 4723 spin_unlock_irqrestore(&brd_lock, flags);
4769} 4724}
4770 4725
4771/*****************************************************************************/ 4726/*****************************************************************************/
@@ -4781,14 +4736,13 @@ static void stl_sc26198flush(stlport_t *portp)
4781 if (portp == (stlport_t *) NULL) 4736 if (portp == (stlport_t *) NULL)
4782 return; 4737 return;
4783 4738
4784 save_flags(flags); 4739 spin_lock_irqsave(&brd_lock, flags);
4785 cli();
4786 BRDENABLE(portp->brdnr, portp->pagenr); 4740 BRDENABLE(portp->brdnr, portp->pagenr);
4787 stl_sc26198setreg(portp, SCCR, CR_TXRESET); 4741 stl_sc26198setreg(portp, SCCR, CR_TXRESET);
4788 stl_sc26198setreg(portp, SCCR, portp->crenable); 4742 stl_sc26198setreg(portp, SCCR, portp->crenable);
4789 BRDDISABLE(portp->brdnr); 4743 BRDDISABLE(portp->brdnr);
4790 portp->tx.tail = portp->tx.head; 4744 portp->tx.tail = portp->tx.head;
4791 restore_flags(flags); 4745 spin_unlock_irqrestore(&brd_lock, flags);
4792} 4746}
4793 4747
4794/*****************************************************************************/ 4748/*****************************************************************************/
@@ -4815,12 +4769,11 @@ static int stl_sc26198datastate(stlport_t *portp)
4815 if (test_bit(ASYI_TXBUSY, &portp->istate)) 4769 if (test_bit(ASYI_TXBUSY, &portp->istate))
4816 return 1; 4770 return 1;
4817 4771
4818 save_flags(flags); 4772 spin_lock_irqsave(&brd_lock, flags);
4819 cli();
4820 BRDENABLE(portp->brdnr, portp->pagenr); 4773 BRDENABLE(portp->brdnr, portp->pagenr);
4821 sr = stl_sc26198getreg(portp, SR); 4774 sr = stl_sc26198getreg(portp, SR);
4822 BRDDISABLE(portp->brdnr); 4775 BRDDISABLE(portp->brdnr);
4823 restore_flags(flags); 4776 spin_unlock_irqrestore(&brd_lock, flags);
4824 4777
4825 return (sr & SR_TXEMPTY) ? 0 : 1; 4778 return (sr & SR_TXEMPTY) ? 0 : 1;
4826} 4779}
@@ -4878,6 +4831,8 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase)
4878 stlport_t *portp; 4831 stlport_t *portp;
4879 unsigned int iack; 4832 unsigned int iack;
4880 4833
4834 spin_lock(&brd_lock);
4835
4881/* 4836/*
4882 * Work around bug in sc26198 chip... Cannot have A6 address 4837 * Work around bug in sc26198 chip... Cannot have A6 address
4883 * line of UART high, else iack will be returned as 0. 4838 * line of UART high, else iack will be returned as 0.
@@ -4893,6 +4848,8 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase)
4893 stl_sc26198txisr(portp); 4848 stl_sc26198txisr(portp);
4894 else 4849 else
4895 stl_sc26198otherisr(portp, iack); 4850 stl_sc26198otherisr(portp, iack);
4851
4852 spin_unlock(&brd_lock);
4896} 4853}
4897 4854
4898/*****************************************************************************/ 4855/*****************************************************************************/
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 3b4747230270..76b9107f7f81 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2320,7 +2320,7 @@ static int sx_init_portstructs (int nboards, int nports)
2320#ifdef NEW_WRITE_LOCKING 2320#ifdef NEW_WRITE_LOCKING
2321 port->gs.port_write_mutex = MUTEX; 2321 port->gs.port_write_mutex = MUTEX;
2322#endif 2322#endif
2323 port->gs.driver_lock = SPIN_LOCK_UNLOCKED; 2323 spin_lock_init(&port->gs.driver_lock);
2324 /* 2324 /*
2325 * Initializing wait queue 2325 * Initializing wait queue
2326 */ 2326 */
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
index 079db5a935a1..f7802e5bd7ca 100644
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -56,7 +56,6 @@
56#include <linux/ioport.h> 56#include <linux/ioport.h>
57#include <asm/io.h> 57#include <asm/io.h>
58#include <linux/bitops.h> 58#include <linux/bitops.h>
59#include <linux/devfs_fs_kernel.h> /* DevFs support */
60#include <linux/parport.h> /* Our code depend on parport */ 59#include <linux/parport.h> /* Our code depend on parport */
61#include <linux/device.h> 60#include <linux/device.h>
62 61
@@ -443,12 +442,6 @@ tipar_register(int nr, struct parport *port)
443 442
444 class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR, 443 class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR,
445 TIPAR_MINOR + nr), NULL, "par%d", nr); 444 TIPAR_MINOR + nr), NULL, "par%d", nr);
446 /* Use devfs, tree: /dev/ticables/par/[0..2] */
447 err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
448 S_IFCHR | S_IRUGO | S_IWUGO,
449 "ticables/par/%d", nr);
450 if (err)
451 goto out_class;
452 445
453 /* Display informations */ 446 /* Display informations */
454 pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq == 447 pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq ==
@@ -460,11 +453,7 @@ tipar_register(int nr, struct parport *port)
460 pr_info("tipar%d: link cable not found\n", nr); 453 pr_info("tipar%d: link cable not found\n", nr);
461 454
462 err = 0; 455 err = 0;
463 goto out;
464 456
465out_class:
466 class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr));
467 class_destroy(tipar_class);
468out: 457out:
469 return err; 458 return err;
470} 459}
@@ -507,9 +496,6 @@ tipar_init_module(void)
507 goto out; 496 goto out;
508 } 497 }
509 498
510 /* Use devfs with tree: /dev/ticables/par/[0..2] */
511 devfs_mk_dir("ticables/par");
512
513 tipar_class = class_create(THIS_MODULE, "ticables"); 499 tipar_class = class_create(THIS_MODULE, "ticables");
514 if (IS_ERR(tipar_class)) { 500 if (IS_ERR(tipar_class)) {
515 err = PTR_ERR(tipar_class); 501 err = PTR_ERR(tipar_class);
@@ -528,7 +514,6 @@ out_class:
528 class_destroy(tipar_class); 514 class_destroy(tipar_class);
529 515
530out_chrdev: 516out_chrdev:
531 devfs_remove("ticables/par");
532 unregister_chrdev(TIPAR_MAJOR, "tipar"); 517 unregister_chrdev(TIPAR_MAJOR, "tipar");
533out: 518out:
534 return err; 519 return err;
@@ -549,10 +534,8 @@ tipar_cleanup_module(void)
549 continue; 534 continue;
550 parport_unregister_device(table[i].dev); 535 parport_unregister_device(table[i].dev);
551 class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i)); 536 class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i));
552 devfs_remove("ticables/par/%d", i);
553 } 537 }
554 class_destroy(tipar_class); 538 class_destroy(tipar_class);
555 devfs_remove("ticables/par");
556 539
557 pr_info("tipar: module unloaded\n"); 540 pr_info("tipar: module unloaded\n");
558} 541}
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 8b2a59969868..a1143238feca 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -102,7 +102,6 @@
102#include <linux/kbd_kern.h> 102#include <linux/kbd_kern.h>
103#include <linux/vt_kern.h> 103#include <linux/vt_kern.h>
104#include <linux/selection.h> 104#include <linux/selection.h>
105#include <linux/devfs_fs_kernel.h>
106 105
107#include <linux/kmod.h> 106#include <linux/kmod.h>
108 107
@@ -267,7 +266,6 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
267 p->used = 0; 266 p->used = 0;
268 p->size = size; 267 p->size = size;
269 p->next = NULL; 268 p->next = NULL;
270 p->active = 0;
271 p->commit = 0; 269 p->commit = 0;
272 p->read = 0; 270 p->read = 0;
273 p->char_buf_ptr = (char *)(p->data); 271 p->char_buf_ptr = (char *)(p->data);
@@ -327,10 +325,9 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
327 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 325 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
328 remove this conditional if its worth it. This would be invisible 326 remove this conditional if its worth it. This would be invisible
329 to the callers */ 327 to the callers */
330 if ((b = tty->buf.tail) != NULL) { 328 if ((b = tty->buf.tail) != NULL)
331 left = b->size - b->used; 329 left = b->size - b->used;
332 b->active = 1; 330 else
333 } else
334 left = 0; 331 left = 0;
335 332
336 if (left < size) { 333 if (left < size) {
@@ -338,12 +335,10 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
338 if ((n = tty_buffer_find(tty, size)) != NULL) { 335 if ((n = tty_buffer_find(tty, size)) != NULL) {
339 if (b != NULL) { 336 if (b != NULL) {
340 b->next = n; 337 b->next = n;
341 b->active = 0;
342 b->commit = b->used; 338 b->commit = b->used;
343 } else 339 } else
344 tty->buf.head = n; 340 tty->buf.head = n;
345 tty->buf.tail = n; 341 tty->buf.tail = n;
346 n->active = 1;
347 } else 342 } else
348 size = left; 343 size = left;
349 } 344 }
@@ -404,10 +399,8 @@ void tty_schedule_flip(struct tty_struct *tty)
404{ 399{
405 unsigned long flags; 400 unsigned long flags;
406 spin_lock_irqsave(&tty->buf.lock, flags); 401 spin_lock_irqsave(&tty->buf.lock, flags);
407 if (tty->buf.tail != NULL) { 402 if (tty->buf.tail != NULL)
408 tty->buf.tail->active = 0;
409 tty->buf.tail->commit = tty->buf.tail->used; 403 tty->buf.tail->commit = tty->buf.tail->used;
410 }
411 spin_unlock_irqrestore(&tty->buf.lock, flags); 404 spin_unlock_irqrestore(&tty->buf.lock, flags);
412 schedule_delayed_work(&tty->buf.work, 1); 405 schedule_delayed_work(&tty->buf.work, 1);
413} 406}
@@ -784,11 +777,8 @@ restart:
784 } 777 }
785 778
786 clear_bit(TTY_LDISC, &tty->flags); 779 clear_bit(TTY_LDISC, &tty->flags);
787 clear_bit(TTY_DONT_FLIP, &tty->flags); 780 if (o_tty)
788 if (o_tty) {
789 clear_bit(TTY_LDISC, &o_tty->flags); 781 clear_bit(TTY_LDISC, &o_tty->flags);
790 clear_bit(TTY_DONT_FLIP, &o_tty->flags);
791 }
792 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 782 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
793 783
794 /* 784 /*
@@ -1955,7 +1945,6 @@ static void release_dev(struct file * filp)
1955 * race with the set_ldisc code path. 1945 * race with the set_ldisc code path.
1956 */ 1946 */
1957 clear_bit(TTY_LDISC, &tty->flags); 1947 clear_bit(TTY_LDISC, &tty->flags);
1958 clear_bit(TTY_DONT_FLIP, &tty->flags);
1959 cancel_delayed_work(&tty->buf.work); 1948 cancel_delayed_work(&tty->buf.work);
1960 1949
1961 /* 1950 /*
@@ -2621,10 +2610,9 @@ int tty_ioctl(struct inode * inode, struct file * file,
2621 tty->driver->break_ctl(tty, 0); 2610 tty->driver->break_ctl(tty, 0);
2622 return 0; 2611 return 0;
2623 case TCSBRK: /* SVID version: non-zero arg --> no break */ 2612 case TCSBRK: /* SVID version: non-zero arg --> no break */
2624 /* 2613 /* non-zero arg means wait for all output data
2625 * XXX is the above comment correct, or the 2614 * to be sent (performed above) but don't send break.
2626 * code below correct? Is this ioctl used at 2615 * This is used by the tcdrain() termios function.
2627 * all by anyone?
2628 */ 2616 */
2629 if (!arg) 2617 if (!arg)
2630 return send_break(tty, 250); 2618 return send_break(tty, 250);
@@ -2776,8 +2764,7 @@ static void flush_to_ldisc(void *private_)
2776 struct tty_struct *tty = (struct tty_struct *) private_; 2764 struct tty_struct *tty = (struct tty_struct *) private_;
2777 unsigned long flags; 2765 unsigned long flags;
2778 struct tty_ldisc *disc; 2766 struct tty_ldisc *disc;
2779 struct tty_buffer *tbuf; 2767 struct tty_buffer *tbuf, *head;
2780 int count;
2781 char *char_buf; 2768 char *char_buf;
2782 unsigned char *flag_buf; 2769 unsigned char *flag_buf;
2783 2770
@@ -2785,32 +2772,37 @@ static void flush_to_ldisc(void *private_)
2785 if (disc == NULL) /* !TTY_LDISC */ 2772 if (disc == NULL) /* !TTY_LDISC */
2786 return; 2773 return;
2787 2774
2788 if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
2789 /*
2790 * Do it after the next timer tick:
2791 */
2792 schedule_delayed_work(&tty->buf.work, 1);
2793 goto out;
2794 }
2795 spin_lock_irqsave(&tty->buf.lock, flags); 2775 spin_lock_irqsave(&tty->buf.lock, flags);
2796 while((tbuf = tty->buf.head) != NULL) { 2776 head = tty->buf.head;
2797 while ((count = tbuf->commit - tbuf->read) != 0) { 2777 if (head != NULL) {
2798 char_buf = tbuf->char_buf_ptr + tbuf->read; 2778 tty->buf.head = NULL;
2799 flag_buf = tbuf->flag_buf_ptr + tbuf->read; 2779 for (;;) {
2800 tbuf->read += count; 2780 int count = head->commit - head->read;
2781 if (!count) {
2782 if (head->next == NULL)
2783 break;
2784 tbuf = head;
2785 head = head->next;
2786 tty_buffer_free(tty, tbuf);
2787 continue;
2788 }
2789 if (!tty->receive_room) {
2790 schedule_delayed_work(&tty->buf.work, 1);
2791 break;
2792 }
2793 if (count > tty->receive_room)
2794 count = tty->receive_room;
2795 char_buf = head->char_buf_ptr + head->read;
2796 flag_buf = head->flag_buf_ptr + head->read;
2797 head->read += count;
2801 spin_unlock_irqrestore(&tty->buf.lock, flags); 2798 spin_unlock_irqrestore(&tty->buf.lock, flags);
2802 disc->receive_buf(tty, char_buf, flag_buf, count); 2799 disc->receive_buf(tty, char_buf, flag_buf, count);
2803 spin_lock_irqsave(&tty->buf.lock, flags); 2800 spin_lock_irqsave(&tty->buf.lock, flags);
2804 } 2801 }
2805 if (tbuf->active) 2802 tty->buf.head = head;
2806 break;
2807 tty->buf.head = tbuf->next;
2808 if (tty->buf.head == NULL)
2809 tty->buf.tail = NULL;
2810 tty_buffer_free(tty, tbuf);
2811 } 2803 }
2812 spin_unlock_irqrestore(&tty->buf.lock, flags); 2804 spin_unlock_irqrestore(&tty->buf.lock, flags);
2813out: 2805
2814 tty_ldisc_deref(disc); 2806 tty_ldisc_deref(disc);
2815} 2807}
2816 2808
@@ -2903,10 +2895,8 @@ void tty_flip_buffer_push(struct tty_struct *tty)
2903{ 2895{
2904 unsigned long flags; 2896 unsigned long flags;
2905 spin_lock_irqsave(&tty->buf.lock, flags); 2897 spin_lock_irqsave(&tty->buf.lock, flags);
2906 if (tty->buf.tail != NULL) { 2898 if (tty->buf.tail != NULL)
2907 tty->buf.tail->active = 0;
2908 tty->buf.tail->commit = tty->buf.tail->used; 2899 tty->buf.tail->commit = tty->buf.tail->used;
2909 }
2910 spin_unlock_irqrestore(&tty->buf.lock, flags); 2900 spin_unlock_irqrestore(&tty->buf.lock, flags);
2911 2901
2912 if (tty->low_latency) 2902 if (tty->low_latency)
@@ -2964,8 +2954,8 @@ static struct class *tty_class;
2964 * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error). 2954 * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error).
2965 * 2955 *
2966 * This call is required to be made to register an individual tty device if 2956 * This call is required to be made to register an individual tty device if
2967 * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that 2957 * the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If that
2968 * bit is not set, this function should not be called. 2958 * bit is not set, this function should not be called by a tty driver.
2969 */ 2959 */
2970struct class_device *tty_register_device(struct tty_driver *driver, 2960struct class_device *tty_register_device(struct tty_driver *driver,
2971 unsigned index, struct device *device) 2961 unsigned index, struct device *device)
@@ -2979,9 +2969,6 @@ struct class_device *tty_register_device(struct tty_driver *driver,
2979 return ERR_PTR(-EINVAL); 2969 return ERR_PTR(-EINVAL);
2980 } 2970 }
2981 2971
2982 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
2983 "%s%d", driver->devfs_name, index + driver->name_base);
2984
2985 if (driver->type == TTY_DRIVER_TYPE_PTY) 2972 if (driver->type == TTY_DRIVER_TYPE_PTY)
2986 pty_line_name(driver, index, name); 2973 pty_line_name(driver, index, name);
2987 else 2974 else
@@ -3000,7 +2987,6 @@ struct class_device *tty_register_device(struct tty_driver *driver,
3000 */ 2987 */
3001void tty_unregister_device(struct tty_driver *driver, unsigned index) 2988void tty_unregister_device(struct tty_driver *driver, unsigned index)
3002{ 2989{
3003 devfs_remove("%s%d", driver->devfs_name, index + driver->name_base);
3004 class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); 2990 class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
3005} 2991}
3006 2992
@@ -3122,7 +3108,7 @@ int tty_register_driver(struct tty_driver *driver)
3122 3108
3123 list_add(&driver->tty_drivers, &tty_drivers); 3109 list_add(&driver->tty_drivers, &tty_drivers);
3124 3110
3125 if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) { 3111 if ( !(driver->flags & TTY_DRIVER_DYNAMIC_DEV) ) {
3126 for(i = 0; i < driver->num; i++) 3112 for(i = 0; i < driver->num; i++)
3127 tty_register_device(driver, i, NULL); 3113 tty_register_device(driver, i, NULL);
3128 } 3114 }
@@ -3165,7 +3151,7 @@ int tty_unregister_driver(struct tty_driver *driver)
3165 driver->termios_locked[i] = NULL; 3151 driver->termios_locked[i] = NULL;
3166 kfree(tp); 3152 kfree(tp);
3167 } 3153 }
3168 if (!(driver->flags & TTY_DRIVER_NO_DEVFS)) 3154 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV))
3169 tty_unregister_device(driver, i); 3155 tty_unregister_device(driver, i);
3170 } 3156 }
3171 p = driver->ttys; 3157 p = driver->ttys;
@@ -3241,14 +3227,12 @@ static int __init tty_init(void)
3241 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3227 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
3242 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 3228 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
3243 panic("Couldn't register /dev/tty driver\n"); 3229 panic("Couldn't register /dev/tty driver\n");
3244 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
3245 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); 3230 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
3246 3231
3247 cdev_init(&console_cdev, &console_fops); 3232 cdev_init(&console_cdev, &console_fops);
3248 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 3233 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
3249 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 3234 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
3250 panic("Couldn't register /dev/console driver\n"); 3235 panic("Couldn't register /dev/console driver\n");
3251 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
3252 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); 3236 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
3253 3237
3254#ifdef CONFIG_UNIX98_PTYS 3238#ifdef CONFIG_UNIX98_PTYS
@@ -3256,7 +3240,6 @@ static int __init tty_init(void)
3256 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || 3240 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
3257 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) 3241 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
3258 panic("Couldn't register /dev/ptmx driver\n"); 3242 panic("Couldn't register /dev/ptmx driver\n");
3259 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
3260 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); 3243 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
3261#endif 3244#endif
3262 3245
@@ -3265,7 +3248,6 @@ static int __init tty_init(void)
3265 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || 3248 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
3266 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 3249 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3267 panic("Couldn't register /dev/tty0 driver\n"); 3250 panic("Couldn't register /dev/tty0 driver\n");
3268 devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
3269 class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); 3251 class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
3270 3252
3271 vty_init(); 3253 vty_init();
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index 3c1dafaa3441..234d7f3fb114 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -26,7 +26,6 @@
26#include <linux/major.h> 26#include <linux/major.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/devfs_fs_kernel.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
31#include <linux/interrupt.h> 30#include <linux/interrupt.h>
32#include <linux/mm.h> 31#include <linux/mm.h>
@@ -478,12 +477,6 @@ static struct class *vc_class;
478 477
479void vcs_make_devfs(struct tty_struct *tty) 478void vcs_make_devfs(struct tty_struct *tty)
480{ 479{
481 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 1),
482 S_IFCHR|S_IRUSR|S_IWUSR,
483 "vcc/%u", tty->index + 1);
484 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
485 S_IFCHR|S_IRUSR|S_IWUSR,
486 "vcc/a%u", tty->index + 1);
487 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 480 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
488 NULL, "vcs%u", tty->index + 1); 481 NULL, "vcs%u", tty->index + 1);
489 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 482 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
@@ -491,8 +484,6 @@ void vcs_make_devfs(struct tty_struct *tty)
491} 484}
492void vcs_remove_devfs(struct tty_struct *tty) 485void vcs_remove_devfs(struct tty_struct *tty)
493{ 486{
494 devfs_remove("vcc/%u", tty->index + 1);
495 devfs_remove("vcc/a%u", tty->index + 1);
496 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1)); 487 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
497 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129)); 488 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
498} 489}
@@ -503,8 +494,6 @@ int __init vcs_init(void)
503 panic("unable to get major %d for vcs device", VCS_MAJOR); 494 panic("unable to get major %d for vcs device", VCS_MAJOR);
504 vc_class = class_create(THIS_MODULE, "vc"); 495 vc_class = class_create(THIS_MODULE, "vc");
505 496
506 devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
507 devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
508 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 497 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
509 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 498 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
510 return 0; 499 return 0;
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c
index 4e5360388748..07f5ce4b28e3 100644
--- a/drivers/char/viocons.c
+++ b/drivers/char/viocons.c
@@ -1152,7 +1152,6 @@ static int __init viocons_init2(void)
1152 viotty_driver = alloc_tty_driver(VTTY_PORTS); 1152 viotty_driver = alloc_tty_driver(VTTY_PORTS);
1153 viotty_driver->owner = THIS_MODULE; 1153 viotty_driver->owner = THIS_MODULE;
1154 viotty_driver->driver_name = "vioconsole"; 1154 viotty_driver->driver_name = "vioconsole";
1155 viotty_driver->devfs_name = "vcs/";
1156 viotty_driver->name = "tty"; 1155 viotty_driver->name = "tty";
1157 viotty_driver->name_base = 1; 1156 viotty_driver->name_base = 1;
1158 viotty_driver->major = TTY_MAJOR; 1157 viotty_driver->major = TTY_MAJOR;
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 11c7e9de5958..198f1505ae23 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -43,7 +43,6 @@
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/fs.h> 44#include <linux/fs.h>
45#include <linux/cdev.h> 45#include <linux/cdev.h>
46#include <linux/devfs_fs_kernel.h>
47#include <linux/major.h> 46#include <linux/major.h>
48#include <linux/completion.h> 47#include <linux/completion.h>
49#include <linux/proc_fs.h> 48#include <linux/proc_fs.h>
@@ -246,7 +245,6 @@ static struct device *tape_device[VIOTAPE_MAX_TAPE];
246 */ 245 */
247static struct { 246static struct {
248 unsigned char cur_part; 247 unsigned char cur_part;
249 int dev_handle;
250 unsigned char part_stat_rwi[MAX_PARTITIONS]; 248 unsigned char part_stat_rwi[MAX_PARTITIONS];
251} state[VIOTAPE_MAX_TAPE]; 249} state[VIOTAPE_MAX_TAPE];
252 250
@@ -959,12 +957,7 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
959 "iseries!vt%d", i); 957 "iseries!vt%d", i);
960 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 958 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
961 NULL, "iseries!nvt%d", i); 959 NULL, "iseries!nvt%d", i);
962 devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR,
963 "iseries/vt%d", i);
964 devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i | 0x80),
965 S_IFCHR | S_IRUSR | S_IWUSR, "iseries/nvt%d", i);
966 sprintf(tapename, "iseries/vt%d", i); 960 sprintf(tapename, "iseries/vt%d", i);
967 state[i].dev_handle = devfs_register_tape(tapename);
968 printk(VIOTAPE_KERN_INFO "tape %s is iSeries " 961 printk(VIOTAPE_KERN_INFO "tape %s is iSeries "
969 "resource %10.10s type %4.4s, model %3.3s\n", 962 "resource %10.10s type %4.4s, model %3.3s\n",
970 tapename, viotape_unitinfo[i].rsrcname, 963 tapename, viotape_unitinfo[i].rsrcname,
@@ -976,9 +969,6 @@ static int viotape_remove(struct vio_dev *vdev)
976{ 969{
977 int i = vdev->unit_address; 970 int i = vdev->unit_address;
978 971
979 devfs_remove("iseries/nvt%d", i);
980 devfs_remove("iseries/vt%d", i);
981 devfs_unregister_tape(state[i].dev_handle);
982 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80)); 972 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80));
983 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i)); 973 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i));
984 return 0; 974 return 0;
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index fd00822ac145..fe99fc1aba45 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -147,7 +147,6 @@ static int scc_init_drivers(void)
147 scc_driver->owner = THIS_MODULE; 147 scc_driver->owner = THIS_MODULE;
148 scc_driver->driver_name = "scc"; 148 scc_driver->driver_name = "scc";
149 scc_driver->name = "ttyS"; 149 scc_driver->name = "ttyS";
150 scc_driver->devfs_name = "tts/";
151 scc_driver->major = TTY_MAJOR; 150 scc_driver->major = TTY_MAJOR;
152 scc_driver->minor_start = SCC_MINOR_BASE; 151 scc_driver->minor_start = SCC_MINOR_BASE;
153 scc_driver->type = TTY_DRIVER_TYPE_SERIAL; 152 scc_driver->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 05e6e814d86f..073da48c092e 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -689,9 +689,9 @@ static int __devinit giu_probe(struct platform_device *dev)
689 689
690 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) { 690 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) {
691 if (i < GIU_IRQ(GIUINT_HIGH_OFFSET)) 691 if (i < GIU_IRQ(GIUINT_HIGH_OFFSET))
692 irq_desc[i].handler = &giuint_low_irq_type; 692 irq_desc[i].chip = &giuint_low_irq_type;
693 else 693 else
694 irq_desc[i].handler = &giuint_high_irq_type; 694 irq_desc[i].chip = &giuint_high_irq_type;
695 } 695 }
696 696
697 return cascade_irq(GIUINT_IRQ, giu_get_irq); 697 return cascade_irq(GIUINT_IRQ, giu_get_irq);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 714d95ff2f1e..d6f65032649a 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -79,7 +79,6 @@
79#include <linux/mm.h> 79#include <linux/mm.h>
80#include <linux/console.h> 80#include <linux/console.h>
81#include <linux/init.h> 81#include <linux/init.h>
82#include <linux/devfs_fs_kernel.h>
83#include <linux/vt_kern.h> 82#include <linux/vt_kern.h>
84#include <linux/selection.h> 83#include <linux/selection.h>
85#include <linux/tiocl.h> 84#include <linux/tiocl.h>
@@ -2663,7 +2662,6 @@ int __init vty_init(void)
2663 if (!console_driver) 2662 if (!console_driver)
2664 panic("Couldn't allocate console driver\n"); 2663 panic("Couldn't allocate console driver\n");
2665 console_driver->owner = THIS_MODULE; 2664 console_driver->owner = THIS_MODULE;
2666 console_driver->devfs_name = "vc/";
2667 console_driver->name = "tty"; 2665 console_driver->name = "tty";
2668 console_driver->name_base = 1; 2666 console_driver->name_base = 1;
2669 console_driver->major = TTY_MAJOR; 2667 console_driver->major = TTY_MAJOR;
diff --git a/drivers/char/watchdog/at91_wdt.c b/drivers/char/watchdog/at91_wdt.c
index ac83bc4b019a..00080655533d 100644
--- a/drivers/char/watchdog/at91_wdt.c
+++ b/drivers/char/watchdog/at91_wdt.c
@@ -17,14 +17,15 @@
17#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20#include <linux/platform_device.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/watchdog.h> 22#include <linux/watchdog.h>
22#include <asm/bitops.h> 23#include <asm/bitops.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
25 26
26#define WDT_DEFAULT_TIME 5 /* 5 seconds */ 27#define WDT_DEFAULT_TIME 5 /* seconds */
27#define WDT_MAX_TIME 256 /* 256 seconds */ 28#define WDT_MAX_TIME 256 /* seconds */
28 29
29static int wdt_time = WDT_DEFAULT_TIME; 30static int wdt_time = WDT_DEFAULT_TIME;
30static int nowayout = WATCHDOG_NOWAYOUT; 31static int nowayout = WATCHDOG_NOWAYOUT;
@@ -32,8 +33,10 @@ static int nowayout = WATCHDOG_NOWAYOUT;
32module_param(wdt_time, int, 0); 33module_param(wdt_time, int, 0);
33MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")"); 34MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")");
34 35
36#ifdef CONFIG_WATCHDOG_NOWAYOUT
35module_param(nowayout, int, 0); 37module_param(nowayout, int, 0);
36MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
39#endif
37 40
38 41
39static unsigned long at91wdt_busy; 42static unsigned long at91wdt_busy;
@@ -138,7 +141,7 @@ static int at91_wdt_ioctl(struct inode *inode, struct file *file,
138 case WDIOC_SETTIMEOUT: 141 case WDIOC_SETTIMEOUT:
139 if (get_user(new_value, p)) 142 if (get_user(new_value, p))
140 return -EFAULT; 143 return -EFAULT;
141 144
142 if (at91_wdt_settimeout(new_value)) 145 if (at91_wdt_settimeout(new_value))
143 return -EINVAL; 146 return -EINVAL;
144 147
@@ -196,27 +199,84 @@ static struct miscdevice at91wdt_miscdev = {
196 .fops = &at91wdt_fops, 199 .fops = &at91wdt_fops,
197}; 200};
198 201
199static int __init at91_wdt_init(void) 202static int __init at91wdt_probe(struct platform_device *pdev)
200{ 203{
201 int res; 204 int res;
202 205
203 /* Check that the heartbeat value is within range; if not reset to the default */ 206 if (at91wdt_miscdev.dev)
204 if (at91_wdt_settimeout(wdt_time)) { 207 return -EBUSY;
205 at91_wdt_settimeout(WDT_DEFAULT_TIME); 208 at91wdt_miscdev.dev = &pdev->dev;
206 printk(KERN_INFO "at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
207 }
208 209
209 res = misc_register(&at91wdt_miscdev); 210 res = misc_register(&at91wdt_miscdev);
210 if (res) 211 if (res)
211 return res; 212 return res;
212 213
213 printk("AT91 Watchdog Timer enabled (%d seconds, nowayout=%d)\n", wdt_time, nowayout); 214 printk("AT91 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : "");
214 return 0; 215 return 0;
215} 216}
216 217
218static int __exit at91wdt_remove(struct platform_device *pdev)
219{
220 int res;
221
222 res = misc_deregister(&at91wdt_miscdev);
223 if (!res)
224 at91wdt_miscdev.dev = NULL;
225
226 return res;
227}
228
229static void at91wdt_shutdown(struct platform_device *pdev)
230{
231 at91_wdt_stop();
232}
233
234#ifdef CONFIG_PM
235
236static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
237{
238 at91_wdt_stop();
239 return 0;
240}
241
242static int at91wdt_resume(struct platform_device *pdev)
243{
244 if (at91wdt_busy)
245 at91_wdt_start();
246 return 0;
247}
248
249#else
250#define at91wdt_suspend NULL
251#define at91wdt_resume NULL
252#endif
253
254static struct platform_driver at91wdt_driver = {
255 .probe = at91wdt_probe,
256 .remove = __exit_p(at91wdt_remove),
257 .shutdown = at91wdt_shutdown,
258 .suspend = at91wdt_suspend,
259 .resume = at91wdt_resume,
260 .driver = {
261 .name = "at91_wdt",
262 .owner = THIS_MODULE,
263 },
264};
265
266static int __init at91_wdt_init(void)
267{
268 /* Check that the heartbeat value is within range; if not reset to the default */
269 if (at91_wdt_settimeout(wdt_time)) {
270 at91_wdt_settimeout(WDT_DEFAULT_TIME);
271 pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
272 }
273
274 return platform_driver_register(&at91wdt_driver);
275}
276
217static void __exit at91_wdt_exit(void) 277static void __exit at91_wdt_exit(void)
218{ 278{
219 misc_deregister(&at91wdt_miscdev); 279 platform_driver_unregister(&at91wdt_driver);
220} 280}
221 281
222module_init(at91_wdt_init); 282module_init(at91_wdt_init);
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
index fa2ba9ebe42a..bfbdbbf3c2f2 100644
--- a/drivers/char/watchdog/i8xx_tco.c
+++ b/drivers/char/watchdog/i8xx_tco.c
@@ -205,6 +205,23 @@ static int tco_timer_set_heartbeat (int t)
205 return 0; 205 return 0;
206} 206}
207 207
208static int tco_timer_get_timeleft (int *time_left)
209{
210 unsigned char val;
211
212 spin_lock(&tco_lock);
213
214 /* read the TCO Timer */
215 val = inb (TCO1_RLD);
216 val &= 0x3f;
217
218 spin_unlock(&tco_lock);
219
220 *time_left = (int)((val * 6) / 10);
221
222 return 0;
223}
224
208/* 225/*
209 * /dev/watchdog handling 226 * /dev/watchdog handling
210 */ 227 */
@@ -272,6 +289,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
272{ 289{
273 int new_options, retval = -EINVAL; 290 int new_options, retval = -EINVAL;
274 int new_heartbeat; 291 int new_heartbeat;
292 int time_left;
275 void __user *argp = (void __user *)arg; 293 void __user *argp = (void __user *)arg;
276 int __user *p = argp; 294 int __user *p = argp;
277 static struct watchdog_info ident = { 295 static struct watchdog_info ident = {
@@ -320,7 +338,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
320 return -EFAULT; 338 return -EFAULT;
321 339
322 if (tco_timer_set_heartbeat(new_heartbeat)) 340 if (tco_timer_set_heartbeat(new_heartbeat))
323 return -EINVAL; 341 return -EINVAL;
324 342
325 tco_timer_keepalive (); 343 tco_timer_keepalive ();
326 /* Fall */ 344 /* Fall */
@@ -329,6 +347,14 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
329 case WDIOC_GETTIMEOUT: 347 case WDIOC_GETTIMEOUT:
330 return put_user(heartbeat, p); 348 return put_user(heartbeat, p);
331 349
350 case WDIOC_GETTIMELEFT:
351 {
352 if (tco_timer_get_timeleft(&time_left))
353 return -EINVAL;
354
355 return put_user(time_left, p);
356 }
357
332 default: 358 default:
333 return -ENOIOCTLCMD; 359 return -ENOIOCTLCMD;
334 } 360 }
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index 2451edbefece..1f40ecefbf72 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -21,7 +21,7 @@
21 */ 21 */
22 22
23/* 23/*
24 * A bells and whistles driver is available from: 24 * A bells and whistles driver is available from:
25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ 25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/
26 * 26 *
27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ 27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/
@@ -390,6 +390,24 @@ static int pcipcwd_get_temperature(int *temperature)
390 return 0; 390 return 0;
391} 391}
392 392
393static int pcipcwd_get_timeleft(int *time_left)
394{
395 int msb;
396 int lsb;
397
398 /* Read the time that's left before rebooting */
399 /* Note: if the board is not yet armed then we will read 0xFFFF */
400 send_command(CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb);
401
402 *time_left = (msb << 8) + lsb;
403
404 if (debug >= VERBOSE)
405 printk(KERN_DEBUG PFX "Time left before next reboot: %d\n",
406 *time_left);
407
408 return 0;
409}
410
393/* 411/*
394 * /dev/watchdog handling 412 * /dev/watchdog handling
395 */ 413 */
@@ -512,6 +530,16 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file,
512 case WDIOC_GETTIMEOUT: 530 case WDIOC_GETTIMEOUT:
513 return put_user(heartbeat, p); 531 return put_user(heartbeat, p);
514 532
533 case WDIOC_GETTIMELEFT:
534 {
535 int time_left;
536
537 if (pcipcwd_get_timeleft(&time_left))
538 return -EFAULT;
539
540 return put_user(time_left, p);
541 }
542
515 default: 543 default:
516 return -ENOIOCTLCMD; 544 return -ENOIOCTLCMD;
517 } 545 }
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 3fdfda9324fa..0d072bed501d 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -317,6 +317,19 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp
317 return 0; 317 return 0;
318} 318}
319 319
320static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_left)
321{
322 unsigned char msb, lsb;
323
324 /* Read the time that's left before rebooting */
325 /* Note: if the board is not yet armed then we will read 0xFFFF */
326 usb_pcwd_send_command(usb_pcwd, CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb);
327
328 *time_left = (msb << 8) + lsb;
329
330 return 0;
331}
332
320/* 333/*
321 * /dev/watchdog handling 334 * /dev/watchdog handling
322 */ 335 */
@@ -422,6 +435,16 @@ static int usb_pcwd_ioctl(struct inode *inode, struct file *file,
422 case WDIOC_GETTIMEOUT: 435 case WDIOC_GETTIMEOUT:
423 return put_user(heartbeat, p); 436 return put_user(heartbeat, p);
424 437
438 case WDIOC_GETTIMELEFT:
439 {
440 int time_left;
441
442 if (usb_pcwd_get_timeleft(usb_pcwd_device, &time_left))
443 return -EFAULT;
444
445 return put_user(time_left, p);
446 }
447
425 default: 448 default:
426 return -ENOIOCTLCMD; 449 return -ENOIOCTLCMD;
427 } 450 }
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 44d1eca83a72..35e0b9ceecf7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1497,6 +1497,7 @@ int cpufreq_update_policy(unsigned int cpu)
1497} 1497}
1498EXPORT_SYMBOL(cpufreq_update_policy); 1498EXPORT_SYMBOL(cpufreq_update_policy);
1499 1499
1500#ifdef CONFIG_HOTPLUG_CPU
1500static int cpufreq_cpu_callback(struct notifier_block *nfb, 1501static int cpufreq_cpu_callback(struct notifier_block *nfb,
1501 unsigned long action, void *hcpu) 1502 unsigned long action, void *hcpu)
1502{ 1503{
@@ -1532,10 +1533,11 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
1532 return NOTIFY_OK; 1533 return NOTIFY_OK;
1533} 1534}
1534 1535
1535static struct notifier_block cpufreq_cpu_notifier = 1536static struct notifier_block __cpuinitdata cpufreq_cpu_notifier =
1536{ 1537{
1537 .notifier_call = cpufreq_cpu_callback, 1538 .notifier_call = cpufreq_cpu_callback,
1538}; 1539};
1540#endif /* CONFIG_HOTPLUG_CPU */
1539 1541
1540/********************************************************************* 1542/*********************************************************************
1541 * REGISTER / UNREGISTER CPUFREQ DRIVER * 1543 * REGISTER / UNREGISTER CPUFREQ DRIVER *
@@ -1596,7 +1598,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1596 } 1598 }
1597 1599
1598 if (!ret) { 1600 if (!ret) {
1599 register_cpu_notifier(&cpufreq_cpu_notifier); 1601 register_hotcpu_notifier(&cpufreq_cpu_notifier);
1600 dprintk("driver %s up and running\n", driver_data->name); 1602 dprintk("driver %s up and running\n", driver_data->name);
1601 cpufreq_debug_enable_ratelimit(); 1603 cpufreq_debug_enable_ratelimit();
1602 } 1604 }
@@ -1628,7 +1630,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
1628 dprintk("unregistering driver %s\n", driver->name); 1630 dprintk("unregistering driver %s\n", driver->name);
1629 1631
1630 sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); 1632 sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver);
1631 unregister_cpu_notifier(&cpufreq_cpu_notifier); 1633 unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
1632 1634
1633 spin_lock_irqsave(&cpufreq_driver_lock, flags); 1635 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1634 cpufreq_driver = NULL; 1636 cpufreq_driver = NULL;
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index c576c0b3f452..145061b8472a 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -350,7 +350,7 @@ __init cpufreq_stats_init(void)
350 return ret; 350 return ret;
351 } 351 }
352 352
353 register_cpu_notifier(&cpufreq_stat_cpu_notifier); 353 register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
354 lock_cpu_hotplug(); 354 lock_cpu_hotplug();
355 for_each_online_cpu(cpu) { 355 for_each_online_cpu(cpu) {
356 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE, 356 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE,
@@ -368,7 +368,7 @@ __exit cpufreq_stats_exit(void)
368 CPUFREQ_POLICY_NOTIFIER); 368 CPUFREQ_POLICY_NOTIFIER);
369 cpufreq_unregister_notifier(&notifier_trans_block, 369 cpufreq_unregister_notifier(&notifier_trans_block,
370 CPUFREQ_TRANSITION_NOTIFIER); 370 CPUFREQ_TRANSITION_NOTIFIER);
371 unregister_cpu_notifier(&cpufreq_stat_cpu_notifier); 371 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
372 lock_cpu_hotplug(); 372 lock_cpu_hotplug();
373 for_each_online_cpu(cpu) { 373 for_each_online_cpu(cpu) {
374 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD, 374 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD,
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 3e0d04d5a800..8b46ef7d9ff8 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -488,7 +488,7 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
488 dev_err(&dev->dev, "SMBus base address uninitialized, " 488 dev_err(&dev->dev, "SMBus base address uninitialized, "
489 "upgrade BIOS\n"); 489 "upgrade BIOS\n");
490 err = -ENODEV; 490 err = -ENODEV;
491 goto exit_disable; 491 goto exit;
492 } 492 }
493 493
494 err = pci_request_region(dev, SMBBAR, i801_driver.name); 494 err = pci_request_region(dev, SMBBAR, i801_driver.name);
@@ -496,7 +496,7 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
496 dev_err(&dev->dev, "Failed to request SMBus region " 496 dev_err(&dev->dev, "Failed to request SMBus region "
497 "0x%lx-0x%lx\n", i801_smba, 497 "0x%lx-0x%lx\n", i801_smba,
498 pci_resource_end(dev, SMBBAR)); 498 pci_resource_end(dev, SMBBAR));
499 goto exit_disable; 499 goto exit;
500 } 500 }
501 501
502 pci_read_config_byte(I801_dev, SMBHSTCFG, &temp); 502 pci_read_config_byte(I801_dev, SMBHSTCFG, &temp);
@@ -520,11 +520,12 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
520 err = i2c_add_adapter(&i801_adapter); 520 err = i2c_add_adapter(&i801_adapter);
521 if (err) { 521 if (err) {
522 dev_err(&dev->dev, "Failed to add SMBus adapter\n"); 522 dev_err(&dev->dev, "Failed to add SMBus adapter\n");
523 goto exit_disable; 523 goto exit_release;
524 } 524 }
525 return 0;
525 526
526exit_disable: 527exit_release:
527 pci_disable_device(dev); 528 pci_release_region(dev, SMBBAR);
528exit: 529exit:
529 return err; 530 return err;
530} 531}
@@ -533,7 +534,10 @@ static void __devexit i801_remove(struct pci_dev *dev)
533{ 534{
534 i2c_del_adapter(&i801_adapter); 535 i2c_del_adapter(&i801_adapter);
535 pci_release_region(dev, SMBBAR); 536 pci_release_region(dev, SMBBAR);
536 pci_disable_device(dev); 537 /*
538 * do not call pci_disable_device(dev) since it can cause hard hangs on
539 * some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010)
540 */
537} 541}
538 542
539static struct pci_driver i801_driver = { 543static struct pci_driver i801_driver = {
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index d633081fa4c5..d1266fe2d1ab 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -774,11 +774,18 @@ config BLK_DEV_IDEDMA_PMAC
774 performance. 774 performance.
775 775
776config BLK_DEV_IDE_PMAC_BLINK 776config BLK_DEV_IDE_PMAC_BLINK
777 bool "Blink laptop LED on drive activity" 777 bool "Blink laptop LED on drive activity (DEPRECATED)"
778 depends on BLK_DEV_IDE_PMAC && ADB_PMU 778 depends on BLK_DEV_IDE_PMAC && ADB_PMU
779 select ADB_PMU_LED
780 select LEDS_TRIGGERS
781 select LEDS_TRIGGER_IDE_DISK
779 help 782 help
780 This option enables the use of the sleep LED as a hard drive 783 This option enables the use of the sleep LED as a hard drive
781 activity LED. 784 activity LED.
785 This option is deprecated, it only selects ADB_PMU_LED and
786 LEDS_TRIGGER_IDE_DISK and changes the code in the new led class
787 device to default to the ide-disk trigger (which should be set
788 from userspace via sysfs).
782 789
783config BLK_DEV_IDE_SWARM 790config BLK_DEV_IDE_SWARM
784 tristate "IDE for Sibyte evaluation boards" 791 tristate "IDE for Sibyte evaluation boards"
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 99fa42402e71..bfafd4846a08 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3527,8 +3527,6 @@ static int ide_cd_probe(ide_drive_t *drive)
3527 drive->driver_data = info; 3527 drive->driver_data = info;
3528 3528
3529 g->minors = 1; 3529 g->minors = 1;
3530 snprintf(g->devfs_name, sizeof(g->devfs_name),
3531 "%s/cd", drive->devfs_name);
3532 g->driverfs_dev = &drive->gendev; 3530 g->driverfs_dev = &drive->gendev;
3533 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; 3531 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
3534 if (ide_cdrom_setup(drive)) { 3532 if (ide_cdrom_setup(drive)) {
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index f033d732f387..d0227c39ced1 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1018,7 +1018,6 @@ static void ide_disk_release(struct kref *kref)
1018 struct gendisk *g = idkp->disk; 1018 struct gendisk *g = idkp->disk;
1019 1019
1020 drive->driver_data = NULL; 1020 drive->driver_data = NULL;
1021 drive->devfs_name[0] = '\0';
1022 g->private_data = NULL; 1021 g->private_data = NULL;
1023 put_disk(g); 1022 put_disk(g);
1024 kfree(idkp); 1023 kfree(idkp);
@@ -1222,7 +1221,6 @@ static int ide_disk_probe(ide_drive_t *drive)
1222 drive->attach = 1; 1221 drive->attach = 1;
1223 1222
1224 g->minors = 1 << PARTN_BITS; 1223 g->minors = 1 << PARTN_BITS;
1225 strcpy(g->devfs_name, drive->devfs_name);
1226 g->driverfs_dev = &drive->gendev; 1224 g->driverfs_dev = &drive->gendev;
1227 g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0; 1225 g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
1228 set_capacity(g, idedisk_capacity(drive)); 1226 set_capacity(g, idedisk_capacity(drive));
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 4656587aa2f7..68628327c0f5 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -2176,7 +2176,6 @@ static int ide_floppy_probe(ide_drive_t *drive)
2176 2176
2177 g->minors = 1 << PARTN_BITS; 2177 g->minors = 1 << PARTN_BITS;
2178 g->driverfs_dev = &drive->gendev; 2178 g->driverfs_dev = &drive->gendev;
2179 strcpy(g->devfs_name, drive->devfs_name);
2180 g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0; 2179 g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
2181 g->fops = &idefloppy_ops; 2180 g->fops = &idefloppy_ops;
2182 drive->attach = 1; 2181 drive->attach = 1;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 935cb2583770..26ceab1e90bb 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -505,7 +505,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
505 } 505 }
506 } 506 }
507 507
508 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ) 508 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && hwif->err_stops_fifo == 0)
509 try_to_flush_leftover_data(drive); 509 try_to_flush_leftover_data(drive);
510 510
511 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 511 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 97a49e77a8f1..32117f0ec5c0 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -597,6 +597,10 @@ u8 eighty_ninty_three (ide_drive_t *drive)
597{ 597{
598 if(HWIF(drive)->udma_four == 0) 598 if(HWIF(drive)->udma_four == 0)
599 return 0; 599 return 0;
600
601 /* Check for SATA but only if we are ATA5 or higher */
602 if (drive->id->hw_config == 0 && (drive->id->major_rev_num & 0x7FE0))
603 return 1;
600 if (!(drive->id->hw_config & 0x6000)) 604 if (!(drive->id->hw_config & 0x6000))
601 return 0; 605 return 0;
602#ifndef CONFIG_IDEDMA_IVB 606#ifndef CONFIG_IDEDMA_IVB
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 9ebf8ae2a5e3..0d5038a28560 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -47,7 +47,6 @@
47#include <linux/slab.h> 47#include <linux/slab.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/ide.h> 49#include <linux/ide.h>
50#include <linux/devfs_fs_kernel.h>
51#include <linux/spinlock.h> 50#include <linux/spinlock.h>
52#include <linux/kmod.h> 51#include <linux/kmod.h>
53#include <linux/pci.h> 52#include <linux/pci.h>
@@ -1279,10 +1278,6 @@ static void drive_release_dev (struct device *dev)
1279 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); 1278 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
1280 1279
1281 spin_lock_irq(&ide_lock); 1280 spin_lock_irq(&ide_lock);
1282 if (drive->devfs_name[0] != '\0') {
1283 devfs_remove(drive->devfs_name);
1284 drive->devfs_name[0] = '\0';
1285 }
1286 ide_remove_drive_from_hwgroup(drive); 1281 ide_remove_drive_from_hwgroup(drive);
1287 kfree(drive->id); 1282 kfree(drive->id);
1288 drive->id = NULL; 1283 drive->id = NULL;
@@ -1316,12 +1311,6 @@ static void init_gendisk (ide_hwif_t *hwif)
1316 drive->gendev.bus = &ide_bus_type; 1311 drive->gendev.bus = &ide_bus_type;
1317 drive->gendev.driver_data = drive; 1312 drive->gendev.driver_data = drive;
1318 drive->gendev.release = drive_release_dev; 1313 drive->gendev.release = drive_release_dev;
1319 if (drive->present) {
1320 sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d",
1321 (hwif->channel && hwif->mate) ?
1322 hwif->mate->index : hwif->index,
1323 hwif->channel, unit, drive->lun);
1324 }
1325 } 1314 }
1326 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, 1315 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS,
1327 THIS_MODULE, ata_probe, ata_lock, hwif); 1316 THIS_MODULE, ata_probe, ata_lock, hwif);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 09f3a7dab28a..4b91101e12b7 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -435,7 +435,6 @@
435#include <linux/interrupt.h> 435#include <linux/interrupt.h>
436#include <linux/jiffies.h> 436#include <linux/jiffies.h>
437#include <linux/major.h> 437#include <linux/major.h>
438#include <linux/devfs_fs_kernel.h>
439#include <linux/errno.h> 438#include <linux/errno.h>
440#include <linux/genhd.h> 439#include <linux/genhd.h>
441#include <linux/slab.h> 440#include <linux/slab.h>
@@ -4726,9 +4725,6 @@ static void ide_tape_release(struct kref *kref)
4726 MKDEV(IDETAPE_MAJOR, tape->minor)); 4725 MKDEV(IDETAPE_MAJOR, tape->minor));
4727 class_device_destroy(idetape_sysfs_class, 4726 class_device_destroy(idetape_sysfs_class,
4728 MKDEV(IDETAPE_MAJOR, tape->minor + 128)); 4727 MKDEV(IDETAPE_MAJOR, tape->minor + 128));
4729 devfs_remove("%s/mt", drive->devfs_name);
4730 devfs_remove("%s/mtn", drive->devfs_name);
4731 devfs_unregister_tape(g->number);
4732 idetape_devs[tape->minor] = NULL; 4728 idetape_devs[tape->minor] = NULL;
4733 g->private_data = NULL; 4729 g->private_data = NULL;
4734 put_disk(g); 4730 put_disk(g);
@@ -4902,14 +4898,6 @@ static int ide_tape_probe(ide_drive_t *drive)
4902 class_device_create(idetape_sysfs_class, NULL, 4898 class_device_create(idetape_sysfs_class, NULL,
4903 MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name); 4899 MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name);
4904 4900
4905 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
4906 S_IFCHR | S_IRUGO | S_IWUGO,
4907 "%s/mt", drive->devfs_name);
4908 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor + 128),
4909 S_IFCHR | S_IRUGO | S_IWUGO,
4910 "%s/mtn", drive->devfs_name);
4911
4912 g->number = devfs_register_tape(drive->devfs_name);
4913 g->fops = &idetape_block_ops; 4901 g->fops = &idetape_block_ops;
4914 ide_register_region(g); 4902 ide_register_region(g);
4915 4903
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 59fe358048b3..1cdf44205162 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -147,7 +147,6 @@
147#include <linux/pci.h> 147#include <linux/pci.h>
148#include <linux/delay.h> 148#include <linux/delay.h>
149#include <linux/ide.h> 149#include <linux/ide.h>
150#include <linux/devfs_fs_kernel.h>
151#include <linux/completion.h> 150#include <linux/completion.h>
152#include <linux/reboot.h> 151#include <linux/reboot.h>
153#include <linux/cdrom.h> 152#include <linux/cdrom.h>
@@ -592,13 +591,8 @@ void ide_unregister(unsigned int index)
592 goto abort; 591 goto abort;
593 for (unit = 0; unit < MAX_DRIVES; ++unit) { 592 for (unit = 0; unit < MAX_DRIVES; ++unit) {
594 drive = &hwif->drives[unit]; 593 drive = &hwif->drives[unit];
595 if (!drive->present) { 594 if (!drive->present)
596 if (drive->devfs_name[0] != '\0') {
597 devfs_remove(drive->devfs_name);
598 drive->devfs_name[0] = '\0';
599 }
600 continue; 595 continue;
601 }
602 spin_unlock_irq(&ide_lock); 596 spin_unlock_irq(&ide_lock);
603 device_unregister(&drive->gendev); 597 device_unregister(&drive->gendev);
604 wait_for_completion(&drive->gendev_rel_comp); 598 wait_for_completion(&drive->gendev_rel_comp);
@@ -1996,7 +1990,6 @@ EXPORT_SYMBOL_GPL(ide_bus_type);
1996static int __init ide_init(void) 1990static int __init ide_init(void)
1997{ 1991{
1998 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); 1992 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n");
1999 devfs_mk_dir("ide");
2000 system_bus_speed = ide_system_bus_speed(); 1993 system_bus_speed = ide_system_bus_speed();
2001 1994
2002 bus_register(&ide_bus_type); 1995 bus_register(&ide_bus_type);
@@ -2074,7 +2067,6 @@ void cleanup_module (void)
2074#ifdef CONFIG_PROC_FS 2067#ifdef CONFIG_PROC_FS
2075 proc_ide_destroy(); 2068 proc_ide_destroy();
2076#endif 2069#endif
2077 devfs_remove("ide");
2078 2070
2079 bus_unregister(&ide_bus_type); 2071 bus_unregister(&ide_bus_type);
2080} 2072}
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index c743e68c33aa..3edd7060510f 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -22,7 +22,7 @@ struct chipset_bus_clock_list_entry {
22 u8 ultra_settings; 22 u8 ultra_settings;
23}; 23};
24 24
25static struct chipset_bus_clock_list_entry aec6xxx_33_base [] = { 25static const struct chipset_bus_clock_list_entry aec6xxx_33_base [] = {
26 { XFER_UDMA_6, 0x31, 0x07 }, 26 { XFER_UDMA_6, 0x31, 0x07 },
27 { XFER_UDMA_5, 0x31, 0x06 }, 27 { XFER_UDMA_5, 0x31, 0x06 },
28 { XFER_UDMA_4, 0x31, 0x05 }, 28 { XFER_UDMA_4, 0x31, 0x05 },
@@ -42,7 +42,7 @@ static struct chipset_bus_clock_list_entry aec6xxx_33_base [] = {
42 { 0, 0x00, 0x00 } 42 { 0, 0x00, 0x00 }
43}; 43};
44 44
45static struct chipset_bus_clock_list_entry aec6xxx_34_base [] = { 45static const struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
46 { XFER_UDMA_6, 0x41, 0x06 }, 46 { XFER_UDMA_6, 0x41, 0x06 },
47 { XFER_UDMA_5, 0x41, 0x05 }, 47 { XFER_UDMA_5, 0x41, 0x05 },
48 { XFER_UDMA_4, 0x41, 0x04 }, 48 { XFER_UDMA_4, 0x41, 0x04 },
@@ -254,7 +254,8 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
254 254
255 if (dev->resource[PCI_ROM_RESOURCE].start) { 255 if (dev->resource[PCI_ROM_RESOURCE].start) {
256 pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 256 pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
257 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start); 257 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name,
258 (unsigned long)dev->resource[PCI_ROM_RESOURCE].start);
258 } 259 }
259 260
260 if (bus_speed <= 33) 261 if (bus_speed <= 33)
@@ -425,12 +426,12 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi
425 return d->init_setup(dev, d); 426 return d->init_setup(dev, d);
426} 427}
427 428
428static struct pci_device_id aec62xx_pci_tbl[] = { 429static const struct pci_device_id aec62xx_pci_tbl[] = {
429 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 430 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 },
430 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 431 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 },
431 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860R, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 432 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860R), 2 },
432 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, 433 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865), 3 },
433 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865R, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 434 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865R), 4 },
434 { 0, }, 435 { 0, },
435}; 436};
436MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl); 437MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl);
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 6e9dbf4d8077..85007cb12c52 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -75,6 +75,7 @@ static struct amd_ide_chip {
75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, AMD_UDMA_133 }, 75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, AMD_UDMA_133 },
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 }, 76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 },
77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 }, 77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 }, 79 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 },
79 { 0 } 80 { 0 }
80}; 81};
@@ -490,7 +491,8 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
490 /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"), 491 /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"),
491 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"), 492 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"),
492 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 493 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"),
493 /* 18 */ DECLARE_AMD_DEV("AMD5536"), 494 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"),
495 /* 19 */ DECLARE_AMD_DEV("AMD5536"),
494}; 496};
495 497
496static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 498static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -528,7 +530,8 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
528 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, 530 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 },
529 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, 531 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 },
530 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 532 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 },
531 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 533 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 },
534 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 },
532 { 0, }, 535 { 0, },
533}; 536};
534MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 537MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 3d9c7afc8695..92b7b1549b16 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -190,14 +190,6 @@ static int cmd64x_get_info (char *buffer, char **addr, off_t offset, int count)
190#endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */ 190#endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */
191 191
192/* 192/*
193 * Registers and masks for easy access by drive index:
194 */
195#if 0
196static u8 prefetch_regs[4] = {CNTRL, CNTRL, ARTTIM23, ARTTIM23};
197static u8 prefetch_masks[4] = {CNTRL_DIS_RA0, CNTRL_DIS_RA1, ARTTIM23_DIS_RA2, ARTTIM23_DIS_RA3};
198#endif
199
200/*
201 * This routine writes the prepared setup/active/recovery counts 193 * This routine writes the prepared setup/active/recovery counts
202 * for a drive into the cmd646 chipset registers to active them. 194 * for a drive into the cmd646 chipset registers to active them.
203 */ 195 */
@@ -606,13 +598,6 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
606 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 598 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
607 class_rev &= 0xff; 599 class_rev &= 0xff;
608 600
609#ifdef __i386__
610 if (dev->resource[PCI_ROM_RESOURCE].start) {
611 pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
612 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
613 }
614#endif
615
616 switch(dev->device) { 601 switch(dev->device) {
617 case PCI_DEVICE_ID_CMD_643: 602 case PCI_DEVICE_ID_CMD_643:
618 break; 603 break;
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index be334da7a754..7da550281cf2 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -176,7 +176,7 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha
176 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 176 pci_write_config_dword(dev, PCI_ROM_ADDRESS,
177 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 177 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
178 printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n", 178 printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n",
179 dev->resource[PCI_ROM_RESOURCE].start); 179 (unsigned long)dev->resource[PCI_ROM_RESOURCE].start);
180 } 180 }
181 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0); 181 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
182 } else { 182 } else {
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index acd63173199b..5a8334d134fb 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -313,8 +313,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
313 if (dev->resource[PCI_ROM_RESOURCE].start) { 313 if (dev->resource[PCI_ROM_RESOURCE].start) {
314 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 314 pci_write_config_dword(dev, PCI_ROM_ADDRESS,
315 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 315 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
316 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", 316 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name,
317 name, dev->resource[PCI_ROM_RESOURCE].start); 317 (unsigned long)dev->resource[PCI_ROM_RESOURCE].start);
318 } 318 }
319 319
320#ifdef CONFIG_PPC_PMAC 320#ifdef CONFIG_PPC_PMAC
@@ -338,6 +338,8 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
338 hwif->ultra_mask = 0x7f; 338 hwif->ultra_mask = 0x7f;
339 hwif->mwdma_mask = 0x07; 339 hwif->mwdma_mask = 0x07;
340 340
341 hwif->err_stops_fifo = 1;
342
341 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate; 343 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate;
342 hwif->ide_dma_lostirq = &pdcnew_ide_dma_lostirq; 344 hwif->ide_dma_lostirq = &pdcnew_ide_dma_lostirq;
343 hwif->ide_dma_timeout = &pdcnew_ide_dma_timeout; 345 hwif->ide_dma_timeout = &pdcnew_ide_dma_timeout;
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 22d17548ecdb..1e209d8f9437 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -101,31 +101,6 @@ static const char *pdc_quirk_drives[] = {
101#define MC1 0x02 /* DMA"C" timing */ 101#define MC1 0x02 /* DMA"C" timing */
102#define MC0 0x01 /* DMA"C" timing */ 102#define MC0 0x01 /* DMA"C" timing */
103 103
104#if 0
105 unsigned long bibma = pci_resource_start(dev, 4);
106 u8 hi = 0, lo = 0;
107
108 u8 sc1c = inb_p((u16)bibma + 0x1c);
109 u8 sc1e = inb_p((u16)bibma + 0x1e);
110 u8 sc1f = inb_p((u16)bibma + 0x1f);
111
112 p += sprintf(p, "Host Mode : %s\n",
113 (sc1f & 0x08) ? "Tri-Stated" : "Normal");
114 p += sprintf(p, "Bus Clocking : %s\n",
115 ((sc1f & 0xC0) == 0xC0) ? "100 External" :
116 ((sc1f & 0x80) == 0x80) ? "66 External" :
117 ((sc1f & 0x40) == 0x40) ? "33 External" : "33 PCI Internal");
118 p += sprintf(p, "IO pad select : %s mA\n",
119 ((sc1c & 0x03) == 0x03) ? "10" :
120 ((sc1c & 0x02) == 0x02) ? "8" :
121 ((sc1c & 0x01) == 0x01) ? "6" :
122 ((sc1c & 0x00) == 0x00) ? "4" : "??");
123 hi = sc1e >> 4;
124 lo = sc1e & 0xf;
125 p += sprintf(p, "Status Polling Period : %d\n", hi);
126 p += sprintf(p, "Interrupt Check Status Polling Delay : %d\n", lo);
127#endif
128
129static u8 pdc202xx_ratemask (ide_drive_t *drive) 104static u8 pdc202xx_ratemask (ide_drive_t *drive)
130{ 105{
131 u8 mode; 106 u8 mode;
@@ -505,73 +480,20 @@ static void pdc202xx_reset (ide_drive_t *drive)
505 480
506 pdc202xx_reset_host(hwif); 481 pdc202xx_reset_host(hwif);
507 pdc202xx_reset_host(mate); 482 pdc202xx_reset_host(mate);
508#if 0
509 /*
510 * FIXME: Have to kick all the drives again :-/
511 * What a pain in the ACE!
512 */
513 if (hwif->present) {
514 u16 hunit = 0;
515 for (hunit = 0; hunit < MAX_DRIVES; ++hunit) {
516 ide_drive_t *hdrive = &hwif->drives[hunit];
517 if (hdrive->present) {
518 if (hwif->ide_dma_check)
519 hwif->ide_dma_check(hdrive);
520 else
521 hwif->tuneproc(hdrive, 5);
522 }
523 }
524 }
525 if (mate->present) {
526 u16 munit = 0;
527 for (munit = 0; munit < MAX_DRIVES; ++munit) {
528 ide_drive_t *mdrive = &mate->drives[munit];
529 if (mdrive->present) {
530 if (mate->ide_dma_check)
531 mate->ide_dma_check(mdrive);
532 else
533 mate->tuneproc(mdrive, 5);
534 }
535 }
536 }
537#else
538 hwif->tuneproc(drive, 5); 483 hwif->tuneproc(drive, 5);
539#endif
540} 484}
541 485
542static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, const char *name) 486static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev,
487 const char *name)
543{ 488{
489 /* This doesn't appear needed */
544 if (dev->resource[PCI_ROM_RESOURCE].start) { 490 if (dev->resource[PCI_ROM_RESOURCE].start) {
545 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 491 pci_write_config_dword(dev, PCI_ROM_ADDRESS,
546 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 492 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
547 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", 493 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name,
548 name, dev->resource[PCI_ROM_RESOURCE].start); 494 (unsigned long)dev->resource[PCI_ROM_RESOURCE].start);
549 }
550
551 /*
552 * software reset - this is required because the bios
553 * will set UDMA timing on if the hdd supports it. The
554 * user may want to turn udma off. A bug in the pdc20262
555 * is that it cannot handle a downgrade in timing from
556 * UDMA to DMA. Disk accesses after issuing a set
557 * feature command will result in errors. A software
558 * reset leaves the timing registers intact,
559 * but resets the drives.
560 */
561#if 0
562 if ((dev->device == PCI_DEVICE_ID_PROMISE_20267) ||
563 (dev->device == PCI_DEVICE_ID_PROMISE_20265) ||
564 (dev->device == PCI_DEVICE_ID_PROMISE_20263) ||
565 (dev->device == PCI_DEVICE_ID_PROMISE_20262)) {
566 unsigned long high_16 = pci_resource_start(dev, 4);
567 byte udma_speed_flag = inb(high_16 + 0x001f);
568 outb(udma_speed_flag | 0x10, high_16 + 0x001f);
569 mdelay(100);
570 outb(udma_speed_flag & ~0x10, high_16 + 0x001f);
571 mdelay(2000); /* 2 seconds ?! */
572 } 495 }
573 496
574#endif
575 return dev->irq; 497 return dev->irq;
576} 498}
577 499
@@ -599,6 +521,8 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
599 hwif->mwdma_mask = 0x07; 521 hwif->mwdma_mask = 0x07;
600 hwif->swdma_mask = 0x07; 522 hwif->swdma_mask = 0x07;
601 523
524 hwif->err_stops_fifo = 1;
525
602 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate; 526 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate;
603 hwif->ide_dma_lostirq = &pdc202xx_ide_dma_lostirq; 527 hwif->ide_dma_lostirq = &pdc202xx_ide_dma_lostirq;
604 hwif->ide_dma_timeout = &pdc202xx_ide_dma_timeout; 528 hwif->ide_dma_timeout = &pdc202xx_ide_dma_timeout;
@@ -687,19 +611,6 @@ static int __devinit init_setup_pdc202ata4(struct pci_dev *dev,
687 "mirror fixed.\n", d->name); 611 "mirror fixed.\n", d->name);
688 } 612 }
689 } 613 }
690
691#if 0
692 if (dev->device == PCI_DEVICE_ID_PROMISE_20262)
693 if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) ||
694 (tmp & e->mask) != e->val))
695
696 if (d->enablebits[0].reg != d->enablebits[1].reg) {
697 d->enablebits[0].reg = d->enablebits[1].reg;
698 d->enablebits[0].mask = d->enablebits[1].mask;
699 d->enablebits[0].val = d->enablebits[1].val;
700 }
701#endif
702
703 return ide_setup_pci_device(dev, d); 614 return ide_setup_pci_device(dev, d);
704} 615}
705 616
@@ -714,22 +625,6 @@ static int __devinit init_setup_pdc20265(struct pci_dev *dev,
714 "attached to I2O RAID controller.\n"); 625 "attached to I2O RAID controller.\n");
715 return -ENODEV; 626 return -ENODEV;
716 } 627 }
717
718#if 0
719 {
720 u8 pri = 0, sec = 0;
721
722 if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) ||
723 (tmp & e->mask) != e->val))
724
725 if (d->enablebits[0].reg != d->enablebits[1].reg) {
726 d->enablebits[0].reg = d->enablebits[1].reg;
727 d->enablebits[0].mask = d->enablebits[1].mask;
728 d->enablebits[0].val = d->enablebits[1].val;
729 }
730 }
731#endif
732
733 return ide_setup_pci_device(dev, d); 628 return ide_setup_pci_device(dev, d);
734} 629}
735 630
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 24e21b2838c1..778b82ae964d 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -395,7 +395,6 @@ static int sc1200_resume (struct pci_dev *dev)
395{ 395{
396 ide_hwif_t *hwif = NULL; 396 ide_hwif_t *hwif = NULL;
397 397
398printk("SC1200: resume\n");
399 pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state 398 pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state
400 dev->current_state = PM_EVENT_ON; 399 dev->current_state = PM_EVENT_ON;
401 pci_enable_device(dev); 400 pci_enable_device(dev);
@@ -405,7 +404,6 @@ printk("SC1200: resume\n");
405 while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) { 404 while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) {
406 unsigned int basereg, r, d, format; 405 unsigned int basereg, r, d, format;
407 sc1200_saved_state_t *ss = (sc1200_saved_state_t *)hwif->config_data; 406 sc1200_saved_state_t *ss = (sc1200_saved_state_t *)hwif->config_data;
408printk("%s: SC1200: resume\n", hwif->name);
409 407
410 // 408 //
411 // Restore timing registers: this may be unnecessary if BIOS also does it 409 // Restore timing registers: this may be unnecessary if BIOS also does it
@@ -493,7 +491,7 @@ static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_devic
493} 491}
494 492
495static struct pci_device_id sc1200_pci_tbl[] = { 493static struct pci_device_id sc1200_pci_tbl[] = {
496 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 494 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE), 0},
497 { 0, }, 495 { 0, },
498}; 496};
499MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl); 497MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl);
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 0d3073f4eab4..5100b827a935 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -123,11 +123,11 @@ static u8 svwks_csb_check (struct pci_dev *dev)
123} 123}
124static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed) 124static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
125{ 125{
126 u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; 126 static const u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
127 u8 dma_modes[] = { 0x77, 0x21, 0x20 }; 127 static const u8 dma_modes[] = { 0x77, 0x21, 0x20 };
128 u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 128 static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
129 u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; 129 static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 };
130 u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; 130 static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 };
131 131
132 ide_hwif_t *hwif = HWIF(drive); 132 ide_hwif_t *hwif = HWIF(drive);
133 struct pci_dev *dev = hwif->pci_dev; 133 struct pci_dev *dev = hwif->pci_dev;
@@ -392,16 +392,6 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha
392 } 392 }
393 outb_p(0x06, 0x0c00); 393 outb_p(0x06, 0x0c00);
394 dev->irq = inb_p(0x0c01); 394 dev->irq = inb_p(0x0c01);
395#if 0
396 printk("%s: device class (0x%04x)\n",
397 name, dev->class);
398 if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
399 dev->class &= ~0x000F0F00;
400 // dev->class |= ~0x00000400;
401 dev->class |= ~0x00010100;
402 /**/
403 }
404#endif
405 } else { 395 } else {
406 struct pci_dev * findev = NULL; 396 struct pci_dev * findev = NULL;
407 u8 reg41 = 0; 397 u8 reg41 = 0;
@@ -452,7 +442,7 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha
452 pci_write_config_byte(dev, 0x5A, btr); 442 pci_write_config_byte(dev, 0x5A, btr);
453 } 443 }
454 444
455 return (dev->irq) ? dev->irq : 0; 445 return dev->irq;
456} 446}
457 447
458static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif) 448static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif)
@@ -500,11 +490,6 @@ static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif)
500{ 490{
501 struct pci_dev *dev = hwif->pci_dev; 491 struct pci_dev *dev = hwif->pci_dev;
502 492
503 /* Per Specified Design by OEM, and ASIC Architect */
504 if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
505 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
506 return 1;
507
508 /* Server Works */ 493 /* Server Works */
509 if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS) 494 if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS)
510 return ata66_svwks_svwks (hwif); 495 return ata66_svwks_svwks (hwif);
@@ -517,10 +502,14 @@ static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif)
517 if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN) 502 if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN)
518 return ata66_svwks_cobalt (hwif); 503 return ata66_svwks_cobalt (hwif);
519 504
505 /* Per Specified Design by OEM, and ASIC Architect */
506 if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
507 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
508 return 1;
509
520 return 0; 510 return 0;
521} 511}
522 512
523#undef CAN_SW_DMA
524static void __devinit init_hwif_svwks (ide_hwif_t *hwif) 513static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
525{ 514{
526 u8 dma_stat = 0; 515 u8 dma_stat = 0;
@@ -537,9 +526,6 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
537 hwif->ultra_mask = 0x3f; 526 hwif->ultra_mask = 0x3f;
538 527
539 hwif->mwdma_mask = 0x07; 528 hwif->mwdma_mask = 0x07;
540#ifdef CAN_SW_DMA
541 hwif->swdma_mask = 0x07;
542#endif /* CAN_SW_DMA */
543 529
544 hwif->autodma = 0; 530 hwif->autodma = 0;
545 531
@@ -562,8 +548,6 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
562 hwif->drives[1].autodma = (dma_stat & 0x40); 548 hwif->drives[1].autodma = (dma_stat & 0x40);
563 hwif->drives[0].autotune = (!(dma_stat & 0x20)); 549 hwif->drives[0].autotune = (!(dma_stat & 0x20));
564 hwif->drives[1].autotune = (!(dma_stat & 0x40)); 550 hwif->drives[1].autotune = (!(dma_stat & 0x40));
565// hwif->drives[0].autodma = hwif->autodma;
566// hwif->drives[1].autodma = hwif->autodma;
567} 551}
568 552
569/* 553/*
@@ -593,11 +577,6 @@ static int __devinit init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d)
593 if (dev->resource[0].start == 0x01f1) 577 if (dev->resource[0].start == 0x01f1)
594 d->bootable = ON_BOARD; 578 d->bootable = ON_BOARD;
595 } 579 }
596#if 0
597 if ((IDE_PCI_DEVID_EQ(d->devid, DEVID_CSB6) &&
598 (!(PCI_FUNC(dev->devfn) & 1)))
599 d->autodma = AUTODMA;
600#endif
601 580
602 d->channels = ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE || 581 d->channels = ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE ||
603 dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) && 582 dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) &&
@@ -671,11 +650,11 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device
671} 650}
672 651
673static struct pci_device_id svwks_pci_tbl[] = { 652static struct pci_device_id svwks_pci_tbl[] = {
674 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 653 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0},
675 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 654 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE), 1},
676 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 655 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE), 2},
677 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 656 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2), 3},
678 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 657 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE), 4},
679 { 0, }, 658 { 0, },
680}; 659};
681MODULE_DEVICE_TABLE(pci, svwks_pci_tbl); 660MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index f1ca154dd52c..72dade14c725 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -38,9 +38,6 @@
38 38
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#undef SIIMAGE_VIRTUAL_DMAPIO
42#undef SIIMAGE_LARGE_DMA
43
44/** 41/**
45 * pdev_is_sata - check if device is SATA 42 * pdev_is_sata - check if device is SATA
46 * @pdev: PCI device to check 43 * @pdev: PCI device to check
@@ -461,36 +458,6 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive)
461 return 0; 458 return 0;
462} 459}
463 460
464#if 0
465/**
466 * siimage_mmio_ide_dma_count - DMA bytes done
467 * @drive
468 *
469 * If we are doing VDMA the CMD680 requires a little bit
470 * of more careful handling and we have to read the counts
471 * off ourselves. For non VDMA life is normal.
472 */
473
474static int siimage_mmio_ide_dma_count (ide_drive_t *drive)
475{
476#ifdef SIIMAGE_VIRTUAL_DMAPIO
477 struct request *rq = HWGROUP(drive)->rq;
478 ide_hwif_t *hwif = HWIF(drive);
479 u32 count = (rq->nr_sectors * SECTOR_SIZE);
480 u32 rcount = 0;
481 unsigned long addr = siimage_selreg(hwif, 0x1C);
482
483 hwif->OUTL(count, addr);
484 rcount = hwif->INL(addr);
485
486 printk("\n%s: count = %d, rcount = %d, nr_sectors = %lu\n",
487 drive->name, count, rcount, rq->nr_sectors);
488
489#endif /* SIIMAGE_VIRTUAL_DMAPIO */
490 return __ide_dma_count(drive);
491}
492#endif
493
494/** 461/**
495 * siimage_mmio_ide_dma_test_irq - check we caused an IRQ 462 * siimage_mmio_ide_dma_test_irq - check we caused an IRQ
496 * @drive: drive we are testing 463 * @drive: drive we are testing
@@ -512,12 +479,10 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
512 u32 sata_error = hwif->INL(SATA_ERROR_REG); 479 u32 sata_error = hwif->INL(SATA_ERROR_REG);
513 hwif->OUTL(sata_error, SATA_ERROR_REG); 480 hwif->OUTL(sata_error, SATA_ERROR_REG);
514 watchdog = (sata_error & 0x00680000) ? 1 : 0; 481 watchdog = (sata_error & 0x00680000) ? 1 : 0;
515#if 1
516 printk(KERN_WARNING "%s: sata_error = 0x%08x, " 482 printk(KERN_WARNING "%s: sata_error = 0x%08x, "
517 "watchdog = %d, %s\n", 483 "watchdog = %d, %s\n",
518 drive->name, sata_error, watchdog, 484 drive->name, sata_error, watchdog,
519 __FUNCTION__); 485 __FUNCTION__);
520#endif
521 486
522 } else { 487 } else {
523 watchdog = (ext_stat & 0x8000) ? 1 : 0; 488 watchdog = (ext_stat & 0x8000) ? 1 : 0;
@@ -863,7 +828,7 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, const ch
863 * time. 828 * time.
864 * 829 *
865 * The hardware supports buffered taskfiles and also some rather nice 830 * The hardware supports buffered taskfiles and also some rather nice
866 * extended PRD tables. Unfortunately right now we don't. 831 * extended PRD tables. For better SI3112 support use the libata driver
867 */ 832 */
868 833
869static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) 834static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
@@ -900,9 +865,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
900 * so we can't currently use it sanely since we want to 865 * so we can't currently use it sanely since we want to
901 * use LBA48 mode. 866 * use LBA48 mode.
902 */ 867 */
903// base += 0x10;
904// hwif->no_lba48 = 1;
905
906 hw.io_ports[IDE_DATA_OFFSET] = base; 868 hw.io_ports[IDE_DATA_OFFSET] = base;
907 hw.io_ports[IDE_ERROR_OFFSET] = base + 1; 869 hw.io_ports[IDE_ERROR_OFFSET] = base + 1;
908 hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2; 870 hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2;
@@ -936,15 +898,8 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
936 898
937 base = (unsigned long) addr; 899 base = (unsigned long) addr;
938 900
939#ifdef SIIMAGE_LARGE_DMA
940/* Watch the brackets - even Ken and Dennis get some language design wrong */
941 hwif->dma_base = base + (ch ? 0x18 : 0x10);
942 hwif->dma_base2 = base + (ch ? 0x08 : 0x00);
943 hwif->dma_prdtable = hwif->dma_base2 + 4;
944#else /* ! SIIMAGE_LARGE_DMA */
945 hwif->dma_base = base + (ch ? 0x08 : 0x00); 901 hwif->dma_base = base + (ch ? 0x08 : 0x00);
946 hwif->dma_base2 = base + (ch ? 0x18 : 0x10); 902 hwif->dma_base2 = base + (ch ? 0x18 : 0x10);
947#endif /* SIIMAGE_LARGE_DMA */
948 hwif->mmio = 2; 903 hwif->mmio = 2;
949} 904}
950 905
@@ -1052,9 +1007,16 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
1052 hwif->reset_poll = &siimage_reset_poll; 1007 hwif->reset_poll = &siimage_reset_poll;
1053 hwif->pre_reset = &siimage_pre_reset; 1008 hwif->pre_reset = &siimage_pre_reset;
1054 1009
1055 if(is_sata(hwif)) 1010 if(is_sata(hwif)) {
1011 static int first = 1;
1012
1056 hwif->busproc = &siimage_busproc; 1013 hwif->busproc = &siimage_busproc;
1057 1014
1015 if (first) {
1016 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n");
1017 first = 0;
1018 }
1019 }
1058 if (!hwif->dma_base) { 1020 if (!hwif->dma_base) {
1059 hwif->drives[0].autotune = 1; 1021 hwif->drives[0].autotune = 1;
1060 hwif->drives[1].autotune = 1; 1022 hwif->drives[1].autotune = 1;
@@ -1121,10 +1083,10 @@ static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_devi
1121} 1083}
1122 1084
1123static struct pci_device_id siimage_pci_tbl[] = { 1085static struct pci_device_id siimage_pci_tbl[] = {
1124 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1086 { PCI_DEVICE(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680), 0},
1125#ifdef CONFIG_BLK_DEV_IDE_SATA 1087#ifdef CONFIG_BLK_DEV_IDE_SATA
1126 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 1088 { PCI_DEVICE(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112), 1},
1127 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 1089 { PCI_DEVICE(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA), 2},
1128#endif 1090#endif
1129 { 0, }, 1091 { 0, },
1130}; 1092};
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 8a5c7b286b2b..900301e43818 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -447,7 +447,6 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
447 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n", 447 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
448 hwif->name, rev); 448 hwif->name, rev);
449 } else { 449 } else {
450#ifdef CONFIG_BLK_DEV_IDEDMA
451 dma_state |= 0x60; 450 dma_state |= 0x60;
452 451
453 hwif->atapi_dma = 1; 452 hwif->atapi_dma = 1;
@@ -468,7 +467,6 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
468 467
469 if (hwif->mate) 468 if (hwif->mate)
470 hwif->serialized = hwif->mate->serialized = 1; 469 hwif->serialized = hwif->mate->serialized = 1;
471#endif /* CONFIG_BLK_DEV_IDEDMA */
472 } 470 }
473 hwif->OUTB(dma_state, hwif->dma_base + 2); 471 hwif->OUTB(dma_state, hwif->dma_base + 2);
474} 472}
@@ -489,7 +487,7 @@ static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_dev
489} 487}
490 488
491static struct pci_device_id sl82c105_pci_tbl[] = { 489static struct pci_device_id sl82c105_pci_tbl[] = {
492 { PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 490 { PCI_DEVICE(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105), 0},
493 { 0, }, 491 { 0, },
494}; 492};
495MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl); 493MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl);
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index 5112c726633b..0968f6bc669a 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -72,7 +72,8 @@ static void slc90e66_tune_drive (ide_drive_t *drive, u8 pio)
72 u16 master_data; 72 u16 master_data;
73 u8 slave_data; 73 u8 slave_data;
74 /* ISP RTC */ 74 /* ISP RTC */
75 u8 timings[][2] = { { 0, 0 }, 75 static const u8 timings[][2]= {
76 { 0, 0 },
76 { 0, 0 }, 77 { 0, 0 },
77 { 1, 0 }, 78 { 1, 0 },
78 { 2, 1 }, 79 { 2, 1 },
@@ -119,7 +120,6 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
119 pci_read_config_word(dev, 0x4a, &reg4a); 120 pci_read_config_word(dev, 0x4a, &reg4a);
120 121
121 switch(speed) { 122 switch(speed) {
122#ifdef CONFIG_BLK_DEV_IDEDMA
123 case XFER_UDMA_4: u_speed = 4 << (drive->dn * 4); break; 123 case XFER_UDMA_4: u_speed = 4 << (drive->dn * 4); break;
124 case XFER_UDMA_3: u_speed = 3 << (drive->dn * 4); break; 124 case XFER_UDMA_3: u_speed = 3 << (drive->dn * 4); break;
125 case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break; 125 case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break;
@@ -128,7 +128,6 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
128 case XFER_MW_DMA_2: 128 case XFER_MW_DMA_2:
129 case XFER_MW_DMA_1: 129 case XFER_MW_DMA_1:
130 case XFER_SW_DMA_2: break; 130 case XFER_SW_DMA_2: break;
131#endif /* CONFIG_BLK_DEV_IDEDMA */
132 case XFER_PIO_4: 131 case XFER_PIO_4:
133 case XFER_PIO_3: 132 case XFER_PIO_3:
134 case XFER_PIO_2: 133 case XFER_PIO_2:
@@ -156,7 +155,6 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
156 return (ide_config_drive_speed(drive, speed)); 155 return (ide_config_drive_speed(drive, speed));
157} 156}
158 157
159#ifdef CONFIG_BLK_DEV_IDEDMA
160static int slc90e66_config_drive_for_dma (ide_drive_t *drive) 158static int slc90e66_config_drive_for_dma (ide_drive_t *drive)
161{ 159{
162 u8 speed = ide_dma_speed(drive, slc90e66_ratemask(drive)); 160 u8 speed = ide_dma_speed(drive, slc90e66_ratemask(drive));
@@ -194,7 +192,6 @@ fast_ata_pio:
194 /* IORDY not supported */ 192 /* IORDY not supported */
195 return 0; 193 return 0;
196} 194}
197#endif /* CONFIG_BLK_DEV_IDEDMA */
198 195
199static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) 196static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
200{ 197{
@@ -222,7 +219,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
222 hwif->mwdma_mask = 0x07; 219 hwif->mwdma_mask = 0x07;
223 hwif->swdma_mask = 0x07; 220 hwif->swdma_mask = 0x07;
224 221
225#ifdef CONFIG_BLK_DEV_IDEDMA
226 if (!(hwif->udma_four)) 222 if (!(hwif->udma_four))
227 /* bit[0(1)]: 0:80, 1:40 */ 223 /* bit[0(1)]: 0:80, 1:40 */
228 hwif->udma_four = (reg47 & mask) ? 0 : 1; 224 hwif->udma_four = (reg47 & mask) ? 0 : 1;
@@ -232,7 +228,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
232 hwif->autodma = 1; 228 hwif->autodma = 1;
233 hwif->drives[0].autodma = hwif->autodma; 229 hwif->drives[0].autodma = hwif->autodma;
234 hwif->drives[1].autodma = hwif->autodma; 230 hwif->drives[1].autodma = hwif->autodma;
235#endif /* !CONFIG_BLK_DEV_IDEDMA */
236} 231}
237 232
238static ide_pci_device_t slc90e66_chipset __devinitdata = { 233static ide_pci_device_t slc90e66_chipset __devinitdata = {
@@ -250,7 +245,7 @@ static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_dev
250} 245}
251 246
252static struct pci_device_id slc90e66_pci_tbl[] = { 247static struct pci_device_id slc90e66_pci_tbl[] = {
253 { PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 248 { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1), 0},
254 { 0, }, 249 { 0, },
255}; 250};
256MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl); 251MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index ffca8b63ee79..e8ef3455ec35 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -421,107 +421,6 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
421#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 421#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
422 422
423/* 423/*
424 * Below is the code for blinking the laptop LED along with hard
425 * disk activity.
426 */
427
428#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
429
430/* Set to 50ms minimum led-on time (also used to limit frequency
431 * of requests sent to the PMU
432 */
433#define PMU_HD_BLINK_TIME (HZ/50)
434
435static struct adb_request pmu_blink_on, pmu_blink_off;
436static spinlock_t pmu_blink_lock;
437static unsigned long pmu_blink_stoptime;
438static int pmu_blink_ledstate;
439static struct timer_list pmu_blink_timer;
440static int pmu_ide_blink_enabled;
441
442
443static void
444pmu_hd_blink_timeout(unsigned long data)
445{
446 unsigned long flags;
447
448 spin_lock_irqsave(&pmu_blink_lock, flags);
449
450 /* We may have been triggered again in a racy way, check
451 * that we really want to switch it off
452 */
453 if (time_after(pmu_blink_stoptime, jiffies))
454 goto done;
455
456 /* Previous req. not complete, try 100ms more */
457 if (pmu_blink_off.complete == 0)
458 mod_timer(&pmu_blink_timer, jiffies + PMU_HD_BLINK_TIME);
459 else if (pmu_blink_ledstate) {
460 pmu_request(&pmu_blink_off, NULL, 4, 0xee, 4, 0, 0);
461 pmu_blink_ledstate = 0;
462 }
463done:
464 spin_unlock_irqrestore(&pmu_blink_lock, flags);
465}
466
467static void
468pmu_hd_kick_blink(void *data, int rw)
469{
470 unsigned long flags;
471
472 pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME;
473 wmb();
474 mod_timer(&pmu_blink_timer, pmu_blink_stoptime);
475 /* Fast path when LED is already ON */
476 if (pmu_blink_ledstate == 1)
477 return;
478 spin_lock_irqsave(&pmu_blink_lock, flags);
479 if (pmu_blink_on.complete && !pmu_blink_ledstate) {
480 pmu_request(&pmu_blink_on, NULL, 4, 0xee, 4, 0, 1);
481 pmu_blink_ledstate = 1;
482 }
483 spin_unlock_irqrestore(&pmu_blink_lock, flags);
484}
485
486static int
487pmu_hd_blink_init(void)
488{
489 struct device_node *dt;
490 const char *model;
491
492 /* Currently, I only enable this feature on KeyLargo based laptops,
493 * older laptops may support it (at least heathrow/paddington) but
494 * I don't feel like loading those venerable old machines with so
495 * much additional interrupt & PMU activity...
496 */
497 if (pmu_get_model() != PMU_KEYLARGO_BASED)
498 return 0;
499
500 dt = of_find_node_by_path("/");
501 if (dt == NULL)
502 return 0;
503 model = (const char *)get_property(dt, "model", NULL);
504 if (model == NULL)
505 return 0;
506 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
507 strncmp(model, "iBook", strlen("iBook")) != 0) {
508 of_node_put(dt);
509 return 0;
510 }
511 of_node_put(dt);
512
513 pmu_blink_on.complete = 1;
514 pmu_blink_off.complete = 1;
515 spin_lock_init(&pmu_blink_lock);
516 init_timer(&pmu_blink_timer);
517 pmu_blink_timer.function = pmu_hd_blink_timeout;
518
519 return 1;
520}
521
522#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
523
524/*
525 * N.B. this can't be an initfunc, because the media-bay task can 424 * N.B. this can't be an initfunc, because the media-bay task can
526 * call ide_[un]register at any time. 425 * call ide_[un]register at any time.
527 */ 426 */
@@ -1192,23 +1091,6 @@ pmac_ide_do_suspend(ide_hwif_t *hwif)
1192 pmif->timings[0] = 0; 1091 pmif->timings[0] = 0;
1193 pmif->timings[1] = 0; 1092 pmif->timings[1] = 0;
1194 1093
1195#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
1196 /* Note: This code will be called for every hwif, thus we'll
1197 * try several time to stop the LED blinker timer, but that
1198 * should be harmless
1199 */
1200 if (pmu_ide_blink_enabled) {
1201 unsigned long flags;
1202
1203 /* Make sure we don't hit the PMU blink */
1204 spin_lock_irqsave(&pmu_blink_lock, flags);
1205 if (pmu_blink_ledstate)
1206 del_timer(&pmu_blink_timer);
1207 pmu_blink_ledstate = 0;
1208 spin_unlock_irqrestore(&pmu_blink_lock, flags);
1209 }
1210#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
1211
1212 disable_irq(pmif->irq); 1094 disable_irq(pmif->irq);
1213 1095
1214 /* The media bay will handle itself just fine */ 1096 /* The media bay will handle itself just fine */
@@ -1376,13 +1258,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1376 hwif->selectproc = pmac_ide_selectproc; 1258 hwif->selectproc = pmac_ide_selectproc;
1377 hwif->speedproc = pmac_ide_tune_chipset; 1259 hwif->speedproc = pmac_ide_tune_chipset;
1378 1260
1379#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
1380 pmu_ide_blink_enabled = pmu_hd_blink_init();
1381
1382 if (pmu_ide_blink_enabled)
1383 hwif->led_act = pmu_hd_kick_blink;
1384#endif
1385
1386 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", 1261 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
1387 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, 1262 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
1388 pmif->mediabay ? " (mediabay)" : "", hwif->irq); 1263 pmif->mediabay ? " (mediabay)" : "", hwif->irq);
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 3d278412e1ca..800c8d518430 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -590,11 +590,11 @@ static void ohci_initialize(struct ti_ohci *ohci)
590 buf = reg_read(ohci, OHCI1394_Version); 590 buf = reg_read(ohci, OHCI1394_Version);
591 sprintf (irq_buf, "%d", ohci->dev->irq); 591 sprintf (irq_buf, "%d", ohci->dev->irq);
592 PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] " 592 PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] "
593 "MMIO=[%lx-%lx] Max Packet=[%d] IR/IT contexts=[%d/%d]", 593 "MMIO=[%llx-%llx] Max Packet=[%d] IR/IT contexts=[%d/%d]",
594 ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10), 594 ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10),
595 ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf, 595 ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf,
596 pci_resource_start(ohci->dev, 0), 596 (unsigned long long)pci_resource_start(ohci->dev, 0),
597 pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1, 597 (unsigned long long)pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1,
598 ohci->max_packet_size, 598 ohci->max_packet_size,
599 ohci->nb_iso_rcv_ctx, ohci->nb_iso_xmit_ctx); 599 ohci->nb_iso_rcv_ctx, ohci->nb_iso_xmit_ctx);
600 600
@@ -3217,7 +3217,7 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3217{ 3217{
3218 struct hpsb_host *host; 3218 struct hpsb_host *host;
3219 struct ti_ohci *ohci; /* shortcut to currently handled device */ 3219 struct ti_ohci *ohci; /* shortcut to currently handled device */
3220 unsigned long ohci_base; 3220 resource_size_t ohci_base;
3221 3221
3222 if (pci_enable_device(dev)) 3222 if (pci_enable_device(dev))
3223 FAIL(-ENXIO, "Failed to enable OHCI hardware"); 3223 FAIL(-ENXIO, "Failed to enable OHCI hardware");
@@ -3270,15 +3270,16 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3270 * clearly says it's 2kb, so this shouldn't be a problem. */ 3270 * clearly says it's 2kb, so this shouldn't be a problem. */
3271 ohci_base = pci_resource_start(dev, 0); 3271 ohci_base = pci_resource_start(dev, 0);
3272 if (pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE) 3272 if (pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE)
3273 PRINT(KERN_WARNING, "PCI resource length of %lx too small!", 3273 PRINT(KERN_WARNING, "PCI resource length of 0x%llx too small!",
3274 pci_resource_len(dev, 0)); 3274 (unsigned long long)pci_resource_len(dev, 0));
3275 3275
3276 /* Seems PCMCIA handles this internally. Not sure why. Seems 3276 /* Seems PCMCIA handles this internally. Not sure why. Seems
3277 * pretty bogus to force a driver to special case this. */ 3277 * pretty bogus to force a driver to special case this. */
3278#ifndef PCMCIA 3278#ifndef PCMCIA
3279 if (!request_mem_region (ohci_base, OHCI1394_REGISTER_SIZE, OHCI1394_DRIVER_NAME)) 3279 if (!request_mem_region (ohci_base, OHCI1394_REGISTER_SIZE, OHCI1394_DRIVER_NAME))
3280 FAIL(-ENOMEM, "MMIO resource (0x%lx - 0x%lx) unavailable", 3280 FAIL(-ENOMEM, "MMIO resource (0x%llx - 0x%llx) unavailable",
3281 ohci_base, ohci_base + OHCI1394_REGISTER_SIZE); 3281 (unsigned long long)ohci_base,
3282 (unsigned long long)ohci_base + OHCI1394_REGISTER_SIZE);
3282#endif 3283#endif
3283 ohci->init_state = OHCI_INIT_HAVE_MEM_REGION; 3284 ohci->init_state = OHCI_INIT_HAVE_MEM_REGION;
3284 3285
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index dddcdae736ac..e4b897fa569a 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -460,10 +460,10 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
460 for (j = 0; j < 6; j++) { 460 for (j = 0; j < 6; j++) {
461 if (!pdev->resource[j].start) 461 if (!pdev->resource[j].start)
462 continue; 462 continue;
463 ipath_cdbg(VERBOSE, "BAR %d start %lx, end %lx, len %lx\n", 463 ipath_cdbg(VERBOSE, "BAR %d start %llx, end %llx, len %llx\n",
464 j, pdev->resource[j].start, 464 j, (unsigned long long)pdev->resource[j].start,
465 pdev->resource[j].end, 465 (unsigned long long)pdev->resource[j].end,
466 pci_resource_len(pdev, j)); 466 (unsigned long long)pci_resource_len(pdev, j));
467 } 467 }
468 468
469 if (!addr) { 469 if (!addr) {
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 9b9ff7bff357..465fd220569c 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -172,8 +172,9 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
172 172
173 if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) { 173 if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) {
174 mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than " 174 mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than "
175 "PCI resource 2 size of 0x%lx, aborting.\n", 175 "PCI resource 2 size of 0x%llx, aborting.\n",
176 dev_lim->uar_size, pci_resource_len(mdev->pdev, 2)); 176 dev_lim->uar_size,
177 (unsigned long long)pci_resource_len(mdev->pdev, 2));
177 return -ENODEV; 178 return -ENODEV;
178 } 179 }
179 180
diff --git a/drivers/input/input.c b/drivers/input/input.c
index de2e7546b491..a90486f5e491 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -998,12 +998,13 @@ void input_unregister_device(struct input_dev *dev)
998 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); 998 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
999 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); 999 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
1000 sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); 1000 sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
1001 class_device_unregister(&dev->cdev);
1002 1001
1003 mutex_lock(&dev->mutex); 1002 mutex_lock(&dev->mutex);
1004 dev->name = dev->phys = dev->uniq = NULL; 1003 dev->name = dev->phys = dev->uniq = NULL;
1005 mutex_unlock(&dev->mutex); 1004 mutex_unlock(&dev->mutex);
1006 1005
1006 class_device_unregister(&dev->cdev);
1007
1007 input_wakeup_procfs_readers(); 1008 input_wakeup_procfs_readers();
1008} 1009}
1009EXPORT_SYMBOL(input_unregister_device); 1010EXPORT_SYMBOL(input_unregister_device);
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index 6f31f054d1bb..5080e15c6d30 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -584,7 +584,7 @@ static struct db9 __init *db9_probe(int parport, int mode)
584 goto err_out; 584 goto err_out;
585 } 585 }
586 586
587 if (db9_mode[mode].bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) { 587 if (db9_mode->bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) {
588 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); 588 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n");
589 err = -EINVAL; 589 err = -EINVAL;
590 goto err_put_pp; 590 goto err_put_pp;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ffde8f86e0fb..ce1f10e8984b 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -459,7 +459,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
459 } 459 }
460 460
461 input_regs(dev, regs); 461 input_regs(dev, regs);
462 input_report_key(dev, keycode, value); 462 input_event(dev, EV_KEY, keycode, value);
463 input_sync(dev); 463 input_sync(dev);
464 464
465 if (value && add_release_event) { 465 if (value && add_release_event) {
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index e4e5be111c96..ccf0faeee5c1 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -285,6 +285,15 @@ static struct key_entry keymap_fujitsu_n3510[] = {
285 { KE_END, 0 } 285 { KE_END, 0 }
286}; 286};
287 287
288static struct key_entry keymap_wistron_ms2111[] = {
289 { KE_KEY, 0x11, KEY_PROG1 },
290 { KE_KEY, 0x12, KEY_PROG2 },
291 { KE_KEY, 0x13, KEY_PROG3 },
292 { KE_KEY, 0x31, KEY_MAIL },
293 { KE_KEY, 0x36, KEY_WWW },
294 { KE_END, 0 }
295};
296
288static struct key_entry keymap_wistron_ms2141[] = { 297static struct key_entry keymap_wistron_ms2141[] = {
289 { KE_KEY, 0x11, KEY_PROG1 }, 298 { KE_KEY, 0x11, KEY_PROG1 },
290 { KE_KEY, 0x12, KEY_PROG2 }, 299 { KE_KEY, 0x12, KEY_PROG2 },
@@ -326,6 +335,7 @@ static struct key_entry keymap_aopen_1559as[] = {
326 { KE_WIFI, 0x30, 0 }, 335 { KE_WIFI, 0x30, 0 },
327 { KE_KEY, 0x31, KEY_MAIL }, 336 { KE_KEY, 0x31, KEY_MAIL },
328 { KE_KEY, 0x36, KEY_WWW }, 337 { KE_KEY, 0x36, KEY_WWW },
338 { KE_END, 0 },
329}; 339};
330 340
331/* 341/*
@@ -388,6 +398,15 @@ static struct dmi_system_id dmi_ids[] = {
388 }, 398 },
389 .driver_data = keymap_aopen_1559as 399 .driver_data = keymap_aopen_1559as
390 }, 400 },
401 {
402 .callback = dmi_matched,
403 .ident = "Medion MD 9783",
404 .matches = {
405 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
406 DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"),
407 },
408 .driver_data = keymap_wistron_ms2111
409 },
391 { NULL, } 410 { NULL, }
392}; 411};
393 412
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
index 096b6a0b5cca..1ac739ef2ffa 100644
--- a/drivers/input/serio/ct82c710.c
+++ b/drivers/input/serio/ct82c710.c
@@ -189,7 +189,7 @@ static int __devinit ct82c710_probe(struct platform_device *dev)
189 strlcpy(ct82c710_port->name, "C&T 82c710 mouse port", 189 strlcpy(ct82c710_port->name, "C&T 82c710 mouse port",
190 sizeof(ct82c710_port->name)); 190 sizeof(ct82c710_port->name));
191 snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys), 191 snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys),
192 "isa%04lx/serio0", CT82C710_DATA); 192 "isa%16llx/serio0", (unsigned long long)CT82C710_DATA);
193 193
194 serio_register_port(ct82c710_port); 194 serio_register_port(ct82c710_port);
195 195
@@ -241,8 +241,8 @@ static int __init ct82c710_init(void)
241 241
242 serio_register_port(ct82c710_port); 242 serio_register_port(ct82c710_port);
243 243
244 printk(KERN_INFO "serio: C&T 82c710 mouse port at %#lx irq %d\n", 244 printk(KERN_INFO "serio: C&T 82c710 mouse port at %#llx irq %d\n",
245 CT82C710_DATA, CT82C710_IRQ); 245 (unsigned long long)CT82C710_DATA, CT82C710_IRQ);
246 246
247 return 0; 247 return 0;
248 248
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 5a2703b536dc..71a8eea816cb 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -16,7 +16,6 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/major.h> 17#include <linux/major.h>
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/devfs_fs_kernel.h>
20#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
21#include <linux/wait.h> 20#include <linux/wait.h>
22#include <linux/mutex.h> 21#include <linux/mutex.h>
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 2e541fa02024..a518ec531021 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -39,7 +39,6 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/device.h> 40#include <linux/device.h>
41#include <linux/moduleparam.h> 41#include <linux/moduleparam.h>
42#include <linux/devfs_fs_kernel.h>
43#include <linux/isdn/capiutil.h> 42#include <linux/isdn/capiutil.h>
44#include <linux/isdn/capicmd.h> 43#include <linux/isdn/capicmd.h>
45#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) 44#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE)
@@ -1337,7 +1336,6 @@ static int capinc_tty_init(void)
1337 1336
1338 drv->owner = THIS_MODULE; 1337 drv->owner = THIS_MODULE;
1339 drv->driver_name = "capi_nc"; 1338 drv->driver_name = "capi_nc";
1340 drv->devfs_name = "capi/";
1341 drv->name = "capi"; 1339 drv->name = "capi";
1342 drv->major = capi_ttymajor; 1340 drv->major = capi_ttymajor;
1343 drv->minor_start = 0; 1341 drv->minor_start = 0;
@@ -1516,8 +1514,6 @@ static int __init capi_init(void)
1516 } 1514 }
1517 1515
1518 class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi"); 1516 class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
1519 devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
1520 "isdn/capi20");
1521 1517
1522#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1518#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1523 if (capinc_tty_init() < 0) { 1519 if (capinc_tty_init() < 0) {
@@ -1552,7 +1548,6 @@ static void __exit capi_exit(void)
1552 class_device_destroy(capi_class, MKDEV(capi_major, 0)); 1548 class_device_destroy(capi_class, MKDEV(capi_major, 0));
1553 class_destroy(capi_class); 1549 class_destroy(capi_class);
1554 unregister_chrdev(capi_major, "capi20"); 1550 unregister_chrdev(capi_major, "capi20");
1555 devfs_remove("isdn/capi20");
1556 1551
1557#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1552#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1558 capinc_tty_exit(); 1553 capinc_tty_exit();
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 8a45715dd4c1..3845defd4901 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -41,7 +41,6 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode");
41#define GIGASET_MINORS 1 41#define GIGASET_MINORS 1
42#define GIGASET_MINOR 16 42#define GIGASET_MINOR 16
43#define GIGASET_MODULENAME "bas_gigaset" 43#define GIGASET_MODULENAME "bas_gigaset"
44#define GIGASET_DEVFSNAME "gig/bas/"
45#define GIGASET_DEVNAME "ttyGB" 44#define GIGASET_DEVNAME "ttyGB"
46 45
47/* length limit according to Siemens 3070usb-protokoll.doc ch. 2.1 */ 46/* length limit according to Siemens 3070usb-protokoll.doc ch. 2.1 */
@@ -2349,8 +2348,7 @@ static int __init bas_gigaset_init(void)
2349 /* allocate memory for our driver state and intialize it */ 2348 /* allocate memory for our driver state and intialize it */
2350 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 2349 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
2351 GIGASET_MODULENAME, GIGASET_DEVNAME, 2350 GIGASET_MODULENAME, GIGASET_DEVNAME,
2352 GIGASET_DEVFSNAME, &gigops, 2351 &gigops, THIS_MODULE)) == NULL)
2353 THIS_MODULE)) == NULL)
2354 goto error; 2352 goto error;
2355 2353
2356 /* allocate memory for our device state and intialize it */ 2354 /* allocate memory for our device state and intialize it */
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index acb7e2656780..aca165d43aa0 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -981,7 +981,7 @@ exit:
981EXPORT_SYMBOL_GPL(gigaset_stop); 981EXPORT_SYMBOL_GPL(gigaset_stop);
982 982
983static LIST_HEAD(drivers); 983static LIST_HEAD(drivers);
984static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED; 984static DEFINE_SPINLOCK(driver_lock);
985 985
986struct cardstate *gigaset_get_cs_by_id(int id) 986struct cardstate *gigaset_get_cs_by_id(int id)
987{ 987{
@@ -1092,14 +1092,12 @@ EXPORT_SYMBOL_GPL(gigaset_freedriver);
1092 * minors Number of minors this driver can handle 1092 * minors Number of minors this driver can handle
1093 * procname Name of the driver 1093 * procname Name of the driver
1094 * devname Name of the device files (prefix without minor number) 1094 * devname Name of the device files (prefix without minor number)
1095 * devfsname Devfs name of the device files without %d
1096 * return value: 1095 * return value:
1097 * Pointer to the gigaset_driver structure on success, NULL on failure. 1096 * Pointer to the gigaset_driver structure on success, NULL on failure.
1098 */ 1097 */
1099struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, 1098struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
1100 const char *procname, 1099 const char *procname,
1101 const char *devname, 1100 const char *devname,
1102 const char *devfsname,
1103 const struct gigaset_ops *ops, 1101 const struct gigaset_ops *ops,
1104 struct module *owner) 1102 struct module *owner)
1105{ 1103{
@@ -1139,7 +1137,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
1139 drv->cs[i].minor_index = i; 1137 drv->cs[i].minor_index = i;
1140 } 1138 }
1141 1139
1142 gigaset_if_initdriver(drv, procname, devname, devfsname); 1140 gigaset_if_initdriver(drv, procname, devname);
1143 1141
1144 spin_lock_irqsave(&driver_lock, flags); 1142 spin_lock_irqsave(&driver_lock, flags);
1145 list_add(&drv->list, &drivers); 1143 list_add(&drv->list, &drivers);
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 8d63d822104f..1ca3bfdef51d 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -769,7 +769,6 @@ void gigaset_block_channels(struct cardstate *cs);
769struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, 769struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
770 const char *procname, 770 const char *procname,
771 const char *devname, 771 const char *devname,
772 const char *devfsname,
773 const struct gigaset_ops *ops, 772 const struct gigaset_ops *ops,
774 struct module *owner); 773 struct module *owner);
775 774
@@ -892,7 +891,7 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
892 891
893/* initialize interface */ 892/* initialize interface */
894void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, 893void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
895 const char *devname, const char *devfsname); 894 const char *devname);
896/* release interface */ 895/* release interface */
897void gigaset_if_freedriver(struct gigaset_driver *drv); 896void gigaset_if_freedriver(struct gigaset_driver *drv);
898/* add minor */ 897/* add minor */
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 74fd234956c8..bd2e4267528e 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -673,10 +673,9 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive);
673 * drv Driver 673 * drv Driver
674 * procname Name of the driver (e.g. for /proc/tty/drivers) 674 * procname Name of the driver (e.g. for /proc/tty/drivers)
675 * devname Name of the device files (prefix without minor number) 675 * devname Name of the device files (prefix without minor number)
676 * devfsname Devfs name of the device files without %d
677 */ 676 */
678void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, 677void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
679 const char *devname, const char *devfsname) 678 const char *devname)
680{ 679{
681 unsigned minors = drv->minors; 680 unsigned minors = drv->minors;
682 int ret; 681 int ret;
@@ -692,7 +691,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
692 tty->major = GIG_MAJOR, 691 tty->major = GIG_MAJOR,
693 tty->type = TTY_DRIVER_TYPE_SERIAL, 692 tty->type = TTY_DRIVER_TYPE_SERIAL,
694 tty->subtype = SERIAL_TYPE_NORMAL, 693 tty->subtype = SERIAL_TYPE_NORMAL,
695 tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS, 694 tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
696 695
697 tty->driver_name = procname; 696 tty->driver_name = procname;
698 tty->name = devname; 697 tty->name = devname;
@@ -700,7 +699,6 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
700 tty->num = drv->minors; 699 tty->num = drv->minors;
701 700
702 tty->owner = THIS_MODULE; 701 tty->owner = THIS_MODULE;
703 tty->devfs_name = devfsname;
704 702
705 tty->init_termios = tty_std_termios; //FIXME 703 tty->init_termios = tty_std_termios; //FIXME
706 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; //FIXME 704 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; //FIXME
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index d86ab68114b0..6e05d9d4a51a 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -41,7 +41,6 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode");
41#define GIGASET_MINORS 1 41#define GIGASET_MINORS 1
42#define GIGASET_MINOR 8 42#define GIGASET_MINOR 8
43#define GIGASET_MODULENAME "usb_gigaset" 43#define GIGASET_MODULENAME "usb_gigaset"
44#define GIGASET_DEVFSNAME "gig/usb/"
45#define GIGASET_DEVNAME "ttyGU" 44#define GIGASET_DEVNAME "ttyGU"
46 45
47#define IF_WRITEBUF 2000 //FIXME // WAKEUP_CHARS: 256 46#define IF_WRITEBUF 2000 //FIXME // WAKEUP_CHARS: 256
@@ -896,8 +895,7 @@ static int __init usb_gigaset_init(void)
896 /* allocate memory for our driver state and intialize it */ 895 /* allocate memory for our driver state and intialize it */
897 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 896 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
898 GIGASET_MODULENAME, GIGASET_DEVNAME, 897 GIGASET_MODULENAME, GIGASET_DEVNAME,
899 GIGASET_DEVFSNAME, &ops, 898 &ops, THIS_MODULE)) == NULL)
900 THIS_MODULE)) == NULL)
901 goto error; 899 goto error;
902 900
903 /* allocate memory for our device state and intialize it */ 901 /* allocate memory for our device state and intialize it */
diff --git a/drivers/isdn/hardware/avm/b1pcmcia.c b/drivers/isdn/hardware/avm/b1pcmcia.c
index 9746cc5ffff8..ad5025155b4e 100644
--- a/drivers/isdn/hardware/avm/b1pcmcia.c
+++ b/drivers/isdn/hardware/avm/b1pcmcia.c
@@ -82,7 +82,7 @@ static int b1pcmcia_add_card(unsigned int port, unsigned irq,
82 card->irq = irq; 82 card->irq = irq;
83 card->cardtype = cardtype; 83 card->cardtype = cardtype;
84 84
85 retval = request_irq(card->irq, b1_interrupt, 0, card->name, card); 85 retval = request_irq(card->irq, b1_interrupt, SA_SHIRQ, card->name, card);
86 if (retval) { 86 if (retval) {
87 printk(KERN_ERR "b1pcmcia: unable to get IRQ %d.\n", 87 printk(KERN_ERR "b1pcmcia: unable to get IRQ %d.\n",
88 card->irq); 88 card->irq);
diff --git a/drivers/isdn/hardware/eicon/divamnt.c b/drivers/isdn/hardware/eicon/divamnt.c
index 6146f7633be5..b163c5909182 100644
--- a/drivers/isdn/hardware/eicon/divamnt.c
+++ b/drivers/isdn/hardware/eicon/divamnt.c
@@ -17,7 +17,6 @@
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/smp_lock.h> 18#include <linux/smp_lock.h>
19#include <linux/poll.h> 19#include <linux/poll.h>
20#include <linux/devfs_fs_kernel.h>
21#include <asm/uaccess.h> 20#include <asm/uaccess.h>
22 21
23#include "platform.h" 22#include "platform.h"
@@ -178,7 +177,6 @@ static struct file_operations divas_maint_fops = {
178 177
179static void divas_maint_unregister_chrdev(void) 178static void divas_maint_unregister_chrdev(void)
180{ 179{
181 devfs_remove(DEVNAME);
182 unregister_chrdev(major, DEVNAME); 180 unregister_chrdev(major, DEVNAME);
183} 181}
184 182
@@ -190,7 +188,6 @@ static int DIVA_INIT_FUNCTION divas_maint_register_chrdev(void)
190 DRIVERLNAME); 188 DRIVERLNAME);
191 return (0); 189 return (0);
192 } 190 }
193 devfs_mk_cdev(MKDEV(major, 0), S_IFCHR|S_IRUSR|S_IWUSR, DEVNAME);
194 191
195 return (1); 192 return (1);
196} 193}
diff --git a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c
index df715b47e2b4..6e7d89a31c1d 100644
--- a/drivers/isdn/hardware/eicon/divasi.c
+++ b/drivers/isdn/hardware/eicon/divasi.c
@@ -19,7 +19,6 @@
19#include <linux/poll.h> 19#include <linux/poll.h>
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/skbuff.h> 21#include <linux/skbuff.h>
22#include <linux/devfs_fs_kernel.h>
23#include <asm/uaccess.h> 22#include <asm/uaccess.h>
24 23
25#include "platform.h" 24#include "platform.h"
@@ -145,7 +144,6 @@ static struct file_operations divas_idi_fops = {
145 144
146static void divas_idi_unregister_chrdev(void) 145static void divas_idi_unregister_chrdev(void)
147{ 146{
148 devfs_remove(DEVNAME);
149 unregister_chrdev(major, DEVNAME); 147 unregister_chrdev(major, DEVNAME);
150} 148}
151 149
@@ -157,7 +155,6 @@ static int DIVA_INIT_FUNCTION divas_idi_register_chrdev(void)
157 DRIVERLNAME); 155 DRIVERLNAME);
158 return (0); 156 return (0);
159 } 157 }
160 devfs_mk_cdev(MKDEV(major, 0), S_IFCHR|S_IRUSR|S_IWUSR, DEVNAME);
161 158
162 return (1); 159 return (1);
163} 160}
diff --git a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c
index c9b26e86d183..9dee6a39104c 100644
--- a/drivers/isdn/hardware/eicon/divasmain.c
+++ b/drivers/isdn/hardware/eicon/divasmain.c
@@ -14,7 +14,6 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/devfs_fs_kernel.h>
18#include <asm/uaccess.h> 17#include <asm/uaccess.h>
19#include <asm/io.h> 18#include <asm/io.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
@@ -678,7 +677,6 @@ static struct file_operations divas_fops = {
678 677
679static void divas_unregister_chrdev(void) 678static void divas_unregister_chrdev(void)
680{ 679{
681 devfs_remove(DEVNAME);
682 unregister_chrdev(major, DEVNAME); 680 unregister_chrdev(major, DEVNAME);
683} 681}
684 682
@@ -690,7 +688,6 @@ static int DIVA_INIT_FUNCTION divas_register_chrdev(void)
690 DRIVERLNAME); 688 DRIVERLNAME);
691 return (0); 689 return (0);
692 } 690 }
693 devfs_mk_cdev(MKDEV(major, 0), S_IFCHR|S_IRUSR|S_IWUSR, DEVNAME);
694 691
695 return (1); 692 return (1);
696} 693}
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 91d25acb5ede..3622720f0505 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -1688,7 +1688,7 @@ setup_hfcpci(struct IsdnCard *card)
1688 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); 1688 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
1689 return (0); 1689 return (0);
1690 } 1690 }
1691 cs->hw.hfcpci.pci_io = (char *) dev_hfcpci->resource[ 1].start; 1691 cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
1692 printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name); 1692 printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
1693 } else { 1693 } else {
1694 printk(KERN_WARNING "HFC-PCI: No PCI card found\n"); 1694 printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 9bb18f3f7829..f9c14a2970bc 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -164,7 +164,7 @@ static int sedlbauer_probe(struct pcmcia_device *link)
164 link->priv = local; 164 link->priv = local;
165 165
166 /* Interrupt setup */ 166 /* Interrupt setup */
167 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 167 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
168 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 168 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
169 link->irq.Handler = NULL; 169 link->irq.Handler = NULL;
170 170
diff --git a/drivers/isdn/hisax/teles3.c b/drivers/isdn/hisax/teles3.c
index a3eaf4d65707..090abd16b4bc 100644
--- a/drivers/isdn/hisax/teles3.c
+++ b/drivers/isdn/hisax/teles3.c
@@ -369,6 +369,7 @@ setup_teles3(struct IsdnCard *card)
369 cs->hw.teles3.hscx[1] + 96); 369 cs->hw.teles3.hscx[1] + 96);
370 return (0); 370 return (0);
371 } 371 }
372 cs->irq_flags |= SA_SHIRQ; /* cardbus can share */
372 } else { 373 } else {
373 if (cs->hw.teles3.cfg_reg) { 374 if (cs->hw.teles3.cfg_reg) {
374 if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { 375 if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
index e2bb4fd8e25e..e82ab2251b82 100644
--- a/drivers/isdn/hisax/telespci.c
+++ b/drivers/isdn/hisax/telespci.c
@@ -311,8 +311,9 @@ setup_telespci(struct IsdnCard *card)
311 } 311 }
312 cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0), 312 cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0),
313 PAGE_SIZE); 313 PAGE_SIZE);
314 printk(KERN_INFO "Found: Zoran, base-address: 0x%lx, irq: 0x%x\n", 314 printk(KERN_INFO "Found: Zoran, base-address: 0x%llx, irq: 0x%x\n",
315 pci_resource_start(dev_tel, 0), dev_tel->irq); 315 (unsigned long long)pci_resource_start(dev_tel, 0),
316 dev_tel->irq);
316 } else { 317 } else {
317 printk(KERN_WARNING "TelesPCI: No PCI card found\n"); 318 printk(KERN_WARNING "TelesPCI: No PCI card found\n");
318 return(0); 319 return(0);
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index b26e509ec759..eb21063e6f63 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -340,6 +340,16 @@ isdn_command(isdn_ctrl *cmd)
340 printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command); 340 printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command);
341 return(1); 341 return(1);
342 } 342 }
343 if (!dev->drv[cmd->driver]) {
344 printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d] NULL\n",
345 cmd->command, cmd->driver);
346 return(1);
347 }
348 if (!dev->drv[cmd->driver]->interface) {
349 printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d]->interface NULL\n",
350 cmd->command, cmd->driver);
351 return(1);
352 }
343 if (cmd->command == ISDN_CMD_SETL2) { 353 if (cmd->command == ISDN_CMD_SETL2) {
344 int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255); 354 int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255);
345 unsigned long l2prot = (cmd->arg >> 8) & 255; 355 unsigned long l2prot = (cmd->arg >> 8) & 255;
@@ -1903,6 +1913,11 @@ isdn_free_channel(int di, int ch, int usage)
1903{ 1913{
1904 int i; 1914 int i;
1905 1915
1916 if ((di < 0) || (ch < 0)) {
1917 printk(KERN_WARNING "%s: called with invalid drv(%d) or channel(%d)\n",
1918 __FUNCTION__, di, ch);
1919 return;
1920 }
1906 for (i = 0; i < ISDN_MAX_CHANNELS; i++) 1921 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
1907 if (((!usage) || ((dev->usage[i] & ISDN_USAGE_MASK) == usage)) && 1922 if (((!usage) || ((dev->usage[i] & ISDN_USAGE_MASK) == usage)) &&
1908 (dev->drvmap[i] == di) && 1923 (dev->drvmap[i] == di) &&
@@ -1918,7 +1933,8 @@ isdn_free_channel(int di, int ch, int usage)
1918 dev->v110[i] = NULL; 1933 dev->v110[i] = NULL;
1919// 20.10.99 JIM, try to reinitialize v110 ! 1934// 20.10.99 JIM, try to reinitialize v110 !
1920 isdn_info_update(); 1935 isdn_info_update();
1921 skb_queue_purge(&dev->drv[di]->rpqueue[ch]); 1936 if (dev->drv[di])
1937 skb_queue_purge(&dev->drv[di]->rpqueue[ch]);
1922 } 1938 }
1923} 1939}
1924 1940
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 2ac90242d263..0a53a990c100 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -82,7 +82,7 @@ isdn_tty_try_read(modem_info * info, struct sk_buff *skb)
82 int l = skb->len; 82 int l = skb->len;
83 unsigned char *dp = skb->data; 83 unsigned char *dp = skb->data;
84 while (--l) { 84 while (--l) {
85 if (*skb->data == DLE) 85 if (*dp == DLE)
86 tty_insert_flip_char(tty, DLE, 0); 86 tty_insert_flip_char(tty, DLE, 0);
87 tty_insert_flip_char(tty, *dp++, 0); 87 tty_insert_flip_char(tty, *dp++, 0);
88 } 88 }
@@ -1890,14 +1890,13 @@ isdn_tty_modem_init(void)
1890 if (!m->tty_modem) 1890 if (!m->tty_modem)
1891 return -ENOMEM; 1891 return -ENOMEM;
1892 m->tty_modem->name = "ttyI"; 1892 m->tty_modem->name = "ttyI";
1893 m->tty_modem->devfs_name = "isdn/ttyI";
1894 m->tty_modem->major = ISDN_TTY_MAJOR; 1893 m->tty_modem->major = ISDN_TTY_MAJOR;
1895 m->tty_modem->minor_start = 0; 1894 m->tty_modem->minor_start = 0;
1896 m->tty_modem->type = TTY_DRIVER_TYPE_SERIAL; 1895 m->tty_modem->type = TTY_DRIVER_TYPE_SERIAL;
1897 m->tty_modem->subtype = SERIAL_TYPE_NORMAL; 1896 m->tty_modem->subtype = SERIAL_TYPE_NORMAL;
1898 m->tty_modem->init_termios = tty_std_termios; 1897 m->tty_modem->init_termios = tty_std_termios;
1899 m->tty_modem->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1898 m->tty_modem->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1900 m->tty_modem->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 1899 m->tty_modem->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1901 m->tty_modem->driver_name = "isdn_tty"; 1900 m->tty_modem->driver_name = "isdn_tty";
1902 tty_set_operations(m->tty_modem, &modem_ops); 1901 tty_set_operations(m->tty_modem, &modem_ops);
1903 retval = tty_register_driver(m->tty_modem); 1902 retval = tty_register_driver(m->tty_modem);
diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
index 743ac4077f35..8b3efc243161 100644
--- a/drivers/isdn/i4l/isdn_x25iface.c
+++ b/drivers/isdn/i4l/isdn_x25iface.c
@@ -208,7 +208,7 @@ static int isdn_x25iface_receive(struct concap_proto *cprot, struct sk_buff *skb
208 */ 208 */
209static int isdn_x25iface_connect_ind(struct concap_proto *cprot) 209static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
210{ 210{
211 struct sk_buff * skb = dev_alloc_skb(1); 211 struct sk_buff * skb;
212 enum wan_states *state_p 212 enum wan_states *state_p
213 = &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state); 213 = &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state);
214 IX25DEBUG( "isdn_x25iface_connect_ind %s \n" 214 IX25DEBUG( "isdn_x25iface_connect_ind %s \n"
@@ -220,6 +220,8 @@ static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
220 return -1; 220 return -1;
221 } 221 }
222 *state_p = WAN_CONNECTED; 222 *state_p = WAN_CONNECTED;
223
224 skb = dev_alloc_skb(1);
223 if( skb ){ 225 if( skb ){
224 *( skb_put(skb, 1) ) = 0x01; 226 *( skb_put(skb, 1) ) = 0x01;
225 skb->protocol = x25_type_trans(skb, cprot->net_dev); 227 skb->protocol = x25_type_trans(skb, cprot->net_dev);
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index fe6541326c71..9b015f9af351 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -18,7 +18,7 @@
18#include <linux/leds.h> 18#include <linux/leds.h>
19#include "leds.h" 19#include "leds.h"
20 20
21rwlock_t leds_list_lock = RW_LOCK_UNLOCKED; 21DEFINE_RWLOCK(leds_list_lock);
22LIST_HEAD(leds_list); 22LIST_HEAD(leds_list);
23 23
24EXPORT_SYMBOL_GPL(leds_list); 24EXPORT_SYMBOL_GPL(leds_list);
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 5e2cd8be1191..1b1ce6523960 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -26,7 +26,7 @@
26/* 26/*
27 * Nests outside led_cdev->trigger_lock 27 * Nests outside led_cdev->trigger_lock
28 */ 28 */
29static rwlock_t triggers_list_lock = RW_LOCK_UNLOCKED; 29static DEFINE_RWLOCK(triggers_list_lock);
30static LIST_HEAD(trigger_list); 30static LIST_HEAD(trigger_list);
31 31
32ssize_t led_trigger_store(struct class_device *dev, const char *buf, 32ssize_t led_trigger_store(struct class_device *dev, const char *buf,
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 37cd6ee4586b..54f3f6b94efc 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -78,6 +78,18 @@ config ADB_PMU
78 this device; you should do so if your machine is one of those 78 this device; you should do so if your machine is one of those
79 mentioned above. 79 mentioned above.
80 80
81config ADB_PMU_LED
82 bool "Support for the Power/iBook front LED"
83 depends on ADB_PMU
84 select NEW_LEDS
85 select LEDS_CLASS
86 help
87 Support the front LED on Power/iBooks as a generic LED that can
88 be triggered by any of the supported triggers. To get the
89 behaviour of the old CONFIG_BLK_DEV_IDE_PMAC_BLINK, select this
90 and the ide-disk LED trigger and configure appropriately through
91 sysfs.
92
81config PMAC_SMU 93config PMAC_SMU
82 bool "Support for SMU based PowerMacs" 94 bool "Support for SMU based PowerMacs"
83 depends on PPC_PMAC64 95 depends on PPC_PMAC64
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 45a268f8047e..b53d45f87b0b 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_INPUT_ADBHID) += adbhid.o
12obj-$(CONFIG_ANSLCD) += ans-lcd.o 12obj-$(CONFIG_ANSLCD) += ans-lcd.o
13 13
14obj-$(CONFIG_ADB_PMU) += via-pmu.o via-pmu-event.o 14obj-$(CONFIG_ADB_PMU) += via-pmu.o via-pmu-event.o
15obj-$(CONFIG_ADB_PMU_LED) += via-pmu-led.o
15obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o 16obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o
16obj-$(CONFIG_ADB_CUDA) += via-cuda.o 17obj-$(CONFIG_ADB_CUDA) += via-cuda.o
17obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o 18obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 259fd8973ce9..9f1a049dc226 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -36,7 +36,6 @@
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/completion.h> 37#include <linux/completion.h>
38#include <linux/device.h> 38#include <linux/device.h>
39#include <linux/devfs_fs_kernel.h>
40 39
41#include <asm/uaccess.h> 40#include <asm/uaccess.h>
42#include <asm/semaphore.h> 41#include <asm/semaphore.h>
@@ -904,8 +903,6 @@ adbdev_init(void)
904 return; 903 return;
905 } 904 }
906 905
907 devfs_mk_cdev(MKDEV(ADB_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR, "adb");
908
909 adb_dev_class = class_create(THIS_MODULE, "adb"); 906 adb_dev_class = class_create(THIS_MODULE, "adb");
910 if (IS_ERR(adb_dev_class)) 907 if (IS_ERR(adb_dev_class))
911 return; 908 return;
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 431bd37225a1..c687ac703941 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -428,10 +428,10 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
428 428
429 /* MacIO itself has a different reg, we use it's PCI base */ 429 /* MacIO itself has a different reg, we use it's PCI base */
430 if (np == chip->of_node) { 430 if (np == chip->of_node) {
431 sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s", 431 sprintf(dev->ofdev.dev.bus_id, "%1d.%016llx:%.*s",
432 chip->lbus.index, 432 chip->lbus.index,
433#ifdef CONFIG_PCI 433#ifdef CONFIG_PCI
434 pci_resource_start(chip->lbus.pdev, 0), 434 (unsigned long long)pci_resource_start(chip->lbus.pdev, 0),
435#else 435#else
436 0, /* NuBus may want to do something better here */ 436 0, /* NuBus may want to do something better here */
437#endif 437#endif
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
new file mode 100644
index 000000000000..af8375ed0f5e
--- /dev/null
+++ b/drivers/macintosh/via-pmu-led.c
@@ -0,0 +1,144 @@
1/*
2 * via-pmu LED class device
3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
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, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22#include <linux/types.h>
23#include <linux/kernel.h>
24#include <linux/device.h>
25#include <linux/leds.h>
26#include <linux/adb.h>
27#include <linux/pmu.h>
28#include <asm/prom.h>
29
30static spinlock_t pmu_blink_lock;
31static struct adb_request pmu_blink_req;
32/* -1: no change, 0: request off, 1: request on */
33static int requested_change;
34static int sleeping;
35
36static void pmu_req_done(struct adb_request * req)
37{
38 unsigned long flags;
39
40 spin_lock_irqsave(&pmu_blink_lock, flags);
41 /* if someone requested a change in the meantime
42 * (we only see the last one which is fine)
43 * then apply it now */
44 if (requested_change != -1 && !sleeping)
45 pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
46 /* reset requested change */
47 requested_change = -1;
48 spin_unlock_irqrestore(&pmu_blink_lock, flags);
49}
50
51static void pmu_led_set(struct led_classdev *led_cdev,
52 enum led_brightness brightness)
53{
54 unsigned long flags;
55
56 spin_lock_irqsave(&pmu_blink_lock, flags);
57 switch (brightness) {
58 case LED_OFF:
59 requested_change = 0;
60 break;
61 case LED_FULL:
62 requested_change = 1;
63 break;
64 default:
65 goto out;
66 break;
67 }
68 /* if request isn't done, then don't do anything */
69 if (pmu_blink_req.complete && !sleeping)
70 pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
71 out:
72 spin_unlock_irqrestore(&pmu_blink_lock, flags);
73}
74
75static struct led_classdev pmu_led = {
76 .name = "pmu-front-led",
77#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
78 .default_trigger = "ide-disk",
79#endif
80 .brightness_set = pmu_led_set,
81};
82
83#ifdef CONFIG_PM
84static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
85{
86 unsigned long flags;
87
88 spin_lock_irqsave(&pmu_blink_lock, flags);
89
90 switch (when) {
91 case PBOOK_SLEEP_REQUEST:
92 sleeping = 1;
93 break;
94 case PBOOK_WAKE:
95 sleeping = 0;
96 break;
97 default:
98 /* do nothing */
99 break;
100 }
101 spin_unlock_irqrestore(&pmu_blink_lock, flags);
102
103 return PBOOK_SLEEP_OK;
104}
105
106static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
107 .notifier_call = pmu_led_sleep_call,
108};
109#endif
110
111static int __init via_pmu_led_init(void)
112{
113 struct device_node *dt;
114 const char *model;
115
116 /* only do this on keylargo based models */
117 if (pmu_get_model() != PMU_KEYLARGO_BASED)
118 return -ENODEV;
119
120 dt = of_find_node_by_path("/");
121 if (dt == NULL)
122 return -ENODEV;
123 model = (const char *)get_property(dt, "model", NULL);
124 if (model == NULL)
125 return -ENODEV;
126 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
127 strncmp(model, "iBook", strlen("iBook")) != 0) {
128 of_node_put(dt);
129 /* ignore */
130 return -ENODEV;
131 }
132 of_node_put(dt);
133
134 spin_lock_init(&pmu_blink_lock);
135 /* no outstanding req */
136 pmu_blink_req.complete = 1;
137 pmu_blink_req.done = pmu_req_done;
138#ifdef CONFIG_PM
139 pmu_register_sleep_notifier(&via_pmu_led_sleep_notif);
140#endif
141 return led_classdev_register(NULL, &pmu_led);
142}
143
144late_initcall(via_pmu_led_init);
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 3edb3477f987..d13bb15a8a02 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.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/slab.h> 15#include <linux/slab.h>
16#include <linux/devfs_fs_kernel.h>
17#include <linux/dm-ioctl.h> 16#include <linux/dm-ioctl.h>
18#include <linux/hdreg.h> 17#include <linux/hdreg.h>
19 18
@@ -68,14 +67,12 @@ static int dm_hash_init(void)
68{ 67{
69 init_buckets(_name_buckets); 68 init_buckets(_name_buckets);
70 init_buckets(_uuid_buckets); 69 init_buckets(_uuid_buckets);
71 devfs_mk_dir(DM_DIR);
72 return 0; 70 return 0;
73} 71}
74 72
75static void dm_hash_exit(void) 73static void dm_hash_exit(void)
76{ 74{
77 dm_hash_remove_all(0); 75 dm_hash_remove_all(0);
78 devfs_remove(DM_DIR);
79} 76}
80 77
81/*----------------------------------------------------------------- 78/*-----------------------------------------------------------------
@@ -172,25 +169,6 @@ static void free_cell(struct hash_cell *hc)
172} 169}
173 170
174/* 171/*
175 * devfs stuff.
176 */
177static int register_with_devfs(struct hash_cell *hc)
178{
179 struct gendisk *disk = dm_disk(hc->md);
180
181 devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
182 S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
183 DM_DIR "/%s", hc->name);
184 return 0;
185}
186
187static int unregister_with_devfs(struct hash_cell *hc)
188{
189 devfs_remove(DM_DIR"/%s", hc->name);
190 return 0;
191}
192
193/*
194 * The kdev_t and uuid of a device can never change once it is 172 * The kdev_t and uuid of a device can never change once it is
195 * initially inserted. 173 * initially inserted.
196 */ 174 */
@@ -226,7 +204,6 @@ static int dm_hash_insert(const char *name, const char *uuid, struct mapped_devi
226 } 204 }
227 list_add(&cell->uuid_list, _uuid_buckets + hash_str(uuid)); 205 list_add(&cell->uuid_list, _uuid_buckets + hash_str(uuid));
228 } 206 }
229 register_with_devfs(cell);
230 dm_get(md); 207 dm_get(md);
231 dm_set_mdptr(md, cell); 208 dm_set_mdptr(md, cell);
232 up_write(&_hash_lock); 209 up_write(&_hash_lock);
@@ -246,7 +223,6 @@ static void __hash_remove(struct hash_cell *hc)
246 /* remove from the dev hash */ 223 /* remove from the dev hash */
247 list_del(&hc->uuid_list); 224 list_del(&hc->uuid_list);
248 list_del(&hc->name_list); 225 list_del(&hc->name_list);
249 unregister_with_devfs(hc);
250 dm_set_mdptr(hc->md, NULL); 226 dm_set_mdptr(hc->md, NULL);
251 227
252 table = dm_get_table(hc->md); 228 table = dm_get_table(hc->md);
@@ -342,16 +318,11 @@ static int dm_hash_rename(const char *old, const char *new)
342 /* 318 /*
343 * rename and move the name cell. 319 * rename and move the name cell.
344 */ 320 */
345 unregister_with_devfs(hc);
346
347 list_del(&hc->name_list); 321 list_del(&hc->name_list);
348 old_name = hc->name; 322 old_name = hc->name;
349 hc->name = new_name; 323 hc->name = new_name;
350 list_add(&hc->name_list, _name_buckets + hash_str(new_name)); 324 list_add(&hc->name_list, _name_buckets + hash_str(new_name));
351 325
352 /* rename the device node in devfs */
353 register_with_devfs(hc);
354
355 /* 326 /*
356 * Wake up any dm event waiters. 327 * Wake up any dm event waiters.
357 */ 328 */
@@ -1501,7 +1472,6 @@ static struct file_operations _ctl_fops = {
1501static struct miscdevice _dm_misc = { 1472static struct miscdevice _dm_misc = {
1502 .minor = MISC_DYNAMIC_MINOR, 1473 .minor = MISC_DYNAMIC_MINOR,
1503 .name = DM_NAME, 1474 .name = DM_NAME,
1504 .devfs_name = "mapper/control",
1505 .fops = &_ctl_fops 1475 .fops = &_ctl_fops
1506}; 1476};
1507 1477
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 3ed2e53b9eb6..c99bf9f01759 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -167,7 +167,7 @@ static void local_exit(void)
167 bioset_free(dm_set); 167 bioset_free(dm_set);
168 168
169 if (unregister_blkdev(_major, _name) < 0) 169 if (unregister_blkdev(_major, _name) < 0)
170 DMERR("devfs_unregister_blkdev failed"); 170 DMERR("unregister_blkdev failed");
171 171
172 _major = 0; 172 _major = 0;
173 173
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 306268ec99ff..2ec1b3520a0b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -39,7 +39,6 @@
39#include <linux/raid/md.h> 39#include <linux/raid/md.h>
40#include <linux/raid/bitmap.h> 40#include <linux/raid/bitmap.h>
41#include <linux/sysctl.h> 41#include <linux/sysctl.h>
42#include <linux/devfs_fs_kernel.h>
43#include <linux/buffer_head.h> /* for invalidate_bdev */ 42#include <linux/buffer_head.h> /* for invalidate_bdev */
44#include <linux/suspend.h> 43#include <linux/suspend.h>
45#include <linux/poll.h> 44#include <linux/poll.h>
@@ -2911,13 +2910,10 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
2911 } 2910 }
2912 disk->major = MAJOR(dev); 2911 disk->major = MAJOR(dev);
2913 disk->first_minor = unit << shift; 2912 disk->first_minor = unit << shift;
2914 if (partitioned) { 2913 if (partitioned)
2915 sprintf(disk->disk_name, "md_d%d", unit); 2914 sprintf(disk->disk_name, "md_d%d", unit);
2916 sprintf(disk->devfs_name, "md/d%d", unit); 2915 else
2917 } else {
2918 sprintf(disk->disk_name, "md%d", unit); 2916 sprintf(disk->disk_name, "md%d", unit);
2919 sprintf(disk->devfs_name, "md/%d", unit);
2920 }
2921 disk->fops = &md_fops; 2917 disk->fops = &md_fops;
2922 disk->private_data = mddev; 2918 disk->private_data = mddev;
2923 disk->queue = mddev->queue; 2919 disk->queue = mddev->queue;
@@ -5538,8 +5534,6 @@ static void md_geninit(void)
5538 5534
5539static int __init md_init(void) 5535static int __init md_init(void)
5540{ 5536{
5541 int minor;
5542
5543 printk(KERN_INFO "md: md driver %d.%d.%d MAX_MD_DEVS=%d," 5537 printk(KERN_INFO "md: md driver %d.%d.%d MAX_MD_DEVS=%d,"
5544 " MD_SB_DISKS=%d\n", 5538 " MD_SB_DISKS=%d\n",
5545 MD_MAJOR_VERSION, MD_MINOR_VERSION, 5539 MD_MAJOR_VERSION, MD_MINOR_VERSION,
@@ -5553,23 +5547,11 @@ static int __init md_init(void)
5553 unregister_blkdev(MAJOR_NR, "md"); 5547 unregister_blkdev(MAJOR_NR, "md");
5554 return -1; 5548 return -1;
5555 } 5549 }
5556 devfs_mk_dir("md");
5557 blk_register_region(MKDEV(MAJOR_NR, 0), MAX_MD_DEVS, THIS_MODULE, 5550 blk_register_region(MKDEV(MAJOR_NR, 0), MAX_MD_DEVS, THIS_MODULE,
5558 md_probe, NULL, NULL); 5551 md_probe, NULL, NULL);
5559 blk_register_region(MKDEV(mdp_major, 0), MAX_MD_DEVS<<MdpMinorShift, THIS_MODULE, 5552 blk_register_region(MKDEV(mdp_major, 0), MAX_MD_DEVS<<MdpMinorShift, THIS_MODULE,
5560 md_probe, NULL, NULL); 5553 md_probe, NULL, NULL);
5561 5554
5562 for (minor=0; minor < MAX_MD_DEVS; ++minor)
5563 devfs_mk_bdev(MKDEV(MAJOR_NR, minor),
5564 S_IFBLK|S_IRUSR|S_IWUSR,
5565 "md/%d", minor);
5566
5567 for (minor=0; minor < MAX_MD_DEVS; ++minor)
5568 devfs_mk_bdev(MKDEV(mdp_major, minor<<MdpMinorShift),
5569 S_IFBLK|S_IRUSR|S_IWUSR,
5570 "md/mdp%d", minor);
5571
5572
5573 register_reboot_notifier(&md_notifier); 5555 register_reboot_notifier(&md_notifier);
5574 raid_table_header = register_sysctl_table(raid_root_table, 1); 5556 raid_table_header = register_sysctl_table(raid_root_table, 1);
5575 5557
@@ -5625,15 +5607,9 @@ static __exit void md_exit(void)
5625{ 5607{
5626 mddev_t *mddev; 5608 mddev_t *mddev;
5627 struct list_head *tmp; 5609 struct list_head *tmp;
5628 int i; 5610
5629 blk_unregister_region(MKDEV(MAJOR_NR,0), MAX_MD_DEVS); 5611 blk_unregister_region(MKDEV(MAJOR_NR,0), MAX_MD_DEVS);
5630 blk_unregister_region(MKDEV(mdp_major,0), MAX_MD_DEVS << MdpMinorShift); 5612 blk_unregister_region(MKDEV(mdp_major,0), MAX_MD_DEVS << MdpMinorShift);
5631 for (i=0; i < MAX_MD_DEVS; i++)
5632 devfs_remove("md/%d", i);
5633 for (i=0; i < MAX_MD_DEVS; i++)
5634 devfs_remove("md/d%d", i);
5635
5636 devfs_remove("md");
5637 5613
5638 unregister_blkdev(MAJOR_NR,"md"); 5614 unregister_blkdev(MAJOR_NR,"md");
5639 unregister_blkdev(mdp_major, "mdp"); 5615 unregister_blkdev(mdp_major, "mdp");
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f920e50ea124..837ec4eb3d60 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2827,7 +2827,6 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
2827 struct stripe_head *sh; 2827 struct stripe_head *sh;
2828 int pd_idx; 2828 int pd_idx;
2829 int raid_disks = conf->raid_disks; 2829 int raid_disks = conf->raid_disks;
2830 int data_disks = raid_disks - conf->max_degraded;
2831 sector_t max_sector = mddev->size << 1; 2830 sector_t max_sector = mddev->size << 1;
2832 int sync_blocks; 2831 int sync_blocks;
2833 int still_degraded = 0; 2832 int still_degraded = 0;
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 134c2bbbeeb5..40774feb8953 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -231,10 +231,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
231 231
232 mutex_unlock(&dvbdev_register_lock); 232 mutex_unlock(&dvbdev_register_lock);
233 233
234 devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
235 S_IFCHR | S_IRUSR | S_IWUSR,
236 "dvb/adapter%d/%s%d", adap->num, dnames[type], id);
237
238 class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 234 class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
239 adap->device, "dvb%d.%s%d", adap->num, dnames[type], id); 235 adap->device, "dvb%d.%s%d", adap->num, dnames[type], id);
240 236
@@ -252,9 +248,6 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
252 if (!dvbdev) 248 if (!dvbdev)
253 return; 249 return;
254 250
255 devfs_remove("dvb/adapter%d/%s%d", dvbdev->adapter->num,
256 dnames[dvbdev->type], dvbdev->id);
257
258 class_device_destroy(dvb_class, MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num, 251 class_device_destroy(dvb_class, MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num,
259 dvbdev->type, dvbdev->id))); 252 dvbdev->type, dvbdev->id)));
260 253
@@ -302,7 +295,6 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu
302 295
303 printk ("DVB: registering new adapter (%s).\n", name); 296 printk ("DVB: registering new adapter (%s).\n", name);
304 297
305 devfs_mk_dir("dvb/adapter%d", num);
306 adap->num = num; 298 adap->num = num;
307 adap->name = name; 299 adap->name = name;
308 adap->module = module; 300 adap->module = module;
@@ -319,8 +311,6 @@ EXPORT_SYMBOL(dvb_register_adapter);
319 311
320int dvb_unregister_adapter(struct dvb_adapter *adap) 312int dvb_unregister_adapter(struct dvb_adapter *adap)
321{ 313{
322 devfs_remove("dvb/adapter%d", adap->num);
323
324 if (mutex_lock_interruptible(&dvbdev_register_lock)) 314 if (mutex_lock_interruptible(&dvbdev_register_lock))
325 return -ERESTARTSYS; 315 return -ERESTARTSYS;
326 list_del (&adap->list_head); 316 list_del (&adap->list_head);
@@ -410,8 +400,6 @@ static int __init init_dvbdev(void)
410 goto error; 400 goto error;
411 } 401 }
412 402
413 devfs_mk_dir("dvb");
414
415 dvb_class = class_create(THIS_MODULE, "dvb"); 403 dvb_class = class_create(THIS_MODULE, "dvb");
416 if (IS_ERR(dvb_class)) { 404 if (IS_ERR(dvb_class)) {
417 retval = PTR_ERR(dvb_class); 405 retval = PTR_ERR(dvb_class);
@@ -428,7 +416,6 @@ error:
428 416
429static void __exit exit_dvbdev(void) 417static void __exit exit_dvbdev(void)
430{ 418{
431 devfs_remove("dvb");
432 class_destroy(dvb_class); 419 class_destroy(dvb_class);
433 cdev_del(&dvb_device_cdev); 420 cdev_del(&dvb_device_cdev);
434 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); 421 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index d7a976d040d7..7a7f75fd168c 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -27,7 +27,6 @@
27#include <linux/poll.h> 27#include <linux/poll.h>
28#include <linux/fs.h> 28#include <linux/fs.h>
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/devfs_fs_kernel.h>
31#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
32 31
33#define DVB_MAJOR 212 32#define DVB_MAJOR 212
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index 3e2e12124bae..9c79696da08a 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -6,10 +6,6 @@
6#include <linux/netdevice.h> 6#include <linux/netdevice.h>
7#include <linux/i2c.h> 7#include <linux/i2c.h>
8 8
9#ifdef CONFIG_DEVFS_FS
10#include <linux/devfs_fs_kernel.h>
11#endif
12
13#include <linux/dvb/video.h> 9#include <linux/dvb/video.h>
14#include <linux/dvb/audio.h> 10#include <linux/dvb/audio.h>
15#include <linux/dvb/dmx.h> 11#include <linux/dvb/dmx.h>
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 14559ef6153c..336b2fe1a5f2 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -126,10 +126,6 @@ struct ttusb {
126 126
127 int revision; 127 int revision;
128 128
129#if 0
130 devfs_handle_t stc_devfs_handle;
131#endif
132
133 struct dvb_frontend* fe; 129 struct dvb_frontend* fe;
134}; 130};
135 131
@@ -1746,13 +1742,6 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1746 return -ENODEV; 1742 return -ENODEV;
1747 } 1743 }
1748 1744
1749#if 0
1750 ttusb->stc_devfs_handle =
1751 devfs_register(ttusb->adapter->devfs_handle, TTUSB_BUDGET_NAME,
1752 DEVFS_FL_DEFAULT, 0, 192,
1753 S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
1754 | S_IROTH | S_IWOTH, &stc_fops, ttusb);
1755#endif
1756 usb_set_intfdata(intf, (void *) ttusb); 1745 usb_set_intfdata(intf, (void *) ttusb);
1757 1746
1758 frontend_init(ttusb); 1747 frontend_init(ttusb);
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c
index 87b37b7691da..c1b1db65e668 100644
--- a/drivers/media/radio/miropcm20-rds.c
+++ b/drivers/media/radio/miropcm20-rds.c
@@ -115,7 +115,6 @@ static struct file_operations rds_fops = {
115static struct miscdevice rds_miscdev = { 115static struct miscdevice rds_miscdev = {
116 .minor = MISC_DYNAMIC_MINOR, 116 .minor = MISC_DYNAMIC_MINOR,
117 .name = "radiotext", 117 .name = "radiotext",
118 .devfs_name = "v4l/rds/radiotext",
119 .fops = &rds_fops, 118 .fops = &rds_fops,
120}; 119};
121 120
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index e4290491fa9e..6d532f170ce5 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -445,6 +445,8 @@ endmenu # encoder / decoder chips
445menu "V4L USB devices" 445menu "V4L USB devices"
446 depends on USB && VIDEO_DEV 446 depends on USB && VIDEO_DEV
447 447
448source "drivers/media/video/pvrusb2/Kconfig"
449
448source "drivers/media/video/em28xx/Kconfig" 450source "drivers/media/video/em28xx/Kconfig"
449 451
450config USB_DSBR 452config USB_DSBR
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 6c401b46398a..353d61cfac1b 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/
47obj-$(CONFIG_VIDEO_CX88) += cx88/ 47obj-$(CONFIG_VIDEO_CX88) += cx88/
48obj-$(CONFIG_VIDEO_EM28XX) += em28xx/ 48obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
49obj-$(CONFIG_VIDEO_EM28XX) += tvp5150.o 49obj-$(CONFIG_VIDEO_EM28XX) += tvp5150.o
50obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
50obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o 51obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
51obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o 52obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
52obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o 53obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 6e08e32346eb..ae14f5f32039 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -20,7 +20,6 @@
20 20
21#include <linux/config.h> 21#include <linux/config.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/devfs_fs_kernel.h>
24#include <linux/module.h> 23#include <linux/module.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/errno.h> 25#include <linux/errno.h>
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 423e954948be..aa3203ae670c 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -4019,8 +4019,9 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4019 if (!request_mem_region(pci_resource_start(dev,0), 4019 if (!request_mem_region(pci_resource_start(dev,0),
4020 pci_resource_len(dev,0), 4020 pci_resource_len(dev,0),
4021 btv->c.name)) { 4021 btv->c.name)) {
4022 printk(KERN_WARNING "bttv%d: can't request iomem (0x%lx).\n", 4022 printk(KERN_WARNING "bttv%d: can't request iomem (0x%llx).\n",
4023 btv->c.nr, pci_resource_start(dev,0)); 4023 btv->c.nr,
4024 (unsigned long long)pci_resource_start(dev,0));
4024 return -EBUSY; 4025 return -EBUSY;
4025 } 4026 }
4026 pci_set_master(dev); 4027 pci_set_master(dev);
@@ -4031,8 +4032,9 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4031 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 4032 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
4032 printk(KERN_INFO "bttv%d: Bt%d (rev %d) at %s, ", 4033 printk(KERN_INFO "bttv%d: Bt%d (rev %d) at %s, ",
4033 bttv_num,btv->id, btv->revision, pci_name(dev)); 4034 bttv_num,btv->id, btv->revision, pci_name(dev));
4034 printk("irq: %d, latency: %d, mmio: 0x%lx\n", 4035 printk("irq: %d, latency: %d, mmio: 0x%llx\n",
4035 btv->c.pci->irq, lat, pci_resource_start(dev,0)); 4036 btv->c.pci->irq, lat,
4037 (unsigned long long)pci_resource_start(dev,0));
4036 schedule(); 4038 schedule();
4037 4039
4038 btv->bt848_mmio=ioremap(pci_resource_start(dev,0), 0x1000); 4040 btv->bt848_mmio=ioremap(pci_resource_start(dev,0), 0x1000);
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 01b22eab5725..65f00fc08fa9 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -601,7 +601,7 @@ static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params)
601} 601}
602 602
603int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, 603int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params,
604 struct v4l2_ext_controls *ctrls, int cmd) 604 struct v4l2_ext_controls *ctrls, unsigned int cmd)
605{ 605{
606 int err = 0; 606 int err = 0;
607 int i; 607 int i;
@@ -847,22 +847,22 @@ invalid:
847 return "<invalid>"; 847 return "<invalid>";
848} 848}
849 849
850void cx2341x_log_status(struct cx2341x_mpeg_params *p, int card_id) 850void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
851{ 851{
852 int is_mpeg1 = p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; 852 int is_mpeg1 = p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
853 853
854 /* Stream */ 854 /* Stream */
855 printk(KERN_INFO "cx2341x-%d: Stream: %s\n", 855 printk(KERN_INFO "%s: Stream: %s\n",
856 card_id, 856 prefix,
857 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE)); 857 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE));
858 858
859 /* Video */ 859 /* Video */
860 printk(KERN_INFO "cx2341x-%d: Video: %dx%d, %d fps\n", 860 printk(KERN_INFO "%s: Video: %dx%d, %d fps\n",
861 card_id, 861 prefix,
862 p->width / (is_mpeg1 ? 2 : 1), p->height / (is_mpeg1 ? 2 : 1), 862 p->width / (is_mpeg1 ? 2 : 1), p->height / (is_mpeg1 ? 2 : 1),
863 p->is_50hz ? 25 : 30); 863 p->is_50hz ? 25 : 30);
864 printk(KERN_INFO "cx2341x-%d: Video: %s, %s, %s, %d", 864 printk(KERN_INFO "%s: Video: %s, %s, %s, %d",
865 card_id, 865 prefix,
866 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ENCODING), 866 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ENCODING),
867 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ASPECT), 867 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ASPECT),
868 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_BITRATE_MODE), 868 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_BITRATE_MODE),
@@ -871,19 +871,19 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, int card_id)
871 printk(", Peak %d", p->video_bitrate_peak); 871 printk(", Peak %d", p->video_bitrate_peak);
872 } 872 }
873 printk("\n"); 873 printk("\n");
874 printk(KERN_INFO "cx2341x-%d: Video: GOP Size %d, %d B-Frames, %sGOP Closure, %s3:2 Pulldown\n", 874 printk(KERN_INFO "%s: Video: GOP Size %d, %d B-Frames, %sGOP Closure, %s3:2 Pulldown\n",
875 card_id, 875 prefix,
876 p->video_gop_size, p->video_b_frames, 876 p->video_gop_size, p->video_b_frames,
877 p->video_gop_closure ? "" : "No ", 877 p->video_gop_closure ? "" : "No ",
878 p->video_pulldown ? "" : "No "); 878 p->video_pulldown ? "" : "No ");
879 if (p->video_temporal_decimation) { 879 if (p->video_temporal_decimation) {
880 printk(KERN_INFO "cx2341x-%d: Video: Temporal Decimation %d\n", 880 printk(KERN_INFO "%s: Video: Temporal Decimation %d\n",
881 card_id, p->video_temporal_decimation); 881 prefix, p->video_temporal_decimation);
882 } 882 }
883 883
884 /* Audio */ 884 /* Audio */
885 printk(KERN_INFO "cx2341x-%d: Audio: %s, %s, %s, %s", 885 printk(KERN_INFO "%s: Audio: %s, %s, %s, %s",
886 card_id, 886 prefix,
887 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ), 887 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ),
888 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_ENCODING), 888 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_ENCODING),
889 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE), 889 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE),
@@ -897,18 +897,18 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, int card_id)
897 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_CRC)); 897 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_CRC));
898 898
899 /* Encoding filters */ 899 /* Encoding filters */
900 printk(KERN_INFO "cx2341x-%d: Spatial Filter: %s, Luma %s, Chroma %s, %d\n", 900 printk(KERN_INFO "%s: Spatial Filter: %s, Luma %s, Chroma %s, %d\n",
901 card_id, 901 prefix,
902 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE), 902 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE),
903 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE), 903 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE),
904 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE), 904 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE),
905 p->video_spatial_filter); 905 p->video_spatial_filter);
906 printk(KERN_INFO "cx2341x-%d: Temporal Filter: %s, %d\n", 906 printk(KERN_INFO "%s: Temporal Filter: %s, %d\n",
907 card_id, 907 prefix,
908 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE), 908 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE),
909 p->video_temporal_filter); 909 p->video_temporal_filter);
910 printk(KERN_INFO "cx2341x-%d: Median Filter: %s, Luma [%d, %d], Chroma [%d, %d]\n", 910 printk(KERN_INFO "%s: Median Filter: %s, Luma [%d, %d], Chroma [%d, %d]\n",
911 card_id, 911 prefix,
912 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE), 912 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE),
913 p->video_luma_median_filter_bottom, 913 p->video_luma_median_filter_bottom,
914 p->video_luma_median_filter_top, 914 p->video_luma_median_filter_top,
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 2194cbeca33b..292a5e81eb75 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -712,9 +712,9 @@ static int __devinit snd_cx88_create(struct snd_card *card,
712 pci_read_config_byte(pci, PCI_LATENCY_TIMER, &chip->pci_lat); 712 pci_read_config_byte(pci, PCI_LATENCY_TIMER, &chip->pci_lat);
713 713
714 dprintk(1,"ALSA %s/%i: found at %s, rev: %d, irq: %d, " 714 dprintk(1,"ALSA %s/%i: found at %s, rev: %d, irq: %d, "
715 "latency: %d, mmio: 0x%lx\n", core->name, devno, 715 "latency: %d, mmio: 0x%llx\n", core->name, devno,
716 pci_name(pci), chip->pci_rev, pci->irq, 716 pci_name(pci), chip->pci_rev, pci->irq,
717 chip->pci_lat,pci_resource_start(pci,0)); 717 chip->pci_lat,(unsigned long long)pci_resource_start(pci,0));
718 718
719 chip->irq = pci->irq; 719 chip->irq = pci->irq;
720 synchronize_irq(chip->irq); 720 synchronize_irq(chip->irq);
@@ -766,8 +766,8 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
766 766
767 strcpy (card->driver, "CX88x"); 767 strcpy (card->driver, "CX88x");
768 sprintf(card->shortname, "Conexant CX%x", pci->device); 768 sprintf(card->shortname, "Conexant CX%x", pci->device);
769 sprintf(card->longname, "%s at %#lx", 769 sprintf(card->longname, "%s at %#llx",
770 card->shortname, pci_resource_start(pci, 0)); 770 card->shortname,(unsigned long long)pci_resource_start(pci, 0));
771 strcpy (card->mixername, "CX88"); 771 strcpy (card->mixername, "CX88");
772 772
773 dprintk (0, "%s/%i: ALSA support for cx2388x boards\n", 773 dprintk (0, "%s/%i: ALSA support for cx2388x boards\n",
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 78df66671ea2..4ff81582ec56 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -853,6 +853,19 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
853 fh->mpegq.field); 853 fh->mpegq.field);
854 return 0; 854 return 0;
855 } 855 }
856 case VIDIOC_LOG_STATUS:
857 {
858 char name[32 + 2];
859
860 snprintf(name, sizeof(name), "%s/2", core->name);
861 printk("%s/2: ============ START LOG STATUS ============\n",
862 core->name);
863 cx88_call_i2c_clients(core, VIDIOC_LOG_STATUS, 0);
864 cx2341x_log_status(&dev->params, name);
865 printk("%s/2: ============= END LOG STATUS =============\n",
866 core->name);
867 return 0;
868 }
856 869
857 default: 870 default:
858 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl); 871 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 26f4c0fb8c36..973d3f39b2d5 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1031,8 +1031,8 @@ static int get_ressources(struct cx88_core *core, struct pci_dev *pci)
1031 pci_resource_len(pci,0), 1031 pci_resource_len(pci,0),
1032 core->name)) 1032 core->name))
1033 return 0; 1033 return 0;
1034 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%lx\n", 1034 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n",
1035 core->name,pci_resource_start(pci,0)); 1035 core->name,(unsigned long long)pci_resource_start(pci,0));
1036 return -EBUSY; 1036 return -EBUSY;
1037} 1037}
1038 1038
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index a9d7795a8e14..2c12aca1b6a3 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -420,9 +420,9 @@ int cx8802_init_common(struct cx8802_dev *dev)
420 pci_read_config_byte(dev->pci, PCI_CLASS_REVISION, &dev->pci_rev); 420 pci_read_config_byte(dev->pci, PCI_CLASS_REVISION, &dev->pci_rev);
421 pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER, &dev->pci_lat); 421 pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER, &dev->pci_lat);
422 printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, " 422 printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, "
423 "latency: %d, mmio: 0x%lx\n", dev->core->name, 423 "latency: %d, mmio: 0x%llx\n", dev->core->name,
424 pci_name(dev->pci), dev->pci_rev, dev->pci->irq, 424 pci_name(dev->pci), dev->pci_rev, dev->pci->irq,
425 dev->pci_lat,pci_resource_start(dev->pci,0)); 425 dev->pci_lat,(unsigned long long)pci_resource_start(dev->pci,0));
426 426
427 /* initialize driver struct */ 427 /* initialize driver struct */
428 spin_lock_init(&dev->slock); 428 spin_lock_init(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index dcda5291b990..8d5cf474b68e 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1847,9 +1847,9 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1847 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev); 1847 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
1848 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); 1848 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
1849 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " 1849 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, "
1850 "latency: %d, mmio: 0x%lx\n", core->name, 1850 "latency: %d, mmio: 0x%llx\n", core->name,
1851 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, 1851 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
1852 dev->pci_lat,pci_resource_start(pci_dev,0)); 1852 dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
1853 1853
1854 pci_set_master(pci_dev); 1854 pci_set_master(pci_dev);
1855 if (!pci_dma_supported(pci_dev,0xffffffff)) { 1855 if (!pci_dma_supported(pci_dev,0xffffffff)) {
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
new file mode 100644
index 000000000000..7e727fe14b32
--- /dev/null
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -0,0 +1,62 @@
1config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && USB && I2C && EXPERIMENTAL
4 select FW_LOADER
5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM
7 select VIDEO_CX2341X
8 select VIDEO_SAA711X
9 select VIDEO_MSP3400
10 ---help---
11 This is a video4linux driver for Conexant 23416 based
12 usb2 personal video recorder devices.
13
14 To compile this driver as a module, choose M here: the
15 module will be called pvrusb2
16
17config VIDEO_PVRUSB2_24XXX
18 bool "Hauppauge WinTV-PVR USB2 support for 24xxx model series"
19 depends on VIDEO_PVRUSB2 && EXPERIMENTAL
20 select VIDEO_CX25840
21 select VIDEO_WM8775
22 ---help---
23 This option enables inclusion of additional logic to operate
24 newer WinTV-PVR USB2 devices whose model number is of the
25 form "24xxx" (leading prefix of "24" followed by 3 digits).
26 To see if you may need this option, examine the white
27 sticker on the underside of your device. Enabling this
28 option will not harm support for older devices, however it
29 is a separate option because of the experimental nature of
30 this new feature.
31
32 If you are in doubt, say N.
33
34 Note: This feature is _very_ experimental. You have been
35 warned.
36
37config VIDEO_PVRUSB2_SYSFS
38 bool "pvrusb2 sysfs support (EXPERIMENTAL)"
39 default y
40 depends on VIDEO_PVRUSB2 && SYSFS && EXPERIMENTAL
41 ---help---
42 This option enables the operation of a sysfs based
43 interface for query and control of the pvrusb2 driver.
44
45 This is not generally needed for v4l applications,
46 although certain applications are optimized to take
47 advantage of this feature.
48
49 If you are in doubt, say Y.
50
51 Note: This feature is experimental and subject to change.
52
53config VIDEO_PVRUSB2_DEBUGIFC
54 bool "pvrusb2 debug interface"
55 depends on VIDEO_PVRUSB2_SYSFS
56 ---help---
57 This option enables the inclusion of a debug interface
58 in the pvrusb2 driver, hosted through sysfs.
59
60 You do not need to select this option unless you plan
61 on debugging the driver or performing a manual firmware
62 extraction.
diff --git a/drivers/media/video/pvrusb2/Makefile b/drivers/media/video/pvrusb2/Makefile
new file mode 100644
index 000000000000..fed603ad0a67
--- /dev/null
+++ b/drivers/media/video/pvrusb2/Makefile
@@ -0,0 +1,18 @@
1obj-pvrusb2-sysfs-$(CONFIG_VIDEO_PVRUSB2_SYSFS) := pvrusb2-sysfs.o
2obj-pvrusb2-debugifc-$(CONFIG_VIDEO_PVRUSB2_DEBUGIFC) := pvrusb2-debugifc.o
3
4obj-pvrusb2-24xxx-$(CONFIG_VIDEO_PVRUSB2_24XXX) := \
5 pvrusb2-cx2584x-v4l.o \
6 pvrusb2-wm8775.o
7
8pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \
9 pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \
10 pvrusb2-encoder.o pvrusb2-video-v4l.o \
11 pvrusb2-eeprom.o pvrusb2-tuner.o pvrusb2-demod.o \
12 pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \
13 pvrusb2-ctrl.o pvrusb2-std.o \
14 pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \
15 $(obj-pvrusb2-24xxx-y) \
16 $(obj-pvrusb2-sysfs-y) $(obj-pvrusb2-debugifc-y)
17
18obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c
new file mode 100644
index 000000000000..313d2dcf9e4b
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -0,0 +1,204 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "pvrusb2-audio.h"
24#include "pvrusb2-hdw-internal.h"
25#include "pvrusb2-debug.h"
26#include <linux/videodev2.h>
27#include <media/msp3400.h>
28#include <media/v4l2-common.h>
29
30struct pvr2_msp3400_handler {
31 struct pvr2_hdw *hdw;
32 struct pvr2_i2c_client *client;
33 struct pvr2_i2c_handler i2c_handler;
34 struct pvr2_audio_stat astat;
35 unsigned long stale_mask;
36};
37
38
39/* This function selects the correct audio input source */
40static void set_stereo(struct pvr2_msp3400_handler *ctxt)
41{
42 struct pvr2_hdw *hdw = ctxt->hdw;
43 struct v4l2_routing route;
44
45 pvr2_trace(PVR2_TRACE_CHIPS,"i2c msp3400 v4l2 set_stereo");
46
47 if (hdw->input_val == PVR2_CVAL_INPUT_TV) {
48 struct v4l2_tuner vt;
49 memset(&vt,0,sizeof(vt));
50 vt.audmode = hdw->audiomode_val;
51 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_S_TUNER,&vt);
52 }
53
54 route.input = MSP_INPUT_DEFAULT;
55 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
56 switch (hdw->input_val) {
57 case PVR2_CVAL_INPUT_TV:
58 break;
59 case PVR2_CVAL_INPUT_RADIO:
60 /* Assume that msp34xx also handle FM decoding, in which case
61 we're still using the tuner. */
62 /* HV: actually it is more likely to be the SCART2 input if
63 the ivtv experience is any indication. */
64 route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
65 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
66 break;
67 case PVR2_CVAL_INPUT_SVIDEO:
68 case PVR2_CVAL_INPUT_COMPOSITE:
69 /* SCART 1 input */
70 route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
71 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
72 break;
73 }
74 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route);
75}
76
77
78static int check_stereo(struct pvr2_msp3400_handler *ctxt)
79{
80 struct pvr2_hdw *hdw = ctxt->hdw;
81 return (hdw->input_dirty ||
82 hdw->audiomode_dirty);
83}
84
85
86struct pvr2_msp3400_ops {
87 void (*update)(struct pvr2_msp3400_handler *);
88 int (*check)(struct pvr2_msp3400_handler *);
89};
90
91
92static const struct pvr2_msp3400_ops msp3400_ops[] = {
93 { .update = set_stereo, .check = check_stereo},
94};
95
96
97static int msp3400_check(struct pvr2_msp3400_handler *ctxt)
98{
99 unsigned long msk;
100 unsigned int idx;
101
102 for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]);
103 idx++) {
104 msk = 1 << idx;
105 if (ctxt->stale_mask & msk) continue;
106 if (msp3400_ops[idx].check(ctxt)) {
107 ctxt->stale_mask |= msk;
108 }
109 }
110 return ctxt->stale_mask != 0;
111}
112
113
114static void msp3400_update(struct pvr2_msp3400_handler *ctxt)
115{
116 unsigned long msk;
117 unsigned int idx;
118
119 for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]);
120 idx++) {
121 msk = 1 << idx;
122 if (!(ctxt->stale_mask & msk)) continue;
123 ctxt->stale_mask &= ~msk;
124 msp3400_ops[idx].update(ctxt);
125 }
126}
127
128
129/* This reads back the current signal type */
130static int get_audio_status(struct pvr2_msp3400_handler *ctxt)
131{
132 struct v4l2_tuner vt;
133 int stat;
134
135 memset(&vt,0,sizeof(vt));
136 stat = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_G_TUNER,&vt);
137 if (stat < 0) return stat;
138
139 ctxt->hdw->flag_stereo = (vt.audmode & V4L2_TUNER_MODE_STEREO) != 0;
140 ctxt->hdw->flag_bilingual =
141 (vt.audmode & V4L2_TUNER_MODE_LANG2) != 0;
142 return 0;
143}
144
145
146static void pvr2_msp3400_detach(struct pvr2_msp3400_handler *ctxt)
147{
148 ctxt->client->handler = 0;
149 ctxt->hdw->audio_stat = 0;
150 kfree(ctxt);
151}
152
153
154static unsigned int pvr2_msp3400_describe(struct pvr2_msp3400_handler *ctxt,
155 char *buf,unsigned int cnt)
156{
157 return scnprintf(buf,cnt,"handler: pvrusb2-audio v4l2");
158}
159
160
161const static struct pvr2_i2c_handler_functions msp3400_funcs = {
162 .detach = (void (*)(void *))pvr2_msp3400_detach,
163 .check = (int (*)(void *))msp3400_check,
164 .update = (void (*)(void *))msp3400_update,
165 .describe = (unsigned int (*)(void *,char *,unsigned int))pvr2_msp3400_describe,
166};
167
168
169int pvr2_i2c_msp3400_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
170{
171 struct pvr2_msp3400_handler *ctxt;
172 if (hdw->audio_stat) return 0;
173 if (cp->handler) return 0;
174
175 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
176 if (!ctxt) return 0;
177 memset(ctxt,0,sizeof(*ctxt));
178
179 ctxt->i2c_handler.func_data = ctxt;
180 ctxt->i2c_handler.func_table = &msp3400_funcs;
181 ctxt->client = cp;
182 ctxt->hdw = hdw;
183 ctxt->astat.ctxt = ctxt;
184 ctxt->astat.status = (int (*)(void *))get_audio_status;
185 ctxt->astat.detach = (void (*)(void *))pvr2_msp3400_detach;
186 ctxt->stale_mask = (1 << (sizeof(msp3400_ops)/
187 sizeof(msp3400_ops[0]))) - 1;
188 cp->handler = &ctxt->i2c_handler;
189 hdw->audio_stat = &ctxt->astat;
190 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x msp3400 V4L2 handler set up",
191 cp->client->addr);
192 return !0;
193}
194
195
196/*
197 Stuff for Emacs to see, in order to encourage consistent editing style:
198 *** Local Variables: ***
199 *** mode: c ***
200 *** fill-column: 70 ***
201 *** tab-width: 8 ***
202 *** c-basic-offset: 8 ***
203 *** End: ***
204 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.h b/drivers/media/video/pvrusb2/pvrusb2-audio.h
new file mode 100644
index 000000000000..536339b68843
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-audio.h
@@ -0,0 +1,40 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_AUDIO_H
24#define __PVRUSB2_AUDIO_H
25
26#include "pvrusb2-i2c-core.h"
27
28int pvr2_i2c_msp3400_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
29
30#endif /* __PVRUSB2_AUDIO_H */
31
32/*
33 Stuff for Emacs to see, in order to encourage consistent editing style:
34 *** Local Variables: ***
35 *** mode: c ***
36 *** fill-column: 70 ***
37 *** tab-width: 8 ***
38 *** c-basic-offset: 8 ***
39 *** End: ***
40 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
new file mode 100644
index 000000000000..40dc59871a45
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -0,0 +1,230 @@
1/*
2 * $Id$
3 *
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include "pvrusb2-context.h"
22#include "pvrusb2-io.h"
23#include "pvrusb2-ioread.h"
24#include "pvrusb2-hdw.h"
25#include "pvrusb2-debug.h"
26#include <linux/errno.h>
27#include <linux/string.h>
28#include <linux/slab.h>
29#include <asm/semaphore.h>
30
31
32static void pvr2_context_destroy(struct pvr2_context *mp)
33{
34 if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
35 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr_main id=%p",mp);
36 flush_workqueue(mp->workqueue);
37 destroy_workqueue(mp->workqueue);
38 kfree(mp);
39}
40
41
42static void pvr2_context_trigger_poll(struct pvr2_context *mp)
43{
44 queue_work(mp->workqueue,&mp->workpoll);
45}
46
47
48static void pvr2_context_poll(struct pvr2_context *mp)
49{
50 pvr2_context_enter(mp); do {
51 pvr2_hdw_poll(mp->hdw);
52 } while (0); pvr2_context_exit(mp);
53}
54
55
56static void pvr2_context_setup(struct pvr2_context *mp)
57{
58 pvr2_context_enter(mp); do {
59 if (!pvr2_hdw_dev_ok(mp->hdw)) break;
60 pvr2_hdw_setup(mp->hdw);
61 pvr2_hdw_setup_poll_trigger(
62 mp->hdw,
63 (void (*)(void *))pvr2_context_trigger_poll,
64 mp);
65 if (!pvr2_hdw_dev_ok(mp->hdw)) break;
66 if (!pvr2_hdw_init_ok(mp->hdw)) break;
67 mp->video_stream.stream = pvr2_hdw_get_video_stream(mp->hdw);
68 if (mp->setup_func) {
69 mp->setup_func(mp);
70 }
71 } while (0); pvr2_context_exit(mp);
72}
73
74
75struct pvr2_context *pvr2_context_create(
76 struct usb_interface *intf,
77 const struct usb_device_id *devid,
78 void (*setup_func)(struct pvr2_context *))
79{
80 struct pvr2_context *mp = 0;
81 mp = kmalloc(sizeof(*mp),GFP_KERNEL);
82 if (!mp) goto done;
83 memset(mp,0,sizeof(*mp));
84 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_main id=%p",mp);
85 mp->setup_func = setup_func;
86 mutex_init(&mp->mutex);
87 mp->hdw = pvr2_hdw_create(intf,devid);
88 if (!mp->hdw) {
89 pvr2_context_destroy(mp);
90 mp = 0;
91 goto done;
92 }
93
94 mp->workqueue = create_singlethread_workqueue("pvrusb2");
95 INIT_WORK(&mp->workinit,(void (*)(void*))pvr2_context_setup,mp);
96 INIT_WORK(&mp->workpoll,(void (*)(void*))pvr2_context_poll,mp);
97 queue_work(mp->workqueue,&mp->workinit);
98 done:
99 return mp;
100}
101
102
103void pvr2_context_enter(struct pvr2_context *mp)
104{
105 mutex_lock(&mp->mutex);
106 pvr2_trace(PVR2_TRACE_CREG,"pvr2_context_enter(id=%p)",mp);
107}
108
109
110void pvr2_context_exit(struct pvr2_context *mp)
111{
112 int destroy_flag = 0;
113 if (!(mp->mc_first || !mp->disconnect_flag)) {
114 destroy_flag = !0;
115 }
116 pvr2_trace(PVR2_TRACE_CREG,"pvr2_context_exit(id=%p) outside",mp);
117 mutex_unlock(&mp->mutex);
118 if (destroy_flag) pvr2_context_destroy(mp);
119}
120
121
122static void pvr2_context_run_checks(struct pvr2_context *mp)
123{
124 struct pvr2_channel *ch1,*ch2;
125 for (ch1 = mp->mc_first; ch1; ch1 = ch2) {
126 ch2 = ch1->mc_next;
127 if (ch1->check_func) {
128 ch1->check_func(ch1);
129 }
130 }
131}
132
133
134void pvr2_context_disconnect(struct pvr2_context *mp)
135{
136 pvr2_context_enter(mp); do {
137 pvr2_hdw_disconnect(mp->hdw);
138 mp->disconnect_flag = !0;
139 pvr2_context_run_checks(mp);
140 } while (0); pvr2_context_exit(mp);
141}
142
143
144void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp)
145{
146 cp->hdw = mp->hdw;
147 cp->mc_head = mp;
148 cp->mc_next = 0;
149 cp->mc_prev = mp->mc_last;
150 if (mp->mc_last) {
151 mp->mc_last->mc_next = cp;
152 } else {
153 mp->mc_first = cp;
154 }
155 mp->mc_last = cp;
156}
157
158
159static void pvr2_channel_disclaim_stream(struct pvr2_channel *cp)
160{
161 if (!cp->stream) return;
162 pvr2_stream_kill(cp->stream->stream);
163 cp->stream->user = 0;
164 cp->stream = 0;
165}
166
167
168void pvr2_channel_done(struct pvr2_channel *cp)
169{
170 struct pvr2_context *mp = cp->mc_head;
171 pvr2_channel_disclaim_stream(cp);
172 if (cp->mc_next) {
173 cp->mc_next->mc_prev = cp->mc_prev;
174 } else {
175 mp->mc_last = cp->mc_prev;
176 }
177 if (cp->mc_prev) {
178 cp->mc_prev->mc_next = cp->mc_next;
179 } else {
180 mp->mc_first = cp->mc_next;
181 }
182 cp->hdw = 0;
183}
184
185
186int pvr2_channel_claim_stream(struct pvr2_channel *cp,
187 struct pvr2_context_stream *sp)
188{
189 int code = 0;
190 pvr2_context_enter(cp->mc_head); do {
191 if (sp == cp->stream) break;
192 if (sp->user) {
193 code = -EBUSY;
194 break;
195 }
196 pvr2_channel_disclaim_stream(cp);
197 if (!sp) break;
198 sp->user = cp;
199 cp->stream = sp;
200 } while (0); pvr2_context_exit(cp->mc_head);
201 return code;
202}
203
204
205// This is the marker for the real beginning of a legitimate mpeg2 stream.
206static char stream_sync_key[] = {
207 0x00, 0x00, 0x01, 0xba,
208};
209
210struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
211 struct pvr2_context_stream *sp)
212{
213 struct pvr2_ioread *cp;
214 cp = pvr2_ioread_create();
215 if (!cp) return 0;
216 pvr2_ioread_setup(cp,sp->stream);
217 pvr2_ioread_set_sync_key(cp,stream_sync_key,sizeof(stream_sync_key));
218 return cp;
219}
220
221
222/*
223 Stuff for Emacs to see, in order to encourage consistent editing style:
224 *** Local Variables: ***
225 *** mode: c ***
226 *** fill-column: 75 ***
227 *** tab-width: 8 ***
228 *** c-basic-offset: 8 ***
229 *** End: ***
230 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.h b/drivers/media/video/pvrusb2/pvrusb2-context.h
new file mode 100644
index 000000000000..6327fa1f7e4f
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.h
@@ -0,0 +1,92 @@
1/*
2 * $Id$
3 *
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20#ifndef __PVRUSB2_BASE_H
21#define __PVRUSB2_BASE_H
22
23#include <linux/mutex.h>
24#include <linux/usb.h>
25#include <linux/workqueue.h>
26
27struct pvr2_hdw; /* hardware interface - defined elsewhere */
28struct pvr2_stream; /* stream interface - defined elsewhere */
29
30struct pvr2_context; /* All central state */
31struct pvr2_channel; /* One I/O pathway to a user */
32struct pvr2_context_stream; /* Wrapper for a stream */
33struct pvr2_crit_reg; /* Critical region pointer */
34struct pvr2_ioread; /* Low level stream structure */
35
36struct pvr2_context_stream {
37 struct pvr2_channel *user;
38 struct pvr2_stream *stream;
39};
40
41struct pvr2_context {
42 struct pvr2_channel *mc_first;
43 struct pvr2_channel *mc_last;
44 struct pvr2_hdw *hdw;
45 struct pvr2_context_stream video_stream;
46 struct mutex mutex;
47 int disconnect_flag;
48
49 /* Called after pvr2_context initialization is complete */
50 void (*setup_func)(struct pvr2_context *);
51
52 /* Work queue overhead for out-of-line processing */
53 struct workqueue_struct *workqueue;
54 struct work_struct workinit;
55 struct work_struct workpoll;
56};
57
58struct pvr2_channel {
59 struct pvr2_context *mc_head;
60 struct pvr2_channel *mc_next;
61 struct pvr2_channel *mc_prev;
62 struct pvr2_context_stream *stream;
63 struct pvr2_hdw *hdw;
64 void (*check_func)(struct pvr2_channel *);
65};
66
67void pvr2_context_enter(struct pvr2_context *);
68void pvr2_context_exit(struct pvr2_context *);
69
70struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
71 const struct usb_device_id *devid,
72 void (*setup_func)(struct pvr2_context *));
73void pvr2_context_disconnect(struct pvr2_context *);
74
75void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *);
76void pvr2_channel_done(struct pvr2_channel *);
77int pvr2_channel_claim_stream(struct pvr2_channel *,
78 struct pvr2_context_stream *);
79struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
80 struct pvr2_context_stream *);
81
82
83#endif /* __PVRUSB2_CONTEXT_H */
84/*
85 Stuff for Emacs to see, in order to encourage consistent editing style:
86 *** Local Variables: ***
87 *** mode: c ***
88 *** fill-column: 75 ***
89 *** tab-width: 8 ***
90 *** c-basic-offset: 8 ***
91 *** End: ***
92 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
new file mode 100644
index 000000000000..d5df9fbeba2f
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -0,0 +1,593 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include "pvrusb2-ctrl.h"
23#include "pvrusb2-hdw-internal.h"
24#include <linux/errno.h>
25#include <linux/string.h>
26#include <linux/mutex.h>
27
28
29/* Set the given control. */
30int pvr2_ctrl_set_value(struct pvr2_ctrl *cptr,int val)
31{
32 return pvr2_ctrl_set_mask_value(cptr,~0,val);
33}
34
35
36/* Set/clear specific bits of the given control. */
37int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
38{
39 int ret = 0;
40 if (!cptr) return -EINVAL;
41 LOCK_TAKE(cptr->hdw->big_lock); do {
42 if (cptr->info->set_value != 0) {
43 if (cptr->info->type == pvr2_ctl_bitmask) {
44 mask &= cptr->info->def.type_bitmask.valid_bits;
45 } else if (cptr->info->type == pvr2_ctl_int) {
46 if (val < cptr->info->def.type_int.min_value) {
47 break;
48 }
49 if (val > cptr->info->def.type_int.max_value) {
50 break;
51 }
52 } else if (cptr->info->type == pvr2_ctl_enum) {
53 if (val >= cptr->info->def.type_enum.count) {
54 break;
55 }
56 } else if (cptr->info->type != pvr2_ctl_bool) {
57 break;
58 }
59 ret = cptr->info->set_value(cptr,mask,val);
60 } else {
61 ret = -EPERM;
62 }
63 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
64 return ret;
65}
66
67
68/* Get the current value of the given control. */
69int pvr2_ctrl_get_value(struct pvr2_ctrl *cptr,int *valptr)
70{
71 int ret = 0;
72 if (!cptr) return -EINVAL;
73 LOCK_TAKE(cptr->hdw->big_lock); do {
74 ret = cptr->info->get_value(cptr,valptr);
75 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
76 return ret;
77}
78
79
80/* Retrieve control's type */
81enum pvr2_ctl_type pvr2_ctrl_get_type(struct pvr2_ctrl *cptr)
82{
83 if (!cptr) return pvr2_ctl_int;
84 return cptr->info->type;
85}
86
87
88/* Retrieve control's maximum value (int type) */
89int pvr2_ctrl_get_max(struct pvr2_ctrl *cptr)
90{
91 int ret = 0;
92 if (!cptr) return 0;
93 LOCK_TAKE(cptr->hdw->big_lock); do {
94 if (cptr->info->type == pvr2_ctl_int) {
95 ret = cptr->info->def.type_int.max_value;
96 }
97 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
98 return ret;
99}
100
101
102/* Retrieve control's minimum value (int type) */
103int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr)
104{
105 int ret = 0;
106 if (!cptr) return 0;
107 LOCK_TAKE(cptr->hdw->big_lock); do {
108 if (cptr->info->type == pvr2_ctl_int) {
109 ret = cptr->info->def.type_int.min_value;
110 }
111 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
112 return ret;
113}
114
115
116/* Retrieve control's default value (any type) */
117int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr)
118{
119 int ret = 0;
120 if (!cptr) return 0;
121 LOCK_TAKE(cptr->hdw->big_lock); do {
122 if (cptr->info->type == pvr2_ctl_int) {
123 ret = cptr->info->default_value;
124 }
125 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
126 return ret;
127}
128
129
130/* Retrieve control's enumeration count (enum only) */
131int pvr2_ctrl_get_cnt(struct pvr2_ctrl *cptr)
132{
133 int ret = 0;
134 if (!cptr) return 0;
135 LOCK_TAKE(cptr->hdw->big_lock); do {
136 if (cptr->info->type == pvr2_ctl_enum) {
137 ret = cptr->info->def.type_enum.count;
138 }
139 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
140 return ret;
141}
142
143
144/* Retrieve control's valid mask bits (bit mask only) */
145int pvr2_ctrl_get_mask(struct pvr2_ctrl *cptr)
146{
147 int ret = 0;
148 if (!cptr) return 0;
149 LOCK_TAKE(cptr->hdw->big_lock); do {
150 if (cptr->info->type == pvr2_ctl_bitmask) {
151 ret = cptr->info->def.type_bitmask.valid_bits;
152 }
153 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
154 return ret;
155}
156
157
158/* Retrieve the control's name */
159const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr)
160{
161 if (!cptr) return 0;
162 return cptr->info->name;
163}
164
165
166/* Retrieve the control's desc */
167const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *cptr)
168{
169 if (!cptr) return 0;
170 return cptr->info->desc;
171}
172
173
174/* Retrieve a control enumeration or bit mask value */
175int pvr2_ctrl_get_valname(struct pvr2_ctrl *cptr,int val,
176 char *bptr,unsigned int bmax,
177 unsigned int *blen)
178{
179 int ret = -EINVAL;
180 if (!cptr) return 0;
181 *blen = 0;
182 LOCK_TAKE(cptr->hdw->big_lock); do {
183 if (cptr->info->type == pvr2_ctl_enum) {
184 const char **names;
185 names = cptr->info->def.type_enum.value_names;
186 if ((val >= 0) &&
187 (val < cptr->info->def.type_enum.count)) {
188 if (names[val]) {
189 *blen = scnprintf(
190 bptr,bmax,"%s",
191 names[val]);
192 } else {
193 *blen = 0;
194 }
195 ret = 0;
196 }
197 } else if (cptr->info->type == pvr2_ctl_bitmask) {
198 const char **names;
199 unsigned int idx;
200 int msk;
201 names = cptr->info->def.type_bitmask.bit_names;
202 val &= cptr->info->def.type_bitmask.valid_bits;
203 for (idx = 0, msk = 1; val; idx++, msk <<= 1) {
204 if (val & msk) {
205 *blen = scnprintf(bptr,bmax,"%s",
206 names[idx]);
207 ret = 0;
208 break;
209 }
210 }
211 }
212 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
213 return ret;
214}
215
216
217/* Return V4L ID for this control or zero if none */
218int pvr2_ctrl_get_v4lid(struct pvr2_ctrl *cptr)
219{
220 if (!cptr) return 0;
221 return cptr->info->v4l_id;
222}
223
224
225unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *cptr)
226{
227 unsigned int flags = 0;
228
229 if (cptr->info->get_v4lflags) {
230 flags = cptr->info->get_v4lflags(cptr);
231 }
232
233 if (cptr->info->set_value) {
234 flags &= ~V4L2_CTRL_FLAG_READ_ONLY;
235 } else {
236 flags |= V4L2_CTRL_FLAG_READ_ONLY;
237 }
238
239 return flags;
240}
241
242
243/* Return true if control is writable */
244int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr)
245{
246 if (!cptr) return 0;
247 return cptr->info->set_value != 0;
248}
249
250
251/* Return true if control has custom symbolic representation */
252int pvr2_ctrl_has_custom_symbols(struct pvr2_ctrl *cptr)
253{
254 if (!cptr) return 0;
255 if (!cptr->info->val_to_sym) return 0;
256 if (!cptr->info->sym_to_val) return 0;
257 return !0;
258}
259
260
261/* Convert a given mask/val to a custom symbolic value */
262int pvr2_ctrl_custom_value_to_sym(struct pvr2_ctrl *cptr,
263 int mask,int val,
264 char *buf,unsigned int maxlen,
265 unsigned int *len)
266{
267 if (!cptr) return -EINVAL;
268 if (!cptr->info->val_to_sym) return -EINVAL;
269 return cptr->info->val_to_sym(cptr,mask,val,buf,maxlen,len);
270}
271
272
273/* Convert a symbolic value to a mask/value pair */
274int pvr2_ctrl_custom_sym_to_value(struct pvr2_ctrl *cptr,
275 const char *buf,unsigned int len,
276 int *maskptr,int *valptr)
277{
278 if (!cptr) return -EINVAL;
279 if (!cptr->info->sym_to_val) return -EINVAL;
280 return cptr->info->sym_to_val(cptr,buf,len,maskptr,valptr);
281}
282
283
284static unsigned int gen_bitmask_string(int msk,int val,int msk_only,
285 const char **names,
286 char *ptr,unsigned int len)
287{
288 unsigned int idx;
289 long sm,um;
290 int spcFl;
291 unsigned int uc,cnt;
292 const char *idStr;
293
294 spcFl = 0;
295 uc = 0;
296 um = 0;
297 for (idx = 0, sm = 1; msk; idx++, sm <<= 1) {
298 if (sm & msk) {
299 msk &= ~sm;
300 idStr = names[idx];
301 if (idStr) {
302 cnt = scnprintf(ptr,len,"%s%s%s",
303 (spcFl ? " " : ""),
304 (msk_only ? "" :
305 ((val & sm) ? "+" : "-")),
306 idStr);
307 ptr += cnt; len -= cnt; uc += cnt;
308 spcFl = !0;
309 } else {
310 um |= sm;
311 }
312 }
313 }
314 if (um) {
315 if (msk_only) {
316 cnt = scnprintf(ptr,len,"%s0x%lx",
317 (spcFl ? " " : ""),
318 um);
319 ptr += cnt; len -= cnt; uc += cnt;
320 spcFl = !0;
321 } else if (um & val) {
322 cnt = scnprintf(ptr,len,"%s+0x%lx",
323 (spcFl ? " " : ""),
324 um & val);
325 ptr += cnt; len -= cnt; uc += cnt;
326 spcFl = !0;
327 } else if (um & ~val) {
328 cnt = scnprintf(ptr,len,"%s+0x%lx",
329 (spcFl ? " " : ""),
330 um & ~val);
331 ptr += cnt; len -= cnt; uc += cnt;
332 spcFl = !0;
333 }
334 }
335 return uc;
336}
337
338
339static const char *boolNames[] = {
340 "false",
341 "true",
342 "no",
343 "yes",
344};
345
346
347static int parse_token(const char *ptr,unsigned int len,
348 int *valptr,
349 const char **names,unsigned int namecnt)
350{
351 char buf[33];
352 unsigned int slen;
353 unsigned int idx;
354 int negfl;
355 char *p2;
356 *valptr = 0;
357 if (!names) namecnt = 0;
358 for (idx = 0; idx < namecnt; idx++) {
359 if (!names[idx]) continue;
360 slen = strlen(names[idx]);
361 if (slen != len) continue;
362 if (memcmp(names[idx],ptr,slen)) continue;
363 *valptr = idx;
364 return 0;
365 }
366 negfl = 0;
367 if ((*ptr == '-') || (*ptr == '+')) {
368 negfl = (*ptr == '-');
369 ptr++; len--;
370 }
371 if (len >= sizeof(buf)) return -EINVAL;
372 memcpy(buf,ptr,len);
373 buf[len] = 0;
374 *valptr = simple_strtol(buf,&p2,0);
375 if (negfl) *valptr = -(*valptr);
376 if (*p2) return -EINVAL;
377 return 1;
378}
379
380
381static int parse_mtoken(const char *ptr,unsigned int len,
382 int *valptr,
383 const char **names,int valid_bits)
384{
385 char buf[33];
386 unsigned int slen;
387 unsigned int idx;
388 char *p2;
389 int msk;
390 *valptr = 0;
391 for (idx = 0, msk = 1; valid_bits; idx++, msk <<= 1) {
392 if (!msk & valid_bits) continue;
393 valid_bits &= ~msk;
394 if (!names[idx]) continue;
395 slen = strlen(names[idx]);
396 if (slen != len) continue;
397 if (memcmp(names[idx],ptr,slen)) continue;
398 *valptr = msk;
399 return 0;
400 }
401 if (len >= sizeof(buf)) return -EINVAL;
402 memcpy(buf,ptr,len);
403 buf[len] = 0;
404 *valptr = simple_strtol(buf,&p2,0);
405 if (*p2) return -EINVAL;
406 return 0;
407}
408
409
410static int parse_tlist(const char *ptr,unsigned int len,
411 int *maskptr,int *valptr,
412 const char **names,int valid_bits)
413{
414 unsigned int cnt;
415 int mask,val,kv,mode,ret;
416 mask = 0;
417 val = 0;
418 ret = 0;
419 while (len) {
420 cnt = 0;
421 while ((cnt < len) &&
422 ((ptr[cnt] <= 32) ||
423 (ptr[cnt] >= 127))) cnt++;
424 ptr += cnt;
425 len -= cnt;
426 mode = 0;
427 if ((*ptr == '-') || (*ptr == '+')) {
428 mode = (*ptr == '-') ? -1 : 1;
429 ptr++;
430 len--;
431 }
432 cnt = 0;
433 while (cnt < len) {
434 if (ptr[cnt] <= 32) break;
435 if (ptr[cnt] >= 127) break;
436 cnt++;
437 }
438 if (!cnt) break;
439 if (parse_mtoken(ptr,cnt,&kv,names,valid_bits)) {
440 ret = -EINVAL;
441 break;
442 }
443 ptr += cnt;
444 len -= cnt;
445 switch (mode) {
446 case 0:
447 mask = valid_bits;
448 val |= kv;
449 break;
450 case -1:
451 mask |= kv;
452 val &= ~kv;
453 break;
454 case 1:
455 mask |= kv;
456 val |= kv;
457 break;
458 default:
459 break;
460 }
461 }
462 *maskptr = mask;
463 *valptr = val;
464 return ret;
465}
466
467
468/* Convert a symbolic value to a mask/value pair */
469int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr,
470 const char *ptr,unsigned int len,
471 int *maskptr,int *valptr)
472{
473 int ret = -EINVAL;
474 unsigned int cnt;
475
476 *maskptr = 0;
477 *valptr = 0;
478
479 cnt = 0;
480 while ((cnt < len) && ((ptr[cnt] <= 32) || (ptr[cnt] >= 127))) cnt++;
481 len -= cnt; ptr += cnt;
482 cnt = 0;
483 while ((cnt < len) && ((ptr[len-(cnt+1)] <= 32) ||
484 (ptr[len-(cnt+1)] >= 127))) cnt++;
485 len -= cnt;
486
487 if (!len) return -EINVAL;
488
489 LOCK_TAKE(cptr->hdw->big_lock); do {
490 if (cptr->info->type == pvr2_ctl_int) {
491 ret = parse_token(ptr,len,valptr,0,0);
492 if ((ret >= 0) &&
493 ((*valptr < cptr->info->def.type_int.min_value) ||
494 (*valptr > cptr->info->def.type_int.max_value))) {
495 ret = -ERANGE;
496 }
497 if (maskptr) *maskptr = ~0;
498 } else if (cptr->info->type == pvr2_ctl_bool) {
499 ret = parse_token(
500 ptr,len,valptr,boolNames,
501 sizeof(boolNames)/sizeof(boolNames[0]));
502 if (ret == 1) {
503 *valptr = *valptr ? !0 : 0;
504 } else if (ret == 0) {
505 *valptr = (*valptr & 1) ? !0 : 0;
506 }
507 if (maskptr) *maskptr = 1;
508 } else if (cptr->info->type == pvr2_ctl_enum) {
509 ret = parse_token(
510 ptr,len,valptr,
511 cptr->info->def.type_enum.value_names,
512 cptr->info->def.type_enum.count);
513 if ((ret >= 0) &&
514 ((*valptr < 0) ||
515 (*valptr >= cptr->info->def.type_enum.count))) {
516 ret = -ERANGE;
517 }
518 if (maskptr) *maskptr = ~0;
519 } else if (cptr->info->type == pvr2_ctl_bitmask) {
520 ret = parse_tlist(
521 ptr,len,maskptr,valptr,
522 cptr->info->def.type_bitmask.bit_names,
523 cptr->info->def.type_bitmask.valid_bits);
524 }
525 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
526 return ret;
527}
528
529
530/* Convert a given mask/val to a symbolic value */
531int pvr2_ctrl_value_to_sym_internal(struct pvr2_ctrl *cptr,
532 int mask,int val,
533 char *buf,unsigned int maxlen,
534 unsigned int *len)
535{
536 int ret = -EINVAL;
537
538 *len = 0;
539 if (cptr->info->type == pvr2_ctl_int) {
540 *len = scnprintf(buf,maxlen,"%d",val);
541 ret = 0;
542 } else if (cptr->info->type == pvr2_ctl_bool) {
543 *len = scnprintf(buf,maxlen,"%s",val ? "true" : "false");
544 ret = 0;
545 } else if (cptr->info->type == pvr2_ctl_enum) {
546 const char **names;
547 names = cptr->info->def.type_enum.value_names;
548 if ((val >= 0) &&
549 (val < cptr->info->def.type_enum.count)) {
550 if (names[val]) {
551 *len = scnprintf(
552 buf,maxlen,"%s",
553 names[val]);
554 } else {
555 *len = 0;
556 }
557 ret = 0;
558 }
559 } else if (cptr->info->type == pvr2_ctl_bitmask) {
560 *len = gen_bitmask_string(
561 val & mask & cptr->info->def.type_bitmask.valid_bits,
562 ~0,!0,
563 cptr->info->def.type_bitmask.bit_names,
564 buf,maxlen);
565 }
566 return ret;
567}
568
569
570/* Convert a given mask/val to a symbolic value */
571int pvr2_ctrl_value_to_sym(struct pvr2_ctrl *cptr,
572 int mask,int val,
573 char *buf,unsigned int maxlen,
574 unsigned int *len)
575{
576 int ret;
577 LOCK_TAKE(cptr->hdw->big_lock); do {
578 ret = pvr2_ctrl_value_to_sym_internal(cptr,mask,val,
579 buf,maxlen,len);
580 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
581 return ret;
582}
583
584
585/*
586 Stuff for Emacs to see, in order to encourage consistent editing style:
587 *** Local Variables: ***
588 *** mode: c ***
589 *** fill-column: 75 ***
590 *** tab-width: 8 ***
591 *** c-basic-offset: 8 ***
592 *** End: ***
593 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.h b/drivers/media/video/pvrusb2/pvrusb2-ctrl.h
new file mode 100644
index 000000000000..c1680053cd64
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.h
@@ -0,0 +1,123 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_CTRL_H
22#define __PVRUSB2_CTRL_H
23
24struct pvr2_ctrl;
25
26enum pvr2_ctl_type {
27 pvr2_ctl_int = 0,
28 pvr2_ctl_enum = 1,
29 pvr2_ctl_bitmask = 2,
30 pvr2_ctl_bool = 3,
31};
32
33
34/* Set the given control. */
35int pvr2_ctrl_set_value(struct pvr2_ctrl *,int val);
36
37/* Set/clear specific bits of the given control. */
38int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *,int mask,int val);
39
40/* Get the current value of the given control. */
41int pvr2_ctrl_get_value(struct pvr2_ctrl *,int *valptr);
42
43/* Retrieve control's type */
44enum pvr2_ctl_type pvr2_ctrl_get_type(struct pvr2_ctrl *);
45
46/* Retrieve control's maximum value (int type) */
47int pvr2_ctrl_get_max(struct pvr2_ctrl *);
48
49/* Retrieve control's minimum value (int type) */
50int pvr2_ctrl_get_min(struct pvr2_ctrl *);
51
52/* Retrieve control's default value (any type) */
53int pvr2_ctrl_get_def(struct pvr2_ctrl *);
54
55/* Retrieve control's enumeration count (enum only) */
56int pvr2_ctrl_get_cnt(struct pvr2_ctrl *);
57
58/* Retrieve control's valid mask bits (bit mask only) */
59int pvr2_ctrl_get_mask(struct pvr2_ctrl *);
60
61/* Retrieve the control's name */
62const char *pvr2_ctrl_get_name(struct pvr2_ctrl *);
63
64/* Retrieve the control's desc */
65const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *);
66
67/* Retrieve a control enumeration or bit mask value */
68int pvr2_ctrl_get_valname(struct pvr2_ctrl *,int,char *,unsigned int,
69 unsigned int *);
70
71/* Return true if control is writable */
72int pvr2_ctrl_is_writable(struct pvr2_ctrl *);
73
74/* Return V4L flags value for control (or zero if there is no v4l control
75 actually under this control) */
76unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *);
77
78/* Return V4L ID for this control or zero if none */
79int pvr2_ctrl_get_v4lid(struct pvr2_ctrl *);
80
81/* Return true if control has custom symbolic representation */
82int pvr2_ctrl_has_custom_symbols(struct pvr2_ctrl *);
83
84/* Convert a given mask/val to a custom symbolic value */
85int pvr2_ctrl_custom_value_to_sym(struct pvr2_ctrl *,
86 int mask,int val,
87 char *buf,unsigned int maxlen,
88 unsigned int *len);
89
90/* Convert a symbolic value to a mask/value pair */
91int pvr2_ctrl_custom_sym_to_value(struct pvr2_ctrl *,
92 const char *buf,unsigned int len,
93 int *maskptr,int *valptr);
94
95/* Convert a given mask/val to a symbolic value */
96int pvr2_ctrl_value_to_sym(struct pvr2_ctrl *,
97 int mask,int val,
98 char *buf,unsigned int maxlen,
99 unsigned int *len);
100
101/* Convert a symbolic value to a mask/value pair */
102int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *,
103 const char *buf,unsigned int len,
104 int *maskptr,int *valptr);
105
106/* Convert a given mask/val to a symbolic value - must already be
107 inside of critical region. */
108int pvr2_ctrl_value_to_sym_internal(struct pvr2_ctrl *,
109 int mask,int val,
110 char *buf,unsigned int maxlen,
111 unsigned int *len);
112
113#endif /* __PVRUSB2_CTRL_H */
114
115/*
116 Stuff for Emacs to see, in order to encourage consistent editing style:
117 *** Local Variables: ***
118 *** mode: c ***
119 *** fill-column: 75 ***
120 *** tab-width: 8 ***
121 *** c-basic-offset: 8 ***
122 *** End: ***
123 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
new file mode 100644
index 000000000000..27eadaff75a0
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -0,0 +1,279 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23/*
24
25 This source file is specifically designed to interface with the
26 cx2584x, in kernels 2.6.16 or newer.
27
28*/
29
30#include "pvrusb2-cx2584x-v4l.h"
31#include "pvrusb2-video-v4l.h"
32#include "pvrusb2-i2c-cmd-v4l2.h"
33
34
35#include "pvrusb2-hdw-internal.h"
36#include "pvrusb2-debug.h"
37#include <media/cx25840.h>
38#include <linux/videodev2.h>
39#include <media/v4l2-common.h>
40#include <linux/errno.h>
41#include <linux/slab.h>
42
43struct pvr2_v4l_cx2584x {
44 struct pvr2_i2c_handler handler;
45 struct pvr2_decoder_ctrl ctrl;
46 struct pvr2_i2c_client *client;
47 struct pvr2_hdw *hdw;
48 unsigned long stale_mask;
49};
50
51
52static void set_input(struct pvr2_v4l_cx2584x *ctxt)
53{
54 struct pvr2_hdw *hdw = ctxt->hdw;
55 struct v4l2_routing route;
56 enum cx25840_video_input vid_input;
57 enum cx25840_audio_input aud_input;
58
59 memset(&route,0,sizeof(route));
60
61 switch(hdw->input_val) {
62 case PVR2_CVAL_INPUT_TV:
63 vid_input = CX25840_COMPOSITE7;
64 aud_input = CX25840_AUDIO8;
65 break;
66 case PVR2_CVAL_INPUT_COMPOSITE:
67 vid_input = CX25840_COMPOSITE3;
68 aud_input = CX25840_AUDIO_SERIAL;
69 break;
70 case PVR2_CVAL_INPUT_SVIDEO:
71 vid_input = CX25840_SVIDEO1;
72 aud_input = CX25840_AUDIO_SERIAL;
73 break;
74 case PVR2_CVAL_INPUT_RADIO:
75 default:
76 // Just set it to be composite input for now...
77 vid_input = CX25840_COMPOSITE3;
78 aud_input = CX25840_AUDIO_SERIAL;
79 break;
80 }
81
82 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx2584x set_input vid=0x%x aud=0x%x",
83 vid_input,aud_input);
84 route.input = (u32)vid_input;
85 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_VIDEO_ROUTING,&route);
86 route.input = (u32)aud_input;
87 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route);
88}
89
90
91static int check_input(struct pvr2_v4l_cx2584x *ctxt)
92{
93 struct pvr2_hdw *hdw = ctxt->hdw;
94 return hdw->input_dirty != 0;
95}
96
97
98static void set_audio(struct pvr2_v4l_cx2584x *ctxt)
99{
100 u32 val;
101 struct pvr2_hdw *hdw = ctxt->hdw;
102
103 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx2584x set_audio %d",
104 hdw->srate_val);
105 switch (hdw->srate_val) {
106 default:
107 case V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000:
108 val = 48000;
109 break;
110 case V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100:
111 val = 44100;
112 break;
113 case V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000:
114 val = 32000;
115 break;
116 }
117 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_AUDIO_CLOCK_FREQ,&val);
118}
119
120
121static int check_audio(struct pvr2_v4l_cx2584x *ctxt)
122{
123 struct pvr2_hdw *hdw = ctxt->hdw;
124 return hdw->srate_dirty != 0;
125}
126
127
128struct pvr2_v4l_cx2584x_ops {
129 void (*update)(struct pvr2_v4l_cx2584x *);
130 int (*check)(struct pvr2_v4l_cx2584x *);
131};
132
133
134static const struct pvr2_v4l_cx2584x_ops decoder_ops[] = {
135 { .update = set_input, .check = check_input},
136 { .update = set_audio, .check = check_audio},
137};
138
139
140static void decoder_detach(struct pvr2_v4l_cx2584x *ctxt)
141{
142 ctxt->client->handler = 0;
143 ctxt->hdw->decoder_ctrl = 0;
144 kfree(ctxt);
145}
146
147
148static int decoder_check(struct pvr2_v4l_cx2584x *ctxt)
149{
150 unsigned long msk;
151 unsigned int idx;
152
153 for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
154 idx++) {
155 msk = 1 << idx;
156 if (ctxt->stale_mask & msk) continue;
157 if (decoder_ops[idx].check(ctxt)) {
158 ctxt->stale_mask |= msk;
159 }
160 }
161 return ctxt->stale_mask != 0;
162}
163
164
165static void decoder_update(struct pvr2_v4l_cx2584x *ctxt)
166{
167 unsigned long msk;
168 unsigned int idx;
169
170 for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
171 idx++) {
172 msk = 1 << idx;
173 if (!(ctxt->stale_mask & msk)) continue;
174 ctxt->stale_mask &= ~msk;
175 decoder_ops[idx].update(ctxt);
176 }
177}
178
179
180static void decoder_enable(struct pvr2_v4l_cx2584x *ctxt,int fl)
181{
182 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_enable(%d)",fl);
183 pvr2_v4l2_cmd_stream(ctxt->client,fl);
184}
185
186
187static int decoder_detect(struct pvr2_i2c_client *cp)
188{
189 int ret;
190 /* Attempt to query the decoder - let's see if it will answer */
191 struct v4l2_queryctrl qc;
192
193 memset(&qc,0,sizeof(qc));
194
195 qc.id = V4L2_CID_BRIGHTNESS;
196
197 ret = pvr2_i2c_client_cmd(cp,VIDIOC_QUERYCTRL,&qc);
198 return ret == 0; /* Return true if it answered */
199}
200
201
202static int decoder_is_tuned(struct pvr2_v4l_cx2584x *ctxt)
203{
204 struct v4l2_tuner vt;
205 int ret;
206
207 memset(&vt,0,sizeof(vt));
208 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_G_TUNER,&vt);
209 if (ret < 0) return -EINVAL;
210 return vt.signal ? 1 : 0;
211}
212
213
214static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
215 char *buf,unsigned int cnt)
216{
217 return scnprintf(buf,cnt,"handler: pvrusb2-cx2584x-v4l");
218}
219
220
221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
222{
223 int ret;
224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0);
225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
226}
227
228
229const static struct pvr2_i2c_handler_functions hfuncs = {
230 .detach = (void (*)(void *))decoder_detach,
231 .check = (int (*)(void *))decoder_check,
232 .update = (void (*)(void *))decoder_update,
233 .describe = (unsigned int (*)(void *,char *,unsigned int))decoder_describe,
234};
235
236
237int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *hdw,
238 struct pvr2_i2c_client *cp)
239{
240 struct pvr2_v4l_cx2584x *ctxt;
241
242 if (hdw->decoder_ctrl) return 0;
243 if (cp->handler) return 0;
244 if (!decoder_detect(cp)) return 0;
245
246 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
247 if (!ctxt) return 0;
248 memset(ctxt,0,sizeof(*ctxt));
249
250 ctxt->handler.func_data = ctxt;
251 ctxt->handler.func_table = &hfuncs;
252 ctxt->ctrl.ctxt = ctxt;
253 ctxt->ctrl.detach = (void (*)(void *))decoder_detach;
254 ctxt->ctrl.enable = (void (*)(void *,int))decoder_enable;
255 ctxt->ctrl.tuned = (int (*)(void *))decoder_is_tuned;
256 ctxt->ctrl.force_reset = (void (*)(void*))decoder_reset;
257 ctxt->client = cp;
258 ctxt->hdw = hdw;
259 ctxt->stale_mask = (1 << (sizeof(decoder_ops)/
260 sizeof(decoder_ops[0]))) - 1;
261 hdw->decoder_ctrl = &ctxt->ctrl;
262 cp->handler = &ctxt->handler;
263 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x cx2584x V4L2 handler set up",
264 cp->client->addr);
265 return !0;
266}
267
268
269
270
271/*
272 Stuff for Emacs to see, in order to encourage consistent editing style:
273 *** Local Variables: ***
274 *** mode: c ***
275 *** fill-column: 70 ***
276 *** tab-width: 8 ***
277 *** c-basic-offset: 8 ***
278 *** End: ***
279 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.h b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.h
new file mode 100644
index 000000000000..54b2844e7a71
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.h
@@ -0,0 +1,53 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_CX2584X_V4L_H
24#define __PVRUSB2_CX2584X_V4L_H
25
26/*
27
28 This module connects the pvrusb2 driver to the I2C chip level
29 driver which handles combined device audio & video processing.
30 This interface is used internally by the driver; higher level code
31 should only interact through the interface provided by
32 pvrusb2-hdw.h.
33
34*/
35
36
37
38#include "pvrusb2-i2c-core.h"
39
40int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
41
42
43#endif /* __PVRUSB2_CX2584X_V4L_H */
44
45/*
46 Stuff for Emacs to see, in order to encourage consistent editing style:
47 *** Local Variables: ***
48 *** mode: c ***
49 *** fill-column: 70 ***
50 *** tab-width: 8 ***
51 *** c-basic-offset: 8 ***
52 *** End: ***
53 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debug.h b/drivers/media/video/pvrusb2/pvrusb2-debug.h
new file mode 100644
index 000000000000..d95a8588e4f8
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-debug.h
@@ -0,0 +1,67 @@
1/*
2 * $Id$
3 *
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20#ifndef __PVRUSB2_DEBUG_H
21#define __PVRUSB2_DEBUG_H
22
23extern int pvrusb2_debug;
24
25#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) printk(KERN_INFO "pvrusb2: " fmt "\n", ##arg); } while (0)
26
27/* These are listed in *rough* order of decreasing usefulness and
28 increasing noise level. */
29#define PVR2_TRACE_INFO (1 << 0) // Normal messages
30#define PVR2_TRACE_ERROR_LEGS (1 << 1) // error messages
31#define PVR2_TRACE_TOLERANCE (1 << 2) // track tolerance-affected errors
32#define PVR2_TRACE_TRAP (1 << 3) // Trap & report misbehavior from app
33#define PVR2_TRACE_INIT (1 << 4) // misc initialization steps
34#define PVR2_TRACE_START_STOP (1 << 5) // Streaming start / stop
35#define PVR2_TRACE_CTL (1 << 6) // commit of control changes
36#define PVR2_TRACE_DEBUG (1 << 7) // Temporary debug code
37#define PVR2_TRACE_EEPROM (1 << 8) // eeprom parsing / report
38#define PVR2_TRACE_STRUCT (1 << 9) // internal struct creation
39#define PVR2_TRACE_OPEN_CLOSE (1 << 10) // application open / close
40#define PVR2_TRACE_CREG (1 << 11) // Main critical region entry / exit
41#define PVR2_TRACE_SYSFS (1 << 12) // Sysfs driven I/O
42#define PVR2_TRACE_FIRMWARE (1 << 13) // firmware upload actions
43#define PVR2_TRACE_CHIPS (1 << 14) // chip broadcast operation
44#define PVR2_TRACE_I2C (1 << 15) // I2C related stuff
45#define PVR2_TRACE_I2C_CMD (1 << 16) // Software commands to I2C modules
46#define PVR2_TRACE_I2C_CORE (1 << 17) // I2C core debugging
47#define PVR2_TRACE_I2C_TRAF (1 << 18) // I2C traffic through the adapter
48#define PVR2_TRACE_V4LIOCTL (1 << 19) // v4l ioctl details
49#define PVR2_TRACE_ENCODER (1 << 20) // mpeg2 encoder operation
50#define PVR2_TRACE_BUF_POOL (1 << 21) // Track buffer pool management
51#define PVR2_TRACE_BUF_FLOW (1 << 22) // Track buffer flow in system
52#define PVR2_TRACE_DATA_FLOW (1 << 23) // Track data flow
53#define PVR2_TRACE_DEBUGIFC (1 << 24) // Debug interface actions
54#define PVR2_TRACE_GPIO (1 << 25) // GPIO state bit changes
55
56
57#endif /* __PVRUSB2_HDW_INTERNAL_H */
58
59/*
60 Stuff for Emacs to see, in order to encourage consistent editing style:
61 *** Local Variables: ***
62 *** mode: c ***
63 *** fill-column: 75 ***
64 *** tab-width: 8 ***
65 *** c-basic-offset: 8 ***
66 *** End: ***
67 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
new file mode 100644
index 000000000000..586900e365ff
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
@@ -0,0 +1,478 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include <linux/string.h>
23#include <linux/slab.h>
24#include "pvrusb2-debugifc.h"
25#include "pvrusb2-hdw.h"
26#include "pvrusb2-debug.h"
27#include "pvrusb2-i2c-core.h"
28
29struct debugifc_mask_item {
30 const char *name;
31 unsigned long msk;
32};
33
34static struct debugifc_mask_item mask_items[] = {
35 {"ENC_FIRMWARE",(1<<PVR2_SUBSYS_B_ENC_FIRMWARE)},
36 {"ENC_CFG",(1<<PVR2_SUBSYS_B_ENC_CFG)},
37 {"DIG_RUN",(1<<PVR2_SUBSYS_B_DIGITIZER_RUN)},
38 {"USB_RUN",(1<<PVR2_SUBSYS_B_USBSTREAM_RUN)},
39 {"ENC_RUN",(1<<PVR2_SUBSYS_B_ENC_RUN)},
40};
41
42
43static unsigned int debugifc_count_whitespace(const char *buf,
44 unsigned int count)
45{
46 unsigned int scnt;
47 char ch;
48
49 for (scnt = 0; scnt < count; scnt++) {
50 ch = buf[scnt];
51 if (ch == ' ') continue;
52 if (ch == '\t') continue;
53 if (ch == '\n') continue;
54 break;
55 }
56 return scnt;
57}
58
59
60static unsigned int debugifc_count_nonwhitespace(const char *buf,
61 unsigned int count)
62{
63 unsigned int scnt;
64 char ch;
65
66 for (scnt = 0; scnt < count; scnt++) {
67 ch = buf[scnt];
68 if (ch == ' ') break;
69 if (ch == '\t') break;
70 if (ch == '\n') break;
71 }
72 return scnt;
73}
74
75
76static unsigned int debugifc_isolate_word(const char *buf,unsigned int count,
77 const char **wstrPtr,
78 unsigned int *wlenPtr)
79{
80 const char *wptr;
81 unsigned int consume_cnt = 0;
82 unsigned int wlen;
83 unsigned int scnt;
84
85 wptr = 0;
86 wlen = 0;
87 scnt = debugifc_count_whitespace(buf,count);
88 consume_cnt += scnt; count -= scnt; buf += scnt;
89 if (!count) goto done;
90
91 scnt = debugifc_count_nonwhitespace(buf,count);
92 if (!scnt) goto done;
93 wptr = buf;
94 wlen = scnt;
95 consume_cnt += scnt; count -= scnt; buf += scnt;
96
97 done:
98 *wstrPtr = wptr;
99 *wlenPtr = wlen;
100 return consume_cnt;
101}
102
103
104static int debugifc_parse_unsigned_number(const char *buf,unsigned int count,
105 u32 *num_ptr)
106{
107 u32 result = 0;
108 u32 val;
109 int ch;
110 int radix = 10;
111 if ((count >= 2) && (buf[0] == '0') &&
112 ((buf[1] == 'x') || (buf[1] == 'X'))) {
113 radix = 16;
114 count -= 2;
115 buf += 2;
116 } else if ((count >= 1) && (buf[0] == '0')) {
117 radix = 8;
118 }
119
120 while (count--) {
121 ch = *buf++;
122 if ((ch >= '0') && (ch <= '9')) {
123 val = ch - '0';
124 } else if ((ch >= 'a') && (ch <= 'f')) {
125 val = ch - 'a' + 10;
126 } else if ((ch >= 'A') && (ch <= 'F')) {
127 val = ch - 'A' + 10;
128 } else {
129 return -EINVAL;
130 }
131 if (val >= radix) return -EINVAL;
132 result *= radix;
133 result += val;
134 }
135 *num_ptr = result;
136 return 0;
137}
138
139
140static int debugifc_match_keyword(const char *buf,unsigned int count,
141 const char *keyword)
142{
143 unsigned int kl;
144 if (!keyword) return 0;
145 kl = strlen(keyword);
146 if (kl != count) return 0;
147 return !memcmp(buf,keyword,kl);
148}
149
150
151static unsigned long debugifc_find_mask(const char *buf,unsigned int count)
152{
153 struct debugifc_mask_item *mip;
154 unsigned int idx;
155 for (idx = 0; idx < sizeof(mask_items)/sizeof(mask_items[0]); idx++) {
156 mip = mask_items + idx;
157 if (debugifc_match_keyword(buf,count,mip->name)) {
158 return mip->msk;
159 }
160 }
161 return 0;
162}
163
164
165static int debugifc_print_mask(char *buf,unsigned int sz,
166 unsigned long msk,unsigned long val)
167{
168 struct debugifc_mask_item *mip;
169 unsigned int idx;
170 int bcnt = 0;
171 int ccnt;
172 for (idx = 0; idx < sizeof(mask_items)/sizeof(mask_items[0]); idx++) {
173 mip = mask_items + idx;
174 if (!(mip->msk & msk)) continue;
175 ccnt = scnprintf(buf,sz,"%s%c%s",
176 (bcnt ? " " : ""),
177 ((mip->msk & val) ? '+' : '-'),
178 mip->name);
179 sz -= ccnt;
180 buf += ccnt;
181 bcnt += ccnt;
182 }
183 return bcnt;
184}
185
186static unsigned int debugifc_parse_subsys_mask(const char *buf,
187 unsigned int count,
188 unsigned long *mskPtr,
189 unsigned long *valPtr)
190{
191 const char *wptr;
192 unsigned int consume_cnt = 0;
193 unsigned int scnt;
194 unsigned int wlen;
195 int mode;
196 unsigned long m1,msk,val;
197
198 msk = 0;
199 val = 0;
200
201 while (count) {
202 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
203 if (!scnt) break;
204 consume_cnt += scnt; count -= scnt; buf += scnt;
205 if (!wptr) break;
206
207 mode = 0;
208 if (wlen) switch (wptr[0]) {
209 case '+':
210 wptr++;
211 wlen--;
212 break;
213 case '-':
214 mode = 1;
215 wptr++;
216 wlen--;
217 break;
218 }
219 if (!wlen) continue;
220 m1 = debugifc_find_mask(wptr,wlen);
221 if (!m1) break;
222 msk |= m1;
223 if (!mode) val |= m1;
224 }
225 *mskPtr = msk;
226 *valPtr = val;
227 return consume_cnt;
228}
229
230
231int pvr2_debugifc_print_info(struct pvr2_hdw *hdw,char *buf,unsigned int acnt)
232{
233 int bcnt = 0;
234 int ccnt;
235 struct pvr2_hdw_debug_info dbg;
236
237 pvr2_hdw_get_debug_info(hdw,&dbg);
238
239 ccnt = scnprintf(buf,acnt,"big lock %s; ctl lock %s",
240 (dbg.big_lock_held ? "held" : "free"),
241 (dbg.ctl_lock_held ? "held" : "free"));
242 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
243 if (dbg.ctl_lock_held) {
244 ccnt = scnprintf(buf,acnt,"; cmd_state=%d cmd_code=%d"
245 " cmd_wlen=%d cmd_rlen=%d"
246 " wpend=%d rpend=%d tmout=%d rstatus=%d"
247 " wstatus=%d",
248 dbg.cmd_debug_state,dbg.cmd_code,
249 dbg.cmd_debug_write_len,
250 dbg.cmd_debug_read_len,
251 dbg.cmd_debug_write_pend,
252 dbg.cmd_debug_read_pend,
253 dbg.cmd_debug_timeout,
254 dbg.cmd_debug_rstatus,
255 dbg.cmd_debug_wstatus);
256 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
257 }
258 ccnt = scnprintf(buf,acnt,"\n");
259 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
260 ccnt = scnprintf(
261 buf,acnt,"driver flags: %s %s %s\n",
262 (dbg.flag_init_ok ? "initialized" : "uninitialized"),
263 (dbg.flag_ok ? "ok" : "fail"),
264 (dbg.flag_disconnected ? "disconnected" : "connected"));
265 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
266 ccnt = scnprintf(buf,acnt,"Subsystems enabled / configured: ");
267 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
268 ccnt = debugifc_print_mask(buf,acnt,dbg.subsys_flags,dbg.subsys_flags);
269 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
270 ccnt = scnprintf(buf,acnt,"\n");
271 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
272 ccnt = scnprintf(buf,acnt,"Subsystems disabled / unconfigured: ");
273 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
274 ccnt = debugifc_print_mask(buf,acnt,~dbg.subsys_flags,dbg.subsys_flags);
275 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
276 ccnt = scnprintf(buf,acnt,"\n");
277 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
278
279 ccnt = scnprintf(buf,acnt,"Attached I2C modules:\n");
280 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
281 ccnt = pvr2_i2c_report(hdw,buf,acnt);
282 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
283
284 return bcnt;
285}
286
287
288int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
289 char *buf,unsigned int acnt)
290{
291 int bcnt = 0;
292 int ccnt;
293 unsigned long msk;
294 int ret;
295 u32 gpio_dir,gpio_in,gpio_out;
296
297 ret = pvr2_hdw_is_hsm(hdw);
298 ccnt = scnprintf(buf,acnt,"USB link speed: %s\n",
299 (ret < 0 ? "FAIL" : (ret ? "high" : "full")));
300 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
301
302 gpio_dir = 0; gpio_in = 0; gpio_out = 0;
303 pvr2_hdw_gpio_get_dir(hdw,&gpio_dir);
304 pvr2_hdw_gpio_get_out(hdw,&gpio_out);
305 pvr2_hdw_gpio_get_in(hdw,&gpio_in);
306 ccnt = scnprintf(buf,acnt,"GPIO state: dir=0x%x in=0x%x out=0x%x\n",
307 gpio_dir,gpio_in,gpio_out);
308 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
309
310 ccnt = scnprintf(buf,acnt,"Streaming is %s\n",
311 pvr2_hdw_get_streaming(hdw) ? "on" : "off");
312 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
313
314 msk = pvr2_hdw_subsys_get(hdw);
315 ccnt = scnprintf(buf,acnt,"Subsystems enabled / configured: ");
316 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
317 ccnt = debugifc_print_mask(buf,acnt,msk,msk);
318 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
319 ccnt = scnprintf(buf,acnt,"\n");
320 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
321 ccnt = scnprintf(buf,acnt,"Subsystems disabled / unconfigured: ");
322 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
323 ccnt = debugifc_print_mask(buf,acnt,~msk,msk);
324 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
325 ccnt = scnprintf(buf,acnt,"\n");
326 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
327
328 msk = pvr2_hdw_subsys_stream_get(hdw);
329 ccnt = scnprintf(buf,acnt,"Subsystems stopped on stream shutdown: ");
330 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
331 ccnt = debugifc_print_mask(buf,acnt,msk,msk);
332 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
333 ccnt = scnprintf(buf,acnt,"\n");
334 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
335
336 return bcnt;
337}
338
339
340int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
341 unsigned int count)
342{
343 const char *wptr;
344 unsigned int wlen;
345 unsigned int scnt;
346
347 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
348 if (!scnt) return 0;
349 count -= scnt; buf += scnt;
350 if (!wptr) return 0;
351
352 pvr2_trace(PVR2_TRACE_DEBUGIFC,"debugifc cmd: \"%.*s\"",wlen,wptr);
353 if (debugifc_match_keyword(wptr,wlen,"reset")) {
354 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
355 if (!scnt) return -EINVAL;
356 count -= scnt; buf += scnt;
357 if (!wptr) return -EINVAL;
358 if (debugifc_match_keyword(wptr,wlen,"cpu")) {
359 pvr2_hdw_cpureset_assert(hdw,!0);
360 pvr2_hdw_cpureset_assert(hdw,0);
361 return 0;
362 } else if (debugifc_match_keyword(wptr,wlen,"bus")) {
363 pvr2_hdw_device_reset(hdw);
364 } else if (debugifc_match_keyword(wptr,wlen,"soft")) {
365 return pvr2_hdw_cmd_powerup(hdw);
366 } else if (debugifc_match_keyword(wptr,wlen,"deep")) {
367 return pvr2_hdw_cmd_deep_reset(hdw);
368 } else if (debugifc_match_keyword(wptr,wlen,"firmware")) {
369 return pvr2_upload_firmware2(hdw);
370 } else if (debugifc_match_keyword(wptr,wlen,"decoder")) {
371 return pvr2_hdw_cmd_decoder_reset(hdw);
372 }
373 return -EINVAL;
374 } else if (debugifc_match_keyword(wptr,wlen,"subsys_flags")) {
375 unsigned long msk = 0;
376 unsigned long val = 0;
377 if (debugifc_parse_subsys_mask(buf,count,&msk,&val) != count) {
378 pvr2_trace(PVR2_TRACE_DEBUGIFC,
379 "debugifc parse error on subsys mask");
380 return -EINVAL;
381 }
382 pvr2_hdw_subsys_bit_chg(hdw,msk,val);
383 return 0;
384 } else if (debugifc_match_keyword(wptr,wlen,"stream_flags")) {
385 unsigned long msk = 0;
386 unsigned long val = 0;
387 if (debugifc_parse_subsys_mask(buf,count,&msk,&val) != count) {
388 pvr2_trace(PVR2_TRACE_DEBUGIFC,
389 "debugifc parse error on stream mask");
390 return -EINVAL;
391 }
392 pvr2_hdw_subsys_stream_bit_chg(hdw,msk,val);
393 return 0;
394 } else if (debugifc_match_keyword(wptr,wlen,"cpufw")) {
395 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
396 if (!scnt) return -EINVAL;
397 count -= scnt; buf += scnt;
398 if (!wptr) return -EINVAL;
399 if (debugifc_match_keyword(wptr,wlen,"fetch")) {
400 pvr2_hdw_cpufw_set_enabled(hdw,!0);
401 return 0;
402 } else if (debugifc_match_keyword(wptr,wlen,"done")) {
403 pvr2_hdw_cpufw_set_enabled(hdw,0);
404 return 0;
405 } else {
406 return -EINVAL;
407 }
408 } else if (debugifc_match_keyword(wptr,wlen,"gpio")) {
409 int dir_fl = 0;
410 int ret;
411 u32 msk,val;
412 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
413 if (!scnt) return -EINVAL;
414 count -= scnt; buf += scnt;
415 if (!wptr) return -EINVAL;
416 if (debugifc_match_keyword(wptr,wlen,"dir")) {
417 dir_fl = !0;
418 } else if (!debugifc_match_keyword(wptr,wlen,"out")) {
419 return -EINVAL;
420 }
421 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
422 if (!scnt) return -EINVAL;
423 count -= scnt; buf += scnt;
424 if (!wptr) return -EINVAL;
425 ret = debugifc_parse_unsigned_number(wptr,wlen,&msk);
426 if (ret) return ret;
427 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
428 if (wptr) {
429 ret = debugifc_parse_unsigned_number(wptr,wlen,&val);
430 if (ret) return ret;
431 } else {
432 val = msk;
433 msk = 0xffffffff;
434 }
435 if (dir_fl) {
436 ret = pvr2_hdw_gpio_chg_dir(hdw,msk,val);
437 } else {
438 ret = pvr2_hdw_gpio_chg_out(hdw,msk,val);
439 }
440 return ret;
441 }
442 pvr2_trace(PVR2_TRACE_DEBUGIFC,
443 "debugifc failed to recognize cmd: \"%.*s\"",wlen,wptr);
444 return -EINVAL;
445}
446
447
448int pvr2_debugifc_docmd(struct pvr2_hdw *hdw,const char *buf,
449 unsigned int count)
450{
451 unsigned int bcnt = 0;
452 int ret;
453
454 while (count) {
455 for (bcnt = 0; bcnt < count; bcnt++) {
456 if (buf[bcnt] == '\n') break;
457 }
458
459 ret = pvr2_debugifc_do1cmd(hdw,buf,bcnt);
460 if (ret < 0) return ret;
461 if (bcnt < count) bcnt++;
462 buf += bcnt;
463 count -= bcnt;
464 }
465
466 return 0;
467}
468
469
470/*
471 Stuff for Emacs to see, in order to encourage consistent editing style:
472 *** Local Variables: ***
473 *** mode: c ***
474 *** fill-column: 75 ***
475 *** tab-width: 8 ***
476 *** c-basic-offset: 8 ***
477 *** End: ***
478 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.h b/drivers/media/video/pvrusb2/pvrusb2-debugifc.h
new file mode 100644
index 000000000000..990b02d35d36
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.h
@@ -0,0 +1,53 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_DEBUGIFC_H
22#define __PVRUSB2_DEBUGIFC_H
23
24struct pvr2_hdw;
25
26/* Non-intrusively print some useful debugging info from inside the
27 driver. This should work even if the driver appears to be
28 wedged. */
29int pvr2_debugifc_print_info(struct pvr2_hdw *,
30 char *buf_ptr,unsigned int buf_size);
31
32/* Print general status of driver. This will also trigger a probe of
33 the USB link. Unlike print_info(), this one synchronizes with the
34 driver so the information should be self-consistent (but it will
35 hang if the driver is wedged). */
36int pvr2_debugifc_print_status(struct pvr2_hdw *,
37 char *buf_ptr,unsigned int buf_size);
38
39/* Parse a string command into a driver action. */
40int pvr2_debugifc_docmd(struct pvr2_hdw *,
41 const char *buf_ptr,unsigned int buf_size);
42
43#endif /* __PVRUSB2_DEBUGIFC_H */
44
45/*
46 Stuff for Emacs to see, in order to encourage consistent editing style:
47 *** Local Variables: ***
48 *** mode: c ***
49 *** fill-column: 75 ***
50 *** tab-width: 8 ***
51 *** c-basic-offset: 8 ***
52 *** End: ***
53 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-demod.c b/drivers/media/video/pvrusb2/pvrusb2-demod.c
new file mode 100644
index 000000000000..9686569a11f6
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-demod.c
@@ -0,0 +1,126 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "pvrusb2.h"
24#include "pvrusb2-util.h"
25#include "pvrusb2-demod.h"
26#include "pvrusb2-hdw-internal.h"
27#include "pvrusb2-debug.h"
28#include <linux/videodev2.h>
29#include <media/tuner.h>
30#include <media/v4l2-common.h>
31
32
33struct pvr2_demod_handler {
34 struct pvr2_hdw *hdw;
35 struct pvr2_i2c_client *client;
36 struct pvr2_i2c_handler i2c_handler;
37 int type_update_fl;
38};
39
40
41static void set_config(struct pvr2_demod_handler *ctxt)
42{
43 struct pvr2_hdw *hdw = ctxt->hdw;
44 int cfg = 0;
45
46 switch (hdw->tuner_type) {
47 case TUNER_PHILIPS_FM1216ME_MK3:
48 case TUNER_PHILIPS_FM1236_MK3:
49 cfg = TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE;
50 break;
51 default:
52 break;
53 }
54 pvr2_trace(PVR2_TRACE_CHIPS,"i2c demod set_config(0x%x)",cfg);
55 pvr2_i2c_client_cmd(ctxt->client,TDA9887_SET_CONFIG,&cfg);
56 ctxt->type_update_fl = 0;
57}
58
59
60static int demod_check(struct pvr2_demod_handler *ctxt)
61{
62 struct pvr2_hdw *hdw = ctxt->hdw;
63 if (hdw->tuner_updated) ctxt->type_update_fl = !0;
64 return ctxt->type_update_fl != 0;
65}
66
67
68static void demod_update(struct pvr2_demod_handler *ctxt)
69{
70 if (ctxt->type_update_fl) set_config(ctxt);
71}
72
73
74static void demod_detach(struct pvr2_demod_handler *ctxt)
75{
76 ctxt->client->handler = 0;
77 kfree(ctxt);
78}
79
80
81static unsigned int demod_describe(struct pvr2_demod_handler *ctxt,char *buf,unsigned int cnt)
82{
83 return scnprintf(buf,cnt,"handler: pvrusb2-demod");
84}
85
86
87const static struct pvr2_i2c_handler_functions tuner_funcs = {
88 .detach = (void (*)(void *))demod_detach,
89 .check = (int (*)(void *))demod_check,
90 .update = (void (*)(void *))demod_update,
91 .describe = (unsigned int (*)(void *,char *,unsigned int))demod_describe,
92};
93
94
95int pvr2_i2c_demod_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
96{
97 struct pvr2_demod_handler *ctxt;
98 if (cp->handler) return 0;
99
100 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
101 if (!ctxt) return 0;
102 memset(ctxt,0,sizeof(*ctxt));
103
104 ctxt->i2c_handler.func_data = ctxt;
105 ctxt->i2c_handler.func_table = &tuner_funcs;
106 ctxt->type_update_fl = !0;
107 ctxt->client = cp;
108 ctxt->hdw = hdw;
109 cp->handler = &ctxt->i2c_handler;
110 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x tda9887 V4L2 handler set up",
111 cp->client->addr);
112 return !0;
113}
114
115
116
117
118/*
119 Stuff for Emacs to see, in order to encourage consistent editing style:
120 *** Local Variables: ***
121 *** mode: c ***
122 *** fill-column: 70 ***
123 *** tab-width: 8 ***
124 *** c-basic-offset: 8 ***
125 *** End: ***
126 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-demod.h b/drivers/media/video/pvrusb2/pvrusb2-demod.h
new file mode 100644
index 000000000000..4c4e40ffbf03
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-demod.h
@@ -0,0 +1,38 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_DEMOD_H
22#define __PVRUSB2_DEMOD_H
23
24#include "pvrusb2-i2c-core.h"
25
26int pvr2_i2c_demod_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
27
28#endif /* __PVRUSB2_DEMOD_H */
29
30/*
31 Stuff for Emacs to see, in order to encourage consistent editing style:
32 *** Local Variables: ***
33 *** mode: c ***
34 *** fill-column: 70 ***
35 *** tab-width: 8 ***
36 *** c-basic-offset: 8 ***
37 *** End: ***
38 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-eeprom.c b/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
new file mode 100644
index 000000000000..94d383ff9889
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
@@ -0,0 +1,164 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "pvrusb2-eeprom.h"
24#include "pvrusb2-hdw-internal.h"
25#include "pvrusb2-debug.h"
26
27#define trace_eeprom(...) pvr2_trace(PVR2_TRACE_EEPROM,__VA_ARGS__)
28
29
30
31/*
32
33 Read and analyze data in the eeprom. Use tveeprom to figure out
34 the packet structure, since this is another Hauppauge device and
35 internally it has a family resemblence to ivtv-type devices
36
37*/
38
39#include <media/tveeprom.h>
40
41/* We seem to only be interested in the last 128 bytes of the EEPROM */
42#define EEPROM_SIZE 128
43
44/* Grab EEPROM contents, needed for direct method. */
45static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
46{
47 struct i2c_msg msg[2];
48 u8 *eeprom;
49 u8 iadd[2];
50 u8 addr;
51 u16 eepromSize;
52 unsigned int offs;
53 int ret;
54 int mode16 = 0;
55 unsigned pcnt,tcnt;
56 eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL);
57 if (!eeprom) {
58 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
59 "Failed to allocate memory"
60 " required to read eeprom");
61 return 0;
62 }
63
64 trace_eeprom("Value for eeprom addr from controller was 0x%x",
65 hdw->eeprom_addr);
66 addr = hdw->eeprom_addr;
67 /* Seems that if the high bit is set, then the *real* eeprom
68 address is shifted right now bit position (noticed this in
69 newer PVR USB2 hardware) */
70 if (addr & 0x80) addr >>= 1;
71
72 /* FX2 documentation states that a 16bit-addressed eeprom is
73 expected if the I2C address is an odd number (yeah, this is
74 strange but it's what they do) */
75 mode16 = (addr & 1);
76 eepromSize = (mode16 ? 4096 : 256);
77 trace_eeprom("Examining %d byte eeprom at location 0x%x"
78 " using %d bit addressing",eepromSize,addr,
79 mode16 ? 16 : 8);
80
81 msg[0].addr = addr;
82 msg[0].flags = 0;
83 msg[0].len = mode16 ? 2 : 1;
84 msg[0].buf = iadd;
85 msg[1].addr = addr;
86 msg[1].flags = I2C_M_RD;
87
88 /* We have to do the actual eeprom data fetch ourselves, because
89 (1) we're only fetching part of the eeprom, and (2) if we were
90 getting the whole thing our I2C driver can't grab it in one
91 pass - which is what tveeprom is otherwise going to attempt */
92 memset(eeprom,0,EEPROM_SIZE);
93 for (tcnt = 0; tcnt < EEPROM_SIZE; tcnt += pcnt) {
94 pcnt = 16;
95 if (pcnt + tcnt > EEPROM_SIZE) pcnt = EEPROM_SIZE-tcnt;
96 offs = tcnt + (eepromSize - EEPROM_SIZE);
97 if (mode16) {
98 iadd[0] = offs >> 8;
99 iadd[1] = offs;
100 } else {
101 iadd[0] = offs;
102 }
103 msg[1].len = pcnt;
104 msg[1].buf = eeprom+tcnt;
105 if ((ret = i2c_transfer(
106 &hdw->i2c_adap,
107 msg,sizeof(msg)/sizeof(msg[0]))) != 2) {
108 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
109 "eeprom fetch set offs err=%d",ret);
110 kfree(eeprom);
111 return 0;
112 }
113 }
114 return eeprom;
115}
116
117
118/* Directly call eeprom analysis function within tveeprom. */
119int pvr2_eeprom_analyze(struct pvr2_hdw *hdw)
120{
121 u8 *eeprom;
122 struct tveeprom tvdata;
123
124 memset(&tvdata,0,sizeof(tvdata));
125
126 eeprom = pvr2_eeprom_fetch(hdw);
127 if (!eeprom) return -EINVAL;
128
129 {
130 struct i2c_client fake_client;
131 /* Newer version expects a useless client interface */
132 fake_client.addr = hdw->eeprom_addr;
133 fake_client.adapter = &hdw->i2c_adap;
134 tveeprom_hauppauge_analog(&fake_client,&tvdata,eeprom);
135 }
136
137 trace_eeprom("eeprom assumed v4l tveeprom module");
138 trace_eeprom("eeprom direct call results:");
139 trace_eeprom("has_radio=%d",tvdata.has_radio);
140 trace_eeprom("tuner_type=%d",tvdata.tuner_type);
141 trace_eeprom("tuner_formats=0x%x",tvdata.tuner_formats);
142 trace_eeprom("audio_processor=%d",tvdata.audio_processor);
143 trace_eeprom("model=%d",tvdata.model);
144 trace_eeprom("revision=%d",tvdata.revision);
145 trace_eeprom("serial_number=%d",tvdata.serial_number);
146 trace_eeprom("rev_str=%s",tvdata.rev_str);
147 hdw->tuner_type = tvdata.tuner_type;
148 hdw->serial_number = tvdata.serial_number;
149 hdw->std_mask_eeprom = tvdata.tuner_formats;
150
151 kfree(eeprom);
152
153 return 0;
154}
155
156/*
157 Stuff for Emacs to see, in order to encourage consistent editing style:
158 *** Local Variables: ***
159 *** mode: c ***
160 *** fill-column: 70 ***
161 *** tab-width: 8 ***
162 *** c-basic-offset: 8 ***
163 *** End: ***
164 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-eeprom.h b/drivers/media/video/pvrusb2/pvrusb2-eeprom.h
new file mode 100644
index 000000000000..84242975dea7
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-eeprom.h
@@ -0,0 +1,40 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_EEPROM_H
24#define __PVRUSB2_EEPROM_H
25
26struct pvr2_hdw;
27
28int pvr2_eeprom_analyze(struct pvr2_hdw *);
29
30#endif /* __PVRUSB2_EEPROM_H */
31
32/*
33 Stuff for Emacs to see, in order to encourage consistent editing style:
34 *** Local Variables: ***
35 *** mode: c ***
36 *** fill-column: 70 ***
37 *** tab-width: 8 ***
38 *** c-basic-offset: 8 ***
39 *** End: ***
40 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
new file mode 100644
index 000000000000..2cc31695b435
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -0,0 +1,418 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/device.h> // for linux/firmware.h
24#include <linux/firmware.h>
25#include "pvrusb2-util.h"
26#include "pvrusb2-encoder.h"
27#include "pvrusb2-hdw-internal.h"
28#include "pvrusb2-debug.h"
29
30
31
32/* Firmware mailbox flags - definitions found from ivtv */
33#define IVTV_MBOX_FIRMWARE_DONE 0x00000004
34#define IVTV_MBOX_DRIVER_DONE 0x00000002
35#define IVTV_MBOX_DRIVER_BUSY 0x00000001
36
37
38static int pvr2_encoder_write_words(struct pvr2_hdw *hdw,
39 const u32 *data, unsigned int dlen)
40{
41 unsigned int idx;
42 int ret;
43 unsigned int offs = 0;
44 unsigned int chunkCnt;
45
46 /*
47
48 Format: First byte must be 0x01. Remaining 32 bit words are
49 spread out into chunks of 7 bytes each, little-endian ordered,
50 offset at zero within each 2 blank bytes following and a
51 single byte that is 0x44 plus the offset of the word. Repeat
52 request for additional words, with offset adjusted
53 accordingly.
54
55 */
56 while (dlen) {
57 chunkCnt = 8;
58 if (chunkCnt > dlen) chunkCnt = dlen;
59 memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer));
60 hdw->cmd_buffer[0] = 0x01;
61 for (idx = 0; idx < chunkCnt; idx++) {
62 hdw->cmd_buffer[1+(idx*7)+6] = 0x44 + idx + offs;
63 PVR2_DECOMPOSE_LE(hdw->cmd_buffer, 1+(idx*7),
64 data[idx]);
65 }
66 ret = pvr2_send_request(hdw,
67 hdw->cmd_buffer,1+(chunkCnt*7),
68 0,0);
69 if (ret) return ret;
70 data += chunkCnt;
71 dlen -= chunkCnt;
72 offs += chunkCnt;
73 }
74
75 return 0;
76}
77
78
79static int pvr2_encoder_read_words(struct pvr2_hdw *hdw,int statusFl,
80 u32 *data, unsigned int dlen)
81{
82 unsigned int idx;
83 int ret;
84 unsigned int offs = 0;
85 unsigned int chunkCnt;
86
87 /*
88
89 Format: First byte must be 0x02 (status check) or 0x28 (read
90 back block of 32 bit words). Next 6 bytes must be zero,
91 followed by a single byte of 0x44+offset for portion to be
92 read. Returned data is packed set of 32 bits words that were
93 read.
94
95 */
96
97 while (dlen) {
98 chunkCnt = 16;
99 if (chunkCnt > dlen) chunkCnt = dlen;
100 memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer));
101 hdw->cmd_buffer[0] = statusFl ? 0x02 : 0x28;
102 hdw->cmd_buffer[7] = 0x44 + offs;
103 ret = pvr2_send_request(hdw,
104 hdw->cmd_buffer,8,
105 hdw->cmd_buffer,chunkCnt * 4);
106 if (ret) return ret;
107
108 for (idx = 0; idx < chunkCnt; idx++) {
109 data[idx] = PVR2_COMPOSE_LE(hdw->cmd_buffer,idx*4);
110 }
111 data += chunkCnt;
112 dlen -= chunkCnt;
113 offs += chunkCnt;
114 }
115
116 return 0;
117}
118
119
120/* This prototype is set up to be compatible with the
121 cx2341x_mbox_func prototype in cx2341x.h, which should be in
122 kernels 2.6.18 or later. We do this so that we can enable
123 cx2341x.ko to write to our encoder (by handing it a pointer to this
124 function). For earlier kernels this doesn't really matter. */
125static int pvr2_encoder_cmd(void *ctxt,
126 int cmd,
127 int arg_cnt_send,
128 int arg_cnt_recv,
129 u32 *argp)
130{
131 unsigned int poll_count;
132 int ret = 0;
133 unsigned int idx;
134 /* These sizes look to be limited by the FX2 firmware implementation */
135 u32 wrData[16];
136 u32 rdData[16];
137 struct pvr2_hdw *hdw = (struct pvr2_hdw *)ctxt;
138
139
140 /*
141
142 The encoder seems to speak entirely using blocks 32 bit words.
143 In ivtv driver terms, this is a mailbox which we populate with
144 data and watch what the hardware does with it. The first word
145 is a set of flags used to control the transaction, the second
146 word is the command to execute, the third byte is zero (ivtv
147 driver suggests that this is some kind of return value), and
148 the fourth byte is a specified timeout (windows driver always
149 uses 0x00060000 except for one case when it is zero). All
150 successive words are the argument words for the command.
151
152 First, write out the entire set of words, with the first word
153 being zero.
154
155 Next, write out just the first word again, but set it to
156 IVTV_MBOX_DRIVER_DONE | IVTV_DRIVER_BUSY this time (which
157 probably means "go").
158
159 Next, read back 16 words as status. Check the first word,
160 which should have IVTV_MBOX_FIRMWARE_DONE set. If however
161 that bit is not set, then the command isn't done so repeat the
162 read.
163
164 Next, read back 32 words and compare with the original
165 arugments. Hopefully they will match.
166
167 Finally, write out just the first word again, but set it to
168 0x0 this time (which probably means "idle").
169
170 */
171
172 if (arg_cnt_send > (sizeof(wrData)/sizeof(wrData[0]))-4) {
173 pvr2_trace(
174 PVR2_TRACE_ERROR_LEGS,
175 "Failed to write cx23416 command"
176 " - too many input arguments"
177 " (was given %u limit %u)",
178 arg_cnt_send,
179 (unsigned int)(sizeof(wrData)/sizeof(wrData[0])) - 4);
180 return -EINVAL;
181 }
182
183 if (arg_cnt_recv > (sizeof(rdData)/sizeof(rdData[0]))-4) {
184 pvr2_trace(
185 PVR2_TRACE_ERROR_LEGS,
186 "Failed to write cx23416 command"
187 " - too many return arguments"
188 " (was given %u limit %u)",
189 arg_cnt_recv,
190 (unsigned int)(sizeof(rdData)/sizeof(rdData[0])) - 4);
191 return -EINVAL;
192 }
193
194
195 LOCK_TAKE(hdw->ctl_lock); do {
196
197 wrData[0] = 0;
198 wrData[1] = cmd;
199 wrData[2] = 0;
200 wrData[3] = 0x00060000;
201 for (idx = 0; idx < arg_cnt_send; idx++) {
202 wrData[idx+4] = argp[idx];
203 }
204 for (; idx < (sizeof(wrData)/sizeof(wrData[0]))-4; idx++) {
205 wrData[idx+4] = 0;
206 }
207
208 ret = pvr2_encoder_write_words(hdw,wrData,idx);
209 if (ret) break;
210 wrData[0] = IVTV_MBOX_DRIVER_DONE|IVTV_MBOX_DRIVER_BUSY;
211 ret = pvr2_encoder_write_words(hdw,wrData,1);
212 if (ret) break;
213 poll_count = 0;
214 while (1) {
215 if (poll_count < 10000000) poll_count++;
216 ret = pvr2_encoder_read_words(hdw,!0,rdData,1);
217 if (ret) break;
218 if (rdData[0] & IVTV_MBOX_FIRMWARE_DONE) {
219 break;
220 }
221 if (poll_count == 100) {
222 pvr2_trace(
223 PVR2_TRACE_ERROR_LEGS,
224 "***WARNING*** device's encoder"
225 " appears to be stuck"
226 " (status=0%08x)",rdData[0]);
227 pvr2_trace(
228 PVR2_TRACE_ERROR_LEGS,
229 "Encoder command: 0x%02x",cmd);
230 for (idx = 4; idx < arg_cnt_send; idx++) {
231 pvr2_trace(
232 PVR2_TRACE_ERROR_LEGS,
233 "Encoder arg%d: 0x%08x",
234 idx-3,wrData[idx]);
235 }
236 pvr2_trace(
237 PVR2_TRACE_ERROR_LEGS,
238 "Giving up waiting."
239 " It is likely that"
240 " this is a bad idea...");
241 ret = -EBUSY;
242 break;
243 }
244 }
245 if (ret) break;
246 wrData[0] = 0x7;
247 ret = pvr2_encoder_read_words(
248 hdw,0,rdData,
249 sizeof(rdData)/sizeof(rdData[0]));
250 if (ret) break;
251 for (idx = 0; idx < arg_cnt_recv; idx++) {
252 argp[idx] = rdData[idx+4];
253 }
254
255 wrData[0] = 0x0;
256 ret = pvr2_encoder_write_words(hdw,wrData,1);
257 if (ret) break;
258
259 } while(0); LOCK_GIVE(hdw->ctl_lock);
260
261 return ret;
262}
263
264
265static int pvr2_encoder_vcmd(struct pvr2_hdw *hdw, int cmd,
266 int args, ...)
267{
268 va_list vl;
269 unsigned int idx;
270 u32 data[12];
271
272 if (args > sizeof(data)/sizeof(data[0])) {
273 pvr2_trace(
274 PVR2_TRACE_ERROR_LEGS,
275 "Failed to write cx23416 command"
276 " - too many arguments"
277 " (was given %u limit %u)",
278 args,(unsigned int)(sizeof(data)/sizeof(data[0])));
279 return -EINVAL;
280 }
281
282 va_start(vl, args);
283 for (idx = 0; idx < args; idx++) {
284 data[idx] = va_arg(vl, u32);
285 }
286 va_end(vl);
287
288 return pvr2_encoder_cmd(hdw,cmd,args,0,data);
289}
290
291int pvr2_encoder_configure(struct pvr2_hdw *hdw)
292{
293 int ret;
294 pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure"
295 " (cx2341x module)");
296 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING;
297 hdw->enc_ctl_state.width = hdw->res_hor_val;
298 hdw->enc_ctl_state.height = hdw->res_ver_val;
299 hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur &
300 (V4L2_STD_NTSC|V4L2_STD_PAL_M)) ?
301 0 : 1);
302
303 ret = 0;
304
305 if (!ret) ret = pvr2_encoder_vcmd(
306 hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
307 0xf0, 0xf0);
308
309 /* setup firmware to notify us about some events (don't know why...) */
310 if (!ret) ret = pvr2_encoder_vcmd(
311 hdw,CX2341X_ENC_SET_EVENT_NOTIFICATION, 4,
312 0, 0, 0x10000000, 0xffffffff);
313
314 if (!ret) ret = pvr2_encoder_vcmd(
315 hdw,CX2341X_ENC_SET_VBI_LINE, 5,
316 0xffffffff,0,0,0,0);
317
318 if (ret) {
319 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
320 "Failed to configure cx32416");
321 return ret;
322 }
323
324 ret = cx2341x_update(hdw,pvr2_encoder_cmd,
325 (hdw->enc_cur_valid ? &hdw->enc_cur_state : 0),
326 &hdw->enc_ctl_state);
327 if (ret) {
328 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
329 "Error from cx2341x module code=%d",ret);
330 return ret;
331 }
332
333 ret = 0;
334
335 if (!ret) ret = pvr2_encoder_vcmd(
336 hdw, CX2341X_ENC_INITIALIZE_INPUT, 0);
337
338 if (ret) {
339 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
340 "Failed to initialize cx32416 video input");
341 return ret;
342 }
343
344 hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
345 memcpy(&hdw->enc_cur_state,&hdw->enc_ctl_state,
346 sizeof(struct cx2341x_mpeg_params));
347 hdw->enc_cur_valid = !0;
348 return 0;
349}
350
351
352int pvr2_encoder_start(struct pvr2_hdw *hdw)
353{
354 int status;
355
356 /* unmask some interrupts */
357 pvr2_write_register(hdw, 0x0048, 0xbfffffff);
358
359 /* change some GPIO data */
360 pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000481);
361 pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000000);
362
363 if (hdw->config == pvr2_config_vbi) {
364 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
365 0x01,0x14);
366 } else if (hdw->config == pvr2_config_mpeg) {
367 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
368 0,0x13);
369 } else {
370 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
371 0,0x13);
372 }
373 if (!status) {
374 hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_RUN);
375 }
376 return status;
377}
378
379int pvr2_encoder_stop(struct pvr2_hdw *hdw)
380{
381 int status;
382
383 /* mask all interrupts */
384 pvr2_write_register(hdw, 0x0048, 0xffffffff);
385
386 if (hdw->config == pvr2_config_vbi) {
387 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_STOP_CAPTURE,3,
388 0x01,0x01,0x14);
389 } else if (hdw->config == pvr2_config_mpeg) {
390 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_STOP_CAPTURE,3,
391 0x01,0,0x13);
392 } else {
393 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_STOP_CAPTURE,3,
394 0x01,0,0x13);
395 }
396
397 /* change some GPIO data */
398 /* Note: Bit d7 of dir appears to control the LED. So we shut it
399 off here. */
400 pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000401);
401 pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000000);
402
403 if (!status) {
404 hdw->subsys_enabled_mask &= ~(1<<PVR2_SUBSYS_B_ENC_RUN);
405 }
406 return status;
407}
408
409
410/*
411 Stuff for Emacs to see, in order to encourage consistent editing style:
412 *** Local Variables: ***
413 *** mode: c ***
414 *** fill-column: 70 ***
415 *** tab-width: 8 ***
416 *** c-basic-offset: 8 ***
417 *** End: ***
418 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.h b/drivers/media/video/pvrusb2/pvrusb2-encoder.h
new file mode 100644
index 000000000000..01b5a0b89c03
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.h
@@ -0,0 +1,42 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_ENCODER_H
24#define __PVRUSB2_ENCODER_H
25
26struct pvr2_hdw;
27
28int pvr2_encoder_configure(struct pvr2_hdw *);
29int pvr2_encoder_start(struct pvr2_hdw *);
30int pvr2_encoder_stop(struct pvr2_hdw *);
31
32#endif /* __PVRUSB2_ENCODER_H */
33
34/*
35 Stuff for Emacs to see, in order to encourage consistent editing style:
36 *** Local Variables: ***
37 *** mode: c ***
38 *** fill-column: 70 ***
39 *** tab-width: 8 ***
40 *** c-basic-offset: 8 ***
41 *** End: ***
42 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
new file mode 100644
index 000000000000..ba2afbfe32c5
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -0,0 +1,384 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_HDW_INTERNAL_H
22#define __PVRUSB2_HDW_INTERNAL_H
23
24/*
25
26 This header sets up all the internal structures and definitions needed to
27 track and coordinate the driver's interaction with the hardware. ONLY
28 source files which actually implement part of that whole circus should be
29 including this header. Higher levels, like the external layers to the
30 various public APIs (V4L, sysfs, etc) should NOT ever include this
31 private, internal header. This means that pvrusb2-hdw, pvrusb2-encoder,
32 etc will include this, but pvrusb2-v4l should not.
33
34*/
35
36#include <linux/config.h>
37#include <linux/videodev2.h>
38#include <linux/i2c.h>
39#include <linux/mutex.h>
40#include "pvrusb2-hdw.h"
41#include "pvrusb2-io.h"
42#include <media/cx2341x.h>
43
44/* Legal values for the SRATE state variable */
45#define PVR2_CVAL_SRATE_48 0
46#define PVR2_CVAL_SRATE_44_1 1
47
48/* Legal values for the AUDIOBITRATE state variable */
49#define PVR2_CVAL_AUDIOBITRATE_384 0
50#define PVR2_CVAL_AUDIOBITRATE_320 1
51#define PVR2_CVAL_AUDIOBITRATE_256 2
52#define PVR2_CVAL_AUDIOBITRATE_224 3
53#define PVR2_CVAL_AUDIOBITRATE_192 4
54#define PVR2_CVAL_AUDIOBITRATE_160 5
55#define PVR2_CVAL_AUDIOBITRATE_128 6
56#define PVR2_CVAL_AUDIOBITRATE_112 7
57#define PVR2_CVAL_AUDIOBITRATE_96 8
58#define PVR2_CVAL_AUDIOBITRATE_80 9
59#define PVR2_CVAL_AUDIOBITRATE_64 10
60#define PVR2_CVAL_AUDIOBITRATE_56 11
61#define PVR2_CVAL_AUDIOBITRATE_48 12
62#define PVR2_CVAL_AUDIOBITRATE_32 13
63#define PVR2_CVAL_AUDIOBITRATE_VBR 14
64
65/* Legal values for the AUDIOEMPHASIS state variable */
66#define PVR2_CVAL_AUDIOEMPHASIS_NONE 0
67#define PVR2_CVAL_AUDIOEMPHASIS_50_15 1
68#define PVR2_CVAL_AUDIOEMPHASIS_CCITT 2
69
70/* Legal values for PVR2_CID_HSM */
71#define PVR2_CVAL_HSM_FAIL 0
72#define PVR2_CVAL_HSM_FULL 1
73#define PVR2_CVAL_HSM_HIGH 2
74
75#define PVR2_VID_ENDPOINT 0x84
76#define PVR2_UNK_ENDPOINT 0x86 /* maybe raw yuv ? */
77#define PVR2_VBI_ENDPOINT 0x88
78
79#define PVR2_CTL_BUFFSIZE 64
80
81#define FREQTABLE_SIZE 500
82
83#define LOCK_TAKE(x) do { mutex_lock(&x##_mutex); x##_held = !0; } while (0)
84#define LOCK_GIVE(x) do { x##_held = 0; mutex_unlock(&x##_mutex); } while (0)
85
86struct pvr2_decoder;
87
88typedef int (*pvr2_ctlf_is_dirty)(struct pvr2_ctrl *);
89typedef void (*pvr2_ctlf_clear_dirty)(struct pvr2_ctrl *);
90typedef int (*pvr2_ctlf_get_value)(struct pvr2_ctrl *,int *);
91typedef int (*pvr2_ctlf_set_value)(struct pvr2_ctrl *,int msk,int val);
92typedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val,
93 char *,unsigned int,unsigned int *);
94typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *,
95 const char *,unsigned int,
96 int *mskp,int *valp);
97typedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *);
98
99/* This structure describes a specific control. A table of these is set up
100 in pvrusb2-hdw.c. */
101struct pvr2_ctl_info {
102 /* Control's name suitable for use as an identifier */
103 const char *name;
104
105 /* Short description of control */
106 const char *desc;
107
108 /* Control's implementation */
109 pvr2_ctlf_get_value get_value; /* Get its value */
110 pvr2_ctlf_set_value set_value; /* Set its value */
111 pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */
112 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */
113 pvr2_ctlf_is_dirty is_dirty; /* Return true if dirty */
114 pvr2_ctlf_clear_dirty clear_dirty; /* Clear dirty state */
115 pvr2_ctlf_get_v4lflags get_v4lflags;/* Retrieve v4l flags */
116
117 /* Control's type (int, enum, bitmask) */
118 enum pvr2_ctl_type type;
119
120 /* Associated V4L control ID, if any */
121 int v4l_id;
122
123 /* Associated driver internal ID, if any */
124 int internal_id;
125
126 /* Don't implicitly initialize this control's value */
127 int skip_init;
128
129 /* Starting value for this control */
130 int default_value;
131
132 /* Type-specific control information */
133 union {
134 struct { /* Integer control */
135 long min_value; /* lower limit */
136 long max_value; /* upper limit */
137 } type_int;
138 struct { /* enumerated control */
139 unsigned int count; /* enum value count */
140 const char **value_names; /* symbol names */
141 } type_enum;
142 struct { /* bitmask control */
143 unsigned int valid_bits; /* bits in use */
144 const char **bit_names; /* symbol name/bit */
145 } type_bitmask;
146 } def;
147};
148
149
150/* Same as pvr2_ctl_info, but includes storage for the control description */
151#define PVR2_CTLD_INFO_DESC_SIZE 32
152struct pvr2_ctld_info {
153 struct pvr2_ctl_info info;
154 char desc[PVR2_CTLD_INFO_DESC_SIZE];
155};
156
157struct pvr2_ctrl {
158 const struct pvr2_ctl_info *info;
159 struct pvr2_hdw *hdw;
160};
161
162
163struct pvr2_audio_stat {
164 void *ctxt;
165 void (*detach)(void *);
166 int (*status)(void *);
167};
168
169struct pvr2_decoder_ctrl {
170 void *ctxt;
171 void (*detach)(void *);
172 void (*enable)(void *,int);
173 int (*tuned)(void *);
174 void (*force_reset)(void *);
175};
176
177#define PVR2_I2C_PEND_DETECT 0x01 /* Need to detect a client type */
178#define PVR2_I2C_PEND_CLIENT 0x02 /* Client needs a specific update */
179#define PVR2_I2C_PEND_REFRESH 0x04 /* Client has specific pending bits */
180#define PVR2_I2C_PEND_STALE 0x08 /* Broadcast pending bits */
181
182#define PVR2_I2C_PEND_ALL (PVR2_I2C_PEND_DETECT |\
183 PVR2_I2C_PEND_CLIENT |\
184 PVR2_I2C_PEND_REFRESH |\
185 PVR2_I2C_PEND_STALE)
186
187/* Disposition of firmware1 loading situation */
188#define FW1_STATE_UNKNOWN 0
189#define FW1_STATE_MISSING 1
190#define FW1_STATE_FAILED 2
191#define FW1_STATE_RELOAD 3
192#define FW1_STATE_OK 4
193
194/* Known major hardware variants, keyed from device ID */
195#define PVR2_HDW_TYPE_29XXX 0
196#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
197#define PVR2_HDW_TYPE_24XXX 1
198#endif
199
200typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16);
201#define PVR2_I2C_FUNC_CNT 128
202
203/* This structure contains all state data directly needed to
204 manipulate the hardware (as opposed to complying with a kernel
205 interface) */
206struct pvr2_hdw {
207 /* Underlying USB device handle */
208 struct usb_device *usb_dev;
209 struct usb_interface *usb_intf;
210
211 /* Device type, one of PVR2_HDW_TYPE_xxxxx */
212 unsigned int hdw_type;
213
214 /* Video spigot */
215 struct pvr2_stream *vid_stream;
216
217 /* Mutex for all hardware state control */
218 struct mutex big_lock_mutex;
219 int big_lock_held; /* For debugging */
220
221 void (*poll_trigger_func)(void *);
222 void *poll_trigger_data;
223
224 char name[32];
225
226 /* I2C stuff */
227 struct i2c_adapter i2c_adap;
228 struct i2c_algorithm i2c_algo;
229 pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
230 int i2c_cx25840_hack_state;
231 int i2c_linked;
232 unsigned int i2c_pend_types; /* Which types of update are needed */
233 unsigned long i2c_pend_mask; /* Change bits we need to scan */
234 unsigned long i2c_stale_mask; /* Pending broadcast change bits */
235 unsigned long i2c_active_mask; /* All change bits currently in use */
236 struct list_head i2c_clients;
237 struct mutex i2c_list_lock;
238
239 /* Frequency table */
240 unsigned int freqTable[FREQTABLE_SIZE];
241 unsigned int freqProgSlot;
242 unsigned int freqSlot;
243
244 /* Stuff for handling low level control interaction with device */
245 struct mutex ctl_lock_mutex;
246 int ctl_lock_held; /* For debugging */
247 struct urb *ctl_write_urb;
248 struct urb *ctl_read_urb;
249 unsigned char *ctl_write_buffer;
250 unsigned char *ctl_read_buffer;
251 volatile int ctl_write_pend_flag;
252 volatile int ctl_read_pend_flag;
253 volatile int ctl_timeout_flag;
254 struct completion ctl_done;
255 unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE];
256 int cmd_debug_state; // Low level command debugging info
257 unsigned char cmd_debug_code; //
258 unsigned int cmd_debug_write_len; //
259 unsigned int cmd_debug_read_len; //
260
261 int flag_ok; // device in known good state
262 int flag_disconnected; // flag_ok == 0 due to disconnect
263 int flag_init_ok; // true if structure is fully initialized
264 int flag_streaming_enabled; // true if streaming should be on
265 int fw1_state; // current situation with fw1
266
267 int flag_decoder_is_tuned;
268
269 struct pvr2_decoder_ctrl *decoder_ctrl;
270
271 // CPU firmware info (used to help find / save firmware data)
272 char *fw_buffer;
273 unsigned int fw_size;
274
275 // Which subsystem pieces have been enabled / configured
276 unsigned long subsys_enabled_mask;
277
278 // Which subsystems are manipulated to enable streaming
279 unsigned long subsys_stream_mask;
280
281 // True if there is a request to trigger logging of state in each
282 // module.
283 int log_requested;
284
285 /* Tuner / frequency control stuff */
286 unsigned int tuner_type;
287 int tuner_updated;
288 unsigned int freqVal;
289 int freqDirty;
290
291 /* Video standard handling */
292 v4l2_std_id std_mask_eeprom; // Hardware supported selections
293 v4l2_std_id std_mask_avail; // Which standards we may select from
294 v4l2_std_id std_mask_cur; // Currently selected standard(s)
295 unsigned int std_enum_cnt; // # of enumerated standards
296 int std_enum_cur; // selected standard enumeration value
297 int std_dirty; // True if std_mask_cur has changed
298 struct pvr2_ctl_info std_info_enum;
299 struct pvr2_ctl_info std_info_avail;
300 struct pvr2_ctl_info std_info_cur;
301 struct v4l2_standard *std_defs;
302 const char **std_enum_names;
303
304 // Generated string names, one per actual V4L2 standard
305 const char *std_mask_ptrs[32];
306 char std_mask_names[32][10];
307
308 int unit_number; /* ID for driver instance */
309 unsigned long serial_number; /* ID for hardware itself */
310
311 /* Minor number used by v4l logic (yes, this is a hack, as there should
312 be no v4l junk here). Probably a better way to do this. */
313 int v4l_minor_number;
314
315 /* Location of eeprom or a negative number if none */
316 int eeprom_addr;
317
318 enum pvr2_config config;
319
320 /* Information about what audio signal we're hearing */
321 int flag_stereo;
322 int flag_bilingual;
323 struct pvr2_audio_stat *audio_stat;
324
325 /* Control state needed for cx2341x module */
326 struct cx2341x_mpeg_params enc_cur_state;
327 struct cx2341x_mpeg_params enc_ctl_state;
328 /* True if an encoder attribute has changed */
329 int enc_stale;
330 /* True if enc_cur_state is valid */
331 int enc_cur_valid;
332
333 /* Control state */
334#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
335 VCREATE_DATA(brightness);
336 VCREATE_DATA(contrast);
337 VCREATE_DATA(saturation);
338 VCREATE_DATA(hue);
339 VCREATE_DATA(volume);
340 VCREATE_DATA(balance);
341 VCREATE_DATA(bass);
342 VCREATE_DATA(treble);
343 VCREATE_DATA(mute);
344 VCREATE_DATA(input);
345 VCREATE_DATA(audiomode);
346 VCREATE_DATA(res_hor);
347 VCREATE_DATA(res_ver);
348 VCREATE_DATA(srate);
349#undef VCREATE_DATA
350
351 struct pvr2_ctld_info *mpeg_ctrl_info;
352
353 struct pvr2_ctrl *controls;
354 unsigned int control_cnt;
355};
356
357int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
358
359unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *);
360
361void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
362 unsigned long msk,unsigned long val);
363void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
364 unsigned long msk,
365 unsigned long val);
366
367void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
368void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
369
370int pvr2_i2c_basic_op(struct pvr2_hdw *,u8 i2c_addr,
371 u8 *wdata,u16 wlen,
372 u8 *rdata,u16 rlen);
373
374#endif /* __PVRUSB2_HDW_INTERNAL_H */
375
376/*
377 Stuff for Emacs to see, in order to encourage consistent editing style:
378 *** Local Variables: ***
379 *** mode: c ***
380 *** fill-column: 75 ***
381 *** tab-width: 8 ***
382 *** c-basic-offset: 8 ***
383 *** End: ***
384 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
new file mode 100644
index 000000000000..643c471375da
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -0,0 +1,3120 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include <linux/errno.h>
23#include <linux/string.h>
24#include <linux/slab.h>
25#include <linux/firmware.h>
26#include <linux/videodev2.h>
27#include <asm/semaphore.h>
28#include "pvrusb2.h"
29#include "pvrusb2-std.h"
30#include "pvrusb2-util.h"
31#include "pvrusb2-hdw.h"
32#include "pvrusb2-i2c-core.h"
33#include "pvrusb2-tuner.h"
34#include "pvrusb2-eeprom.h"
35#include "pvrusb2-hdw-internal.h"
36#include "pvrusb2-encoder.h"
37#include "pvrusb2-debug.h"
38
39struct usb_device_id pvr2_device_table[] = {
40 [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) },
41#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
42 [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) },
43#endif
44 { }
45};
46
47MODULE_DEVICE_TABLE(usb, pvr2_device_table);
48
49static const char *pvr2_device_names[] = {
50 [PVR2_HDW_TYPE_29XXX] = "WinTV PVR USB2 Model Category 29xxxx",
51#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
52 [PVR2_HDW_TYPE_24XXX] = "WinTV PVR USB2 Model Category 24xxxx",
53#endif
54};
55
56struct pvr2_string_table {
57 const char **lst;
58 unsigned int cnt;
59};
60
61#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
62// Names of other client modules to request for 24xxx model hardware
63static const char *pvr2_client_24xxx[] = {
64 "cx25840",
65 "tuner",
66 "tda9887",
67 "wm8775",
68};
69#endif
70
71// Names of other client modules to request for 29xxx model hardware
72static const char *pvr2_client_29xxx[] = {
73 "msp3400",
74 "saa7115",
75 "tuner",
76 "tda9887",
77};
78
79static struct pvr2_string_table pvr2_client_lists[] = {
80 [PVR2_HDW_TYPE_29XXX] = {
81 pvr2_client_29xxx,
82 sizeof(pvr2_client_29xxx)/sizeof(pvr2_client_29xxx[0]),
83 },
84#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
85 [PVR2_HDW_TYPE_24XXX] = {
86 pvr2_client_24xxx,
87 sizeof(pvr2_client_24xxx)/sizeof(pvr2_client_24xxx[0]),
88 },
89#endif
90};
91
92static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0};
93DECLARE_MUTEX(pvr2_unit_sem);
94
95static int ctlchg = 0;
96static int initusbreset = 1;
97static int procreload = 0;
98static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 };
99static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 };
100static int video_std[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 };
101static int init_pause_msec = 0;
102
103module_param(ctlchg, int, S_IRUGO|S_IWUSR);
104MODULE_PARM_DESC(ctlchg, "0=optimize ctl change 1=always accept new ctl value");
105module_param(init_pause_msec, int, S_IRUGO|S_IWUSR);
106MODULE_PARM_DESC(init_pause_msec, "hardware initialization settling delay");
107module_param(initusbreset, int, S_IRUGO|S_IWUSR);
108MODULE_PARM_DESC(initusbreset, "Do USB reset device on probe");
109module_param(procreload, int, S_IRUGO|S_IWUSR);
110MODULE_PARM_DESC(procreload,
111 "Attempt init failure recovery with firmware reload");
112module_param_array(tuner, int, NULL, 0444);
113MODULE_PARM_DESC(tuner,"specify installed tuner type");
114module_param_array(video_std, int, NULL, 0444);
115MODULE_PARM_DESC(video_std,"specify initial video standard");
116module_param_array(tolerance, int, NULL, 0444);
117MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
118
119#define PVR2_CTL_WRITE_ENDPOINT 0x01
120#define PVR2_CTL_READ_ENDPOINT 0x81
121
122#define PVR2_GPIO_IN 0x9008
123#define PVR2_GPIO_OUT 0x900c
124#define PVR2_GPIO_DIR 0x9020
125
126#define trace_firmware(...) pvr2_trace(PVR2_TRACE_FIRMWARE,__VA_ARGS__)
127
128#define PVR2_FIRMWARE_ENDPOINT 0x02
129
130/* size of a firmware chunk */
131#define FIRMWARE_CHUNK_SIZE 0x2000
132
133/* Define the list of additional controls we'll dynamically construct based
134 on query of the cx2341x module. */
135struct pvr2_mpeg_ids {
136 const char *strid;
137 int id;
138};
139static const struct pvr2_mpeg_ids mpeg_ids[] = {
140 {
141 .strid = "audio_layer",
142 .id = V4L2_CID_MPEG_AUDIO_ENCODING,
143 },{
144 .strid = "audio_bitrate",
145 .id = V4L2_CID_MPEG_AUDIO_L2_BITRATE,
146 },{
147 /* Already using audio_mode elsewhere :-( */
148 .strid = "mpeg_audio_mode",
149 .id = V4L2_CID_MPEG_AUDIO_MODE,
150 },{
151 .strid = "mpeg_audio_mode_extension",
152 .id = V4L2_CID_MPEG_AUDIO_MODE_EXTENSION,
153 },{
154 .strid = "audio_emphasis",
155 .id = V4L2_CID_MPEG_AUDIO_EMPHASIS,
156 },{
157 .strid = "audio_crc",
158 .id = V4L2_CID_MPEG_AUDIO_CRC,
159 },{
160 .strid = "video_aspect",
161 .id = V4L2_CID_MPEG_VIDEO_ASPECT,
162 },{
163 .strid = "video_b_frames",
164 .id = V4L2_CID_MPEG_VIDEO_B_FRAMES,
165 },{
166 .strid = "video_gop_size",
167 .id = V4L2_CID_MPEG_VIDEO_GOP_SIZE,
168 },{
169 .strid = "video_gop_closure",
170 .id = V4L2_CID_MPEG_VIDEO_GOP_CLOSURE,
171 },{
172 .strid = "video_pulldown",
173 .id = V4L2_CID_MPEG_VIDEO_PULLDOWN,
174 },{
175 .strid = "video_bitrate_mode",
176 .id = V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
177 },{
178 .strid = "video_bitrate",
179 .id = V4L2_CID_MPEG_VIDEO_BITRATE,
180 },{
181 .strid = "video_bitrate_peak",
182 .id = V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
183 },{
184 .strid = "video_temporal_decimation",
185 .id = V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION,
186 },{
187 .strid = "stream_type",
188 .id = V4L2_CID_MPEG_STREAM_TYPE,
189 },{
190 .strid = "video_spatial_filter_mode",
191 .id = V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE,
192 },{
193 .strid = "video_spatial_filter",
194 .id = V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER,
195 },{
196 .strid = "video_luma_spatial_filter_type",
197 .id = V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE,
198 },{
199 .strid = "video_chroma_spatial_filter_type",
200 .id = V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE,
201 },{
202 .strid = "video_temporal_filter_mode",
203 .id = V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE,
204 },{
205 .strid = "video_temporal_filter",
206 .id = V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER,
207 },{
208 .strid = "video_median_filter_type",
209 .id = V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE,
210 },{
211 .strid = "video_luma_median_filter_top",
212 .id = V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP,
213 },{
214 .strid = "video_luma_median_filter_bottom",
215 .id = V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM,
216 },{
217 .strid = "video_chroma_median_filter_top",
218 .id = V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP,
219 },{
220 .strid = "video_chroma_median_filter_bottom",
221 .id = V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM,
222 }
223};
224#define MPEGDEF_COUNT (sizeof(mpeg_ids)/sizeof(mpeg_ids[0]))
225
226static const char *control_values_srate[] = {
227 [PVR2_CVAL_SRATE_48] = "48KHz",
228 [PVR2_CVAL_SRATE_44_1] = "44.1KHz",
229};
230
231
232
233
234static const char *control_values_input[] = {
235 [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/
236 [PVR2_CVAL_INPUT_RADIO] = "radio",
237 [PVR2_CVAL_INPUT_SVIDEO] = "s-video",
238 [PVR2_CVAL_INPUT_COMPOSITE] = "composite",
239};
240
241
242static const char *control_values_audiomode[] = {
243 [V4L2_TUNER_MODE_MONO] = "Mono",
244 [V4L2_TUNER_MODE_STEREO] = "Stereo",
245 [V4L2_TUNER_MODE_LANG1] = "Lang1",
246 [V4L2_TUNER_MODE_LANG2] = "Lang2",
247 [V4L2_TUNER_MODE_LANG1_LANG2] = "Lang1+Lang2",
248};
249
250
251static const char *control_values_hsm[] = {
252 [PVR2_CVAL_HSM_FAIL] = "Fail",
253 [PVR2_CVAL_HSM_HIGH] = "High",
254 [PVR2_CVAL_HSM_FULL] = "Full",
255};
256
257
258static const char *control_values_subsystem[] = {
259 [PVR2_SUBSYS_B_ENC_FIRMWARE] = "enc_firmware",
260 [PVR2_SUBSYS_B_ENC_CFG] = "enc_config",
261 [PVR2_SUBSYS_B_DIGITIZER_RUN] = "digitizer_run",
262 [PVR2_SUBSYS_B_USBSTREAM_RUN] = "usbstream_run",
263 [PVR2_SUBSYS_B_ENC_RUN] = "enc_run",
264};
265
266
267static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
268{
269 struct pvr2_hdw *hdw = cptr->hdw;
270 if ((hdw->freqProgSlot > 0) && (hdw->freqProgSlot <= FREQTABLE_SIZE)) {
271 *vp = hdw->freqTable[hdw->freqProgSlot-1];
272 } else {
273 *vp = 0;
274 }
275 return 0;
276}
277
278static int ctrl_channelfreq_set(struct pvr2_ctrl *cptr,int m,int v)
279{
280 struct pvr2_hdw *hdw = cptr->hdw;
281 if ((hdw->freqProgSlot > 0) && (hdw->freqProgSlot <= FREQTABLE_SIZE)) {
282 hdw->freqTable[hdw->freqProgSlot-1] = v;
283 }
284 return 0;
285}
286
287static int ctrl_channelprog_get(struct pvr2_ctrl *cptr,int *vp)
288{
289 *vp = cptr->hdw->freqProgSlot;
290 return 0;
291}
292
293static int ctrl_channelprog_set(struct pvr2_ctrl *cptr,int m,int v)
294{
295 struct pvr2_hdw *hdw = cptr->hdw;
296 if ((v >= 0) && (v <= FREQTABLE_SIZE)) {
297 hdw->freqProgSlot = v;
298 }
299 return 0;
300}
301
302static int ctrl_channel_get(struct pvr2_ctrl *cptr,int *vp)
303{
304 *vp = cptr->hdw->freqSlot;
305 return 0;
306}
307
308static int ctrl_channel_set(struct pvr2_ctrl *cptr,int m,int v)
309{
310 unsigned freq = 0;
311 struct pvr2_hdw *hdw = cptr->hdw;
312 hdw->freqSlot = v;
313 if ((hdw->freqSlot > 0) && (hdw->freqSlot <= FREQTABLE_SIZE)) {
314 freq = hdw->freqTable[hdw->freqSlot-1];
315 }
316 if (freq && (freq != hdw->freqVal)) {
317 hdw->freqVal = freq;
318 hdw->freqDirty = !0;
319 }
320 return 0;
321}
322
323static int ctrl_freq_get(struct pvr2_ctrl *cptr,int *vp)
324{
325 *vp = cptr->hdw->freqVal;
326 return 0;
327}
328
329static int ctrl_freq_is_dirty(struct pvr2_ctrl *cptr)
330{
331 return cptr->hdw->freqDirty != 0;
332}
333
334static void ctrl_freq_clear_dirty(struct pvr2_ctrl *cptr)
335{
336 cptr->hdw->freqDirty = 0;
337}
338
339static int ctrl_freq_set(struct pvr2_ctrl *cptr,int m,int v)
340{
341 struct pvr2_hdw *hdw = cptr->hdw;
342 hdw->freqVal = v;
343 hdw->freqDirty = !0;
344 hdw->freqSlot = 0;
345 return 0;
346}
347
348static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr)
349{
350 return cptr->hdw->enc_stale != 0;
351}
352
353static void ctrl_cx2341x_clear_dirty(struct pvr2_ctrl *cptr)
354{
355 cptr->hdw->enc_stale = 0;
356}
357
358static int ctrl_cx2341x_get(struct pvr2_ctrl *cptr,int *vp)
359{
360 int ret;
361 struct v4l2_ext_controls cs;
362 struct v4l2_ext_control c1;
363 memset(&cs,0,sizeof(cs));
364 memset(&c1,0,sizeof(c1));
365 cs.controls = &c1;
366 cs.count = 1;
367 c1.id = cptr->info->v4l_id;
368 ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state,&cs,
369 VIDIOC_G_EXT_CTRLS);
370 if (ret) return ret;
371 *vp = c1.value;
372 return 0;
373}
374
375static int ctrl_cx2341x_set(struct pvr2_ctrl *cptr,int m,int v)
376{
377 int ret;
378 struct v4l2_ext_controls cs;
379 struct v4l2_ext_control c1;
380 memset(&cs,0,sizeof(cs));
381 memset(&c1,0,sizeof(c1));
382 cs.controls = &c1;
383 cs.count = 1;
384 c1.id = cptr->info->v4l_id;
385 c1.value = v;
386 ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state,&cs,
387 VIDIOC_S_EXT_CTRLS);
388 if (ret) return ret;
389 cptr->hdw->enc_stale = !0;
390 return 0;
391}
392
393static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr)
394{
395 struct v4l2_queryctrl qctrl;
396 struct pvr2_ctl_info *info;
397 qctrl.id = cptr->info->v4l_id;
398 cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl);
399 /* Strip out the const so we can adjust a function pointer. It's
400 OK to do this here because we know this is a dynamically created
401 control, so the underlying storage for the info pointer is (a)
402 private to us, and (b) not in read-only storage. Either we do
403 this or we significantly complicate the underlying control
404 implementation. */
405 info = (struct pvr2_ctl_info *)(cptr->info);
406 if (qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY) {
407 if (info->set_value) {
408 info->set_value = 0;
409 }
410 } else {
411 if (!(info->set_value)) {
412 info->set_value = ctrl_cx2341x_set;
413 }
414 }
415 return qctrl.flags;
416}
417
418static int ctrl_streamingenabled_get(struct pvr2_ctrl *cptr,int *vp)
419{
420 *vp = cptr->hdw->flag_streaming_enabled;
421 return 0;
422}
423
424static int ctrl_hsm_get(struct pvr2_ctrl *cptr,int *vp)
425{
426 int result = pvr2_hdw_is_hsm(cptr->hdw);
427 *vp = PVR2_CVAL_HSM_FULL;
428 if (result < 0) *vp = PVR2_CVAL_HSM_FAIL;
429 if (result) *vp = PVR2_CVAL_HSM_HIGH;
430 return 0;
431}
432
433static int ctrl_stdavail_get(struct pvr2_ctrl *cptr,int *vp)
434{
435 *vp = cptr->hdw->std_mask_avail;
436 return 0;
437}
438
439static int ctrl_stdavail_set(struct pvr2_ctrl *cptr,int m,int v)
440{
441 struct pvr2_hdw *hdw = cptr->hdw;
442 v4l2_std_id ns;
443 ns = hdw->std_mask_avail;
444 ns = (ns & ~m) | (v & m);
445 if (ns == hdw->std_mask_avail) return 0;
446 hdw->std_mask_avail = ns;
447 pvr2_hdw_internal_set_std_avail(hdw);
448 pvr2_hdw_internal_find_stdenum(hdw);
449 return 0;
450}
451
452static int ctrl_std_val_to_sym(struct pvr2_ctrl *cptr,int msk,int val,
453 char *bufPtr,unsigned int bufSize,
454 unsigned int *len)
455{
456 *len = pvr2_std_id_to_str(bufPtr,bufSize,msk & val);
457 return 0;
458}
459
460static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
461 const char *bufPtr,unsigned int bufSize,
462 int *mskp,int *valp)
463{
464 int ret;
465 v4l2_std_id id;
466 ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
467 if (ret < 0) return ret;
468 if (mskp) *mskp = id;
469 if (valp) *valp = id;
470 return 0;
471}
472
473static int ctrl_stdcur_get(struct pvr2_ctrl *cptr,int *vp)
474{
475 *vp = cptr->hdw->std_mask_cur;
476 return 0;
477}
478
479static int ctrl_stdcur_set(struct pvr2_ctrl *cptr,int m,int v)
480{
481 struct pvr2_hdw *hdw = cptr->hdw;
482 v4l2_std_id ns;
483 ns = hdw->std_mask_cur;
484 ns = (ns & ~m) | (v & m);
485 if (ns == hdw->std_mask_cur) return 0;
486 hdw->std_mask_cur = ns;
487 hdw->std_dirty = !0;
488 pvr2_hdw_internal_find_stdenum(hdw);
489 return 0;
490}
491
492static int ctrl_stdcur_is_dirty(struct pvr2_ctrl *cptr)
493{
494 return cptr->hdw->std_dirty != 0;
495}
496
497static void ctrl_stdcur_clear_dirty(struct pvr2_ctrl *cptr)
498{
499 cptr->hdw->std_dirty = 0;
500}
501
502static int ctrl_signal_get(struct pvr2_ctrl *cptr,int *vp)
503{
504 *vp = ((pvr2_hdw_get_signal_status_internal(cptr->hdw) &
505 PVR2_SIGNAL_OK) ? 1 : 0);
506 return 0;
507}
508
509static int ctrl_subsys_get(struct pvr2_ctrl *cptr,int *vp)
510{
511 *vp = cptr->hdw->subsys_enabled_mask;
512 return 0;
513}
514
515static int ctrl_subsys_set(struct pvr2_ctrl *cptr,int m,int v)
516{
517 pvr2_hdw_subsys_bit_chg_no_lock(cptr->hdw,m,v);
518 return 0;
519}
520
521static int ctrl_subsys_stream_get(struct pvr2_ctrl *cptr,int *vp)
522{
523 *vp = cptr->hdw->subsys_stream_mask;
524 return 0;
525}
526
527static int ctrl_subsys_stream_set(struct pvr2_ctrl *cptr,int m,int v)
528{
529 pvr2_hdw_subsys_stream_bit_chg_no_lock(cptr->hdw,m,v);
530 return 0;
531}
532
533static int ctrl_stdenumcur_set(struct pvr2_ctrl *cptr,int m,int v)
534{
535 struct pvr2_hdw *hdw = cptr->hdw;
536 if (v < 0) return -EINVAL;
537 if (v > hdw->std_enum_cnt) return -EINVAL;
538 hdw->std_enum_cur = v;
539 if (!v) return 0;
540 v--;
541 if (hdw->std_mask_cur == hdw->std_defs[v].id) return 0;
542 hdw->std_mask_cur = hdw->std_defs[v].id;
543 hdw->std_dirty = !0;
544 return 0;
545}
546
547
548static int ctrl_stdenumcur_get(struct pvr2_ctrl *cptr,int *vp)
549{
550 *vp = cptr->hdw->std_enum_cur;
551 return 0;
552}
553
554
555static int ctrl_stdenumcur_is_dirty(struct pvr2_ctrl *cptr)
556{
557 return cptr->hdw->std_dirty != 0;
558}
559
560
561static void ctrl_stdenumcur_clear_dirty(struct pvr2_ctrl *cptr)
562{
563 cptr->hdw->std_dirty = 0;
564}
565
566
567#define DEFINT(vmin,vmax) \
568 .type = pvr2_ctl_int, \
569 .def.type_int.min_value = vmin, \
570 .def.type_int.max_value = vmax
571
572#define DEFENUM(tab) \
573 .type = pvr2_ctl_enum, \
574 .def.type_enum.count = (sizeof(tab)/sizeof((tab)[0])), \
575 .def.type_enum.value_names = tab
576
577#define DEFBOOL \
578 .type = pvr2_ctl_bool
579
580#define DEFMASK(msk,tab) \
581 .type = pvr2_ctl_bitmask, \
582 .def.type_bitmask.valid_bits = msk, \
583 .def.type_bitmask.bit_names = tab
584
585#define DEFREF(vname) \
586 .set_value = ctrl_set_##vname, \
587 .get_value = ctrl_get_##vname, \
588 .is_dirty = ctrl_isdirty_##vname, \
589 .clear_dirty = ctrl_cleardirty_##vname
590
591
592#define VCREATE_FUNCS(vname) \
593static int ctrl_get_##vname(struct pvr2_ctrl *cptr,int *vp) \
594{*vp = cptr->hdw->vname##_val; return 0;} \
595static int ctrl_set_##vname(struct pvr2_ctrl *cptr,int m,int v) \
596{cptr->hdw->vname##_val = v; cptr->hdw->vname##_dirty = !0; return 0;} \
597static int ctrl_isdirty_##vname(struct pvr2_ctrl *cptr) \
598{return cptr->hdw->vname##_dirty != 0;} \
599static void ctrl_cleardirty_##vname(struct pvr2_ctrl *cptr) \
600{cptr->hdw->vname##_dirty = 0;}
601
602VCREATE_FUNCS(brightness)
603VCREATE_FUNCS(contrast)
604VCREATE_FUNCS(saturation)
605VCREATE_FUNCS(hue)
606VCREATE_FUNCS(volume)
607VCREATE_FUNCS(balance)
608VCREATE_FUNCS(bass)
609VCREATE_FUNCS(treble)
610VCREATE_FUNCS(mute)
611VCREATE_FUNCS(input)
612VCREATE_FUNCS(audiomode)
613VCREATE_FUNCS(res_hor)
614VCREATE_FUNCS(res_ver)
615VCREATE_FUNCS(srate)
616
617#define MIN_FREQ 55250000L
618#define MAX_FREQ 850000000L
619
620/* Table definition of all controls which can be manipulated */
621static const struct pvr2_ctl_info control_defs[] = {
622 {
623 .v4l_id = V4L2_CID_BRIGHTNESS,
624 .desc = "Brightness",
625 .name = "brightness",
626 .default_value = 128,
627 DEFREF(brightness),
628 DEFINT(0,255),
629 },{
630 .v4l_id = V4L2_CID_CONTRAST,
631 .desc = "Contrast",
632 .name = "contrast",
633 .default_value = 68,
634 DEFREF(contrast),
635 DEFINT(0,127),
636 },{
637 .v4l_id = V4L2_CID_SATURATION,
638 .desc = "Saturation",
639 .name = "saturation",
640 .default_value = 64,
641 DEFREF(saturation),
642 DEFINT(0,127),
643 },{
644 .v4l_id = V4L2_CID_HUE,
645 .desc = "Hue",
646 .name = "hue",
647 .default_value = 0,
648 DEFREF(hue),
649 DEFINT(-128,127),
650 },{
651 .v4l_id = V4L2_CID_AUDIO_VOLUME,
652 .desc = "Volume",
653 .name = "volume",
654 .default_value = 65535,
655 DEFREF(volume),
656 DEFINT(0,65535),
657 },{
658 .v4l_id = V4L2_CID_AUDIO_BALANCE,
659 .desc = "Balance",
660 .name = "balance",
661 .default_value = 0,
662 DEFREF(balance),
663 DEFINT(-32768,32767),
664 },{
665 .v4l_id = V4L2_CID_AUDIO_BASS,
666 .desc = "Bass",
667 .name = "bass",
668 .default_value = 0,
669 DEFREF(bass),
670 DEFINT(-32768,32767),
671 },{
672 .v4l_id = V4L2_CID_AUDIO_TREBLE,
673 .desc = "Treble",
674 .name = "treble",
675 .default_value = 0,
676 DEFREF(treble),
677 DEFINT(-32768,32767),
678 },{
679 .v4l_id = V4L2_CID_AUDIO_MUTE,
680 .desc = "Mute",
681 .name = "mute",
682 .default_value = 0,
683 DEFREF(mute),
684 DEFBOOL,
685 },{
686 .desc = "Video Source",
687 .name = "input",
688 .internal_id = PVR2_CID_INPUT,
689 .default_value = PVR2_CVAL_INPUT_TV,
690 DEFREF(input),
691 DEFENUM(control_values_input),
692 },{
693 .desc = "Audio Mode",
694 .name = "audio_mode",
695 .internal_id = PVR2_CID_AUDIOMODE,
696 .default_value = V4L2_TUNER_MODE_STEREO,
697 DEFREF(audiomode),
698 DEFENUM(control_values_audiomode),
699 },{
700 .desc = "Horizontal capture resolution",
701 .name = "resolution_hor",
702 .internal_id = PVR2_CID_HRES,
703 .default_value = 720,
704 DEFREF(res_hor),
705 DEFINT(320,720),
706 },{
707 .desc = "Vertical capture resolution",
708 .name = "resolution_ver",
709 .internal_id = PVR2_CID_VRES,
710 .default_value = 480,
711 DEFREF(res_ver),
712 DEFINT(200,625),
713 },{
714 .v4l_id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ,
715 .desc = "Sample rate",
716 .name = "srate",
717 .default_value = PVR2_CVAL_SRATE_48,
718 DEFREF(srate),
719 DEFENUM(control_values_srate),
720 },{
721 .desc = "Tuner Frequency (Hz)",
722 .name = "frequency",
723 .internal_id = PVR2_CID_FREQUENCY,
724 .default_value = 175250000L,
725 .set_value = ctrl_freq_set,
726 .get_value = ctrl_freq_get,
727 .is_dirty = ctrl_freq_is_dirty,
728 .clear_dirty = ctrl_freq_clear_dirty,
729 DEFINT(MIN_FREQ,MAX_FREQ),
730 },{
731 .desc = "Channel",
732 .name = "channel",
733 .set_value = ctrl_channel_set,
734 .get_value = ctrl_channel_get,
735 DEFINT(0,FREQTABLE_SIZE),
736 },{
737 .desc = "Channel Program Frequency",
738 .name = "freq_table_value",
739 .set_value = ctrl_channelfreq_set,
740 .get_value = ctrl_channelfreq_get,
741 DEFINT(MIN_FREQ,MAX_FREQ),
742 },{
743 .desc = "Channel Program ID",
744 .name = "freq_table_channel",
745 .set_value = ctrl_channelprog_set,
746 .get_value = ctrl_channelprog_get,
747 DEFINT(0,FREQTABLE_SIZE),
748 },{
749 .desc = "Streaming Enabled",
750 .name = "streaming_enabled",
751 .get_value = ctrl_streamingenabled_get,
752 DEFBOOL,
753 },{
754 .desc = "USB Speed",
755 .name = "usb_speed",
756 .get_value = ctrl_hsm_get,
757 DEFENUM(control_values_hsm),
758 },{
759 .desc = "Signal Present",
760 .name = "signal_present",
761 .get_value = ctrl_signal_get,
762 DEFBOOL,
763 },{
764 .desc = "Video Standards Available Mask",
765 .name = "video_standard_mask_available",
766 .internal_id = PVR2_CID_STDAVAIL,
767 .skip_init = !0,
768 .get_value = ctrl_stdavail_get,
769 .set_value = ctrl_stdavail_set,
770 .val_to_sym = ctrl_std_val_to_sym,
771 .sym_to_val = ctrl_std_sym_to_val,
772 .type = pvr2_ctl_bitmask,
773 },{
774 .desc = "Video Standards In Use Mask",
775 .name = "video_standard_mask_active",
776 .internal_id = PVR2_CID_STDCUR,
777 .skip_init = !0,
778 .get_value = ctrl_stdcur_get,
779 .set_value = ctrl_stdcur_set,
780 .is_dirty = ctrl_stdcur_is_dirty,
781 .clear_dirty = ctrl_stdcur_clear_dirty,
782 .val_to_sym = ctrl_std_val_to_sym,
783 .sym_to_val = ctrl_std_sym_to_val,
784 .type = pvr2_ctl_bitmask,
785 },{
786 .desc = "Subsystem enabled mask",
787 .name = "debug_subsys_mask",
788 .skip_init = !0,
789 .get_value = ctrl_subsys_get,
790 .set_value = ctrl_subsys_set,
791 DEFMASK(PVR2_SUBSYS_ALL,control_values_subsystem),
792 },{
793 .desc = "Subsystem stream mask",
794 .name = "debug_subsys_stream_mask",
795 .skip_init = !0,
796 .get_value = ctrl_subsys_stream_get,
797 .set_value = ctrl_subsys_stream_set,
798 DEFMASK(PVR2_SUBSYS_ALL,control_values_subsystem),
799 },{
800 .desc = "Video Standard Name",
801 .name = "video_standard",
802 .internal_id = PVR2_CID_STDENUM,
803 .skip_init = !0,
804 .get_value = ctrl_stdenumcur_get,
805 .set_value = ctrl_stdenumcur_set,
806 .is_dirty = ctrl_stdenumcur_is_dirty,
807 .clear_dirty = ctrl_stdenumcur_clear_dirty,
808 .type = pvr2_ctl_enum,
809 }
810};
811
812#define CTRLDEF_COUNT (sizeof(control_defs)/sizeof(control_defs[0]))
813
814
815const char *pvr2_config_get_name(enum pvr2_config cfg)
816{
817 switch (cfg) {
818 case pvr2_config_empty: return "empty";
819 case pvr2_config_mpeg: return "mpeg";
820 case pvr2_config_vbi: return "vbi";
821 case pvr2_config_radio: return "radio";
822 }
823 return "<unknown>";
824}
825
826
827struct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *hdw)
828{
829 return hdw->usb_dev;
830}
831
832
833unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
834{
835 return hdw->serial_number;
836}
837
838
839struct pvr2_hdw *pvr2_hdw_find(int unit_number)
840{
841 if (unit_number < 0) return 0;
842 if (unit_number >= PVR_NUM) return 0;
843 return unit_pointers[unit_number];
844}
845
846
847int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
848{
849 return hdw->unit_number;
850}
851
852
853/* Attempt to locate one of the given set of files. Messages are logged
854 appropriate to what has been found. The return value will be 0 or
855 greater on success (it will be the index of the file name found) and
856 fw_entry will be filled in. Otherwise a negative error is returned on
857 failure. If the return value is -ENOENT then no viable firmware file
858 could be located. */
859static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
860 const struct firmware **fw_entry,
861 const char *fwtypename,
862 unsigned int fwcount,
863 const char *fwnames[])
864{
865 unsigned int idx;
866 int ret = -EINVAL;
867 for (idx = 0; idx < fwcount; idx++) {
868 ret = request_firmware(fw_entry,
869 fwnames[idx],
870 &hdw->usb_dev->dev);
871 if (!ret) {
872 trace_firmware("Located %s firmware: %s;"
873 " uploading...",
874 fwtypename,
875 fwnames[idx]);
876 return idx;
877 }
878 if (ret == -ENOENT) continue;
879 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
880 "request_firmware fatal error with code=%d",ret);
881 return ret;
882 }
883 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
884 "***WARNING***"
885 " Device %s firmware"
886 " seems to be missing.",
887 fwtypename);
888 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
889 "Did you install the pvrusb2 firmware files"
890 " in their proper location?");
891 if (fwcount == 1) {
892 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
893 "request_firmware unable to locate %s file %s",
894 fwtypename,fwnames[0]);
895 } else {
896 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
897 "request_firmware unable to locate"
898 " one of the following %s files:",
899 fwtypename);
900 for (idx = 0; idx < fwcount; idx++) {
901 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
902 "request_firmware: Failed to find %s",
903 fwnames[idx]);
904 }
905 }
906 return ret;
907}
908
909
910/*
911 * pvr2_upload_firmware1().
912 *
913 * Send the 8051 firmware to the device. After the upload, arrange for
914 * device to re-enumerate.
915 *
916 * NOTE : the pointer to the firmware data given by request_firmware()
917 * is not suitable for an usb transaction.
918 *
919 */
920int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
921{
922 const struct firmware *fw_entry = 0;
923 void *fw_ptr;
924 unsigned int pipe;
925 int ret;
926 u16 address;
927 static const char *fw_files_29xxx[] = {
928 "v4l-pvrusb2-29xxx-01.fw",
929 };
930#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
931 static const char *fw_files_24xxx[] = {
932 "v4l-pvrusb2-24xxx-01.fw",
933 };
934#endif
935 static const struct pvr2_string_table fw_file_defs[] = {
936 [PVR2_HDW_TYPE_29XXX] = {
937 fw_files_29xxx,
938 sizeof(fw_files_29xxx)/sizeof(fw_files_29xxx[0]),
939 },
940#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
941 [PVR2_HDW_TYPE_24XXX] = {
942 fw_files_24xxx,
943 sizeof(fw_files_24xxx)/sizeof(fw_files_24xxx[0]),
944 },
945#endif
946 };
947 hdw->fw1_state = FW1_STATE_FAILED; // default result
948
949 trace_firmware("pvr2_upload_firmware1");
950
951 ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller",
952 fw_file_defs[hdw->hdw_type].cnt,
953 fw_file_defs[hdw->hdw_type].lst);
954 if (ret < 0) {
955 if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING;
956 return ret;
957 }
958
959 usb_settoggle(hdw->usb_dev, 0 & 0xf, !(0 & USB_DIR_IN), 0);
960 usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f));
961
962 pipe = usb_sndctrlpipe(hdw->usb_dev, 0);
963
964 if (fw_entry->size != 0x2000){
965 pvr2_trace(PVR2_TRACE_ERROR_LEGS,"wrong fx2 firmware size");
966 release_firmware(fw_entry);
967 return -ENOMEM;
968 }
969
970 fw_ptr = kmalloc(0x800, GFP_KERNEL);
971 if (fw_ptr == NULL){
972 release_firmware(fw_entry);
973 return -ENOMEM;
974 }
975
976 /* We have to hold the CPU during firmware upload. */
977 pvr2_hdw_cpureset_assert(hdw,1);
978
979 /* upload the firmware to address 0000-1fff in 2048 (=0x800) bytes
980 chunk. */
981
982 ret = 0;
983 for(address = 0; address < fw_entry->size; address += 0x800) {
984 memcpy(fw_ptr, fw_entry->data + address, 0x800);
985 ret += usb_control_msg(hdw->usb_dev, pipe, 0xa0, 0x40, address,
986 0, fw_ptr, 0x800, HZ);
987 }
988
989 trace_firmware("Upload done, releasing device's CPU");
990
991 /* Now release the CPU. It will disconnect and reconnect later. */
992 pvr2_hdw_cpureset_assert(hdw,0);
993
994 kfree(fw_ptr);
995 release_firmware(fw_entry);
996
997 trace_firmware("Upload done (%d bytes sent)",ret);
998
999 /* We should have written 8192 bytes */
1000 if (ret == 8192) {
1001 hdw->fw1_state = FW1_STATE_RELOAD;
1002 return 0;
1003 }
1004
1005 return -EIO;
1006}
1007
1008
1009/*
1010 * pvr2_upload_firmware2()
1011 *
1012 * This uploads encoder firmware on endpoint 2.
1013 *
1014 */
1015
1016int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1017{
1018 const struct firmware *fw_entry = 0;
1019 void *fw_ptr;
1020 unsigned int pipe, fw_len, fw_done;
1021 int actual_length;
1022 int ret = 0;
1023 int fwidx;
1024 static const char *fw_files[] = {
1025 CX2341X_FIRM_ENC_FILENAME,
1026 };
1027
1028 trace_firmware("pvr2_upload_firmware2");
1029
1030 ret = pvr2_locate_firmware(hdw,&fw_entry,"encoder",
1031 sizeof(fw_files)/sizeof(fw_files[0]),
1032 fw_files);
1033 if (ret < 0) return ret;
1034 fwidx = ret;
1035 ret = 0;
1036 /* Since we're about to completely reinitialize the encoder,
1037 invalidate our cached copy of its configuration state. Next
1038 time we configure the encoder, then we'll fully configure it. */
1039 hdw->enc_cur_valid = 0;
1040
1041 /* First prepare firmware loading */
1042 ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/
1043 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/
1044 ret |= pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000008); /*gpio output state*/
1045 ret |= pvr2_hdw_cmd_deep_reset(hdw);
1046 ret |= pvr2_write_register(hdw, 0xa064, 0x00000000); /*APU command*/
1047 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000408); /*gpio dir*/
1048 ret |= pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000008); /*gpio output state*/
1049 ret |= pvr2_write_register(hdw, 0x9058, 0xffffffed); /*VPU ctrl*/
1050 ret |= pvr2_write_register(hdw, 0x9054, 0xfffffffd); /*reset hw blocks*/
1051 ret |= pvr2_write_register(hdw, 0x07f8, 0x80000800); /*encoder SDRAM refresh*/
1052 ret |= pvr2_write_register(hdw, 0x07fc, 0x0000001a); /*encoder SDRAM pre-charge*/
1053 ret |= pvr2_write_register(hdw, 0x0700, 0x00000000); /*I2C clock*/
1054 ret |= pvr2_write_register(hdw, 0xaa00, 0x00000000); /*unknown*/
1055 ret |= pvr2_write_register(hdw, 0xaa04, 0x00057810); /*unknown*/
1056 ret |= pvr2_write_register(hdw, 0xaa10, 0x00148500); /*unknown*/
1057 ret |= pvr2_write_register(hdw, 0xaa18, 0x00840000); /*unknown*/
1058 ret |= pvr2_write_u8(hdw, 0x52, 0);
1059 ret |= pvr2_write_u16(hdw, 0x0600, 0);
1060
1061 if (ret) {
1062 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1063 "firmware2 upload prep failed, ret=%d",ret);
1064 release_firmware(fw_entry);
1065 return ret;
1066 }
1067
1068 /* Now send firmware */
1069
1070 fw_len = fw_entry->size;
1071
1072 if (fw_len % FIRMWARE_CHUNK_SIZE) {
1073 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1074 "size of %s firmware"
1075 " must be a multiple of 8192B",
1076 fw_files[fwidx]);
1077 release_firmware(fw_entry);
1078 return -1;
1079 }
1080
1081 fw_ptr = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL);
1082 if (fw_ptr == NULL){
1083 release_firmware(fw_entry);
1084 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1085 "failed to allocate memory for firmware2 upload");
1086 return -ENOMEM;
1087 }
1088
1089 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT);
1090
1091 for (fw_done = 0 ; (fw_done < fw_len) && !ret ;
1092 fw_done += FIRMWARE_CHUNK_SIZE ) {
1093 int i;
1094 memcpy(fw_ptr, fw_entry->data + fw_done, FIRMWARE_CHUNK_SIZE);
1095 /* Usbsnoop log shows that we must swap bytes... */
1096 for (i = 0; i < FIRMWARE_CHUNK_SIZE/4 ; i++)
1097 ((u32 *)fw_ptr)[i] = ___swab32(((u32 *)fw_ptr)[i]);
1098
1099 ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,
1100 FIRMWARE_CHUNK_SIZE,
1101 &actual_length, HZ);
1102 ret |= (actual_length != FIRMWARE_CHUNK_SIZE);
1103 }
1104
1105 trace_firmware("upload of %s : %i / %i ",
1106 fw_files[fwidx],fw_done,fw_len);
1107
1108 kfree(fw_ptr);
1109 release_firmware(fw_entry);
1110
1111 if (ret) {
1112 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1113 "firmware2 upload transfer failure");
1114 return ret;
1115 }
1116
1117 /* Finish upload */
1118
1119 ret |= pvr2_write_register(hdw, 0x9054, 0xffffffff); /*reset hw blocks*/
1120 ret |= pvr2_write_register(hdw, 0x9058, 0xffffffe8); /*VPU ctrl*/
1121 ret |= pvr2_write_u16(hdw, 0x0600, 0);
1122
1123 if (ret) {
1124 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1125 "firmware2 upload post-proc failure");
1126 } else {
1127 hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_FIRMWARE);
1128 }
1129 return ret;
1130}
1131
1132
1133#define FIRMWARE_RECOVERY_BITS \
1134 ((1<<PVR2_SUBSYS_B_ENC_CFG) | \
1135 (1<<PVR2_SUBSYS_B_ENC_RUN) | \
1136 (1<<PVR2_SUBSYS_B_ENC_FIRMWARE) | \
1137 (1<<PVR2_SUBSYS_B_USBSTREAM_RUN))
1138
1139/*
1140
1141 This single function is key to pretty much everything. The pvrusb2
1142 device can logically be viewed as a series of subsystems which can be
1143 stopped / started or unconfigured / configured. To get things streaming,
1144 one must configure everything and start everything, but there may be
1145 various reasons over time to deconfigure something or stop something.
1146 This function handles all of this activity. Everything EVERYWHERE that
1147 must affect a subsystem eventually comes here to do the work.
1148
1149 The current state of all subsystems is represented by a single bit mask,
1150 known as subsys_enabled_mask. The bit positions are defined by the
1151 PVR2_SUBSYS_xxxx macros, with one subsystem per bit position. At any
1152 time the set of configured or active subsystems can be queried just by
1153 looking at that mask. To change bits in that mask, this function here
1154 must be called. The "msk" argument indicates which bit positions to
1155 change, and the "val" argument defines the new values for the positions
1156 defined by "msk".
1157
1158 There is a priority ordering of starting / stopping things, and for
1159 multiple requested changes, this function implements that ordering.
1160 (Thus we will act on a request to load encoder firmware before we
1161 configure the encoder.) In addition to priority ordering, there is a
1162 recovery strategy implemented here. If a particular step fails and we
1163 detect that failure, this function will clear the affected subsystem bits
1164 and restart. Thus we have a means for recovering from a dead encoder:
1165 Clear all bits that correspond to subsystems that we need to restart /
1166 reconfigure and start over.
1167
1168*/
1169void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
1170 unsigned long msk,unsigned long val)
1171{
1172 unsigned long nmsk;
1173 unsigned long vmsk;
1174 int ret;
1175 unsigned int tryCount = 0;
1176
1177 if (!hdw->flag_ok) return;
1178
1179 msk &= PVR2_SUBSYS_ALL;
1180 nmsk = (hdw->subsys_enabled_mask & ~msk) | (val & msk);
1181 nmsk &= PVR2_SUBSYS_ALL;
1182
1183 for (;;) {
1184 tryCount++;
1185 if (!((nmsk ^ hdw->subsys_enabled_mask) &
1186 PVR2_SUBSYS_ALL)) break;
1187 if (tryCount > 4) {
1188 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1189 "Too many retries when configuring device;"
1190 " giving up");
1191 pvr2_hdw_render_useless(hdw);
1192 break;
1193 }
1194 if (tryCount > 1) {
1195 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1196 "Retrying device reconfiguration");
1197 }
1198 pvr2_trace(PVR2_TRACE_INIT,
1199 "subsys mask changing 0x%lx:0x%lx"
1200 " from 0x%lx to 0x%lx",
1201 msk,val,hdw->subsys_enabled_mask,nmsk);
1202
1203 vmsk = (nmsk ^ hdw->subsys_enabled_mask) &
1204 hdw->subsys_enabled_mask;
1205 if (vmsk) {
1206 if (vmsk & (1<<PVR2_SUBSYS_B_ENC_RUN)) {
1207 pvr2_trace(PVR2_TRACE_CTL,
1208 "/*---TRACE_CTL----*/"
1209 " pvr2_encoder_stop");
1210 ret = pvr2_encoder_stop(hdw);
1211 if (ret) {
1212 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1213 "Error recovery initiated");
1214 hdw->subsys_enabled_mask &=
1215 ~FIRMWARE_RECOVERY_BITS;
1216 continue;
1217 }
1218 }
1219 if (vmsk & (1<<PVR2_SUBSYS_B_USBSTREAM_RUN)) {
1220 pvr2_trace(PVR2_TRACE_CTL,
1221 "/*---TRACE_CTL----*/"
1222 " pvr2_hdw_cmd_usbstream(0)");
1223 pvr2_hdw_cmd_usbstream(hdw,0);
1224 }
1225 if (vmsk & (1<<PVR2_SUBSYS_B_DIGITIZER_RUN)) {
1226 pvr2_trace(PVR2_TRACE_CTL,
1227 "/*---TRACE_CTL----*/"
1228 " decoder disable");
1229 if (hdw->decoder_ctrl) {
1230 hdw->decoder_ctrl->enable(
1231 hdw->decoder_ctrl->ctxt,0);
1232 } else {
1233 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1234 "WARNING:"
1235 " No decoder present");
1236 }
1237 hdw->subsys_enabled_mask &=
1238 ~(1<<PVR2_SUBSYS_B_DIGITIZER_RUN);
1239 }
1240 if (vmsk & PVR2_SUBSYS_CFG_ALL) {
1241 hdw->subsys_enabled_mask &=
1242 ~(vmsk & PVR2_SUBSYS_CFG_ALL);
1243 }
1244 }
1245 vmsk = (nmsk ^ hdw->subsys_enabled_mask) & nmsk;
1246 if (vmsk) {
1247 if (vmsk & (1<<PVR2_SUBSYS_B_ENC_FIRMWARE)) {
1248 pvr2_trace(PVR2_TRACE_CTL,
1249 "/*---TRACE_CTL----*/"
1250 " pvr2_upload_firmware2");
1251 ret = pvr2_upload_firmware2(hdw);
1252 if (ret) {
1253 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1254 "Failure uploading encoder"
1255 " firmware");
1256 pvr2_hdw_render_useless(hdw);
1257 break;
1258 }
1259 }
1260 if (vmsk & (1<<PVR2_SUBSYS_B_ENC_CFG)) {
1261 pvr2_trace(PVR2_TRACE_CTL,
1262 "/*---TRACE_CTL----*/"
1263 " pvr2_encoder_configure");
1264 ret = pvr2_encoder_configure(hdw);
1265 if (ret) {
1266 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1267 "Error recovery initiated");
1268 hdw->subsys_enabled_mask &=
1269 ~FIRMWARE_RECOVERY_BITS;
1270 continue;
1271 }
1272 }
1273 if (vmsk & (1<<PVR2_SUBSYS_B_DIGITIZER_RUN)) {
1274 pvr2_trace(PVR2_TRACE_CTL,
1275 "/*---TRACE_CTL----*/"
1276 " decoder enable");
1277 if (hdw->decoder_ctrl) {
1278 hdw->decoder_ctrl->enable(
1279 hdw->decoder_ctrl->ctxt,!0);
1280 } else {
1281 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1282 "WARNING:"
1283 " No decoder present");
1284 }
1285 hdw->subsys_enabled_mask |=
1286 (1<<PVR2_SUBSYS_B_DIGITIZER_RUN);
1287 }
1288 if (vmsk & (1<<PVR2_SUBSYS_B_USBSTREAM_RUN)) {
1289 pvr2_trace(PVR2_TRACE_CTL,
1290 "/*---TRACE_CTL----*/"
1291 " pvr2_hdw_cmd_usbstream(1)");
1292 pvr2_hdw_cmd_usbstream(hdw,!0);
1293 }
1294 if (vmsk & (1<<PVR2_SUBSYS_B_ENC_RUN)) {
1295 pvr2_trace(PVR2_TRACE_CTL,
1296 "/*---TRACE_CTL----*/"
1297 " pvr2_encoder_start");
1298 ret = pvr2_encoder_start(hdw);
1299 if (ret) {
1300 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1301 "Error recovery initiated");
1302 hdw->subsys_enabled_mask &=
1303 ~FIRMWARE_RECOVERY_BITS;
1304 continue;
1305 }
1306 }
1307 }
1308 }
1309}
1310
1311
1312void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
1313 unsigned long msk,unsigned long val)
1314{
1315 LOCK_TAKE(hdw->big_lock); do {
1316 pvr2_hdw_subsys_bit_chg_no_lock(hdw,msk,val);
1317 } while (0); LOCK_GIVE(hdw->big_lock);
1318}
1319
1320
1321void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk)
1322{
1323 pvr2_hdw_subsys_bit_chg(hdw,msk,msk);
1324}
1325
1326
1327void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk)
1328{
1329 pvr2_hdw_subsys_bit_chg(hdw,msk,0);
1330}
1331
1332
1333unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw)
1334{
1335 return hdw->subsys_enabled_mask;
1336}
1337
1338
1339unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
1340{
1341 return hdw->subsys_stream_mask;
1342}
1343
1344
1345void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
1346 unsigned long msk,
1347 unsigned long val)
1348{
1349 unsigned long val2;
1350 msk &= PVR2_SUBSYS_ALL;
1351 val2 = ((hdw->subsys_stream_mask & ~msk) | (val & msk));
1352 pvr2_trace(PVR2_TRACE_INIT,
1353 "stream mask changing 0x%lx:0x%lx from 0x%lx to 0x%lx",
1354 msk,val,hdw->subsys_stream_mask,val2);
1355 hdw->subsys_stream_mask = val2;
1356}
1357
1358
1359void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
1360 unsigned long msk,
1361 unsigned long val)
1362{
1363 LOCK_TAKE(hdw->big_lock); do {
1364 pvr2_hdw_subsys_stream_bit_chg_no_lock(hdw,msk,val);
1365 } while (0); LOCK_GIVE(hdw->big_lock);
1366}
1367
1368
1369int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
1370{
1371 if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0;
1372 if (enableFl) {
1373 pvr2_trace(PVR2_TRACE_START_STOP,
1374 "/*--TRACE_STREAM--*/ enable");
1375 pvr2_hdw_subsys_bit_chg_no_lock(hdw,~0,~0);
1376 } else {
1377 pvr2_trace(PVR2_TRACE_START_STOP,
1378 "/*--TRACE_STREAM--*/ disable");
1379 pvr2_hdw_subsys_bit_chg_no_lock(hdw,hdw->subsys_stream_mask,0);
1380 }
1381 if (!hdw->flag_ok) return -EIO;
1382 hdw->flag_streaming_enabled = enableFl != 0;
1383 return 0;
1384}
1385
1386
1387int pvr2_hdw_get_streaming(struct pvr2_hdw *hdw)
1388{
1389 return hdw->flag_streaming_enabled != 0;
1390}
1391
1392
1393int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
1394{
1395 int ret;
1396 LOCK_TAKE(hdw->big_lock); do {
1397 ret = pvr2_hdw_set_streaming_no_lock(hdw,enable_flag);
1398 } while (0); LOCK_GIVE(hdw->big_lock);
1399 return ret;
1400}
1401
1402
1403int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
1404 enum pvr2_config config)
1405{
1406 unsigned long sm = hdw->subsys_enabled_mask;
1407 if (!hdw->flag_ok) return -EIO;
1408 pvr2_hdw_subsys_bit_chg_no_lock(hdw,hdw->subsys_stream_mask,0);
1409 hdw->config = config;
1410 pvr2_hdw_subsys_bit_chg_no_lock(hdw,~0,sm);
1411 return 0;
1412}
1413
1414
1415int pvr2_hdw_set_stream_type(struct pvr2_hdw *hdw,enum pvr2_config config)
1416{
1417 int ret;
1418 if (!hdw->flag_ok) return -EIO;
1419 LOCK_TAKE(hdw->big_lock);
1420 ret = pvr2_hdw_set_stream_type_no_lock(hdw,config);
1421 LOCK_GIVE(hdw->big_lock);
1422 return ret;
1423}
1424
1425
1426static int get_default_tuner_type(struct pvr2_hdw *hdw)
1427{
1428 int unit_number = hdw->unit_number;
1429 int tp = -1;
1430 if ((unit_number >= 0) && (unit_number < PVR_NUM)) {
1431 tp = tuner[unit_number];
1432 }
1433 if (tp < 0) return -EINVAL;
1434 hdw->tuner_type = tp;
1435 return 0;
1436}
1437
1438
1439static v4l2_std_id get_default_standard(struct pvr2_hdw *hdw)
1440{
1441 int unit_number = hdw->unit_number;
1442 int tp = 0;
1443 if ((unit_number >= 0) && (unit_number < PVR_NUM)) {
1444 tp = video_std[unit_number];
1445 }
1446 return tp;
1447}
1448
1449
1450static unsigned int get_default_error_tolerance(struct pvr2_hdw *hdw)
1451{
1452 int unit_number = hdw->unit_number;
1453 int tp = 0;
1454 if ((unit_number >= 0) && (unit_number < PVR_NUM)) {
1455 tp = tolerance[unit_number];
1456 }
1457 return tp;
1458}
1459
1460
1461static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw)
1462{
1463 /* Try a harmless request to fetch the eeprom's address over
1464 endpoint 1. See what happens. Only the full FX2 image can
1465 respond to this. If this probe fails then likely the FX2
1466 firmware needs be loaded. */
1467 int result;
1468 LOCK_TAKE(hdw->ctl_lock); do {
1469 hdw->cmd_buffer[0] = 0xeb;
1470 result = pvr2_send_request_ex(hdw,HZ*1,!0,
1471 hdw->cmd_buffer,1,
1472 hdw->cmd_buffer,1);
1473 if (result < 0) break;
1474 } while(0); LOCK_GIVE(hdw->ctl_lock);
1475 if (result) {
1476 pvr2_trace(PVR2_TRACE_INIT,
1477 "Probe of device endpoint 1 result status %d",
1478 result);
1479 } else {
1480 pvr2_trace(PVR2_TRACE_INIT,
1481 "Probe of device endpoint 1 succeeded");
1482 }
1483 return result == 0;
1484}
1485
1486static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw)
1487{
1488 char buf[40];
1489 unsigned int bcnt;
1490 v4l2_std_id std1,std2;
1491
1492 std1 = get_default_standard(hdw);
1493
1494 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),hdw->std_mask_eeprom);
1495 pvr2_trace(PVR2_TRACE_INIT,
1496 "Supported video standard(s) reported by eeprom: %.*s",
1497 bcnt,buf);
1498
1499 hdw->std_mask_avail = hdw->std_mask_eeprom;
1500
1501 std2 = std1 & ~hdw->std_mask_avail;
1502 if (std2) {
1503 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std2);
1504 pvr2_trace(PVR2_TRACE_INIT,
1505 "Expanding supported video standards"
1506 " to include: %.*s",
1507 bcnt,buf);
1508 hdw->std_mask_avail |= std2;
1509 }
1510
1511 pvr2_hdw_internal_set_std_avail(hdw);
1512
1513 if (std1) {
1514 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std1);
1515 pvr2_trace(PVR2_TRACE_INIT,
1516 "Initial video standard forced to %.*s",
1517 bcnt,buf);
1518 hdw->std_mask_cur = std1;
1519 hdw->std_dirty = !0;
1520 pvr2_hdw_internal_find_stdenum(hdw);
1521 return;
1522 }
1523
1524 if (hdw->std_enum_cnt > 1) {
1525 // Autoselect the first listed standard
1526 hdw->std_enum_cur = 1;
1527 hdw->std_mask_cur = hdw->std_defs[hdw->std_enum_cur-1].id;
1528 hdw->std_dirty = !0;
1529 pvr2_trace(PVR2_TRACE_INIT,
1530 "Initial video standard auto-selected to %s",
1531 hdw->std_defs[hdw->std_enum_cur-1].name);
1532 return;
1533 }
1534
1535 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1536 "Unable to select a viable initial video standard");
1537}
1538
1539
1540static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1541{
1542 int ret;
1543 unsigned int idx;
1544 struct pvr2_ctrl *cptr;
1545 int reloadFl = 0;
1546 if (!reloadFl) {
1547 reloadFl = (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints
1548 == 0);
1549 if (reloadFl) {
1550 pvr2_trace(PVR2_TRACE_INIT,
1551 "USB endpoint config looks strange"
1552 "; possibly firmware needs to be loaded");
1553 }
1554 }
1555 if (!reloadFl) {
1556 reloadFl = !pvr2_hdw_check_firmware(hdw);
1557 if (reloadFl) {
1558 pvr2_trace(PVR2_TRACE_INIT,
1559 "Check for FX2 firmware failed"
1560 "; possibly firmware needs to be loaded");
1561 }
1562 }
1563 if (reloadFl) {
1564 if (pvr2_upload_firmware1(hdw) != 0) {
1565 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1566 "Failure uploading firmware1");
1567 }
1568 return;
1569 }
1570 hdw->fw1_state = FW1_STATE_OK;
1571
1572 if (initusbreset) {
1573 pvr2_hdw_device_reset(hdw);
1574 }
1575 if (!pvr2_hdw_dev_ok(hdw)) return;
1576
1577 for (idx = 0; idx < pvr2_client_lists[hdw->hdw_type].cnt; idx++) {
1578 request_module(pvr2_client_lists[hdw->hdw_type].lst[idx]);
1579 }
1580
1581 pvr2_hdw_cmd_powerup(hdw);
1582 if (!pvr2_hdw_dev_ok(hdw)) return;
1583
1584 if (pvr2_upload_firmware2(hdw)){
1585 pvr2_trace(PVR2_TRACE_ERROR_LEGS,"device unstable!!");
1586 pvr2_hdw_render_useless(hdw);
1587 return;
1588 }
1589
1590 // This step MUST happen after the earlier powerup step.
1591 pvr2_i2c_core_init(hdw);
1592 if (!pvr2_hdw_dev_ok(hdw)) return;
1593
1594 for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
1595 cptr = hdw->controls + idx;
1596 if (cptr->info->skip_init) continue;
1597 if (!cptr->info->set_value) continue;
1598 cptr->info->set_value(cptr,~0,cptr->info->default_value);
1599 }
1600
1601 // Do not use pvr2_reset_ctl_endpoints() here. It is not
1602 // thread-safe against the normal pvr2_send_request() mechanism.
1603 // (We should make it thread safe).
1604
1605 ret = pvr2_hdw_get_eeprom_addr(hdw);
1606 if (!pvr2_hdw_dev_ok(hdw)) return;
1607 if (ret < 0) {
1608 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1609 "Unable to determine location of eeprom, skipping");
1610 } else {
1611 hdw->eeprom_addr = ret;
1612 pvr2_eeprom_analyze(hdw);
1613 if (!pvr2_hdw_dev_ok(hdw)) return;
1614 }
1615
1616 pvr2_hdw_setup_std(hdw);
1617
1618 if (!get_default_tuner_type(hdw)) {
1619 pvr2_trace(PVR2_TRACE_INIT,
1620 "pvr2_hdw_setup: Tuner type overridden to %d",
1621 hdw->tuner_type);
1622 }
1623
1624 hdw->tuner_updated = !0;
1625 pvr2_i2c_core_check_stale(hdw);
1626 hdw->tuner_updated = 0;
1627
1628 if (!pvr2_hdw_dev_ok(hdw)) return;
1629
1630 pvr2_hdw_commit_ctl_internal(hdw);
1631 if (!pvr2_hdw_dev_ok(hdw)) return;
1632
1633 hdw->vid_stream = pvr2_stream_create();
1634 if (!pvr2_hdw_dev_ok(hdw)) return;
1635 pvr2_trace(PVR2_TRACE_INIT,
1636 "pvr2_hdw_setup: video stream is %p",hdw->vid_stream);
1637 if (hdw->vid_stream) {
1638 idx = get_default_error_tolerance(hdw);
1639 if (idx) {
1640 pvr2_trace(PVR2_TRACE_INIT,
1641 "pvr2_hdw_setup: video stream %p"
1642 " setting tolerance %u",
1643 hdw->vid_stream,idx);
1644 }
1645 pvr2_stream_setup(hdw->vid_stream,hdw->usb_dev,
1646 PVR2_VID_ENDPOINT,idx);
1647 }
1648
1649 if (!pvr2_hdw_dev_ok(hdw)) return;
1650
1651 /* Make sure everything is up to date */
1652 pvr2_i2c_core_sync(hdw);
1653
1654 if (!pvr2_hdw_dev_ok(hdw)) return;
1655
1656 hdw->flag_init_ok = !0;
1657}
1658
1659
1660int pvr2_hdw_setup(struct pvr2_hdw *hdw)
1661{
1662 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) begin",hdw);
1663 LOCK_TAKE(hdw->big_lock); do {
1664 pvr2_hdw_setup_low(hdw);
1665 pvr2_trace(PVR2_TRACE_INIT,
1666 "pvr2_hdw_setup(hdw=%p) done, ok=%d init_ok=%d",
1667 hdw,hdw->flag_ok,hdw->flag_init_ok);
1668 if (pvr2_hdw_dev_ok(hdw)) {
1669 if (pvr2_hdw_init_ok(hdw)) {
1670 pvr2_trace(
1671 PVR2_TRACE_INFO,
1672 "Device initialization"
1673 " completed successfully.");
1674 break;
1675 }
1676 if (hdw->fw1_state == FW1_STATE_RELOAD) {
1677 pvr2_trace(
1678 PVR2_TRACE_INFO,
1679 "Device microcontroller firmware"
1680 " (re)loaded; it should now reset"
1681 " and reconnect.");
1682 break;
1683 }
1684 pvr2_trace(
1685 PVR2_TRACE_ERROR_LEGS,
1686 "Device initialization was not successful.");
1687 if (hdw->fw1_state == FW1_STATE_MISSING) {
1688 pvr2_trace(
1689 PVR2_TRACE_ERROR_LEGS,
1690 "Giving up since device"
1691 " microcontroller firmware"
1692 " appears to be missing.");
1693 break;
1694 }
1695 }
1696 if (procreload) {
1697 pvr2_trace(
1698 PVR2_TRACE_ERROR_LEGS,
1699 "Attempting pvrusb2 recovery by reloading"
1700 " primary firmware.");
1701 pvr2_trace(
1702 PVR2_TRACE_ERROR_LEGS,
1703 "If this works, device should disconnect"
1704 " and reconnect in a sane state.");
1705 hdw->fw1_state = FW1_STATE_UNKNOWN;
1706 pvr2_upload_firmware1(hdw);
1707 } else {
1708 pvr2_trace(
1709 PVR2_TRACE_ERROR_LEGS,
1710 "***WARNING*** pvrusb2 device hardware"
1711 " appears to be jammed"
1712 " and I can't clear it.");
1713 pvr2_trace(
1714 PVR2_TRACE_ERROR_LEGS,
1715 "You might need to power cycle"
1716 " the pvrusb2 device"
1717 " in order to recover.");
1718 }
1719 } while (0); LOCK_GIVE(hdw->big_lock);
1720 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw);
1721 return hdw->flag_init_ok;
1722}
1723
1724
1725/* Create and return a structure for interacting with the underlying
1726 hardware */
1727struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1728 const struct usb_device_id *devid)
1729{
1730 unsigned int idx,cnt1,cnt2;
1731 struct pvr2_hdw *hdw;
1732 unsigned int hdw_type;
1733 int valid_std_mask;
1734 struct pvr2_ctrl *cptr;
1735 __u8 ifnum;
1736 struct v4l2_queryctrl qctrl;
1737 struct pvr2_ctl_info *ciptr;
1738
1739 hdw_type = devid - pvr2_device_table;
1740 if (hdw_type >=
1741 sizeof(pvr2_device_names)/sizeof(pvr2_device_names[0])) {
1742 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1743 "Bogus device type of %u reported",hdw_type);
1744 return 0;
1745 }
1746
1747 hdw = kmalloc(sizeof(*hdw),GFP_KERNEL);
1748 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p, type \"%s\"",
1749 hdw,pvr2_device_names[hdw_type]);
1750 if (!hdw) goto fail;
1751 memset(hdw,0,sizeof(*hdw));
1752 cx2341x_fill_defaults(&hdw->enc_ctl_state);
1753
1754 hdw->control_cnt = CTRLDEF_COUNT;
1755 hdw->control_cnt += MPEGDEF_COUNT;
1756 hdw->controls = kmalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
1757 GFP_KERNEL);
1758 if (!hdw->controls) goto fail;
1759 memset(hdw->controls,0,sizeof(struct pvr2_ctrl) * hdw->control_cnt);
1760 hdw->hdw_type = hdw_type;
1761 for (idx = 0; idx < hdw->control_cnt; idx++) {
1762 cptr = hdw->controls + idx;
1763 cptr->hdw = hdw;
1764 }
1765 for (idx = 0; idx < 32; idx++) {
1766 hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx];
1767 }
1768 for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
1769 cptr = hdw->controls + idx;
1770 cptr->info = control_defs+idx;
1771 }
1772 /* Define and configure additional controls from cx2341x module. */
1773 hdw->mpeg_ctrl_info = kmalloc(
1774 sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT, GFP_KERNEL);
1775 if (!hdw->mpeg_ctrl_info) goto fail;
1776 memset(hdw->mpeg_ctrl_info,0,
1777 sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT);
1778 for (idx = 0; idx < MPEGDEF_COUNT; idx++) {
1779 cptr = hdw->controls + idx + CTRLDEF_COUNT;
1780 ciptr = &(hdw->mpeg_ctrl_info[idx].info);
1781 ciptr->desc = hdw->mpeg_ctrl_info[idx].desc;
1782 ciptr->name = mpeg_ids[idx].strid;
1783 ciptr->v4l_id = mpeg_ids[idx].id;
1784 ciptr->skip_init = !0;
1785 ciptr->get_value = ctrl_cx2341x_get;
1786 ciptr->get_v4lflags = ctrl_cx2341x_getv4lflags;
1787 ciptr->is_dirty = ctrl_cx2341x_is_dirty;
1788 if (!idx) ciptr->clear_dirty = ctrl_cx2341x_clear_dirty;
1789 qctrl.id = ciptr->v4l_id;
1790 cx2341x_ctrl_query(&hdw->enc_ctl_state,&qctrl);
1791 if (!(qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)) {
1792 ciptr->set_value = ctrl_cx2341x_set;
1793 }
1794 strncpy(hdw->mpeg_ctrl_info[idx].desc,qctrl.name,
1795 PVR2_CTLD_INFO_DESC_SIZE);
1796 hdw->mpeg_ctrl_info[idx].desc[PVR2_CTLD_INFO_DESC_SIZE-1] = 0;
1797 ciptr->default_value = qctrl.default_value;
1798 switch (qctrl.type) {
1799 default:
1800 case V4L2_CTRL_TYPE_INTEGER:
1801 ciptr->type = pvr2_ctl_int;
1802 ciptr->def.type_int.min_value = qctrl.minimum;
1803 ciptr->def.type_int.max_value = qctrl.maximum;
1804 break;
1805 case V4L2_CTRL_TYPE_BOOLEAN:
1806 ciptr->type = pvr2_ctl_bool;
1807 break;
1808 case V4L2_CTRL_TYPE_MENU:
1809 ciptr->type = pvr2_ctl_enum;
1810 ciptr->def.type_enum.value_names =
1811 cx2341x_ctrl_get_menu(ciptr->v4l_id);
1812 for (cnt1 = 0;
1813 ciptr->def.type_enum.value_names[cnt1] != NULL;
1814 cnt1++) { }
1815 ciptr->def.type_enum.count = cnt1;
1816 break;
1817 }
1818 cptr->info = ciptr;
1819 }
1820
1821 // Initialize video standard enum dynamic control
1822 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDENUM);
1823 if (cptr) {
1824 memcpy(&hdw->std_info_enum,cptr->info,
1825 sizeof(hdw->std_info_enum));
1826 cptr->info = &hdw->std_info_enum;
1827
1828 }
1829 // Initialize control data regarding video standard masks
1830 valid_std_mask = pvr2_std_get_usable();
1831 for (idx = 0; idx < 32; idx++) {
1832 if (!(valid_std_mask & (1 << idx))) continue;
1833 cnt1 = pvr2_std_id_to_str(
1834 hdw->std_mask_names[idx],
1835 sizeof(hdw->std_mask_names[idx])-1,
1836 1 << idx);
1837 hdw->std_mask_names[idx][cnt1] = 0;
1838 }
1839 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDAVAIL);
1840 if (cptr) {
1841 memcpy(&hdw->std_info_avail,cptr->info,
1842 sizeof(hdw->std_info_avail));
1843 cptr->info = &hdw->std_info_avail;
1844 hdw->std_info_avail.def.type_bitmask.bit_names =
1845 hdw->std_mask_ptrs;
1846 hdw->std_info_avail.def.type_bitmask.valid_bits =
1847 valid_std_mask;
1848 }
1849 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR);
1850 if (cptr) {
1851 memcpy(&hdw->std_info_cur,cptr->info,
1852 sizeof(hdw->std_info_cur));
1853 cptr->info = &hdw->std_info_cur;
1854 hdw->std_info_cur.def.type_bitmask.bit_names =
1855 hdw->std_mask_ptrs;
1856 hdw->std_info_avail.def.type_bitmask.valid_bits =
1857 valid_std_mask;
1858 }
1859
1860 hdw->eeprom_addr = -1;
1861 hdw->unit_number = -1;
1862 hdw->v4l_minor_number = -1;
1863 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
1864 if (!hdw->ctl_write_buffer) goto fail;
1865 hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
1866 if (!hdw->ctl_read_buffer) goto fail;
1867 hdw->ctl_write_urb = usb_alloc_urb(0,GFP_KERNEL);
1868 if (!hdw->ctl_write_urb) goto fail;
1869 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL);
1870 if (!hdw->ctl_read_urb) goto fail;
1871
1872 down(&pvr2_unit_sem); do {
1873 for (idx = 0; idx < PVR_NUM; idx++) {
1874 if (unit_pointers[idx]) continue;
1875 hdw->unit_number = idx;
1876 unit_pointers[idx] = hdw;
1877 break;
1878 }
1879 } while (0); up(&pvr2_unit_sem);
1880
1881 cnt1 = 0;
1882 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2");
1883 cnt1 += cnt2;
1884 if (hdw->unit_number >= 0) {
1885 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"_%c",
1886 ('a' + hdw->unit_number));
1887 cnt1 += cnt2;
1888 }
1889 if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1;
1890 hdw->name[cnt1] = 0;
1891
1892 pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s",
1893 hdw->unit_number,hdw->name);
1894
1895 hdw->tuner_type = -1;
1896 hdw->flag_ok = !0;
1897 /* Initialize the mask of subsystems that we will shut down when we
1898 stop streaming. */
1899 hdw->subsys_stream_mask = PVR2_SUBSYS_RUN_ALL;
1900 hdw->subsys_stream_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
1901
1902 pvr2_trace(PVR2_TRACE_INIT,"subsys_stream_mask: 0x%lx",
1903 hdw->subsys_stream_mask);
1904
1905 hdw->usb_intf = intf;
1906 hdw->usb_dev = interface_to_usbdev(intf);
1907
1908 ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber;
1909 usb_set_interface(hdw->usb_dev,ifnum,0);
1910
1911 mutex_init(&hdw->ctl_lock_mutex);
1912 mutex_init(&hdw->big_lock_mutex);
1913
1914 return hdw;
1915 fail:
1916 if (hdw) {
1917 if (hdw->ctl_read_urb) usb_free_urb(hdw->ctl_read_urb);
1918 if (hdw->ctl_write_urb) usb_free_urb(hdw->ctl_write_urb);
1919 if (hdw->ctl_read_buffer) kfree(hdw->ctl_read_buffer);
1920 if (hdw->ctl_write_buffer) kfree(hdw->ctl_write_buffer);
1921 if (hdw->controls) kfree(hdw->controls);
1922 if (hdw->mpeg_ctrl_info) kfree(hdw->mpeg_ctrl_info);
1923 kfree(hdw);
1924 }
1925 return 0;
1926}
1927
1928
1929/* Remove _all_ associations between this driver and the underlying USB
1930 layer. */
1931void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
1932{
1933 if (hdw->flag_disconnected) return;
1934 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw);
1935 if (hdw->ctl_read_urb) {
1936 usb_kill_urb(hdw->ctl_read_urb);
1937 usb_free_urb(hdw->ctl_read_urb);
1938 hdw->ctl_read_urb = 0;
1939 }
1940 if (hdw->ctl_write_urb) {
1941 usb_kill_urb(hdw->ctl_write_urb);
1942 usb_free_urb(hdw->ctl_write_urb);
1943 hdw->ctl_write_urb = 0;
1944 }
1945 if (hdw->ctl_read_buffer) {
1946 kfree(hdw->ctl_read_buffer);
1947 hdw->ctl_read_buffer = 0;
1948 }
1949 if (hdw->ctl_write_buffer) {
1950 kfree(hdw->ctl_write_buffer);
1951 hdw->ctl_write_buffer = 0;
1952 }
1953 pvr2_hdw_render_useless_unlocked(hdw);
1954 hdw->flag_disconnected = !0;
1955 hdw->usb_dev = 0;
1956 hdw->usb_intf = 0;
1957}
1958
1959
1960/* Destroy hardware interaction structure */
1961void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
1962{
1963 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw);
1964 if (hdw->fw_buffer) {
1965 kfree(hdw->fw_buffer);
1966 hdw->fw_buffer = 0;
1967 }
1968 if (hdw->vid_stream) {
1969 pvr2_stream_destroy(hdw->vid_stream);
1970 hdw->vid_stream = 0;
1971 }
1972 if (hdw->audio_stat) {
1973 hdw->audio_stat->detach(hdw->audio_stat->ctxt);
1974 }
1975 if (hdw->decoder_ctrl) {
1976 hdw->decoder_ctrl->detach(hdw->decoder_ctrl->ctxt);
1977 }
1978 pvr2_i2c_core_done(hdw);
1979 pvr2_hdw_remove_usb_stuff(hdw);
1980 down(&pvr2_unit_sem); do {
1981 if ((hdw->unit_number >= 0) &&
1982 (hdw->unit_number < PVR_NUM) &&
1983 (unit_pointers[hdw->unit_number] == hdw)) {
1984 unit_pointers[hdw->unit_number] = 0;
1985 }
1986 } while (0); up(&pvr2_unit_sem);
1987 if (hdw->controls) kfree(hdw->controls);
1988 if (hdw->mpeg_ctrl_info) kfree(hdw->mpeg_ctrl_info);
1989 if (hdw->std_defs) kfree(hdw->std_defs);
1990 if (hdw->std_enum_names) kfree(hdw->std_enum_names);
1991 kfree(hdw);
1992}
1993
1994
1995int pvr2_hdw_init_ok(struct pvr2_hdw *hdw)
1996{
1997 return hdw->flag_init_ok;
1998}
1999
2000
2001int pvr2_hdw_dev_ok(struct pvr2_hdw *hdw)
2002{
2003 return (hdw && hdw->flag_ok);
2004}
2005
2006
2007/* Called when hardware has been unplugged */
2008void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
2009{
2010 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_disconnect(hdw=%p)",hdw);
2011 LOCK_TAKE(hdw->big_lock);
2012 LOCK_TAKE(hdw->ctl_lock);
2013 pvr2_hdw_remove_usb_stuff(hdw);
2014 LOCK_GIVE(hdw->ctl_lock);
2015 LOCK_GIVE(hdw->big_lock);
2016}
2017
2018
2019// Attempt to autoselect an appropriate value for std_enum_cur given
2020// whatever is currently in std_mask_cur
2021void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
2022{
2023 unsigned int idx;
2024 for (idx = 1; idx < hdw->std_enum_cnt; idx++) {
2025 if (hdw->std_defs[idx-1].id == hdw->std_mask_cur) {
2026 hdw->std_enum_cur = idx;
2027 return;
2028 }
2029 }
2030 hdw->std_enum_cur = 0;
2031}
2032
2033
2034// Calculate correct set of enumerated standards based on currently known
2035// set of available standards bits.
2036void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
2037{
2038 struct v4l2_standard *newstd;
2039 unsigned int std_cnt;
2040 unsigned int idx;
2041
2042 newstd = pvr2_std_create_enum(&std_cnt,hdw->std_mask_avail);
2043
2044 if (hdw->std_defs) {
2045 kfree(hdw->std_defs);
2046 hdw->std_defs = 0;
2047 }
2048 hdw->std_enum_cnt = 0;
2049 if (hdw->std_enum_names) {
2050 kfree(hdw->std_enum_names);
2051 hdw->std_enum_names = 0;
2052 }
2053
2054 if (!std_cnt) {
2055 pvr2_trace(
2056 PVR2_TRACE_ERROR_LEGS,
2057 "WARNING: Failed to identify any viable standards");
2058 }
2059 hdw->std_enum_names = kmalloc(sizeof(char *)*(std_cnt+1),GFP_KERNEL);
2060 hdw->std_enum_names[0] = "none";
2061 for (idx = 0; idx < std_cnt; idx++) {
2062 hdw->std_enum_names[idx+1] =
2063 newstd[idx].name;
2064 }
2065 // Set up the dynamic control for this standard
2066 hdw->std_info_enum.def.type_enum.value_names = hdw->std_enum_names;
2067 hdw->std_info_enum.def.type_enum.count = std_cnt+1;
2068 hdw->std_defs = newstd;
2069 hdw->std_enum_cnt = std_cnt+1;
2070 hdw->std_enum_cur = 0;
2071 hdw->std_info_cur.def.type_bitmask.valid_bits = hdw->std_mask_avail;
2072}
2073
2074
2075int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,
2076 struct v4l2_standard *std,
2077 unsigned int idx)
2078{
2079 int ret = -EINVAL;
2080 if (!idx) return ret;
2081 LOCK_TAKE(hdw->big_lock); do {
2082 if (idx >= hdw->std_enum_cnt) break;
2083 idx--;
2084 memcpy(std,hdw->std_defs+idx,sizeof(*std));
2085 ret = 0;
2086 } while (0); LOCK_GIVE(hdw->big_lock);
2087 return ret;
2088}
2089
2090
2091/* Get the number of defined controls */
2092unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
2093{
2094 return hdw->control_cnt;
2095}
2096
2097
2098/* Retrieve a control handle given its index (0..count-1) */
2099struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
2100 unsigned int idx)
2101{
2102 if (idx >= hdw->control_cnt) return 0;
2103 return hdw->controls + idx;
2104}
2105
2106
2107/* Retrieve a control handle given its index (0..count-1) */
2108struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
2109 unsigned int ctl_id)
2110{
2111 struct pvr2_ctrl *cptr;
2112 unsigned int idx;
2113 int i;
2114
2115 /* This could be made a lot more efficient, but for now... */
2116 for (idx = 0; idx < hdw->control_cnt; idx++) {
2117 cptr = hdw->controls + idx;
2118 i = cptr->info->internal_id;
2119 if (i && (i == ctl_id)) return cptr;
2120 }
2121 return 0;
2122}
2123
2124
2125/* Given a V4L ID, retrieve the control structure associated with it. */
2126struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id)
2127{
2128 struct pvr2_ctrl *cptr;
2129 unsigned int idx;
2130 int i;
2131
2132 /* This could be made a lot more efficient, but for now... */
2133 for (idx = 0; idx < hdw->control_cnt; idx++) {
2134 cptr = hdw->controls + idx;
2135 i = cptr->info->v4l_id;
2136 if (i && (i == ctl_id)) return cptr;
2137 }
2138 return 0;
2139}
2140
2141
2142/* Given a V4L ID for its immediate predecessor, retrieve the control
2143 structure associated with it. */
2144struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
2145 unsigned int ctl_id)
2146{
2147 struct pvr2_ctrl *cptr,*cp2;
2148 unsigned int idx;
2149 int i;
2150
2151 /* This could be made a lot more efficient, but for now... */
2152 cp2 = 0;
2153 for (idx = 0; idx < hdw->control_cnt; idx++) {
2154 cptr = hdw->controls + idx;
2155 i = cptr->info->v4l_id;
2156 if (!i) continue;
2157 if (i <= ctl_id) continue;
2158 if (cp2 && (cp2->info->v4l_id < i)) continue;
2159 cp2 = cptr;
2160 }
2161 return cp2;
2162 return 0;
2163}
2164
2165
2166static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
2167{
2168 switch (tp) {
2169 case pvr2_ctl_int: return "integer";
2170 case pvr2_ctl_enum: return "enum";
2171 case pvr2_ctl_bool: return "boolean";
2172 case pvr2_ctl_bitmask: return "bitmask";
2173 }
2174 return "";
2175}
2176
2177
2178/* Commit all control changes made up to this point. Subsystems can be
2179 indirectly affected by these changes. For a given set of things being
2180 committed, we'll clear the affected subsystem bits and then once we're
2181 done committing everything we'll make a request to restore the subsystem
2182 state(s) back to their previous value before this function was called.
2183 Thus we can automatically reconfigure affected pieces of the driver as
2184 controls are changed. */
2185int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2186{
2187 unsigned long saved_subsys_mask = hdw->subsys_enabled_mask;
2188 unsigned long stale_subsys_mask = 0;
2189 unsigned int idx;
2190 struct pvr2_ctrl *cptr;
2191 int value;
2192 int commit_flag = 0;
2193 char buf[100];
2194 unsigned int bcnt,ccnt;
2195
2196 for (idx = 0; idx < hdw->control_cnt; idx++) {
2197 cptr = hdw->controls + idx;
2198 if (cptr->info->is_dirty == 0) continue;
2199 if (!cptr->info->is_dirty(cptr)) continue;
2200 if (!commit_flag) {
2201 commit_flag = !0;
2202 }
2203
2204 bcnt = scnprintf(buf,sizeof(buf),"\"%s\" <-- ",
2205 cptr->info->name);
2206 value = 0;
2207 cptr->info->get_value(cptr,&value);
2208 pvr2_ctrl_value_to_sym_internal(cptr,~0,value,
2209 buf+bcnt,
2210 sizeof(buf)-bcnt,&ccnt);
2211 bcnt += ccnt;
2212 bcnt += scnprintf(buf+bcnt,sizeof(buf)-bcnt," <%s>",
2213 get_ctrl_typename(cptr->info->type));
2214 pvr2_trace(PVR2_TRACE_CTL,
2215 "/*--TRACE_COMMIT--*/ %.*s",
2216 bcnt,buf);
2217 }
2218
2219 if (!commit_flag) {
2220 /* Nothing has changed */
2221 return 0;
2222 }
2223
2224 /* When video standard changes, reset the hres and vres values -
2225 but if the user has pending changes there, then let the changes
2226 take priority. */
2227 if (hdw->std_dirty) {
2228 /* Rewrite the vertical resolution to be appropriate to the
2229 video standard that has been selected. */
2230 int nvres;
2231 if (hdw->std_mask_cur & V4L2_STD_525_60) {
2232 nvres = 480;
2233 } else {
2234 nvres = 576;
2235 }
2236 if (nvres != hdw->res_ver_val) {
2237 hdw->res_ver_val = nvres;
2238 hdw->res_ver_dirty = !0;
2239 }
2240 }
2241
2242 if (hdw->std_dirty ||
2243 0) {
2244 /* If any of this changes, then the encoder needs to be
2245 reconfigured, and we need to reset the stream. */
2246 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
2247 stale_subsys_mask |= hdw->subsys_stream_mask;
2248 }
2249
2250 if (hdw->srate_dirty) {
2251 /* Write new sample rate into control structure since
2252 * the master copy is stale. We must track srate
2253 * separate from the mpeg control structure because
2254 * other logic also uses this value. */
2255 struct v4l2_ext_controls cs;
2256 struct v4l2_ext_control c1;
2257 memset(&cs,0,sizeof(cs));
2258 memset(&c1,0,sizeof(c1));
2259 cs.controls = &c1;
2260 cs.count = 1;
2261 c1.id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ;
2262 c1.value = hdw->srate_val;
2263 cx2341x_ext_ctrls(&hdw->enc_ctl_state,&cs,VIDIOC_S_EXT_CTRLS);
2264 }
2265
2266 /* Scan i2c core at this point - before we clear all the dirty
2267 bits. Various parts of the i2c core will notice dirty bits as
2268 appropriate and arrange to broadcast or directly send updates to
2269 the client drivers in order to keep everything in sync */
2270 pvr2_i2c_core_check_stale(hdw);
2271
2272 for (idx = 0; idx < hdw->control_cnt; idx++) {
2273 cptr = hdw->controls + idx;
2274 if (!cptr->info->clear_dirty) continue;
2275 cptr->info->clear_dirty(cptr);
2276 }
2277
2278 /* Now execute i2c core update */
2279 pvr2_i2c_core_sync(hdw);
2280
2281 pvr2_hdw_subsys_bit_chg_no_lock(hdw,stale_subsys_mask,0);
2282 pvr2_hdw_subsys_bit_chg_no_lock(hdw,~0,saved_subsys_mask);
2283
2284 return 0;
2285}
2286
2287
2288int pvr2_hdw_commit_ctl(struct pvr2_hdw *hdw)
2289{
2290 LOCK_TAKE(hdw->big_lock); do {
2291 pvr2_hdw_commit_ctl_internal(hdw);
2292 } while (0); LOCK_GIVE(hdw->big_lock);
2293 return 0;
2294}
2295
2296
2297void pvr2_hdw_poll(struct pvr2_hdw *hdw)
2298{
2299 LOCK_TAKE(hdw->big_lock); do {
2300 pvr2_i2c_core_sync(hdw);
2301 } while (0); LOCK_GIVE(hdw->big_lock);
2302}
2303
2304
2305void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *hdw,
2306 void (*func)(void *),
2307 void *data)
2308{
2309 LOCK_TAKE(hdw->big_lock); do {
2310 hdw->poll_trigger_func = func;
2311 hdw->poll_trigger_data = data;
2312 } while (0); LOCK_GIVE(hdw->big_lock);
2313}
2314
2315
2316void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *hdw)
2317{
2318 if (hdw->poll_trigger_func) {
2319 hdw->poll_trigger_func(hdw->poll_trigger_data);
2320 }
2321}
2322
2323
2324void pvr2_hdw_poll_trigger(struct pvr2_hdw *hdw)
2325{
2326 LOCK_TAKE(hdw->big_lock); do {
2327 pvr2_hdw_poll_trigger_unlocked(hdw);
2328 } while (0); LOCK_GIVE(hdw->big_lock);
2329}
2330
2331
2332/* Return name for this driver instance */
2333const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
2334{
2335 return hdw->name;
2336}
2337
2338
2339/* Return bit mask indicating signal status */
2340unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
2341{
2342 unsigned int msk = 0;
2343 switch (hdw->input_val) {
2344 case PVR2_CVAL_INPUT_TV:
2345 case PVR2_CVAL_INPUT_RADIO:
2346 if (hdw->decoder_ctrl &&
2347 hdw->decoder_ctrl->tuned(hdw->decoder_ctrl->ctxt)) {
2348 msk |= PVR2_SIGNAL_OK;
2349 if (hdw->audio_stat &&
2350 hdw->audio_stat->status(hdw->audio_stat->ctxt)) {
2351 if (hdw->flag_stereo) {
2352 msk |= PVR2_SIGNAL_STEREO;
2353 }
2354 if (hdw->flag_bilingual) {
2355 msk |= PVR2_SIGNAL_SAP;
2356 }
2357 }
2358 }
2359 break;
2360 default:
2361 msk |= PVR2_SIGNAL_OK | PVR2_SIGNAL_STEREO;
2362 }
2363 return msk;
2364}
2365
2366
2367int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw)
2368{
2369 int result;
2370 LOCK_TAKE(hdw->ctl_lock); do {
2371 hdw->cmd_buffer[0] = 0x0b;
2372 result = pvr2_send_request(hdw,
2373 hdw->cmd_buffer,1,
2374 hdw->cmd_buffer,1);
2375 if (result < 0) break;
2376 result = (hdw->cmd_buffer[0] != 0);
2377 } while(0); LOCK_GIVE(hdw->ctl_lock);
2378 return result;
2379}
2380
2381
2382/* Return bit mask indicating signal status */
2383unsigned int pvr2_hdw_get_signal_status(struct pvr2_hdw *hdw)
2384{
2385 unsigned int msk = 0;
2386 LOCK_TAKE(hdw->big_lock); do {
2387 msk = pvr2_hdw_get_signal_status_internal(hdw);
2388 } while (0); LOCK_GIVE(hdw->big_lock);
2389 return msk;
2390}
2391
2392
2393/* Get handle to video output stream */
2394struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *hp)
2395{
2396 return hp->vid_stream;
2397}
2398
2399
2400void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw)
2401{
2402 int nr = pvr2_hdw_get_unit_number(hdw);
2403 LOCK_TAKE(hdw->big_lock); do {
2404 hdw->log_requested = !0;
2405 printk(KERN_INFO "pvrusb2: ================= START STATUS CARD #%d =================\n", nr);
2406 pvr2_i2c_core_check_stale(hdw);
2407 hdw->log_requested = 0;
2408 pvr2_i2c_core_sync(hdw);
2409 pvr2_trace(PVR2_TRACE_INFO,"cx2341x config:");
2410 cx2341x_log_status(&hdw->enc_ctl_state, "pvrusb2");
2411 printk(KERN_INFO "pvrusb2: ================== END STATUS CARD #%d ==================\n", nr);
2412 } while (0); LOCK_GIVE(hdw->big_lock);
2413}
2414
2415void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, int enable_flag)
2416{
2417 int ret;
2418 u16 address;
2419 unsigned int pipe;
2420 LOCK_TAKE(hdw->big_lock); do {
2421 if ((hdw->fw_buffer == 0) == !enable_flag) break;
2422
2423 if (!enable_flag) {
2424 pvr2_trace(PVR2_TRACE_FIRMWARE,
2425 "Cleaning up after CPU firmware fetch");
2426 kfree(hdw->fw_buffer);
2427 hdw->fw_buffer = 0;
2428 hdw->fw_size = 0;
2429 /* Now release the CPU. It will disconnect and
2430 reconnect later. */
2431 pvr2_hdw_cpureset_assert(hdw,0);
2432 break;
2433 }
2434
2435 pvr2_trace(PVR2_TRACE_FIRMWARE,
2436 "Preparing to suck out CPU firmware");
2437 hdw->fw_size = 0x2000;
2438 hdw->fw_buffer = kmalloc(hdw->fw_size,GFP_KERNEL);
2439 if (!hdw->fw_buffer) {
2440 hdw->fw_size = 0;
2441 break;
2442 }
2443
2444 memset(hdw->fw_buffer,0,hdw->fw_size);
2445
2446 /* We have to hold the CPU during firmware upload. */
2447 pvr2_hdw_cpureset_assert(hdw,1);
2448
2449 /* download the firmware from address 0000-1fff in 2048
2450 (=0x800) bytes chunk. */
2451
2452 pvr2_trace(PVR2_TRACE_FIRMWARE,"Grabbing CPU firmware");
2453 pipe = usb_rcvctrlpipe(hdw->usb_dev, 0);
2454 for(address = 0; address < hdw->fw_size; address += 0x800) {
2455 ret = usb_control_msg(hdw->usb_dev,pipe,0xa0,0xc0,
2456 address,0,
2457 hdw->fw_buffer+address,0x800,HZ);
2458 if (ret < 0) break;
2459 }
2460
2461 pvr2_trace(PVR2_TRACE_FIRMWARE,"Done grabbing CPU firmware");
2462
2463 } while (0); LOCK_GIVE(hdw->big_lock);
2464}
2465
2466
2467/* Return true if we're in a mode for retrieval CPU firmware */
2468int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw)
2469{
2470 return hdw->fw_buffer != 0;
2471}
2472
2473
2474int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs,
2475 char *buf,unsigned int cnt)
2476{
2477 int ret = -EINVAL;
2478 LOCK_TAKE(hdw->big_lock); do {
2479 if (!buf) break;
2480 if (!cnt) break;
2481
2482 if (!hdw->fw_buffer) {
2483 ret = -EIO;
2484 break;
2485 }
2486
2487 if (offs >= hdw->fw_size) {
2488 pvr2_trace(PVR2_TRACE_FIRMWARE,
2489 "Read firmware data offs=%d EOF",
2490 offs);
2491 ret = 0;
2492 break;
2493 }
2494
2495 if (offs + cnt > hdw->fw_size) cnt = hdw->fw_size - offs;
2496
2497 memcpy(buf,hdw->fw_buffer+offs,cnt);
2498
2499 pvr2_trace(PVR2_TRACE_FIRMWARE,
2500 "Read firmware data offs=%d cnt=%d",
2501 offs,cnt);
2502 ret = cnt;
2503 } while (0); LOCK_GIVE(hdw->big_lock);
2504
2505 return ret;
2506}
2507
2508
2509int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw)
2510{
2511 return hdw->v4l_minor_number;
2512}
2513
2514
2515/* Store the v4l minor device number */
2516void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
2517{
2518 hdw->v4l_minor_number = v;
2519}
2520
2521
2522void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw)
2523{
2524 if (!hdw->usb_dev) return;
2525 usb_settoggle(hdw->usb_dev, PVR2_CTL_WRITE_ENDPOINT & 0xf,
2526 !(PVR2_CTL_WRITE_ENDPOINT & USB_DIR_IN), 0);
2527 usb_settoggle(hdw->usb_dev, PVR2_CTL_READ_ENDPOINT & 0xf,
2528 !(PVR2_CTL_READ_ENDPOINT & USB_DIR_IN), 0);
2529 usb_clear_halt(hdw->usb_dev,
2530 usb_rcvbulkpipe(hdw->usb_dev,
2531 PVR2_CTL_READ_ENDPOINT & 0x7f));
2532 usb_clear_halt(hdw->usb_dev,
2533 usb_sndbulkpipe(hdw->usb_dev,
2534 PVR2_CTL_WRITE_ENDPOINT & 0x7f));
2535}
2536
2537
2538static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs)
2539{
2540 struct pvr2_hdw *hdw = urb->context;
2541 hdw->ctl_write_pend_flag = 0;
2542 if (hdw->ctl_read_pend_flag) return;
2543 complete(&hdw->ctl_done);
2544}
2545
2546
2547static void pvr2_ctl_read_complete(struct urb *urb, struct pt_regs *regs)
2548{
2549 struct pvr2_hdw *hdw = urb->context;
2550 hdw->ctl_read_pend_flag = 0;
2551 if (hdw->ctl_write_pend_flag) return;
2552 complete(&hdw->ctl_done);
2553}
2554
2555
2556static void pvr2_ctl_timeout(unsigned long data)
2557{
2558 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
2559 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) {
2560 hdw->ctl_timeout_flag = !0;
2561 if (hdw->ctl_write_pend_flag && hdw->ctl_write_urb) {
2562 usb_unlink_urb(hdw->ctl_write_urb);
2563 }
2564 if (hdw->ctl_read_pend_flag && hdw->ctl_read_urb) {
2565 usb_unlink_urb(hdw->ctl_read_urb);
2566 }
2567 }
2568}
2569
2570
2571int pvr2_send_request_ex(struct pvr2_hdw *hdw,
2572 unsigned int timeout,int probe_fl,
2573 void *write_data,unsigned int write_len,
2574 void *read_data,unsigned int read_len)
2575{
2576 unsigned int idx;
2577 int status = 0;
2578 struct timer_list timer;
2579 if (!hdw->ctl_lock_held) {
2580 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2581 "Attempted to execute control transfer"
2582 " without lock!!");
2583 return -EDEADLK;
2584 }
2585 if ((!hdw->flag_ok) && !probe_fl) {
2586 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2587 "Attempted to execute control transfer"
2588 " when device not ok");
2589 return -EIO;
2590 }
2591 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) {
2592 if (!probe_fl) {
2593 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2594 "Attempted to execute control transfer"
2595 " when USB is disconnected");
2596 }
2597 return -ENOTTY;
2598 }
2599
2600 /* Ensure that we have sane parameters */
2601 if (!write_data) write_len = 0;
2602 if (!read_data) read_len = 0;
2603 if (write_len > PVR2_CTL_BUFFSIZE) {
2604 pvr2_trace(
2605 PVR2_TRACE_ERROR_LEGS,
2606 "Attempted to execute %d byte"
2607 " control-write transfer (limit=%d)",
2608 write_len,PVR2_CTL_BUFFSIZE);
2609 return -EINVAL;
2610 }
2611 if (read_len > PVR2_CTL_BUFFSIZE) {
2612 pvr2_trace(
2613 PVR2_TRACE_ERROR_LEGS,
2614 "Attempted to execute %d byte"
2615 " control-read transfer (limit=%d)",
2616 write_len,PVR2_CTL_BUFFSIZE);
2617 return -EINVAL;
2618 }
2619 if ((!write_len) && (!read_len)) {
2620 pvr2_trace(
2621 PVR2_TRACE_ERROR_LEGS,
2622 "Attempted to execute null control transfer?");
2623 return -EINVAL;
2624 }
2625
2626
2627 hdw->cmd_debug_state = 1;
2628 if (write_len) {
2629 hdw->cmd_debug_code = ((unsigned char *)write_data)[0];
2630 } else {
2631 hdw->cmd_debug_code = 0;
2632 }
2633 hdw->cmd_debug_write_len = write_len;
2634 hdw->cmd_debug_read_len = read_len;
2635
2636 /* Initialize common stuff */
2637 init_completion(&hdw->ctl_done);
2638 hdw->ctl_timeout_flag = 0;
2639 hdw->ctl_write_pend_flag = 0;
2640 hdw->ctl_read_pend_flag = 0;
2641 init_timer(&timer);
2642 timer.expires = jiffies + timeout;
2643 timer.data = (unsigned long)hdw;
2644 timer.function = pvr2_ctl_timeout;
2645
2646 if (write_len) {
2647 hdw->cmd_debug_state = 2;
2648 /* Transfer write data to internal buffer */
2649 for (idx = 0; idx < write_len; idx++) {
2650 hdw->ctl_write_buffer[idx] =
2651 ((unsigned char *)write_data)[idx];
2652 }
2653 /* Initiate a write request */
2654 usb_fill_bulk_urb(hdw->ctl_write_urb,
2655 hdw->usb_dev,
2656 usb_sndbulkpipe(hdw->usb_dev,
2657 PVR2_CTL_WRITE_ENDPOINT),
2658 hdw->ctl_write_buffer,
2659 write_len,
2660 pvr2_ctl_write_complete,
2661 hdw);
2662 hdw->ctl_write_urb->actual_length = 0;
2663 hdw->ctl_write_pend_flag = !0;
2664 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL);
2665 if (status < 0) {
2666 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2667 "Failed to submit write-control"
2668 " URB status=%d",status);
2669 hdw->ctl_write_pend_flag = 0;
2670 goto done;
2671 }
2672 }
2673
2674 if (read_len) {
2675 hdw->cmd_debug_state = 3;
2676 memset(hdw->ctl_read_buffer,0x43,read_len);
2677 /* Initiate a read request */
2678 usb_fill_bulk_urb(hdw->ctl_read_urb,
2679 hdw->usb_dev,
2680 usb_rcvbulkpipe(hdw->usb_dev,
2681 PVR2_CTL_READ_ENDPOINT),
2682 hdw->ctl_read_buffer,
2683 read_len,
2684 pvr2_ctl_read_complete,
2685 hdw);
2686 hdw->ctl_read_urb->actual_length = 0;
2687 hdw->ctl_read_pend_flag = !0;
2688 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL);
2689 if (status < 0) {
2690 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2691 "Failed to submit read-control"
2692 " URB status=%d",status);
2693 hdw->ctl_read_pend_flag = 0;
2694 goto done;
2695 }
2696 }
2697
2698 /* Start timer */
2699 add_timer(&timer);
2700
2701 /* Now wait for all I/O to complete */
2702 hdw->cmd_debug_state = 4;
2703 while (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) {
2704 wait_for_completion(&hdw->ctl_done);
2705 }
2706 hdw->cmd_debug_state = 5;
2707
2708 /* Stop timer */
2709 del_timer_sync(&timer);
2710
2711 hdw->cmd_debug_state = 6;
2712 status = 0;
2713
2714 if (hdw->ctl_timeout_flag) {
2715 status = -ETIMEDOUT;
2716 if (!probe_fl) {
2717 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2718 "Timed out control-write");
2719 }
2720 goto done;
2721 }
2722
2723 if (write_len) {
2724 /* Validate results of write request */
2725 if ((hdw->ctl_write_urb->status != 0) &&
2726 (hdw->ctl_write_urb->status != -ENOENT) &&
2727 (hdw->ctl_write_urb->status != -ESHUTDOWN) &&
2728 (hdw->ctl_write_urb->status != -ECONNRESET)) {
2729 /* USB subsystem is reporting some kind of failure
2730 on the write */
2731 status = hdw->ctl_write_urb->status;
2732 if (!probe_fl) {
2733 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2734 "control-write URB failure,"
2735 " status=%d",
2736 status);
2737 }
2738 goto done;
2739 }
2740 if (hdw->ctl_write_urb->actual_length < write_len) {
2741 /* Failed to write enough data */
2742 status = -EIO;
2743 if (!probe_fl) {
2744 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2745 "control-write URB short,"
2746 " expected=%d got=%d",
2747 write_len,
2748 hdw->ctl_write_urb->actual_length);
2749 }
2750 goto done;
2751 }
2752 }
2753 if (read_len) {
2754 /* Validate results of read request */
2755 if ((hdw->ctl_read_urb->status != 0) &&
2756 (hdw->ctl_read_urb->status != -ENOENT) &&
2757 (hdw->ctl_read_urb->status != -ESHUTDOWN) &&
2758 (hdw->ctl_read_urb->status != -ECONNRESET)) {
2759 /* USB subsystem is reporting some kind of failure
2760 on the read */
2761 status = hdw->ctl_read_urb->status;
2762 if (!probe_fl) {
2763 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2764 "control-read URB failure,"
2765 " status=%d",
2766 status);
2767 }
2768 goto done;
2769 }
2770 if (hdw->ctl_read_urb->actual_length < read_len) {
2771 /* Failed to read enough data */
2772 status = -EIO;
2773 if (!probe_fl) {
2774 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2775 "control-read URB short,"
2776 " expected=%d got=%d",
2777 read_len,
2778 hdw->ctl_read_urb->actual_length);
2779 }
2780 goto done;
2781 }
2782 /* Transfer retrieved data out from internal buffer */
2783 for (idx = 0; idx < read_len; idx++) {
2784 ((unsigned char *)read_data)[idx] =
2785 hdw->ctl_read_buffer[idx];
2786 }
2787 }
2788
2789 done:
2790
2791 hdw->cmd_debug_state = 0;
2792 if ((status < 0) && (!probe_fl)) {
2793 pvr2_hdw_render_useless_unlocked(hdw);
2794 }
2795 return status;
2796}
2797
2798
2799int pvr2_send_request(struct pvr2_hdw *hdw,
2800 void *write_data,unsigned int write_len,
2801 void *read_data,unsigned int read_len)
2802{
2803 return pvr2_send_request_ex(hdw,HZ*4,0,
2804 write_data,write_len,
2805 read_data,read_len);
2806}
2807
2808int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
2809{
2810 int ret;
2811
2812 LOCK_TAKE(hdw->ctl_lock);
2813
2814 hdw->cmd_buffer[0] = 0x04; /* write register prefix */
2815 PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data);
2816 hdw->cmd_buffer[5] = 0;
2817 hdw->cmd_buffer[6] = (reg >> 8) & 0xff;
2818 hdw->cmd_buffer[7] = reg & 0xff;
2819
2820
2821 ret = pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 0);
2822
2823 LOCK_GIVE(hdw->ctl_lock);
2824
2825 return ret;
2826}
2827
2828
2829int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
2830{
2831 int ret = 0;
2832
2833 LOCK_TAKE(hdw->ctl_lock);
2834
2835 hdw->cmd_buffer[0] = 0x05; /* read register prefix */
2836 hdw->cmd_buffer[1] = 0;
2837 hdw->cmd_buffer[2] = 0;
2838 hdw->cmd_buffer[3] = 0;
2839 hdw->cmd_buffer[4] = 0;
2840 hdw->cmd_buffer[5] = 0;
2841 hdw->cmd_buffer[6] = (reg >> 8) & 0xff;
2842 hdw->cmd_buffer[7] = reg & 0xff;
2843
2844 ret |= pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 4);
2845 *data = PVR2_COMPOSE_LE(hdw->cmd_buffer,0);
2846
2847 LOCK_GIVE(hdw->ctl_lock);
2848
2849 return ret;
2850}
2851
2852
2853int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
2854{
2855 int ret;
2856
2857 LOCK_TAKE(hdw->ctl_lock);
2858
2859 hdw->cmd_buffer[0] = (data >> 8) & 0xff;
2860 hdw->cmd_buffer[1] = data & 0xff;
2861
2862 ret = pvr2_send_request(hdw, hdw->cmd_buffer, 2, hdw->cmd_buffer, res);
2863
2864 LOCK_GIVE(hdw->ctl_lock);
2865
2866 return ret;
2867}
2868
2869
2870int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
2871{
2872 int ret;
2873
2874 LOCK_TAKE(hdw->ctl_lock);
2875
2876 hdw->cmd_buffer[0] = data;
2877
2878 ret = pvr2_send_request(hdw, hdw->cmd_buffer, 1, hdw->cmd_buffer, res);
2879
2880 LOCK_GIVE(hdw->ctl_lock);
2881
2882 return ret;
2883}
2884
2885
2886void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
2887{
2888 if (!hdw->flag_ok) return;
2889 pvr2_trace(PVR2_TRACE_INIT,"render_useless");
2890 hdw->flag_ok = 0;
2891 if (hdw->vid_stream) {
2892 pvr2_stream_setup(hdw->vid_stream,0,0,0);
2893 }
2894 hdw->flag_streaming_enabled = 0;
2895 hdw->subsys_enabled_mask = 0;
2896}
2897
2898
2899void pvr2_hdw_render_useless(struct pvr2_hdw *hdw)
2900{
2901 LOCK_TAKE(hdw->ctl_lock);
2902 pvr2_hdw_render_useless_unlocked(hdw);
2903 LOCK_GIVE(hdw->ctl_lock);
2904}
2905
2906
2907void pvr2_hdw_device_reset(struct pvr2_hdw *hdw)
2908{
2909 int ret;
2910 pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset...");
2911 ret = usb_lock_device_for_reset(hdw->usb_dev,0);
2912 if (ret == 1) {
2913 ret = usb_reset_device(hdw->usb_dev);
2914 usb_unlock_device(hdw->usb_dev);
2915 } else {
2916 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2917 "Failed to lock USB device ret=%d",ret);
2918 }
2919 if (init_pause_msec) {
2920 pvr2_trace(PVR2_TRACE_INFO,
2921 "Waiting %u msec for hardware to settle",
2922 init_pause_msec);
2923 msleep(init_pause_msec);
2924 }
2925
2926}
2927
2928
2929void pvr2_hdw_cpureset_assert(struct pvr2_hdw *hdw,int val)
2930{
2931 char da[1];
2932 unsigned int pipe;
2933 int ret;
2934
2935 if (!hdw->usb_dev) return;
2936
2937 pvr2_trace(PVR2_TRACE_INIT,"cpureset_assert(%d)",val);
2938
2939 da[0] = val ? 0x01 : 0x00;
2940
2941 /* Write the CPUCS register on the 8051. The lsb of the register
2942 is the reset bit; a 1 asserts reset while a 0 clears it. */
2943 pipe = usb_sndctrlpipe(hdw->usb_dev, 0);
2944 ret = usb_control_msg(hdw->usb_dev,pipe,0xa0,0x40,0xe600,0,da,1,HZ);
2945 if (ret < 0) {
2946 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2947 "cpureset_assert(%d) error=%d",val,ret);
2948 pvr2_hdw_render_useless(hdw);
2949 }
2950}
2951
2952
2953int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw)
2954{
2955 int status;
2956 LOCK_TAKE(hdw->ctl_lock); do {
2957 pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset");
2958 hdw->flag_ok = !0;
2959 hdw->cmd_buffer[0] = 0xdd;
2960 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
2961 } while (0); LOCK_GIVE(hdw->ctl_lock);
2962 return status;
2963}
2964
2965
2966int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw)
2967{
2968 int status;
2969 LOCK_TAKE(hdw->ctl_lock); do {
2970 pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup");
2971 hdw->cmd_buffer[0] = 0xde;
2972 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
2973 } while (0); LOCK_GIVE(hdw->ctl_lock);
2974 return status;
2975}
2976
2977
2978int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
2979{
2980 if (!hdw->decoder_ctrl) {
2981 pvr2_trace(PVR2_TRACE_INIT,
2982 "Unable to reset decoder: nothing attached");
2983 return -ENOTTY;
2984 }
2985
2986 if (!hdw->decoder_ctrl->force_reset) {
2987 pvr2_trace(PVR2_TRACE_INIT,
2988 "Unable to reset decoder: not implemented");
2989 return -ENOTTY;
2990 }
2991
2992 pvr2_trace(PVR2_TRACE_INIT,
2993 "Requesting decoder reset");
2994 hdw->decoder_ctrl->force_reset(hdw->decoder_ctrl->ctxt);
2995 return 0;
2996}
2997
2998
2999int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
3000{
3001 int status;
3002 LOCK_TAKE(hdw->ctl_lock); do {
3003 hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37);
3004 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
3005 } while (0); LOCK_GIVE(hdw->ctl_lock);
3006 if (!status) {
3007 hdw->subsys_enabled_mask =
3008 ((hdw->subsys_enabled_mask &
3009 ~(1<<PVR2_SUBSYS_B_USBSTREAM_RUN)) |
3010 (runFl ? (1<<PVR2_SUBSYS_B_USBSTREAM_RUN) : 0));
3011 }
3012 return status;
3013}
3014
3015
3016void pvr2_hdw_get_debug_info(const struct pvr2_hdw *hdw,
3017 struct pvr2_hdw_debug_info *ptr)
3018{
3019 ptr->big_lock_held = hdw->big_lock_held;
3020 ptr->ctl_lock_held = hdw->ctl_lock_held;
3021 ptr->flag_ok = hdw->flag_ok;
3022 ptr->flag_disconnected = hdw->flag_disconnected;
3023 ptr->flag_init_ok = hdw->flag_init_ok;
3024 ptr->flag_streaming_enabled = hdw->flag_streaming_enabled;
3025 ptr->subsys_flags = hdw->subsys_enabled_mask;
3026 ptr->cmd_debug_state = hdw->cmd_debug_state;
3027 ptr->cmd_code = hdw->cmd_debug_code;
3028 ptr->cmd_debug_write_len = hdw->cmd_debug_write_len;
3029 ptr->cmd_debug_read_len = hdw->cmd_debug_read_len;
3030 ptr->cmd_debug_timeout = hdw->ctl_timeout_flag;
3031 ptr->cmd_debug_write_pend = hdw->ctl_write_pend_flag;
3032 ptr->cmd_debug_read_pend = hdw->ctl_read_pend_flag;
3033 ptr->cmd_debug_rstatus = hdw->ctl_read_urb->status;
3034 ptr->cmd_debug_wstatus = hdw->ctl_read_urb->status;
3035}
3036
3037
3038int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *dp)
3039{
3040 return pvr2_read_register(hdw,PVR2_GPIO_DIR,dp);
3041}
3042
3043
3044int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *dp)
3045{
3046 return pvr2_read_register(hdw,PVR2_GPIO_OUT,dp);
3047}
3048
3049
3050int pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *dp)
3051{
3052 return pvr2_read_register(hdw,PVR2_GPIO_IN,dp);
3053}
3054
3055
3056int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val)
3057{
3058 u32 cval,nval;
3059 int ret;
3060 if (~msk) {
3061 ret = pvr2_read_register(hdw,PVR2_GPIO_DIR,&cval);
3062 if (ret) return ret;
3063 nval = (cval & ~msk) | (val & msk);
3064 pvr2_trace(PVR2_TRACE_GPIO,
3065 "GPIO direction changing 0x%x:0x%x"
3066 " from 0x%x to 0x%x",
3067 msk,val,cval,nval);
3068 } else {
3069 nval = val;
3070 pvr2_trace(PVR2_TRACE_GPIO,
3071 "GPIO direction changing to 0x%x",nval);
3072 }
3073 return pvr2_write_register(hdw,PVR2_GPIO_DIR,nval);
3074}
3075
3076
3077int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
3078{
3079 u32 cval,nval;
3080 int ret;
3081 if (~msk) {
3082 ret = pvr2_read_register(hdw,PVR2_GPIO_OUT,&cval);
3083 if (ret) return ret;
3084 nval = (cval & ~msk) | (val & msk);
3085 pvr2_trace(PVR2_TRACE_GPIO,
3086 "GPIO output changing 0x%x:0x%x from 0x%x to 0x%x",
3087 msk,val,cval,nval);
3088 } else {
3089 nval = val;
3090 pvr2_trace(PVR2_TRACE_GPIO,
3091 "GPIO output changing to 0x%x",nval);
3092 }
3093 return pvr2_write_register(hdw,PVR2_GPIO_OUT,nval);
3094}
3095
3096
3097int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3098{
3099 int result;
3100 LOCK_TAKE(hdw->ctl_lock); do {
3101 hdw->cmd_buffer[0] = 0xeb;
3102 result = pvr2_send_request(hdw,
3103 hdw->cmd_buffer,1,
3104 hdw->cmd_buffer,1);
3105 if (result < 0) break;
3106 result = hdw->cmd_buffer[0];
3107 } while(0); LOCK_GIVE(hdw->ctl_lock);
3108 return result;
3109}
3110
3111
3112/*
3113 Stuff for Emacs to see, in order to encourage consistent editing style:
3114 *** Local Variables: ***
3115 *** mode: c ***
3116 *** fill-column: 75 ***
3117 *** tab-width: 8 ***
3118 *** c-basic-offset: 8 ***
3119 *** End: ***
3120 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
new file mode 100644
index 000000000000..63f529154431
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -0,0 +1,335 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_HDW_H
22#define __PVRUSB2_HDW_H
23
24#include <linux/usb.h>
25#include <linux/videodev2.h>
26#include "pvrusb2-io.h"
27#include "pvrusb2-ctrl.h"
28
29
30/* Private internal control ids, look these up with
31 pvr2_hdw_get_ctrl_by_id() - these are NOT visible in V4L */
32#define PVR2_CID_STDENUM 1
33#define PVR2_CID_STDCUR 2
34#define PVR2_CID_STDAVAIL 3
35#define PVR2_CID_INPUT 4
36#define PVR2_CID_AUDIOMODE 5
37#define PVR2_CID_FREQUENCY 6
38#define PVR2_CID_HRES 7
39#define PVR2_CID_VRES 8
40
41/* Legal values for the INPUT state variable */
42#define PVR2_CVAL_INPUT_TV 0
43#define PVR2_CVAL_INPUT_SVIDEO 1
44#define PVR2_CVAL_INPUT_COMPOSITE 2
45#define PVR2_CVAL_INPUT_RADIO 3
46
47/* Values that pvr2_hdw_get_signal_status() returns */
48#define PVR2_SIGNAL_OK 0x0001
49#define PVR2_SIGNAL_STEREO 0x0002
50#define PVR2_SIGNAL_SAP 0x0004
51
52
53/* Subsystem definitions - these are various pieces that can be
54 independently stopped / started. Usually you don't want to mess with
55 this directly (let the driver handle things itself), but it is useful
56 for debugging. */
57#define PVR2_SUBSYS_B_ENC_FIRMWARE 0
58#define PVR2_SUBSYS_B_ENC_CFG 1
59#define PVR2_SUBSYS_B_DIGITIZER_RUN 2
60#define PVR2_SUBSYS_B_USBSTREAM_RUN 3
61#define PVR2_SUBSYS_B_ENC_RUN 4
62
63#define PVR2_SUBSYS_CFG_ALL ( \
64 (1 << PVR2_SUBSYS_B_ENC_FIRMWARE) | \
65 (1 << PVR2_SUBSYS_B_ENC_CFG) )
66#define PVR2_SUBSYS_RUN_ALL ( \
67 (1 << PVR2_SUBSYS_B_DIGITIZER_RUN) | \
68 (1 << PVR2_SUBSYS_B_USBSTREAM_RUN) | \
69 (1 << PVR2_SUBSYS_B_ENC_RUN) )
70#define PVR2_SUBSYS_ALL ( \
71 PVR2_SUBSYS_CFG_ALL | \
72 PVR2_SUBSYS_RUN_ALL )
73
74enum pvr2_config {
75 pvr2_config_empty,
76 pvr2_config_mpeg,
77 pvr2_config_vbi,
78 pvr2_config_radio,
79};
80
81const char *pvr2_config_get_name(enum pvr2_config);
82
83struct pvr2_hdw;
84
85/* Create and return a structure for interacting with the underlying
86 hardware */
87struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
88 const struct usb_device_id *devid);
89
90/* Poll for background activity (if any) */
91void pvr2_hdw_poll(struct pvr2_hdw *);
92
93/* Trigger a poll to take place later at a convenient time */
94void pvr2_hdw_poll_trigger(struct pvr2_hdw *);
95void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *);
96
97/* Register a callback used to trigger a future poll */
98void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *,
99 void (*func)(void *),
100 void *data);
101
102/* Get pointer to structure given unit number */
103struct pvr2_hdw *pvr2_hdw_find(int unit_number);
104
105/* Destroy hardware interaction structure */
106void pvr2_hdw_destroy(struct pvr2_hdw *);
107
108/* Set up the structure and attempt to put the device into a usable state.
109 This can be a time-consuming operation, which is why it is not done
110 internally as part of the create() step. Return value is exactly the
111 same as pvr2_hdw_init_ok(). */
112int pvr2_hdw_setup(struct pvr2_hdw *);
113
114/* Initialization succeeded */
115int pvr2_hdw_init_ok(struct pvr2_hdw *);
116
117/* Return true if in the ready (normal) state */
118int pvr2_hdw_dev_ok(struct pvr2_hdw *);
119
120/* Return small integer number [1..N] for logical instance number of this
121 device. This is useful for indexing array-valued module parameters. */
122int pvr2_hdw_get_unit_number(struct pvr2_hdw *);
123
124/* Get pointer to underlying USB device */
125struct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *);
126
127/* Retrieve serial number of device */
128unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *);
129
130/* Called when hardware has been unplugged */
131void pvr2_hdw_disconnect(struct pvr2_hdw *);
132
133/* Get the number of defined controls */
134unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *);
135
136/* Retrieve a control handle given its index (0..count-1) */
137struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *,unsigned int);
138
139/* Retrieve a control handle given its internal ID (if any) */
140struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *,unsigned int);
141
142/* Retrieve a control handle given its V4L ID (if any) */
143struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *,unsigned int ctl_id);
144
145/* Retrieve a control handle given its immediate predecessor V4L ID (if any) */
146struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *,
147 unsigned int ctl_id);
148
149/* Commit all control changes made up to this point */
150int pvr2_hdw_commit_ctl(struct pvr2_hdw *);
151
152/* Return name for this driver instance */
153const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *);
154
155/* Return PVR2_SIGNAL_XXXX bit mask indicating signal status */
156unsigned int pvr2_hdw_get_signal_status(struct pvr2_hdw *);
157
158/* Query device and see if it thinks it is on a high-speed USB link */
159int pvr2_hdw_is_hsm(struct pvr2_hdw *);
160
161/* Turn streaming on/off */
162int pvr2_hdw_set_streaming(struct pvr2_hdw *,int);
163
164/* Find out if streaming is on */
165int pvr2_hdw_get_streaming(struct pvr2_hdw *);
166
167/* Configure the type of stream to generate */
168int pvr2_hdw_set_stream_type(struct pvr2_hdw *, enum pvr2_config);
169
170/* Get handle to video output stream */
171struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *);
172
173/* Emit a video standard struct */
174int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
175 unsigned int idx);
176
177/* Enable / disable various pieces of hardware. Items to change are
178 identified by bit positions within msk, and new state for each item is
179 identified by corresponding bit positions within val. */
180void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
181 unsigned long msk,unsigned long val);
182
183/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,msk) */
184void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk);
185
186/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,0) */
187void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk);
188
189/* Retrieve mask indicating which pieces of hardware are currently enabled
190 / configured. */
191unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *);
192
193/* Adjust mask of what get shut down when streaming is stopped. This is a
194 debugging aid. */
195void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
196 unsigned long msk,unsigned long val);
197
198/* Retrieve mask indicating which pieces of hardware are disabled when
199 streaming is turned off. */
200unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *);
201
202
203/* Enable / disable retrieval of CPU firmware. This must be enabled before
204 pvr2_hdw_cpufw_get() will function. Note that doing this may prevent
205 the device from running (and leaving this mode may imply a device
206 reset). */
207void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *, int enable_flag);
208
209/* Return true if we're in a mode for retrieval CPU firmware */
210int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *);
211
212/* Retrieve a piece of the CPU's firmware at the given offset. Return
213 value is the number of bytes retrieved or zero if we're past the end or
214 an error otherwise (e.g. if firmware retrieval is not enabled). */
215int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
216 char *buf,unsigned int cnt);
217
218/* Retrieve previously stored v4l minor device number */
219int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
220
221/* Store the v4l minor device number */
222void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
223
224
225/* The following entry points are all lower level things you normally don't
226 want to worry about. */
227
228/* Attempt to recover from a USB foul-up (in practice I find that if you
229 have to do this, then it's already too late). */
230void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw);
231
232/* Issue a command and get a response from the device. LOTS of higher
233 level stuff is built on this. */
234int pvr2_send_request(struct pvr2_hdw *,
235 void *write_ptr,unsigned int write_len,
236 void *read_ptr,unsigned int read_len);
237
238/* Issue a command and get a response from the device. This extended
239 version includes a probe flag (which if set means that device errors
240 should not be logged or treated as fatal) and a timeout in jiffies.
241 This can be used to non-lethally probe the health of endpoint 1. */
242int pvr2_send_request_ex(struct pvr2_hdw *,unsigned int timeout,int probe_fl,
243 void *write_ptr,unsigned int write_len,
244 void *read_ptr,unsigned int read_len);
245
246/* Slightly higher level device communication functions. */
247int pvr2_write_register(struct pvr2_hdw *, u16, u32);
248int pvr2_read_register(struct pvr2_hdw *, u16, u32 *);
249int pvr2_write_u16(struct pvr2_hdw *, u16, int);
250int pvr2_write_u8(struct pvr2_hdw *, u8, int);
251
252/* Call if for any reason we can't talk to the hardware anymore - this will
253 cause the driver to stop flailing on the device. */
254void pvr2_hdw_render_useless(struct pvr2_hdw *);
255void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *);
256
257/* Set / clear 8051's reset bit */
258void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int);
259
260/* Execute a USB-commanded device reset */
261void pvr2_hdw_device_reset(struct pvr2_hdw *);
262
263/* Execute hard reset command (after this point it's likely that the
264 encoder will have to be reconfigured). This also clears the "useless"
265 state. */
266int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *);
267
268/* Execute simple reset command */
269int pvr2_hdw_cmd_powerup(struct pvr2_hdw *);
270
271/* Order decoder to reset */
272int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *);
273
274/* Stop / start video stream transport */
275int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
276
277/* Find I2C address of eeprom */
278int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *);
279
280/* Direct manipulation of GPIO bits */
281int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
282int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
283int pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *);
284int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val);
285int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val);
286
287/* This data structure is specifically for the next function... */
288struct pvr2_hdw_debug_info {
289 int big_lock_held;
290 int ctl_lock_held;
291 int flag_ok;
292 int flag_disconnected;
293 int flag_init_ok;
294 int flag_streaming_enabled;
295 unsigned long subsys_flags;
296 int cmd_debug_state;
297 int cmd_debug_write_len;
298 int cmd_debug_read_len;
299 int cmd_debug_write_pend;
300 int cmd_debug_read_pend;
301 int cmd_debug_timeout;
302 int cmd_debug_rstatus;
303 int cmd_debug_wstatus;
304 unsigned char cmd_code;
305};
306
307/* Non-intrusively retrieve internal state info - this is useful for
308 diagnosing lockups. Note that this operation is completed without any
309 kind of locking and so it is not atomic and may yield inconsistent
310 results. This is *purely* a debugging aid. */
311void pvr2_hdw_get_debug_info(const struct pvr2_hdw *hdw,
312 struct pvr2_hdw_debug_info *);
313
314/* Cause modules to log their state once */
315void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw);
316
317/* Cause encoder firmware to be uploaded into the device. This is normally
318 done autonomously, but the interface is exported here because it is also
319 a debugging aid. */
320int pvr2_upload_firmware2(struct pvr2_hdw *hdw);
321
322/* List of device types that we can match */
323extern struct usb_device_id pvr2_device_table[];
324
325#endif /* __PVRUSB2_HDW_H */
326
327/*
328 Stuff for Emacs to see, in order to encourage consistent editing style:
329 *** Local Variables: ***
330 *** mode: c ***
331 *** fill-column: 75 ***
332 *** tab-width: 8 ***
333 *** c-basic-offset: 8 ***
334 *** End: ***
335 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
new file mode 100644
index 000000000000..1dd4f6249b99
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
@@ -0,0 +1,115 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include "pvrusb2-i2c-core.h"
23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h"
25#include "pvrusb2-i2c-cmd-v4l2.h"
26#include "pvrusb2-audio.h"
27#include "pvrusb2-tuner.h"
28#include "pvrusb2-demod.h"
29#include "pvrusb2-video-v4l.h"
30#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
31#include "pvrusb2-cx2584x-v4l.h"
32#include "pvrusb2-wm8775.h"
33#endif
34
35#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
36
37#define OP_STANDARD 0
38#define OP_BCSH 1
39#define OP_VOLUME 2
40#define OP_FREQ 3
41#define OP_AUDIORATE 4
42#define OP_SIZE 5
43#define OP_LOG 6
44
45static const struct pvr2_i2c_op * const ops[] = {
46 [OP_STANDARD] = &pvr2_i2c_op_v4l2_standard,
47 [OP_BCSH] = &pvr2_i2c_op_v4l2_bcsh,
48 [OP_VOLUME] = &pvr2_i2c_op_v4l2_volume,
49 [OP_FREQ] = &pvr2_i2c_op_v4l2_frequency,
50 [OP_SIZE] = &pvr2_i2c_op_v4l2_size,
51 [OP_LOG] = &pvr2_i2c_op_v4l2_log,
52};
53
54void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
55{
56 int id;
57 id = cp->client->driver->id;
58 cp->ctl_mask = ((1 << OP_STANDARD) |
59 (1 << OP_BCSH) |
60 (1 << OP_VOLUME) |
61 (1 << OP_FREQ) |
62 (1 << OP_SIZE) |
63 (1 << OP_LOG));
64
65 if (id == I2C_DRIVERID_MSP3400) {
66 if (pvr2_i2c_msp3400_setup(hdw,cp)) {
67 return;
68 }
69 }
70 if (id == I2C_DRIVERID_TUNER) {
71 if (pvr2_i2c_tuner_setup(hdw,cp)) {
72 return;
73 }
74 }
75#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
76 if (id == I2C_DRIVERID_CX25840) {
77 if (pvr2_i2c_cx2584x_v4l_setup(hdw,cp)) {
78 return;
79 }
80 }
81 if (id == I2C_DRIVERID_WM8775) {
82 if (pvr2_i2c_wm8775_setup(hdw,cp)) {
83 return;
84 }
85 }
86#endif
87 if (id == I2C_DRIVERID_SAA711X) {
88 if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) {
89 return;
90 }
91 }
92 if (id == I2C_DRIVERID_TDA9887) {
93 if (pvr2_i2c_demod_setup(hdw,cp)) {
94 return;
95 }
96 }
97}
98
99
100const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx)
101{
102 if (idx >= sizeof(ops)/sizeof(ops[0])) return 0;
103 return ops[idx];
104}
105
106
107/*
108 Stuff for Emacs to see, in order to encourage consistent editing style:
109 *** Local Variables: ***
110 *** mode: c ***
111 *** fill-column: 75 ***
112 *** tab-width: 8 ***
113 *** c-basic-offset: 8 ***
114 *** End: ***
115 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
new file mode 100644
index 000000000000..9f81aff2b38a
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
@@ -0,0 +1,232 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "pvrusb2-i2c-cmd-v4l2.h"
24#include "pvrusb2-hdw-internal.h"
25#include "pvrusb2-debug.h"
26#include <linux/videodev2.h>
27
28
29static void set_standard(struct pvr2_hdw *hdw)
30{
31 v4l2_std_id vs;
32 vs = hdw->std_mask_cur;
33 pvr2_trace(PVR2_TRACE_CHIPS,
34 "i2c v4l2 set_standard(0x%llx)",(__u64)vs);
35
36 pvr2_i2c_core_cmd(hdw,VIDIOC_S_STD,&vs);
37}
38
39
40static int check_standard(struct pvr2_hdw *hdw)
41{
42 return hdw->std_dirty != 0;
43}
44
45
46const struct pvr2_i2c_op pvr2_i2c_op_v4l2_standard = {
47 .check = check_standard,
48 .update = set_standard,
49 .name = "v4l2_standard",
50};
51
52
53static void set_bcsh(struct pvr2_hdw *hdw)
54{
55 struct v4l2_control ctrl;
56 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 set_bcsh"
57 " b=%d c=%d s=%d h=%d",
58 hdw->brightness_val,hdw->contrast_val,
59 hdw->saturation_val,hdw->hue_val);
60 memset(&ctrl,0,sizeof(ctrl));
61 ctrl.id = V4L2_CID_BRIGHTNESS;
62 ctrl.value = hdw->brightness_val;
63 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
64 ctrl.id = V4L2_CID_CONTRAST;
65 ctrl.value = hdw->contrast_val;
66 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
67 ctrl.id = V4L2_CID_SATURATION;
68 ctrl.value = hdw->saturation_val;
69 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
70 ctrl.id = V4L2_CID_HUE;
71 ctrl.value = hdw->hue_val;
72 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
73}
74
75
76static int check_bcsh(struct pvr2_hdw *hdw)
77{
78 return (hdw->brightness_dirty ||
79 hdw->contrast_dirty ||
80 hdw->saturation_dirty ||
81 hdw->hue_dirty);
82}
83
84
85const struct pvr2_i2c_op pvr2_i2c_op_v4l2_bcsh = {
86 .check = check_bcsh,
87 .update = set_bcsh,
88 .name = "v4l2_bcsh",
89};
90
91
92static void set_volume(struct pvr2_hdw *hdw)
93{
94 struct v4l2_control ctrl;
95 pvr2_trace(PVR2_TRACE_CHIPS,
96 "i2c v4l2 set_volume"
97 "(vol=%d bal=%d bas=%d treb=%d mute=%d)",
98 hdw->volume_val,
99 hdw->balance_val,
100 hdw->bass_val,
101 hdw->treble_val,
102 hdw->mute_val);
103 memset(&ctrl,0,sizeof(ctrl));
104 ctrl.id = V4L2_CID_AUDIO_MUTE;
105 ctrl.value = hdw->mute_val ? 1 : 0;
106 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
107 ctrl.id = V4L2_CID_AUDIO_VOLUME;
108 ctrl.value = hdw->volume_val;
109 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
110 ctrl.id = V4L2_CID_AUDIO_BALANCE;
111 ctrl.value = hdw->balance_val;
112 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
113 ctrl.id = V4L2_CID_AUDIO_BASS;
114 ctrl.value = hdw->bass_val;
115 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
116 ctrl.id = V4L2_CID_AUDIO_TREBLE;
117 ctrl.value = hdw->treble_val;
118 pvr2_i2c_core_cmd(hdw,VIDIOC_S_CTRL,&ctrl);
119}
120
121
122static int check_volume(struct pvr2_hdw *hdw)
123{
124 return (hdw->volume_dirty ||
125 hdw->balance_dirty ||
126 hdw->bass_dirty ||
127 hdw->treble_dirty ||
128 hdw->mute_dirty);
129}
130
131
132const struct pvr2_i2c_op pvr2_i2c_op_v4l2_volume = {
133 .check = check_volume,
134 .update = set_volume,
135 .name = "v4l2_volume",
136};
137
138
139static void set_frequency(struct pvr2_hdw *hdw)
140{
141 unsigned long fv;
142 struct v4l2_frequency freq;
143 fv = hdw->freqVal;
144 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 set_freq(%lu)",fv);
145 memset(&freq,0,sizeof(freq));
146 freq.frequency = fv / 62500;
147 freq.tuner = 0;
148 freq.type = V4L2_TUNER_ANALOG_TV;
149 pvr2_i2c_core_cmd(hdw,VIDIOC_S_FREQUENCY,&freq);
150}
151
152
153static int check_frequency(struct pvr2_hdw *hdw)
154{
155 return hdw->freqDirty != 0;
156}
157
158
159const struct pvr2_i2c_op pvr2_i2c_op_v4l2_frequency = {
160 .check = check_frequency,
161 .update = set_frequency,
162 .name = "v4l2_freq",
163};
164
165
166static void set_size(struct pvr2_hdw *hdw)
167{
168 struct v4l2_format fmt;
169
170 memset(&fmt,0,sizeof(fmt));
171
172 fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
173 fmt.fmt.pix.width = hdw->res_hor_val;
174 fmt.fmt.pix.height = hdw->res_ver_val;
175
176 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 set_size(%dx%d)",
177 fmt.fmt.pix.width,fmt.fmt.pix.height);
178
179 pvr2_i2c_core_cmd(hdw,VIDIOC_S_FMT,&fmt);
180}
181
182
183static int check_size(struct pvr2_hdw *hdw)
184{
185 return (hdw->res_hor_dirty || hdw->res_ver_dirty);
186}
187
188
189const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size = {
190 .check = check_size,
191 .update = set_size,
192 .name = "v4l2_size",
193};
194
195
196static void do_log(struct pvr2_hdw *hdw)
197{
198 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 do_log()");
199 pvr2_i2c_core_cmd(hdw,VIDIOC_LOG_STATUS,0);
200
201}
202
203
204static int check_log(struct pvr2_hdw *hdw)
205{
206 return hdw->log_requested != 0;
207}
208
209
210const struct pvr2_i2c_op pvr2_i2c_op_v4l2_log = {
211 .check = check_log,
212 .update = do_log,
213 .name = "v4l2_log",
214};
215
216
217void pvr2_v4l2_cmd_stream(struct pvr2_i2c_client *cp,int fl)
218{
219 pvr2_i2c_client_cmd(cp,
220 (fl ? VIDIOC_STREAMON : VIDIOC_STREAMOFF),0);
221}
222
223
224/*
225 Stuff for Emacs to see, in order to encourage consistent editing style:
226 *** Local Variables: ***
227 *** mode: c ***
228 *** fill-column: 70 ***
229 *** tab-width: 8 ***
230 *** c-basic-offset: 8 ***
231 *** End: ***
232 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
new file mode 100644
index 000000000000..ecabddba1ec5
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
@@ -0,0 +1,47 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_CMD_V4L2_H
24#define __PVRUSB2_CMD_V4L2_H
25
26#include "pvrusb2-i2c-core.h"
27
28extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_standard;
29extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_bcsh;
30extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_volume;
31extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_frequency;
32extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size;
33extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_log;
34
35void pvr2_v4l2_cmd_stream(struct pvr2_i2c_client *,int);
36
37#endif /* __PVRUSB2_CMD_V4L2_H */
38
39/*
40 Stuff for Emacs to see, in order to encourage consistent editing style:
41 *** Local Variables: ***
42 *** mode: c ***
43 *** fill-column: 70 ***
44 *** tab-width: 8 ***
45 *** c-basic-offset: 8 ***
46 *** End: ***
47 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
new file mode 100644
index 000000000000..c8d0bdee3ff1
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -0,0 +1,937 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include "pvrusb2-i2c-core.h"
23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h"
25
26#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
27
28/*
29
30 This module attempts to implement a compliant I2C adapter for the pvrusb2
31 device. By doing this we can then make use of existing functionality in
32 V4L (e.g. tuner.c) rather than rolling our own.
33
34*/
35
36static unsigned int i2c_scan = 0;
37module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
38MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
39
40static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
41 u8 i2c_addr, /* I2C address we're talking to */
42 u8 *data, /* Data to write */
43 u16 length) /* Size of data to write */
44{
45 /* Return value - default 0 means success */
46 int ret;
47
48
49 if (!data) length = 0;
50 if (length > (sizeof(hdw->cmd_buffer) - 3)) {
51 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
52 "Killing an I2C write to %u that is too large"
53 " (desired=%u limit=%u)",
54 i2c_addr,
55 length,(unsigned int)(sizeof(hdw->cmd_buffer) - 3));
56 return -ENOTSUPP;
57 }
58
59 LOCK_TAKE(hdw->ctl_lock);
60
61 /* Clear the command buffer (likely to be paranoia) */
62 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer));
63
64 /* Set up command buffer for an I2C write */
65 hdw->cmd_buffer[0] = 0x08; /* write prefix */
66 hdw->cmd_buffer[1] = i2c_addr; /* i2c addr of chip */
67 hdw->cmd_buffer[2] = length; /* length of what follows */
68 if (length) memcpy(hdw->cmd_buffer + 3, data, length);
69
70 /* Do the operation */
71 ret = pvr2_send_request(hdw,
72 hdw->cmd_buffer,
73 length + 3,
74 hdw->cmd_buffer,
75 1);
76 if (!ret) {
77 if (hdw->cmd_buffer[0] != 8) {
78 ret = -EIO;
79 if (hdw->cmd_buffer[0] != 7) {
80 trace_i2c("unexpected status"
81 " from i2_write[%d]: %d",
82 i2c_addr,hdw->cmd_buffer[0]);
83 }
84 }
85 }
86
87 LOCK_GIVE(hdw->ctl_lock);
88
89 return ret;
90}
91
92static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
93 u8 i2c_addr, /* I2C address we're talking to */
94 u8 *data, /* Data to write */
95 u16 dlen, /* Size of data to write */
96 u8 *res, /* Where to put data we read */
97 u16 rlen) /* Amount of data to read */
98{
99 /* Return value - default 0 means success */
100 int ret;
101
102
103 if (!data) dlen = 0;
104 if (dlen > (sizeof(hdw->cmd_buffer) - 4)) {
105 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
106 "Killing an I2C read to %u that has wlen too large"
107 " (desired=%u limit=%u)",
108 i2c_addr,
109 dlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 4));
110 return -ENOTSUPP;
111 }
112 if (res && (rlen > (sizeof(hdw->cmd_buffer) - 1))) {
113 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
114 "Killing an I2C read to %u that has rlen too large"
115 " (desired=%u limit=%u)",
116 i2c_addr,
117 rlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 1));
118 return -ENOTSUPP;
119 }
120
121 LOCK_TAKE(hdw->ctl_lock);
122
123 /* Clear the command buffer (likely to be paranoia) */
124 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer));
125
126 /* Set up command buffer for an I2C write followed by a read */
127 hdw->cmd_buffer[0] = 0x09; /* read prefix */
128 hdw->cmd_buffer[1] = dlen; /* arg length */
129 hdw->cmd_buffer[2] = rlen; /* answer length. Device will send one
130 more byte (status). */
131 hdw->cmd_buffer[3] = i2c_addr; /* i2c addr of chip */
132 if (dlen) memcpy(hdw->cmd_buffer + 4, data, dlen);
133
134 /* Do the operation */
135 ret = pvr2_send_request(hdw,
136 hdw->cmd_buffer,
137 4 + dlen,
138 hdw->cmd_buffer,
139 rlen + 1);
140 if (!ret) {
141 if (hdw->cmd_buffer[0] != 8) {
142 ret = -EIO;
143 if (hdw->cmd_buffer[0] != 7) {
144 trace_i2c("unexpected status"
145 " from i2_read[%d]: %d",
146 i2c_addr,hdw->cmd_buffer[0]);
147 }
148 }
149 }
150
151 /* Copy back the result */
152 if (res && rlen) {
153 if (ret) {
154 /* Error, just blank out the return buffer */
155 memset(res, 0, rlen);
156 } else {
157 memcpy(res, hdw->cmd_buffer + 1, rlen);
158 }
159 }
160
161 LOCK_GIVE(hdw->ctl_lock);
162
163 return ret;
164}
165
166/* This is the common low level entry point for doing I2C operations to the
167 hardware. */
168int pvr2_i2c_basic_op(struct pvr2_hdw *hdw,
169 u8 i2c_addr,
170 u8 *wdata,
171 u16 wlen,
172 u8 *rdata,
173 u16 rlen)
174{
175 if (!rdata) rlen = 0;
176 if (!wdata) wlen = 0;
177 if (rlen || !wlen) {
178 return pvr2_i2c_read(hdw,i2c_addr,wdata,wlen,rdata,rlen);
179 } else {
180 return pvr2_i2c_write(hdw,i2c_addr,wdata,wlen);
181 }
182}
183
184#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
185
186/* This is a special entry point that is entered if an I2C operation is
187 attempted to a wm8775 chip on model 24xxx hardware. Autodetect of this
188 part doesn't work, but we know it is really there. So let's look for
189 the autodetect attempt and just return success if we see that. */
190static int i2c_hack_wm8775(struct pvr2_hdw *hdw,
191 u8 i2c_addr,u8 *wdata,u16 wlen,u8 *rdata,u16 rlen)
192{
193 if (!(rlen || wlen)) {
194 // This is a probe attempt. Just let it succeed.
195 return 0;
196 }
197 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen);
198}
199
200/* This is a special entry point that is entered if an I2C operation is
201 attempted to a cx25840 chip on model 24xxx hardware. This chip can
202 sometimes wedge itself. Worse still, when this happens msp3400 can
203 falsely detect this part and then the system gets hosed up after msp3400
204 gets confused and dies. What we want to do here is try to keep msp3400
205 away and also try to notice if the chip is wedged and send a warning to
206 the system log. */
207static int i2c_hack_cx25840(struct pvr2_hdw *hdw,
208 u8 i2c_addr,u8 *wdata,u16 wlen,u8 *rdata,u16 rlen)
209{
210 int ret;
211 unsigned int subaddr;
212 u8 wbuf[2];
213 int state = hdw->i2c_cx25840_hack_state;
214
215 if (!(rlen || wlen)) {
216 // Probe attempt - always just succeed and don't bother the
217 // hardware (this helps to make the state machine further
218 // down somewhat easier).
219 return 0;
220 }
221
222 if (state == 3) {
223 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen);
224 }
225
226 /* We're looking for the exact pattern where the revision register
227 is being read. The cx25840 module will always look at the
228 revision register first. Any other pattern of access therefore
229 has to be a probe attempt from somebody else so we'll reject it.
230 Normally we could just let each client just probe the part
231 anyway, but when the cx25840 is wedged, msp3400 will get a false
232 positive and that just screws things up... */
233
234 if (wlen == 0) {
235 switch (state) {
236 case 1: subaddr = 0x0100; break;
237 case 2: subaddr = 0x0101; break;
238 default: goto fail;
239 }
240 } else if (wlen == 2) {
241 subaddr = (wdata[0] << 8) | wdata[1];
242 switch (subaddr) {
243 case 0x0100: state = 1; break;
244 case 0x0101: state = 2; break;
245 default: goto fail;
246 }
247 } else {
248 goto fail;
249 }
250 if (!rlen) goto success;
251 state = 0;
252 if (rlen != 1) goto fail;
253
254 /* If we get to here then we have a legitimate read for one of the
255 two revision bytes, so pass it through. */
256 wbuf[0] = subaddr >> 8;
257 wbuf[1] = subaddr;
258 ret = pvr2_i2c_basic_op(hdw,i2c_addr,wbuf,2,rdata,rlen);
259
260 if ((ret != 0) || (*rdata == 0x04) || (*rdata == 0x0a)) {
261 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
262 "WARNING: Detected a wedged cx25840 chip;"
263 " the device will not work.");
264 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
265 "WARNING: Try power cycling the pvrusb2 device.");
266 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
267 "WARNING: Disabling further access to the device"
268 " to prevent other foul-ups.");
269 // This blocks all further communication with the part.
270 hdw->i2c_func[0x44] = 0;
271 pvr2_hdw_render_useless(hdw);
272 goto fail;
273 }
274
275 /* Success! */
276 pvr2_trace(PVR2_TRACE_CHIPS,"cx25840 appears to be OK.");
277 state = 3;
278
279 success:
280 hdw->i2c_cx25840_hack_state = state;
281 return 0;
282
283 fail:
284 hdw->i2c_cx25840_hack_state = state;
285 return -EIO;
286}
287
288#endif /* CONFIG_VIDEO_PVRUSB2_24XXX */
289
290/* This is a very, very limited I2C adapter implementation. We can only
291 support what we actually know will work on the device... */
292static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
293 struct i2c_msg msgs[],
294 int num)
295{
296 int ret = -ENOTSUPP;
297 pvr2_i2c_func funcp = 0;
298 struct pvr2_hdw *hdw = (struct pvr2_hdw *)(i2c_adap->algo_data);
299
300 if (!num) {
301 ret = -EINVAL;
302 goto done;
303 }
304 if ((msgs[0].flags & I2C_M_NOSTART)) {
305 trace_i2c("i2c refusing I2C_M_NOSTART");
306 goto done;
307 }
308 if (msgs[0].addr < PVR2_I2C_FUNC_CNT) {
309 funcp = hdw->i2c_func[msgs[0].addr];
310 }
311 if (!funcp) {
312 ret = -EIO;
313 goto done;
314 }
315
316 if (num == 1) {
317 if (msgs[0].flags & I2C_M_RD) {
318 /* Simple read */
319 u16 tcnt,bcnt,offs;
320 if (!msgs[0].len) {
321 /* Length == 0 read. This is a probe. */
322 if (funcp(hdw,msgs[0].addr,0,0,0,0)) {
323 ret = -EIO;
324 goto done;
325 }
326 ret = 1;
327 goto done;
328 }
329 /* If the read is short enough we'll do the whole
330 thing atomically. Otherwise we have no choice
331 but to break apart the reads. */
332 tcnt = msgs[0].len;
333 offs = 0;
334 while (tcnt) {
335 bcnt = tcnt;
336 if (bcnt > sizeof(hdw->cmd_buffer)-1) {
337 bcnt = sizeof(hdw->cmd_buffer)-1;
338 }
339 if (funcp(hdw,msgs[0].addr,0,0,
340 msgs[0].buf+offs,bcnt)) {
341 ret = -EIO;
342 goto done;
343 }
344 offs += bcnt;
345 tcnt -= bcnt;
346 }
347 ret = 1;
348 goto done;
349 } else {
350 /* Simple write */
351 ret = 1;
352 if (funcp(hdw,msgs[0].addr,
353 msgs[0].buf,msgs[0].len,0,0)) {
354 ret = -EIO;
355 }
356 goto done;
357 }
358 } else if (num == 2) {
359 if (msgs[0].addr != msgs[1].addr) {
360 trace_i2c("i2c refusing 2 phase transfer with"
361 " conflicting target addresses");
362 ret = -ENOTSUPP;
363 goto done;
364 }
365 if ((!((msgs[0].flags & I2C_M_RD))) &&
366 (msgs[1].flags & I2C_M_RD)) {
367 u16 tcnt,bcnt,wcnt,offs;
368 /* Write followed by atomic read. If the read
369 portion is short enough we'll do the whole thing
370 atomically. Otherwise we have no choice but to
371 break apart the reads. */
372 tcnt = msgs[1].len;
373 wcnt = msgs[0].len;
374 offs = 0;
375 while (tcnt || wcnt) {
376 bcnt = tcnt;
377 if (bcnt > sizeof(hdw->cmd_buffer)-1) {
378 bcnt = sizeof(hdw->cmd_buffer)-1;
379 }
380 if (funcp(hdw,msgs[0].addr,
381 msgs[0].buf,wcnt,
382 msgs[1].buf+offs,bcnt)) {
383 ret = -EIO;
384 goto done;
385 }
386 offs += bcnt;
387 tcnt -= bcnt;
388 wcnt = 0;
389 }
390 ret = 2;
391 goto done;
392 } else {
393 trace_i2c("i2c refusing complex transfer"
394 " read0=%d read1=%d",
395 (msgs[0].flags & I2C_M_RD),
396 (msgs[1].flags & I2C_M_RD));
397 }
398 } else {
399 trace_i2c("i2c refusing %d phase transfer",num);
400 }
401
402 done:
403 if (pvrusb2_debug & PVR2_TRACE_I2C_TRAF) {
404 unsigned int idx,offs,cnt;
405 for (idx = 0; idx < num; idx++) {
406 cnt = msgs[idx].len;
407 printk(KERN_INFO
408 "pvrusb2 i2c xfer %u/%u:"
409 " addr=0x%x len=%d %s%s",
410 idx+1,num,
411 msgs[idx].addr,
412 cnt,
413 (msgs[idx].flags & I2C_M_RD ?
414 "read" : "write"),
415 (msgs[idx].flags & I2C_M_NOSTART ?
416 " nostart" : ""));
417 if ((ret > 0) || !(msgs[idx].flags & I2C_M_RD)) {
418 if (cnt > 8) cnt = 8;
419 printk(" [");
420 for (offs = 0; offs < (cnt>8?8:cnt); offs++) {
421 if (offs) printk(" ");
422 printk("%02x",msgs[idx].buf[offs]);
423 }
424 if (offs < cnt) printk(" ...");
425 printk("]");
426 }
427 if (idx+1 == num) {
428 printk(" result=%d",ret);
429 }
430 printk("\n");
431 }
432 if (!num) {
433 printk(KERN_INFO
434 "pvrusb2 i2c xfer null transfer result=%d\n",
435 ret);
436 }
437 }
438 return ret;
439}
440
441static int pvr2_i2c_control(struct i2c_adapter *adapter,
442 unsigned int cmd, unsigned long arg)
443{
444 return 0;
445}
446
447static u32 pvr2_i2c_functionality(struct i2c_adapter *adap)
448{
449 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C | I2C_FUNC_SMBUS_BYTE_DATA;
450}
451
452static int pvr2_i2c_core_singleton(struct i2c_client *cp,
453 unsigned int cmd,void *arg)
454{
455 int stat;
456 if (!cp) return -EINVAL;
457 if (!(cp->driver)) return -EINVAL;
458 if (!(cp->driver->command)) return -EINVAL;
459 if (!try_module_get(cp->driver->driver.owner)) return -EAGAIN;
460 stat = cp->driver->command(cp,cmd,arg);
461 module_put(cp->driver->driver.owner);
462 return stat;
463}
464
465int pvr2_i2c_client_cmd(struct pvr2_i2c_client *cp,unsigned int cmd,void *arg)
466{
467 int stat;
468 if (pvrusb2_debug & PVR2_TRACE_I2C_CMD) {
469 char buf[100];
470 unsigned int cnt;
471 cnt = pvr2_i2c_client_describe(cp,PVR2_I2C_DETAIL_DEBUG,
472 buf,sizeof(buf));
473 pvr2_trace(PVR2_TRACE_I2C_CMD,
474 "i2c COMMAND (code=%u 0x%x) to %.*s",
475 cmd,cmd,cnt,buf);
476 }
477 stat = pvr2_i2c_core_singleton(cp->client,cmd,arg);
478 if (pvrusb2_debug & PVR2_TRACE_I2C_CMD) {
479 char buf[100];
480 unsigned int cnt;
481 cnt = pvr2_i2c_client_describe(cp,PVR2_I2C_DETAIL_DEBUG,
482 buf,sizeof(buf));
483 pvr2_trace(PVR2_TRACE_I2C_CMD,
484 "i2c COMMAND to %.*s (ret=%d)",cnt,buf,stat);
485 }
486 return stat;
487}
488
489int pvr2_i2c_core_cmd(struct pvr2_hdw *hdw,unsigned int cmd,void *arg)
490{
491 struct list_head *item,*nc;
492 struct pvr2_i2c_client *cp;
493 int stat = -EINVAL;
494
495 if (!hdw) return stat;
496
497 mutex_lock(&hdw->i2c_list_lock);
498 list_for_each_safe(item,nc,&hdw->i2c_clients) {
499 cp = list_entry(item,struct pvr2_i2c_client,list);
500 if (!cp->recv_enable) continue;
501 mutex_unlock(&hdw->i2c_list_lock);
502 stat = pvr2_i2c_client_cmd(cp,cmd,arg);
503 mutex_lock(&hdw->i2c_list_lock);
504 }
505 mutex_unlock(&hdw->i2c_list_lock);
506 return stat;
507}
508
509
510static int handler_check(struct pvr2_i2c_client *cp)
511{
512 struct pvr2_i2c_handler *hp = cp->handler;
513 if (!hp) return 0;
514 if (!hp->func_table->check) return 0;
515 return hp->func_table->check(hp->func_data) != 0;
516}
517
518#define BUFSIZE 500
519
520void pvr2_i2c_core_sync(struct pvr2_hdw *hdw)
521{
522 unsigned long msk;
523 unsigned int idx;
524 struct list_head *item,*nc;
525 struct pvr2_i2c_client *cp;
526
527 if (!hdw->i2c_linked) return;
528 if (!(hdw->i2c_pend_types & PVR2_I2C_PEND_ALL)) {
529 return;
530 }
531 mutex_lock(&hdw->i2c_list_lock); do {
532 pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: core_sync BEGIN");
533 if (hdw->i2c_pend_types & PVR2_I2C_PEND_DETECT) {
534 /* One or more I2C clients have attached since we
535 last synced. So scan the list and identify the
536 new clients. */
537 char *buf;
538 unsigned int cnt;
539 unsigned long amask = 0;
540 buf = kmalloc(BUFSIZE,GFP_KERNEL);
541 pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: PEND_DETECT");
542 hdw->i2c_pend_types &= ~PVR2_I2C_PEND_DETECT;
543 list_for_each(item,&hdw->i2c_clients) {
544 cp = list_entry(item,struct pvr2_i2c_client,
545 list);
546 if (!cp->detected_flag) {
547 cp->ctl_mask = 0;
548 pvr2_i2c_probe(hdw,cp);
549 cp->detected_flag = !0;
550 msk = cp->ctl_mask;
551 cnt = 0;
552 if (buf) {
553 cnt = pvr2_i2c_client_describe(
554 cp,
555 PVR2_I2C_DETAIL_ALL,
556 buf,BUFSIZE);
557 }
558 trace_i2c("Probed: %.*s",cnt,buf);
559 if (handler_check(cp)) {
560 hdw->i2c_pend_types |=
561 PVR2_I2C_PEND_CLIENT;
562 }
563 cp->pend_mask = msk;
564 hdw->i2c_pend_mask |= msk;
565 hdw->i2c_pend_types |=
566 PVR2_I2C_PEND_REFRESH;
567 }
568 amask |= cp->ctl_mask;
569 }
570 hdw->i2c_active_mask = amask;
571 if (buf) kfree(buf);
572 }
573 if (hdw->i2c_pend_types & PVR2_I2C_PEND_STALE) {
574 /* Need to do one or more global updates. Arrange
575 for this to happen. */
576 unsigned long m2;
577 pvr2_trace(PVR2_TRACE_I2C_CORE,
578 "i2c: PEND_STALE (0x%lx)",
579 hdw->i2c_stale_mask);
580 hdw->i2c_pend_types &= ~PVR2_I2C_PEND_STALE;
581 list_for_each(item,&hdw->i2c_clients) {
582 cp = list_entry(item,struct pvr2_i2c_client,
583 list);
584 m2 = hdw->i2c_stale_mask;
585 m2 &= cp->ctl_mask;
586 m2 &= ~cp->pend_mask;
587 if (m2) {
588 pvr2_trace(PVR2_TRACE_I2C_CORE,
589 "i2c: cp=%p setting 0x%lx",
590 cp,m2);
591 cp->pend_mask |= m2;
592 }
593 }
594 hdw->i2c_pend_mask |= hdw->i2c_stale_mask;
595 hdw->i2c_stale_mask = 0;
596 hdw->i2c_pend_types |= PVR2_I2C_PEND_REFRESH;
597 }
598 if (hdw->i2c_pend_types & PVR2_I2C_PEND_CLIENT) {
599 /* One or more client handlers are asking for an
600 update. Run through the list of known clients
601 and update each one. */
602 pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: PEND_CLIENT");
603 hdw->i2c_pend_types &= ~PVR2_I2C_PEND_CLIENT;
604 list_for_each_safe(item,nc,&hdw->i2c_clients) {
605 cp = list_entry(item,struct pvr2_i2c_client,
606 list);
607 if (!cp->handler) continue;
608 if (!cp->handler->func_table->update) continue;
609 pvr2_trace(PVR2_TRACE_I2C_CORE,
610 "i2c: cp=%p update",cp);
611 mutex_unlock(&hdw->i2c_list_lock);
612 cp->handler->func_table->update(
613 cp->handler->func_data);
614 mutex_lock(&hdw->i2c_list_lock);
615 /* If client's update function set some
616 additional pending bits, account for that
617 here. */
618 if (cp->pend_mask & ~hdw->i2c_pend_mask) {
619 hdw->i2c_pend_mask |= cp->pend_mask;
620 hdw->i2c_pend_types |=
621 PVR2_I2C_PEND_REFRESH;
622 }
623 }
624 }
625 if (hdw->i2c_pend_types & PVR2_I2C_PEND_REFRESH) {
626 const struct pvr2_i2c_op *opf;
627 unsigned long pm;
628 /* Some actual updates are pending. Walk through
629 each update type and perform it. */
630 pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: PEND_REFRESH"
631 " (0x%lx)",hdw->i2c_pend_mask);
632 hdw->i2c_pend_types &= ~PVR2_I2C_PEND_REFRESH;
633 pm = hdw->i2c_pend_mask;
634 hdw->i2c_pend_mask = 0;
635 for (idx = 0, msk = 1; pm; idx++, msk <<= 1) {
636 if (!(pm & msk)) continue;
637 pm &= ~msk;
638 list_for_each(item,&hdw->i2c_clients) {
639 cp = list_entry(item,
640 struct pvr2_i2c_client,
641 list);
642 if (cp->pend_mask & msk) {
643 cp->pend_mask &= ~msk;
644 cp->recv_enable = !0;
645 } else {
646 cp->recv_enable = 0;
647 }
648 }
649 opf = pvr2_i2c_get_op(idx);
650 if (!opf) continue;
651 mutex_unlock(&hdw->i2c_list_lock);
652 opf->update(hdw);
653 mutex_lock(&hdw->i2c_list_lock);
654 }
655 }
656 pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: core_sync END");
657 } while (0); mutex_unlock(&hdw->i2c_list_lock);
658}
659
660int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw)
661{
662 unsigned long msk,sm,pm;
663 unsigned int idx;
664 const struct pvr2_i2c_op *opf;
665 struct list_head *item;
666 struct pvr2_i2c_client *cp;
667 unsigned int pt = 0;
668
669 pvr2_trace(PVR2_TRACE_I2C_CORE,"pvr2_i2c_core_check_stale BEGIN");
670
671 pm = hdw->i2c_active_mask;
672 sm = 0;
673 for (idx = 0, msk = 1; pm; idx++, msk <<= 1) {
674 if (!(msk & pm)) continue;
675 pm &= ~msk;
676 opf = pvr2_i2c_get_op(idx);
677 if (!opf) continue;
678 if (opf->check(hdw)) {
679 sm |= msk;
680 }
681 }
682 if (sm) pt |= PVR2_I2C_PEND_STALE;
683
684 list_for_each(item,&hdw->i2c_clients) {
685 cp = list_entry(item,struct pvr2_i2c_client,list);
686 if (!handler_check(cp)) continue;
687 pt |= PVR2_I2C_PEND_CLIENT;
688 }
689
690 if (pt) {
691 mutex_lock(&hdw->i2c_list_lock); do {
692 hdw->i2c_pend_types |= pt;
693 hdw->i2c_stale_mask |= sm;
694 hdw->i2c_pend_mask |= hdw->i2c_stale_mask;
695 } while (0); mutex_unlock(&hdw->i2c_list_lock);
696 }
697
698 pvr2_trace(PVR2_TRACE_I2C_CORE,
699 "i2c: types=0x%x stale=0x%lx pend=0x%lx",
700 hdw->i2c_pend_types,
701 hdw->i2c_stale_mask,
702 hdw->i2c_pend_mask);
703 pvr2_trace(PVR2_TRACE_I2C_CORE,"pvr2_i2c_core_check_stale END");
704
705 return (hdw->i2c_pend_types & PVR2_I2C_PEND_ALL) != 0;
706}
707
708unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
709 unsigned int detail,
710 char *buf,unsigned int maxlen)
711{
712 unsigned int ccnt,bcnt;
713 int spcfl = 0;
714 const struct pvr2_i2c_op *opf;
715
716 ccnt = 0;
717 if (detail & PVR2_I2C_DETAIL_DEBUG) {
718 bcnt = scnprintf(buf,maxlen,
719 "ctxt=%p ctl_mask=0x%lx",
720 cp,cp->ctl_mask);
721 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
722 spcfl = !0;
723 }
724 bcnt = scnprintf(buf,maxlen,
725 "%s%s @ 0x%x",
726 (spcfl ? " " : ""),
727 cp->client->name,
728 cp->client->addr);
729 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
730 if ((detail & PVR2_I2C_DETAIL_HANDLER) &&
731 cp->handler && cp->handler->func_table->describe) {
732 bcnt = scnprintf(buf,maxlen," (");
733 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
734 bcnt = cp->handler->func_table->describe(
735 cp->handler->func_data,buf,maxlen);
736 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
737 bcnt = scnprintf(buf,maxlen,")");
738 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
739 }
740 if ((detail & PVR2_I2C_DETAIL_CTLMASK) && cp->ctl_mask) {
741 unsigned int idx;
742 unsigned long msk,sm;
743 int spcfl;
744 bcnt = scnprintf(buf,maxlen," [");
745 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
746 sm = 0;
747 spcfl = 0;
748 for (idx = 0, msk = 1; msk; idx++, msk <<= 1) {
749 if (!(cp->ctl_mask & msk)) continue;
750 opf = pvr2_i2c_get_op(idx);
751 if (opf) {
752 bcnt = scnprintf(buf,maxlen,"%s%s",
753 spcfl ? " " : "",
754 opf->name);
755 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
756 spcfl = !0;
757 } else {
758 sm |= msk;
759 }
760 }
761 if (sm) {
762 bcnt = scnprintf(buf,maxlen,"%s%lx",
763 idx != 0 ? " " : "",sm);
764 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
765 }
766 bcnt = scnprintf(buf,maxlen,"]");
767 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
768 }
769 return ccnt;
770}
771
772unsigned int pvr2_i2c_report(struct pvr2_hdw *hdw,
773 char *buf,unsigned int maxlen)
774{
775 unsigned int ccnt,bcnt;
776 struct list_head *item;
777 struct pvr2_i2c_client *cp;
778 ccnt = 0;
779 mutex_lock(&hdw->i2c_list_lock); do {
780 list_for_each(item,&hdw->i2c_clients) {
781 cp = list_entry(item,struct pvr2_i2c_client,list);
782 bcnt = pvr2_i2c_client_describe(
783 cp,
784 (PVR2_I2C_DETAIL_HANDLER|
785 PVR2_I2C_DETAIL_CTLMASK),
786 buf,maxlen);
787 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
788 bcnt = scnprintf(buf,maxlen,"\n");
789 ccnt += bcnt; buf += bcnt; maxlen -= bcnt;
790 }
791 } while (0); mutex_unlock(&hdw->i2c_list_lock);
792 return ccnt;
793}
794
795static int pvr2_i2c_attach_inform(struct i2c_client *client)
796{
797 struct pvr2_hdw *hdw = (struct pvr2_hdw *)(client->adapter->algo_data);
798 struct pvr2_i2c_client *cp;
799 int fl = !(hdw->i2c_pend_types & PVR2_I2C_PEND_ALL);
800 cp = kmalloc(sizeof(*cp),GFP_KERNEL);
801 trace_i2c("i2c_attach [client=%s @ 0x%x ctxt=%p]",
802 client->name,
803 client->addr,cp);
804 if (!cp) return -ENOMEM;
805 memset(cp,0,sizeof(*cp));
806 INIT_LIST_HEAD(&cp->list);
807 cp->client = client;
808 mutex_lock(&hdw->i2c_list_lock); do {
809 list_add_tail(&cp->list,&hdw->i2c_clients);
810 hdw->i2c_pend_types |= PVR2_I2C_PEND_DETECT;
811 } while (0); mutex_unlock(&hdw->i2c_list_lock);
812 if (fl) pvr2_hdw_poll_trigger_unlocked(hdw);
813 return 0;
814}
815
816static int pvr2_i2c_detach_inform(struct i2c_client *client)
817{
818 struct pvr2_hdw *hdw = (struct pvr2_hdw *)(client->adapter->algo_data);
819 struct pvr2_i2c_client *cp;
820 struct list_head *item,*nc;
821 unsigned long amask = 0;
822 int foundfl = 0;
823 mutex_lock(&hdw->i2c_list_lock); do {
824 list_for_each_safe(item,nc,&hdw->i2c_clients) {
825 cp = list_entry(item,struct pvr2_i2c_client,list);
826 if (cp->client == client) {
827 trace_i2c("pvr2_i2c_detach"
828 " [client=%s @ 0x%x ctxt=%p]",
829 client->name,
830 client->addr,cp);
831 if (cp->handler &&
832 cp->handler->func_table->detach) {
833 cp->handler->func_table->detach(
834 cp->handler->func_data);
835 }
836 list_del(&cp->list);
837 kfree(cp);
838 foundfl = !0;
839 continue;
840 }
841 amask |= cp->ctl_mask;
842 }
843 hdw->i2c_active_mask = amask;
844 } while (0); mutex_unlock(&hdw->i2c_list_lock);
845 if (!foundfl) {
846 trace_i2c("pvr2_i2c_detach [client=%s @ 0x%x ctxt=<unknown>]",
847 client->name,
848 client->addr);
849 }
850 return 0;
851}
852
853static struct i2c_algorithm pvr2_i2c_algo_template = {
854 .master_xfer = pvr2_i2c_xfer,
855 .algo_control = pvr2_i2c_control,
856 .functionality = pvr2_i2c_functionality,
857};
858
859static struct i2c_adapter pvr2_i2c_adap_template = {
860 .owner = THIS_MODULE,
861 .class = I2C_CLASS_TV_ANALOG,
862 .id = I2C_HW_B_BT848,
863 .client_register = pvr2_i2c_attach_inform,
864 .client_unregister = pvr2_i2c_detach_inform,
865};
866
867static void do_i2c_scan(struct pvr2_hdw *hdw)
868{
869 struct i2c_msg msg[1];
870 int i,rc;
871 msg[0].addr = 0;
872 msg[0].flags = I2C_M_RD;
873 msg[0].len = 0;
874 msg[0].buf = 0;
875 printk("%s: i2c scan beginning\n",hdw->name);
876 for (i = 0; i < 128; i++) {
877 msg[0].addr = i;
878 rc = i2c_transfer(&hdw->i2c_adap,msg,
879 sizeof(msg)/sizeof(msg[0]));
880 if (rc != 1) continue;
881 printk("%s: i2c scan: found device @ 0x%x\n",hdw->name,i);
882 }
883 printk("%s: i2c scan done.\n",hdw->name);
884}
885
886void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
887{
888 unsigned int idx;
889
890 // The default action for all possible I2C addresses is just to do
891 // the transfer normally.
892 for (idx = 0; idx < PVR2_I2C_FUNC_CNT; idx++) {
893 hdw->i2c_func[idx] = pvr2_i2c_basic_op;
894 }
895
896#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
897 // If however we're dealing with new hardware, insert some hacks in
898 // the I2C transfer stack to let things work better.
899 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
900 hdw->i2c_func[0x1b] = i2c_hack_wm8775;
901 hdw->i2c_func[0x44] = i2c_hack_cx25840;
902 }
903#endif
904
905 // Configure the adapter and set up everything else related to it.
906 memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap));
907 memcpy(&hdw->i2c_algo,&pvr2_i2c_algo_template,sizeof(hdw->i2c_algo));
908 strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name));
909 hdw->i2c_adap.algo = &hdw->i2c_algo;
910 hdw->i2c_adap.algo_data = hdw;
911 hdw->i2c_pend_mask = 0;
912 hdw->i2c_stale_mask = 0;
913 hdw->i2c_active_mask = 0;
914 INIT_LIST_HEAD(&hdw->i2c_clients);
915 mutex_init(&hdw->i2c_list_lock);
916 hdw->i2c_linked = !0;
917 i2c_add_adapter(&hdw->i2c_adap);
918 if (i2c_scan) do_i2c_scan(hdw);
919}
920
921void pvr2_i2c_core_done(struct pvr2_hdw *hdw)
922{
923 if (hdw->i2c_linked) {
924 i2c_del_adapter(&hdw->i2c_adap);
925 hdw->i2c_linked = 0;
926 }
927}
928
929/*
930 Stuff for Emacs to see, in order to encourage consistent editing style:
931 *** Local Variables: ***
932 *** mode: c ***
933 *** fill-column: 75 ***
934 *** tab-width: 8 ***
935 *** c-basic-offset: 8 ***
936 *** End: ***
937 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
new file mode 100644
index 000000000000..e8af5b0ed3ce
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
@@ -0,0 +1,96 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_I2C_CORE_H
22#define __PVRUSB2_I2C_CORE_H
23
24#include <linux/list.h>
25#include <linux/i2c.h>
26
27struct pvr2_hdw;
28struct pvr2_i2c_client;
29struct pvr2_i2c_handler;
30struct pvr2_i2c_handler_functions;
31struct pvr2_i2c_op;
32struct pvr2_i2c_op_functions;
33
34struct pvr2_i2c_client {
35 struct i2c_client *client;
36 struct pvr2_i2c_handler *handler;
37 struct list_head list;
38 int detected_flag;
39 int recv_enable;
40 unsigned long pend_mask;
41 unsigned long ctl_mask;
42};
43
44struct pvr2_i2c_handler {
45 void *func_data;
46 const struct pvr2_i2c_handler_functions *func_table;
47};
48
49struct pvr2_i2c_handler_functions {
50 void (*detach)(void *);
51 int (*check)(void *);
52 void (*update)(void *);
53 unsigned int (*describe)(void *,char *,unsigned int);
54};
55
56struct pvr2_i2c_op {
57 int (*check)(struct pvr2_hdw *);
58 void (*update)(struct pvr2_hdw *);
59 const char *name;
60};
61
62void pvr2_i2c_core_init(struct pvr2_hdw *);
63void pvr2_i2c_core_done(struct pvr2_hdw *);
64
65int pvr2_i2c_client_cmd(struct pvr2_i2c_client *,unsigned int cmd,void *arg);
66int pvr2_i2c_core_cmd(struct pvr2_hdw *,unsigned int cmd,void *arg);
67
68int pvr2_i2c_core_check_stale(struct pvr2_hdw *);
69void pvr2_i2c_core_sync(struct pvr2_hdw *);
70unsigned int pvr2_i2c_report(struct pvr2_hdw *,char *buf,unsigned int maxlen);
71#define PVR2_I2C_DETAIL_DEBUG 0x0001
72#define PVR2_I2C_DETAIL_HANDLER 0x0002
73#define PVR2_I2C_DETAIL_CTLMASK 0x0004
74#define PVR2_I2C_DETAIL_ALL (\
75 PVR2_I2C_DETAIL_DEBUG |\
76 PVR2_I2C_DETAIL_HANDLER |\
77 PVR2_I2C_DETAIL_CTLMASK)
78unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *,
79 unsigned int detail_mask,
80 char *buf,unsigned int maxlen);
81
82void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *);
83const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx);
84
85#endif /* __PVRUSB2_I2C_CORE_H */
86
87
88/*
89 Stuff for Emacs to see, in order to encourage consistent editing style:
90 *** Local Variables: ***
91 *** mode: c ***
92 *** fill-column: 75 ***
93 *** tab-width: 8 ***
94 *** c-basic-offset: 8 ***
95 *** End: ***
96 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
new file mode 100644
index 000000000000..a984c91f571c
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -0,0 +1,695 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include "pvrusb2-io.h"
23#include "pvrusb2-debug.h"
24#include <linux/errno.h>
25#include <linux/string.h>
26#include <linux/slab.h>
27#include <linux/mutex.h>
28
29#define BUFFER_SIG 0x47653271
30
31// #define SANITY_CHECK_BUFFERS
32
33
34#ifdef SANITY_CHECK_BUFFERS
35#define BUFFER_CHECK(bp) do { \
36 if ((bp)->signature != BUFFER_SIG) { \
37 pvr2_trace(PVR2_TRACE_ERROR_LEGS, \
38 "Buffer %p is bad at %s:%d", \
39 (bp),__FILE__,__LINE__); \
40 pvr2_buffer_describe(bp,"BadSig"); \
41 BUG(); \
42 } \
43} while (0)
44#else
45#define BUFFER_CHECK(bp) do {} while(0)
46#endif
47
48struct pvr2_stream {
49 /* Buffers queued for reading */
50 struct list_head queued_list;
51 unsigned int q_count;
52 unsigned int q_bcount;
53 /* Buffers with retrieved data */
54 struct list_head ready_list;
55 unsigned int r_count;
56 unsigned int r_bcount;
57 /* Buffers available for use */
58 struct list_head idle_list;
59 unsigned int i_count;
60 unsigned int i_bcount;
61 /* Pointers to all buffers */
62 struct pvr2_buffer **buffers;
63 /* Array size of buffers */
64 unsigned int buffer_slot_count;
65 /* Total buffers actually in circulation */
66 unsigned int buffer_total_count;
67 /* Designed number of buffers to be in circulation */
68 unsigned int buffer_target_count;
69 /* Executed when ready list become non-empty */
70 pvr2_stream_callback callback_func;
71 void *callback_data;
72 /* Context for transfer endpoint */
73 struct usb_device *dev;
74 int endpoint;
75 /* Overhead for mutex enforcement */
76 spinlock_t list_lock;
77 struct mutex mutex;
78 /* Tracking state for tolerating errors */
79 unsigned int fail_count;
80 unsigned int fail_tolerance;
81};
82
83struct pvr2_buffer {
84 int id;
85 int signature;
86 enum pvr2_buffer_state state;
87 void *ptr; /* Pointer to storage area */
88 unsigned int max_count; /* Size of storage area */
89 unsigned int used_count; /* Amount of valid data in storage area */
90 int status; /* Transfer result status */
91 struct pvr2_stream *stream;
92 struct list_head list_overhead;
93 struct urb *purb;
94};
95
96const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
97{
98 switch (st) {
99 case pvr2_buffer_state_none: return "none";
100 case pvr2_buffer_state_idle: return "idle";
101 case pvr2_buffer_state_queued: return "queued";
102 case pvr2_buffer_state_ready: return "ready";
103 }
104 return "unknown";
105}
106
107void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
108{
109 pvr2_trace(PVR2_TRACE_INFO,
110 "buffer%s%s %p state=%s id=%d status=%d"
111 " stream=%p purb=%p sig=0x%x",
112 (msg ? " " : ""),
113 (msg ? msg : ""),
114 bp,
115 (bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"),
116 (bp ? bp->id : 0),
117 (bp ? bp->status : 0),
118 (bp ? bp->stream : 0),
119 (bp ? bp->purb : 0),
120 (bp ? bp->signature : 0));
121}
122
123static void pvr2_buffer_remove(struct pvr2_buffer *bp)
124{
125 unsigned int *cnt;
126 unsigned int *bcnt;
127 unsigned int ccnt;
128 struct pvr2_stream *sp = bp->stream;
129 switch (bp->state) {
130 case pvr2_buffer_state_idle:
131 cnt = &sp->i_count;
132 bcnt = &sp->i_bcount;
133 ccnt = bp->max_count;
134 break;
135 case pvr2_buffer_state_queued:
136 cnt = &sp->q_count;
137 bcnt = &sp->q_bcount;
138 ccnt = bp->max_count;
139 break;
140 case pvr2_buffer_state_ready:
141 cnt = &sp->r_count;
142 bcnt = &sp->r_bcount;
143 ccnt = bp->used_count;
144 break;
145 default:
146 return;
147 }
148 list_del_init(&bp->list_overhead);
149 (*cnt)--;
150 (*bcnt) -= ccnt;
151 pvr2_trace(PVR2_TRACE_BUF_FLOW,
152 "/*---TRACE_FLOW---*/"
153 " bufferPool %8s dec cap=%07d cnt=%02d",
154 pvr2_buffer_state_decode(bp->state),*bcnt,*cnt);
155 bp->state = pvr2_buffer_state_none;
156}
157
158static void pvr2_buffer_set_none(struct pvr2_buffer *bp)
159{
160 unsigned long irq_flags;
161 struct pvr2_stream *sp;
162 BUFFER_CHECK(bp);
163 sp = bp->stream;
164 pvr2_trace(PVR2_TRACE_BUF_FLOW,
165 "/*---TRACE_FLOW---*/ bufferState %p %6s --> %6s",
166 bp,
167 pvr2_buffer_state_decode(bp->state),
168 pvr2_buffer_state_decode(pvr2_buffer_state_none));
169 spin_lock_irqsave(&sp->list_lock,irq_flags);
170 pvr2_buffer_remove(bp);
171 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
172}
173
174static int pvr2_buffer_set_ready(struct pvr2_buffer *bp)
175{
176 int fl;
177 unsigned long irq_flags;
178 struct pvr2_stream *sp;
179 BUFFER_CHECK(bp);
180 sp = bp->stream;
181 pvr2_trace(PVR2_TRACE_BUF_FLOW,
182 "/*---TRACE_FLOW---*/ bufferState %p %6s --> %6s",
183 bp,
184 pvr2_buffer_state_decode(bp->state),
185 pvr2_buffer_state_decode(pvr2_buffer_state_ready));
186 spin_lock_irqsave(&sp->list_lock,irq_flags);
187 fl = (sp->r_count == 0);
188 pvr2_buffer_remove(bp);
189 list_add_tail(&bp->list_overhead,&sp->ready_list);
190 bp->state = pvr2_buffer_state_ready;
191 (sp->r_count)++;
192 sp->r_bcount += bp->used_count;
193 pvr2_trace(PVR2_TRACE_BUF_FLOW,
194 "/*---TRACE_FLOW---*/"
195 " bufferPool %8s inc cap=%07d cnt=%02d",
196 pvr2_buffer_state_decode(bp->state),
197 sp->r_bcount,sp->r_count);
198 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
199 return fl;
200}
201
202static void pvr2_buffer_set_idle(struct pvr2_buffer *bp)
203{
204 unsigned long irq_flags;
205 struct pvr2_stream *sp;
206 BUFFER_CHECK(bp);
207 sp = bp->stream;
208 pvr2_trace(PVR2_TRACE_BUF_FLOW,
209 "/*---TRACE_FLOW---*/ bufferState %p %6s --> %6s",
210 bp,
211 pvr2_buffer_state_decode(bp->state),
212 pvr2_buffer_state_decode(pvr2_buffer_state_idle));
213 spin_lock_irqsave(&sp->list_lock,irq_flags);
214 pvr2_buffer_remove(bp);
215 list_add_tail(&bp->list_overhead,&sp->idle_list);
216 bp->state = pvr2_buffer_state_idle;
217 (sp->i_count)++;
218 sp->i_bcount += bp->max_count;
219 pvr2_trace(PVR2_TRACE_BUF_FLOW,
220 "/*---TRACE_FLOW---*/"
221 " bufferPool %8s inc cap=%07d cnt=%02d",
222 pvr2_buffer_state_decode(bp->state),
223 sp->i_bcount,sp->i_count);
224 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
225}
226
227static void pvr2_buffer_set_queued(struct pvr2_buffer *bp)
228{
229 unsigned long irq_flags;
230 struct pvr2_stream *sp;
231 BUFFER_CHECK(bp);
232 sp = bp->stream;
233 pvr2_trace(PVR2_TRACE_BUF_FLOW,
234 "/*---TRACE_FLOW---*/ bufferState %p %6s --> %6s",
235 bp,
236 pvr2_buffer_state_decode(bp->state),
237 pvr2_buffer_state_decode(pvr2_buffer_state_queued));
238 spin_lock_irqsave(&sp->list_lock,irq_flags);
239 pvr2_buffer_remove(bp);
240 list_add_tail(&bp->list_overhead,&sp->queued_list);
241 bp->state = pvr2_buffer_state_queued;
242 (sp->q_count)++;
243 sp->q_bcount += bp->max_count;
244 pvr2_trace(PVR2_TRACE_BUF_FLOW,
245 "/*---TRACE_FLOW---*/"
246 " bufferPool %8s inc cap=%07d cnt=%02d",
247 pvr2_buffer_state_decode(bp->state),
248 sp->q_bcount,sp->q_count);
249 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
250}
251
252static void pvr2_buffer_wipe(struct pvr2_buffer *bp)
253{
254 if (bp->state == pvr2_buffer_state_queued) {
255 usb_kill_urb(bp->purb);
256 }
257}
258
259static int pvr2_buffer_init(struct pvr2_buffer *bp,
260 struct pvr2_stream *sp,
261 unsigned int id)
262{
263 memset(bp,0,sizeof(*bp));
264 bp->signature = BUFFER_SIG;
265 bp->id = id;
266 pvr2_trace(PVR2_TRACE_BUF_POOL,
267 "/*---TRACE_FLOW---*/ bufferInit %p stream=%p",bp,sp);
268 bp->stream = sp;
269 bp->state = pvr2_buffer_state_none;
270 INIT_LIST_HEAD(&bp->list_overhead);
271 bp->purb = usb_alloc_urb(0,GFP_KERNEL);
272 if (! bp->purb) return -ENOMEM;
273#ifdef SANITY_CHECK_BUFFERS
274 pvr2_buffer_describe(bp,"create");
275#endif
276 return 0;
277}
278
279static void pvr2_buffer_done(struct pvr2_buffer *bp)
280{
281#ifdef SANITY_CHECK_BUFFERS
282 pvr2_buffer_describe(bp,"delete");
283#endif
284 pvr2_buffer_wipe(bp);
285 pvr2_buffer_set_none(bp);
286 bp->signature = 0;
287 bp->stream = 0;
288 if (bp->purb) usb_free_urb(bp->purb);
289 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/"
290 " bufferDone %p",bp);
291}
292
293static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
294{
295 int ret;
296 unsigned int scnt;
297
298 /* Allocate buffers pointer array in multiples of 32 entries */
299 if (cnt == sp->buffer_total_count) return 0;
300
301 pvr2_trace(PVR2_TRACE_BUF_POOL,
302 "/*---TRACE_FLOW---*/ poolResize "
303 " stream=%p cur=%d adj=%+d",
304 sp,
305 sp->buffer_total_count,
306 cnt-sp->buffer_total_count);
307
308 scnt = cnt & ~0x1f;
309 if (cnt > scnt) scnt += 0x20;
310
311 if (cnt > sp->buffer_total_count) {
312 if (scnt > sp->buffer_slot_count) {
313 struct pvr2_buffer **nb;
314 nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL);
315 if (!nb) return -ENOMEM;
316 if (sp->buffer_slot_count) {
317 memcpy(nb,sp->buffers,
318 sp->buffer_slot_count * sizeof(*nb));
319 kfree(sp->buffers);
320 }
321 sp->buffers = nb;
322 sp->buffer_slot_count = scnt;
323 }
324 while (sp->buffer_total_count < cnt) {
325 struct pvr2_buffer *bp;
326 bp = kmalloc(sizeof(*bp),GFP_KERNEL);
327 if (!bp) return -ENOMEM;
328 ret = pvr2_buffer_init(bp,sp,sp->buffer_total_count);
329 if (ret) {
330 kfree(bp);
331 return -ENOMEM;
332 }
333 sp->buffers[sp->buffer_total_count] = bp;
334 (sp->buffer_total_count)++;
335 pvr2_buffer_set_idle(bp);
336 }
337 } else {
338 while (sp->buffer_total_count > cnt) {
339 struct pvr2_buffer *bp;
340 bp = sp->buffers[sp->buffer_total_count - 1];
341 /* Paranoia */
342 sp->buffers[sp->buffer_total_count - 1] = 0;
343 (sp->buffer_total_count)--;
344 pvr2_buffer_done(bp);
345 kfree(bp);
346 }
347 if (scnt < sp->buffer_slot_count) {
348 struct pvr2_buffer **nb = 0;
349 if (scnt) {
350 nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL);
351 if (!nb) return -ENOMEM;
352 memcpy(nb,sp->buffers,scnt * sizeof(*nb));
353 }
354 kfree(sp->buffers);
355 sp->buffers = nb;
356 sp->buffer_slot_count = scnt;
357 }
358 }
359 return 0;
360}
361
362static int pvr2_stream_achieve_buffer_count(struct pvr2_stream *sp)
363{
364 struct pvr2_buffer *bp;
365 unsigned int cnt;
366
367 if (sp->buffer_total_count == sp->buffer_target_count) return 0;
368
369 pvr2_trace(PVR2_TRACE_BUF_POOL,
370 "/*---TRACE_FLOW---*/"
371 " poolCheck stream=%p cur=%d tgt=%d",
372 sp,sp->buffer_total_count,sp->buffer_target_count);
373
374 if (sp->buffer_total_count < sp->buffer_target_count) {
375 return pvr2_stream_buffer_count(sp,sp->buffer_target_count);
376 }
377
378 cnt = 0;
379 while ((sp->buffer_total_count - cnt) > sp->buffer_target_count) {
380 bp = sp->buffers[sp->buffer_total_count - (cnt + 1)];
381 if (bp->state != pvr2_buffer_state_idle) break;
382 cnt++;
383 }
384 if (cnt) {
385 pvr2_stream_buffer_count(sp,sp->buffer_total_count - cnt);
386 }
387
388 return 0;
389}
390
391static void pvr2_stream_internal_flush(struct pvr2_stream *sp)
392{
393 struct list_head *lp;
394 struct pvr2_buffer *bp1;
395 while ((lp = sp->queued_list.next) != &sp->queued_list) {
396 bp1 = list_entry(lp,struct pvr2_buffer,list_overhead);
397 pvr2_buffer_wipe(bp1);
398 /* At this point, we should be guaranteed that no
399 completion callback may happen on this buffer. But it's
400 possible that it might have completed after we noticed
401 it but before we wiped it. So double check its status
402 here first. */
403 if (bp1->state != pvr2_buffer_state_queued) continue;
404 pvr2_buffer_set_idle(bp1);
405 }
406 if (sp->buffer_total_count != sp->buffer_target_count) {
407 pvr2_stream_achieve_buffer_count(sp);
408 }
409}
410
411static void pvr2_stream_init(struct pvr2_stream *sp)
412{
413 spin_lock_init(&sp->list_lock);
414 mutex_init(&sp->mutex);
415 INIT_LIST_HEAD(&sp->queued_list);
416 INIT_LIST_HEAD(&sp->ready_list);
417 INIT_LIST_HEAD(&sp->idle_list);
418}
419
420static void pvr2_stream_done(struct pvr2_stream *sp)
421{
422 mutex_lock(&sp->mutex); do {
423 pvr2_stream_internal_flush(sp);
424 pvr2_stream_buffer_count(sp,0);
425 } while (0); mutex_unlock(&sp->mutex);
426}
427
428static void buffer_complete(struct urb *urb, struct pt_regs *regs)
429{
430 struct pvr2_buffer *bp = urb->context;
431 struct pvr2_stream *sp;
432 unsigned long irq_flags;
433 BUFFER_CHECK(bp);
434 sp = bp->stream;
435 bp->used_count = 0;
436 bp->status = 0;
437 pvr2_trace(PVR2_TRACE_BUF_FLOW,
438 "/*---TRACE_FLOW---*/ bufferComplete %p stat=%d cnt=%d",
439 bp,urb->status,urb->actual_length);
440 spin_lock_irqsave(&sp->list_lock,irq_flags);
441 if ((!(urb->status)) ||
442 (urb->status == -ENOENT) ||
443 (urb->status == -ECONNRESET) ||
444 (urb->status == -ESHUTDOWN)) {
445 bp->used_count = urb->actual_length;
446 if (sp->fail_count) {
447 pvr2_trace(PVR2_TRACE_TOLERANCE,
448 "stream %p transfer ok"
449 " - fail count reset",sp);
450 sp->fail_count = 0;
451 }
452 } else if (sp->fail_count < sp->fail_tolerance) {
453 // We can tolerate this error, because we're below the
454 // threshold...
455 (sp->fail_count)++;
456 pvr2_trace(PVR2_TRACE_TOLERANCE,
457 "stream %p ignoring error %d"
458 " - fail count increased to %u",
459 sp,urb->status,sp->fail_count);
460 } else {
461 bp->status = urb->status;
462 }
463 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
464 pvr2_buffer_set_ready(bp);
465 if (sp && sp->callback_func) {
466 sp->callback_func(sp->callback_data);
467 }
468}
469
470struct pvr2_stream *pvr2_stream_create(void)
471{
472 struct pvr2_stream *sp;
473 sp = kmalloc(sizeof(*sp),GFP_KERNEL);
474 if (!sp) return sp;
475 memset(sp,0,sizeof(*sp));
476 pvr2_trace(PVR2_TRACE_INIT,"pvr2_stream_create: sp=%p",sp);
477 pvr2_stream_init(sp);
478 return sp;
479}
480
481void pvr2_stream_destroy(struct pvr2_stream *sp)
482{
483 if (!sp) return;
484 pvr2_trace(PVR2_TRACE_INIT,"pvr2_stream_destroy: sp=%p",sp);
485 pvr2_stream_done(sp);
486 kfree(sp);
487}
488
489void pvr2_stream_setup(struct pvr2_stream *sp,
490 struct usb_device *dev,
491 int endpoint,
492 unsigned int tolerance)
493{
494 mutex_lock(&sp->mutex); do {
495 pvr2_stream_internal_flush(sp);
496 sp->dev = dev;
497 sp->endpoint = endpoint;
498 sp->fail_tolerance = tolerance;
499 } while(0); mutex_unlock(&sp->mutex);
500}
501
502void pvr2_stream_set_callback(struct pvr2_stream *sp,
503 pvr2_stream_callback func,
504 void *data)
505{
506 unsigned long irq_flags;
507 mutex_lock(&sp->mutex); do {
508 spin_lock_irqsave(&sp->list_lock,irq_flags);
509 sp->callback_data = data;
510 sp->callback_func = func;
511 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
512 } while(0); mutex_unlock(&sp->mutex);
513}
514
515/* Query / set the nominal buffer count */
516int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
517{
518 return sp->buffer_target_count;
519}
520
521int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
522{
523 int ret;
524 if (sp->buffer_target_count == cnt) return 0;
525 mutex_lock(&sp->mutex); do {
526 sp->buffer_target_count = cnt;
527 ret = pvr2_stream_achieve_buffer_count(sp);
528 } while(0); mutex_unlock(&sp->mutex);
529 return ret;
530}
531
532struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp)
533{
534 struct list_head *lp = sp->idle_list.next;
535 if (lp == &sp->idle_list) return 0;
536 return list_entry(lp,struct pvr2_buffer,list_overhead);
537}
538
539struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp)
540{
541 struct list_head *lp = sp->ready_list.next;
542 if (lp == &sp->ready_list) return 0;
543 return list_entry(lp,struct pvr2_buffer,list_overhead);
544}
545
546struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id)
547{
548 if (id < 0) return 0;
549 if (id >= sp->buffer_total_count) return 0;
550 return sp->buffers[id];
551}
552
553int pvr2_stream_get_ready_count(struct pvr2_stream *sp)
554{
555 return sp->r_count;
556}
557
558int pvr2_stream_get_idle_count(struct pvr2_stream *sp)
559{
560 return sp->i_count;
561}
562
563void pvr2_stream_flush(struct pvr2_stream *sp)
564{
565 mutex_lock(&sp->mutex); do {
566 pvr2_stream_internal_flush(sp);
567 } while(0); mutex_unlock(&sp->mutex);
568}
569
570void pvr2_stream_kill(struct pvr2_stream *sp)
571{
572 struct pvr2_buffer *bp;
573 mutex_lock(&sp->mutex); do {
574 pvr2_stream_internal_flush(sp);
575 while ((bp = pvr2_stream_get_ready_buffer(sp)) != 0) {
576 pvr2_buffer_set_idle(bp);
577 }
578 if (sp->buffer_total_count != sp->buffer_target_count) {
579 pvr2_stream_achieve_buffer_count(sp);
580 }
581 } while(0); mutex_unlock(&sp->mutex);
582}
583
584int pvr2_buffer_queue(struct pvr2_buffer *bp)
585{
586#undef SEED_BUFFER
587#ifdef SEED_BUFFER
588 unsigned int idx;
589 unsigned int val;
590#endif
591 int ret = 0;
592 struct pvr2_stream *sp;
593 if (!bp) return -EINVAL;
594 sp = bp->stream;
595 mutex_lock(&sp->mutex); do {
596 pvr2_buffer_wipe(bp);
597 if (!sp->dev) {
598 ret = -EIO;
599 break;
600 }
601 pvr2_buffer_set_queued(bp);
602#ifdef SEED_BUFFER
603 for (idx = 0; idx < (bp->max_count) / 4; idx++) {
604 val = bp->id << 24;
605 val |= idx;
606 ((unsigned int *)(bp->ptr))[idx] = val;
607 }
608#endif
609 bp->status = -EINPROGRESS;
610 usb_fill_bulk_urb(bp->purb, // struct urb *urb
611 sp->dev, // struct usb_device *dev
612 // endpoint (below)
613 usb_rcvbulkpipe(sp->dev,sp->endpoint),
614 bp->ptr, // void *transfer_buffer
615 bp->max_count, // int buffer_length
616 buffer_complete,
617 bp);
618 usb_submit_urb(bp->purb,GFP_KERNEL);
619 } while(0); mutex_unlock(&sp->mutex);
620 return ret;
621}
622
623int pvr2_buffer_idle(struct pvr2_buffer *bp)
624{
625 struct pvr2_stream *sp;
626 if (!bp) return -EINVAL;
627 sp = bp->stream;
628 mutex_lock(&sp->mutex); do {
629 pvr2_buffer_wipe(bp);
630 pvr2_buffer_set_idle(bp);
631 if (sp->buffer_total_count != sp->buffer_target_count) {
632 pvr2_stream_achieve_buffer_count(sp);
633 }
634 } while(0); mutex_unlock(&sp->mutex);
635 return 0;
636}
637
638int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
639{
640 int ret = 0;
641 unsigned long irq_flags;
642 struct pvr2_stream *sp;
643 if (!bp) return -EINVAL;
644 sp = bp->stream;
645 mutex_lock(&sp->mutex); do {
646 spin_lock_irqsave(&sp->list_lock,irq_flags);
647 if (bp->state != pvr2_buffer_state_idle) {
648 ret = -EPERM;
649 } else {
650 bp->ptr = ptr;
651 bp->stream->i_bcount -= bp->max_count;
652 bp->max_count = cnt;
653 bp->stream->i_bcount += bp->max_count;
654 pvr2_trace(PVR2_TRACE_BUF_FLOW,
655 "/*---TRACE_FLOW---*/ bufferPool "
656 " %8s cap cap=%07d cnt=%02d",
657 pvr2_buffer_state_decode(
658 pvr2_buffer_state_idle),
659 bp->stream->i_bcount,bp->stream->i_count);
660 }
661 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
662 } while(0); mutex_unlock(&sp->mutex);
663 return ret;
664}
665
666unsigned int pvr2_buffer_get_count(struct pvr2_buffer *bp)
667{
668 return bp->used_count;
669}
670
671int pvr2_buffer_get_status(struct pvr2_buffer *bp)
672{
673 return bp->status;
674}
675
676enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *bp)
677{
678 return bp->state;
679}
680
681int pvr2_buffer_get_id(struct pvr2_buffer *bp)
682{
683 return bp->id;
684}
685
686
687/*
688 Stuff for Emacs to see, in order to encourage consistent editing style:
689 *** Local Variables: ***
690 *** mode: c ***
691 *** fill-column: 75 ***
692 *** tab-width: 8 ***
693 *** c-basic-offset: 8 ***
694 *** End: ***
695 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.h b/drivers/media/video/pvrusb2/pvrusb2-io.h
new file mode 100644
index 000000000000..65e11385b2b3
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.h
@@ -0,0 +1,102 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_IO_H
22#define __PVRUSB2_IO_H
23
24#include <linux/usb.h>
25#include <linux/list.h>
26
27typedef void (*pvr2_stream_callback)(void *);
28
29enum pvr2_buffer_state {
30 pvr2_buffer_state_none = 0, // Not on any list
31 pvr2_buffer_state_idle = 1, // Buffer is ready to be used again
32 pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
33 pvr2_buffer_state_ready = 3, // Buffer has data available
34};
35
36struct pvr2_stream;
37struct pvr2_buffer;
38
39const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
40
41/* Initialize / tear down stream structure */
42struct pvr2_stream *pvr2_stream_create(void);
43void pvr2_stream_destroy(struct pvr2_stream *);
44void pvr2_stream_setup(struct pvr2_stream *,
45 struct usb_device *dev,int endpoint,
46 unsigned int tolerance);
47void pvr2_stream_set_callback(struct pvr2_stream *,
48 pvr2_stream_callback func,
49 void *data);
50
51/* Query / set the nominal buffer count */
52int pvr2_stream_get_buffer_count(struct pvr2_stream *);
53int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
54
55/* Get a pointer to a buffer that is either idle, ready, or is specified
56 named. */
57struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
58struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
59struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
60
61/* Find out how many buffers are idle or ready */
62int pvr2_stream_get_idle_count(struct pvr2_stream *);
63int pvr2_stream_get_ready_count(struct pvr2_stream *);
64
65/* Kill all pending operations */
66void pvr2_stream_flush(struct pvr2_stream *);
67
68/* Kill all pending buffers and throw away any ready buffers as well */
69void pvr2_stream_kill(struct pvr2_stream *);
70
71/* Set up the actual storage for a buffer */
72int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
73
74/* Find out size of data in the given ready buffer */
75unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
76
77/* Retrieve completion code for given ready buffer */
78int pvr2_buffer_get_status(struct pvr2_buffer *);
79
80/* Retrieve state of given buffer */
81enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *);
82
83/* Retrieve ID of given buffer */
84int pvr2_buffer_get_id(struct pvr2_buffer *);
85
86/* Start reading into given buffer (kill it if needed) */
87int pvr2_buffer_queue(struct pvr2_buffer *);
88
89/* Move buffer back to idle pool (kill it if needed) */
90int pvr2_buffer_idle(struct pvr2_buffer *);
91
92#endif /* __PVRUSB2_IO_H */
93
94/*
95 Stuff for Emacs to see, in order to encourage consistent editing style:
96 *** Local Variables: ***
97 *** mode: c ***
98 *** fill-column: 75 ***
99 *** tab-width: 8 ***
100 *** c-basic-offset: 8 ***
101 *** End: ***
102 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.c b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
new file mode 100644
index 000000000000..49da062e3271
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
@@ -0,0 +1,513 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include "pvrusb2-ioread.h"
23#include "pvrusb2-debug.h"
24#include <linux/errno.h>
25#include <linux/string.h>
26#include <linux/slab.h>
27#include <linux/mutex.h>
28#include <asm/uaccess.h>
29
30#define BUFFER_COUNT 32
31#define BUFFER_SIZE PAGE_ALIGN(0x4000)
32
33struct pvr2_ioread {
34 struct pvr2_stream *stream;
35 char *buffer_storage[BUFFER_COUNT];
36 char *sync_key_ptr;
37 unsigned int sync_key_len;
38 unsigned int sync_buf_offs;
39 unsigned int sync_state;
40 unsigned int sync_trashed_count;
41 int enabled; // Streaming is on
42 int spigot_open; // OK to pass data to client
43 int stream_running; // Passing data to client now
44
45 /* State relevant to current buffer being read */
46 struct pvr2_buffer *c_buf;
47 char *c_data_ptr;
48 unsigned int c_data_len;
49 unsigned int c_data_offs;
50 struct mutex mutex;
51};
52
53static int pvr2_ioread_init(struct pvr2_ioread *cp)
54{
55 unsigned int idx;
56
57 cp->stream = 0;
58 mutex_init(&cp->mutex);
59
60 for (idx = 0; idx < BUFFER_COUNT; idx++) {
61 cp->buffer_storage[idx] = kmalloc(BUFFER_SIZE,GFP_KERNEL);
62 if (!(cp->buffer_storage[idx])) break;
63 }
64
65 if (idx < BUFFER_COUNT) {
66 // An allocation appears to have failed
67 for (idx = 0; idx < BUFFER_COUNT; idx++) {
68 if (!(cp->buffer_storage[idx])) continue;
69 kfree(cp->buffer_storage[idx]);
70 }
71 return -ENOMEM;
72 }
73 return 0;
74}
75
76static void pvr2_ioread_done(struct pvr2_ioread *cp)
77{
78 unsigned int idx;
79
80 pvr2_ioread_setup(cp,0);
81 for (idx = 0; idx < BUFFER_COUNT; idx++) {
82 if (!(cp->buffer_storage[idx])) continue;
83 kfree(cp->buffer_storage[idx]);
84 }
85}
86
87struct pvr2_ioread *pvr2_ioread_create(void)
88{
89 struct pvr2_ioread *cp;
90 cp = kmalloc(sizeof(*cp),GFP_KERNEL);
91 if (!cp) return 0;
92 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_create id=%p",cp);
93 memset(cp,0,sizeof(*cp));
94 if (pvr2_ioread_init(cp) < 0) {
95 kfree(cp);
96 return 0;
97 }
98 return cp;
99}
100
101void pvr2_ioread_destroy(struct pvr2_ioread *cp)
102{
103 if (!cp) return;
104 pvr2_ioread_done(cp);
105 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp);
106 if (cp->sync_key_ptr) {
107 kfree(cp->sync_key_ptr);
108 cp->sync_key_ptr = 0;
109 }
110 kfree(cp);
111}
112
113void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp,
114 const char *sync_key_ptr,
115 unsigned int sync_key_len)
116{
117 if (!cp) return;
118
119 if (!sync_key_ptr) sync_key_len = 0;
120 if ((sync_key_len == cp->sync_key_len) &&
121 ((!sync_key_len) ||
122 (!memcmp(sync_key_ptr,cp->sync_key_ptr,sync_key_len)))) return;
123
124 if (sync_key_len != cp->sync_key_len) {
125 if (cp->sync_key_ptr) {
126 kfree(cp->sync_key_ptr);
127 cp->sync_key_ptr = 0;
128 }
129 cp->sync_key_len = 0;
130 if (sync_key_len) {
131 cp->sync_key_ptr = kmalloc(sync_key_len,GFP_KERNEL);
132 if (cp->sync_key_ptr) {
133 cp->sync_key_len = sync_key_len;
134 }
135 }
136 }
137 if (!cp->sync_key_len) return;
138 memcpy(cp->sync_key_ptr,sync_key_ptr,cp->sync_key_len);
139}
140
141static void pvr2_ioread_stop(struct pvr2_ioread *cp)
142{
143 if (!(cp->enabled)) return;
144 pvr2_trace(PVR2_TRACE_START_STOP,
145 "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp);
146 pvr2_stream_kill(cp->stream);
147 cp->c_buf = 0;
148 cp->c_data_ptr = 0;
149 cp->c_data_len = 0;
150 cp->c_data_offs = 0;
151 cp->enabled = 0;
152 cp->stream_running = 0;
153 cp->spigot_open = 0;
154 if (cp->sync_state) {
155 pvr2_trace(PVR2_TRACE_DATA_FLOW,
156 "/*---TRACE_READ---*/ sync_state <== 0");
157 cp->sync_state = 0;
158 }
159}
160
161static int pvr2_ioread_start(struct pvr2_ioread *cp)
162{
163 int stat;
164 struct pvr2_buffer *bp;
165 if (cp->enabled) return 0;
166 if (!(cp->stream)) return 0;
167 pvr2_trace(PVR2_TRACE_START_STOP,
168 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp);
169 while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != 0) {
170 stat = pvr2_buffer_queue(bp);
171 if (stat < 0) {
172 pvr2_trace(PVR2_TRACE_DATA_FLOW,
173 "/*---TRACE_READ---*/"
174 " pvr2_ioread_start id=%p"
175 " error=%d",
176 cp,stat);
177 pvr2_ioread_stop(cp);
178 return stat;
179 }
180 }
181 cp->enabled = !0;
182 cp->c_buf = 0;
183 cp->c_data_ptr = 0;
184 cp->c_data_len = 0;
185 cp->c_data_offs = 0;
186 cp->stream_running = 0;
187 if (cp->sync_key_len) {
188 pvr2_trace(PVR2_TRACE_DATA_FLOW,
189 "/*---TRACE_READ---*/ sync_state <== 1");
190 cp->sync_state = 1;
191 cp->sync_trashed_count = 0;
192 cp->sync_buf_offs = 0;
193 }
194 cp->spigot_open = 0;
195 return 0;
196}
197
198struct pvr2_stream *pvr2_ioread_get_stream(struct pvr2_ioread *cp)
199{
200 return cp->stream;
201}
202
203int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
204{
205 int ret;
206 unsigned int idx;
207 struct pvr2_buffer *bp;
208
209 mutex_lock(&cp->mutex); do {
210 if (cp->stream) {
211 pvr2_trace(PVR2_TRACE_START_STOP,
212 "/*---TRACE_READ---*/"
213 " pvr2_ioread_setup (tear-down) id=%p",cp);
214 pvr2_ioread_stop(cp);
215 pvr2_stream_kill(cp->stream);
216 pvr2_stream_set_buffer_count(cp->stream,0);
217 cp->stream = 0;
218 }
219 if (sp) {
220 pvr2_trace(PVR2_TRACE_START_STOP,
221 "/*---TRACE_READ---*/"
222 " pvr2_ioread_setup (setup) id=%p",cp);
223 pvr2_stream_kill(sp);
224 ret = pvr2_stream_set_buffer_count(sp,BUFFER_COUNT);
225 if (ret < 0) return ret;
226 for (idx = 0; idx < BUFFER_COUNT; idx++) {
227 bp = pvr2_stream_get_buffer(sp,idx);
228 pvr2_buffer_set_buffer(bp,
229 cp->buffer_storage[idx],
230 BUFFER_SIZE);
231 }
232 cp->stream = sp;
233 }
234 } while (0); mutex_unlock(&cp->mutex);
235
236 return 0;
237}
238
239int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl)
240{
241 int ret = 0;
242 if ((!fl) == (!(cp->enabled))) return ret;
243
244 mutex_lock(&cp->mutex); do {
245 if (fl) {
246 ret = pvr2_ioread_start(cp);
247 } else {
248 pvr2_ioread_stop(cp);
249 }
250 } while (0); mutex_unlock(&cp->mutex);
251 return ret;
252}
253
254int pvr2_ioread_get_enabled(struct pvr2_ioread *cp)
255{
256 return cp->enabled != 0;
257}
258
259int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
260{
261 int stat;
262
263 while (cp->c_data_len <= cp->c_data_offs) {
264 if (cp->c_buf) {
265 // Flush out current buffer first.
266 stat = pvr2_buffer_queue(cp->c_buf);
267 if (stat < 0) {
268 // Streaming error...
269 pvr2_trace(PVR2_TRACE_DATA_FLOW,
270 "/*---TRACE_READ---*/"
271 " pvr2_ioread_read id=%p"
272 " queue_error=%d",
273 cp,stat);
274 pvr2_ioread_stop(cp);
275 return 0;
276 }
277 cp->c_buf = 0;
278 cp->c_data_ptr = 0;
279 cp->c_data_len = 0;
280 cp->c_data_offs = 0;
281 }
282 // Now get a freshly filled buffer.
283 cp->c_buf = pvr2_stream_get_ready_buffer(cp->stream);
284 if (!cp->c_buf) break; // Nothing ready; done.
285 cp->c_data_len = pvr2_buffer_get_count(cp->c_buf);
286 if (!cp->c_data_len) {
287 // Nothing transferred. Was there an error?
288 stat = pvr2_buffer_get_status(cp->c_buf);
289 if (stat < 0) {
290 // Streaming error...
291 pvr2_trace(PVR2_TRACE_DATA_FLOW,
292 "/*---TRACE_READ---*/"
293 " pvr2_ioread_read id=%p"
294 " buffer_error=%d",
295 cp,stat);
296 pvr2_ioread_stop(cp);
297 // Give up.
298 return 0;
299 }
300 // Start over...
301 continue;
302 }
303 cp->c_data_offs = 0;
304 cp->c_data_ptr = cp->buffer_storage[
305 pvr2_buffer_get_id(cp->c_buf)];
306 }
307 return !0;
308}
309
310void pvr2_ioread_filter(struct pvr2_ioread *cp)
311{
312 unsigned int idx;
313 if (!cp->enabled) return;
314 if (cp->sync_state != 1) return;
315
316 // Search the stream for our synchronization key. This is made
317 // complicated by the fact that in order to be honest with
318 // ourselves here we must search across buffer boundaries...
319 mutex_lock(&cp->mutex); while (1) {
320 // Ensure we have a buffer
321 if (!pvr2_ioread_get_buffer(cp)) break;
322 if (!cp->c_data_len) break;
323
324 // Now walk the buffer contents until we match the key or
325 // run out of buffer data.
326 for (idx = cp->c_data_offs; idx < cp->c_data_len; idx++) {
327 if (cp->sync_buf_offs >= cp->sync_key_len) break;
328 if (cp->c_data_ptr[idx] ==
329 cp->sync_key_ptr[cp->sync_buf_offs]) {
330 // Found the next key byte
331 (cp->sync_buf_offs)++;
332 } else {
333 // Whoops, mismatched. Start key over...
334 cp->sync_buf_offs = 0;
335 }
336 }
337
338 // Consume what we've walked through
339 cp->c_data_offs += idx;
340 cp->sync_trashed_count += idx;
341
342 // If we've found the key, then update state and get out.
343 if (cp->sync_buf_offs >= cp->sync_key_len) {
344 cp->sync_trashed_count -= cp->sync_key_len;
345 pvr2_trace(PVR2_TRACE_DATA_FLOW,
346 "/*---TRACE_READ---*/"
347 " sync_state <== 2 (skipped %u bytes)",
348 cp->sync_trashed_count);
349 cp->sync_state = 2;
350 cp->sync_buf_offs = 0;
351 break;
352 }
353
354 if (cp->c_data_offs < cp->c_data_len) {
355 // Sanity check - should NEVER get here
356 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
357 "ERROR: pvr2_ioread filter sync problem"
358 " len=%u offs=%u",
359 cp->c_data_len,cp->c_data_offs);
360 // Get out so we don't get stuck in an infinite
361 // loop.
362 break;
363 }
364
365 continue; // (for clarity)
366 } mutex_unlock(&cp->mutex);
367}
368
369int pvr2_ioread_avail(struct pvr2_ioread *cp)
370{
371 int ret;
372 if (!(cp->enabled)) {
373 // Stream is not enabled; so this is an I/O error
374 return -EIO;
375 }
376
377 if (cp->sync_state == 1) {
378 pvr2_ioread_filter(cp);
379 if (cp->sync_state == 1) return -EAGAIN;
380 }
381
382 ret = 0;
383 if (cp->stream_running) {
384 if (!pvr2_stream_get_ready_count(cp->stream)) {
385 // No data available at all right now.
386 ret = -EAGAIN;
387 }
388 } else {
389 if (pvr2_stream_get_ready_count(cp->stream) < BUFFER_COUNT/2) {
390 // Haven't buffered up enough yet; try again later
391 ret = -EAGAIN;
392 }
393 }
394
395 if ((!(cp->spigot_open)) != (!(ret == 0))) {
396 cp->spigot_open = (ret == 0);
397 pvr2_trace(PVR2_TRACE_DATA_FLOW,
398 "/*---TRACE_READ---*/ data is %s",
399 cp->spigot_open ? "available" : "pending");
400 }
401
402 return ret;
403}
404
405int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
406{
407 unsigned int copied_cnt;
408 unsigned int bcnt;
409 const char *src;
410 int stat;
411 int ret = 0;
412 unsigned int req_cnt = cnt;
413
414 if (!cnt) {
415 pvr2_trace(PVR2_TRACE_TRAP,
416 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p"
417 " ZERO Request? Returning zero.",cp);
418 return 0;
419 }
420
421 stat = pvr2_ioread_avail(cp);
422 if (stat < 0) return stat;
423
424 cp->stream_running = !0;
425
426 mutex_lock(&cp->mutex); do {
427
428 // Suck data out of the buffers and copy to the user
429 copied_cnt = 0;
430 if (!buf) cnt = 0;
431 while (1) {
432 if (!pvr2_ioread_get_buffer(cp)) {
433 ret = -EIO;
434 break;
435 }
436
437 if (!cnt) break;
438
439 if (cp->sync_state == 2) {
440 // We're repeating the sync key data into
441 // the stream.
442 src = cp->sync_key_ptr + cp->sync_buf_offs;
443 bcnt = cp->sync_key_len - cp->sync_buf_offs;
444 } else {
445 // Normal buffer copy
446 src = cp->c_data_ptr + cp->c_data_offs;
447 bcnt = cp->c_data_len - cp->c_data_offs;
448 }
449
450 if (!bcnt) break;
451
452 // Don't run past user's buffer
453 if (bcnt > cnt) bcnt = cnt;
454
455 if (copy_to_user(buf,src,bcnt)) {
456 // User supplied a bad pointer?
457 // Give up - this *will* cause data
458 // to be lost.
459 ret = -EFAULT;
460 break;
461 }
462 cnt -= bcnt;
463 buf += bcnt;
464 copied_cnt += bcnt;
465
466 if (cp->sync_state == 2) {
467 // Update offset inside sync key that we're
468 // repeating back out.
469 cp->sync_buf_offs += bcnt;
470 if (cp->sync_buf_offs >= cp->sync_key_len) {
471 // Consumed entire key; switch mode
472 // to normal.
473 pvr2_trace(PVR2_TRACE_DATA_FLOW,
474 "/*---TRACE_READ---*/"
475 " sync_state <== 0");
476 cp->sync_state = 0;
477 }
478 } else {
479 // Update buffer offset.
480 cp->c_data_offs += bcnt;
481 }
482 }
483
484 } while (0); mutex_unlock(&cp->mutex);
485
486 if (!ret) {
487 if (copied_cnt) {
488 // If anything was copied, return that count
489 ret = copied_cnt;
490 } else {
491 // Nothing copied; suggest to caller that another
492 // attempt should be tried again later
493 ret = -EAGAIN;
494 }
495 }
496
497 pvr2_trace(PVR2_TRACE_DATA_FLOW,
498 "/*---TRACE_READ---*/ pvr2_ioread_read"
499 " id=%p request=%d result=%d",
500 cp,req_cnt,ret);
501 return ret;
502}
503
504
505/*
506 Stuff for Emacs to see, in order to encourage consistent editing style:
507 *** Local Variables: ***
508 *** mode: c ***
509 *** fill-column: 75 ***
510 *** tab-width: 8 ***
511 *** c-basic-offset: 8 ***
512 *** End: ***
513 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.h b/drivers/media/video/pvrusb2/pvrusb2-ioread.h
new file mode 100644
index 000000000000..6b002597f5de
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.h
@@ -0,0 +1,50 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_IOREAD_H
22#define __PVRUSB2_IOREAD_H
23
24#include "pvrusb2-io.h"
25
26struct pvr2_ioread;
27
28struct pvr2_ioread *pvr2_ioread_create(void);
29void pvr2_ioread_destroy(struct pvr2_ioread *);
30int pvr2_ioread_setup(struct pvr2_ioread *,struct pvr2_stream *);
31struct pvr2_stream *pvr2_ioread_get_stream(struct pvr2_ioread *);
32void pvr2_ioread_set_sync_key(struct pvr2_ioread *,
33 const char *sync_key_ptr,
34 unsigned int sync_key_len);
35int pvr2_ioread_set_enabled(struct pvr2_ioread *,int fl);
36int pvr2_ioread_get_enabled(struct pvr2_ioread *);
37int pvr2_ioread_read(struct pvr2_ioread *,void __user *buf,unsigned int cnt);
38int pvr2_ioread_avail(struct pvr2_ioread *);
39
40#endif /* __PVRUSB2_IOREAD_H */
41
42/*
43 Stuff for Emacs to see, in order to encourage consistent editing style:
44 *** Local Variables: ***
45 *** mode: c ***
46 *** fill-column: 75 ***
47 *** tab-width: 8 ***
48 *** c-basic-offset: 8 ***
49 *** End: ***
50 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-main.c b/drivers/media/video/pvrusb2/pvrusb2-main.c
new file mode 100644
index 000000000000..b95248274ed0
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-main.c
@@ -0,0 +1,172 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/config.h>
24#include <linux/kernel.h>
25#include <linux/errno.h>
26#include <linux/slab.h>
27#include <linux/module.h>
28#include <linux/moduleparam.h>
29#include <linux/smp_lock.h>
30#include <linux/usb.h>
31#include <linux/videodev2.h>
32
33#include "pvrusb2-hdw.h"
34#include "pvrusb2-context.h"
35#include "pvrusb2-debug.h"
36#include "pvrusb2-v4l2.h"
37#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
38#include "pvrusb2-sysfs.h"
39#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
40
41#define DRIVER_AUTHOR "Mike Isely <isely@pobox.com>"
42#define DRIVER_DESC "Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner"
43#define DRIVER_VERSION "V4L in-tree version"
44
45#define DEFAULT_DEBUG_MASK (PVR2_TRACE_ERROR_LEGS| \
46 PVR2_TRACE_INFO| \
47 PVR2_TRACE_TOLERANCE| \
48 PVR2_TRACE_TRAP| \
49 0)
50
51int pvrusb2_debug = DEFAULT_DEBUG_MASK;
52
53module_param_named(debug,pvrusb2_debug,int,S_IRUGO|S_IWUSR);
54MODULE_PARM_DESC(debug, "Debug trace mask");
55
56#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
57static struct pvr2_sysfs_class *class_ptr = 0;
58#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
59
60static void pvr_setup_attach(struct pvr2_context *pvr)
61{
62 /* Create association with v4l layer */
63 pvr2_v4l2_create(pvr);
64#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
65 pvr2_sysfs_create(pvr,class_ptr);
66#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
67}
68
69static int pvr_probe(struct usb_interface *intf,
70 const struct usb_device_id *devid)
71{
72 struct pvr2_context *pvr;
73
74 /* Create underlying hardware interface */
75 pvr = pvr2_context_create(intf,devid,pvr_setup_attach);
76 if (!pvr) {
77 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
78 "Failed to create hdw handler");
79 return -ENOMEM;
80 }
81
82 pvr2_trace(PVR2_TRACE_INIT,"pvr_probe(pvr=%p)",pvr);
83
84 usb_set_intfdata(intf, pvr);
85
86 return 0;
87}
88
89/*
90 * pvr_disconnect()
91 *
92 */
93static void pvr_disconnect(struct usb_interface *intf)
94{
95 struct pvr2_context *pvr = usb_get_intfdata(intf);
96
97 pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) BEGIN",pvr);
98
99 usb_set_intfdata (intf, NULL);
100 pvr2_context_disconnect(pvr);
101
102 pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) DONE",pvr);
103
104}
105
106static struct usb_driver pvr_driver = {
107 name: "pvrusb2",
108 id_table: pvr2_device_table,
109 probe: pvr_probe,
110 disconnect: pvr_disconnect
111};
112
113/*
114 * pvr_init() / pvr_exit()
115 *
116 * This code is run to initialize/exit the driver.
117 *
118 */
119static int __init pvr_init(void)
120{
121 int ret;
122
123 pvr2_trace(PVR2_TRACE_INIT,"pvr_init");
124
125#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
126 class_ptr = pvr2_sysfs_class_create();
127#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
128
129 ret = usb_register(&pvr_driver);
130
131 if (ret == 0)
132 info(DRIVER_DESC " : " DRIVER_VERSION);
133 if (pvrusb2_debug) info("Debug mask is %d (0x%x)",
134 pvrusb2_debug,pvrusb2_debug);
135
136 return ret;
137}
138
139static void __exit pvr_exit(void)
140{
141
142 pvr2_trace(PVR2_TRACE_INIT,"pvr_exit");
143
144#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
145 pvr2_sysfs_class_destroy(class_ptr);
146#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
147
148 usb_deregister(&pvr_driver);
149}
150
151module_init(pvr_init);
152module_exit(pvr_exit);
153
154/* Mike Isely <mcisely@pobox.com> 11-Mar-2006: See pvrusb2-hdw.c for
155 MODULE_DEVICE_TABLE(). We have to declare that attribute there
156 because that's where the device table actually is now and it seems
157 that certain gcc configurations get angry if MODULE_DEVICE_TABLE()
158 is used on what ends up being an external symbol. */
159MODULE_AUTHOR(DRIVER_AUTHOR);
160MODULE_DESCRIPTION(DRIVER_DESC);
161MODULE_LICENSE("GPL");
162
163
164/*
165 Stuff for Emacs to see, in order to encourage consistent editing style:
166 *** Local Variables: ***
167 *** mode: c ***
168 *** fill-column: 70 ***
169 *** tab-width: 8 ***
170 *** c-basic-offset: 8 ***
171 *** End: ***
172 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-std.c b/drivers/media/video/pvrusb2/pvrusb2-std.c
new file mode 100644
index 000000000000..134063693643
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-std.c
@@ -0,0 +1,408 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include "pvrusb2-std.h"
23#include "pvrusb2-debug.h"
24#include <asm/string.h>
25#include <linux/slab.h>
26
27struct std_name {
28 const char *name;
29 v4l2_std_id id;
30};
31
32
33#define CSTD_PAL \
34 (V4L2_STD_PAL_B| \
35 V4L2_STD_PAL_B1| \
36 V4L2_STD_PAL_G| \
37 V4L2_STD_PAL_H| \
38 V4L2_STD_PAL_I| \
39 V4L2_STD_PAL_D| \
40 V4L2_STD_PAL_D1| \
41 V4L2_STD_PAL_K| \
42 V4L2_STD_PAL_M| \
43 V4L2_STD_PAL_N| \
44 V4L2_STD_PAL_Nc| \
45 V4L2_STD_PAL_60)
46
47#define CSTD_NTSC \
48 (V4L2_STD_NTSC_M| \
49 V4L2_STD_NTSC_M_JP| \
50 V4L2_STD_NTSC_M_KR| \
51 V4L2_STD_NTSC_443)
52
53#define CSTD_SECAM \
54 (V4L2_STD_SECAM_B| \
55 V4L2_STD_SECAM_D| \
56 V4L2_STD_SECAM_G| \
57 V4L2_STD_SECAM_H| \
58 V4L2_STD_SECAM_K| \
59 V4L2_STD_SECAM_K1| \
60 V4L2_STD_SECAM_L| \
61 V4L2_STD_SECAM_LC)
62
63#define TSTD_B (V4L2_STD_PAL_B|V4L2_STD_SECAM_B)
64#define TSTD_B1 (V4L2_STD_PAL_B1)
65#define TSTD_D (V4L2_STD_PAL_D|V4L2_STD_SECAM_D)
66#define TSTD_D1 (V4L2_STD_PAL_D1)
67#define TSTD_G (V4L2_STD_PAL_G|V4L2_STD_SECAM_G)
68#define TSTD_H (V4L2_STD_PAL_H|V4L2_STD_SECAM_H)
69#define TSTD_I (V4L2_STD_PAL_I)
70#define TSTD_K (V4L2_STD_PAL_K|V4L2_STD_SECAM_K)
71#define TSTD_K1 (V4L2_STD_SECAM_K1)
72#define TSTD_L (V4L2_STD_SECAM_L)
73#define TSTD_M (V4L2_STD_PAL_M|V4L2_STD_NTSC_M)
74#define TSTD_N (V4L2_STD_PAL_N)
75#define TSTD_Nc (V4L2_STD_PAL_Nc)
76#define TSTD_60 (V4L2_STD_PAL_60)
77
78#define CSTD_ALL (CSTD_PAL|CSTD_NTSC|CSTD_SECAM)
79
80/* Mapping of standard bits to color system */
81const static struct std_name std_groups[] = {
82 {"PAL",CSTD_PAL},
83 {"NTSC",CSTD_NTSC},
84 {"SECAM",CSTD_SECAM},
85};
86
87/* Mapping of standard bits to modulation system */
88const static struct std_name std_items[] = {
89 {"B",TSTD_B},
90 {"B1",TSTD_B1},
91 {"D",TSTD_D},
92 {"D1",TSTD_D1},
93 {"G",TSTD_G},
94 {"H",TSTD_H},
95 {"I",TSTD_I},
96 {"K",TSTD_K},
97 {"K1",TSTD_K1},
98 {"L",TSTD_L},
99 {"LC",V4L2_STD_SECAM_LC},
100 {"M",TSTD_M},
101 {"Mj",V4L2_STD_NTSC_M_JP},
102 {"443",V4L2_STD_NTSC_443},
103 {"Mk",V4L2_STD_NTSC_M_KR},
104 {"N",TSTD_N},
105 {"Nc",TSTD_Nc},
106 {"60",TSTD_60},
107};
108
109
110// Search an array of std_name structures and return a pointer to the
111// element with the matching name.
112static const struct std_name *find_std_name(const struct std_name *arrPtr,
113 unsigned int arrSize,
114 const char *bufPtr,
115 unsigned int bufSize)
116{
117 unsigned int idx;
118 const struct std_name *p;
119 for (idx = 0; idx < arrSize; idx++) {
120 p = arrPtr + idx;
121 if (strlen(p->name) != bufSize) continue;
122 if (!memcmp(bufPtr,p->name,bufSize)) return p;
123 }
124 return 0;
125}
126
127
128int pvr2_std_str_to_id(v4l2_std_id *idPtr,const char *bufPtr,
129 unsigned int bufSize)
130{
131 v4l2_std_id id = 0;
132 v4l2_std_id cmsk = 0;
133 v4l2_std_id t;
134 int mMode = 0;
135 unsigned int cnt;
136 char ch;
137 const struct std_name *sp;
138
139 while (bufSize) {
140 if (!mMode) {
141 cnt = 0;
142 while ((cnt < bufSize) && (bufPtr[cnt] != '-')) cnt++;
143 if (cnt >= bufSize) return 0; // No more characters
144 sp = find_std_name(
145 std_groups,
146 sizeof(std_groups)/sizeof(std_groups[0]),
147 bufPtr,cnt);
148 if (!sp) return 0; // Illegal color system name
149 cnt++;
150 bufPtr += cnt;
151 bufSize -= cnt;
152 mMode = !0;
153 cmsk = sp->id;
154 continue;
155 }
156 cnt = 0;
157 while (cnt < bufSize) {
158 ch = bufPtr[cnt];
159 if (ch == ';') {
160 mMode = 0;
161 break;
162 }
163 if (ch == '/') break;
164 cnt++;
165 }
166 sp = find_std_name(std_items,
167 sizeof(std_items)/sizeof(std_items[0]),
168 bufPtr,cnt);
169 if (!sp) return 0; // Illegal modulation system ID
170 t = sp->id & cmsk;
171 if (!t) return 0; // Specific color + modulation system illegal
172 id |= t;
173 if (cnt < bufSize) cnt++;
174 bufPtr += cnt;
175 bufSize -= cnt;
176 }
177
178 if (idPtr) *idPtr = id;
179 return !0;
180}
181
182
183unsigned int pvr2_std_id_to_str(char *bufPtr, unsigned int bufSize,
184 v4l2_std_id id)
185{
186 unsigned int idx1,idx2;
187 const struct std_name *ip,*gp;
188 int gfl,cfl;
189 unsigned int c1,c2;
190 cfl = 0;
191 c1 = 0;
192 for (idx1 = 0;
193 idx1 < sizeof(std_groups)/sizeof(std_groups[0]);
194 idx1++) {
195 gp = std_groups + idx1;
196 gfl = 0;
197 for (idx2 = 0;
198 idx2 < sizeof(std_items)/sizeof(std_items[0]);
199 idx2++) {
200 ip = std_items + idx2;
201 if (!(gp->id & ip->id & id)) continue;
202 if (!gfl) {
203 if (cfl) {
204 c2 = scnprintf(bufPtr,bufSize,";");
205 c1 += c2;
206 bufSize -= c2;
207 bufPtr += c2;
208 }
209 cfl = !0;
210 c2 = scnprintf(bufPtr,bufSize,
211 "%s-",gp->name);
212 gfl = !0;
213 } else {
214 c2 = scnprintf(bufPtr,bufSize,"/");
215 }
216 c1 += c2;
217 bufSize -= c2;
218 bufPtr += c2;
219 c2 = scnprintf(bufPtr,bufSize,
220 ip->name);
221 c1 += c2;
222 bufSize -= c2;
223 bufPtr += c2;
224 }
225 }
226 return c1;
227}
228
229
230// Template data for possible enumerated video standards. Here we group
231// standards which share common frame rates and resolution.
232static struct v4l2_standard generic_standards[] = {
233 {
234 .id = (TSTD_B|TSTD_B1|
235 TSTD_D|TSTD_D1|
236 TSTD_G|
237 TSTD_H|
238 TSTD_I|
239 TSTD_K|TSTD_K1|
240 TSTD_L|
241 V4L2_STD_SECAM_LC |
242 TSTD_N|TSTD_Nc),
243 .frameperiod =
244 {
245 .numerator = 1,
246 .denominator= 25
247 },
248 .framelines = 625,
249 .reserved = {0,0,0,0}
250 }, {
251 .id = (TSTD_M|
252 V4L2_STD_NTSC_M_JP|
253 V4L2_STD_NTSC_M_KR),
254 .frameperiod =
255 {
256 .numerator = 1001,
257 .denominator= 30000
258 },
259 .framelines = 525,
260 .reserved = {0,0,0,0}
261 }, { // This is a total wild guess
262 .id = (TSTD_60),
263 .frameperiod =
264 {
265 .numerator = 1001,
266 .denominator= 30000
267 },
268 .framelines = 525,
269 .reserved = {0,0,0,0}
270 }, { // This is total wild guess
271 .id = V4L2_STD_NTSC_443,
272 .frameperiod =
273 {
274 .numerator = 1001,
275 .denominator= 30000
276 },
277 .framelines = 525,
278 .reserved = {0,0,0,0}
279 }
280};
281
282#define generic_standards_cnt (sizeof(generic_standards)/sizeof(generic_standards[0]))
283
284static struct v4l2_standard *match_std(v4l2_std_id id)
285{
286 unsigned int idx;
287 for (idx = 0; idx < generic_standards_cnt; idx++) {
288 if (generic_standards[idx].id & id) {
289 return generic_standards + idx;
290 }
291 }
292 return 0;
293}
294
295static int pvr2_std_fill(struct v4l2_standard *std,v4l2_std_id id)
296{
297 struct v4l2_standard *template;
298 int idx;
299 unsigned int bcnt;
300 template = match_std(id);
301 if (!template) return 0;
302 idx = std->index;
303 memcpy(std,template,sizeof(*template));
304 std->index = idx;
305 std->id = id;
306 bcnt = pvr2_std_id_to_str(std->name,sizeof(std->name)-1,id);
307 std->name[bcnt] = 0;
308 pvr2_trace(PVR2_TRACE_INIT,"Set up standard idx=%u name=%s",
309 std->index,std->name);
310 return !0;
311}
312
313/* These are special cases of combined standards that we should enumerate
314 separately if the component pieces are present. */
315static v4l2_std_id std_mixes[] = {
316 V4L2_STD_PAL_B | V4L2_STD_PAL_G,
317 V4L2_STD_PAL_D | V4L2_STD_PAL_K,
318 V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
319 V4L2_STD_SECAM_D | V4L2_STD_SECAM_K,
320};
321
322struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
323 v4l2_std_id id)
324{
325 unsigned int std_cnt = 0;
326 unsigned int idx,bcnt,idx2;
327 v4l2_std_id idmsk,cmsk,fmsk;
328 struct v4l2_standard *stddefs;
329
330 if (pvrusb2_debug & PVR2_TRACE_INIT) {
331 char buf[50];
332 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),id);
333 pvr2_trace(
334 PVR2_TRACE_INIT,"Mapping standards mask=0x%x (%.*s)",
335 (int)id,bcnt,buf);
336 }
337
338 *countptr = 0;
339 std_cnt = 0;
340 fmsk = 0;
341 for (idmsk = 1, cmsk = id; cmsk; idmsk <<= 1) {
342 if (!(idmsk & cmsk)) continue;
343 cmsk &= ~idmsk;
344 if (match_std(idmsk)) {
345 std_cnt++;
346 continue;
347 }
348 fmsk |= idmsk;
349 }
350
351 for (idx2 = 0; idx2 < sizeof(std_mixes)/sizeof(std_mixes[0]); idx2++) {
352 if ((id & std_mixes[idx2]) == std_mixes[idx2]) std_cnt++;
353 }
354
355 if (fmsk) {
356 char buf[50];
357 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),fmsk);
358 pvr2_trace(
359 PVR2_TRACE_ERROR_LEGS,
360 "WARNING:"
361 " Failed to classify the following standard(s): %.*s",
362 bcnt,buf);
363 }
364
365 pvr2_trace(PVR2_TRACE_INIT,"Setting up %u unique standard(s)",
366 std_cnt);
367 if (!std_cnt) return 0; // paranoia
368
369 stddefs = kmalloc(sizeof(struct v4l2_standard) * std_cnt,
370 GFP_KERNEL);
371 memset(stddefs,0,sizeof(struct v4l2_standard) * std_cnt);
372 for (idx = 0; idx < std_cnt; idx++) stddefs[idx].index = idx;
373
374 idx = 0;
375
376 /* Enumerate potential special cases */
377 for (idx2 = 0; ((idx2 < sizeof(std_mixes)/sizeof(std_mixes[0])) &&
378 (idx < std_cnt)); idx2++) {
379 if (!(id & std_mixes[idx2])) continue;
380 if (pvr2_std_fill(stddefs+idx,std_mixes[idx2])) idx++;
381 }
382 /* Now enumerate individual pieces */
383 for (idmsk = 1, cmsk = id; cmsk && (idx < std_cnt); idmsk <<= 1) {
384 if (!(idmsk & cmsk)) continue;
385 cmsk &= ~idmsk;
386 if (!pvr2_std_fill(stddefs+idx,idmsk)) continue;
387 idx++;
388 }
389
390 *countptr = std_cnt;
391 return stddefs;
392}
393
394v4l2_std_id pvr2_std_get_usable(void)
395{
396 return CSTD_ALL;
397}
398
399
400/*
401 Stuff for Emacs to see, in order to encourage consistent editing style:
402 *** Local Variables: ***
403 *** mode: c ***
404 *** fill-column: 75 ***
405 *** tab-width: 8 ***
406 *** c-basic-offset: 8 ***
407 *** End: ***
408 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-std.h b/drivers/media/video/pvrusb2/pvrusb2-std.h
new file mode 100644
index 000000000000..07c399375341
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-std.h
@@ -0,0 +1,60 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_STD_H
22#define __PVRUSB2_STD_H
23
24#include <linux/videodev2.h>
25
26// Convert string describing one or more video standards into a mask of V4L
27// standard bits. Return true if conversion succeeds otherwise return
28// false. String is expected to be of the form: C1-x/y;C2-a/b where C1 and
29// C2 are color system names (e.g. "PAL", "NTSC") and x, y, a, and b are
30// modulation schemes (e.g. "M", "B", "G", etc).
31int pvr2_std_str_to_id(v4l2_std_id *idPtr,const char *bufPtr,
32 unsigned int bufSize);
33
34// Convert any arbitrary set of video standard bits into an unambiguous
35// readable string. Return value is the number of bytes consumed in the
36// buffer. The formatted string is of a form that can be parsed by our
37// sibling std_std_to_id() function.
38unsigned int pvr2_std_id_to_str(char *bufPtr, unsigned int bufSize,
39 v4l2_std_id id);
40
41// Create an array of suitable v4l2_standard structures given a bit mask of
42// video standards to support. The array is allocated from the heap, and
43// the number of elements is returned in the first argument.
44struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
45 v4l2_std_id id);
46
47// Return mask of which video standard bits are valid
48v4l2_std_id pvr2_std_get_usable(void);
49
50#endif /* __PVRUSB2_STD_H */
51
52/*
53 Stuff for Emacs to see, in order to encourage consistent editing style:
54 *** Local Variables: ***
55 *** mode: c ***
56 *** fill-column: 75 ***
57 *** tab-width: 8 ***
58 *** c-basic-offset: 8 ***
59 *** End: ***
60 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
new file mode 100644
index 000000000000..c6e6523d74b4
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -0,0 +1,865 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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
22#include <linux/config.h>
23#include <linux/string.h>
24#include <linux/slab.h>
25#include <asm/semaphore.h>
26#include "pvrusb2-sysfs.h"
27#include "pvrusb2-hdw.h"
28#include "pvrusb2-debug.h"
29#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
30#include "pvrusb2-debugifc.h"
31#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
32
33#define pvr2_sysfs_trace(...) pvr2_trace(PVR2_TRACE_SYSFS,__VA_ARGS__)
34
35struct pvr2_sysfs {
36 struct pvr2_channel channel;
37 struct class_device *class_dev;
38#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
39 struct pvr2_sysfs_debugifc *debugifc;
40#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
41 struct pvr2_sysfs_ctl_item *item_first;
42 struct pvr2_sysfs_ctl_item *item_last;
43 struct sysfs_ops kops;
44 struct kobj_type ktype;
45 struct class_device_attribute attr_v4l_minor_number;
46 struct class_device_attribute attr_unit_number;
47};
48
49#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
50struct pvr2_sysfs_debugifc {
51 struct class_device_attribute attr_debugcmd;
52 struct class_device_attribute attr_debuginfo;
53};
54#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
55
56struct pvr2_sysfs_ctl_item {
57 struct class_device_attribute attr_name;
58 struct class_device_attribute attr_type;
59 struct class_device_attribute attr_min;
60 struct class_device_attribute attr_max;
61 struct class_device_attribute attr_enum;
62 struct class_device_attribute attr_bits;
63 struct class_device_attribute attr_val;
64 struct class_device_attribute attr_custom;
65 struct pvr2_ctrl *cptr;
66 struct pvr2_sysfs *chptr;
67 struct pvr2_sysfs_ctl_item *item_next;
68 struct attribute *attr_gen[7];
69 struct attribute_group grp;
70 char name[80];
71};
72
73struct pvr2_sysfs_class {
74 struct class class;
75};
76
77static ssize_t show_name(int id,struct class_device *class_dev,char *buf)
78{
79 struct pvr2_ctrl *cptr;
80 struct pvr2_sysfs *sfp;
81 const char *name;
82
83 sfp = (struct pvr2_sysfs *)class_dev->class_data;
84 if (!sfp) return -EINVAL;
85 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
86 if (!cptr) return -EINVAL;
87
88 name = pvr2_ctrl_get_desc(cptr);
89 pvr2_sysfs_trace("pvr2_sysfs(%p) show_name(cid=%d) is %s",sfp,id,name);
90
91 if (!name) return -EINVAL;
92
93 return scnprintf(buf,PAGE_SIZE,"%s\n",name);
94}
95
96static ssize_t show_type(int id,struct class_device *class_dev,char *buf)
97{
98 struct pvr2_ctrl *cptr;
99 struct pvr2_sysfs *sfp;
100 const char *name;
101 enum pvr2_ctl_type tp;
102
103 sfp = (struct pvr2_sysfs *)class_dev->class_data;
104 if (!sfp) return -EINVAL;
105 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
106 if (!cptr) return -EINVAL;
107
108 tp = pvr2_ctrl_get_type(cptr);
109 switch (tp) {
110 case pvr2_ctl_int: name = "integer"; break;
111 case pvr2_ctl_enum: name = "enum"; break;
112 case pvr2_ctl_bitmask: name = "bitmask"; break;
113 case pvr2_ctl_bool: name = "boolean"; break;
114 default: name = "?"; break;
115 }
116 pvr2_sysfs_trace("pvr2_sysfs(%p) show_type(cid=%d) is %s",sfp,id,name);
117
118 if (!name) return -EINVAL;
119
120 return scnprintf(buf,PAGE_SIZE,"%s\n",name);
121}
122
123static ssize_t show_min(int id,struct class_device *class_dev,char *buf)
124{
125 struct pvr2_ctrl *cptr;
126 struct pvr2_sysfs *sfp;
127 long val;
128
129 sfp = (struct pvr2_sysfs *)class_dev->class_data;
130 if (!sfp) return -EINVAL;
131 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
132 if (!cptr) return -EINVAL;
133 val = pvr2_ctrl_get_min(cptr);
134
135 pvr2_sysfs_trace("pvr2_sysfs(%p) show_min(cid=%d) is %ld",sfp,id,val);
136
137 return scnprintf(buf,PAGE_SIZE,"%ld\n",val);
138}
139
140static ssize_t show_max(int id,struct class_device *class_dev,char *buf)
141{
142 struct pvr2_ctrl *cptr;
143 struct pvr2_sysfs *sfp;
144 long val;
145
146 sfp = (struct pvr2_sysfs *)class_dev->class_data;
147 if (!sfp) return -EINVAL;
148 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
149 if (!cptr) return -EINVAL;
150 val = pvr2_ctrl_get_max(cptr);
151
152 pvr2_sysfs_trace("pvr2_sysfs(%p) show_max(cid=%d) is %ld",sfp,id,val);
153
154 return scnprintf(buf,PAGE_SIZE,"%ld\n",val);
155}
156
157static ssize_t show_val_norm(int id,struct class_device *class_dev,char *buf)
158{
159 struct pvr2_ctrl *cptr;
160 struct pvr2_sysfs *sfp;
161 int val,ret;
162 unsigned int cnt = 0;
163
164 sfp = (struct pvr2_sysfs *)class_dev->class_data;
165 if (!sfp) return -EINVAL;
166 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
167 if (!cptr) return -EINVAL;
168
169 ret = pvr2_ctrl_get_value(cptr,&val);
170 if (ret < 0) return ret;
171
172 ret = pvr2_ctrl_value_to_sym(cptr,~0,val,
173 buf,PAGE_SIZE-1,&cnt);
174
175 pvr2_sysfs_trace("pvr2_sysfs(%p) show_val_norm(cid=%d) is %.*s (%d)",
176 sfp,id,cnt,buf,val);
177 buf[cnt] = '\n';
178 return cnt+1;
179}
180
181static ssize_t show_val_custom(int id,struct class_device *class_dev,char *buf)
182{
183 struct pvr2_ctrl *cptr;
184 struct pvr2_sysfs *sfp;
185 int val,ret;
186 unsigned int cnt = 0;
187
188 sfp = (struct pvr2_sysfs *)class_dev->class_data;
189 if (!sfp) return -EINVAL;
190 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
191 if (!cptr) return -EINVAL;
192
193 ret = pvr2_ctrl_get_value(cptr,&val);
194 if (ret < 0) return ret;
195
196 ret = pvr2_ctrl_custom_value_to_sym(cptr,~0,val,
197 buf,PAGE_SIZE-1,&cnt);
198
199 pvr2_sysfs_trace("pvr2_sysfs(%p) show_val_custom(cid=%d) is %.*s (%d)",
200 sfp,id,cnt,buf,val);
201 buf[cnt] = '\n';
202 return cnt+1;
203}
204
205static ssize_t show_enum(int id,struct class_device *class_dev,char *buf)
206{
207 struct pvr2_ctrl *cptr;
208 struct pvr2_sysfs *sfp;
209 long val;
210 unsigned int bcnt,ccnt,ecnt;
211
212 sfp = (struct pvr2_sysfs *)class_dev->class_data;
213 if (!sfp) return -EINVAL;
214 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
215 if (!cptr) return -EINVAL;
216 ecnt = pvr2_ctrl_get_cnt(cptr);
217 bcnt = 0;
218 for (val = 0; val < ecnt; val++) {
219 pvr2_ctrl_get_valname(cptr,val,buf+bcnt,PAGE_SIZE-bcnt,&ccnt);
220 if (!ccnt) continue;
221 bcnt += ccnt;
222 if (bcnt >= PAGE_SIZE) break;
223 buf[bcnt] = '\n';
224 bcnt++;
225 }
226 pvr2_sysfs_trace("pvr2_sysfs(%p) show_enum(cid=%d)",sfp,id);
227 return bcnt;
228}
229
230static ssize_t show_bits(int id,struct class_device *class_dev,char *buf)
231{
232 struct pvr2_ctrl *cptr;
233 struct pvr2_sysfs *sfp;
234 int valid_bits,msk;
235 unsigned int bcnt,ccnt;
236
237 sfp = (struct pvr2_sysfs *)class_dev->class_data;
238 if (!sfp) return -EINVAL;
239 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
240 if (!cptr) return -EINVAL;
241 valid_bits = pvr2_ctrl_get_mask(cptr);
242 bcnt = 0;
243 for (msk = 1; valid_bits; msk <<= 1) {
244 if (!(msk & valid_bits)) continue;
245 valid_bits &= ~msk;
246 pvr2_ctrl_get_valname(cptr,msk,buf+bcnt,PAGE_SIZE-bcnt,&ccnt);
247 bcnt += ccnt;
248 if (bcnt >= PAGE_SIZE) break;
249 buf[bcnt] = '\n';
250 bcnt++;
251 }
252 pvr2_sysfs_trace("pvr2_sysfs(%p) show_bits(cid=%d)",sfp,id);
253 return bcnt;
254}
255
256static int store_val_any(int id,int customfl,struct pvr2_sysfs *sfp,
257 const char *buf,unsigned int count)
258{
259 struct pvr2_ctrl *cptr;
260 int ret;
261 int mask,val;
262
263 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
264 if (customfl) {
265 ret = pvr2_ctrl_custom_sym_to_value(cptr,buf,count,&mask,&val);
266 } else {
267 ret = pvr2_ctrl_sym_to_value(cptr,buf,count,&mask,&val);
268 }
269 if (ret < 0) return ret;
270 ret = pvr2_ctrl_set_mask_value(cptr,mask,val);
271 pvr2_hdw_commit_ctl(sfp->channel.hdw);
272 return ret;
273}
274
275static ssize_t store_val_norm(int id,struct class_device *class_dev,
276 const char *buf,size_t count)
277{
278 struct pvr2_sysfs *sfp;
279 int ret;
280 sfp = (struct pvr2_sysfs *)class_dev->class_data;
281 ret = store_val_any(id,0,sfp,buf,count);
282 if (!ret) ret = count;
283 return ret;
284}
285
286static ssize_t store_val_custom(int id,struct class_device *class_dev,
287 const char *buf,size_t count)
288{
289 struct pvr2_sysfs *sfp;
290 int ret;
291 sfp = (struct pvr2_sysfs *)class_dev->class_data;
292 ret = store_val_any(id,1,sfp,buf,count);
293 if (!ret) ret = count;
294 return ret;
295}
296
297/*
298 Mike Isely <isely@pobox.com> 30-April-2005
299
300 This next batch of horrible preprocessor hackery is needed because the
301 kernel's class_device_attribute mechanism fails to pass the actual
302 attribute through to the show / store functions, which means we have no
303 way to package up any attribute-specific parameters, like for example the
304 control id. So we work around this brain-damage by encoding the control
305 id into the show / store functions themselves and pick the function based
306 on the control id we're setting up. These macros try to ease the pain.
307 Yuck.
308*/
309
310#define CREATE_SHOW_INSTANCE(sf_name,ctl_id) \
311static ssize_t sf_name##_##ctl_id(struct class_device *class_dev,char *buf) \
312{ return sf_name(ctl_id,class_dev,buf); }
313
314#define CREATE_STORE_INSTANCE(sf_name,ctl_id) \
315static ssize_t sf_name##_##ctl_id(struct class_device *class_dev,const char *buf,size_t count) \
316{ return sf_name(ctl_id,class_dev,buf,count); }
317
318#define CREATE_BATCH(ctl_id) \
319CREATE_SHOW_INSTANCE(show_name,ctl_id) \
320CREATE_SHOW_INSTANCE(show_type,ctl_id) \
321CREATE_SHOW_INSTANCE(show_min,ctl_id) \
322CREATE_SHOW_INSTANCE(show_max,ctl_id) \
323CREATE_SHOW_INSTANCE(show_val_norm,ctl_id) \
324CREATE_SHOW_INSTANCE(show_val_custom,ctl_id) \
325CREATE_SHOW_INSTANCE(show_enum,ctl_id) \
326CREATE_SHOW_INSTANCE(show_bits,ctl_id) \
327CREATE_STORE_INSTANCE(store_val_norm,ctl_id) \
328CREATE_STORE_INSTANCE(store_val_custom,ctl_id) \
329
330CREATE_BATCH(0)
331CREATE_BATCH(1)
332CREATE_BATCH(2)
333CREATE_BATCH(3)
334CREATE_BATCH(4)
335CREATE_BATCH(5)
336CREATE_BATCH(6)
337CREATE_BATCH(7)
338CREATE_BATCH(8)
339CREATE_BATCH(9)
340CREATE_BATCH(10)
341CREATE_BATCH(11)
342CREATE_BATCH(12)
343CREATE_BATCH(13)
344CREATE_BATCH(14)
345CREATE_BATCH(15)
346CREATE_BATCH(16)
347CREATE_BATCH(17)
348CREATE_BATCH(18)
349CREATE_BATCH(19)
350CREATE_BATCH(20)
351CREATE_BATCH(21)
352CREATE_BATCH(22)
353CREATE_BATCH(23)
354CREATE_BATCH(24)
355CREATE_BATCH(25)
356CREATE_BATCH(26)
357CREATE_BATCH(27)
358CREATE_BATCH(28)
359CREATE_BATCH(29)
360CREATE_BATCH(30)
361CREATE_BATCH(31)
362CREATE_BATCH(32)
363CREATE_BATCH(33)
364CREATE_BATCH(34)
365CREATE_BATCH(35)
366CREATE_BATCH(36)
367CREATE_BATCH(37)
368CREATE_BATCH(38)
369CREATE_BATCH(39)
370CREATE_BATCH(40)
371CREATE_BATCH(41)
372CREATE_BATCH(42)
373CREATE_BATCH(43)
374CREATE_BATCH(44)
375CREATE_BATCH(45)
376CREATE_BATCH(46)
377CREATE_BATCH(47)
378CREATE_BATCH(48)
379CREATE_BATCH(49)
380CREATE_BATCH(50)
381CREATE_BATCH(51)
382CREATE_BATCH(52)
383CREATE_BATCH(53)
384CREATE_BATCH(54)
385CREATE_BATCH(55)
386CREATE_BATCH(56)
387CREATE_BATCH(57)
388CREATE_BATCH(58)
389CREATE_BATCH(59)
390
391struct pvr2_sysfs_func_set {
392 ssize_t (*show_name)(struct class_device *,char *);
393 ssize_t (*show_type)(struct class_device *,char *);
394 ssize_t (*show_min)(struct class_device *,char *);
395 ssize_t (*show_max)(struct class_device *,char *);
396 ssize_t (*show_enum)(struct class_device *,char *);
397 ssize_t (*show_bits)(struct class_device *,char *);
398 ssize_t (*show_val_norm)(struct class_device *,char *);
399 ssize_t (*store_val_norm)(struct class_device *,
400 const char *,size_t);
401 ssize_t (*show_val_custom)(struct class_device *,char *);
402 ssize_t (*store_val_custom)(struct class_device *,
403 const char *,size_t);
404};
405
406#define INIT_BATCH(ctl_id) \
407[ctl_id] = { \
408 .show_name = show_name_##ctl_id, \
409 .show_type = show_type_##ctl_id, \
410 .show_min = show_min_##ctl_id, \
411 .show_max = show_max_##ctl_id, \
412 .show_enum = show_enum_##ctl_id, \
413 .show_bits = show_bits_##ctl_id, \
414 .show_val_norm = show_val_norm_##ctl_id, \
415 .store_val_norm = store_val_norm_##ctl_id, \
416 .show_val_custom = show_val_custom_##ctl_id, \
417 .store_val_custom = store_val_custom_##ctl_id, \
418} \
419
420static struct pvr2_sysfs_func_set funcs[] = {
421 INIT_BATCH(0),
422 INIT_BATCH(1),
423 INIT_BATCH(2),
424 INIT_BATCH(3),
425 INIT_BATCH(4),
426 INIT_BATCH(5),
427 INIT_BATCH(6),
428 INIT_BATCH(7),
429 INIT_BATCH(8),
430 INIT_BATCH(9),
431 INIT_BATCH(10),
432 INIT_BATCH(11),
433 INIT_BATCH(12),
434 INIT_BATCH(13),
435 INIT_BATCH(14),
436 INIT_BATCH(15),
437 INIT_BATCH(16),
438 INIT_BATCH(17),
439 INIT_BATCH(18),
440 INIT_BATCH(19),
441 INIT_BATCH(20),
442 INIT_BATCH(21),
443 INIT_BATCH(22),
444 INIT_BATCH(23),
445 INIT_BATCH(24),
446 INIT_BATCH(25),
447 INIT_BATCH(26),
448 INIT_BATCH(27),
449 INIT_BATCH(28),
450 INIT_BATCH(29),
451 INIT_BATCH(30),
452 INIT_BATCH(31),
453 INIT_BATCH(32),
454 INIT_BATCH(33),
455 INIT_BATCH(34),
456 INIT_BATCH(35),
457 INIT_BATCH(36),
458 INIT_BATCH(37),
459 INIT_BATCH(38),
460 INIT_BATCH(39),
461 INIT_BATCH(40),
462 INIT_BATCH(41),
463 INIT_BATCH(42),
464 INIT_BATCH(43),
465 INIT_BATCH(44),
466 INIT_BATCH(45),
467 INIT_BATCH(46),
468 INIT_BATCH(47),
469 INIT_BATCH(48),
470 INIT_BATCH(49),
471 INIT_BATCH(50),
472 INIT_BATCH(51),
473 INIT_BATCH(52),
474 INIT_BATCH(53),
475 INIT_BATCH(54),
476 INIT_BATCH(55),
477 INIT_BATCH(56),
478 INIT_BATCH(57),
479 INIT_BATCH(58),
480 INIT_BATCH(59),
481};
482
483
484static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
485{
486 struct pvr2_sysfs_ctl_item *cip;
487 struct pvr2_sysfs_func_set *fp;
488 struct pvr2_ctrl *cptr;
489 unsigned int cnt,acnt;
490
491 if ((ctl_id < 0) || (ctl_id >= (sizeof(funcs)/sizeof(funcs[0])))) {
492 return;
493 }
494
495 fp = funcs + ctl_id;
496 cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,ctl_id);
497 if (!cptr) return;
498
499 cip = kmalloc(sizeof(*cip),GFP_KERNEL);
500 if (!cip) return;
501 memset(cip,0,sizeof(*cip));
502 pvr2_sysfs_trace("Creating pvr2_sysfs_ctl_item id=%p",cip);
503
504 cip->cptr = cptr;
505
506 cip->chptr = sfp;
507 cip->item_next = 0;
508 if (sfp->item_last) {
509 sfp->item_last->item_next = cip;
510 } else {
511 sfp->item_first = cip;
512 }
513 sfp->item_last = cip;
514
515 cip->attr_name.attr.owner = THIS_MODULE;
516 cip->attr_name.attr.name = "name";
517 cip->attr_name.attr.mode = S_IRUGO;
518 cip->attr_name.show = fp->show_name;
519
520 cip->attr_type.attr.owner = THIS_MODULE;
521 cip->attr_type.attr.name = "type";
522 cip->attr_type.attr.mode = S_IRUGO;
523 cip->attr_type.show = fp->show_type;
524
525 cip->attr_min.attr.owner = THIS_MODULE;
526 cip->attr_min.attr.name = "min_val";
527 cip->attr_min.attr.mode = S_IRUGO;
528 cip->attr_min.show = fp->show_min;
529
530 cip->attr_max.attr.owner = THIS_MODULE;
531 cip->attr_max.attr.name = "max_val";
532 cip->attr_max.attr.mode = S_IRUGO;
533 cip->attr_max.show = fp->show_max;
534
535 cip->attr_val.attr.owner = THIS_MODULE;
536 cip->attr_val.attr.name = "cur_val";
537 cip->attr_val.attr.mode = S_IRUGO;
538
539 cip->attr_custom.attr.owner = THIS_MODULE;
540 cip->attr_custom.attr.name = "custom_val";
541 cip->attr_custom.attr.mode = S_IRUGO;
542
543 cip->attr_enum.attr.owner = THIS_MODULE;
544 cip->attr_enum.attr.name = "enum_val";
545 cip->attr_enum.attr.mode = S_IRUGO;
546 cip->attr_enum.show = fp->show_enum;
547
548 cip->attr_bits.attr.owner = THIS_MODULE;
549 cip->attr_bits.attr.name = "bit_val";
550 cip->attr_bits.attr.mode = S_IRUGO;
551 cip->attr_bits.show = fp->show_bits;
552
553 if (pvr2_ctrl_is_writable(cptr)) {
554 cip->attr_val.attr.mode |= S_IWUSR|S_IWGRP;
555 cip->attr_custom.attr.mode |= S_IWUSR|S_IWGRP;
556 }
557
558 acnt = 0;
559 cip->attr_gen[acnt++] = &cip->attr_name.attr;
560 cip->attr_gen[acnt++] = &cip->attr_type.attr;
561 cip->attr_gen[acnt++] = &cip->attr_val.attr;
562 cip->attr_val.show = fp->show_val_norm;
563 cip->attr_val.store = fp->store_val_norm;
564 if (pvr2_ctrl_has_custom_symbols(cptr)) {
565 cip->attr_gen[acnt++] = &cip->attr_custom.attr;
566 cip->attr_custom.show = fp->show_val_custom;
567 cip->attr_custom.store = fp->store_val_custom;
568 }
569 switch (pvr2_ctrl_get_type(cptr)) {
570 case pvr2_ctl_enum:
571 // Control is an enumeration
572 cip->attr_gen[acnt++] = &cip->attr_enum.attr;
573 break;
574 case pvr2_ctl_int:
575 // Control is an integer
576 cip->attr_gen[acnt++] = &cip->attr_min.attr;
577 cip->attr_gen[acnt++] = &cip->attr_max.attr;
578 break;
579 case pvr2_ctl_bitmask:
580 // Control is an bitmask
581 cip->attr_gen[acnt++] = &cip->attr_bits.attr;
582 break;
583 default: break;
584 }
585
586 cnt = scnprintf(cip->name,sizeof(cip->name)-1,"ctl_%s",
587 pvr2_ctrl_get_name(cptr));
588 cip->name[cnt] = 0;
589 cip->grp.name = cip->name;
590 cip->grp.attrs = cip->attr_gen;
591
592 sysfs_create_group(&sfp->class_dev->kobj,&cip->grp);
593}
594
595#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
596static ssize_t debuginfo_show(struct class_device *,char *);
597static ssize_t debugcmd_show(struct class_device *,char *);
598static ssize_t debugcmd_store(struct class_device *,const char *,size_t count);
599
600static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
601{
602 struct pvr2_sysfs_debugifc *dip;
603 dip = kmalloc(sizeof(*dip),GFP_KERNEL);
604 if (!dip) return;
605 memset(dip,0,sizeof(*dip));
606 dip->attr_debugcmd.attr.owner = THIS_MODULE;
607 dip->attr_debugcmd.attr.name = "debugcmd";
608 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP;
609 dip->attr_debugcmd.show = debugcmd_show;
610 dip->attr_debugcmd.store = debugcmd_store;
611 dip->attr_debuginfo.attr.owner = THIS_MODULE;
612 dip->attr_debuginfo.attr.name = "debuginfo";
613 dip->attr_debuginfo.attr.mode = S_IRUGO;
614 dip->attr_debuginfo.show = debuginfo_show;
615 sfp->debugifc = dip;
616 class_device_create_file(sfp->class_dev,&dip->attr_debugcmd);
617 class_device_create_file(sfp->class_dev,&dip->attr_debuginfo);
618}
619
620
621static void pvr2_sysfs_tear_down_debugifc(struct pvr2_sysfs *sfp)
622{
623 if (!sfp->debugifc) return;
624 class_device_remove_file(sfp->class_dev,
625 &sfp->debugifc->attr_debuginfo);
626 class_device_remove_file(sfp->class_dev,&sfp->debugifc->attr_debugcmd);
627 kfree(sfp->debugifc);
628 sfp->debugifc = 0;
629}
630#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
631
632
633static void pvr2_sysfs_add_controls(struct pvr2_sysfs *sfp)
634{
635 unsigned int idx,cnt;
636 cnt = pvr2_hdw_get_ctrl_count(sfp->channel.hdw);
637 for (idx = 0; idx < cnt; idx++) {
638 pvr2_sysfs_add_control(sfp,idx);
639 }
640}
641
642
643static void pvr2_sysfs_tear_down_controls(struct pvr2_sysfs *sfp)
644{
645 struct pvr2_sysfs_ctl_item *cip1,*cip2;
646 for (cip1 = sfp->item_first; cip1; cip1 = cip2) {
647 cip2 = cip1->item_next;
648 sysfs_remove_group(&sfp->class_dev->kobj,&cip1->grp);
649 pvr2_sysfs_trace("Destroying pvr2_sysfs_ctl_item id=%p",cip1);
650 kfree(cip1);
651 }
652}
653
654
655static void pvr2_sysfs_class_release(struct class *class)
656{
657 struct pvr2_sysfs_class *clp;
658 clp = container_of(class,struct pvr2_sysfs_class,class);
659 pvr2_sysfs_trace("Destroying pvr2_sysfs_class id=%p",clp);
660 kfree(clp);
661}
662
663
664static void pvr2_sysfs_release(struct class_device *class_dev)
665{
666 pvr2_sysfs_trace("Releasing class_dev id=%p",class_dev);
667 kfree(class_dev);
668}
669
670
671static void class_dev_destroy(struct pvr2_sysfs *sfp)
672{
673 if (!sfp->class_dev) return;
674#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
675 pvr2_sysfs_tear_down_debugifc(sfp);
676#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
677 pvr2_sysfs_tear_down_controls(sfp);
678 class_device_remove_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
679 class_device_remove_file(sfp->class_dev,&sfp->attr_unit_number);
680 pvr2_sysfs_trace("Destroying class_dev id=%p",sfp->class_dev);
681 sfp->class_dev->class_data = 0;
682 class_device_unregister(sfp->class_dev);
683 sfp->class_dev = 0;
684}
685
686
687static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
688{
689 struct pvr2_sysfs *sfp;
690 sfp = (struct pvr2_sysfs *)class_dev->class_data;
691 if (!sfp) return -EINVAL;
692 return scnprintf(buf,PAGE_SIZE,"%d\n",
693 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw));
694}
695
696
697static ssize_t unit_number_show(struct class_device *class_dev,char *buf)
698{
699 struct pvr2_sysfs *sfp;
700 sfp = (struct pvr2_sysfs *)class_dev->class_data;
701 if (!sfp) return -EINVAL;
702 return scnprintf(buf,PAGE_SIZE,"%d\n",
703 pvr2_hdw_get_unit_number(sfp->channel.hdw));
704}
705
706
707static void class_dev_create(struct pvr2_sysfs *sfp,
708 struct pvr2_sysfs_class *class_ptr)
709{
710 struct usb_device *usb_dev;
711 struct class_device *class_dev;
712 usb_dev = pvr2_hdw_get_dev(sfp->channel.hdw);
713 if (!usb_dev) return;
714 class_dev = kmalloc(sizeof(*class_dev),GFP_KERNEL);
715 if (!class_dev) return;
716 memset(class_dev,0,sizeof(*class_dev));
717
718 pvr2_sysfs_trace("Creating class_dev id=%p",class_dev);
719
720 class_dev->class = &class_ptr->class;
721 if (pvr2_hdw_get_sn(sfp->channel.hdw)) {
722 snprintf(class_dev->class_id,BUS_ID_SIZE,"sn-%lu",
723 pvr2_hdw_get_sn(sfp->channel.hdw));
724 } else if (pvr2_hdw_get_unit_number(sfp->channel.hdw) >= 0) {
725 snprintf(class_dev->class_id,BUS_ID_SIZE,"unit-%c",
726 pvr2_hdw_get_unit_number(sfp->channel.hdw) + 'a');
727 } else {
728 kfree(class_dev);
729 return;
730 }
731
732 class_dev->dev = &usb_dev->dev;
733
734 sfp->class_dev = class_dev;
735 class_dev->class_data = sfp;
736 class_device_register(class_dev);
737
738 sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE;
739 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
740 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
741 sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
742 sfp->attr_v4l_minor_number.store = 0;
743 class_device_create_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
744 sfp->attr_unit_number.attr.owner = THIS_MODULE;
745 sfp->attr_unit_number.attr.name = "unit_number";
746 sfp->attr_unit_number.attr.mode = S_IRUGO;
747 sfp->attr_unit_number.show = unit_number_show;
748 sfp->attr_unit_number.store = 0;
749 class_device_create_file(sfp->class_dev,&sfp->attr_unit_number);
750
751 pvr2_sysfs_add_controls(sfp);
752#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
753 pvr2_sysfs_add_debugifc(sfp);
754#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
755}
756
757
758static void pvr2_sysfs_internal_check(struct pvr2_channel *chp)
759{
760 struct pvr2_sysfs *sfp;
761 sfp = container_of(chp,struct pvr2_sysfs,channel);
762 if (!sfp->channel.mc_head->disconnect_flag) return;
763 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_sysfs id=%p",sfp);
764 class_dev_destroy(sfp);
765 pvr2_channel_done(&sfp->channel);
766 kfree(sfp);
767}
768
769
770struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *mp,
771 struct pvr2_sysfs_class *class_ptr)
772{
773 struct pvr2_sysfs *sfp;
774 sfp = kmalloc(sizeof(*sfp),GFP_KERNEL);
775 if (!sfp) return sfp;
776 memset(sfp,0,sizeof(*sfp));
777 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_sysfs id=%p",sfp);
778 pvr2_channel_init(&sfp->channel,mp);
779 sfp->channel.check_func = pvr2_sysfs_internal_check;
780
781 class_dev_create(sfp,class_ptr);
782 return sfp;
783}
784
785
786static int pvr2_sysfs_hotplug(struct class_device *cd,char **envp,
787 int numenvp,char *buf,int size)
788{
789 /* Even though we don't do anything here, we still need this function
790 because sysfs will still try to call it. */
791 return 0;
792}
793
794struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
795{
796 struct pvr2_sysfs_class *clp;
797 clp = kmalloc(sizeof(*clp),GFP_KERNEL);
798 if (!clp) return clp;
799 memset(clp,0,sizeof(*clp));
800 pvr2_sysfs_trace("Creating pvr2_sysfs_class id=%p",clp);
801 clp->class.name = "pvrusb2";
802 clp->class.class_release = pvr2_sysfs_class_release;
803 clp->class.release = pvr2_sysfs_release;
804 clp->class.uevent = pvr2_sysfs_hotplug;
805 if (class_register(&clp->class)) {
806 pvr2_sysfs_trace(
807 "Registration failed for pvr2_sysfs_class id=%p",clp);
808 kfree(clp);
809 clp = 0;
810 }
811 return clp;
812}
813
814
815void pvr2_sysfs_class_destroy(struct pvr2_sysfs_class *clp)
816{
817 class_unregister(&clp->class);
818}
819
820
821#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
822static ssize_t debuginfo_show(struct class_device *class_dev,char *buf)
823{
824 struct pvr2_sysfs *sfp;
825 sfp = (struct pvr2_sysfs *)class_dev->class_data;
826 if (!sfp) return -EINVAL;
827 pvr2_hdw_trigger_module_log(sfp->channel.hdw);
828 return pvr2_debugifc_print_info(sfp->channel.hdw,buf,PAGE_SIZE);
829}
830
831
832static ssize_t debugcmd_show(struct class_device *class_dev,char *buf)
833{
834 struct pvr2_sysfs *sfp;
835 sfp = (struct pvr2_sysfs *)class_dev->class_data;
836 if (!sfp) return -EINVAL;
837 return pvr2_debugifc_print_status(sfp->channel.hdw,buf,PAGE_SIZE);
838}
839
840
841static ssize_t debugcmd_store(struct class_device *class_dev,
842 const char *buf,size_t count)
843{
844 struct pvr2_sysfs *sfp;
845 int ret;
846
847 sfp = (struct pvr2_sysfs *)class_dev->class_data;
848 if (!sfp) return -EINVAL;
849
850 ret = pvr2_debugifc_docmd(sfp->channel.hdw,buf,count);
851 if (ret < 0) return ret;
852 return count;
853}
854#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
855
856
857/*
858 Stuff for Emacs to see, in order to encourage consistent editing style:
859 *** Local Variables: ***
860 *** mode: c ***
861 *** fill-column: 75 ***
862 *** tab-width: 8 ***
863 *** c-basic-offset: 8 ***
864 *** End: ***
865 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.h b/drivers/media/video/pvrusb2/pvrusb2-sysfs.h
new file mode 100644
index 000000000000..ff9373b47f8f
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.h
@@ -0,0 +1,47 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_SYSFS_H
22#define __PVRUSB2_SYSFS_H
23
24#include <linux/list.h>
25#include <linux/sysfs.h>
26#include "pvrusb2-context.h"
27
28struct pvr2_sysfs;
29struct pvr2_sysfs_class;
30
31struct pvr2_sysfs_class *pvr2_sysfs_class_create(void);
32void pvr2_sysfs_class_destroy(struct pvr2_sysfs_class *);
33
34struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *,
35 struct pvr2_sysfs_class *);
36
37#endif /* __PVRUSB2_SYSFS_H */
38
39/*
40 Stuff for Emacs to see, in order to encourage consistent editing style:
41 *** Local Variables: ***
42 *** mode: c ***
43 *** fill-column: 75 ***
44 *** tab-width: 8 ***
45 *** c-basic-offset: 8 ***
46 *** End: ***
47 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-tuner.c b/drivers/media/video/pvrusb2/pvrusb2-tuner.c
new file mode 100644
index 000000000000..f4aba8144ce0
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-tuner.c
@@ -0,0 +1,122 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "pvrusb2.h"
24#include "pvrusb2-util.h"
25#include "pvrusb2-tuner.h"
26#include "pvrusb2-hdw-internal.h"
27#include "pvrusb2-debug.h"
28#include <linux/videodev2.h>
29#include <media/tuner.h>
30#include <media/v4l2-common.h>
31
32struct pvr2_tuner_handler {
33 struct pvr2_hdw *hdw;
34 struct pvr2_i2c_client *client;
35 struct pvr2_i2c_handler i2c_handler;
36 int type_update_fl;
37};
38
39
40static void set_type(struct pvr2_tuner_handler *ctxt)
41{
42 struct pvr2_hdw *hdw = ctxt->hdw;
43 struct tuner_setup setup;
44 pvr2_trace(PVR2_TRACE_CHIPS,"i2c tuner set_type(%d)",hdw->tuner_type);
45 if (((int)(hdw->tuner_type)) < 0) return;
46
47 setup.addr = ADDR_UNSET;
48 setup.type = hdw->tuner_type;
49 setup.mode_mask = T_RADIO | T_ANALOG_TV;
50 /* We may really want mode_mask to be T_ANALOG_TV for now */
51 pvr2_i2c_client_cmd(ctxt->client,TUNER_SET_TYPE_ADDR,&setup);
52 ctxt->type_update_fl = 0;
53}
54
55
56static int tuner_check(struct pvr2_tuner_handler *ctxt)
57{
58 struct pvr2_hdw *hdw = ctxt->hdw;
59 if (hdw->tuner_updated) ctxt->type_update_fl = !0;
60 return ctxt->type_update_fl != 0;
61}
62
63
64static void tuner_update(struct pvr2_tuner_handler *ctxt)
65{
66 if (ctxt->type_update_fl) set_type(ctxt);
67}
68
69
70static void pvr2_tuner_detach(struct pvr2_tuner_handler *ctxt)
71{
72 ctxt->client->handler = 0;
73 kfree(ctxt);
74}
75
76
77static unsigned int pvr2_tuner_describe(struct pvr2_tuner_handler *ctxt,char *buf,unsigned int cnt)
78{
79 return scnprintf(buf,cnt,"handler: pvrusb2-tuner");
80}
81
82
83const static struct pvr2_i2c_handler_functions tuner_funcs = {
84 .detach = (void (*)(void *))pvr2_tuner_detach,
85 .check = (int (*)(void *))tuner_check,
86 .update = (void (*)(void *))tuner_update,
87 .describe = (unsigned int (*)(void *,char *,unsigned int))pvr2_tuner_describe,
88};
89
90
91int pvr2_i2c_tuner_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
92{
93 struct pvr2_tuner_handler *ctxt;
94 if (cp->handler) return 0;
95
96 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
97 if (!ctxt) return 0;
98 memset(ctxt,0,sizeof(*ctxt));
99
100 ctxt->i2c_handler.func_data = ctxt;
101 ctxt->i2c_handler.func_table = &tuner_funcs;
102 ctxt->type_update_fl = !0;
103 ctxt->client = cp;
104 ctxt->hdw = hdw;
105 cp->handler = &ctxt->i2c_handler;
106 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x tuner handler set up",
107 cp->client->addr);
108 return !0;
109}
110
111
112
113
114/*
115 Stuff for Emacs to see, in order to encourage consistent editing style:
116 *** Local Variables: ***
117 *** mode: c ***
118 *** fill-column: 70 ***
119 *** tab-width: 8 ***
120 *** c-basic-offset: 8 ***
121 *** End: ***
122 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-tuner.h b/drivers/media/video/pvrusb2/pvrusb2-tuner.h
new file mode 100644
index 000000000000..556f12aa9160
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-tuner.h
@@ -0,0 +1,38 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_TUNER_H
22#define __PVRUSB2_TUNER_H
23
24#include "pvrusb2-i2c-core.h"
25
26int pvr2_i2c_tuner_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
27
28#endif /* __PVRUSB2_TUNER_H */
29
30/*
31 Stuff for Emacs to see, in order to encourage consistent editing style:
32 *** Local Variables: ***
33 *** mode: c ***
34 *** fill-column: 70 ***
35 *** tab-width: 8 ***
36 *** c-basic-offset: 8 ***
37 *** End: ***
38 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-util.h b/drivers/media/video/pvrusb2/pvrusb2-util.h
new file mode 100644
index 000000000000..e53aee416f56
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-util.h
@@ -0,0 +1,63 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_UTIL_H
22#define __PVRUSB2_UTIL_H
23
24#define PVR2_DECOMPOSE_LE(t,i,d) \
25 do { \
26 (t)[i] = (d) & 0xff;\
27 (t)[i+1] = ((d) >> 8) & 0xff;\
28 (t)[i+2] = ((d) >> 16) & 0xff;\
29 (t)[i+3] = ((d) >> 24) & 0xff;\
30 } while(0)
31
32#define PVR2_DECOMPOSE_BE(t,i,d) \
33 do { \
34 (t)[i+3] = (d) & 0xff;\
35 (t)[i+2] = ((d) >> 8) & 0xff;\
36 (t)[i+1] = ((d) >> 16) & 0xff;\
37 (t)[i] = ((d) >> 24) & 0xff;\
38 } while(0)
39
40#define PVR2_COMPOSE_LE(t,i) \
41 ((((u32)((t)[i+3])) << 24) | \
42 (((u32)((t)[i+2])) << 16) | \
43 (((u32)((t)[i+1])) << 8) | \
44 ((u32)((t)[i])))
45
46#define PVR2_COMPOSE_BE(t,i) \
47 ((((u32)((t)[i])) << 24) | \
48 (((u32)((t)[i+1])) << 16) | \
49 (((u32)((t)[i+2])) << 8) | \
50 ((u32)((t)[i+3])))
51
52
53#endif /* __PVRUSB2_UTIL_H */
54
55/*
56 Stuff for Emacs to see, in order to encourage consistent editing style:
57 *** Local Variables: ***
58 *** mode: c ***
59 *** fill-column: 75 ***
60 *** tab-width: 8 ***
61 *** c-basic-offset: 8 ***
62 *** End: ***
63 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
new file mode 100644
index 000000000000..961951010c27
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -0,0 +1,1126 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/version.h>
25#include "pvrusb2-context.h"
26#include "pvrusb2-hdw.h"
27#include "pvrusb2.h"
28#include "pvrusb2-debug.h"
29#include "pvrusb2-v4l2.h"
30#include "pvrusb2-ioread.h"
31#include <linux/videodev2.h>
32#include <media/v4l2-common.h>
33
34struct pvr2_v4l2_dev;
35struct pvr2_v4l2_fh;
36struct pvr2_v4l2;
37
38/* V4L no longer provide the ability to set / get a private context pointer
39 (i.e. video_get_drvdata / video_set_drvdata), which means we have to
40 concoct our own context locating mechanism. Supposedly this is intended
41 to simplify driver implementation. It's not clear to me how that can
42 possibly be true. Our solution here is to maintain a lookup table of
43 our context instances, indexed by the minor device number of the V4L
44 device. See pvr2_v4l2_open() for some implications of this approach. */
45static struct pvr2_v4l2_dev *devices[256];
46static DEFINE_MUTEX(device_lock);
47
48struct pvr2_v4l2_dev {
49 struct pvr2_v4l2 *v4lp;
50 struct video_device *vdev;
51 struct pvr2_context_stream *stream;
52 int ctxt_idx;
53 enum pvr2_config config;
54};
55
56struct pvr2_v4l2_fh {
57 struct pvr2_channel channel;
58 struct pvr2_v4l2_dev *dev_info;
59 enum v4l2_priority prio;
60 struct pvr2_ioread *rhp;
61 struct file *file;
62 struct pvr2_v4l2 *vhead;
63 struct pvr2_v4l2_fh *vnext;
64 struct pvr2_v4l2_fh *vprev;
65 wait_queue_head_t wait_data;
66 int fw_mode_flag;
67};
68
69struct pvr2_v4l2 {
70 struct pvr2_channel channel;
71 struct pvr2_v4l2_fh *vfirst;
72 struct pvr2_v4l2_fh *vlast;
73
74 struct v4l2_prio_state prio;
75
76 /* streams */
77 struct pvr2_v4l2_dev video_dev;
78};
79
80static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
81module_param_array(video_nr, int, NULL, 0444);
82MODULE_PARM_DESC(video_nr, "Offset for device's minor");
83
84struct v4l2_capability pvr_capability ={
85 .driver = "pvrusb2",
86 .card = "Hauppauge WinTV pvr-usb2",
87 .bus_info = "usb",
88 .version = KERNEL_VERSION(0,8,0),
89 .capabilities = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
90 V4L2_CAP_TUNER | V4L2_CAP_AUDIO |
91 V4L2_CAP_READWRITE),
92 .reserved = {0,0,0,0}
93};
94
95static struct v4l2_tuner pvr_v4l2_tuners[]= {
96 {
97 .index = 0,
98 .name = "TV Tuner",
99 .type = V4L2_TUNER_ANALOG_TV,
100 .capability = (V4L2_TUNER_CAP_NORM |
101 V4L2_TUNER_CAP_STEREO |
102 V4L2_TUNER_CAP_LANG1 |
103 V4L2_TUNER_CAP_LANG2),
104 .rangelow = 0,
105 .rangehigh = 0,
106 .rxsubchans = V4L2_TUNER_SUB_STEREO,
107 .audmode = V4L2_TUNER_MODE_STEREO,
108 .signal = 0,
109 .afc = 0,
110 .reserved = {0,0,0,0}
111 }
112};
113
114struct v4l2_fmtdesc pvr_fmtdesc [] = {
115 {
116 .index = 0,
117 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
118 .flags = V4L2_FMT_FLAG_COMPRESSED,
119 .description = "MPEG1/2",
120 // This should really be V4L2_PIX_FMT_MPEG, but xawtv
121 // breaks when I do that.
122 .pixelformat = 0, // V4L2_PIX_FMT_MPEG,
123 .reserved = { 0, 0, 0, 0 }
124 }
125};
126
127#define PVR_FORMAT_PIX 0
128#define PVR_FORMAT_VBI 1
129
130struct v4l2_format pvr_format [] = {
131 [PVR_FORMAT_PIX] = {
132 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
133 .fmt = {
134 .pix = {
135 .width = 720,
136 .height = 576,
137 // This should really be V4L2_PIX_FMT_MPEG,
138 // but xawtv breaks when I do that.
139 .pixelformat = 0, // V4L2_PIX_FMT_MPEG,
140 .field = V4L2_FIELD_INTERLACED,
141 .bytesperline = 0, // doesn't make sense
142 // here
143 //FIXME : Don't know what to put here...
144 .sizeimage = (32*1024),
145 .colorspace = 0, // doesn't make sense here
146 .priv = 0
147 }
148 }
149 },
150 [PVR_FORMAT_VBI] = {
151 .type = V4L2_BUF_TYPE_VBI_CAPTURE,
152 .fmt = {
153 .vbi = {
154 .sampling_rate = 27000000,
155 .offset = 248,
156 .samples_per_line = 1443,
157 .sample_format = V4L2_PIX_FMT_GREY,
158 .start = { 0, 0 },
159 .count = { 0, 0 },
160 .flags = 0,
161 .reserved = { 0, 0 }
162 }
163 }
164 }
165};
166
167/*
168 * pvr_ioctl()
169 *
170 * This is part of Video 4 Linux API. The procedure handles ioctl() calls.
171 *
172 */
173static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
174 unsigned int cmd, void *arg)
175{
176 struct pvr2_v4l2_fh *fh = file->private_data;
177 struct pvr2_v4l2 *vp = fh->vhead;
178 struct pvr2_v4l2_dev *dev_info = fh->dev_info;
179 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
180 int ret = -EINVAL;
181
182 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
183 v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),cmd);
184 }
185
186 if (!pvr2_hdw_dev_ok(hdw)) {
187 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
188 "ioctl failed - bad or no context");
189 return -EFAULT;
190 }
191
192 /* check priority */
193 switch (cmd) {
194 case VIDIOC_S_CTRL:
195 case VIDIOC_S_STD:
196 case VIDIOC_S_INPUT:
197 case VIDIOC_S_TUNER:
198 case VIDIOC_S_FREQUENCY:
199 ret = v4l2_prio_check(&vp->prio, &fh->prio);
200 if (ret)
201 return ret;
202 }
203
204 switch (cmd) {
205 case VIDIOC_QUERYCAP:
206 {
207 struct v4l2_capability *cap = arg;
208
209 memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability));
210
211 ret = 0;
212 break;
213 }
214
215 case VIDIOC_G_PRIORITY:
216 {
217 enum v4l2_priority *p = arg;
218
219 *p = v4l2_prio_max(&vp->prio);
220 ret = 0;
221 break;
222 }
223
224 case VIDIOC_S_PRIORITY:
225 {
226 enum v4l2_priority *prio = arg;
227
228 ret = v4l2_prio_change(&vp->prio, &fh->prio, *prio);
229 break;
230 }
231
232 case VIDIOC_ENUMSTD:
233 {
234 struct v4l2_standard *vs = (struct v4l2_standard *)arg;
235 int idx = vs->index;
236 ret = pvr2_hdw_get_stdenum_value(hdw,vs,idx+1);
237 break;
238 }
239
240 case VIDIOC_G_STD:
241 {
242 int val = 0;
243 ret = pvr2_ctrl_get_value(
244 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR),&val);
245 *(v4l2_std_id *)arg = val;
246 break;
247 }
248
249 case VIDIOC_S_STD:
250 {
251 ret = pvr2_ctrl_set_value(
252 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR),
253 *(v4l2_std_id *)arg);
254 break;
255 }
256
257 case VIDIOC_ENUMINPUT:
258 {
259 struct pvr2_ctrl *cptr;
260 struct v4l2_input *vi = (struct v4l2_input *)arg;
261 struct v4l2_input tmp;
262 unsigned int cnt;
263
264 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT);
265
266 memset(&tmp,0,sizeof(tmp));
267 tmp.index = vi->index;
268 ret = 0;
269 switch (vi->index) {
270 case PVR2_CVAL_INPUT_TV:
271 case PVR2_CVAL_INPUT_RADIO:
272 tmp.type = V4L2_INPUT_TYPE_TUNER;
273 break;
274 case PVR2_CVAL_INPUT_SVIDEO:
275 case PVR2_CVAL_INPUT_COMPOSITE:
276 tmp.type = V4L2_INPUT_TYPE_CAMERA;
277 break;
278 default:
279 ret = -EINVAL;
280 break;
281 }
282 if (ret < 0) break;
283
284 cnt = 0;
285 pvr2_ctrl_get_valname(cptr,vi->index,
286 tmp.name,sizeof(tmp.name)-1,&cnt);
287 tmp.name[cnt] = 0;
288
289 /* Don't bother with audioset, since this driver currently
290 always switches the audio whenever the video is
291 switched. */
292
293 /* Handling std is a tougher problem. It doesn't make
294 sense in cases where a device might be multi-standard.
295 We could just copy out the current value for the
296 standard, but it can change over time. For now just
297 leave it zero. */
298
299 memcpy(vi, &tmp, sizeof(tmp));
300
301 ret = 0;
302 break;
303 }
304
305 case VIDIOC_G_INPUT:
306 {
307 struct pvr2_ctrl *cptr;
308 struct v4l2_input *vi = (struct v4l2_input *)arg;
309 int val;
310 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT);
311 val = 0;
312 ret = pvr2_ctrl_get_value(cptr,&val);
313 vi->index = val;
314 break;
315 }
316
317 case VIDIOC_S_INPUT:
318 {
319 struct v4l2_input *vi = (struct v4l2_input *)arg;
320 ret = pvr2_ctrl_set_value(
321 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT),
322 vi->index);
323 break;
324 }
325
326 case VIDIOC_ENUMAUDIO:
327 {
328 ret = -EINVAL;
329 break;
330 }
331
332 case VIDIOC_G_AUDIO:
333 {
334 ret = -EINVAL;
335 break;
336 }
337
338 case VIDIOC_S_AUDIO:
339 {
340 ret = -EINVAL;
341 break;
342 }
343 case VIDIOC_G_TUNER:
344 {
345 struct v4l2_tuner *vt = (struct v4l2_tuner *)arg;
346 unsigned int status_mask;
347 int val;
348 if (vt->index !=0) break;
349
350 status_mask = pvr2_hdw_get_signal_status(hdw);
351
352 memcpy(vt, &pvr_v4l2_tuners[vt->index],
353 sizeof(struct v4l2_tuner));
354
355 vt->signal = 0;
356 if (status_mask & PVR2_SIGNAL_OK) {
357 if (status_mask & PVR2_SIGNAL_STEREO) {
358 vt->rxsubchans = V4L2_TUNER_SUB_STEREO;
359 } else {
360 vt->rxsubchans = V4L2_TUNER_SUB_MONO;
361 }
362 if (status_mask & PVR2_SIGNAL_SAP) {
363 vt->rxsubchans |= (V4L2_TUNER_SUB_LANG1 |
364 V4L2_TUNER_SUB_LANG2);
365 }
366 vt->signal = 65535;
367 }
368
369 val = 0;
370 ret = pvr2_ctrl_get_value(
371 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE),
372 &val);
373 vt->audmode = val;
374 break;
375 }
376
377 case VIDIOC_S_TUNER:
378 {
379 struct v4l2_tuner *vt=(struct v4l2_tuner *)arg;
380
381 if (vt->index != 0)
382 break;
383
384 ret = pvr2_ctrl_set_value(
385 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE),
386 vt->audmode);
387 }
388
389 case VIDIOC_S_FREQUENCY:
390 {
391 const struct v4l2_frequency *vf = (struct v4l2_frequency *)arg;
392 ret = pvr2_ctrl_set_value(
393 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY),
394 vf->frequency * 62500);
395 break;
396 }
397
398 case VIDIOC_G_FREQUENCY:
399 {
400 struct v4l2_frequency *vf = (struct v4l2_frequency *)arg;
401 int val = 0;
402 ret = pvr2_ctrl_get_value(
403 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY),
404 &val);
405 val /= 62500;
406 vf->frequency = val;
407 break;
408 }
409
410 case VIDIOC_ENUM_FMT:
411 {
412 struct v4l2_fmtdesc *fd = (struct v4l2_fmtdesc *)arg;
413
414 /* Only one format is supported : mpeg.*/
415 if (fd->index != 0)
416 break;
417
418 memcpy(fd, pvr_fmtdesc, sizeof(struct v4l2_fmtdesc));
419 ret = 0;
420 break;
421 }
422
423 case VIDIOC_G_FMT:
424 {
425 struct v4l2_format *vf = (struct v4l2_format *)arg;
426 int val;
427 switch(vf->type) {
428 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
429 memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
430 sizeof(struct v4l2_format));
431 val = 0;
432 pvr2_ctrl_get_value(
433 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES),
434 &val);
435 vf->fmt.pix.width = val;
436 val = 0;
437 pvr2_ctrl_get_value(
438 pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES),
439 &val);
440 vf->fmt.pix.height = val;
441 ret = 0;
442 break;
443 case V4L2_BUF_TYPE_VBI_CAPTURE:
444 // ????? Still need to figure out to do VBI correctly
445 ret = -EINVAL;
446 break;
447 default:
448 ret = -EINVAL;
449 break;
450 }
451 break;
452 }
453
454 case VIDIOC_TRY_FMT:
455 case VIDIOC_S_FMT:
456 {
457 struct v4l2_format *vf = (struct v4l2_format *)arg;
458
459 ret = 0;
460 switch(vf->type) {
461 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
462 int h = vf->fmt.pix.height;
463 int w = vf->fmt.pix.width;
464
465 if (h < 200) {
466 h = 200;
467 } else if (h > 625) {
468 h = 625;
469 }
470 if (w < 320) {
471 w = 320;
472 } else if (w > 720) {
473 w = 720;
474 }
475
476 memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
477 sizeof(struct v4l2_format));
478 vf->fmt.pix.width = w;
479 vf->fmt.pix.height = h;
480
481 if (cmd == VIDIOC_S_FMT) {
482 pvr2_ctrl_set_value(
483 pvr2_hdw_get_ctrl_by_id(hdw,
484 PVR2_CID_HRES),
485 vf->fmt.pix.width);
486 pvr2_ctrl_set_value(
487 pvr2_hdw_get_ctrl_by_id(hdw,
488 PVR2_CID_VRES),
489 vf->fmt.pix.height);
490 }
491 } break;
492 case V4L2_BUF_TYPE_VBI_CAPTURE:
493 // ????? Still need to figure out to do VBI correctly
494 ret = -EINVAL;
495 break;
496 default:
497 ret = -EINVAL;
498 break;
499 }
500 break;
501 }
502
503 case VIDIOC_STREAMON:
504 {
505 ret = pvr2_hdw_set_stream_type(hdw,dev_info->config);
506 if (ret < 0) return ret;
507 ret = pvr2_hdw_set_streaming(hdw,!0);
508 break;
509 }
510
511 case VIDIOC_STREAMOFF:
512 {
513 ret = pvr2_hdw_set_streaming(hdw,0);
514 break;
515 }
516
517 case VIDIOC_QUERYCTRL:
518 {
519 struct pvr2_ctrl *cptr;
520 struct v4l2_queryctrl *vc = (struct v4l2_queryctrl *)arg;
521 ret = 0;
522 if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) {
523 cptr = pvr2_hdw_get_ctrl_nextv4l(
524 hdw,(vc->id & ~V4L2_CTRL_FLAG_NEXT_CTRL));
525 if (cptr) vc->id = pvr2_ctrl_get_v4lid(cptr);
526 } else {
527 cptr = pvr2_hdw_get_ctrl_v4l(hdw,vc->id);
528 }
529 if (!cptr) {
530 pvr2_trace(PVR2_TRACE_V4LIOCTL,
531 "QUERYCTRL id=0x%x not implemented here",
532 vc->id);
533 ret = -EINVAL;
534 break;
535 }
536
537 pvr2_trace(PVR2_TRACE_V4LIOCTL,
538 "QUERYCTRL id=0x%x mapping name=%s (%s)",
539 vc->id,pvr2_ctrl_get_name(cptr),
540 pvr2_ctrl_get_desc(cptr));
541 strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name));
542 vc->flags = pvr2_ctrl_get_v4lflags(cptr);
543 vc->default_value = pvr2_ctrl_get_def(cptr);
544 switch (pvr2_ctrl_get_type(cptr)) {
545 case pvr2_ctl_enum:
546 vc->type = V4L2_CTRL_TYPE_MENU;
547 vc->minimum = 0;
548 vc->maximum = pvr2_ctrl_get_cnt(cptr) - 1;
549 vc->step = 1;
550 break;
551 case pvr2_ctl_bool:
552 vc->type = V4L2_CTRL_TYPE_BOOLEAN;
553 vc->minimum = 0;
554 vc->maximum = 1;
555 vc->step = 1;
556 break;
557 case pvr2_ctl_int:
558 vc->type = V4L2_CTRL_TYPE_INTEGER;
559 vc->minimum = pvr2_ctrl_get_min(cptr);
560 vc->maximum = pvr2_ctrl_get_max(cptr);
561 vc->step = 1;
562 break;
563 default:
564 pvr2_trace(PVR2_TRACE_V4LIOCTL,
565 "QUERYCTRL id=0x%x name=%s not mappable",
566 vc->id,pvr2_ctrl_get_name(cptr));
567 ret = -EINVAL;
568 break;
569 }
570 break;
571 }
572
573 case VIDIOC_QUERYMENU:
574 {
575 struct v4l2_querymenu *vm = (struct v4l2_querymenu *)arg;
576 unsigned int cnt = 0;
577 ret = pvr2_ctrl_get_valname(pvr2_hdw_get_ctrl_v4l(hdw,vm->id),
578 vm->index,
579 vm->name,sizeof(vm->name)-1,
580 &cnt);
581 vm->name[cnt] = 0;
582 break;
583 }
584
585 case VIDIOC_G_CTRL:
586 {
587 struct v4l2_control *vc = (struct v4l2_control *)arg;
588 int val = 0;
589 ret = pvr2_ctrl_get_value(pvr2_hdw_get_ctrl_v4l(hdw,vc->id),
590 &val);
591 vc->value = val;
592 break;
593 }
594
595 case VIDIOC_S_CTRL:
596 {
597 struct v4l2_control *vc = (struct v4l2_control *)arg;
598 ret = pvr2_ctrl_set_value(pvr2_hdw_get_ctrl_v4l(hdw,vc->id),
599 vc->value);
600 break;
601 }
602
603 case VIDIOC_G_EXT_CTRLS:
604 {
605 struct v4l2_ext_controls *ctls =
606 (struct v4l2_ext_controls *)arg;
607 struct v4l2_ext_control *ctrl;
608 unsigned int idx;
609 int val;
610 for (idx = 0; idx < ctls->count; idx++) {
611 ctrl = ctls->controls + idx;
612 ret = pvr2_ctrl_get_value(
613 pvr2_hdw_get_ctrl_v4l(hdw,ctrl->id),&val);
614 if (ret) {
615 ctls->error_idx = idx;
616 break;
617 }
618 /* Ensure that if read as a 64 bit value, the user
619 will still get a hopefully sane value */
620 ctrl->value64 = 0;
621 ctrl->value = val;
622 }
623 break;
624 }
625
626 case VIDIOC_S_EXT_CTRLS:
627 {
628 struct v4l2_ext_controls *ctls =
629 (struct v4l2_ext_controls *)arg;
630 struct v4l2_ext_control *ctrl;
631 unsigned int idx;
632 for (idx = 0; idx < ctls->count; idx++) {
633 ctrl = ctls->controls + idx;
634 ret = pvr2_ctrl_set_value(
635 pvr2_hdw_get_ctrl_v4l(hdw,ctrl->id),
636 ctrl->value);
637 if (ret) {
638 ctls->error_idx = idx;
639 break;
640 }
641 }
642 break;
643 }
644
645 case VIDIOC_TRY_EXT_CTRLS:
646 {
647 struct v4l2_ext_controls *ctls =
648 (struct v4l2_ext_controls *)arg;
649 struct v4l2_ext_control *ctrl;
650 struct pvr2_ctrl *pctl;
651 unsigned int idx;
652 /* For the moment just validate that the requested control
653 actually exists. */
654 for (idx = 0; idx < ctls->count; idx++) {
655 ctrl = ctls->controls + idx;
656 pctl = pvr2_hdw_get_ctrl_v4l(hdw,ctrl->id);
657 if (!pctl) {
658 ret = -EINVAL;
659 ctls->error_idx = idx;
660 break;
661 }
662 }
663 break;
664 }
665
666 case VIDIOC_LOG_STATUS:
667 {
668 pvr2_hdw_trigger_module_log(hdw);
669 ret = 0;
670 break;
671 }
672
673 default :
674 ret = v4l_compat_translate_ioctl(inode,file,cmd,
675 arg,pvr2_v4l2_do_ioctl);
676 }
677
678 pvr2_hdw_commit_ctl(hdw);
679
680 if (ret < 0) {
681 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
682 pvr2_trace(PVR2_TRACE_V4LIOCTL,
683 "pvr2_v4l2_do_ioctl failure, ret=%d",ret);
684 } else {
685 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
686 pvr2_trace(PVR2_TRACE_V4LIOCTL,
687 "pvr2_v4l2_do_ioctl failure, ret=%d"
688 " command was:",ret);
689 v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),
690 cmd);
691 }
692 }
693 } else {
694 pvr2_trace(PVR2_TRACE_V4LIOCTL,
695 "pvr2_v4l2_do_ioctl complete, ret=%d (0x%x)",
696 ret,ret);
697 }
698 return ret;
699}
700
701
702static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
703{
704 pvr2_trace(PVR2_TRACE_INIT,
705 "unregistering device video%d [%s]",
706 dip->vdev->minor,pvr2_config_get_name(dip->config));
707 if (dip->ctxt_idx >= 0) {
708 mutex_lock(&device_lock);
709 devices[dip->ctxt_idx] = NULL;
710 dip->ctxt_idx = -1;
711 mutex_unlock(&device_lock);
712 }
713 video_unregister_device(dip->vdev);
714}
715
716
717static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
718{
719 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,-1);
720 pvr2_v4l2_dev_destroy(&vp->video_dev);
721
722 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp);
723 pvr2_channel_done(&vp->channel);
724 kfree(vp);
725}
726
727
728void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
729{
730 struct pvr2_v4l2 *vp;
731 vp = container_of(chp,struct pvr2_v4l2,channel);
732 if (!vp->channel.mc_head->disconnect_flag) return;
733 if (vp->vfirst) return;
734 pvr2_v4l2_destroy_no_lock(vp);
735}
736
737
738int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
739 unsigned int cmd, unsigned long arg)
740{
741
742/* Temporary hack : use ivtv api until a v4l2 one is available. */
743#define IVTV_IOC_G_CODEC 0xFFEE7703
744#define IVTV_IOC_S_CODEC 0xFFEE7704
745 if (cmd == IVTV_IOC_G_CODEC || cmd == IVTV_IOC_S_CODEC) return 0;
746 return video_usercopy(inode, file, cmd, arg, pvr2_v4l2_do_ioctl);
747}
748
749
750int pvr2_v4l2_release(struct inode *inode, struct file *file)
751{
752 struct pvr2_v4l2_fh *fhp = file->private_data;
753 struct pvr2_v4l2 *vp = fhp->vhead;
754 struct pvr2_context *mp = fhp->vhead->channel.mc_head;
755
756 pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_release");
757
758 if (fhp->rhp) {
759 struct pvr2_stream *sp;
760 struct pvr2_hdw *hdw;
761 hdw = fhp->channel.mc_head->hdw;
762 pvr2_hdw_set_streaming(hdw,0);
763 sp = pvr2_ioread_get_stream(fhp->rhp);
764 if (sp) pvr2_stream_set_callback(sp,0,0);
765 pvr2_ioread_destroy(fhp->rhp);
766 fhp->rhp = 0;
767 }
768 v4l2_prio_close(&vp->prio, &fhp->prio);
769 file->private_data = NULL;
770
771 pvr2_context_enter(mp); do {
772 if (fhp->vnext) {
773 fhp->vnext->vprev = fhp->vprev;
774 } else {
775 vp->vlast = fhp->vprev;
776 }
777 if (fhp->vprev) {
778 fhp->vprev->vnext = fhp->vnext;
779 } else {
780 vp->vfirst = fhp->vnext;
781 }
782 fhp->vnext = 0;
783 fhp->vprev = 0;
784 fhp->vhead = 0;
785 pvr2_channel_done(&fhp->channel);
786 pvr2_trace(PVR2_TRACE_STRUCT,
787 "Destroying pvr_v4l2_fh id=%p",fhp);
788 kfree(fhp);
789 if (vp->channel.mc_head->disconnect_flag && !vp->vfirst) {
790 pvr2_v4l2_destroy_no_lock(vp);
791 }
792 } while (0); pvr2_context_exit(mp);
793 return 0;
794}
795
796
797int pvr2_v4l2_open(struct inode *inode, struct file *file)
798{
799 struct pvr2_v4l2_dev *dip = 0; /* Our own context pointer */
800 struct pvr2_v4l2_fh *fhp;
801 struct pvr2_v4l2 *vp;
802 struct pvr2_hdw *hdw;
803
804 mutex_lock(&device_lock);
805 /* MCI 7-Jun-2006 Even though we're just doing what amounts to an
806 atomic read of the device mapping array here, we still need the
807 mutex. The problem is that there is a tiny race possible when
808 we register the device. We can't update the device mapping
809 array until after the device has been registered, owing to the
810 fact that we can't know the minor device number until after the
811 registration succeeds. And if another thread tries to open the
812 device in the window of time after registration but before the
813 map is updated, then it will get back an erroneous null pointer
814 and the open will result in a spurious failure. The only way to
815 prevent that is to (a) be inside the mutex here before we access
816 the array, and (b) cover the entire registration process later
817 on with this same mutex. Thus if we get inside the mutex here,
818 then we can be assured that the registration process actually
819 completed correctly. This is an unhappy complication from the
820 use of global data in a driver that lives in a preemptible
821 environment. It sure would be nice if the video device itself
822 had a means for storing and retrieving a local context pointer.
823 Oh wait. It did. But now it's gone. Silly me. */
824 {
825 unsigned int midx = iminor(file->f_dentry->d_inode);
826 if (midx < sizeof(devices)/sizeof(devices[0])) {
827 dip = devices[midx];
828 }
829 }
830 mutex_unlock(&device_lock);
831
832 if (!dip) return -ENODEV; /* Should be impossible but I'm paranoid */
833
834 vp = dip->v4lp;
835 hdw = vp->channel.hdw;
836
837 pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_open");
838
839 if (!pvr2_hdw_dev_ok(hdw)) {
840 pvr2_trace(PVR2_TRACE_OPEN_CLOSE,
841 "pvr2_v4l2_open: hardware not ready");
842 return -EIO;
843 }
844
845 fhp = kmalloc(sizeof(*fhp),GFP_KERNEL);
846 if (!fhp) {
847 return -ENOMEM;
848 }
849 memset(fhp,0,sizeof(*fhp));
850
851 init_waitqueue_head(&fhp->wait_data);
852 fhp->dev_info = dip;
853
854 pvr2_context_enter(vp->channel.mc_head); do {
855 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp);
856 pvr2_channel_init(&fhp->channel,vp->channel.mc_head);
857 fhp->vnext = 0;
858 fhp->vprev = vp->vlast;
859 if (vp->vlast) {
860 vp->vlast->vnext = fhp;
861 } else {
862 vp->vfirst = fhp;
863 }
864 vp->vlast = fhp;
865 fhp->vhead = vp;
866 } while (0); pvr2_context_exit(vp->channel.mc_head);
867
868 fhp->file = file;
869 file->private_data = fhp;
870 v4l2_prio_open(&vp->prio,&fhp->prio);
871
872 fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
873
874 return 0;
875}
876
877
878static void pvr2_v4l2_notify(struct pvr2_v4l2_fh *fhp)
879{
880 wake_up(&fhp->wait_data);
881}
882
883static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
884{
885 int ret;
886 struct pvr2_stream *sp;
887 struct pvr2_hdw *hdw;
888 if (fh->rhp) return 0;
889
890 /* First read() attempt. Try to claim the stream and start
891 it... */
892 if ((ret = pvr2_channel_claim_stream(&fh->channel,
893 fh->dev_info->stream)) != 0) {
894 /* Someone else must already have it */
895 return ret;
896 }
897
898 fh->rhp = pvr2_channel_create_mpeg_stream(fh->dev_info->stream);
899 if (!fh->rhp) {
900 pvr2_channel_claim_stream(&fh->channel,0);
901 return -ENOMEM;
902 }
903
904 hdw = fh->channel.mc_head->hdw;
905 sp = fh->dev_info->stream->stream;
906 pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
907 pvr2_hdw_set_stream_type(hdw,fh->dev_info->config);
908 pvr2_hdw_set_streaming(hdw,!0);
909 ret = pvr2_ioread_set_enabled(fh->rhp,!0);
910
911 return ret;
912}
913
914
915static ssize_t pvr2_v4l2_read(struct file *file,
916 char __user *buff, size_t count, loff_t *ppos)
917{
918 struct pvr2_v4l2_fh *fh = file->private_data;
919 int ret;
920
921 if (fh->fw_mode_flag) {
922 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
923 char *tbuf;
924 int c1,c2;
925 int tcnt = 0;
926 unsigned int offs = *ppos;
927
928 tbuf = kmalloc(PAGE_SIZE,GFP_KERNEL);
929 if (!tbuf) return -ENOMEM;
930
931 while (count) {
932 c1 = count;
933 if (c1 > PAGE_SIZE) c1 = PAGE_SIZE;
934 c2 = pvr2_hdw_cpufw_get(hdw,offs,tbuf,c1);
935 if (c2 < 0) {
936 tcnt = c2;
937 break;
938 }
939 if (!c2) break;
940 if (copy_to_user(buff,tbuf,c2)) {
941 tcnt = -EFAULT;
942 break;
943 }
944 offs += c2;
945 tcnt += c2;
946 buff += c2;
947 count -= c2;
948 *ppos += c2;
949 }
950 kfree(tbuf);
951 return tcnt;
952 }
953
954 if (!fh->rhp) {
955 ret = pvr2_v4l2_iosetup(fh);
956 if (ret) {
957 return ret;
958 }
959 }
960
961 for (;;) {
962 ret = pvr2_ioread_read(fh->rhp,buff,count);
963 if (ret >= 0) break;
964 if (ret != -EAGAIN) break;
965 if (file->f_flags & O_NONBLOCK) break;
966 /* Doing blocking I/O. Wait here. */
967 ret = wait_event_interruptible(
968 fh->wait_data,
969 pvr2_ioread_avail(fh->rhp) >= 0);
970 if (ret < 0) break;
971 }
972
973 return ret;
974}
975
976
977static unsigned int pvr2_v4l2_poll(struct file *file, poll_table *wait)
978{
979 unsigned int mask = 0;
980 struct pvr2_v4l2_fh *fh = file->private_data;
981 int ret;
982
983 if (fh->fw_mode_flag) {
984 mask |= POLLIN | POLLRDNORM;
985 return mask;
986 }
987
988 if (!fh->rhp) {
989 ret = pvr2_v4l2_iosetup(fh);
990 if (ret) return POLLERR;
991 }
992
993 poll_wait(file,&fh->wait_data,wait);
994
995 if (pvr2_ioread_avail(fh->rhp) >= 0) {
996 mask |= POLLIN | POLLRDNORM;
997 }
998
999 return mask;
1000}
1001
1002
1003static struct file_operations vdev_fops = {
1004 .owner = THIS_MODULE,
1005 .open = pvr2_v4l2_open,
1006 .release = pvr2_v4l2_release,
1007 .read = pvr2_v4l2_read,
1008 .ioctl = pvr2_v4l2_ioctl,
1009 .llseek = no_llseek,
1010 .poll = pvr2_v4l2_poll,
1011};
1012
1013
1014#define VID_HARDWARE_PVRUSB2 38 /* FIXME : need a good value */
1015
1016static struct video_device vdev_template = {
1017 .owner = THIS_MODULE,
1018 .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER,
1019 .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE
1020 | V4L2_CAP_TUNER | V4L2_CAP_AUDIO
1021 | V4L2_CAP_READWRITE),
1022 .hardware = VID_HARDWARE_PVRUSB2,
1023 .fops = &vdev_fops,
1024};
1025
1026
1027static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1028 struct pvr2_v4l2 *vp,
1029 enum pvr2_config cfg)
1030{
1031 int mindevnum;
1032 int unit_number;
1033 int v4l_type;
1034 dip->v4lp = vp;
1035 dip->config = cfg;
1036
1037
1038 switch (cfg) {
1039 case pvr2_config_mpeg:
1040 v4l_type = VFL_TYPE_GRABBER;
1041 dip->stream = &vp->channel.mc_head->video_stream;
1042 break;
1043 case pvr2_config_vbi:
1044 v4l_type = VFL_TYPE_VBI;
1045 break;
1046 case pvr2_config_radio:
1047 v4l_type = VFL_TYPE_RADIO;
1048 break;
1049 default:
1050 /* Bail out (this should be impossible) */
1051 err("Failed to set up pvrusb2 v4l dev"
1052 " due to unrecognized config");
1053 return;
1054 }
1055
1056 if (!dip->stream) {
1057 err("Failed to set up pvrusb2 v4l dev"
1058 " due to missing stream instance");
1059 return;
1060 }
1061
1062 dip->vdev = video_device_alloc();
1063 if (!dip->vdev) {
1064 err("Alloc of pvrusb2 v4l video device failed");
1065 return;
1066 }
1067
1068 memcpy(dip->vdev,&vdev_template,sizeof(vdev_template));
1069 dip->vdev->release = video_device_release;
1070 mutex_lock(&device_lock);
1071
1072 mindevnum = -1;
1073 unit_number = pvr2_hdw_get_unit_number(vp->channel.mc_head->hdw);
1074 if ((unit_number >= 0) && (unit_number < PVR_NUM)) {
1075 mindevnum = video_nr[unit_number];
1076 }
1077 if ((video_register_device(dip->vdev, v4l_type, mindevnum) < 0) &&
1078 (video_register_device(dip->vdev, v4l_type, -1) < 0)) {
1079 err("Failed to register pvrusb2 v4l video device");
1080 } else {
1081 pvr2_trace(PVR2_TRACE_INIT,
1082 "registered device video%d [%s]",
1083 dip->vdev->minor,pvr2_config_get_name(dip->config));
1084 }
1085
1086 if ((dip->vdev->minor < sizeof(devices)/sizeof(devices[0])) &&
1087 (devices[dip->vdev->minor] == NULL)) {
1088 dip->ctxt_idx = dip->vdev->minor;
1089 devices[dip->ctxt_idx] = dip;
1090 }
1091 mutex_unlock(&device_lock);
1092
1093 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
1094 dip->vdev->minor);
1095}
1096
1097
1098struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp)
1099{
1100 struct pvr2_v4l2 *vp;
1101
1102 vp = kmalloc(sizeof(*vp),GFP_KERNEL);
1103 if (!vp) return vp;
1104 memset(vp,0,sizeof(*vp));
1105 vp->video_dev.ctxt_idx = -1;
1106 pvr2_channel_init(&vp->channel,mnp);
1107 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp);
1108
1109 vp->channel.check_func = pvr2_v4l2_internal_check;
1110
1111 /* register streams */
1112 pvr2_v4l2_dev_init(&vp->video_dev,vp,pvr2_config_mpeg);
1113
1114
1115 return vp;
1116}
1117
1118/*
1119 Stuff for Emacs to see, in order to encourage consistent editing style:
1120 *** Local Variables: ***
1121 *** mode: c ***
1122 *** fill-column: 75 ***
1123 *** tab-width: 8 ***
1124 *** c-basic-offset: 8 ***
1125 *** End: ***
1126 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.h b/drivers/media/video/pvrusb2/pvrusb2-v4l2.h
new file mode 100644
index 000000000000..9a995e2d2256
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.h
@@ -0,0 +1,40 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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 __PVRUSB2_V4L2_H
22#define __PVRUSB2_V4L2_H
23
24#include "pvrusb2-context.h"
25
26struct pvr2_v4l2;
27
28struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *);
29
30#endif /* __PVRUSB2_V4L2_H */
31
32/*
33 Stuff for Emacs to see, in order to encourage consistent editing style:
34 *** Local Variables: ***
35 *** mode: c ***
36 *** fill-column: 75 ***
37 *** tab-width: 8 ***
38 *** c-basic-offset: 8 ***
39 *** End: ***
40 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
new file mode 100644
index 000000000000..e4ec7f25194c
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
@@ -0,0 +1,253 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23/*
24
25 This source file is specifically designed to interface with the
26 saa711x support that is available in the v4l available starting
27 with linux 2.6.15.
28
29*/
30
31#include "pvrusb2-video-v4l.h"
32#include "pvrusb2-i2c-cmd-v4l2.h"
33
34
35#include "pvrusb2-hdw-internal.h"
36#include "pvrusb2-debug.h"
37#include <linux/videodev2.h>
38#include <media/v4l2-common.h>
39#include <media/saa7115.h>
40#include <linux/errno.h>
41#include <linux/slab.h>
42
43struct pvr2_v4l_decoder {
44 struct pvr2_i2c_handler handler;
45 struct pvr2_decoder_ctrl ctrl;
46 struct pvr2_i2c_client *client;
47 struct pvr2_hdw *hdw;
48 unsigned long stale_mask;
49};
50
51
52static void set_input(struct pvr2_v4l_decoder *ctxt)
53{
54 struct pvr2_hdw *hdw = ctxt->hdw;
55 struct v4l2_routing route;
56
57 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 set_input(%d)",hdw->input_val);
58 switch(hdw->input_val) {
59 case PVR2_CVAL_INPUT_TV:
60 route.input = SAA7115_COMPOSITE4;
61 break;
62 case PVR2_CVAL_INPUT_COMPOSITE:
63 route.input = SAA7115_COMPOSITE5;
64 break;
65 case PVR2_CVAL_INPUT_SVIDEO:
66 route.input = SAA7115_SVIDEO2;
67 break;
68 case PVR2_CVAL_INPUT_RADIO:
69 // ????? No idea yet what to do here
70 default:
71 return;
72 }
73 route.output = 0;
74 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_VIDEO_ROUTING,&route);
75}
76
77
78static int check_input(struct pvr2_v4l_decoder *ctxt)
79{
80 struct pvr2_hdw *hdw = ctxt->hdw;
81 return hdw->input_dirty != 0;
82}
83
84
85static void set_audio(struct pvr2_v4l_decoder *ctxt)
86{
87 u32 val;
88 struct pvr2_hdw *hdw = ctxt->hdw;
89
90 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 set_audio %d",
91 hdw->srate_val);
92 switch (hdw->srate_val) {
93 default:
94 case V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000:
95 val = 48000;
96 break;
97 case V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100:
98 val = 44100;
99 break;
100 case V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000:
101 val = 32000;
102 break;
103 }
104 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_AUDIO_CLOCK_FREQ,&val);
105}
106
107
108static int check_audio(struct pvr2_v4l_decoder *ctxt)
109{
110 struct pvr2_hdw *hdw = ctxt->hdw;
111 return hdw->srate_dirty != 0;
112}
113
114
115struct pvr2_v4l_decoder_ops {
116 void (*update)(struct pvr2_v4l_decoder *);
117 int (*check)(struct pvr2_v4l_decoder *);
118};
119
120
121static const struct pvr2_v4l_decoder_ops decoder_ops[] = {
122 { .update = set_input, .check = check_input},
123 { .update = set_audio, .check = check_audio},
124};
125
126
127static void decoder_detach(struct pvr2_v4l_decoder *ctxt)
128{
129 ctxt->client->handler = 0;
130 ctxt->hdw->decoder_ctrl = 0;
131 kfree(ctxt);
132}
133
134
135static int decoder_check(struct pvr2_v4l_decoder *ctxt)
136{
137 unsigned long msk;
138 unsigned int idx;
139
140 for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
141 idx++) {
142 msk = 1 << idx;
143 if (ctxt->stale_mask & msk) continue;
144 if (decoder_ops[idx].check(ctxt)) {
145 ctxt->stale_mask |= msk;
146 }
147 }
148 return ctxt->stale_mask != 0;
149}
150
151
152static void decoder_update(struct pvr2_v4l_decoder *ctxt)
153{
154 unsigned long msk;
155 unsigned int idx;
156
157 for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
158 idx++) {
159 msk = 1 << idx;
160 if (!(ctxt->stale_mask & msk)) continue;
161 ctxt->stale_mask &= ~msk;
162 decoder_ops[idx].update(ctxt);
163 }
164}
165
166
167static int decoder_detect(struct pvr2_i2c_client *cp)
168{
169 /* Attempt to query the decoder - let's see if it will answer */
170 struct v4l2_tuner vt;
171 int ret;
172
173 memset(&vt,0,sizeof(vt));
174 ret = pvr2_i2c_client_cmd(cp,VIDIOC_G_TUNER,&vt);
175 return ret == 0; /* Return true if it answered */
176}
177
178
179static void decoder_enable(struct pvr2_v4l_decoder *ctxt,int fl)
180{
181 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 decoder_enable(%d)",fl);
182 pvr2_v4l2_cmd_stream(ctxt->client,fl);
183}
184
185
186static int decoder_is_tuned(struct pvr2_v4l_decoder *ctxt)
187{
188 struct v4l2_tuner vt;
189 int ret;
190
191 memset(&vt,0,sizeof(vt));
192 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_G_TUNER,&vt);
193 if (ret < 0) return -EINVAL;
194 return vt.signal ? 1 : 0;
195}
196
197
198static unsigned int decoder_describe(struct pvr2_v4l_decoder *ctxt,char *buf,unsigned int cnt)
199{
200 return scnprintf(buf,cnt,"handler: pvrusb2-video-v4l");
201}
202
203
204const static struct pvr2_i2c_handler_functions hfuncs = {
205 .detach = (void (*)(void *))decoder_detach,
206 .check = (int (*)(void *))decoder_check,
207 .update = (void (*)(void *))decoder_update,
208 .describe = (unsigned int (*)(void *,char *,unsigned int))decoder_describe,
209};
210
211
212int pvr2_i2c_decoder_v4l_setup(struct pvr2_hdw *hdw,
213 struct pvr2_i2c_client *cp)
214{
215 struct pvr2_v4l_decoder *ctxt;
216
217 if (hdw->decoder_ctrl) return 0;
218 if (cp->handler) return 0;
219 if (!decoder_detect(cp)) return 0;
220
221 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
222 if (!ctxt) return 0;
223 memset(ctxt,0,sizeof(*ctxt));
224
225 ctxt->handler.func_data = ctxt;
226 ctxt->handler.func_table = &hfuncs;
227 ctxt->ctrl.ctxt = ctxt;
228 ctxt->ctrl.detach = (void (*)(void *))decoder_detach;
229 ctxt->ctrl.enable = (void (*)(void *,int))decoder_enable;
230 ctxt->ctrl.tuned = (int (*)(void *))decoder_is_tuned;
231 ctxt->client = cp;
232 ctxt->hdw = hdw;
233 ctxt->stale_mask = (1 << (sizeof(decoder_ops)/
234 sizeof(decoder_ops[0]))) - 1;
235 hdw->decoder_ctrl = &ctxt->ctrl;
236 cp->handler = &ctxt->handler;
237 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x saa711x V4L2 handler set up",
238 cp->client->addr);
239 return !0;
240}
241
242
243
244
245/*
246 Stuff for Emacs to see, in order to encourage consistent editing style:
247 *** Local Variables: ***
248 *** mode: c ***
249 *** fill-column: 70 ***
250 *** tab-width: 8 ***
251 *** c-basic-offset: 8 ***
252 *** End: ***
253 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.h b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.h
new file mode 100644
index 000000000000..2b917fda02e4
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.h
@@ -0,0 +1,52 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_VIDEO_V4L_H
24#define __PVRUSB2_VIDEO_V4L_H
25
26/*
27
28 This module connects the pvrusb2 driver to the I2C chip level
29 driver which handles device video processing. This interface is
30 used internally by the driver; higher level code should only
31 interact through the interface provided by pvrusb2-hdw.h.
32
33*/
34
35
36
37#include "pvrusb2-i2c-core.h"
38
39int pvr2_i2c_decoder_v4l_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
40
41
42#endif /* __PVRUSB2_VIDEO_V4L_H */
43
44/*
45 Stuff for Emacs to see, in order to encourage consistent editing style:
46 *** Local Variables: ***
47 *** mode: c ***
48 *** fill-column: 70 ***
49 *** tab-width: 8 ***
50 *** c-basic-offset: 8 ***
51 *** End: ***
52 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
new file mode 100644
index 000000000000..fcad346e3955
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
@@ -0,0 +1,170 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23/*
24
25 This source file is specifically designed to interface with the
26 wm8775.
27
28*/
29
30#include "pvrusb2-wm8775.h"
31#include "pvrusb2-i2c-cmd-v4l2.h"
32
33
34#include "pvrusb2-hdw-internal.h"
35#include "pvrusb2-debug.h"
36#include <linux/videodev2.h>
37#include <media/v4l2-common.h>
38#include <linux/errno.h>
39#include <linux/slab.h>
40
41struct pvr2_v4l_wm8775 {
42 struct pvr2_i2c_handler handler;
43 struct pvr2_i2c_client *client;
44 struct pvr2_hdw *hdw;
45 unsigned long stale_mask;
46};
47
48
49static void set_input(struct pvr2_v4l_wm8775 *ctxt)
50{
51 struct v4l2_routing route;
52 struct pvr2_hdw *hdw = ctxt->hdw;
53 int msk = 0;
54
55 memset(&route,0,sizeof(route));
56
57 pvr2_trace(PVR2_TRACE_CHIPS,"i2c wm8775 set_input(val=%d msk=0x%x)",
58 hdw->input_val,msk);
59
60 // Always point to input #1 no matter what
61 route.input = 2;
62 pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route);
63}
64
65static int check_input(struct pvr2_v4l_wm8775 *ctxt)
66{
67 struct pvr2_hdw *hdw = ctxt->hdw;
68 return hdw->input_dirty != 0;
69}
70
71
72struct pvr2_v4l_wm8775_ops {
73 void (*update)(struct pvr2_v4l_wm8775 *);
74 int (*check)(struct pvr2_v4l_wm8775 *);
75};
76
77
78static const struct pvr2_v4l_wm8775_ops wm8775_ops[] = {
79 { .update = set_input, .check = check_input},
80};
81
82
83static unsigned int wm8775_describe(struct pvr2_v4l_wm8775 *ctxt,
84 char *buf,unsigned int cnt)
85{
86 return scnprintf(buf,cnt,"handler: pvrusb2-wm8775");
87}
88
89
90static void wm8775_detach(struct pvr2_v4l_wm8775 *ctxt)
91{
92 ctxt->client->handler = 0;
93 kfree(ctxt);
94}
95
96
97static int wm8775_check(struct pvr2_v4l_wm8775 *ctxt)
98{
99 unsigned long msk;
100 unsigned int idx;
101
102 for (idx = 0; idx < sizeof(wm8775_ops)/sizeof(wm8775_ops[0]);
103 idx++) {
104 msk = 1 << idx;
105 if (ctxt->stale_mask & msk) continue;
106 if (wm8775_ops[idx].check(ctxt)) {
107 ctxt->stale_mask |= msk;
108 }
109 }
110 return ctxt->stale_mask != 0;
111}
112
113
114static void wm8775_update(struct pvr2_v4l_wm8775 *ctxt)
115{
116 unsigned long msk;
117 unsigned int idx;
118
119 for (idx = 0; idx < sizeof(wm8775_ops)/sizeof(wm8775_ops[0]);
120 idx++) {
121 msk = 1 << idx;
122 if (!(ctxt->stale_mask & msk)) continue;
123 ctxt->stale_mask &= ~msk;
124 wm8775_ops[idx].update(ctxt);
125 }
126}
127
128
129const static struct pvr2_i2c_handler_functions hfuncs = {
130 .detach = (void (*)(void *))wm8775_detach,
131 .check = (int (*)(void *))wm8775_check,
132 .update = (void (*)(void *))wm8775_update,
133 .describe = (unsigned int (*)(void *,char *,unsigned int))wm8775_describe,
134};
135
136
137int pvr2_i2c_wm8775_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
138{
139 struct pvr2_v4l_wm8775 *ctxt;
140
141 if (cp->handler) return 0;
142
143 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
144 if (!ctxt) return 0;
145 memset(ctxt,0,sizeof(*ctxt));
146
147 ctxt->handler.func_data = ctxt;
148 ctxt->handler.func_table = &hfuncs;
149 ctxt->client = cp;
150 ctxt->hdw = hdw;
151 ctxt->stale_mask = (1 << (sizeof(wm8775_ops)/
152 sizeof(wm8775_ops[0]))) - 1;
153 cp->handler = &ctxt->handler;
154 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x wm8775 V4L2 handler set up",
155 cp->client->addr);
156 return !0;
157}
158
159
160
161
162/*
163 Stuff for Emacs to see, in order to encourage consistent editing style:
164 *** Local Variables: ***
165 *** mode: c ***
166 *** fill-column: 70 ***
167 *** tab-width: 8 ***
168 *** c-basic-offset: 8 ***
169 *** End: ***
170 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.h b/drivers/media/video/pvrusb2/pvrusb2-wm8775.h
new file mode 100644
index 000000000000..8aaeff4e1e20
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.h
@@ -0,0 +1,53 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_WM8775_H
24#define __PVRUSB2_WM8775_H
25
26/*
27
28 This module connects the pvrusb2 driver to the I2C chip level
29 driver which performs analog -> digital audio conversion for
30 external audio inputs. This interface is used internally by the
31 driver; higher level code should only interact through the
32 interface provided by pvrusb2-hdw.h.
33
34*/
35
36
37
38#include "pvrusb2-i2c-core.h"
39
40int pvr2_i2c_wm8775_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
41
42
43#endif /* __PVRUSB2_WM8775_H */
44
45/*
46 Stuff for Emacs to see, in order to encourage consistent editing style:
47 *** Local Variables: ***
48 *** mode: c ***
49 *** fill-column: 70 ***
50 *** tab-width: 8 ***
51 *** c-basic-offset: 8 ***
52 *** End: ***
53 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2.h b/drivers/media/video/pvrusb2/pvrusb2.h
new file mode 100644
index 000000000000..074533e9c21e
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2.h
@@ -0,0 +1,43 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __PVRUSB2_H
24#define __PVRUSB2_H
25
26/* Maximum number of pvrusb2 instances we can track at once. You
27 might want to increase this - however the driver operation will not
28 be impaired if it is too small. Instead additional units just
29 won't have an ID assigned and it might not be possible to specify
30 module paramters for those extra units. */
31#define PVR_NUM 20
32
33#endif /* __PVRUSB2_H */
34
35/*
36 Stuff for Emacs to see, in order to encourage consistent editing style:
37 *** Local Variables: ***
38 *** mode: c ***
39 *** fill-column: 70 ***
40 *** tab-width: 8 ***
41 *** c-basic-offset: 8 ***
42 *** End: ***
43 */
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index de7b9e6e932a..afc8f352b8e7 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -432,10 +432,10 @@ static void saa6752hs_old_set_params(struct i2c_client* client,
432} 432}
433 433
434static int handle_ctrl(struct saa6752hs_mpeg_params *params, 434static int handle_ctrl(struct saa6752hs_mpeg_params *params,
435 struct v4l2_ext_control *ctrl, int cmd) 435 struct v4l2_ext_control *ctrl, unsigned int cmd)
436{ 436{
437 int old = 0, new; 437 int old = 0, new;
438 int set = cmd == VIDIOC_S_EXT_CTRLS; 438 int set = (cmd == VIDIOC_S_EXT_CTRLS);
439 439
440 new = ctrl->value; 440 new = ctrl->value;
441 switch (ctrl->id) { 441 switch (ctrl->id) {
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index f0c2111f14ad..da3007d2f411 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -871,9 +871,9 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
871 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev); 871 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
872 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); 872 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
873 printk(KERN_INFO "%s: found at %s, rev: %d, irq: %d, " 873 printk(KERN_INFO "%s: found at %s, rev: %d, irq: %d, "
874 "latency: %d, mmio: 0x%lx\n", dev->name, 874 "latency: %d, mmio: 0x%llx\n", dev->name,
875 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, 875 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
876 dev->pci_lat,pci_resource_start(pci_dev,0)); 876 dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
877 pci_set_master(pci_dev); 877 pci_set_master(pci_dev);
878 if (!pci_dma_supported(pci_dev, DMA_32BIT_MASK)) { 878 if (!pci_dma_supported(pci_dev, DMA_32BIT_MASK)) {
879 printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name); 879 printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name);
@@ -905,8 +905,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
905 pci_resource_len(pci_dev,0), 905 pci_resource_len(pci_dev,0),
906 dev->name)) { 906 dev->name)) {
907 err = -EBUSY; 907 err = -EBUSY;
908 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%lx\n", 908 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n",
909 dev->name,pci_resource_start(pci_dev,0)); 909 dev->name,(unsigned long long)pci_resource_start(pci_dev,0));
910 goto fail1; 910 goto fail1;
911 } 911 }
912 dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000); 912 dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000);
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 6be9c1131e1f..c18b31d9928c 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -2190,7 +2190,7 @@ static struct pci_driver stradis_driver = {
2190 .remove = __devexit_p(stradis_remove) 2190 .remove = __devexit_p(stradis_remove)
2191}; 2191};
2192 2192
2193int __init stradis_init(void) 2193static int __init stradis_init(void)
2194{ 2194{
2195 int retval; 2195 int retval;
2196 2196
@@ -2203,7 +2203,7 @@ int __init stradis_init(void)
2203 return retval; 2203 return retval;
2204} 2204}
2205 2205
2206void __exit stradis_exit(void) 2206static void __exit stradis_exit(void)
2207{ 2207{
2208 pci_unregister_driver(&stradis_driver); 2208 pci_unregister_driver(&stradis_driver);
2209 printk(KERN_INFO "stradis: module cleanup complete\n"); 2209 printk(KERN_INFO "stradis: module cleanup complete\n");
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index b6ae969563b2..2fadabf99688 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -22,11 +22,11 @@
22*/ 22*/
23 23
24#define tda9887_info(fmt, arg...) do {\ 24#define tda9887_info(fmt, arg...) do {\
25 printk(KERN_INFO "%s %d-%04x (tda9887): " fmt, t->i2c.name, \ 25 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \
26 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 26 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
27#define tda9887_dbg(fmt, arg...) do {\ 27#define tda9887_dbg(fmt, arg...) do {\
28 if (tuner_debug) \ 28 if (tuner_debug) \
29 printk(KERN_INFO "%s %d-%04x (tda9887): " fmt, t->i2c.name, \ 29 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \
30 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 30 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
31 31
32 32
@@ -84,8 +84,7 @@ struct tvnorm {
84#define cAudioGain6 0x80 // bit c7 84#define cAudioGain6 0x80 // bit c7
85 85
86#define cTopMask 0x1f // bit c0:4 86#define cTopMask 0x1f // bit c0:4
87#define cTopPalSecamDefault 0x14 // bit c0:4 87#define cTopDefault 0x10 // bit c0:4
88#define cTopNtscRadioDefault 0x10 // bit c0:4
89 88
90//// third reg (e) 89//// third reg (e)
91#define cAudioIF_4_5 0x00 // bit e0:1 90#define cAudioIF_4_5 0x00 // bit e0:1
@@ -123,7 +122,7 @@ static struct tvnorm tvnorms[] = {
123 cQSS ), 122 cQSS ),
124 .c = ( cDeemphasisON | 123 .c = ( cDeemphasisON |
125 cDeemphasis50 | 124 cDeemphasis50 |
126 cTopPalSecamDefault), 125 cTopDefault),
127 .e = ( cGating_36 | 126 .e = ( cGating_36 |
128 cAudioIF_5_5 | 127 cAudioIF_5_5 |
129 cVideoIF_38_90 ), 128 cVideoIF_38_90 ),
@@ -134,7 +133,7 @@ static struct tvnorm tvnorms[] = {
134 cQSS ), 133 cQSS ),
135 .c = ( cDeemphasisON | 134 .c = ( cDeemphasisON |
136 cDeemphasis50 | 135 cDeemphasis50 |
137 cTopPalSecamDefault), 136 cTopDefault),
138 .e = ( cGating_36 | 137 .e = ( cGating_36 |
139 cAudioIF_6_0 | 138 cAudioIF_6_0 |
140 cVideoIF_38_90 ), 139 cVideoIF_38_90 ),
@@ -145,7 +144,7 @@ static struct tvnorm tvnorms[] = {
145 cQSS ), 144 cQSS ),
146 .c = ( cDeemphasisON | 145 .c = ( cDeemphasisON |
147 cDeemphasis50 | 146 cDeemphasis50 |
148 cTopPalSecamDefault), 147 cTopDefault),
149 .e = ( cGating_36 | 148 .e = ( cGating_36 |
150 cAudioIF_6_5 | 149 cAudioIF_6_5 |
151 cVideoIF_38_90 ), 150 cVideoIF_38_90 ),
@@ -156,7 +155,7 @@ static struct tvnorm tvnorms[] = {
156 cQSS ), 155 cQSS ),
157 .c = ( cDeemphasisON | 156 .c = ( cDeemphasisON |
158 cDeemphasis75 | 157 cDeemphasis75 |
159 cTopNtscRadioDefault), 158 cTopDefault),
160 .e = ( cGating_36 | 159 .e = ( cGating_36 |
161 cAudioIF_4_5 | 160 cAudioIF_4_5 |
162 cVideoIF_45_75 ), 161 cVideoIF_45_75 ),
@@ -165,7 +164,7 @@ static struct tvnorm tvnorms[] = {
165 .name = "SECAM-BGH", 164 .name = "SECAM-BGH",
166 .b = ( cPositiveAmTV | 165 .b = ( cPositiveAmTV |
167 cQSS ), 166 cQSS ),
168 .c = ( cTopPalSecamDefault), 167 .c = ( cTopDefault),
169 .e = ( cGating_36 | 168 .e = ( cGating_36 |
170 cAudioIF_5_5 | 169 cAudioIF_5_5 |
171 cVideoIF_38_90 ), 170 cVideoIF_38_90 ),
@@ -174,7 +173,7 @@ static struct tvnorm tvnorms[] = {
174 .name = "SECAM-L", 173 .name = "SECAM-L",
175 .b = ( cPositiveAmTV | 174 .b = ( cPositiveAmTV |
176 cQSS ), 175 cQSS ),
177 .c = ( cTopPalSecamDefault), 176 .c = ( cTopDefault),
178 .e = ( cGating_36 | 177 .e = ( cGating_36 |
179 cAudioIF_6_5 | 178 cAudioIF_6_5 |
180 cVideoIF_38_90 ), 179 cVideoIF_38_90 ),
@@ -184,7 +183,7 @@ static struct tvnorm tvnorms[] = {
184 .b = ( cOutputPort2Inactive | 183 .b = ( cOutputPort2Inactive |
185 cPositiveAmTV | 184 cPositiveAmTV |
186 cQSS ), 185 cQSS ),
187 .c = ( cTopPalSecamDefault), 186 .c = ( cTopDefault),
188 .e = ( cGating_36 | 187 .e = ( cGating_36 |
189 cAudioIF_6_5 | 188 cAudioIF_6_5 |
190 cVideoIF_33_90 ), 189 cVideoIF_33_90 ),
@@ -195,7 +194,7 @@ static struct tvnorm tvnorms[] = {
195 cQSS ), 194 cQSS ),
196 .c = ( cDeemphasisON | 195 .c = ( cDeemphasisON |
197 cDeemphasis50 | 196 cDeemphasis50 |
198 cTopPalSecamDefault), 197 cTopDefault),
199 .e = ( cGating_36 | 198 .e = ( cGating_36 |
200 cAudioIF_6_5 | 199 cAudioIF_6_5 |
201 cVideoIF_38_90 ), 200 cVideoIF_38_90 ),
@@ -206,7 +205,7 @@ static struct tvnorm tvnorms[] = {
206 cQSS ), 205 cQSS ),
207 .c = ( cDeemphasisON | 206 .c = ( cDeemphasisON |
208 cDeemphasis75 | 207 cDeemphasis75 |
209 cTopNtscRadioDefault), 208 cTopDefault),
210 .e = ( cGating_36 | 209 .e = ( cGating_36 |
211 cAudioIF_4_5 | 210 cAudioIF_4_5 |
212 cVideoIF_45_75 ), 211 cVideoIF_45_75 ),
@@ -217,7 +216,7 @@ static struct tvnorm tvnorms[] = {
217 cQSS ), 216 cQSS ),
218 .c = ( cDeemphasisON | 217 .c = ( cDeemphasisON |
219 cDeemphasis50 | 218 cDeemphasis50 |
220 cTopNtscRadioDefault), 219 cTopDefault),
221 .e = ( cGating_36 | 220 .e = ( cGating_36 |
222 cAudioIF_4_5 | 221 cAudioIF_4_5 |
223 cVideoIF_58_75 ), 222 cVideoIF_58_75 ),
@@ -230,7 +229,7 @@ static struct tvnorm radio_stereo = {
230 cQSS ), 229 cQSS ),
231 .c = ( cDeemphasisOFF | 230 .c = ( cDeemphasisOFF |
232 cAudioGain6 | 231 cAudioGain6 |
233 cTopNtscRadioDefault), 232 cTopDefault),
234 .e = ( cTunerGainLow | 233 .e = ( cTunerGainLow |
235 cAudioIF_5_5 | 234 cAudioIF_5_5 |
236 cRadioIF_38_90 ), 235 cRadioIF_38_90 ),
@@ -242,7 +241,7 @@ static struct tvnorm radio_mono = {
242 cQSS ), 241 cQSS ),
243 .c = ( cDeemphasisON | 242 .c = ( cDeemphasisON |
244 cDeemphasis75 | 243 cDeemphasis75 |
245 cTopNtscRadioDefault), 244 cTopDefault),
246 .e = ( cTunerGainLow | 245 .e = ( cTunerGainLow |
247 cAudioIF_5_5 | 246 cAudioIF_5_5 |
248 cRadioIF_38_90 ), 247 cRadioIF_38_90 ),
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index a26ded7d6fae..011413cf34a8 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -40,7 +40,6 @@ static unsigned int no_autodetect = 0;
40static unsigned int show_i2c = 0; 40static unsigned int show_i2c = 0;
41 41
42/* insmod options used at runtime => read/write */ 42/* insmod options used at runtime => read/write */
43static unsigned int tuner_debug_old = 0;
44int tuner_debug = 0; 43int tuner_debug = 0;
45 44
46static unsigned int tv_range[2] = { 44, 958 }; 45static unsigned int tv_range[2] = { 44, 958 };
@@ -54,8 +53,6 @@ static char ntsc[] = "-";
54module_param(addr, int, 0444); 53module_param(addr, int, 0444);
55module_param(no_autodetect, int, 0444); 54module_param(no_autodetect, int, 0444);
56module_param(show_i2c, int, 0444); 55module_param(show_i2c, int, 0444);
57/* Note: tuner_debug is deprecated and will be removed in 2.6.17 */
58module_param_named(tuner_debug,tuner_debug_old, int, 0444);
59module_param_named(debug,tuner_debug, int, 0644); 56module_param_named(debug,tuner_debug, int, 0644);
60module_param_string(pal, pal, sizeof(pal), 0644); 57module_param_string(pal, pal, sizeof(pal), 0644);
61module_param_string(secam, secam, sizeof(secam), 0644); 58module_param_string(secam, secam, sizeof(secam), 0644);
@@ -442,11 +439,6 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
442 t->audmode = V4L2_TUNER_MODE_STEREO; 439 t->audmode = V4L2_TUNER_MODE_STEREO;
443 t->mode_mask = T_UNINITIALIZED; 440 t->mode_mask = T_UNINITIALIZED;
444 t->tuner_status = tuner_status; 441 t->tuner_status = tuner_status;
445 if (tuner_debug_old) {
446 tuner_debug = tuner_debug_old;
447 printk(KERN_ERR "tuner: tuner_debug is deprecated and will be removed in 2.6.17.\n");
448 printk(KERN_ERR "tuner: use the debug option instead.\n");
449 }
450 442
451 if (show_i2c) { 443 if (show_i2c) {
452 unsigned char buffer[16]; 444 unsigned char buffer[16];
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index f4b3d64ebf73..97f946db8597 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -1103,7 +1103,7 @@ const char **v4l2_ctrl_get_menu(u32 id)
1103 }; 1103 };
1104 static const char *mpeg_stream_vbi_fmt[] = { 1104 static const char *mpeg_stream_vbi_fmt[] = {
1105 "No VBI", 1105 "No VBI",
1106 "VBI in private packets, IVTV format", 1106 "Private packet, IVTV format",
1107 NULL 1107 NULL
1108 }; 1108 };
1109 1109
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 2dfa7f23d0ca..b26ebaff226f 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -37,7 +37,6 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/kmod.h> 38#include <linux/kmod.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/devfs_fs_kernel.h>
41#include <asm/uaccess.h> 40#include <asm/uaccess.h>
42#include <asm/system.h> 41#include <asm/system.h>
43 42
@@ -1563,10 +1562,6 @@ int video_register_device(struct video_device *vfd, int type, int nr)
1563 video_device[i]=vfd; 1562 video_device[i]=vfd;
1564 vfd->minor=i; 1563 vfd->minor=i;
1565 mutex_unlock(&videodev_lock); 1564 mutex_unlock(&videodev_lock);
1566
1567 sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base);
1568 devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor),
1569 S_IFCHR | S_IRUSR | S_IWUSR, vfd->devfs_name);
1570 mutex_init(&vfd->lock); 1565 mutex_init(&vfd->lock);
1571 1566
1572 /* sysfs class */ 1567 /* sysfs class */
@@ -1575,7 +1570,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
1575 vfd->class_dev.dev = vfd->dev; 1570 vfd->class_dev.dev = vfd->dev;
1576 vfd->class_dev.class = &video_class; 1571 vfd->class_dev.class = &video_class;
1577 vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); 1572 vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
1578 strlcpy(vfd->class_dev.class_id, vfd->devfs_name + 4, BUS_ID_SIZE); 1573 sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base);
1579 class_device_register(&vfd->class_dev); 1574 class_device_register(&vfd->class_dev);
1580 class_device_create_file(&vfd->class_dev, 1575 class_device_create_file(&vfd->class_dev,
1581 &class_device_attr_name); 1576 &class_device_attr_name);
@@ -1604,7 +1599,6 @@ void video_unregister_device(struct video_device *vfd)
1604 if(video_device[vfd->minor]!=vfd) 1599 if(video_device[vfd->minor]!=vfd)
1605 panic("videodev: bad unregister"); 1600 panic("videodev: bad unregister");
1606 1601
1607 devfs_remove(vfd->devfs_name);
1608 video_device[vfd->minor]=NULL; 1602 video_device[vfd->minor]=NULL;
1609 class_device_unregister(&vfd->class_dev); 1603 class_device_unregister(&vfd->class_dev);
1610 mutex_unlock(&videodev_lock); 1604 mutex_unlock(&videodev_lock);
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 74714e5bcf03..3ff8378ea660 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port,
305 } 305 }
306 306
307 out: 307 out:
308 if (pp0_array) 308 kfree(pp0_array);
309 kfree(pp0_array); 309 kfree(p0_array);
310 if (p0_array)
311 kfree(p0_array);
312 return rc; 310 return rc;
313} 311}
314 312
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index af6ec553ff7c..85689ab46cbc 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1378 return 0; 1378 return 0;
1379 1379
1380 out_free_port_info: 1380 out_free_port_info:
1381 if (hba) 1381 kfree(hba);
1382 kfree(hba);
1383 out: 1382 out:
1384 return error; 1383 return error;
1385} 1384}
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 7d4c5497785b..1ddc2fb429d5 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -1089,7 +1089,6 @@ static int i2o_block_probe(struct device *dev)
1089 gd = i2o_blk_dev->gd; 1089 gd = i2o_blk_dev->gd;
1090 gd->first_minor = unit << 4; 1090 gd->first_minor = unit << 4;
1091 sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit); 1091 sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit);
1092 sprintf(gd->devfs_name, "i2o/hd%c", 'a' + unit);
1093 gd->driverfs_dev = &i2o_dev->device; 1092 gd->driverfs_dev = &i2o_dev->device;
1094 1093
1095 /* setup request queue */ 1094 /* setup request queue */
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index febbdd4e0605..3305c12372a2 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -683,9 +683,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
683 c->mem_alloc = 1; 683 c->mem_alloc = 1;
684 sb->current_mem_size = 1 + res->end - res->start; 684 sb->current_mem_size = 1 + res->end - res->start;
685 sb->current_mem_base = res->start; 685 sb->current_mem_base = res->start;
686 osm_info("%s: allocated %ld bytes of PCI memory at " 686 osm_info("%s: allocated %llu bytes of PCI memory at "
687 "0x%08lX.\n", c->name, 687 "0x%016llX.\n", c->name,
688 1 + res->end - res->start, res->start); 688 (unsigned long long)(1 + res->end - res->start),
689 (unsigned long long)res->start);
689 } 690 }
690 } 691 }
691 692
@@ -704,9 +705,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
704 c->io_alloc = 1; 705 c->io_alloc = 1;
705 sb->current_io_size = 1 + res->end - res->start; 706 sb->current_io_size = 1 + res->end - res->start;
706 sb->current_mem_base = res->start; 707 sb->current_mem_base = res->start;
707 osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX" 708 osm_info("%s: allocated %llu bytes of PCI I/O at "
708 ".\n", c->name, 1 + res->end - res->start, 709 "0x%016llX.\n", c->name,
709 res->start); 710 (unsigned long long)(1 + res->end - res->start),
711 (unsigned long long)res->start);
710 } 712 }
711 } 713 }
712 714
@@ -1239,7 +1241,6 @@ EXPORT_SYMBOL(i2o_cntxt_list_remove);
1239EXPORT_SYMBOL(i2o_cntxt_list_get_ptr); 1241EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
1240#endif 1242#endif
1241EXPORT_SYMBOL(i2o_msg_get_wait); 1243EXPORT_SYMBOL(i2o_msg_get_wait);
1242EXPORT_SYMBOL(i2o_msg_nop);
1243EXPORT_SYMBOL(i2o_find_iop); 1244EXPORT_SYMBOL(i2o_find_iop);
1244EXPORT_SYMBOL(i2o_iop_find_device); 1245EXPORT_SYMBOL(i2o_iop_find_device);
1245EXPORT_SYMBOL(i2o_event_register); 1246EXPORT_SYMBOL(i2o_event_register);
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index 1fdf03fd2da7..9706cc19134a 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -85,7 +85,7 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
85 } 85 }
86 memset(sp, 0, sizeof(struct service_processor)); 86 memset(sp, 0, sizeof(struct service_processor));
87 87
88 sp->lock = SPIN_LOCK_UNLOCKED; 88 spin_lock_init(&sp->lock);
89 INIT_LIST_HEAD(&sp->command_queue); 89 INIT_LIST_HEAD(&sp->command_queue);
90 90
91 pci_set_drvdata(pdev, (void *)sp); 91 pci_set_drvdata(pdev, (void *)sp);
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index 587458b370b9..115cc21094b9 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -27,7 +27,6 @@
27#include <linux/hdreg.h> 27#include <linux/hdreg.h>
28#include <linux/kdev_t.h> 28#include <linux/kdev_t.h>
29#include <linux/blkdev.h> 29#include <linux/blkdev.h>
30#include <linux/devfs_fs_kernel.h>
31#include <linux/mutex.h> 30#include <linux/mutex.h>
32 31
33#include <linux/mmc/card.h> 32#include <linux/mmc/card.h>
@@ -409,7 +408,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
409 */ 408 */
410 409
411 sprintf(md->disk->disk_name, "mmcblk%d", devidx); 410 sprintf(md->disk->disk_name, "mmcblk%d", devidx);
412 sprintf(md->disk->devfs_name, "mmc/blk%d", devidx);
413 411
414 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); 412 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
415 413
@@ -555,7 +553,6 @@ static int __init mmc_blk_init(void)
555 if (major == 0) 553 if (major == 0)
556 major = res; 554 major = res;
557 555
558 devfs_mk_dir("mmc");
559 return mmc_register_driver(&mmc_driver); 556 return mmc_register_driver(&mmc_driver);
560 557
561 out: 558 out:
@@ -565,7 +562,6 @@ static int __init mmc_blk_init(void)
565static void __exit mmc_blk_exit(void) 562static void __exit mmc_blk_exit(void)
566{ 563{
567 mmc_unregister_driver(&mmc_driver); 564 mmc_unregister_driver(&mmc_driver);
568 devfs_remove("mmc");
569 unregister_blkdev(major, "mmc"); 565 unregister_blkdev(major, "mmc");
570} 566}
571 567
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index da8e4d7339cc..8576a65ca1c3 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -546,9 +546,9 @@ static int mmci_probe(struct amba_device *dev, void *id)
546 546
547 mmc_add_host(mmc); 547 mmc_add_host(mmc);
548 548
549 printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%08lx irq %d,%d\n", 549 printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n",
550 mmc_hostname(mmc), amba_rev(dev), amba_config(dev), 550 mmc_hostname(mmc), amba_rev(dev), amba_config(dev),
551 dev->res.start, dev->irq[0], dev->irq[1]); 551 (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]);
552 552
553 init_timer(&host->timer); 553 init_timer(&host->timer);
554 host->timer.data = (unsigned long)host; 554 host->timer.data = (unsigned long)host;
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 0d435814aaa1..39edb8250fbc 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -357,6 +357,7 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
357 mtd->resume = cfi_intelext_resume; 357 mtd->resume = cfi_intelext_resume;
358 mtd->flags = MTD_CAP_NORFLASH; 358 mtd->flags = MTD_CAP_NORFLASH;
359 mtd->name = map->name; 359 mtd->name = map->name;
360 mtd->writesize = 1;
360 361
361 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; 362 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
362 363
diff --git a/drivers/mtd/chips/jedec.c b/drivers/mtd/chips/jedec.c
index c40b48dabed3..2c3f019197c1 100644
--- a/drivers/mtd/chips/jedec.c
+++ b/drivers/mtd/chips/jedec.c
@@ -256,6 +256,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
256 MTD->name = map->name; 256 MTD->name = map->name;
257 MTD->type = MTD_NORFLASH; 257 MTD->type = MTD_NORFLASH;
258 MTD->flags = MTD_CAP_NORFLASH; 258 MTD->flags = MTD_CAP_NORFLASH;
259 MTD->writesize = 1;
259 MTD->erasesize = SectorSize*(map->buswidth); 260 MTD->erasesize = SectorSize*(map->buswidth);
260 // printk("MTD->erasesize is %x\n",(unsigned int)MTD->erasesize); 261 // printk("MTD->erasesize is %x\n",(unsigned int)MTD->erasesize);
261 MTD->size = priv->size; 262 MTD->size = priv->size;
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
index a611de9b1515..ac01a949b687 100644
--- a/drivers/mtd/chips/map_absent.c
+++ b/drivers/mtd/chips/map_absent.c
@@ -64,7 +64,8 @@ static struct mtd_info *map_absent_probe(struct map_info *map)
64 mtd->write = map_absent_write; 64 mtd->write = map_absent_write;
65 mtd->sync = map_absent_sync; 65 mtd->sync = map_absent_sync;
66 mtd->flags = 0; 66 mtd->flags = 0;
67 mtd->erasesize = PAGE_SIZE; 67 mtd->erasesize = PAGE_SIZE;
68 mtd->writesize = 1;
68 69
69 __module_get(THIS_MODULE); 70 __module_get(THIS_MODULE);
70 return mtd; 71 return mtd;
diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c
index 763925747db6..3a66680abfd0 100644
--- a/drivers/mtd/chips/map_ram.c
+++ b/drivers/mtd/chips/map_ram.c
@@ -71,6 +71,7 @@ static struct mtd_info *map_ram_probe(struct map_info *map)
71 mtd->write = mapram_write; 71 mtd->write = mapram_write;
72 mtd->sync = mapram_nop; 72 mtd->sync = mapram_nop;
73 mtd->flags = MTD_CAP_RAM; 73 mtd->flags = MTD_CAP_RAM;
74 mtd->writesize = 1;
74 75
75 mtd->erasesize = PAGE_SIZE; 76 mtd->erasesize = PAGE_SIZE;
76 while(mtd->size & (mtd->erasesize - 1)) 77 while(mtd->size & (mtd->erasesize - 1))
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c
index bc6ee9ef8a31..1b328b1378fd 100644
--- a/drivers/mtd/chips/map_rom.c
+++ b/drivers/mtd/chips/map_rom.c
@@ -47,6 +47,7 @@ static struct mtd_info *map_rom_probe(struct map_info *map)
47 mtd->sync = maprom_nop; 47 mtd->sync = maprom_nop;
48 mtd->flags = MTD_CAP_ROM; 48 mtd->flags = MTD_CAP_ROM;
49 mtd->erasesize = map->size; 49 mtd->erasesize = map->size;
50 mtd->writesize = 1;
50 51
51 __module_get(THIS_MODULE); 52 __module_get(THIS_MODULE);
52 return mtd; 53 return mtd;
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 0d98c223c5fc..be3f1c136d02 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -324,6 +324,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
324 324
325 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; 325 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
326 dev->mtd.erasesize = erase_size; 326 dev->mtd.erasesize = erase_size;
327 dev->mtd.writesize = 1;
327 dev->mtd.type = MTD_RAM; 328 dev->mtd.type = MTD_RAM;
328 dev->mtd.flags = MTD_CAP_RAM; 329 dev->mtd.flags = MTD_CAP_RAM;
329 dev->mtd.erase = block2mtd_erase; 330 dev->mtd.erase = block2mtd_erase;
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index 4ab7670770e4..08dfb899b272 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -225,6 +225,7 @@ static int __init ms02nv_init_one(ulong addr)
225 mtd->owner = THIS_MODULE; 225 mtd->owner = THIS_MODULE;
226 mtd->read = ms02nv_read; 226 mtd->read = ms02nv_read;
227 mtd->write = ms02nv_write; 227 mtd->write = ms02nv_write;
228 mtd->writesize = 1;
228 229
229 ret = -EIO; 230 ret = -EIO;
230 if (add_mtd_device(mtd)) { 231 if (add_mtd_device(mtd)) {
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index a19480d07888..04271d02b6b6 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -478,6 +478,7 @@ add_dataflash(struct spi_device *spi, char *name,
478 device->name = (pdata && pdata->name) ? pdata->name : priv->name; 478 device->name = (pdata && pdata->name) ? pdata->name : priv->name;
479 device->size = nr_pages * pagesize; 479 device->size = nr_pages * pagesize;
480 device->erasesize = pagesize; 480 device->erasesize = pagesize;
481 device->writesize = pagesize;
481 device->owner = THIS_MODULE; 482 device->owner = THIS_MODULE;
482 device->type = MTD_DATAFLASH; 483 device->type = MTD_DATAFLASH;
483 device->flags = MTD_CAP_NORFLASH; 484 device->flags = MTD_CAP_NORFLASH;
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index e09e416667d3..6c7337f9ebbb 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -151,6 +151,7 @@ static int register_device(char *name, unsigned long start, unsigned long len)
151 new->mtd.owner = THIS_MODULE; 151 new->mtd.owner = THIS_MODULE;
152 new->mtd.type = MTD_RAM; 152 new->mtd.type = MTD_RAM;
153 new->mtd.erasesize = PAGE_SIZE; 153 new->mtd.erasesize = PAGE_SIZE;
154 new->mtd.writesize = 1;
154 155
155 ret = -EAGAIN; 156 ret = -EAGAIN;
156 if (add_mtd_device(&new->mtd)) { 157 if (add_mtd_device(&new->mtd)) {
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index 666cce1bf60c..30f07b473ae2 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -551,11 +551,11 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
551 /* 551 /*
552 * Some screen fun 552 * Some screen fun
553 */ 553 */
554 printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at 0x%lx\n", 554 printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at 0x%llx\n",
555 (size<1024)?size:(size<1048576)?size>>10:size>>20, 555 (size<1024)?size:(size<1048576)?size>>10:size>>20,
556 (size<1024)?'B':(size<1048576)?'K':'M', 556 (size<1024)?'B':(size<1048576)?'K':'M',
557 size, ((dcmd&(0x1<<3)) == 0)?"non-":"", 557 size, ((dcmd&(0x1<<3)) == 0)?"non-":"",
558 (dev->resource[0].start)&PCI_BASE_ADDRESS_MEM_MASK ); 558 (unsigned long long)((dev->resource[0].start)&PCI_BASE_ADDRESS_MEM_MASK));
559 559
560 /* 560 /*
561 * Check to see the state of the memory 561 * Check to see the state of the memory
@@ -685,8 +685,8 @@ static int __init init_pmc551(void)
685 break; 685 break;
686 } 686 }
687 687
688 printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%lX\n", 688 printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%llx\n",
689 PCI_Device->resource[0].start); 689 (unsigned long long)PCI_Device->resource[0].start);
690 690
691 /* 691 /*
692 * The PMC551 device acts VERY weird if you don't init it 692 * The PMC551 device acts VERY weird if you don't init it
@@ -778,7 +778,8 @@ static int __init init_pmc551(void)
778 mtd->type = MTD_RAM; 778 mtd->type = MTD_RAM;
779 mtd->name = "PMC551 RAM board"; 779 mtd->name = "PMC551 RAM board";
780 mtd->erasesize = 0x10000; 780 mtd->erasesize = 0x10000;
781 mtd->owner = THIS_MODULE; 781 mtd->writesize = 1;
782 mtd->owner = THIS_MODULE;
782 783
783 if (add_mtd_device(mtd)) { 784 if (add_mtd_device(mtd)) {
784 printk(KERN_NOTICE "pmc551: Failed to register new device\n"); 785 printk(KERN_NOTICE "pmc551: Failed to register new device\n");
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index b3f665e3c38b..542a0c009006 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -209,6 +209,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
209 (*curmtd)->mtdinfo->owner = THIS_MODULE; 209 (*curmtd)->mtdinfo->owner = THIS_MODULE;
210 (*curmtd)->mtdinfo->type = MTD_RAM; 210 (*curmtd)->mtdinfo->type = MTD_RAM;
211 (*curmtd)->mtdinfo->erasesize = SLRAM_BLK_SZ; 211 (*curmtd)->mtdinfo->erasesize = SLRAM_BLK_SZ;
212 (*curmtd)->mtdinfo->writesize = 1;
212 213
213 if (add_mtd_device((*curmtd)->mtdinfo)) { 214 if (add_mtd_device((*curmtd)->mtdinfo)) {
214 E("slram: Failed to register new device\n"); 215 E("slram: Failed to register new device\n");
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index c350878d4592..a50587005263 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -123,9 +123,10 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
123 window->rsrc.parent = NULL; 123 window->rsrc.parent = NULL;
124 printk(KERN_ERR MOD_NAME 124 printk(KERN_ERR MOD_NAME
125 " %s(): Unable to register resource" 125 " %s(): Unable to register resource"
126 " 0x%.08lx-0x%.08lx - kernel bug?\n", 126 " 0x%.16llx-0x%.16llx - kernel bug?\n",
127 __func__, 127 __func__,
128 window->rsrc.start, window->rsrc.end); 128 (unsigned long long)window->rsrc.start,
129 (unsigned long long)window->rsrc.end);
129 } 130 }
130 131
131#if 0 132#if 0
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index ea5073781b3a..16732794edf3 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -177,9 +177,10 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
177 window->rsrc.parent = NULL; 177 window->rsrc.parent = NULL;
178 printk(KERN_DEBUG MOD_NAME 178 printk(KERN_DEBUG MOD_NAME
179 ": %s(): Unable to register resource" 179 ": %s(): Unable to register resource"
180 " 0x%.08lx-0x%.08lx - kernel bug?\n", 180 " 0x%.16llx-0x%.16llx - kernel bug?\n",
181 __func__, 181 __func__,
182 window->rsrc.start, window->rsrc.end); 182 (unsigned long long)window->rsrc.start,
183 (unsigned long long)window->rsrc.end);
183 } 184 }
184 185
185 /* Map the firmware hub into my address space. */ 186 /* Map the firmware hub into my address space. */
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 2c9cc7f37e92..c26488a1793a 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -42,7 +42,6 @@ struct ixp2000_flash_info {
42 struct map_info map; 42 struct map_info map;
43 struct mtd_partition *partitions; 43 struct mtd_partition *partitions;
44 struct resource *res; 44 struct resource *res;
45 int nr_banks;
46}; 45};
47 46
48static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long ofs) 47static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long ofs)
@@ -183,7 +182,6 @@ static int ixp2000_flash_probe(struct platform_device *dev)
183 */ 182 */
184 info->map.phys = NO_XIP; 183 info->map.phys = NO_XIP;
185 184
186 info->nr_banks = ixp_data->nr_banks;
187 info->map.size = ixp_data->nr_banks * window_size; 185 info->map.size = ixp_data->nr_banks * window_size;
188 info->map.bankwidth = 1; 186 info->map.bankwidth = 1;
189 187
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 433c3cac3ca9..d6301f08906d 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -182,7 +182,7 @@ static struct physmap_flash_data physmap_flash_data = {
182 182
183static struct resource physmap_flash_resource = { 183static struct resource physmap_flash_resource = {
184 .start = CONFIG_MTD_PHYSMAP_START, 184 .start = CONFIG_MTD_PHYSMAP_START,
185 .end = CONFIG_MTD_PHYSMAP_START + CONFIG_MTD_PHYSMAP_LEN, 185 .end = CONFIG_MTD_PHYSMAP_START + CONFIG_MTD_PHYSMAP_LEN - 1,
186 .flags = IORESOURCE_MEM, 186 .flags = IORESOURCE_MEM,
187}; 187};
188 188
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c
index 28b8a571a91a..331a15859d71 100644
--- a/drivers/mtd/maps/scx200_docflash.c
+++ b/drivers/mtd/maps/scx200_docflash.c
@@ -164,8 +164,9 @@ static int __init init_scx200_docflash(void)
164 outl(pmr, scx200_cb_base + SCx200_PMR); 164 outl(pmr, scx200_cb_base + SCx200_PMR);
165 } 165 }
166 166
167 printk(KERN_INFO NAME ": DOCCS mapped at 0x%lx-0x%lx, width %d\n", 167 printk(KERN_INFO NAME ": DOCCS mapped at 0x%llx-0x%llx, width %d\n",
168 docmem.start, docmem.end, width); 168 (unsigned long long)docmem.start,
169 (unsigned long long)docmem.end, width);
169 170
170 scx200_docflash_map.size = size; 171 scx200_docflash_map.size = size;
171 if (width == 8) 172 if (width == 8)
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
index 24a03152d196..4db2055cee31 100644
--- a/drivers/mtd/maps/sun_uflash.c
+++ b/drivers/mtd/maps/sun_uflash.c
@@ -62,9 +62,10 @@ int uflash_devinit(struct linux_ebus_device *edev, struct device_node *dp)
62 /* Non-CFI userflash device-- once I find one we 62 /* Non-CFI userflash device-- once I find one we
63 * can work on supporting it. 63 * can work on supporting it.
64 */ 64 */
65 printk("%s: unsupported device at 0x%lx (%d regs): " \ 65 printk("%s: unsupported device at 0x%llx (%d regs): " \
66 "email ebrower@usa.net\n", 66 "email ebrower@usa.net\n",
67 dp->full_name, res->start, edev->num_addrs); 67 dp->full_name, (unsigned long long)res->start,
68 edev->num_addrs);
68 69
69 return -ENODEV; 70 return -ENODEV;
70 } 71 }
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index aa18d45b264b..9a4b59d92525 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -78,7 +78,7 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
78 return -EINVAL; 78 return -EINVAL;
79 } 79 }
80 80
81 if (offset >= 0 && offset < mtd->size) 81 if (offset >= 0 && offset <= mtd->size)
82 return file->f_pos = offset; 82 return file->f_pos = offset;
83 83
84 return -EINVAL; 84 return -EINVAL;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 27083ed0a017..80a76654d963 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1176,7 +1176,7 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
1176 1176
1177 status = chip->waitfunc(mtd, chip); 1177 status = chip->waitfunc(mtd, chip);
1178 1178
1179 return status; 1179 return status & NAND_STATUS_FAIL ? -EIO : 0;
1180} 1180}
1181 1181
1182/** 1182/**
@@ -1271,10 +1271,6 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
1271 sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd); 1271 sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd);
1272 buf = nand_transfer_oob(chip, buf, ops); 1272 buf = nand_transfer_oob(chip, buf, ops);
1273 1273
1274 readlen -= ops->ooblen;
1275 if (!readlen)
1276 break;
1277
1278 if (!(chip->options & NAND_NO_READRDY)) { 1274 if (!(chip->options & NAND_NO_READRDY)) {
1279 /* 1275 /*
1280 * Apply delay or wait for ready/busy pin. Do this 1276 * Apply delay or wait for ready/busy pin. Do this
@@ -1288,6 +1284,10 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
1288 nand_wait_ready(mtd); 1284 nand_wait_ready(mtd);
1289 } 1285 }
1290 1286
1287 readlen -= ops->ooblen;
1288 if (!readlen)
1289 break;
1290
1291 /* Increment page address */ 1291 /* Increment page address */
1292 realpage++; 1292 realpage++;
1293 1293
@@ -1610,13 +1610,13 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
1610 if (!writelen) 1610 if (!writelen)
1611 return 0; 1611 return 0;
1612 1612
1613 chipnr = (int)(to >> chip->chip_shift);
1614 chip->select_chip(mtd, chipnr);
1615
1613 /* Check, if it is write protected */ 1616 /* Check, if it is write protected */
1614 if (nand_check_wp(mtd)) 1617 if (nand_check_wp(mtd))
1615 return -EIO; 1618 return -EIO;
1616 1619
1617 chipnr = (int)(to >> chip->chip_shift);
1618 chip->select_chip(mtd, chipnr);
1619
1620 realpage = (int)(to >> chip->page_shift); 1620 realpage = (int)(to >> chip->page_shift);
1621 page = realpage & chip->pagemask; 1621 page = realpage & chip->pagemask;
1622 blockmask = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1; 1622 blockmask = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index fe8d38514ba6..e5bd88f2d560 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -61,15 +61,15 @@ static void ndfc_select_chip(struct mtd_info *mtd, int chip)
61 61
62static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) 62static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
63{ 63{
64 struct nand_chip *chip = mtd->priv; 64 struct ndfc_controller *ndfc = &ndfc_ctrl;
65 65
66 if (cmd == NAND_CMD_NONE) 66 if (cmd == NAND_CMD_NONE)
67 return; 67 return;
68 68
69 if (ctrl & NAND_CLE) 69 if (ctrl & NAND_CLE)
70 writel(cmd & 0xFF, chip->IO_ADDR_W + NDFC_CMD); 70 writel(cmd & 0xFF, ndfc->ndfcbase + NDFC_CMD);
71 else 71 else
72 writel(cmd & 0xFF, chip->IO_ADDR_W + NDFC_ALE); 72 writel(cmd & 0xFF, ndfc->ndfcbase + NDFC_ALE);
73} 73}
74 74
75static int ndfc_ready(struct mtd_info *mtd) 75static int ndfc_ready(struct mtd_info *mtd)
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 2c262fe03d8a..ff5cef24d5bb 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -63,8 +63,6 @@
63#include <asm/arch/regs-nand.h> 63#include <asm/arch/regs-nand.h>
64#include <asm/arch/nand.h> 64#include <asm/arch/nand.h>
65 65
66#define PFX "s3c2410-nand: "
67
68#ifdef CONFIG_MTD_NAND_S3C2410_HWECC 66#ifdef CONFIG_MTD_NAND_S3C2410_HWECC
69static int hardware_ecc = 1; 67static int hardware_ecc = 1;
70#else 68#else
@@ -99,6 +97,12 @@ struct s3c2410_nand_mtd {
99 int scan_res; 97 int scan_res;
100}; 98};
101 99
100enum s3c_cpu_type {
101 TYPE_S3C2410,
102 TYPE_S3C2412,
103 TYPE_S3C2440,
104};
105
102/* overview of the s3c2410 nand state */ 106/* overview of the s3c2410 nand state */
103 107
104struct s3c2410_nand_info { 108struct s3c2410_nand_info {
@@ -112,9 +116,11 @@ struct s3c2410_nand_info {
112 struct resource *area; 116 struct resource *area;
113 struct clk *clk; 117 struct clk *clk;
114 void __iomem *regs; 118 void __iomem *regs;
119 void __iomem *sel_reg;
120 int sel_bit;
115 int mtd_count; 121 int mtd_count;
116 122
117 unsigned char is_s3c2440; 123 enum s3c_cpu_type cpu_type;
118}; 124};
119 125
120/* conversion functions */ 126/* conversion functions */
@@ -148,7 +154,7 @@ static inline int allow_clk_stop(struct s3c2410_nand_info *info)
148 154
149#define NS_IN_KHZ 1000000 155#define NS_IN_KHZ 1000000
150 156
151static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) 157static int s3c_nand_calc_rate(int wanted, unsigned long clk, int max)
152{ 158{
153 int result; 159 int result;
154 160
@@ -172,53 +178,58 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
172 178
173/* controller setup */ 179/* controller setup */
174 180
175static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, struct platform_device *pdev) 181static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
182 struct platform_device *pdev)
176{ 183{
177 struct s3c2410_platform_nand *plat = to_nand_plat(pdev); 184 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
178 unsigned long clkrate = clk_get_rate(info->clk); 185 unsigned long clkrate = clk_get_rate(info->clk);
186 int tacls_max = (info->cpu_type == TYPE_S3C2412) ? 8 : 4;
179 int tacls, twrph0, twrph1; 187 int tacls, twrph0, twrph1;
180 unsigned long cfg; 188 unsigned long cfg = 0;
181 189
182 /* calculate the timing information for the controller */ 190 /* calculate the timing information for the controller */
183 191
184 clkrate /= 1000; /* turn clock into kHz for ease of use */ 192 clkrate /= 1000; /* turn clock into kHz for ease of use */
185 193
186 if (plat != NULL) { 194 if (plat != NULL) {
187 tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4); 195 tacls = s3c_nand_calc_rate(plat->tacls, clkrate, tacls_max);
188 twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); 196 twrph0 = s3c_nand_calc_rate(plat->twrph0, clkrate, 8);
189 twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8); 197 twrph1 = s3c_nand_calc_rate(plat->twrph1, clkrate, 8);
190 } else { 198 } else {
191 /* default timings */ 199 /* default timings */
192 tacls = 4; 200 tacls = tacls_max;
193 twrph0 = 8; 201 twrph0 = 8;
194 twrph1 = 8; 202 twrph1 = 8;
195 } 203 }
196 204
197 if (tacls < 0 || twrph0 < 0 || twrph1 < 0) { 205 if (tacls < 0 || twrph0 < 0 || twrph1 < 0) {
198 printk(KERN_ERR PFX "cannot get timings suitable for board\n"); 206 dev_err(info->device, "cannot get suitable timings\n");
199 return -EINVAL; 207 return -EINVAL;
200 } 208 }
201 209
202 printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n", 210 dev_info(info->device, "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
203 tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate)); 211 tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate));
204 212
205 if (!info->is_s3c2440) { 213 switch (info->cpu_type) {
214 case TYPE_S3C2410:
206 cfg = S3C2410_NFCONF_EN; 215 cfg = S3C2410_NFCONF_EN;
207 cfg |= S3C2410_NFCONF_TACLS(tacls - 1); 216 cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
208 cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1); 217 cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
209 cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1); 218 cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
210 } else { 219 break;
220
221 case TYPE_S3C2440:
222 case TYPE_S3C2412:
211 cfg = S3C2440_NFCONF_TACLS(tacls - 1); 223 cfg = S3C2440_NFCONF_TACLS(tacls - 1);
212 cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1); 224 cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
213 cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1); 225 cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
214 226
215 /* enable the controller and de-assert nFCE */ 227 /* enable the controller and de-assert nFCE */
216 228
217 writel(S3C2440_NFCONT_ENABLE | S3C2440_NFCONT_ENABLE, 229 writel(S3C2440_NFCONT_ENABLE, info->regs + S3C2440_NFCONT);
218 info->regs + S3C2440_NFCONT);
219 } 230 }
220 231
221 pr_debug(PFX "NF_CONF is 0x%lx\n", cfg); 232 dev_dbg(info->device, "NF_CONF is 0x%lx\n", cfg);
222 233
223 writel(cfg, info->regs + S3C2410_NFCONF); 234 writel(cfg, info->regs + S3C2410_NFCONF);
224 return 0; 235 return 0;
@@ -231,26 +242,21 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
231 struct s3c2410_nand_info *info; 242 struct s3c2410_nand_info *info;
232 struct s3c2410_nand_mtd *nmtd; 243 struct s3c2410_nand_mtd *nmtd;
233 struct nand_chip *this = mtd->priv; 244 struct nand_chip *this = mtd->priv;
234 void __iomem *reg;
235 unsigned long cur; 245 unsigned long cur;
236 unsigned long bit;
237 246
238 nmtd = this->priv; 247 nmtd = this->priv;
239 info = nmtd->info; 248 info = nmtd->info;
240 249
241 bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE;
242 reg = info->regs + ((info->is_s3c2440) ? S3C2440_NFCONT : S3C2410_NFCONF);
243
244 if (chip != -1 && allow_clk_stop(info)) 250 if (chip != -1 && allow_clk_stop(info))
245 clk_enable(info->clk); 251 clk_enable(info->clk);
246 252
247 cur = readl(reg); 253 cur = readl(info->sel_reg);
248 254
249 if (chip == -1) { 255 if (chip == -1) {
250 cur |= bit; 256 cur |= info->sel_bit;
251 } else { 257 } else {
252 if (nmtd->set != NULL && chip > nmtd->set->nr_chips) { 258 if (nmtd->set != NULL && chip > nmtd->set->nr_chips) {
253 printk(KERN_ERR PFX "chip %d out of range\n", chip); 259 dev_err(info->device, "invalid chip %d\n", chip);
254 return; 260 return;
255 } 261 }
256 262
@@ -259,10 +265,10 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
259 (info->platform->select_chip) (nmtd->set, chip); 265 (info->platform->select_chip) (nmtd->set, chip);
260 } 266 }
261 267
262 cur &= ~bit; 268 cur &= ~info->sel_bit;
263 } 269 }
264 270
265 writel(cur, reg); 271 writel(cur, info->sel_reg);
266 272
267 if (chip == -1 && allow_clk_stop(info)) 273 if (chip == -1 && allow_clk_stop(info))
268 clk_disable(info->clk); 274 clk_disable(info->clk);
@@ -311,15 +317,25 @@ static void s3c2440_nand_hwcontrol(struct mtd_info *mtd, int cmd,
311static int s3c2410_nand_devready(struct mtd_info *mtd) 317static int s3c2410_nand_devready(struct mtd_info *mtd)
312{ 318{
313 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 319 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
314
315 if (info->is_s3c2440)
316 return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY;
317 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; 320 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;
318} 321}
319 322
323static int s3c2440_nand_devready(struct mtd_info *mtd)
324{
325 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
326 return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY;
327}
328
329static int s3c2412_nand_devready(struct mtd_info *mtd)
330{
331 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
332 return readb(info->regs + S3C2412_NFSTAT) & S3C2412_NFSTAT_READY;
333}
334
320/* ECC handling functions */ 335/* ECC handling functions */
321 336
322static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc) 337static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
338 u_char *read_ecc, u_char *calc_ecc)
323{ 339{
324 pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", mtd, dat, read_ecc, calc_ecc); 340 pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", mtd, dat, read_ecc, calc_ecc);
325 341
@@ -487,11 +503,8 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
487 struct s3c2410_nand_set *set) 503 struct s3c2410_nand_set *set)
488{ 504{
489 struct nand_chip *chip = &nmtd->chip; 505 struct nand_chip *chip = &nmtd->chip;
506 void __iomem *regs = info->regs;
490 507
491 chip->IO_ADDR_R = info->regs + S3C2410_NFDATA;
492 chip->IO_ADDR_W = info->regs + S3C2410_NFDATA;
493 chip->cmd_ctrl = s3c2410_nand_hwcontrol;
494 chip->dev_ready = s3c2410_nand_devready;
495 chip->write_buf = s3c2410_nand_write_buf; 508 chip->write_buf = s3c2410_nand_write_buf;
496 chip->read_buf = s3c2410_nand_read_buf; 509 chip->read_buf = s3c2410_nand_read_buf;
497 chip->select_chip = s3c2410_nand_select_chip; 510 chip->select_chip = s3c2410_nand_select_chip;
@@ -500,11 +513,37 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
500 chip->options = 0; 513 chip->options = 0;
501 chip->controller = &info->controller; 514 chip->controller = &info->controller;
502 515
503 if (info->is_s3c2440) { 516 switch (info->cpu_type) {
504 chip->IO_ADDR_R = info->regs + S3C2440_NFDATA; 517 case TYPE_S3C2410:
505 chip->IO_ADDR_W = info->regs + S3C2440_NFDATA; 518 chip->IO_ADDR_W = regs + S3C2410_NFDATA;
506 chip->cmd_ctrl = s3c2440_nand_hwcontrol; 519 info->sel_reg = regs + S3C2410_NFCONF;
507 } 520 info->sel_bit = S3C2410_NFCONF_nFCE;
521 chip->cmd_ctrl = s3c2410_nand_hwcontrol;
522 chip->dev_ready = s3c2410_nand_devready;
523 break;
524
525 case TYPE_S3C2440:
526 chip->IO_ADDR_W = regs + S3C2440_NFDATA;
527 info->sel_reg = regs + S3C2440_NFCONT;
528 info->sel_bit = S3C2440_NFCONT_nFCE;
529 chip->cmd_ctrl = s3c2440_nand_hwcontrol;
530 chip->dev_ready = s3c2440_nand_devready;
531 break;
532
533 case TYPE_S3C2412:
534 chip->IO_ADDR_W = regs + S3C2440_NFDATA;
535 info->sel_reg = regs + S3C2440_NFCONT;
536 info->sel_bit = S3C2412_NFCONT_nFCE0;
537 chip->cmd_ctrl = s3c2440_nand_hwcontrol;
538 chip->dev_ready = s3c2412_nand_devready;
539
540 if (readl(regs + S3C2410_NFCONF) & S3C2412_NFCONF_NANDBOOT)
541 dev_info(info->device, "System booted from NAND\n");
542
543 break;
544 }
545
546 chip->IO_ADDR_R = chip->IO_ADDR_W;
508 547
509 nmtd->info = info; 548 nmtd->info = info;
510 nmtd->mtd.priv = chip; 549 nmtd->mtd.priv = chip;
@@ -512,17 +551,25 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
512 nmtd->set = set; 551 nmtd->set = set;
513 552
514 if (hardware_ecc) { 553 if (hardware_ecc) {
515 chip->ecc.correct = s3c2410_nand_correct_data;
516 chip->ecc.hwctl = s3c2410_nand_enable_hwecc;
517 chip->ecc.calculate = s3c2410_nand_calculate_ecc; 554 chip->ecc.calculate = s3c2410_nand_calculate_ecc;
555 chip->ecc.correct = s3c2410_nand_correct_data;
518 chip->ecc.mode = NAND_ECC_HW; 556 chip->ecc.mode = NAND_ECC_HW;
519 chip->ecc.size = 512; 557 chip->ecc.size = 512;
520 chip->ecc.bytes = 3; 558 chip->ecc.bytes = 3;
521 chip->ecc.layout = &nand_hw_eccoob; 559 chip->ecc.layout = &nand_hw_eccoob;
522 560
523 if (info->is_s3c2440) { 561 switch (info->cpu_type) {
524 chip->ecc.hwctl = s3c2440_nand_enable_hwecc; 562 case TYPE_S3C2410:
525 chip->ecc.calculate = s3c2440_nand_calculate_ecc; 563 chip->ecc.hwctl = s3c2410_nand_enable_hwecc;
564 chip->ecc.calculate = s3c2410_nand_calculate_ecc;
565 break;
566
567 case TYPE_S3C2412:
568 case TYPE_S3C2440:
569 chip->ecc.hwctl = s3c2440_nand_enable_hwecc;
570 chip->ecc.calculate = s3c2440_nand_calculate_ecc;
571 break;
572
526 } 573 }
527 } else { 574 } else {
528 chip->ecc.mode = NAND_ECC_SOFT; 575 chip->ecc.mode = NAND_ECC_SOFT;
@@ -537,7 +584,8 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
537 * nand layer to look for devices 584 * nand layer to look for devices
538*/ 585*/
539 586
540static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440) 587static int s3c24xx_nand_probe(struct platform_device *pdev,
588 enum s3c_cpu_type cpu_type)
541{ 589{
542 struct s3c2410_platform_nand *plat = to_nand_plat(pdev); 590 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
543 struct s3c2410_nand_info *info; 591 struct s3c2410_nand_info *info;
@@ -592,7 +640,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
592 info->device = &pdev->dev; 640 info->device = &pdev->dev;
593 info->platform = plat; 641 info->platform = plat;
594 info->regs = ioremap(res->start, size); 642 info->regs = ioremap(res->start, size);
595 info->is_s3c2440 = is_s3c2440; 643 info->cpu_type = cpu_type;
596 644
597 if (info->regs == NULL) { 645 if (info->regs == NULL) {
598 dev_err(&pdev->dev, "cannot reserve register region\n"); 646 dev_err(&pdev->dev, "cannot reserve register region\n");
@@ -699,12 +747,17 @@ static int s3c24xx_nand_resume(struct platform_device *dev)
699 747
700static int s3c2410_nand_probe(struct platform_device *dev) 748static int s3c2410_nand_probe(struct platform_device *dev)
701{ 749{
702 return s3c24xx_nand_probe(dev, 0); 750 return s3c24xx_nand_probe(dev, TYPE_S3C2410);
703} 751}
704 752
705static int s3c2440_nand_probe(struct platform_device *dev) 753static int s3c2440_nand_probe(struct platform_device *dev)
706{ 754{
707 return s3c24xx_nand_probe(dev, 1); 755 return s3c24xx_nand_probe(dev, TYPE_S3C2440);
756}
757
758static int s3c2412_nand_probe(struct platform_device *dev)
759{
760 return s3c24xx_nand_probe(dev, TYPE_S3C2412);
708} 761}
709 762
710static struct platform_driver s3c2410_nand_driver = { 763static struct platform_driver s3c2410_nand_driver = {
@@ -729,16 +782,29 @@ static struct platform_driver s3c2440_nand_driver = {
729 }, 782 },
730}; 783};
731 784
785static struct platform_driver s3c2412_nand_driver = {
786 .probe = s3c2412_nand_probe,
787 .remove = s3c2410_nand_remove,
788 .suspend = s3c24xx_nand_suspend,
789 .resume = s3c24xx_nand_resume,
790 .driver = {
791 .name = "s3c2412-nand",
792 .owner = THIS_MODULE,
793 },
794};
795
732static int __init s3c2410_nand_init(void) 796static int __init s3c2410_nand_init(void)
733{ 797{
734 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n"); 798 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");
735 799
800 platform_driver_register(&s3c2412_nand_driver);
736 platform_driver_register(&s3c2440_nand_driver); 801 platform_driver_register(&s3c2440_nand_driver);
737 return platform_driver_register(&s3c2410_nand_driver); 802 return platform_driver_register(&s3c2410_nand_driver);
738} 803}
739 804
740static void __exit s3c2410_nand_exit(void) 805static void __exit s3c2410_nand_exit(void)
741{ 806{
807 platform_driver_unregister(&s3c2412_nand_driver);
742 platform_driver_unregister(&s3c2440_nand_driver); 808 platform_driver_unregister(&s3c2440_nand_driver);
743 platform_driver_unregister(&s3c2410_nand_driver); 809 platform_driver_unregister(&s3c2410_nand_driver);
744} 810}
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c
index a0b4b1edcb0d..f40081069ab2 100644
--- a/drivers/mtd/nand/ts7250.c
+++ b/drivers/mtd/nand/ts7250.c
@@ -97,7 +97,7 @@ static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
97 unsigned long addr = TS72XX_NAND_CONTROL_VIRT_BASE; 97 unsigned long addr = TS72XX_NAND_CONTROL_VIRT_BASE;
98 unsigned char bits; 98 unsigned char bits;
99 99
100 bits = (ctrl & NAND_CNE) << 2; 100 bits = (ctrl & NAND_NCE) << 2;
101 bits |= ctrl & NAND_CLE; 101 bits |= ctrl & NAND_CLE;
102 bits |= (ctrl & NAND_ALE) >> 2; 102 bits |= (ctrl & NAND_ALE) >> 2;
103 103
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index e27778926eba..d2f808979a2b 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -375,8 +375,7 @@ limit of 4K.
375 of the drivers, and will likely be provided by some future kernel. 375 of the drivers, and will likely be provided by some future kernel.
376*/ 376*/
377enum pci_flags_bit { 377enum pci_flags_bit {
378 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4, 378 PCI_USES_MASTER=4,
379 PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
380}; 379};
381 380
382enum { IS_VORTEX=1, IS_BOOMERANG=2, IS_CYCLONE=4, IS_TORNADO=8, 381enum { IS_VORTEX=1, IS_BOOMERANG=2, IS_CYCLONE=4, IS_TORNADO=8,
@@ -446,95 +445,95 @@ static struct vortex_chip_info {
446 int io_size; 445 int io_size;
447} vortex_info_tbl[] __devinitdata = { 446} vortex_info_tbl[] __devinitdata = {
448 {"3c590 Vortex 10Mbps", 447 {"3c590 Vortex 10Mbps",
449 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 448 PCI_USES_MASTER, IS_VORTEX, 32, },
450 {"3c592 EISA 10Mbps Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */ 449 {"3c592 EISA 10Mbps Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */
451 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 450 PCI_USES_MASTER, IS_VORTEX, 32, },
452 {"3c597 EISA Fast Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */ 451 {"3c597 EISA Fast Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */
453 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 452 PCI_USES_MASTER, IS_VORTEX, 32, },
454 {"3c595 Vortex 100baseTx", 453 {"3c595 Vortex 100baseTx",
455 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 454 PCI_USES_MASTER, IS_VORTEX, 32, },
456 {"3c595 Vortex 100baseT4", 455 {"3c595 Vortex 100baseT4",
457 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 456 PCI_USES_MASTER, IS_VORTEX, 32, },
458 457
459 {"3c595 Vortex 100base-MII", 458 {"3c595 Vortex 100base-MII",
460 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 459 PCI_USES_MASTER, IS_VORTEX, 32, },
461 {"3c900 Boomerang 10baseT", 460 {"3c900 Boomerang 10baseT",
462 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, }, 461 PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, },
463 {"3c900 Boomerang 10Mbps Combo", 462 {"3c900 Boomerang 10Mbps Combo",
464 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, }, 463 PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, },
465 {"3c900 Cyclone 10Mbps TPO", /* AKPM: from Don's 0.99M */ 464 {"3c900 Cyclone 10Mbps TPO", /* AKPM: from Don's 0.99M */
466 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 465 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
467 {"3c900 Cyclone 10Mbps Combo", 466 {"3c900 Cyclone 10Mbps Combo",
468 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 467 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
469 468
470 {"3c900 Cyclone 10Mbps TPC", /* AKPM: from Don's 0.99M */ 469 {"3c900 Cyclone 10Mbps TPC", /* AKPM: from Don's 0.99M */
471 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 470 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
472 {"3c900B-FL Cyclone 10base-FL", 471 {"3c900B-FL Cyclone 10base-FL",
473 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 472 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
474 {"3c905 Boomerang 100baseTx", 473 {"3c905 Boomerang 100baseTx",
475 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, }, 474 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, },
476 {"3c905 Boomerang 100baseT4", 475 {"3c905 Boomerang 100baseT4",
477 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, }, 476 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, },
478 {"3c905B Cyclone 100baseTx", 477 {"3c905B Cyclone 100baseTx",
479 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 478 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
480 479
481 {"3c905B Cyclone 10/100/BNC", 480 {"3c905B Cyclone 10/100/BNC",
482 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 481 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
483 {"3c905B-FX Cyclone 100baseFx", 482 {"3c905B-FX Cyclone 100baseFx",
484 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 483 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
485 {"3c905C Tornado", 484 {"3c905C Tornado",
486 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 485 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
487 {"3c920B-EMB-WNM (ATI Radeon 9100 IGP)", 486 {"3c920B-EMB-WNM (ATI Radeon 9100 IGP)",
488 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_MII|HAS_HWCKSM, 128, }, 487 PCI_USES_MASTER, IS_TORNADO|HAS_MII|HAS_HWCKSM, 128, },
489 {"3c980 Cyclone", 488 {"3c980 Cyclone",
490 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 489 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
491 490
492 {"3c980C Python-T", 491 {"3c980C Python-T",
493 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 492 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
494 {"3cSOHO100-TX Hurricane", 493 {"3cSOHO100-TX Hurricane",
495 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 494 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
496 {"3c555 Laptop Hurricane", 495 {"3c555 Laptop Hurricane",
497 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|EEPROM_8BIT|HAS_HWCKSM, 128, }, 496 PCI_USES_MASTER, IS_CYCLONE|EEPROM_8BIT|HAS_HWCKSM, 128, },
498 {"3c556 Laptop Tornado", 497 {"3c556 Laptop Tornado",
499 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_8BIT|HAS_CB_FNS|INVERT_MII_PWR| 498 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_8BIT|HAS_CB_FNS|INVERT_MII_PWR|
500 HAS_HWCKSM, 128, }, 499 HAS_HWCKSM, 128, },
501 {"3c556B Laptop Hurricane", 500 {"3c556B Laptop Hurricane",
502 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_OFFSET|HAS_CB_FNS|INVERT_MII_PWR| 501 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_OFFSET|HAS_CB_FNS|INVERT_MII_PWR|
503 WNO_XCVR_PWR|HAS_HWCKSM, 128, }, 502 WNO_XCVR_PWR|HAS_HWCKSM, 128, },
504 503
505 {"3c575 [Megahertz] 10/100 LAN CardBus", 504 {"3c575 [Megahertz] 10/100 LAN CardBus",
506 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, }, 505 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, },
507 {"3c575 Boomerang CardBus", 506 {"3c575 Boomerang CardBus",
508 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, }, 507 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, },
509 {"3CCFE575BT Cyclone CardBus", 508 {"3CCFE575BT Cyclone CardBus",
510 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT| 509 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|
511 INVERT_LED_PWR|HAS_HWCKSM, 128, }, 510 INVERT_LED_PWR|HAS_HWCKSM, 128, },
512 {"3CCFE575CT Tornado CardBus", 511 {"3CCFE575CT Tornado CardBus",
513 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 512 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
514 MAX_COLLISION_RESET|HAS_HWCKSM, 128, }, 513 MAX_COLLISION_RESET|HAS_HWCKSM, 128, },
515 {"3CCFE656 Cyclone CardBus", 514 {"3CCFE656 Cyclone CardBus",
516 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 515 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
517 INVERT_LED_PWR|HAS_HWCKSM, 128, }, 516 INVERT_LED_PWR|HAS_HWCKSM, 128, },
518 517
519 {"3CCFEM656B Cyclone+Winmodem CardBus", 518 {"3CCFEM656B Cyclone+Winmodem CardBus",
520 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 519 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
521 INVERT_LED_PWR|HAS_HWCKSM, 128, }, 520 INVERT_LED_PWR|HAS_HWCKSM, 128, },
522 {"3CXFEM656C Tornado+Winmodem CardBus", /* From pcmcia-cs-3.1.5 */ 521 {"3CXFEM656C Tornado+Winmodem CardBus", /* From pcmcia-cs-3.1.5 */
523 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 522 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
524 MAX_COLLISION_RESET|HAS_HWCKSM, 128, }, 523 MAX_COLLISION_RESET|HAS_HWCKSM, 128, },
525 {"3c450 HomePNA Tornado", /* AKPM: from Don's 0.99Q */ 524 {"3c450 HomePNA Tornado", /* AKPM: from Don's 0.99Q */
526 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, }, 525 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
527 {"3c920 Tornado", 526 {"3c920 Tornado",
528 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, }, 527 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
529 {"3c982 Hydra Dual Port A", 528 {"3c982 Hydra Dual Port A",
530 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, }, 529 PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, },
531 530
532 {"3c982 Hydra Dual Port B", 531 {"3c982 Hydra Dual Port B",
533 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, }, 532 PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, },
534 {"3c905B-T4", 533 {"3c905B-T4",
535 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 534 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
536 {"3c920B-EMB-WNM Tornado", 535 {"3c920B-EMB-WNM Tornado",
537 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, }, 536 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
538 537
539 {NULL,}, /* NULL terminated list. */ 538 {NULL,}, /* NULL terminated list. */
540}; 539};
@@ -1408,8 +1407,10 @@ static int __devinit vortex_probe1(struct device *gendev,
1408 } 1407 }
1409 1408
1410 if (print_info) { 1409 if (print_info) {
1411 printk(KERN_INFO "%s: CardBus functions mapped %8.8lx->%p\n", 1410 printk(KERN_INFO "%s: CardBus functions mapped "
1412 print_name, pci_resource_start(pdev, 2), 1411 "%16.16llx->%p\n",
1412 print_name,
1413 (unsigned long long)pci_resource_start(pdev, 2),
1413 vp->cb_fn_base); 1414 vp->cb_fn_base);
1414 } 1415 }
1415 EL3WINDOW(2); 1416 EL3WINDOW(2);
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 0cdc830449d8..d26dd6a7062d 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1823,7 +1823,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1823 struct cp_private *cp; 1823 struct cp_private *cp;
1824 int rc; 1824 int rc;
1825 void __iomem *regs; 1825 void __iomem *regs;
1826 long pciaddr; 1826 resource_size_t pciaddr;
1827 unsigned int addr_len, i, pci_using_dac; 1827 unsigned int addr_len, i, pci_using_dac;
1828 u8 pci_rev; 1828 u8 pci_rev;
1829 1829
@@ -1883,8 +1883,8 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1883 } 1883 }
1884 if (pci_resource_len(pdev, 1) < CP_REGS_SIZE) { 1884 if (pci_resource_len(pdev, 1) < CP_REGS_SIZE) {
1885 rc = -EIO; 1885 rc = -EIO;
1886 printk(KERN_ERR PFX "MMIO resource (%lx) too small on pci dev %s\n", 1886 printk(KERN_ERR PFX "MMIO resource (%llx) too small on pci dev %s\n",
1887 pci_resource_len(pdev, 1), pci_name(pdev)); 1887 (unsigned long long)pci_resource_len(pdev, 1), pci_name(pdev));
1888 goto err_out_res; 1888 goto err_out_res;
1889 } 1889 }
1890 1890
@@ -1916,8 +1916,9 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1916 regs = ioremap(pciaddr, CP_REGS_SIZE); 1916 regs = ioremap(pciaddr, CP_REGS_SIZE);
1917 if (!regs) { 1917 if (!regs) {
1918 rc = -EIO; 1918 rc = -EIO;
1919 printk(KERN_ERR PFX "Cannot map PCI MMIO (%lx@%lx) on pci dev %s\n", 1919 printk(KERN_ERR PFX "Cannot map PCI MMIO (%llx@%llx) on pci dev %s\n",
1920 pci_resource_len(pdev, 1), pciaddr, pci_name(pdev)); 1920 (unsigned long long)pci_resource_len(pdev, 1),
1921 (unsigned long long)pciaddr, pci_name(pdev));
1921 goto err_out_res; 1922 goto err_out_res;
1922 } 1923 }
1923 dev->base_addr = (unsigned long) regs; 1924 dev->base_addr = (unsigned long) regs;
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index abd6261465f1..ed2e3c03bc88 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1341,9 +1341,9 @@ static int rtl8139_open (struct net_device *dev)
1341 netif_start_queue (dev); 1341 netif_start_queue (dev);
1342 1342
1343 if (netif_msg_ifup(tp)) 1343 if (netif_msg_ifup(tp))
1344 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d" 1344 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#llx IRQ %d"
1345 " GP Pins %2.2x %s-duplex.\n", 1345 " GP Pins %2.2x %s-duplex.\n", dev->name,
1346 dev->name, pci_resource_start (tp->pci_dev, 1), 1346 (unsigned long long)pci_resource_start (tp->pci_dev, 1),
1347 dev->irq, RTL_R8 (MediaStatus), 1347 dev->irq, RTL_R8 (MediaStatus),
1348 tp->mii.full_duplex ? "full" : "half"); 1348 tp->mii.full_duplex ? "full" : "half");
1349 1349
diff --git a/drivers/net/dl2k.h b/drivers/net/dl2k.h
index 6e75482d75f2..53449207e53b 100644
--- a/drivers/net/dl2k.h
+++ b/drivers/net/dl2k.h
@@ -683,11 +683,6 @@ struct netdev_private {
683}; 683};
684 684
685/* The station address location in the EEPROM. */ 685/* The station address location in the EEPROM. */
686#ifdef MEM_MAPPING
687#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
688#else
689#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0)
690#endif
691/* The struct pci_device_id consist of: 686/* The struct pci_device_id consist of:
692 vendor, device Vendor and device ID to match (or PCI_ANY_ID) 687 vendor, device Vendor and device ID to match (or PCI_ANY_ID)
693 subvendor, subdevice Subsystem vendor and device ID to match (or PCI_ANY_ID) 688 subvendor, subdevice Subsystem vendor and device ID to match (or PCI_ANY_ID)
@@ -695,9 +690,10 @@ struct netdev_private {
695 class_mask of the class are honored during the comparison. 690 class_mask of the class are honored during the comparison.
696 driver_data Data private to the driver. 691 driver_data Data private to the driver.
697*/ 692*/
698static struct pci_device_id rio_pci_tbl[] = { 693
699 {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 694static const struct pci_device_id rio_pci_tbl[] = {
700 {0,} 695 {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, },
696 { }
701}; 697};
702MODULE_DEVICE_TABLE (pci, rio_pci_tbl); 698MODULE_DEVICE_TABLE (pci, rio_pci_tbl);
703#define TX_TIMEOUT (4*HZ) 699#define TX_TIMEOUT (4*HZ)
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 24996da4c1c4..7965a9b08e79 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -410,10 +410,7 @@ dm9000_probe(struct platform_device *pdev)
410 if (pdev->num_resources < 2) { 410 if (pdev->num_resources < 2) {
411 ret = -ENODEV; 411 ret = -ENODEV;
412 goto out; 412 goto out;
413 } 413 } else if (pdev->num_resources == 2) {
414
415 switch (pdev->num_resources) {
416 case 2:
417 base = pdev->resource[0].start; 414 base = pdev->resource[0].start;
418 415
419 if (!request_mem_region(base, 4, ndev->name)) { 416 if (!request_mem_region(base, 4, ndev->name)) {
@@ -423,17 +420,16 @@ dm9000_probe(struct platform_device *pdev)
423 420
424 ndev->base_addr = base; 421 ndev->base_addr = base;
425 ndev->irq = pdev->resource[1].start; 422 ndev->irq = pdev->resource[1].start;
426 db->io_addr = (void *)base; 423 db->io_addr = (void __iomem *)base;
427 db->io_data = (void *)(base + 4); 424 db->io_data = (void __iomem *)(base + 4);
428
429 break;
430 425
431 case 3: 426 } else {
432 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 427 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
433 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 428 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
434 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 429 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
435 430
436 if (db->addr_res == NULL || db->data_res == NULL) { 431 if (db->addr_res == NULL || db->data_res == NULL ||
432 db->irq_res == NULL) {
437 printk(KERN_ERR PFX "insufficient resources\n"); 433 printk(KERN_ERR PFX "insufficient resources\n");
438 ret = -ENOENT; 434 ret = -ENOENT;
439 goto out; 435 goto out;
@@ -482,7 +478,6 @@ dm9000_probe(struct platform_device *pdev)
482 478
483 /* ensure at least we have a default set of IO routines */ 479 /* ensure at least we have a default set of IO routines */
484 dm9000_set_io(db, iosize); 480 dm9000_set_io(db, iosize);
485
486 } 481 }
487 482
488 /* check to see if anything is being over-ridden */ 483 /* check to see if anything is being over-ridden */
@@ -564,6 +559,13 @@ dm9000_probe(struct platform_device *pdev)
564 for (i = 0; i < 6; i++) 559 for (i = 0; i < 6; i++)
565 ndev->dev_addr[i] = db->srom[i]; 560 ndev->dev_addr[i] = db->srom[i];
566 561
562 if (!is_valid_ether_addr(ndev->dev_addr)) {
563 /* try reading from mac */
564
565 for (i = 0; i < 6; i++)
566 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
567 }
568
567 if (!is_valid_ether_addr(ndev->dev_addr)) 569 if (!is_valid_ether_addr(ndev->dev_addr))
568 printk("%s: Invalid ethernet MAC address. Please " 570 printk("%s: Invalid ethernet MAC address. Please "
569 "set using ifconfig\n", ndev->name); 571 "set using ifconfig\n", ndev->name);
@@ -663,7 +665,6 @@ dm9000_init_dm9000(struct net_device *dev)
663 db->tx_pkt_cnt = 0; 665 db->tx_pkt_cnt = 0;
664 db->queue_pkt_len = 0; 666 db->queue_pkt_len = 0;
665 dev->trans_start = 0; 667 dev->trans_start = 0;
666 spin_lock_init(&db->lock);
667} 668}
668 669
669/* 670/*
@@ -767,7 +768,7 @@ dm9000_stop(struct net_device *ndev)
767 * receive the packet to upper layer, free the transmitted packet 768 * receive the packet to upper layer, free the transmitted packet
768 */ 769 */
769 770
770void 771static void
771dm9000_tx_done(struct net_device *dev, board_info_t * db) 772dm9000_tx_done(struct net_device *dev, board_info_t * db)
772{ 773{
773 int tx_status = ior(db, DM9000_NSR); /* Got TX status */ 774 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
@@ -1187,13 +1188,14 @@ dm9000_drv_remove(struct platform_device *pdev)
1187} 1188}
1188 1189
1189static struct platform_driver dm9000_driver = { 1190static struct platform_driver dm9000_driver = {
1191 .driver = {
1192 .name = "dm9000",
1193 .owner = THIS_MODULE,
1194 },
1190 .probe = dm9000_probe, 1195 .probe = dm9000_probe,
1191 .remove = dm9000_drv_remove, 1196 .remove = dm9000_drv_remove,
1192 .suspend = dm9000_drv_suspend, 1197 .suspend = dm9000_drv_suspend,
1193 .resume = dm9000_drv_resume, 1198 .resume = dm9000_drv_resume,
1194 .driver = {
1195 .name = "dm9000",
1196 },
1197}; 1199};
1198 1200
1199static int __init 1201static int __init
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index f37170cc1a37..93a286570923 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2678,9 +2678,9 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2678 goto err_out_free; 2678 goto err_out_free;
2679 } 2679 }
2680 2680
2681 DPRINTK(PROBE, INFO, "addr 0x%lx, irq %d, " 2681 DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, "
2682 "MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n", 2682 "MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
2683 pci_resource_start(pdev, 0), pdev->irq, 2683 (unsigned long long)pci_resource_start(pdev, 0), pdev->irq,
2684 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2], 2684 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
2685 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]); 2685 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
2686 2686
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 467fc861360d..ecf5ad85a684 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -278,11 +278,6 @@ having to sign an Intel NDA when I'm helping Intel sell their own product!
278 278
279static int speedo_found1(struct pci_dev *pdev, void __iomem *ioaddr, int fnd_cnt, int acpi_idle_state); 279static int speedo_found1(struct pci_dev *pdev, void __iomem *ioaddr, int fnd_cnt, int acpi_idle_state);
280 280
281enum pci_flags_bit {
282 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
283 PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
284};
285
286/* Offsets to the various registers. 281/* Offsets to the various registers.
287 All accesses need not be longword aligned. */ 282 All accesses need not be longword aligned. */
288enum speedo_offsets { 283enum speedo_offsets {
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 724d7dc35fa3..ee34a16eb4e2 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -191,23 +191,10 @@ IVc. Errata
191*/ 191*/
192 192
193 193
194enum pci_id_flags_bits {
195 /* Set PCI command register bits before calling probe1(). */
196 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
197 /* Read and map the single following PCI BAR. */
198 PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
199 PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
200};
201
202enum chip_capability_flags { MII_PWRDWN=1, TYPE2_INTR=2, NO_MII=4 }; 194enum chip_capability_flags { MII_PWRDWN=1, TYPE2_INTR=2, NO_MII=4 };
203 195
204#define EPIC_TOTAL_SIZE 0x100 196#define EPIC_TOTAL_SIZE 0x100
205#define USE_IO_OPS 1 197#define USE_IO_OPS 1
206#ifdef USE_IO_OPS
207#define EPIC_IOTYPE PCI_USES_MASTER|PCI_USES_IO|PCI_ADDR0
208#else
209#define EPIC_IOTYPE PCI_USES_MASTER|PCI_USES_MEM|PCI_ADDR1
210#endif
211 198
212typedef enum { 199typedef enum {
213 SMSC_83C170_0, 200 SMSC_83C170_0,
@@ -218,7 +205,6 @@ typedef enum {
218 205
219struct epic_chip_info { 206struct epic_chip_info {
220 const char *name; 207 const char *name;
221 enum pci_id_flags_bits pci_flags;
222 int io_size; /* Needed for I/O region check or ioremap(). */ 208 int io_size; /* Needed for I/O region check or ioremap(). */
223 int drv_flags; /* Driver use, intended as capability flags. */ 209 int drv_flags; /* Driver use, intended as capability flags. */
224}; 210};
@@ -227,11 +213,11 @@ struct epic_chip_info {
227/* indexed by chip_t */ 213/* indexed by chip_t */
228static const struct epic_chip_info pci_id_tbl[] = { 214static const struct epic_chip_info pci_id_tbl[] = {
229 { "SMSC EPIC/100 83c170", 215 { "SMSC EPIC/100 83c170",
230 EPIC_IOTYPE, EPIC_TOTAL_SIZE, TYPE2_INTR | NO_MII | MII_PWRDWN }, 216 EPIC_TOTAL_SIZE, TYPE2_INTR | NO_MII | MII_PWRDWN },
231 { "SMSC EPIC/100 83c170", 217 { "SMSC EPIC/100 83c170",
232 EPIC_IOTYPE, EPIC_TOTAL_SIZE, TYPE2_INTR }, 218 EPIC_TOTAL_SIZE, TYPE2_INTR },
233 { "SMSC EPIC/C 83c175", 219 { "SMSC EPIC/C 83c175",
234 EPIC_IOTYPE, EPIC_TOTAL_SIZE, TYPE2_INTR | MII_PWRDWN }, 220 EPIC_TOTAL_SIZE, TYPE2_INTR | MII_PWRDWN },
235}; 221};
236 222
237 223
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index a8449265e5fd..13eca7ede2af 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -126,16 +126,6 @@ MODULE_PARM_DESC(full_duplex, "fealnx full duplex setting(s) (1)");
126 126
127#define MIN_REGION_SIZE 136 127#define MIN_REGION_SIZE 136
128 128
129enum pci_flags_bit {
130 PCI_USES_IO = 1,
131 PCI_USES_MEM = 2,
132 PCI_USES_MASTER = 4,
133 PCI_ADDR0 = 0x10 << 0,
134 PCI_ADDR1 = 0x10 << 1,
135 PCI_ADDR2 = 0x10 << 2,
136 PCI_ADDR3 = 0x10 << 3,
137};
138
139/* A chip capabilities table, matching the entries in pci_tbl[] above. */ 129/* A chip capabilities table, matching the entries in pci_tbl[] above. */
140enum chip_capability_flags { 130enum chip_capability_flags {
141 HAS_MII_XCVR, 131 HAS_MII_XCVR,
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index bd6983d1afba..db694c832989 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -22,7 +22,7 @@
22 * Copyright (c) 2001-2005 Greg Ungerer (gerg@snapgear.com) 22 * Copyright (c) 2001-2005 Greg Ungerer (gerg@snapgear.com)
23 * 23 *
24 * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be) 24 * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be)
25 * Copyright (c) 2004-2005 Macq Electronique SA. 25 * Copyright (c) 2004-2006 Macq Electronique SA.
26 */ 26 */
27 27
28#include <linux/config.h> 28#include <linux/config.h>
@@ -51,7 +51,7 @@
51 51
52#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ 52#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
53 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \ 53 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \
54 defined(CONFIG_M520x) 54 defined(CONFIG_M520x) || defined(CONFIG_M532x)
55#include <asm/coldfire.h> 55#include <asm/coldfire.h>
56#include <asm/mcfsim.h> 56#include <asm/mcfsim.h>
57#include "fec.h" 57#include "fec.h"
@@ -80,6 +80,8 @@ static unsigned int fec_hw[] = {
80 (MCF_MBAR + 0x1000), 80 (MCF_MBAR + 0x1000),
81#elif defined(CONFIG_M520x) 81#elif defined(CONFIG_M520x)
82 (MCF_MBAR+0x30000), 82 (MCF_MBAR+0x30000),
83#elif defined(CONFIG_M532x)
84 (MCF_MBAR+0xfc030000),
83#else 85#else
84 &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec), 86 &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec),
85#endif 87#endif
@@ -143,7 +145,7 @@ typedef struct {
143#define TX_RING_MOD_MASK 15 /* for this to work */ 145#define TX_RING_MOD_MASK 15 /* for this to work */
144 146
145#if (((RX_RING_SIZE + TX_RING_SIZE) * 8) > PAGE_SIZE) 147#if (((RX_RING_SIZE + TX_RING_SIZE) * 8) > PAGE_SIZE)
146#error "FEC: descriptor ring size contants too large" 148#error "FEC: descriptor ring size constants too large"
147#endif 149#endif
148 150
149/* Interrupt events/masks. 151/* Interrupt events/masks.
@@ -167,12 +169,12 @@ typedef struct {
167 169
168 170
169/* 171/*
170 * The 5270/5271/5280/5282 RX control register also contains maximum frame 172 * The 5270/5271/5280/5282/532x RX control register also contains maximum frame
171 * size bits. Other FEC hardware does not, so we need to take that into 173 * size bits. Other FEC hardware does not, so we need to take that into
172 * account when setting it. 174 * account when setting it.
173 */ 175 */
174#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ 176#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
175 defined(CONFIG_M520x) 177 defined(CONFIG_M520x) || defined(CONFIG_M532x)
176#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) 178#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16)
177#else 179#else
178#define OPT_FRAME_SIZE 0 180#define OPT_FRAME_SIZE 0
@@ -308,6 +310,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
308 struct fec_enet_private *fep; 310 struct fec_enet_private *fep;
309 volatile fec_t *fecp; 311 volatile fec_t *fecp;
310 volatile cbd_t *bdp; 312 volatile cbd_t *bdp;
313 unsigned short status;
311 314
312 fep = netdev_priv(dev); 315 fep = netdev_priv(dev);
313 fecp = (volatile fec_t*)dev->base_addr; 316 fecp = (volatile fec_t*)dev->base_addr;
@@ -320,8 +323,9 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
320 /* Fill in a Tx ring entry */ 323 /* Fill in a Tx ring entry */
321 bdp = fep->cur_tx; 324 bdp = fep->cur_tx;
322 325
326 status = bdp->cbd_sc;
323#ifndef final_version 327#ifndef final_version
324 if (bdp->cbd_sc & BD_ENET_TX_READY) { 328 if (status & BD_ENET_TX_READY) {
325 /* Ooops. All transmit buffers are full. Bail out. 329 /* Ooops. All transmit buffers are full. Bail out.
326 * This should not happen, since dev->tbusy should be set. 330 * This should not happen, since dev->tbusy should be set.
327 */ 331 */
@@ -332,7 +336,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
332 336
333 /* Clear all of the status flags. 337 /* Clear all of the status flags.
334 */ 338 */
335 bdp->cbd_sc &= ~BD_ENET_TX_STATS; 339 status &= ~BD_ENET_TX_STATS;
336 340
337 /* Set buffer length and buffer pointer. 341 /* Set buffer length and buffer pointer.
338 */ 342 */
@@ -366,21 +370,22 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
366 370
367 spin_lock_irq(&fep->lock); 371 spin_lock_irq(&fep->lock);
368 372
369 /* Send it on its way. Tell FEC its ready, interrupt when done, 373 /* Send it on its way. Tell FEC it's ready, interrupt when done,
370 * its the last BD of the frame, and to put the CRC on the end. 374 * it's the last BD of the frame, and to put the CRC on the end.
371 */ 375 */
372 376
373 bdp->cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_INTR 377 status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
374 | BD_ENET_TX_LAST | BD_ENET_TX_TC); 378 | BD_ENET_TX_LAST | BD_ENET_TX_TC);
379 bdp->cbd_sc = status;
375 380
376 dev->trans_start = jiffies; 381 dev->trans_start = jiffies;
377 382
378 /* Trigger transmission start */ 383 /* Trigger transmission start */
379 fecp->fec_x_des_active = 0x01000000; 384 fecp->fec_x_des_active = 0;
380 385
381 /* If this was the last BD in the ring, start at the beginning again. 386 /* If this was the last BD in the ring, start at the beginning again.
382 */ 387 */
383 if (bdp->cbd_sc & BD_ENET_TX_WRAP) { 388 if (status & BD_ENET_TX_WRAP) {
384 bdp = fep->tx_bd_base; 389 bdp = fep->tx_bd_base;
385 } else { 390 } else {
386 bdp++; 391 bdp++;
@@ -491,43 +496,44 @@ fec_enet_tx(struct net_device *dev)
491{ 496{
492 struct fec_enet_private *fep; 497 struct fec_enet_private *fep;
493 volatile cbd_t *bdp; 498 volatile cbd_t *bdp;
499 unsigned short status;
494 struct sk_buff *skb; 500 struct sk_buff *skb;
495 501
496 fep = netdev_priv(dev); 502 fep = netdev_priv(dev);
497 spin_lock(&fep->lock); 503 spin_lock(&fep->lock);
498 bdp = fep->dirty_tx; 504 bdp = fep->dirty_tx;
499 505
500 while ((bdp->cbd_sc&BD_ENET_TX_READY) == 0) { 506 while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
501 if (bdp == fep->cur_tx && fep->tx_full == 0) break; 507 if (bdp == fep->cur_tx && fep->tx_full == 0) break;
502 508
503 skb = fep->tx_skbuff[fep->skb_dirty]; 509 skb = fep->tx_skbuff[fep->skb_dirty];
504 /* Check for errors. */ 510 /* Check for errors. */
505 if (bdp->cbd_sc & (BD_ENET_TX_HB | BD_ENET_TX_LC | 511 if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC |
506 BD_ENET_TX_RL | BD_ENET_TX_UN | 512 BD_ENET_TX_RL | BD_ENET_TX_UN |
507 BD_ENET_TX_CSL)) { 513 BD_ENET_TX_CSL)) {
508 fep->stats.tx_errors++; 514 fep->stats.tx_errors++;
509 if (bdp->cbd_sc & BD_ENET_TX_HB) /* No heartbeat */ 515 if (status & BD_ENET_TX_HB) /* No heartbeat */
510 fep->stats.tx_heartbeat_errors++; 516 fep->stats.tx_heartbeat_errors++;
511 if (bdp->cbd_sc & BD_ENET_TX_LC) /* Late collision */ 517 if (status & BD_ENET_TX_LC) /* Late collision */
512 fep->stats.tx_window_errors++; 518 fep->stats.tx_window_errors++;
513 if (bdp->cbd_sc & BD_ENET_TX_RL) /* Retrans limit */ 519 if (status & BD_ENET_TX_RL) /* Retrans limit */
514 fep->stats.tx_aborted_errors++; 520 fep->stats.tx_aborted_errors++;
515 if (bdp->cbd_sc & BD_ENET_TX_UN) /* Underrun */ 521 if (status & BD_ENET_TX_UN) /* Underrun */
516 fep->stats.tx_fifo_errors++; 522 fep->stats.tx_fifo_errors++;
517 if (bdp->cbd_sc & BD_ENET_TX_CSL) /* Carrier lost */ 523 if (status & BD_ENET_TX_CSL) /* Carrier lost */
518 fep->stats.tx_carrier_errors++; 524 fep->stats.tx_carrier_errors++;
519 } else { 525 } else {
520 fep->stats.tx_packets++; 526 fep->stats.tx_packets++;
521 } 527 }
522 528
523#ifndef final_version 529#ifndef final_version
524 if (bdp->cbd_sc & BD_ENET_TX_READY) 530 if (status & BD_ENET_TX_READY)
525 printk("HEY! Enet xmit interrupt and TX_READY.\n"); 531 printk("HEY! Enet xmit interrupt and TX_READY.\n");
526#endif 532#endif
527 /* Deferred means some collisions occurred during transmit, 533 /* Deferred means some collisions occurred during transmit,
528 * but we eventually sent the packet OK. 534 * but we eventually sent the packet OK.
529 */ 535 */
530 if (bdp->cbd_sc & BD_ENET_TX_DEF) 536 if (status & BD_ENET_TX_DEF)
531 fep->stats.collisions++; 537 fep->stats.collisions++;
532 538
533 /* Free the sk buffer associated with this last transmit. 539 /* Free the sk buffer associated with this last transmit.
@@ -538,7 +544,7 @@ fec_enet_tx(struct net_device *dev)
538 544
539 /* Update pointer to next buffer descriptor to be transmitted. 545 /* Update pointer to next buffer descriptor to be transmitted.
540 */ 546 */
541 if (bdp->cbd_sc & BD_ENET_TX_WRAP) 547 if (status & BD_ENET_TX_WRAP)
542 bdp = fep->tx_bd_base; 548 bdp = fep->tx_bd_base;
543 else 549 else
544 bdp++; 550 bdp++;
@@ -568,9 +574,14 @@ fec_enet_rx(struct net_device *dev)
568 struct fec_enet_private *fep; 574 struct fec_enet_private *fep;
569 volatile fec_t *fecp; 575 volatile fec_t *fecp;
570 volatile cbd_t *bdp; 576 volatile cbd_t *bdp;
577 unsigned short status;
571 struct sk_buff *skb; 578 struct sk_buff *skb;
572 ushort pkt_len; 579 ushort pkt_len;
573 __u8 *data; 580 __u8 *data;
581
582#ifdef CONFIG_M532x
583 flush_cache_all();
584#endif
574 585
575 fep = netdev_priv(dev); 586 fep = netdev_priv(dev);
576 fecp = (volatile fec_t*)dev->base_addr; 587 fecp = (volatile fec_t*)dev->base_addr;
@@ -580,13 +591,13 @@ fec_enet_rx(struct net_device *dev)
580 */ 591 */
581 bdp = fep->cur_rx; 592 bdp = fep->cur_rx;
582 593
583while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) { 594while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) {
584 595
585#ifndef final_version 596#ifndef final_version
586 /* Since we have allocated space to hold a complete frame, 597 /* Since we have allocated space to hold a complete frame,
587 * the last indicator should be set. 598 * the last indicator should be set.
588 */ 599 */
589 if ((bdp->cbd_sc & BD_ENET_RX_LAST) == 0) 600 if ((status & BD_ENET_RX_LAST) == 0)
590 printk("FEC ENET: rcv is not +last\n"); 601 printk("FEC ENET: rcv is not +last\n");
591#endif 602#endif
592 603
@@ -594,26 +605,26 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
594 goto rx_processing_done; 605 goto rx_processing_done;
595 606
596 /* Check for errors. */ 607 /* Check for errors. */
597 if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | 608 if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
598 BD_ENET_RX_CR | BD_ENET_RX_OV)) { 609 BD_ENET_RX_CR | BD_ENET_RX_OV)) {
599 fep->stats.rx_errors++; 610 fep->stats.rx_errors++;
600 if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { 611 if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
601 /* Frame too long or too short. */ 612 /* Frame too long or too short. */
602 fep->stats.rx_length_errors++; 613 fep->stats.rx_length_errors++;
603 } 614 }
604 if (bdp->cbd_sc & BD_ENET_RX_NO) /* Frame alignment */ 615 if (status & BD_ENET_RX_NO) /* Frame alignment */
605 fep->stats.rx_frame_errors++; 616 fep->stats.rx_frame_errors++;
606 if (bdp->cbd_sc & BD_ENET_RX_CR) /* CRC Error */ 617 if (status & BD_ENET_RX_CR) /* CRC Error */
607 fep->stats.rx_crc_errors++;
608 if (bdp->cbd_sc & BD_ENET_RX_OV) /* FIFO overrun */
609 fep->stats.rx_crc_errors++; 618 fep->stats.rx_crc_errors++;
619 if (status & BD_ENET_RX_OV) /* FIFO overrun */
620 fep->stats.rx_fifo_errors++;
610 } 621 }
611 622
612 /* Report late collisions as a frame error. 623 /* Report late collisions as a frame error.
613 * On this error, the BD is closed, but we don't know what we 624 * On this error, the BD is closed, but we don't know what we
614 * have in the buffer. So, just drop this frame on the floor. 625 * have in the buffer. So, just drop this frame on the floor.
615 */ 626 */
616 if (bdp->cbd_sc & BD_ENET_RX_CL) { 627 if (status & BD_ENET_RX_CL) {
617 fep->stats.rx_errors++; 628 fep->stats.rx_errors++;
618 fep->stats.rx_frame_errors++; 629 fep->stats.rx_frame_errors++;
619 goto rx_processing_done; 630 goto rx_processing_done;
@@ -639,9 +650,7 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
639 } else { 650 } else {
640 skb->dev = dev; 651 skb->dev = dev;
641 skb_put(skb,pkt_len-4); /* Make room */ 652 skb_put(skb,pkt_len-4); /* Make room */
642 eth_copy_and_sum(skb, 653 eth_copy_and_sum(skb, data, pkt_len-4, 0);
643 (unsigned char *)__va(bdp->cbd_bufaddr),
644 pkt_len-4, 0);
645 skb->protocol=eth_type_trans(skb,dev); 654 skb->protocol=eth_type_trans(skb,dev);
646 netif_rx(skb); 655 netif_rx(skb);
647 } 656 }
@@ -649,15 +658,16 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
649 658
650 /* Clear the status flags for this buffer. 659 /* Clear the status flags for this buffer.
651 */ 660 */
652 bdp->cbd_sc &= ~BD_ENET_RX_STATS; 661 status &= ~BD_ENET_RX_STATS;
653 662
654 /* Mark the buffer empty. 663 /* Mark the buffer empty.
655 */ 664 */
656 bdp->cbd_sc |= BD_ENET_RX_EMPTY; 665 status |= BD_ENET_RX_EMPTY;
666 bdp->cbd_sc = status;
657 667
658 /* Update BD pointer to next entry. 668 /* Update BD pointer to next entry.
659 */ 669 */
660 if (bdp->cbd_sc & BD_ENET_RX_WRAP) 670 if (status & BD_ENET_RX_WRAP)
661 bdp = fep->rx_bd_base; 671 bdp = fep->rx_bd_base;
662 else 672 else
663 bdp++; 673 bdp++;
@@ -667,9 +677,9 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
667 * incoming frames. On a heavily loaded network, we should be 677 * incoming frames. On a heavily loaded network, we should be
668 * able to keep up at the expense of system resources. 678 * able to keep up at the expense of system resources.
669 */ 679 */
670 fecp->fec_r_des_active = 0x01000000; 680 fecp->fec_r_des_active = 0;
671#endif 681#endif
672 } /* while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) */ 682 } /* while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) */
673 fep->cur_rx = (cbd_t *)bdp; 683 fep->cur_rx = (cbd_t *)bdp;
674 684
675#if 0 685#if 0
@@ -680,11 +690,12 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
680 * our way back to the interrupt return only to come right back 690 * our way back to the interrupt return only to come right back
681 * here. 691 * here.
682 */ 692 */
683 fecp->fec_r_des_active = 0x01000000; 693 fecp->fec_r_des_active = 0;
684#endif 694#endif
685} 695}
686 696
687 697
698/* called from interrupt context */
688static void 699static void
689fec_enet_mii(struct net_device *dev) 700fec_enet_mii(struct net_device *dev)
690{ 701{
@@ -696,10 +707,12 @@ fec_enet_mii(struct net_device *dev)
696 fep = netdev_priv(dev); 707 fep = netdev_priv(dev);
697 ep = fep->hwp; 708 ep = fep->hwp;
698 mii_reg = ep->fec_mii_data; 709 mii_reg = ep->fec_mii_data;
710
711 spin_lock(&fep->lock);
699 712
700 if ((mip = mii_head) == NULL) { 713 if ((mip = mii_head) == NULL) {
701 printk("MII and no head!\n"); 714 printk("MII and no head!\n");
702 return; 715 goto unlock;
703 } 716 }
704 717
705 if (mip->mii_func != NULL) 718 if (mip->mii_func != NULL)
@@ -711,6 +724,9 @@ fec_enet_mii(struct net_device *dev)
711 724
712 if ((mip = mii_head) != NULL) 725 if ((mip = mii_head) != NULL)
713 ep->fec_mii_data = mip->mii_regval; 726 ep->fec_mii_data = mip->mii_regval;
727
728unlock:
729 spin_unlock(&fep->lock);
714} 730}
715 731
716static int 732static int
@@ -728,8 +744,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
728 744
729 retval = 0; 745 retval = 0;
730 746
731 save_flags(flags); 747 spin_lock_irqsave(&fep->lock,flags);
732 cli();
733 748
734 if ((mip = mii_free) != NULL) { 749 if ((mip = mii_free) != NULL) {
735 mii_free = mip->mii_next; 750 mii_free = mip->mii_next;
@@ -749,7 +764,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
749 retval = 1; 764 retval = 1;
750 } 765 }
751 766
752 restore_flags(flags); 767 spin_unlock_irqrestore(&fep->lock,flags);
753 768
754 return(retval); 769 return(retval);
755} 770}
@@ -1216,7 +1231,7 @@ static phy_info_t const * const phy_info[] = {
1216}; 1231};
1217 1232
1218/* ------------------------------------------------------------------------- */ 1233/* ------------------------------------------------------------------------- */
1219 1234#if !defined(CONFIG_M532x)
1220#ifdef CONFIG_RPXCLASSIC 1235#ifdef CONFIG_RPXCLASSIC
1221static void 1236static void
1222mii_link_interrupt(void *dev_id); 1237mii_link_interrupt(void *dev_id);
@@ -1224,6 +1239,7 @@ mii_link_interrupt(void *dev_id);
1224static irqreturn_t 1239static irqreturn_t
1225mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs); 1240mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs);
1226#endif 1241#endif
1242#endif
1227 1243
1228#if defined(CONFIG_M5272) 1244#if defined(CONFIG_M5272)
1229 1245
@@ -1384,13 +1400,13 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1384 { 1400 {
1385 volatile unsigned char *icrp; 1401 volatile unsigned char *icrp;
1386 volatile unsigned long *imrp; 1402 volatile unsigned long *imrp;
1387 int i; 1403 int i, ilip;
1388 1404
1389 b = (fep->index) ? MCFICM_INTC1 : MCFICM_INTC0; 1405 b = (fep->index) ? MCFICM_INTC1 : MCFICM_INTC0;
1390 icrp = (volatile unsigned char *) (MCF_IPSBAR + b + 1406 icrp = (volatile unsigned char *) (MCF_IPSBAR + b +
1391 MCFINTC_ICR0); 1407 MCFINTC_ICR0);
1392 for (i = 23; (i < 36); i++) 1408 for (i = 23, ilip = 0x28; (i < 36); i++)
1393 icrp[i] = 0x23; 1409 icrp[i] = ilip--;
1394 1410
1395 imrp = (volatile unsigned long *) (MCF_IPSBAR + b + 1411 imrp = (volatile unsigned long *) (MCF_IPSBAR + b +
1396 MCFINTC_IMRH); 1412 MCFINTC_IMRH);
@@ -1618,6 +1634,159 @@ static void __inline__ fec_uncache(unsigned long addr)
1618 1634
1619/* ------------------------------------------------------------------------- */ 1635/* ------------------------------------------------------------------------- */
1620 1636
1637#elif defined(CONFIG_M532x)
1638/*
1639 * Code specific for M532x
1640 */
1641static void __inline__ fec_request_intrs(struct net_device *dev)
1642{
1643 struct fec_enet_private *fep;
1644 int b;
1645 static const struct idesc {
1646 char *name;
1647 unsigned short irq;
1648 } *idp, id[] = {
1649 { "fec(TXF)", 36 },
1650 { "fec(TXB)", 37 },
1651 { "fec(TXFIFO)", 38 },
1652 { "fec(TXCR)", 39 },
1653 { "fec(RXF)", 40 },
1654 { "fec(RXB)", 41 },
1655 { "fec(MII)", 42 },
1656 { "fec(LC)", 43 },
1657 { "fec(HBERR)", 44 },
1658 { "fec(GRA)", 45 },
1659 { "fec(EBERR)", 46 },
1660 { "fec(BABT)", 47 },
1661 { "fec(BABR)", 48 },
1662 { NULL },
1663 };
1664
1665 fep = netdev_priv(dev);
1666 b = (fep->index) ? 128 : 64;
1667
1668 /* Setup interrupt handlers. */
1669 for (idp = id; idp->name; idp++) {
1670 if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0)
1671 printk("FEC: Could not allocate %s IRQ(%d)!\n",
1672 idp->name, b+idp->irq);
1673 }
1674
1675 /* Unmask interrupts */
1676 MCF_INTC0_ICR36 = 0x2;
1677 MCF_INTC0_ICR37 = 0x2;
1678 MCF_INTC0_ICR38 = 0x2;
1679 MCF_INTC0_ICR39 = 0x2;
1680 MCF_INTC0_ICR40 = 0x2;
1681 MCF_INTC0_ICR41 = 0x2;
1682 MCF_INTC0_ICR42 = 0x2;
1683 MCF_INTC0_ICR43 = 0x2;
1684 MCF_INTC0_ICR44 = 0x2;
1685 MCF_INTC0_ICR45 = 0x2;
1686 MCF_INTC0_ICR46 = 0x2;
1687 MCF_INTC0_ICR47 = 0x2;
1688 MCF_INTC0_ICR48 = 0x2;
1689
1690 MCF_INTC0_IMRH &= ~(
1691 MCF_INTC_IMRH_INT_MASK36 |
1692 MCF_INTC_IMRH_INT_MASK37 |
1693 MCF_INTC_IMRH_INT_MASK38 |
1694 MCF_INTC_IMRH_INT_MASK39 |
1695 MCF_INTC_IMRH_INT_MASK40 |
1696 MCF_INTC_IMRH_INT_MASK41 |
1697 MCF_INTC_IMRH_INT_MASK42 |
1698 MCF_INTC_IMRH_INT_MASK43 |
1699 MCF_INTC_IMRH_INT_MASK44 |
1700 MCF_INTC_IMRH_INT_MASK45 |
1701 MCF_INTC_IMRH_INT_MASK46 |
1702 MCF_INTC_IMRH_INT_MASK47 |
1703 MCF_INTC_IMRH_INT_MASK48 );
1704
1705 /* Set up gpio outputs for MII lines */
1706 MCF_GPIO_PAR_FECI2C |= (0 |
1707 MCF_GPIO_PAR_FECI2C_PAR_MDC_EMDC |
1708 MCF_GPIO_PAR_FECI2C_PAR_MDIO_EMDIO);
1709 MCF_GPIO_PAR_FEC = (0 |
1710 MCF_GPIO_PAR_FEC_PAR_FEC_7W_FEC |
1711 MCF_GPIO_PAR_FEC_PAR_FEC_MII_FEC);
1712}
1713
1714static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
1715{
1716 volatile fec_t *fecp;
1717
1718 fecp = fep->hwp;
1719 fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;
1720 fecp->fec_x_cntrl = 0x00;
1721
1722 /*
1723 * Set MII speed to 2.5 MHz
1724 */
1725 fep->phy_speed = ((((MCF_CLK / 2) / (2500000 / 10)) + 5) / 10) * 2;
1726 fecp->fec_mii_speed = fep->phy_speed;
1727
1728 fec_restart(dev, 0);
1729}
1730
1731static void __inline__ fec_get_mac(struct net_device *dev)
1732{
1733 struct fec_enet_private *fep = netdev_priv(dev);
1734 volatile fec_t *fecp;
1735 unsigned char *iap, tmpaddr[ETH_ALEN];
1736
1737 fecp = fep->hwp;
1738
1739 if (FEC_FLASHMAC) {
1740 /*
1741 * Get MAC address from FLASH.
1742 * If it is all 1's or 0's, use the default.
1743 */
1744 iap = FEC_FLASHMAC;
1745 if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
1746 (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
1747 iap = fec_mac_default;
1748 if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
1749 (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
1750 iap = fec_mac_default;
1751 } else {
1752 *((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low;
1753 *((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16);
1754 iap = &tmpaddr[0];
1755 }
1756
1757 memcpy(dev->dev_addr, iap, ETH_ALEN);
1758
1759 /* Adjust MAC if using default MAC address */
1760 if (iap == fec_mac_default)
1761 dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index;
1762}
1763
1764static void __inline__ fec_enable_phy_intr(void)
1765{
1766}
1767
1768static void __inline__ fec_disable_phy_intr(void)
1769{
1770}
1771
1772static void __inline__ fec_phy_ack_intr(void)
1773{
1774}
1775
1776static void __inline__ fec_localhw_setup(void)
1777{
1778}
1779
1780/*
1781 * Do not need to make region uncached on 532x.
1782 */
1783static void __inline__ fec_uncache(unsigned long addr)
1784{
1785}
1786
1787/* ------------------------------------------------------------------------- */
1788
1789
1621#else 1790#else
1622 1791
1623/* 1792/*
@@ -1985,9 +2154,12 @@ fec_enet_open(struct net_device *dev)
1985 mii_do_cmd(dev, fep->phy->config); 2154 mii_do_cmd(dev, fep->phy->config);
1986 mii_do_cmd(dev, phy_cmd_config); /* display configuration */ 2155 mii_do_cmd(dev, phy_cmd_config); /* display configuration */
1987 2156
1988 /* FIXME: use netif_carrier_{on,off} ; this polls 2157 /* Poll until the PHY tells us its configuration
1989 * until link is up which is wrong... could be 2158 * (not link state).
1990 * 30 seconds or more we are trapped in here. -jgarzik 2159 * Request is initiated by mii_do_cmd above, but answer
2160 * comes by interrupt.
2161 * This should take about 25 usec per register at 2.5 MHz,
2162 * and we read approximately 5 registers.
1991 */ 2163 */
1992 while(!fep->sequence_done) 2164 while(!fep->sequence_done)
1993 schedule(); 2165 schedule();
@@ -2253,15 +2425,11 @@ int __init fec_enet_init(struct net_device *dev)
2253 */ 2425 */
2254 fec_request_intrs(dev); 2426 fec_request_intrs(dev);
2255 2427
2256 /* Clear and enable interrupts */
2257 fecp->fec_ievent = 0xffc00000;
2258 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2259 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2260 fecp->fec_hash_table_high = 0; 2428 fecp->fec_hash_table_high = 0;
2261 fecp->fec_hash_table_low = 0; 2429 fecp->fec_hash_table_low = 0;
2262 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; 2430 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
2263 fecp->fec_ecntrl = 2; 2431 fecp->fec_ecntrl = 2;
2264 fecp->fec_r_des_active = 0x01000000; 2432 fecp->fec_r_des_active = 0;
2265 2433
2266 dev->base_addr = (unsigned long)fecp; 2434 dev->base_addr = (unsigned long)fecp;
2267 2435
@@ -2281,6 +2449,11 @@ int __init fec_enet_init(struct net_device *dev)
2281 /* setup MII interface */ 2449 /* setup MII interface */
2282 fec_set_mii(dev, fep); 2450 fec_set_mii(dev, fep);
2283 2451
2452 /* Clear and enable interrupts */
2453 fecp->fec_ievent = 0xffc00000;
2454 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2455 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2456
2284 /* Queue up command to detect the PHY and initialize the 2457 /* Queue up command to detect the PHY and initialize the
2285 * remainder of the interface. 2458 * remainder of the interface.
2286 */ 2459 */
@@ -2312,11 +2485,6 @@ fec_restart(struct net_device *dev, int duplex)
2312 fecp->fec_ecntrl = 1; 2485 fecp->fec_ecntrl = 1;
2313 udelay(10); 2486 udelay(10);
2314 2487
2315 /* Enable interrupts we wish to service.
2316 */
2317 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2318 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2319
2320 /* Clear any outstanding interrupt. 2488 /* Clear any outstanding interrupt.
2321 */ 2489 */
2322 fecp->fec_ievent = 0xffc00000; 2490 fecp->fec_ievent = 0xffc00000;
@@ -2408,7 +2576,12 @@ fec_restart(struct net_device *dev, int duplex)
2408 /* And last, enable the transmit and receive processing. 2576 /* And last, enable the transmit and receive processing.
2409 */ 2577 */
2410 fecp->fec_ecntrl = 2; 2578 fecp->fec_ecntrl = 2;
2411 fecp->fec_r_des_active = 0x01000000; 2579 fecp->fec_r_des_active = 0;
2580
2581 /* Enable interrupts we wish to service.
2582 */
2583 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2584 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2412} 2585}
2413 2586
2414static void 2587static void
@@ -2420,9 +2593,16 @@ fec_stop(struct net_device *dev)
2420 fep = netdev_priv(dev); 2593 fep = netdev_priv(dev);
2421 fecp = fep->hwp; 2594 fecp = fep->hwp;
2422 2595
2423 fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */ 2596 /*
2424 2597 ** We cannot expect a graceful transmit stop without link !!!
2425 while(!(fecp->fec_ievent & FEC_ENET_GRA)); 2598 */
2599 if (fep->link)
2600 {
2601 fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */
2602 udelay(10);
2603 if (!(fecp->fec_ievent & FEC_ENET_GRA))
2604 printk("fec_stop : Graceful transmit stop did not complete !\n");
2605 }
2426 2606
2427 /* Whack a reset. We should wait for this. 2607 /* Whack a reset. We should wait for this.
2428 */ 2608 */
diff --git a/drivers/net/fs_enet/fs_enet-mii.c b/drivers/net/fs_enet/fs_enet-mii.c
index c6770377ef87..0cd07150bf4a 100644
--- a/drivers/net/fs_enet/fs_enet-mii.c
+++ b/drivers/net/fs_enet/fs_enet-mii.c
@@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bus(const struct fs_mii_bus_info *bi)
431 return bus; 431 return bus;
432 432
433err: 433err:
434 if (bus) 434 kfree(bus);
435 kfree(bus);
436 return ERR_PTR(ret); 435 return ERR_PTR(ret);
437} 436}
438 437
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0d5fccc984bb..c9a46b89942a 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -436,7 +436,7 @@ static int __init dmascc_init(void)
436module_init(dmascc_init); 436module_init(dmascc_init);
437module_exit(dmascc_exit); 437module_exit(dmascc_exit);
438 438
439static void dev_setup(struct net_device *dev) 439static void __init dev_setup(struct net_device *dev)
440{ 440{
441 dev->type = ARPHRD_AX25; 441 dev->type = ARPHRD_AX25;
442 dev->hard_header_len = AX25_MAX_HEADER_LEN; 442 dev->hard_header_len = AX25_MAX_HEADER_LEN;
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 2e4ecedba057..5657049c2160 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -226,7 +226,6 @@ static int full_duplex[MAX_UNITS];
226 NATSEMI_PG1_NREGS) 226 NATSEMI_PG1_NREGS)
227#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */ 227#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */
228#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32)) 228#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32))
229#define NATSEMI_DEF_EEPROM_SIZE 24 /* 12 16-bit values */
230 229
231/* Buffer sizes: 230/* Buffer sizes:
232 * The nic writes 32-bit values, even if the upper bytes of 231 * The nic writes 32-bit values, even if the upper bytes of
@@ -344,18 +343,6 @@ None characterised.
344 343
345 344
346 345
347enum pcistuff {
348 PCI_USES_IO = 0x01,
349 PCI_USES_MEM = 0x02,
350 PCI_USES_MASTER = 0x04,
351 PCI_ADDR0 = 0x08,
352 PCI_ADDR1 = 0x10,
353};
354
355/* MMIO operations required */
356#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
357
358
359/* 346/*
360 * Support for fibre connections on Am79C874: 347 * Support for fibre connections on Am79C874:
361 * This phy needs a special setup when connected to a fibre cable. 348 * This phy needs a special setup when connected to a fibre cable.
@@ -363,22 +350,25 @@ enum pcistuff {
363 */ 350 */
364#define PHYID_AM79C874 0x0022561b 351#define PHYID_AM79C874 0x0022561b
365 352
366#define MII_MCTRL 0x15 /* mode control register */ 353enum {
367#define MII_FX_SEL 0x0001 /* 100BASE-FX (fiber) */ 354 MII_MCTRL = 0x15, /* mode control register */
368#define MII_EN_SCRM 0x0004 /* enable scrambler (tp) */ 355 MII_FX_SEL = 0x0001, /* 100BASE-FX (fiber) */
356 MII_EN_SCRM = 0x0004, /* enable scrambler (tp) */
357};
369 358
370 359
371/* array of board data directly indexed by pci_tbl[x].driver_data */ 360/* array of board data directly indexed by pci_tbl[x].driver_data */
372static const struct { 361static const struct {
373 const char *name; 362 const char *name;
374 unsigned long flags; 363 unsigned long flags;
364 unsigned int eeprom_size;
375} natsemi_pci_info[] __devinitdata = { 365} natsemi_pci_info[] __devinitdata = {
376 { "NatSemi DP8381[56]", PCI_IOTYPE }, 366 { "NatSemi DP8381[56]", 0, 24 },
377}; 367};
378 368
379static struct pci_device_id natsemi_pci_tbl[] = { 369static const struct pci_device_id natsemi_pci_tbl[] __devinitdata = {
380 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_ANY_ID, PCI_ANY_ID, }, 370 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
381 { 0, }, 371 { } /* terminate list */
382}; 372};
383MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl); 373MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl);
384 374
@@ -813,6 +803,42 @@ static void move_int_phy(struct net_device *dev, int addr)
813 udelay(1); 803 udelay(1);
814} 804}
815 805
806static void __devinit natsemi_init_media (struct net_device *dev)
807{
808 struct netdev_private *np = netdev_priv(dev);
809 u32 tmp;
810
811 netif_carrier_off(dev);
812
813 /* get the initial settings from hardware */
814 tmp = mdio_read(dev, MII_BMCR);
815 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
816 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
817 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
818 np->advertising= mdio_read(dev, MII_ADVERTISE);
819
820 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
821 && netif_msg_probe(np)) {
822 printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
823 "10%s %s duplex.\n",
824 pci_name(np->pci_dev),
825 (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
826 "enabled, advertise" : "disabled, force",
827 (np->advertising &
828 (ADVERTISE_100FULL|ADVERTISE_100HALF))?
829 "0" : "",
830 (np->advertising &
831 (ADVERTISE_100FULL|ADVERTISE_10FULL))?
832 "full" : "half");
833 }
834 if (netif_msg_probe(np))
835 printk(KERN_INFO
836 "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
837 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
838 np->advertising);
839
840}
841
816static int __devinit natsemi_probe1 (struct pci_dev *pdev, 842static int __devinit natsemi_probe1 (struct pci_dev *pdev,
817 const struct pci_device_id *ent) 843 const struct pci_device_id *ent)
818{ 844{
@@ -852,8 +878,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
852 iosize = pci_resource_len(pdev, pcibar); 878 iosize = pci_resource_len(pdev, pcibar);
853 irq = pdev->irq; 879 irq = pdev->irq;
854 880
855 if (natsemi_pci_info[chip_idx].flags & PCI_USES_MASTER) 881 pci_set_master(pdev);
856 pci_set_master(pdev);
857 882
858 dev = alloc_etherdev(sizeof (struct netdev_private)); 883 dev = alloc_etherdev(sizeof (struct netdev_private));
859 if (!dev) 884 if (!dev)
@@ -892,7 +917,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
892 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG; 917 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
893 np->hands_off = 0; 918 np->hands_off = 0;
894 np->intr_status = 0; 919 np->intr_status = 0;
895 np->eeprom_size = NATSEMI_DEF_EEPROM_SIZE; 920 np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size;
896 921
897 /* Initial port: 922 /* Initial port:
898 * - If the nic was configured to use an external phy and if find_mii 923 * - If the nic was configured to use an external phy and if find_mii
@@ -957,34 +982,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
957 if (mtu) 982 if (mtu)
958 dev->mtu = mtu; 983 dev->mtu = mtu;
959 984
960 netif_carrier_off(dev); 985 natsemi_init_media(dev);
961
962 /* get the initial settings from hardware */
963 tmp = mdio_read(dev, MII_BMCR);
964 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
965 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
966 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
967 np->advertising= mdio_read(dev, MII_ADVERTISE);
968
969 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
970 && netif_msg_probe(np)) {
971 printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
972 "10%s %s duplex.\n",
973 pci_name(np->pci_dev),
974 (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
975 "enabled, advertise" : "disabled, force",
976 (np->advertising &
977 (ADVERTISE_100FULL|ADVERTISE_100HALF))?
978 "0" : "",
979 (np->advertising &
980 (ADVERTISE_100FULL|ADVERTISE_10FULL))?
981 "full" : "half");
982 }
983 if (netif_msg_probe(np))
984 printk(KERN_INFO
985 "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
986 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
987 np->advertising);
988 986
989 /* save the silicon revision for later querying */ 987 /* save the silicon revision for later querying */
990 np->srr = readl(ioaddr + SiliconRev); 988 np->srr = readl(ioaddr + SiliconRev);
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index fc08c4af506c..0e01c75da429 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -309,12 +309,6 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name);
309static void pcnet32_free_ring(struct net_device *dev); 309static void pcnet32_free_ring(struct net_device *dev);
310static void pcnet32_check_media(struct net_device *dev, int verbose); 310static void pcnet32_check_media(struct net_device *dev, int verbose);
311 311
312enum pci_flags_bit {
313 PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4,
314 PCI_ADDR0 = 0x10 << 0, PCI_ADDR1 = 0x10 << 1, PCI_ADDR2 =
315 0x10 << 2, PCI_ADDR3 = 0x10 << 3,
316};
317
318static u16 pcnet32_wio_read_csr(unsigned long addr, int index) 312static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
319{ 313{
320 outw(index, addr + PCNET32_WIO_RAP); 314 outw(index, addr + PCNET32_WIO_RAP);
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index bef79e454c33..3f702c503afe 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -123,9 +123,9 @@ static int lxt971_config_intr(struct phy_device *phydev)
123} 123}
124 124
125static struct phy_driver lxt970_driver = { 125static struct phy_driver lxt970_driver = {
126 .phy_id = 0x07810000, 126 .phy_id = 0x78100000,
127 .name = "LXT970", 127 .name = "LXT970",
128 .phy_id_mask = 0x0fffffff, 128 .phy_id_mask = 0xfffffff0,
129 .features = PHY_BASIC_FEATURES, 129 .features = PHY_BASIC_FEATURES,
130 .flags = PHY_HAS_INTERRUPT, 130 .flags = PHY_HAS_INTERRUPT,
131 .config_init = lxt970_config_init, 131 .config_init = lxt970_config_init,
@@ -137,9 +137,9 @@ static struct phy_driver lxt970_driver = {
137}; 137};
138 138
139static struct phy_driver lxt971_driver = { 139static struct phy_driver lxt971_driver = {
140 .phy_id = 0x0001378e, 140 .phy_id = 0x001378e0,
141 .name = "LXT971", 141 .name = "LXT971",
142 .phy_id_mask = 0x0fffffff, 142 .phy_id_mask = 0xfffffff0,
143 .features = PHY_BASIC_FEATURES, 143 .features = PHY_BASIC_FEATURES,
144 .flags = PHY_HAS_INTERRUPT, 144 .flags = PHY_HAS_INTERRUPT,
145 .config_aneg = genphy_config_aneg, 145 .config_aneg = genphy_config_aneg,
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index d643a097faa5..425ff5b117f1 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -28,7 +28,6 @@
28#include <linux/kmod.h> 28#include <linux/kmod.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/list.h> 30#include <linux/list.h>
31#include <linux/devfs_fs_kernel.h>
32#include <linux/netdevice.h> 31#include <linux/netdevice.h>
33#include <linux/poll.h> 32#include <linux/poll.h>
34#include <linux/ppp_defs.h> 33#include <linux/ppp_defs.h>
@@ -863,10 +862,6 @@ static int __init ppp_init(void)
863 goto out_chrdev; 862 goto out_chrdev;
864 } 863 }
865 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); 864 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
866 err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
867 S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
868 if (err)
869 goto out_class;
870 } 865 }
871 866
872out: 867out:
@@ -874,9 +869,6 @@ out:
874 printk(KERN_ERR "failed to register PPP device (%d)\n", err); 869 printk(KERN_ERR "failed to register PPP device (%d)\n", err);
875 return err; 870 return err;
876 871
877out_class:
878 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR,0));
879 class_destroy(ppp_class);
880out_chrdev: 872out_chrdev:
881 unregister_chrdev(PPP_MAJOR, "ppp"); 873 unregister_chrdev(PPP_MAJOR, "ppp");
882 goto out; 874 goto out;
@@ -2681,7 +2673,6 @@ static void __exit ppp_cleanup(void)
2681 cardmap_destroy(&all_ppp_units); 2673 cardmap_destroy(&all_ppp_units);
2682 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0) 2674 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
2683 printk(KERN_ERR "PPP: failed to unregister PPP device\n"); 2675 printk(KERN_ERR "PPP: failed to unregister PPP device\n");
2684 devfs_remove("ppp");
2685 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0)); 2676 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
2686 class_destroy(ppp_class); 2677 class_destroy(ppp_class);
2687} 2678}
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 19a4a16055dc..1608efab4e3d 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -3354,8 +3354,8 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3354 if (err) 3354 if (err)
3355 goto err_out_free_irq; 3355 goto err_out_free_irq;
3356 3356
3357 printk(KERN_INFO PFX DRV_VERSION " addr 0x%lx irq %d chip %s rev %d\n", 3357 printk(KERN_INFO PFX DRV_VERSION " addr 0x%llx irq %d chip %s rev %d\n",
3358 pci_resource_start(pdev, 0), pdev->irq, 3358 (unsigned long long)pci_resource_start(pdev, 0), pdev->irq,
3359 skge_board_name(hw), hw->chip_rev); 3359 skge_board_name(hw), hw->chip_rev);
3360 3360
3361 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL) 3361 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index d3577871be28..e122007e16da 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -3311,9 +3311,9 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3311 if (err) 3311 if (err)
3312 goto err_out_iounmap; 3312 goto err_out_iounmap;
3313 3313
3314 printk(KERN_INFO PFX "v%s addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n", 3314 printk(KERN_INFO PFX "v%s addr 0x%llx irq %d Yukon-%s (0x%x) rev %d\n",
3315 DRV_VERSION, pci_resource_start(pdev, 0), pdev->irq, 3315 DRV_VERSION, (unsigned long long)pci_resource_start(pdev, 0),
3316 yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], 3316 pdev->irq, yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL],
3317 hw->chip_id, hw->chip_rev); 3317 hw->chip_id, hw->chip_rev);
3318 3318
3319 dev = sky2_init_netdev(hw, 0, using_dac); 3319 dev = sky2_init_netdev(hw, 0, using_dac);
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 5f743b972949..fc2468ecce0b 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -2007,8 +2007,8 @@ static int __init de_init_one (struct pci_dev *pdev,
2007 } 2007 }
2008 if (pci_resource_len(pdev, 1) < DE_REGS_SIZE) { 2008 if (pci_resource_len(pdev, 1) < DE_REGS_SIZE) {
2009 rc = -EIO; 2009 rc = -EIO;
2010 printk(KERN_ERR PFX "MMIO resource (%lx) too small on pci dev %s\n", 2010 printk(KERN_ERR PFX "MMIO resource (%llx) too small on pci dev %s\n",
2011 pci_resource_len(pdev, 1), pci_name(pdev)); 2011 (unsigned long long)pci_resource_len(pdev, 1), pci_name(pdev));
2012 goto err_out_res; 2012 goto err_out_res;
2013 } 2013 }
2014 2014
@@ -2016,8 +2016,9 @@ static int __init de_init_one (struct pci_dev *pdev,
2016 regs = ioremap_nocache(pciaddr, DE_REGS_SIZE); 2016 regs = ioremap_nocache(pciaddr, DE_REGS_SIZE);
2017 if (!regs) { 2017 if (!regs) {
2018 rc = -EIO; 2018 rc = -EIO;
2019 printk(KERN_ERR PFX "Cannot map PCI MMIO (%lx@%lx) on pci dev %s\n", 2019 printk(KERN_ERR PFX "Cannot map PCI MMIO (%llx@%lx) on pci dev %s\n",
2020 pci_resource_len(pdev, 1), pciaddr, pci_name(pdev)); 2020 (unsigned long long)pci_resource_len(pdev, 1),
2021 pciaddr, pci_name(pdev));
2021 goto err_out_res; 2022 goto err_out_res;
2022 } 2023 }
2023 dev->base_addr = (unsigned long) regs; 2024 dev->base_addr = (unsigned long) regs;
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index e0de66739a42..53fd9b56d0bd 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1350,10 +1350,10 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1350 SET_MODULE_OWNER(dev); 1350 SET_MODULE_OWNER(dev);
1351 SET_NETDEV_DEV(dev, &pdev->dev); 1351 SET_NETDEV_DEV(dev, &pdev->dev);
1352 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) { 1352 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) {
1353 printk (KERN_ERR PFX "%s: I/O region (0x%lx@0x%lx) too small, " 1353 printk (KERN_ERR PFX "%s: I/O region (0x%llx@0x%llx) too small, "
1354 "aborting\n", pci_name(pdev), 1354 "aborting\n", pci_name(pdev),
1355 pci_resource_len (pdev, 0), 1355 (unsigned long long)pci_resource_len (pdev, 0),
1356 pci_resource_start (pdev, 0)); 1356 (unsigned long long)pci_resource_start (pdev, 0));
1357 goto err_out_free_netdev; 1357 goto err_out_free_netdev;
1358 } 1358 }
1359 1359
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 8fea2aa455d4..602a6e5002a0 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -212,26 +212,15 @@ Test with 'ping -s 10000' on a fast computer.
212/* 212/*
213 PCI probe table. 213 PCI probe table.
214*/ 214*/
215enum pci_id_flags_bits {
216 /* Set PCI command register bits before calling probe1(). */
217 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
218 /* Read and map the single following PCI BAR. */
219 PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
220 PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
221};
222enum chip_capability_flags { 215enum chip_capability_flags {
223 CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,}; 216 CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,
224#ifdef USE_IO_OPS 217};
225#define W840_FLAGS (PCI_USES_IO | PCI_ADDR0 | PCI_USES_MASTER)
226#else
227#define W840_FLAGS (PCI_USES_MEM | PCI_ADDR1 | PCI_USES_MASTER)
228#endif
229 218
230static struct pci_device_id w840_pci_tbl[] = { 219static const struct pci_device_id w840_pci_tbl[] = {
231 { 0x1050, 0x0840, PCI_ANY_ID, 0x8153, 0, 0, 0 }, 220 { 0x1050, 0x0840, PCI_ANY_ID, 0x8153, 0, 0, 0 },
232 { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 221 { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
233 { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 222 { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
234 { 0, } 223 { }
235}; 224};
236MODULE_DEVICE_TABLE(pci, w840_pci_tbl); 225MODULE_DEVICE_TABLE(pci, w840_pci_tbl);
237 226
@@ -241,18 +230,17 @@ struct pci_id_info {
241 int pci, pci_mask, subsystem, subsystem_mask; 230 int pci, pci_mask, subsystem, subsystem_mask;
242 int revision, revision_mask; /* Only 8 bits. */ 231 int revision, revision_mask; /* Only 8 bits. */
243 } id; 232 } id;
244 enum pci_id_flags_bits pci_flags;
245 int io_size; /* Needed for I/O region check or ioremap(). */ 233 int io_size; /* Needed for I/O region check or ioremap(). */
246 int drv_flags; /* Driver use, intended as capability flags. */ 234 int drv_flags; /* Driver use, intended as capability flags. */
247}; 235};
248static struct pci_id_info pci_id_tbl[] = { 236static struct pci_id_info pci_id_tbl[] = {
249 {"Winbond W89c840", /* Sometime a Level-One switch card. */ 237 {"Winbond W89c840", /* Sometime a Level-One switch card. */
250 { 0x08401050, 0xffffffff, 0x81530000, 0xffff0000 }, 238 { 0x08401050, 0xffffffff, 0x81530000, 0xffff0000 },
251 W840_FLAGS, 128, CanHaveMII | HasBrokenTx | FDXOnNoMII}, 239 128, CanHaveMII | HasBrokenTx | FDXOnNoMII},
252 {"Winbond W89c840", { 0x08401050, 0xffffffff, }, 240 {"Winbond W89c840", { 0x08401050, 0xffffffff, },
253 W840_FLAGS, 128, CanHaveMII | HasBrokenTx}, 241 128, CanHaveMII | HasBrokenTx},
254 {"Compex RL100-ATX", { 0x201111F6, 0xffffffff,}, 242 {"Compex RL100-ATX", { 0x201111F6, 0xffffffff,},
255 W840_FLAGS, 128, CanHaveMII | HasBrokenTx}, 243 128, CanHaveMII | HasBrokenTx},
256 {NULL,}, /* 0 terminated list. */ 244 {NULL,}, /* 0 terminated list. */
257}; 245};
258 246
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6c62d5c88268..732c5edec2e5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -780,7 +780,6 @@ static struct miscdevice tun_miscdev = {
780 .minor = TUN_MINOR, 780 .minor = TUN_MINOR,
781 .name = "tun", 781 .name = "tun",
782 .fops = &tun_fops, 782 .fops = &tun_fops,
783 .devfs_name = "net/tun",
784}; 783};
785 784
786/* ethtool interface */ 785/* ethtool interface */
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index e49e8b520c28..e24d2dafcf6c 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -2568,9 +2568,10 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2568 2568
2569 pci_set_drvdata(pdev, dev); 2569 pci_set_drvdata(pdev, dev);
2570 2570
2571 printk(KERN_INFO "%s: %s at %s 0x%lx, ", 2571 printk(KERN_INFO "%s: %s at %s 0x%llx, ",
2572 dev->name, typhoon_card_info[card_id].name, 2572 dev->name, typhoon_card_info[card_id].name,
2573 use_mmio ? "MMIO" : "IO", pci_resource_start(pdev, use_mmio)); 2573 use_mmio ? "MMIO" : "IO",
2574 (unsigned long long)pci_resource_start(pdev, use_mmio));
2574 for(i = 0; i < 5; i++) 2575 for(i = 0; i < 5; i++)
2575 printk("%2.2x:", dev->dev_addr[i]); 2576 printk("%2.2x:", dev->dev_addr[i]);
2576 printk("%2.2x\n", dev->dev_addr[i]); 2577 printk("%2.2x\n", dev->dev_addr[i]);
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
index b60ef02db7b0..c92ac9fde083 100644
--- a/drivers/net/wan/c101.c
+++ b/drivers/net/wan/c101.c
@@ -7,7 +7,7 @@
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation. 8 * as published by the Free Software Foundation.
9 * 9 *
10 * For information see http://hq.pm.waw.pl/hdlc/ 10 * For information see <http://www.kernel.org/pub/linux/utils/net/hdlc/>
11 * 11 *
12 * Sources of information: 12 * Sources of information:
13 * Hitachi HD64570 SCA User's Manual 13 * Hitachi HD64570 SCA User's Manual
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index e392ee8b37a1..be5e33814cb1 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -85,7 +85,6 @@
85#include <linux/slab.h> 85#include <linux/slab.h>
86#include <linux/poll.h> 86#include <linux/poll.h>
87#include <linux/fs.h> 87#include <linux/fs.h>
88#include <linux/devfs_fs_kernel.h>
89#include <linux/interrupt.h> 88#include <linux/interrupt.h>
90#include <linux/delay.h> 89#include <linux/delay.h>
91#include <linux/errno.h> 90#include <linux/errno.h>
@@ -393,7 +392,6 @@ static int __init cosa_init(void)
393 err = -ENODEV; 392 err = -ENODEV;
394 goto out; 393 goto out;
395 } 394 }
396 devfs_mk_dir("cosa");
397 cosa_class = class_create(THIS_MODULE, "cosa"); 395 cosa_class = class_create(THIS_MODULE, "cosa");
398 if (IS_ERR(cosa_class)) { 396 if (IS_ERR(cosa_class)) {
399 err = PTR_ERR(cosa_class); 397 err = PTR_ERR(cosa_class);
@@ -402,13 +400,6 @@ static int __init cosa_init(void)
402 for (i=0; i<nr_cards; i++) { 400 for (i=0; i<nr_cards; i++) {
403 class_device_create(cosa_class, NULL, MKDEV(cosa_major, i), 401 class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
404 NULL, "cosa%d", i); 402 NULL, "cosa%d", i);
405 err = devfs_mk_cdev(MKDEV(cosa_major, i),
406 S_IFCHR|S_IRUSR|S_IWUSR,
407 "cosa/%d", i);
408 if (err) {
409 class_device_destroy(cosa_class, MKDEV(cosa_major, i));
410 goto out_chrdev;
411 }
412 } 403 }
413 err = 0; 404 err = 0;
414 goto out; 405 goto out;
@@ -426,12 +417,9 @@ static void __exit cosa_exit(void)
426 int i; 417 int i;
427 printk(KERN_INFO "Unloading the cosa module\n"); 418 printk(KERN_INFO "Unloading the cosa module\n");
428 419
429 for (i=0; i<nr_cards; i++) { 420 for (i=0; i<nr_cards; i++)
430 class_device_destroy(cosa_class, MKDEV(cosa_major, i)); 421 class_device_destroy(cosa_class, MKDEV(cosa_major, i));
431 devfs_remove("cosa/%d", i);
432 }
433 class_destroy(cosa_class); 422 class_destroy(cosa_class);
434 devfs_remove("cosa");
435 for (cosa=cosa_cards; nr_cards--; cosa++) { 423 for (cosa=cosa_cards; nr_cards--; cosa++) {
436 /* Clean up the per-channel data */ 424 /* Clean up the per-channel data */
437 for (i=0; i<cosa->nchannels; i++) { 425 for (i=0; i<cosa->nchannels; i++) {
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 4505540e3c59..04a376ec0ed8 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -732,15 +732,15 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
732 ioaddr = ioremap(pci_resource_start(pdev, 0), 732 ioaddr = ioremap(pci_resource_start(pdev, 0),
733 pci_resource_len(pdev, 0)); 733 pci_resource_len(pdev, 0));
734 if (!ioaddr) { 734 if (!ioaddr) {
735 printk(KERN_ERR "%s: cannot remap MMIO region %lx @ %lx\n", 735 printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n",
736 DRV_NAME, pci_resource_len(pdev, 0), 736 DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0),
737 pci_resource_start(pdev, 0)); 737 (unsigned long long)pci_resource_start(pdev, 0));
738 rc = -EIO; 738 rc = -EIO;
739 goto err_free_mmio_regions_2; 739 goto err_free_mmio_regions_2;
740 } 740 }
741 printk(KERN_DEBUG "Siemens DSCC4, MMIO at %#lx (regs), %#lx (lbi), IRQ %d\n", 741 printk(KERN_DEBUG "Siemens DSCC4, MMIO at %#llx (regs), %#llx (lbi), IRQ %d\n",
742 pci_resource_start(pdev, 0), 742 (unsigned long long)pci_resource_start(pdev, 0),
743 pci_resource_start(pdev, 1), pdev->irq); 743 (unsigned long long)pci_resource_start(pdev, 1), pdev->irq);
744 744
745 /* Cf errata DS5 p.2 */ 745 /* Cf errata DS5 p.2 */
746 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xf8); 746 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xf8);
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index b7d88db89a5c..e013b817cab8 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -7,7 +7,7 @@
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation. 8 * as published by the Free Software Foundation.
9 * 9 *
10 * For information see http://hq.pm.waw.pl/hdlc/ 10 * For information see <http://www.kernel.org/pub/linux/utils/net/hdlc/>
11 * 11 *
12 * Note: integrated CSU/DSU/DDS are not supported by this driver 12 * Note: integrated CSU/DSU/DDS are not supported by this driver
13 * 13 *
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index a3e65d1bc19b..d7897ae89f90 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3445,9 +3445,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3445 3445
3446 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); 3446 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);
3447 if (card == NULL) { 3447 if (card == NULL) {
3448 printk("PC300 found at RAM 0x%08lx, " 3448 printk("PC300 found at RAM 0x%016llx, "
3449 "but could not allocate card structure.\n", 3449 "but could not allocate card structure.\n",
3450 pci_resource_start(pdev, 3)); 3450 (unsigned long long)pci_resource_start(pdev, 3));
3451 err = -ENOMEM; 3451 err = -ENOMEM;
3452 goto err_disable_dev; 3452 goto err_disable_dev;
3453 } 3453 }
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index 670e8bd2245c..24c3c57c13c9 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -7,7 +7,7 @@
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation. 8 * as published by the Free Software Foundation.
9 * 9 *
10 * For information see http://hq.pm.waw.pl/hdlc/ 10 * For information see <http://www.kernel.org/pub/linux/utils/net/hdlc/>
11 * 11 *
12 * Sources of information: 12 * Sources of information:
13 * Hitachi HD64572 SCA-II User's Manual 13 * Hitachi HD64572 SCA-II User's Manual
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 081a8999666e..a8a8f975432f 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
1229 return error; 1229 return error;
1230} 1230}
1231 1231
1232static void ipw_free_error_log(struct ipw_fw_error *error)
1233{
1234 if (error)
1235 kfree(error);
1236}
1237
1238static ssize_t show_event_log(struct device *d, 1232static ssize_t show_event_log(struct device *d,
1239 struct device_attribute *attr, char *buf) 1233 struct device_attribute *attr, char *buf)
1240{ 1234{
@@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device *d,
1296 const char *buf, size_t count) 1290 const char *buf, size_t count)
1297{ 1291{
1298 struct ipw_priv *priv = dev_get_drvdata(d); 1292 struct ipw_priv *priv = dev_get_drvdata(d);
1299 if (priv->error) { 1293
1300 ipw_free_error_log(priv->error); 1294 kfree(priv->error);
1301 priv->error = NULL; 1295 priv->error = NULL;
1302 }
1303 return count; 1296 return count;
1304} 1297}
1305 1298
@@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
1970 struct ipw_fw_error *error = 1963 struct ipw_fw_error *error =
1971 ipw_alloc_error_log(priv); 1964 ipw_alloc_error_log(priv);
1972 ipw_dump_error_log(priv, error); 1965 ipw_dump_error_log(priv, error);
1973 if (error) 1966 kfree(error);
1974 ipw_free_error_log(error);
1975 } 1967 }
1976#endif 1968#endif
1977 } else { 1969 } else {
@@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_dev *pdev)
11693 } 11685 }
11694 } 11686 }
11695 11687
11696 if (priv->error) { 11688 kfree(priv->error);
11697 ipw_free_error_log(priv->error); 11689 priv->error = NULL;
11698 priv->error = NULL;
11699 }
11700 11690
11701#ifdef CONFIG_IPW2200_PROMISCUOUS 11691#ifdef CONFIG_IPW2200_PROMISCUOUS
11702 ipw_prom_free(priv); 11692 ipw_prom_free(priv);
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index ecec8e5db786..569305f57561 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -234,14 +234,6 @@ See Packet Engines confidential appendix (prototype chips only).
234 234
235 235
236 236
237enum pci_id_flags_bits {
238 /* Set PCI command register bits before calling probe1(). */
239 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
240 /* Read and map the single following PCI BAR. */
241 PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
242 PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
243 PCI_UNUSED_IRQ=0x800,
244};
245enum capability_flags { 237enum capability_flags {
246 HasMII=1, FullTxStatus=2, IsGigabit=4, HasMulticastBug=8, FullRxStatus=16, 238 HasMII=1, FullTxStatus=2, IsGigabit=4, HasMulticastBug=8, FullRxStatus=16,
247 HasMACAddrBug=32, /* Only on early revs. */ 239 HasMACAddrBug=32, /* Only on early revs. */
@@ -249,11 +241,6 @@ enum capability_flags {
249}; 241};
250/* The PCI I/O space extent. */ 242/* The PCI I/O space extent. */
251#define YELLOWFIN_SIZE 0x100 243#define YELLOWFIN_SIZE 0x100
252#ifdef USE_IO_OPS
253#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0)
254#else
255#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
256#endif
257 244
258struct pci_id_info { 245struct pci_id_info {
259 const char *name; 246 const char *name;
@@ -261,24 +248,23 @@ struct pci_id_info {
261 int pci, pci_mask, subsystem, subsystem_mask; 248 int pci, pci_mask, subsystem, subsystem_mask;
262 int revision, revision_mask; /* Only 8 bits. */ 249 int revision, revision_mask; /* Only 8 bits. */
263 } id; 250 } id;
264 enum pci_id_flags_bits pci_flags;
265 int io_size; /* Needed for I/O region check or ioremap(). */ 251 int io_size; /* Needed for I/O region check or ioremap(). */
266 int drv_flags; /* Driver use, intended as capability flags. */ 252 int drv_flags; /* Driver use, intended as capability flags. */
267}; 253};
268 254
269static const struct pci_id_info pci_id_tbl[] = { 255static const struct pci_id_info pci_id_tbl[] = {
270 {"Yellowfin G-NIC Gigabit Ethernet", { 0x07021000, 0xffffffff}, 256 {"Yellowfin G-NIC Gigabit Ethernet", { 0x07021000, 0xffffffff},
271 PCI_IOTYPE, YELLOWFIN_SIZE, 257 YELLOWFIN_SIZE,
272 FullTxStatus | IsGigabit | HasMulticastBug | HasMACAddrBug | DontUseEeprom}, 258 FullTxStatus | IsGigabit | HasMulticastBug | HasMACAddrBug | DontUseEeprom},
273 {"Symbios SYM83C885", { 0x07011000, 0xffffffff}, 259 {"Symbios SYM83C885", { 0x07011000, 0xffffffff},
274 PCI_IOTYPE, YELLOWFIN_SIZE, HasMII | DontUseEeprom }, 260 YELLOWFIN_SIZE, HasMII | DontUseEeprom },
275 {NULL,}, 261 { }
276}; 262};
277 263
278static struct pci_device_id yellowfin_pci_tbl[] = { 264static const struct pci_device_id yellowfin_pci_tbl[] = {
279 { 0x1000, 0x0702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 265 { 0x1000, 0x0702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
280 { 0x1000, 0x0701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 266 { 0x1000, 0x0701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
281 { 0, } 267 { }
282}; 268};
283MODULE_DEVICE_TABLE (pci, yellowfin_pci_tbl); 269MODULE_DEVICE_TABLE (pci, yellowfin_pci_tbl);
284 270
diff --git a/drivers/parisc/Kconfig b/drivers/parisc/Kconfig
index 3f5de867acd7..1d3b84b4af3f 100644
--- a/drivers/parisc/Kconfig
+++ b/drivers/parisc/Kconfig
@@ -140,18 +140,37 @@ config CHASSIS_LCD_LED
140 If unsure, say Y. 140 If unsure, say Y.
141 141
142config PDC_CHASSIS 142config PDC_CHASSIS
143 bool "PDC chassis State Panel support" 143 bool "PDC chassis state codes support"
144 default y 144 default y
145 help 145 help
146 Say Y here if you want to enable support for the LED State front 146 Say Y here if you want to enable support for Chassis codes.
147 panel as found on E class, and support for the GSP Virtual Front 147 That includes support for LED State front panel as found on E
148 Panel (LED State and message logging) as found on high end 148 class, and support for the GSP Virtual Front Panel (LED State and
149 servers such as A, L and N-class. 149 message logging) as found on high end servers such as A, L and
150 150 N-class.
151 This has nothing to do with Chassis LCD and LED support. 151 This driver will also display progress messages on LCD display,
152 such as "INI", "RUN" and "FLT", and might thus clobber messages
153 shown by the LED/LCD driver.
154 This driver updates the state panel (LED and/or LCD) upon system
155 state change (eg: boot, shutdown or panic).
152 156
153 If unsure, say Y. 157 If unsure, say Y.
154 158
159
160config PDC_CHASSIS_WARN
161 bool "PDC chassis warnings support"
162 depends on PROC_FS
163 default y
164 help
165 Say Y here if you want to enable support for Chassis warnings.
166 This will add a proc entry '/proc/chassis' giving some information
167 about the overall health state of the system.
168 This includes NVRAM battery level, overtemp or failures such as
169 fans or power units.
170
171 If unsure, say Y.
172
173
155config PDC_STABLE 174config PDC_STABLE
156 tristate "PDC Stable Storage support" 175 tristate "PDC Stable Storage support"
157 depends on SYSFS 176 depends on SYSFS
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 6e8ed0c81a6c..ce0a6ebcff15 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -299,7 +299,7 @@ struct pci_port_ops dino_port_ops = {
299 299
300static void dino_disable_irq(unsigned int irq) 300static void dino_disable_irq(unsigned int irq)
301{ 301{
302 struct dino_device *dino_dev = irq_desc[irq].handler_data; 302 struct dino_device *dino_dev = irq_desc[irq].chip_data;
303 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); 303 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS);
304 304
305 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq); 305 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq);
@@ -311,7 +311,7 @@ static void dino_disable_irq(unsigned int irq)
311 311
312static void dino_enable_irq(unsigned int irq) 312static void dino_enable_irq(unsigned int irq)
313{ 313{
314 struct dino_device *dino_dev = irq_desc[irq].handler_data; 314 struct dino_device *dino_dev = irq_desc[irq].chip_data;
315 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); 315 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS);
316 u32 tmp; 316 u32 tmp;
317 317
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index 9d3bd15bf53b..58f0ce8d78e0 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -350,7 +350,7 @@ static int __devinit eisa_probe(struct parisc_device *dev)
350 irq_desc[2].action = &irq2_action; 350 irq_desc[2].action = &irq2_action;
351 351
352 for (i = 0; i < 16; i++) { 352 for (i = 0; i < 16; i++) {
353 irq_desc[i].handler = &eisa_interrupt_type; 353 irq_desc[i].chip = &eisa_interrupt_type;
354 } 354 }
355 355
356 EISA_bus = 1; 356 EISA_bus = 1;
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index 16d40f95978d..5476ba7709b3 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -109,7 +109,7 @@ int gsc_find_local_irq(unsigned int irq, int *global_irqs, int limit)
109 109
110static void gsc_asic_disable_irq(unsigned int irq) 110static void gsc_asic_disable_irq(unsigned int irq)
111{ 111{
112 struct gsc_asic *irq_dev = irq_desc[irq].handler_data; 112 struct gsc_asic *irq_dev = irq_desc[irq].chip_data;
113 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); 113 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32);
114 u32 imr; 114 u32 imr;
115 115
@@ -124,7 +124,7 @@ static void gsc_asic_disable_irq(unsigned int irq)
124 124
125static void gsc_asic_enable_irq(unsigned int irq) 125static void gsc_asic_enable_irq(unsigned int irq)
126{ 126{
127 struct gsc_asic *irq_dev = irq_desc[irq].handler_data; 127 struct gsc_asic *irq_dev = irq_desc[irq].chip_data;
128 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); 128 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32);
129 u32 imr; 129 u32 imr;
130 130
@@ -164,8 +164,8 @@ int gsc_assign_irq(struct hw_interrupt_type *type, void *data)
164 if (irq > GSC_IRQ_MAX) 164 if (irq > GSC_IRQ_MAX)
165 return NO_IRQ; 165 return NO_IRQ;
166 166
167 irq_desc[irq].handler = type; 167 irq_desc[irq].chip = type;
168 irq_desc[irq].handler_data = data; 168 irq_desc[irq].chip_data = data;
169 return irq++; 169 return irq++;
170} 170}
171 171
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 7a458d5bc751..1fbda77cefc2 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -619,7 +619,7 @@ iosapic_set_irt_data( struct vector_info *vi, u32 *dp0, u32 *dp1)
619 619
620static struct vector_info *iosapic_get_vector(unsigned int irq) 620static struct vector_info *iosapic_get_vector(unsigned int irq)
621{ 621{
622 return irq_desc[irq].handler_data; 622 return irq_desc[irq].chip_data;
623} 623}
624 624
625static void iosapic_disable_irq(unsigned int irq) 625static void iosapic_disable_irq(unsigned int irq)
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index bbeabe3fc4c6..ea1b7a63598e 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -28,8 +28,15 @@
28 * following code can deal with just 96 bytes of Stable Storage, and all 28 * following code can deal with just 96 bytes of Stable Storage, and all
29 * sizes between 96 and 192 bytes (provided they are multiple of struct 29 * sizes between 96 and 192 bytes (provided they are multiple of struct
30 * device_path size, eg: 128, 160 and 192) to provide full information. 30 * device_path size, eg: 128, 160 and 192) to provide full information.
31 * The code makes no use of data above 192 bytes. One last word: there's one 31 * One last word: there's one path we can always count on: the primary path.
32 * path we can always count on: the primary path. 32 * Anything above 224 bytes is used for 'osdep2' OS-dependent storage area.
33 *
34 * The first OS-dependent area should always be available. Obviously, this is
35 * not true for the other one. Also bear in mind that reading/writing from/to
36 * osdep2 is much more expensive than from/to osdep1.
37 * NOTE: We do not handle the 2 bytes OS-dep area at 0x5D, nor the first
38 * 2 bytes of storage available right after OSID. That's a total of 4 bytes
39 * sacrificed: -ETOOLAZY :P
33 * 40 *
34 * The current policy wrt file permissions is: 41 * The current policy wrt file permissions is:
35 * - write: root only 42 * - write: root only
@@ -64,15 +71,18 @@
64#include <asm/uaccess.h> 71#include <asm/uaccess.h>
65#include <asm/hardware.h> 72#include <asm/hardware.h>
66 73
67#define PDCS_VERSION "0.22" 74#define PDCS_VERSION "0.30"
68#define PDCS_PREFIX "PDC Stable Storage" 75#define PDCS_PREFIX "PDC Stable Storage"
69 76
70#define PDCS_ADDR_PPRI 0x00 77#define PDCS_ADDR_PPRI 0x00
71#define PDCS_ADDR_OSID 0x40 78#define PDCS_ADDR_OSID 0x40
79#define PDCS_ADDR_OSD1 0x48
80#define PDCS_ADDR_DIAG 0x58
72#define PDCS_ADDR_FSIZ 0x5C 81#define PDCS_ADDR_FSIZ 0x5C
73#define PDCS_ADDR_PCON 0x60 82#define PDCS_ADDR_PCON 0x60
74#define PDCS_ADDR_PALT 0x80 83#define PDCS_ADDR_PALT 0x80
75#define PDCS_ADDR_PKBD 0xA0 84#define PDCS_ADDR_PKBD 0xA0
85#define PDCS_ADDR_OSD2 0xE0
76 86
77MODULE_AUTHOR("Thibaut VARENE <varenet@parisc-linux.org>"); 87MODULE_AUTHOR("Thibaut VARENE <varenet@parisc-linux.org>");
78MODULE_DESCRIPTION("sysfs interface to HP PDC Stable Storage data"); 88MODULE_DESCRIPTION("sysfs interface to HP PDC Stable Storage data");
@@ -82,6 +92,9 @@ MODULE_VERSION(PDCS_VERSION);
82/* holds Stable Storage size. Initialized once and for all, no lock needed */ 92/* holds Stable Storage size. Initialized once and for all, no lock needed */
83static unsigned long pdcs_size __read_mostly; 93static unsigned long pdcs_size __read_mostly;
84 94
95/* holds OS ID. Initialized once and for all, hopefully to 0x0006 */
96static u16 pdcs_osid __read_mostly;
97
85/* This struct defines what we need to deal with a parisc pdc path entry */ 98/* This struct defines what we need to deal with a parisc pdc path entry */
86struct pdcspath_entry { 99struct pdcspath_entry {
87 rwlock_t rw_lock; /* to protect path entry access */ 100 rwlock_t rw_lock; /* to protect path entry access */
@@ -609,27 +622,64 @@ static ssize_t
609pdcs_osid_read(struct subsystem *entry, char *buf) 622pdcs_osid_read(struct subsystem *entry, char *buf)
610{ 623{
611 char *out = buf; 624 char *out = buf;
612 __u32 result;
613 char *tmpstr = NULL;
614 625
615 if (!entry || !buf) 626 if (!entry || !buf)
616 return -EINVAL; 627 return -EINVAL;
617 628
618 /* get OSID */ 629 out += sprintf(out, "%s dependent data (0x%.4x)\n",
619 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK) 630 os_id_to_string(pdcs_osid), pdcs_osid);
631
632 return out - buf;
633}
634
635/**
636 * pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output.
637 * @entry: An allocated and populated subsytem struct. We don't use it tho.
638 * @buf: The output buffer to write to.
639 *
640 * This can hold 16 bytes of OS-Dependent data.
641 */
642static ssize_t
643pdcs_osdep1_read(struct subsystem *entry, char *buf)
644{
645 char *out = buf;
646 u32 result[4];
647
648 if (!entry || !buf)
649 return -EINVAL;
650
651 if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK)
620 return -EIO; 652 return -EIO;
621 653
622 /* the actual result is 16 bits away */ 654 out += sprintf(out, "0x%.8x\n", result[0]);
623 switch (result >> 16) { 655 out += sprintf(out, "0x%.8x\n", result[1]);
624 case 0x0000: tmpstr = "No OS-dependent data"; break; 656 out += sprintf(out, "0x%.8x\n", result[2]);
625 case 0x0001: tmpstr = "HP-UX dependent data"; break; 657 out += sprintf(out, "0x%.8x\n", result[3]);
626 case 0x0002: tmpstr = "MPE-iX dependent data"; break; 658
627 case 0x0003: tmpstr = "OSF dependent data"; break; 659 return out - buf;
628 case 0x0004: tmpstr = "HP-RT dependent data"; break; 660}
629 case 0x0005: tmpstr = "Novell Netware dependent data"; break; 661
630 default: tmpstr = "Unknown"; break; 662/**
631 } 663 * pdcs_diagnostic_read - Stable Storage Diagnostic register output.
632 out += sprintf(out, "%s (0x%.4x)\n", tmpstr, (result >> 16)); 664 * @entry: An allocated and populated subsytem struct. We don't use it tho.
665 * @buf: The output buffer to write to.
666 *
667 * I have NFC how to interpret the content of that register ;-).
668 */
669static ssize_t
670pdcs_diagnostic_read(struct subsystem *entry, char *buf)
671{
672 char *out = buf;
673 u32 result;
674
675 if (!entry || !buf)
676 return -EINVAL;
677
678 /* get diagnostic */
679 if (pdc_stable_read(PDCS_ADDR_DIAG, &result, sizeof(result)) != PDC_OK)
680 return -EIO;
681
682 out += sprintf(out, "0x%.4x\n", (result >> 16));
633 683
634 return out - buf; 684 return out - buf;
635} 685}
@@ -645,7 +695,7 @@ static ssize_t
645pdcs_fastsize_read(struct subsystem *entry, char *buf) 695pdcs_fastsize_read(struct subsystem *entry, char *buf)
646{ 696{
647 char *out = buf; 697 char *out = buf;
648 __u32 result; 698 u32 result;
649 699
650 if (!entry || !buf) 700 if (!entry || !buf)
651 return -EINVAL; 701 return -EINVAL;
@@ -664,6 +714,39 @@ pdcs_fastsize_read(struct subsystem *entry, char *buf)
664} 714}
665 715
666/** 716/**
717 * pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output.
718 * @entry: An allocated and populated subsytem struct. We don't use it tho.
719 * @buf: The output buffer to write to.
720 *
721 * This can hold pdcs_size - 224 bytes of OS-Dependent data, when available.
722 */
723static ssize_t
724pdcs_osdep2_read(struct subsystem *entry, char *buf)
725{
726 char *out = buf;
727 unsigned long size;
728 unsigned short i;
729 u32 result;
730
731 if (unlikely(pdcs_size <= 224))
732 return -ENODATA;
733
734 size = pdcs_size - 224;
735
736 if (!entry || !buf)
737 return -EINVAL;
738
739 for (i=0; i<size; i+=4) {
740 if (unlikely(pdc_stable_read(PDCS_ADDR_OSD2 + i, &result,
741 sizeof(result)) != PDC_OK))
742 return -EIO;
743 out += sprintf(out, "0x%.8x\n", result);
744 }
745
746 return out - buf;
747}
748
749/**
667 * pdcs_auto_write - This function handles autoboot/search flag modifying. 750 * pdcs_auto_write - This function handles autoboot/search flag modifying.
668 * @entry: An allocated and populated subsytem struct. We don't use it tho. 751 * @entry: An allocated and populated subsytem struct. We don't use it tho.
669 * @buf: The input buffer to read from. 752 * @buf: The input buffer to read from.
@@ -770,13 +853,100 @@ pdcs_autosearch_write(struct subsystem *entry, const char *buf, size_t count)
770 return pdcs_auto_write(entry, buf, count, PF_AUTOSEARCH); 853 return pdcs_auto_write(entry, buf, count, PF_AUTOSEARCH);
771} 854}
772 855
856/**
857 * pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input.
858 * @entry: An allocated and populated subsytem struct. We don't use it tho.
859 * @buf: The input buffer to read from.
860 * @count: The number of bytes to be read.
861 *
862 * This can store 16 bytes of OS-Dependent data. We use a byte-by-byte
863 * write approach. It's up to userspace to deal with it when constructing
864 * its input buffer.
865 */
866static ssize_t
867pdcs_osdep1_write(struct subsystem *entry, const char *buf, size_t count)
868{
869 u8 in[16];
870
871 if (!capable(CAP_SYS_ADMIN))
872 return -EACCES;
873
874 if (!entry || !buf || !count)
875 return -EINVAL;
876
877 if (unlikely(pdcs_osid != OS_ID_LINUX))
878 return -EPERM;
879
880 if (count > 16)
881 return -EMSGSIZE;
882
883 /* We'll use a local copy of buf */
884 memset(in, 0, 16);
885 memcpy(in, buf, count);
886
887 if (pdc_stable_write(PDCS_ADDR_OSD1, &in, sizeof(in)) != PDC_OK)
888 return -EIO;
889
890 return count;
891}
892
893/**
894 * pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input.
895 * @entry: An allocated and populated subsytem struct. We don't use it tho.
896 * @buf: The input buffer to read from.
897 * @count: The number of bytes to be read.
898 *
899 * This can store pdcs_size - 224 bytes of OS-Dependent data. We use a
900 * byte-by-byte write approach. It's up to userspace to deal with it when
901 * constructing its input buffer.
902 */
903static ssize_t
904pdcs_osdep2_write(struct subsystem *entry, const char *buf, size_t count)
905{
906 unsigned long size;
907 unsigned short i;
908 u8 in[4];
909
910 if (!capable(CAP_SYS_ADMIN))
911 return -EACCES;
912
913 if (!entry || !buf || !count)
914 return -EINVAL;
915
916 if (unlikely(pdcs_size <= 224))
917 return -ENOSYS;
918
919 if (unlikely(pdcs_osid != OS_ID_LINUX))
920 return -EPERM;
921
922 size = pdcs_size - 224;
923
924 if (count > size)
925 return -EMSGSIZE;
926
927 /* We'll use a local copy of buf */
928
929 for (i=0; i<count; i+=4) {
930 memset(in, 0, 4);
931 memcpy(in, buf+i, (count-i < 4) ? count-i : 4);
932 if (unlikely(pdc_stable_write(PDCS_ADDR_OSD2 + i, &in,
933 sizeof(in)) != PDC_OK))
934 return -EIO;
935 }
936
937 return count;
938}
939
773/* The remaining attributes. */ 940/* The remaining attributes. */
774static PDCS_ATTR(size, 0444, pdcs_size_read, NULL); 941static PDCS_ATTR(size, 0444, pdcs_size_read, NULL);
775static PDCS_ATTR(autoboot, 0644, pdcs_autoboot_read, pdcs_autoboot_write); 942static PDCS_ATTR(autoboot, 0644, pdcs_autoboot_read, pdcs_autoboot_write);
776static PDCS_ATTR(autosearch, 0644, pdcs_autosearch_read, pdcs_autosearch_write); 943static PDCS_ATTR(autosearch, 0644, pdcs_autosearch_read, pdcs_autosearch_write);
777static PDCS_ATTR(timer, 0444, pdcs_timer_read, NULL); 944static PDCS_ATTR(timer, 0444, pdcs_timer_read, NULL);
778static PDCS_ATTR(osid, 0400, pdcs_osid_read, NULL); 945static PDCS_ATTR(osid, 0444, pdcs_osid_read, NULL);
946static PDCS_ATTR(osdep1, 0600, pdcs_osdep1_read, pdcs_osdep1_write);
947static PDCS_ATTR(diagnostic, 0400, pdcs_diagnostic_read, NULL);
779static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL); 948static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL);
949static PDCS_ATTR(osdep2, 0600, pdcs_osdep2_read, pdcs_osdep2_write);
780 950
781static struct subsys_attribute *pdcs_subsys_attrs[] = { 951static struct subsys_attribute *pdcs_subsys_attrs[] = {
782 &pdcs_attr_size, 952 &pdcs_attr_size,
@@ -784,7 +954,10 @@ static struct subsys_attribute *pdcs_subsys_attrs[] = {
784 &pdcs_attr_autosearch, 954 &pdcs_attr_autosearch,
785 &pdcs_attr_timer, 955 &pdcs_attr_timer,
786 &pdcs_attr_osid, 956 &pdcs_attr_osid,
957 &pdcs_attr_osdep1,
958 &pdcs_attr_diagnostic,
787 &pdcs_attr_fastsize, 959 &pdcs_attr_fastsize,
960 &pdcs_attr_osdep2,
788 NULL, 961 NULL,
789}; 962};
790 963
@@ -865,6 +1038,7 @@ pdc_stable_init(void)
865{ 1038{
866 struct subsys_attribute *attr; 1039 struct subsys_attribute *attr;
867 int i, rc = 0, error = 0; 1040 int i, rc = 0, error = 0;
1041 u32 result;
868 1042
869 /* find the size of the stable storage */ 1043 /* find the size of the stable storage */
870 if (pdc_stable_get_size(&pdcs_size) != PDC_OK) 1044 if (pdc_stable_get_size(&pdcs_size) != PDC_OK)
@@ -876,6 +1050,13 @@ pdc_stable_init(void)
876 1050
877 printk(KERN_INFO PDCS_PREFIX " facility v%s\n", PDCS_VERSION); 1051 printk(KERN_INFO PDCS_PREFIX " facility v%s\n", PDCS_VERSION);
878 1052
1053 /* get OSID */
1054 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK)
1055 return -EIO;
1056
1057 /* the actual result is 16 bits away */
1058 pdcs_osid = (u16)(result >> 16);
1059
879 /* For now we'll register the stable subsys within this driver */ 1060 /* For now we'll register the stable subsys within this driver */
880 if ((rc = firmware_register(&stable_subsys))) 1061 if ((rc = firmware_register(&stable_subsys)))
881 goto fail_firmreg; 1062 goto fail_firmreg;
@@ -887,7 +1068,7 @@ pdc_stable_init(void)
887 1068
888 /* register the paths subsys as a subsystem of stable subsys */ 1069 /* register the paths subsys as a subsystem of stable subsys */
889 kset_set_kset_s(&paths_subsys, stable_subsys); 1070 kset_set_kset_s(&paths_subsys, stable_subsys);
890 if ((rc= subsystem_register(&paths_subsys))) 1071 if ((rc = subsystem_register(&paths_subsys)))
891 goto fail_subsysreg; 1072 goto fail_subsysreg;
892 1073
893 /* now we create all "files" for the paths subsys */ 1074 /* now we create all "files" for the paths subsys */
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 278f325021ee..d09e39e39c60 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -316,10 +316,10 @@ static int reserve_sba_gart = 1;
316** 316**
317** Superdome (in particular, REO) allows only 64-bit CSR accesses. 317** Superdome (in particular, REO) allows only 64-bit CSR accesses.
318*/ 318*/
319#define READ_REG32(addr) le32_to_cpu(__raw_readl(addr)) 319#define READ_REG32(addr) readl(addr)
320#define READ_REG64(addr) le64_to_cpu(__raw_readq(addr)) 320#define READ_REG64(addr) readq(addr)
321#define WRITE_REG32(val, addr) __raw_writel(cpu_to_le32(val), addr) 321#define WRITE_REG32(val, addr) writel((val), (addr))
322#define WRITE_REG64(val, addr) __raw_writeq(cpu_to_le64(val), addr) 322#define WRITE_REG64(val, addr) writeq((val), (addr))
323 323
324#ifdef CONFIG_64BIT 324#ifdef CONFIG_64BIT
325#define READ_REG(addr) READ_REG64(addr) 325#define READ_REG(addr) READ_REG64(addr)
@@ -1427,7 +1427,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1427 iov_order = get_order(iova_space_size >> (IOVP_SHIFT - PAGE_SHIFT)); 1427 iov_order = get_order(iova_space_size >> (IOVP_SHIFT - PAGE_SHIFT));
1428 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); 1428 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64);
1429 1429
1430 DBG_INIT("%s() hpa 0x%lx IOV %dMB (%d bits)\n", 1430 DBG_INIT("%s() hpa 0x%p IOV %dMB (%d bits)\n",
1431 __FUNCTION__, ioc->ioc_hpa, iova_space_size >> 20, 1431 __FUNCTION__, ioc->ioc_hpa, iova_space_size >> 20,
1432 iov_order + PAGE_SHIFT); 1432 iov_order + PAGE_SHIFT);
1433 1433
@@ -1764,7 +1764,7 @@ printk("sba_hw_init(): mem_boot 0x%x 0x%x 0x%x 0x%x\n", PAGE0->mem_boot.hpa,
1764 1764
1765 sba_dev->num_ioc = num_ioc; 1765 sba_dev->num_ioc = num_ioc;
1766 for (i = 0; i < num_ioc; i++) { 1766 for (i = 0; i < num_ioc; i++) {
1767 unsigned long ioc_hpa = sba_dev->ioc[i].ioc_hpa; 1767 void __iomem *ioc_hpa = sba_dev->ioc[i].ioc_hpa;
1768 unsigned int j; 1768 unsigned int j;
1769 1769
1770 for (j=0; j < sizeof(u64) * ROPES_PER_IOC; j+=sizeof(u64)) { 1770 for (j=0; j < sizeof(u64) * ROPES_PER_IOC; j+=sizeof(u64)) {
@@ -1776,7 +1776,8 @@ printk("sba_hw_init(): mem_boot 0x%x 0x%x 0x%x 0x%x\n", PAGE0->mem_boot.hpa,
1776 * Improves netperf UDP_STREAM by ~10% for bcm5701. 1776 * Improves netperf UDP_STREAM by ~10% for bcm5701.
1777 */ 1777 */
1778 if (IS_PLUTO(sba_dev->iodc)) { 1778 if (IS_PLUTO(sba_dev->iodc)) {
1779 unsigned long rope_cfg, cfg_val; 1779 void __iomem *rope_cfg;
1780 unsigned long cfg_val;
1780 1781
1781 rope_cfg = ioc_hpa + IOC_ROPE0_CFG + j; 1782 rope_cfg = ioc_hpa + IOC_ROPE0_CFG + j;
1782 cfg_val = READ_REG(rope_cfg); 1783 cfg_val = READ_REG(rope_cfg);
@@ -1902,7 +1903,7 @@ sba_common_init(struct sba_device *sba_dev)
1902 * (bit #61, big endian), we have to flush and sync every time 1903 * (bit #61, big endian), we have to flush and sync every time
1903 * IO-PDIR is changed in Ike/Astro. 1904 * IO-PDIR is changed in Ike/Astro.
1904 */ 1905 */
1905 if (boot_cpu_data.pdc.capabilities & PDC_MODEL_IOPDIR_FDC) { 1906 if (ioc_needs_fdc) {
1906 printk(KERN_INFO MODULE_NAME " FDC/SYNC required.\n"); 1907 printk(KERN_INFO MODULE_NAME " FDC/SYNC required.\n");
1907 } else { 1908 } else {
1908 printk(KERN_INFO MODULE_NAME " IOC has cache coherent PDIR.\n"); 1909 printk(KERN_INFO MODULE_NAME " IOC has cache coherent PDIR.\n");
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 828eb45062de..a988dc7a9abd 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -360,7 +360,7 @@ int superio_fixup_irq(struct pci_dev *pcidev)
360#endif 360#endif
361 361
362 for (i = 0; i < 16; i++) { 362 for (i = 0; i < 16; i++) {
363 irq_desc[i].handler = &superio_interrupt_type; 363 irq_desc[i].chip = &superio_interrupt_type;
364 } 364 }
365 365
366 /* 366 /*
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 723092682023..5f7db9d2436e 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -34,11 +34,11 @@
34 */ 34 */
35int 35int
36pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, 36pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
37 unsigned long size, unsigned long align, unsigned long min, 37 resource_size_t size, resource_size_t align,
38 unsigned int type_mask, 38 resource_size_t min, unsigned int type_mask,
39 void (*alignf)(void *, struct resource *, 39 void (*alignf)(void *, struct resource *, resource_size_t,
40 unsigned long, unsigned long), 40 resource_size_t),
41 void *alignf_data) 41 void *alignf_data)
42{ 42{
43 int i, ret = -ENOMEM; 43 int i, ret = -ENOMEM;
44 44
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index f7cb00da38df..1ec165df8522 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -95,8 +95,8 @@ static int zt5550_hc_config(struct pci_dev *pdev)
95 95
96 hc_dev = pdev; 96 hc_dev = pdev;
97 dbg("hc_dev = %p", hc_dev); 97 dbg("hc_dev = %p", hc_dev);
98 dbg("pci resource start %lx", pci_resource_start(hc_dev, 1)); 98 dbg("pci resource start %llx", (unsigned long long)pci_resource_start(hc_dev, 1));
99 dbg("pci resource len %lx", pci_resource_len(hc_dev, 1)); 99 dbg("pci resource len %llx", (unsigned long long)pci_resource_len(hc_dev, 1));
100 100
101 if(!request_mem_region(pci_resource_start(hc_dev, 1), 101 if(!request_mem_region(pci_resource_start(hc_dev, 1),
102 pci_resource_len(hc_dev, 1), MY_NAME)) { 102 pci_resource_len(hc_dev, 1), MY_NAME)) {
@@ -108,8 +108,9 @@ static int zt5550_hc_config(struct pci_dev *pdev)
108 hc_registers = 108 hc_registers =
109 ioremap(pci_resource_start(hc_dev, 1), pci_resource_len(hc_dev, 1)); 109 ioremap(pci_resource_start(hc_dev, 1), pci_resource_len(hc_dev, 1));
110 if(!hc_registers) { 110 if(!hc_registers) {
111 err("cannot remap MMIO region %lx @ %lx", 111 err("cannot remap MMIO region %llx @ %llx",
112 pci_resource_len(hc_dev, 1), pci_resource_start(hc_dev, 1)); 112 (unsigned long long)pci_resource_len(hc_dev, 1),
113 (unsigned long long)pci_resource_start(hc_dev, 1));
113 ret = -ENODEV; 114 ret = -ENODEV;
114 goto exit_release_region; 115 goto exit_release_region;
115 } 116 }
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 9bc1deb8df52..f8658d63f077 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1089,8 +1089,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1089 } 1089 }
1090 1090
1091 dbg("pdev = %p\n", pdev); 1091 dbg("pdev = %p\n", pdev);
1092 dbg("pci resource start %lx\n", pci_resource_start(pdev, 0)); 1092 dbg("pci resource start %llx\n", (unsigned long long)pci_resource_start(pdev, 0));
1093 dbg("pci resource len %lx\n", pci_resource_len(pdev, 0)); 1093 dbg("pci resource len %llx\n", (unsigned long long)pci_resource_len(pdev, 0));
1094 1094
1095 if (!request_mem_region(pci_resource_start(pdev, 0), 1095 if (!request_mem_region(pci_resource_start(pdev, 0),
1096 pci_resource_len(pdev, 0), MY_NAME)) { 1096 pci_resource_len(pdev, 0), MY_NAME)) {
@@ -1102,9 +1102,9 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1102 ctrl->hpc_reg = ioremap(pci_resource_start(pdev, 0), 1102 ctrl->hpc_reg = ioremap(pci_resource_start(pdev, 0),
1103 pci_resource_len(pdev, 0)); 1103 pci_resource_len(pdev, 0));
1104 if (!ctrl->hpc_reg) { 1104 if (!ctrl->hpc_reg) {
1105 err("cannot remap MMIO region %lx @ %lx\n", 1105 err("cannot remap MMIO region %llx @ %llx\n",
1106 pci_resource_len(pdev, 0), 1106 (unsigned long long)pci_resource_len(pdev, 0),
1107 pci_resource_start(pdev, 0)); 1107 (unsigned long long)pci_resource_start(pdev, 0));
1108 rc = -ENODEV; 1108 rc = -ENODEV;
1109 goto err_free_mem_region; 1109 goto err_free_mem_region;
1110 } 1110 }
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index d77138ecb098..11f7858f0064 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1398,8 +1398,9 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1398 1398
1399 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++) 1399 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++)
1400 if (pci_resource_len(pdev, rc) > 0) 1400 if (pci_resource_len(pdev, rc) > 0)
1401 dbg("pci resource[%d] start=0x%lx(len=0x%lx)\n", rc, 1401 dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc,
1402 pci_resource_start(pdev, rc), pci_resource_len(pdev, rc)); 1402 (unsigned long long)pci_resource_start(pdev, rc),
1403 (unsigned long long)pci_resource_len(pdev, rc));
1403 1404
1404 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, 1405 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device,
1405 pdev->subsystem_vendor, pdev->subsystem_device); 1406 pdev->subsystem_vendor, pdev->subsystem_device);
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index f5cfbf2c047c..620e1139e607 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -51,8 +51,10 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
51 res = bus->resource[index]; 51 res = bus->resource[index];
52 if (res && (res->flags & IORESOURCE_MEM) && 52 if (res && (res->flags & IORESOURCE_MEM) &&
53 !(res->flags & IORESOURCE_PREFETCH)) { 53 !(res->flags & IORESOURCE_PREFETCH)) {
54 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n", 54 out += sprintf(out, "start = %8.8llx, "
55 res->start, (res->end - res->start)); 55 "length = %8.8llx\n",
56 (unsigned long long)res->start,
57 (unsigned long long)(res->end - res->start));
56 } 58 }
57 } 59 }
58 out += sprintf(out, "Free resources: prefetchable memory\n"); 60 out += sprintf(out, "Free resources: prefetchable memory\n");
@@ -60,16 +62,20 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
60 res = bus->resource[index]; 62 res = bus->resource[index];
61 if (res && (res->flags & IORESOURCE_MEM) && 63 if (res && (res->flags & IORESOURCE_MEM) &&
62 (res->flags & IORESOURCE_PREFETCH)) { 64 (res->flags & IORESOURCE_PREFETCH)) {
63 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n", 65 out += sprintf(out, "start = %8.8llx, "
64 res->start, (res->end - res->start)); 66 "length = %8.8llx\n",
67 (unsigned long long)res->start,
68 (unsigned long long)(res->end - res->start));
65 } 69 }
66 } 70 }
67 out += sprintf(out, "Free resources: IO\n"); 71 out += sprintf(out, "Free resources: IO\n");
68 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { 72 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
69 res = bus->resource[index]; 73 res = bus->resource[index];
70 if (res && (res->flags & IORESOURCE_IO)) { 74 if (res && (res->flags & IORESOURCE_IO)) {
71 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n", 75 out += sprintf(out, "start = %8.8llx, "
72 res->start, (res->end - res->start)); 76 "length = %8.8llx\n",
77 (unsigned long long)res->start,
78 (unsigned long long)(res->end - res->start));
73 } 79 }
74 } 80 }
75 out += sprintf(out, "Free resources: bus numbers\n"); 81 out += sprintf(out, "Free resources: bus numbers\n");
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 7f8429284fab..76d023d8a33b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -429,12 +429,12 @@ static void irq_handler_init(int cap_id, int pos, int mask)
429 429
430 spin_lock_irqsave(&irq_desc[pos].lock, flags); 430 spin_lock_irqsave(&irq_desc[pos].lock, flags);
431 if (cap_id == PCI_CAP_ID_MSIX) 431 if (cap_id == PCI_CAP_ID_MSIX)
432 irq_desc[pos].handler = &msix_irq_type; 432 irq_desc[pos].chip = &msix_irq_type;
433 else { 433 else {
434 if (!mask) 434 if (!mask)
435 irq_desc[pos].handler = &msi_irq_wo_maskbit_type; 435 irq_desc[pos].chip = &msi_irq_wo_maskbit_type;
436 else 436 else
437 irq_desc[pos].handler = &msi_irq_w_maskbit_type; 437 irq_desc[pos].chip = &msi_irq_w_maskbit_type;
438 } 438 }
439 spin_unlock_irqrestore(&irq_desc[pos].lock, flags); 439 spin_unlock_irqrestore(&irq_desc[pos].lock, flags);
440} 440}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index bc405c035ce3..606f9b6f70eb 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -87,7 +87,7 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
87 char * str = buf; 87 char * str = buf;
88 int i; 88 int i;
89 int max = 7; 89 int max = 7;
90 u64 start, end; 90 resource_size_t start, end;
91 91
92 if (pci_dev->subordinate) 92 if (pci_dev->subordinate)
93 max = DEVICE_COUNT_RESOURCE; 93 max = DEVICE_COUNT_RESOURCE;
@@ -365,7 +365,7 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
365 struct device, kobj)); 365 struct device, kobj));
366 struct resource *res = (struct resource *)attr->private; 366 struct resource *res = (struct resource *)attr->private;
367 enum pci_mmap_state mmap_type; 367 enum pci_mmap_state mmap_type;
368 u64 start, end; 368 resource_size_t start, end;
369 int i; 369 int i;
370 370
371 for (i = 0; i < PCI_ROM_RESOURCE; i++) 371 for (i = 0; i < PCI_ROM_RESOURCE; i++)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 23d3b17c8cad..cf57d7de3765 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -691,10 +691,12 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
691 return 0; 691 return 0;
692 692
693err_out: 693err_out:
694 printk (KERN_WARNING "PCI: Unable to reserve %s region #%d:%lx@%lx for device %s\n", 694 printk (KERN_WARNING "PCI: Unable to reserve %s region #%d:%llx@%llx "
695 "for device %s\n",
695 pci_resource_flags(pdev, bar) & IORESOURCE_IO ? "I/O" : "mem", 696 pci_resource_flags(pdev, bar) & IORESOURCE_IO ? "I/O" : "mem",
696 bar + 1, /* PCI BAR # */ 697 bar + 1, /* PCI BAR # */
697 pci_resource_len(pdev, bar), pci_resource_start(pdev, bar), 698 (unsigned long long)pci_resource_len(pdev, bar),
699 (unsigned long long)pci_resource_start(pdev, bar),
698 pci_name(pdev)); 700 pci_name(pdev));
699 return -EBUSY; 701 return -EBUSY;
700} 702}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 29bdeca031a8..9cc842b666eb 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -6,10 +6,10 @@ extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
7extern void pci_cleanup_rom(struct pci_dev *dev); 7extern void pci_cleanup_rom(struct pci_dev *dev);
8extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, 8extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
9 unsigned long size, unsigned long align, 9 resource_size_t size, resource_size_t align,
10 unsigned long min, unsigned int type_mask, 10 resource_size_t min, unsigned int type_mask,
11 void (*alignf)(void *, struct resource *, 11 void (*alignf)(void *, struct resource *,
12 unsigned long, unsigned long), 12 resource_size_t, resource_size_t),
13 void *alignf_data); 13 void *alignf_data);
14/* Firmware callbacks */ 14/* Firmware callbacks */
15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 54b2ebc9c91a..99cf33379769 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -302,12 +302,6 @@ static struct file_operations proc_bus_pci_operations = {
302#endif /* HAVE_PCI_MMAP */ 302#endif /* HAVE_PCI_MMAP */
303}; 303};
304 304
305#if BITS_PER_LONG == 32
306#define LONG_FORMAT "\t%08lx"
307#else
308#define LONG_FORMAT "\t%16lx"
309#endif
310
311/* iterator */ 305/* iterator */
312static void *pci_seq_start(struct seq_file *m, loff_t *pos) 306static void *pci_seq_start(struct seq_file *m, loff_t *pos)
313{ 307{
@@ -356,18 +350,18 @@ static int show_device(struct seq_file *m, void *v)
356 dev->irq); 350 dev->irq);
357 /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ 351 /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */
358 for (i=0; i<7; i++) { 352 for (i=0; i<7; i++) {
359 u64 start, end; 353 resource_size_t start, end;
360 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); 354 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
361 seq_printf(m, LONG_FORMAT, 355 seq_printf(m, "\t%16llx",
362 ((unsigned long)start) | 356 (unsigned long long)(start |
363 (dev->resource[i].flags & PCI_REGION_FLAG_MASK)); 357 (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
364 } 358 }
365 for (i=0; i<7; i++) { 359 for (i=0; i<7; i++) {
366 u64 start, end; 360 resource_size_t start, end;
367 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); 361 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
368 seq_printf(m, LONG_FORMAT, 362 seq_printf(m, "\t%16llx",
369 dev->resource[i].start < dev->resource[i].end ? 363 dev->resource[i].start < dev->resource[i].end ?
370 (unsigned long)(end - start) + 1 : 0); 364 (unsigned long long)(end - start) + 1 : 0);
371 } 365 }
372 seq_putc(m, '\t'); 366 seq_putc(m, '\t');
373 if (drv) 367 if (drv)
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 598a115cd00e..cbb69cf41311 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -80,8 +80,8 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
80 } else { 80 } else {
81 if (res->flags & IORESOURCE_ROM_COPY) { 81 if (res->flags & IORESOURCE_ROM_COPY) {
82 *size = pci_resource_len(pdev, PCI_ROM_RESOURCE); 82 *size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
83 return (void __iomem *)pci_resource_start(pdev, 83 return (void __iomem *)(unsigned long)
84 PCI_ROM_RESOURCE); 84 pci_resource_start(pdev, PCI_ROM_RESOURCE);
85 } else { 85 } else {
86 /* assign the ROM an address if it doesn't have one */ 86 /* assign the ROM an address if it doesn't have one */
87 if (res->parent == NULL && 87 if (res->parent == NULL &&
@@ -170,11 +170,11 @@ void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
170 return rom; 170 return rom;
171 171
172 res->end = res->start + *size; 172 res->end = res->start + *size;
173 memcpy_fromio((void*)res->start, rom, *size); 173 memcpy_fromio((void*)(unsigned long)res->start, rom, *size);
174 pci_unmap_rom(pdev, rom); 174 pci_unmap_rom(pdev, rom);
175 res->flags |= IORESOURCE_ROM_COPY; 175 res->flags |= IORESOURCE_ROM_COPY;
176 176
177 return (void __iomem *)res->start; 177 return (void __iomem *)(unsigned long)res->start;
178} 178}
179 179
180/** 180/**
@@ -227,7 +227,7 @@ void pci_cleanup_rom(struct pci_dev *pdev)
227{ 227{
228 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; 228 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
229 if (res->flags & IORESOURCE_ROM_COPY) { 229 if (res->flags & IORESOURCE_ROM_COPY) {
230 kfree((void*)res->start); 230 kfree((void*)(unsigned long)res->start);
231 res->flags &= ~IORESOURCE_ROM_COPY; 231 res->flags &= ~IORESOURCE_ROM_COPY;
232 res->start = 0; 232 res->start = 0;
233 res->end = 0; 233 res->end = 0;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 35086e80faa9..47c1071ad84e 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -357,8 +357,10 @@ pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type)
357 order = __ffs(align) - 20; 357 order = __ffs(align) - 20;
358 if (order > 11) { 358 if (order > 11) {
359 printk(KERN_WARNING "PCI: region %s/%d " 359 printk(KERN_WARNING "PCI: region %s/%d "
360 "too large: %lx-%lx\n", 360 "too large: %llx-%llx\n",
361 pci_name(dev), i, r->start, r->end); 361 pci_name(dev), i,
362 (unsigned long long)r->start,
363 (unsigned long long)r->end);
362 r->flags = 0; 364 r->flags = 0;
363 continue; 365 continue;
364 } 366 }
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 577f4b55c46d..ab78e4bbdd83 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -40,8 +40,9 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
40 40
41 pcibios_resource_to_bus(dev, &region, res); 41 pcibios_resource_to_bus(dev, &region, res);
42 42
43 pr_debug(" got res [%lx:%lx] bus [%lx:%lx] flags %lx for " 43 pr_debug(" got res [%llx:%llx] bus [%lx:%lx] flags %lx for "
44 "BAR %d of %s\n", res->start, res->end, 44 "BAR %d of %s\n", (unsigned long long)res->start,
45 (unsigned long long)res->end,
45 region.start, region.end, res->flags, resno, pci_name(dev)); 46 region.start, region.end, res->flags, resno, pci_name(dev));
46 47
47 new = region.start | (res->flags & PCI_REGION_FLAG_MASK); 48 new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
@@ -104,10 +105,12 @@ pci_claim_resource(struct pci_dev *dev, int resource)
104 err = insert_resource(root, res); 105 err = insert_resource(root, res);
105 106
106 if (err) { 107 if (err) {
107 printk(KERN_ERR "PCI: %s region %d of %s %s [%lx:%lx]\n", 108 printk(KERN_ERR "PCI: %s region %d of %s %s [%llx:%llx]\n",
108 root ? "Address space collision on" : 109 root ? "Address space collision on" :
109 "No parent found for", 110 "No parent found for",
110 resource, dtype, pci_name(dev), res->start, res->end); 111 resource, dtype, pci_name(dev),
112 (unsigned long long)res->start,
113 (unsigned long long)res->end);
111 } 114 }
112 115
113 return err; 116 return err;
@@ -118,7 +121,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
118{ 121{
119 struct pci_bus *bus = dev->bus; 122 struct pci_bus *bus = dev->bus;
120 struct resource *res = dev->resource + resno; 123 struct resource *res = dev->resource + resno;
121 unsigned long size, min, align; 124 resource_size_t size, min, align;
122 int ret; 125 int ret;
123 126
124 size = res->end - res->start + 1; 127 size = res->end - res->start + 1;
@@ -145,9 +148,11 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
145 } 148 }
146 149
147 if (ret) { 150 if (ret) {
148 printk(KERN_ERR "PCI: Failed to allocate %s resource #%d:%lx@%lx for %s\n", 151 printk(KERN_ERR "PCI: Failed to allocate %s resource "
149 res->flags & IORESOURCE_IO ? "I/O" : "mem", 152 "#%d:%llx@%llx for %s\n",
150 resno, size, res->start, pci_name(dev)); 153 res->flags & IORESOURCE_IO ? "I/O" : "mem",
154 resno, (unsigned long long)size,
155 (unsigned long long)res->start, pci_name(dev));
151 } else if (resno < PCI_BRIDGE_RESOURCES) { 156 } else if (resno < PCI_BRIDGE_RESOURCES) {
152 pci_update_resource(dev, res, resno); 157 pci_update_resource(dev, res, resno);
153 } 158 }
@@ -204,7 +209,7 @@ pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
204 for (i = 0; i < PCI_NUM_RESOURCES; i++) { 209 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
205 struct resource *r; 210 struct resource *r;
206 struct resource_list *list, *tmp; 211 struct resource_list *list, *tmp;
207 unsigned long r_align; 212 resource_size_t r_align;
208 213
209 r = &dev->resource[i]; 214 r = &dev->resource[i];
210 r_align = r->end - r->start; 215 r_align = r->end - r->start;
@@ -213,13 +218,14 @@ pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
213 continue; 218 continue;
214 if (!r_align) { 219 if (!r_align) {
215 printk(KERN_WARNING "PCI: Ignore bogus resource %d " 220 printk(KERN_WARNING "PCI: Ignore bogus resource %d "
216 "[%lx:%lx] of %s\n", 221 "[%llx:%llx] of %s\n",
217 i, r->start, r->end, pci_name(dev)); 222 i, (unsigned long long)r->start,
223 (unsigned long long)r->end, pci_name(dev));
218 continue; 224 continue;
219 } 225 }
220 r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start; 226 r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start;
221 for (list = head; ; list = list->next) { 227 for (list = head; ; list = list->next) {
222 unsigned long align = 0; 228 resource_size_t align = 0;
223 struct resource_list *ln = list->next; 229 struct resource_list *ln = list->next;
224 int idx; 230 int idx;
225 231
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index b39435bbfaeb..c662e4f89d46 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -244,8 +244,8 @@ static void hs_map_irq(hs_socket_t *sp, unsigned int irq)
244 244
245 hs_mapped_irq[irq].sock = sp; 245 hs_mapped_irq[irq].sock = sp;
246 /* insert ourselves as the irq controller */ 246 /* insert ourselves as the irq controller */
247 hs_mapped_irq[irq].old_handler = irq_desc[irq].handler; 247 hs_mapped_irq[irq].old_handler = irq_desc[irq].chip;
248 irq_desc[irq].handler = &hd64465_ss_irq_type; 248 irq_desc[irq].chip = &hd64465_ss_irq_type;
249} 249}
250 250
251 251
@@ -260,7 +260,7 @@ static void hs_unmap_irq(hs_socket_t *sp, unsigned int irq)
260 return; 260 return;
261 261
262 /* restore the original irq controller */ 262 /* restore the original irq controller */
263 irq_desc[irq].handler = hs_mapped_irq[irq].old_handler; 263 irq_desc[irq].chip = hs_mapped_irq[irq].old_handler;
264} 264}
265 265
266/*============================================================*/ 266/*============================================================*/
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index a2f05f485156..ff51a65d9433 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -1084,9 +1084,10 @@ static int i365_set_mem_map(u_short sock, struct pccard_mem_map *mem)
1084 u_short base, i; 1084 u_short base, i;
1085 u_char map; 1085 u_char map;
1086 1086
1087 debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, %#lx-%#lx, " 1087 debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, %#llx-%#llx, "
1088 "%#x)\n", sock, mem->map, mem->flags, mem->speed, 1088 "%#x)\n", sock, mem->map, mem->flags, mem->speed,
1089 mem->res->start, mem->res->end, mem->card_start); 1089 (unsigned long long)mem->res->start,
1090 (unsigned long long)mem->res->end, mem->card_start);
1090 1091
1091 map = mem->map; 1092 map = mem->map;
1092 if ((map > 4) || (mem->card_start > 0x3ffffff) || 1093 if ((map > 4) || (mem->card_start > 0x3ffffff) ||
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index 0e07d9535116..d0f68ab8f041 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -157,7 +157,7 @@ MODULE_LICENSE("Dual MPL/GPL");
157 157
158static int pcmcia_schlvl = PCMCIA_SCHLVL; 158static int pcmcia_schlvl = PCMCIA_SCHLVL;
159 159
160static spinlock_t events_lock = SPIN_LOCK_UNLOCKED; 160static DEFINE_SPINLOCK(events_lock);
161 161
162 162
163#define PCMCIA_SOCKET_KEY_5V 1 163#define PCMCIA_SOCKET_KEY_5V 1
@@ -644,7 +644,7 @@ static struct platform_device m8xx_device = {
644}; 644};
645 645
646static u32 pending_events[PCMCIA_SOCKETS_NO]; 646static u32 pending_events[PCMCIA_SOCKETS_NO];
647static spinlock_t pending_event_lock = SPIN_LOCK_UNLOCKED; 647static DEFINE_SPINLOCK(pending_event_lock);
648 648
649static irqreturn_t m8xx_interrupt(int irq, void *dev, struct pt_regs *regs) 649static irqreturn_t m8xx_interrupt(int irq, void *dev, struct pt_regs *regs)
650{ 650{
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 247ab837f841..9ee26c1b8635 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -642,7 +642,8 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
642 goto err_out_free_mem; 642 goto err_out_free_mem;
643 643
644 printk(KERN_INFO "pd6729: Cirrus PD6729 PCI to PCMCIA Bridge " 644 printk(KERN_INFO "pd6729: Cirrus PD6729 PCI to PCMCIA Bridge "
645 "at 0x%lx on irq %d\n", pci_resource_start(dev, 0), dev->irq); 645 "at 0x%llx on irq %d\n",
646 (unsigned long long)pci_resource_start(dev, 0), dev->irq);
646 /* 647 /*
647 * Since we have no memory BARs some firmware may not 648 * Since we have no memory BARs some firmware may not
648 * have had PCI_COMMAND_MEMORY enabled, yet the device needs it. 649 * have had PCI_COMMAND_MEMORY enabled, yet the device needs it.
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 0f8b157c9717..c3176b16b7be 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -72,7 +72,7 @@ static DEFINE_MUTEX(rsrc_mutex);
72======================================================================*/ 72======================================================================*/
73 73
74static struct resource * 74static struct resource *
75make_resource(unsigned long b, unsigned long n, int flags, char *name) 75make_resource(resource_size_t b, resource_size_t n, int flags, char *name)
76{ 76{
77 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); 77 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
78 78
@@ -86,8 +86,8 @@ make_resource(unsigned long b, unsigned long n, int flags, char *name)
86} 86}
87 87
88static struct resource * 88static struct resource *
89claim_region(struct pcmcia_socket *s, unsigned long base, unsigned long size, 89claim_region(struct pcmcia_socket *s, resource_size_t base,
90 int type, char *name) 90 resource_size_t size, int type, char *name)
91{ 91{
92 struct resource *res, *parent; 92 struct resource *res, *parent;
93 93
@@ -519,10 +519,10 @@ struct pcmcia_align_data {
519 519
520static void 520static void
521pcmcia_common_align(void *align_data, struct resource *res, 521pcmcia_common_align(void *align_data, struct resource *res,
522 unsigned long size, unsigned long align) 522 resource_size_t size, resource_size_t align)
523{ 523{
524 struct pcmcia_align_data *data = align_data; 524 struct pcmcia_align_data *data = align_data;
525 unsigned long start; 525 resource_size_t start;
526 /* 526 /*
527 * Ensure that we have the correct start address 527 * Ensure that we have the correct start address
528 */ 528 */
@@ -533,8 +533,8 @@ pcmcia_common_align(void *align_data, struct resource *res,
533} 533}
534 534
535static void 535static void
536pcmcia_align(void *align_data, struct resource *res, 536pcmcia_align(void *align_data, struct resource *res, resource_size_t size,
537 unsigned long size, unsigned long align) 537 resource_size_t align)
538{ 538{
539 struct pcmcia_align_data *data = align_data; 539 struct pcmcia_align_data *data = align_data;
540 struct resource_map *m; 540 struct resource_map *m;
@@ -808,8 +808,10 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
808 if (res->flags & IORESOURCE_IO) { 808 if (res->flags & IORESOURCE_IO) {
809 if (res == &ioport_resource) 809 if (res == &ioport_resource)
810 continue; 810 continue;
811 printk(KERN_INFO "pcmcia: parent PCI bridge I/O window: 0x%lx - 0x%lx\n", 811 printk(KERN_INFO "pcmcia: parent PCI bridge I/O "
812 res->start, res->end); 812 "window: 0x%llx - 0x%llx\n",
813 (unsigned long long)res->start,
814 (unsigned long long)res->end);
813 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 815 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
814 done |= IORESOURCE_IO; 816 done |= IORESOURCE_IO;
815 817
@@ -818,8 +820,10 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
818 if (res->flags & IORESOURCE_MEM) { 820 if (res->flags & IORESOURCE_MEM) {
819 if (res == &iomem_resource) 821 if (res == &iomem_resource)
820 continue; 822 continue;
821 printk(KERN_INFO "pcmcia: parent PCI bridge Memory window: 0x%lx - 0x%lx\n", 823 printk(KERN_INFO "pcmcia: parent PCI bridge Memory "
822 res->start, res->end); 824 "window: 0x%llx - 0x%llx\n",
825 (unsigned long long)res->start,
826 (unsigned long long)res->end);
823 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 827 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
824 done |= IORESOURCE_MEM; 828 done |= IORESOURCE_MEM;
825 } 829 }
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 73bad1d5cb23..65a60671659f 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -756,8 +756,9 @@ static int tcic_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *m
756 u_long base, len, mmap; 756 u_long base, len, mmap;
757 757
758 debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, " 758 debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, "
759 "%#lx-%#lx, %#x)\n", psock, mem->map, mem->flags, 759 "%#llx-%#llx, %#x)\n", psock, mem->map, mem->flags,
760 mem->speed, mem->res->start, mem->res->end, mem->card_start); 760 mem->speed, (unsigned long long)mem->res->start,
761 (unsigned long long)mem->res->end, mem->card_start);
761 if ((mem->map > 3) || (mem->card_start > 0x3ffffff) || 762 if ((mem->map > 3) || (mem->card_start > 0x3ffffff) ||
762 (mem->res->start > 0xffffff) || (mem->res->end > 0xffffff) || 763 (mem->res->start > 0xffffff) || (mem->res->end > 0xffffff) ||
763 (mem->res->start > mem->res->end) || (mem->speed > 1000)) 764 (mem->res->start > mem->res->end) || (mem->speed > 1000))
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index a2d8ce7fef9c..3163e3d73da1 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -264,7 +264,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at
264 if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) 264 if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED)
265 pnp_printf(buffer," disabled\n"); 265 pnp_printf(buffer," disabled\n");
266 else 266 else
267 pnp_printf(buffer," 0x%lx-0x%lx\n", 267 pnp_printf(buffer," 0x%llx-0x%llx\n",
268 pnp_port_start(dev, i), 268 pnp_port_start(dev, i),
269 pnp_port_end(dev, i)); 269 pnp_port_end(dev, i));
270 } 270 }
@@ -275,7 +275,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at
275 if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) 275 if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED)
276 pnp_printf(buffer," disabled\n"); 276 pnp_printf(buffer," disabled\n");
277 else 277 else
278 pnp_printf(buffer," 0x%lx-0x%lx\n", 278 pnp_printf(buffer," 0x%llx-0x%llx\n",
279 pnp_mem_start(dev, i), 279 pnp_mem_start(dev, i),
280 pnp_mem_end(dev, i)); 280 pnp_mem_end(dev, i));
281 } 281 }
@@ -286,7 +286,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at
286 if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) 286 if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED)
287 pnp_printf(buffer," disabled\n"); 287 pnp_printf(buffer," disabled\n");
288 else 288 else
289 pnp_printf(buffer," %ld\n", 289 pnp_printf(buffer," %lld\n",
290 pnp_irq(dev, i)); 290 pnp_irq(dev, i));
291 } 291 }
292 } 292 }
@@ -296,7 +296,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at
296 if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) 296 if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED)
297 pnp_printf(buffer," disabled\n"); 297 pnp_printf(buffer," disabled\n");
298 else 298 else
299 pnp_printf(buffer," %ld\n", 299 pnp_printf(buffer," %lld\n",
300 pnp_dma(dev, i)); 300 pnp_dma(dev, i));
301 } 301 }
302 } 302 }
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 6fff109bdab6..1d7a5b87f4cb 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -20,7 +20,8 @@ DECLARE_MUTEX(pnp_res_mutex);
20 20
21static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) 21static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
22{ 22{
23 unsigned long *start, *end, *flags; 23 resource_size_t *start, *end;
24 unsigned long *flags;
24 25
25 if (!dev || !rule) 26 if (!dev || !rule)
26 return -EINVAL; 27 return -EINVAL;
@@ -63,7 +64,8 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
63 64
64static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) 65static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
65{ 66{
66 unsigned long *start, *end, *flags; 67 resource_size_t *start, *end;
68 unsigned long *flags;
67 69
68 if (!dev || !rule) 70 if (!dev || !rule)
69 return -EINVAL; 71 return -EINVAL;
@@ -116,7 +118,8 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
116 118
117static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) 119static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx)
118{ 120{
119 unsigned long *start, *end, *flags; 121 resource_size_t *start, *end;
122 unsigned long *flags;
120 int i; 123 int i;
121 124
122 /* IRQ priority: this table is good for i386 */ 125 /* IRQ priority: this table is good for i386 */
@@ -168,7 +171,8 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx)
168 171
169static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) 172static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
170{ 173{
171 unsigned long *start, *end, *flags; 174 resource_size_t *start, *end;
175 unsigned long *flags;
172 int i; 176 int i;
173 177
174 /* DMA priority: this table is good for i386 */ 178 /* DMA priority: this table is good for i386 */
@@ -582,7 +586,8 @@ int pnp_disable_dev(struct pnp_dev *dev)
582 * @size: size of region 586 * @size: size of region
583 * 587 *
584 */ 588 */
585void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) 589void pnp_resource_change(struct resource *resource, resource_size_t start,
590 resource_size_t size)
586{ 591{
587 if (resource == NULL) 592 if (resource == NULL)
588 return; 593 return;
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 6ded527169f4..7bb892f58cc0 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -241,7 +241,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
241{ 241{
242 int tmp; 242 int tmp;
243 struct pnp_dev *tdev; 243 struct pnp_dev *tdev;
244 unsigned long *port, *end, *tport, *tend; 244 resource_size_t *port, *end, *tport, *tend;
245 port = &dev->res.port_resource[idx].start; 245 port = &dev->res.port_resource[idx].start;
246 end = &dev->res.port_resource[idx].end; 246 end = &dev->res.port_resource[idx].end;
247 247
@@ -297,7 +297,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx)
297{ 297{
298 int tmp; 298 int tmp;
299 struct pnp_dev *tdev; 299 struct pnp_dev *tdev;
300 unsigned long *addr, *end, *taddr, *tend; 300 resource_size_t *addr, *end, *taddr, *tend;
301 addr = &dev->res.mem_resource[idx].start; 301 addr = &dev->res.mem_resource[idx].start;
302 end = &dev->res.mem_resource[idx].end; 302 end = &dev->res.mem_resource[idx].end;
303 303
@@ -358,7 +358,7 @@ int pnp_check_irq(struct pnp_dev * dev, int idx)
358{ 358{
359 int tmp; 359 int tmp;
360 struct pnp_dev *tdev; 360 struct pnp_dev *tdev;
361 unsigned long * irq = &dev->res.irq_resource[idx].start; 361 resource_size_t * irq = &dev->res.irq_resource[idx].start;
362 362
363 /* if the resource doesn't exist, don't complain about it */ 363 /* if the resource doesn't exist, don't complain about it */
364 if (cannot_compare(dev->res.irq_resource[idx].flags)) 364 if (cannot_compare(dev->res.irq_resource[idx].flags))
@@ -423,7 +423,7 @@ int pnp_check_dma(struct pnp_dev * dev, int idx)
423#ifndef CONFIG_IA64 423#ifndef CONFIG_IA64
424 int tmp; 424 int tmp;
425 struct pnp_dev *tdev; 425 struct pnp_dev *tdev;
426 unsigned long * dma = &dev->res.dma_resource[idx].start; 426 resource_size_t * dma = &dev->res.dma_resource[idx].start;
427 427
428 /* if the resource doesn't exist, don't complain about it */ 428 /* if the resource doesn't exist, don't complain about it */
429 if (cannot_compare(dev->res.dma_resource[idx].flags)) 429 if (cannot_compare(dev->res.dma_resource[idx].flags))
diff --git a/drivers/rapidio/rio-access.c b/drivers/rapidio/rio-access.c
index b9fab2ae3a36..8b56bbdd011e 100644
--- a/drivers/rapidio/rio-access.c
+++ b/drivers/rapidio/rio-access.c
@@ -17,8 +17,8 @@
17 * These interrupt-safe spinlocks protect all accesses to RIO 17 * These interrupt-safe spinlocks protect all accesses to RIO
18 * configuration space and doorbell access. 18 * configuration space and doorbell access.
19 */ 19 */
20static spinlock_t rio_config_lock = SPIN_LOCK_UNLOCKED; 20static DEFINE_SPINLOCK(rio_config_lock);
21static spinlock_t rio_doorbell_lock = SPIN_LOCK_UNLOCKED; 21static DEFINE_SPINLOCK(rio_doorbell_lock);
22 22
23/* 23/*
24 * Wrappers for all RIO configuration access functions. They just check 24 * Wrappers for all RIO configuration access functions. They just check
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index bccff400b198..f2fc81a9074d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -162,6 +162,16 @@ config RTC_DRV_PCF8583
162 This driver can also be built as a module. If so, the module 162 This driver can also be built as a module. If so, the module
163 will be called rtc-pcf8583. 163 will be called rtc-pcf8583.
164 164
165config RTC_DRV_RS5C348
166 tristate "Ricoh RS5C348A/B"
167 depends on RTC_CLASS && SPI
168 help
169 If you say yes here you get support for the
170 Ricoh RS5C348A and RS5C348B RTC chips.
171
172 This driver can also be built as a module. If so, the module
173 will be called rtc-rs5c348.
174
165config RTC_DRV_RS5C372 175config RTC_DRV_RS5C372
166 tristate "Ricoh RS5C372A/B" 176 tristate "Ricoh RS5C372A/B"
167 depends on RTC_CLASS && I2C 177 depends on RTC_CLASS && I2C
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 900d210dd1a2..da5e38774e13 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
19obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 19obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
20obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 20obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
21obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o 21obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
22obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
22obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o 23obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
23obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o 24obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o
24obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o 25obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 5396beec30d0..1cb61a761cb2 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -94,7 +94,9 @@ exit_kfree:
94 kfree(rtc); 94 kfree(rtc);
95 95
96exit_idr: 96exit_idr:
97 mutex_lock(&idr_lock);
97 idr_remove(&rtc_idr, id); 98 idr_remove(&rtc_idr, id);
99 mutex_unlock(&idr_lock);
98 100
99exit: 101exit:
100 dev_err(dev, "rtc core: unable to register %s, err = %d\n", 102 dev_err(dev, "rtc core: unable to register %s, err = %d\n",
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index ecafbad41a24..762521a1419c 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -226,7 +226,7 @@ static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd,
226 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 226 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
227 227
228 if (pdata->irq < 0) 228 if (pdata->irq < 0)
229 return -ENOIOCTLCMD; 229 return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
230 switch (cmd) { 230 switch (cmd) {
231 case RTC_AIE_OFF: 231 case RTC_AIE_OFF:
232 pdata->irqen &= ~RTC_AF; 232 pdata->irqen &= ~RTC_AF;
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
new file mode 100644
index 000000000000..0964d1dba925
--- /dev/null
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -0,0 +1,246 @@
1/*
2 * A SPI driver for the Ricoh RS5C348 RTC
3 *
4 * Copyright (C) 2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp>
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 * The board specific init code should provide characteristics of this
11 * device:
12 * Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS
13 */
14
15#include <linux/bcd.h>
16#include <linux/delay.h>
17#include <linux/device.h>
18#include <linux/errno.h>
19#include <linux/init.h>
20#include <linux/kernel.h>
21#include <linux/string.h>
22#include <linux/rtc.h>
23#include <linux/workqueue.h>
24#include <linux/spi/spi.h>
25
26#define DRV_VERSION "0.1"
27
28#define RS5C348_REG_SECS 0
29#define RS5C348_REG_MINS 1
30#define RS5C348_REG_HOURS 2
31#define RS5C348_REG_WDAY 3
32#define RS5C348_REG_DAY 4
33#define RS5C348_REG_MONTH 5
34#define RS5C348_REG_YEAR 6
35#define RS5C348_REG_CTL1 14
36#define RS5C348_REG_CTL2 15
37
38#define RS5C348_SECS_MASK 0x7f
39#define RS5C348_MINS_MASK 0x7f
40#define RS5C348_HOURS_MASK 0x3f
41#define RS5C348_WDAY_MASK 0x03
42#define RS5C348_DAY_MASK 0x3f
43#define RS5C348_MONTH_MASK 0x1f
44
45#define RS5C348_BIT_PM 0x20 /* REG_HOURS */
46#define RS5C348_BIT_Y2K 0x80 /* REG_MONTH */
47#define RS5C348_BIT_24H 0x20 /* REG_CTL1 */
48#define RS5C348_BIT_XSTP 0x10 /* REG_CTL2 */
49#define RS5C348_BIT_VDET 0x40 /* REG_CTL2 */
50
51#define RS5C348_CMD_W(addr) (((addr) << 4) | 0x08) /* single write */
52#define RS5C348_CMD_R(addr) (((addr) << 4) | 0x0c) /* single read */
53#define RS5C348_CMD_MW(addr) (((addr) << 4) | 0x00) /* burst write */
54#define RS5C348_CMD_MR(addr) (((addr) << 4) | 0x04) /* burst read */
55
56struct rs5c348_plat_data {
57 struct rtc_device *rtc;
58 int rtc_24h;
59};
60
61static int
62rs5c348_rtc_set_time(struct device *dev, struct rtc_time *tm)
63{
64 struct spi_device *spi = to_spi_device(dev);
65 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
66 u8 txbuf[5+7], *txp;
67 int ret;
68
69 /* Transfer 5 bytes before writing SEC. This gives 31us for carry. */
70 txp = txbuf;
71 txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
72 txbuf[1] = 0; /* dummy */
73 txbuf[2] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
74 txbuf[3] = 0; /* dummy */
75 txbuf[4] = RS5C348_CMD_MW(RS5C348_REG_SECS); /* cmd, sec, ... */
76 txp = &txbuf[5];
77 txp[RS5C348_REG_SECS] = BIN2BCD(tm->tm_sec);
78 txp[RS5C348_REG_MINS] = BIN2BCD(tm->tm_min);
79 if (pdata->rtc_24h) {
80 txp[RS5C348_REG_HOURS] = BIN2BCD(tm->tm_hour);
81 } else {
82 /* hour 0 is AM12, noon is PM12 */
83 txp[RS5C348_REG_HOURS] = BIN2BCD((tm->tm_hour + 11) % 12 + 1) |
84 (tm->tm_hour >= 12 ? RS5C348_BIT_PM : 0);
85 }
86 txp[RS5C348_REG_WDAY] = BIN2BCD(tm->tm_wday);
87 txp[RS5C348_REG_DAY] = BIN2BCD(tm->tm_mday);
88 txp[RS5C348_REG_MONTH] = BIN2BCD(tm->tm_mon + 1) |
89 (tm->tm_year >= 100 ? RS5C348_BIT_Y2K : 0);
90 txp[RS5C348_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
91 /* write in one transfer to avoid data inconsistency */
92 ret = spi_write_then_read(spi, txbuf, sizeof(txbuf), NULL, 0);
93 udelay(62); /* Tcsr 62us */
94 return ret;
95}
96
97static int
98rs5c348_rtc_read_time(struct device *dev, struct rtc_time *tm)
99{
100 struct spi_device *spi = to_spi_device(dev);
101 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
102 u8 txbuf[5], rxbuf[7];
103 int ret;
104
105 /* Transfer 5 byte befores reading SEC. This gives 31us for carry. */
106 txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
107 txbuf[1] = 0; /* dummy */
108 txbuf[2] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
109 txbuf[3] = 0; /* dummy */
110 txbuf[4] = RS5C348_CMD_MR(RS5C348_REG_SECS); /* cmd, sec, ... */
111
112 /* read in one transfer to avoid data inconsistency */
113 ret = spi_write_then_read(spi, txbuf, sizeof(txbuf),
114 rxbuf, sizeof(rxbuf));
115 udelay(62); /* Tcsr 62us */
116 if (ret < 0)
117 return ret;
118
119 tm->tm_sec = BCD2BIN(rxbuf[RS5C348_REG_SECS] & RS5C348_SECS_MASK);
120 tm->tm_min = BCD2BIN(rxbuf[RS5C348_REG_MINS] & RS5C348_MINS_MASK);
121 tm->tm_hour = BCD2BIN(rxbuf[RS5C348_REG_HOURS] & RS5C348_HOURS_MASK);
122 if (!pdata->rtc_24h) {
123 tm->tm_hour %= 12;
124 if (rxbuf[RS5C348_REG_HOURS] & RS5C348_BIT_PM)
125 tm->tm_hour += 12;
126 }
127 tm->tm_wday = BCD2BIN(rxbuf[RS5C348_REG_WDAY] & RS5C348_WDAY_MASK);
128 tm->tm_mday = BCD2BIN(rxbuf[RS5C348_REG_DAY] & RS5C348_DAY_MASK);
129 tm->tm_mon =
130 BCD2BIN(rxbuf[RS5C348_REG_MONTH] & RS5C348_MONTH_MASK) - 1;
131 /* year is 1900 + tm->tm_year */
132 tm->tm_year = BCD2BIN(rxbuf[RS5C348_REG_YEAR]) +
133 ((rxbuf[RS5C348_REG_MONTH] & RS5C348_BIT_Y2K) ? 100 : 0);
134
135 if (rtc_valid_tm(tm) < 0) {
136 dev_err(&spi->dev, "retrieved date/time is not valid.\n");
137 rtc_time_to_tm(0, tm);
138 }
139
140 return 0;
141}
142
143static struct rtc_class_ops rs5c348_rtc_ops = {
144 .read_time = rs5c348_rtc_read_time,
145 .set_time = rs5c348_rtc_set_time,
146};
147
148static struct spi_driver rs5c348_driver;
149
150static int __devinit rs5c348_probe(struct spi_device *spi)
151{
152 int ret;
153 struct rtc_device *rtc;
154 struct rs5c348_plat_data *pdata;
155
156 pdata = kzalloc(sizeof(struct rs5c348_plat_data), GFP_KERNEL);
157 if (!pdata)
158 return -ENOMEM;
159 spi->dev.platform_data = pdata;
160
161 /* Check D7 of SECOND register */
162 ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_SECS));
163 if (ret < 0 || (ret & 0x80)) {
164 dev_err(&spi->dev, "not found.\n");
165 goto kfree_exit;
166 }
167
168 dev_info(&spi->dev, "chip found, driver version " DRV_VERSION "\n");
169 dev_info(&spi->dev, "spiclk %u KHz.\n",
170 (spi->max_speed_hz + 500) / 1000);
171
172 /* turn RTC on if it was not on */
173 ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL2));
174 if (ret < 0)
175 goto kfree_exit;
176 if (ret & (RS5C348_BIT_XSTP | RS5C348_BIT_VDET)) {
177 u8 buf[2];
178 if (ret & RS5C348_BIT_VDET)
179 dev_warn(&spi->dev, "voltage-low detected.\n");
180 buf[0] = RS5C348_CMD_W(RS5C348_REG_CTL2);
181 buf[1] = 0;
182 ret = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0);
183 if (ret < 0)
184 goto kfree_exit;
185 }
186
187 ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL1));
188 if (ret < 0)
189 goto kfree_exit;
190 if (ret & RS5C348_BIT_24H)
191 pdata->rtc_24h = 1;
192
193 rtc = rtc_device_register(rs5c348_driver.driver.name, &spi->dev,
194 &rs5c348_rtc_ops, THIS_MODULE);
195
196 if (IS_ERR(rtc)) {
197 ret = PTR_ERR(rtc);
198 goto kfree_exit;
199 }
200
201 pdata->rtc = rtc;
202
203 return 0;
204 kfree_exit:
205 kfree(pdata);
206 return ret;
207}
208
209static int __devexit rs5c348_remove(struct spi_device *spi)
210{
211 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
212 struct rtc_device *rtc = pdata->rtc;
213
214 if (rtc)
215 rtc_device_unregister(rtc);
216 kfree(pdata);
217 return 0;
218}
219
220static struct spi_driver rs5c348_driver = {
221 .driver = {
222 .name = "rs5c348",
223 .bus = &spi_bus_type,
224 .owner = THIS_MODULE,
225 },
226 .probe = rs5c348_probe,
227 .remove = __devexit_p(rs5c348_remove),
228};
229
230static __init int rs5c348_init(void)
231{
232 return spi_register_driver(&rs5c348_driver);
233}
234
235static __exit void rs5c348_exit(void)
236{
237 spi_unregister_driver(&rs5c348_driver);
238}
239
240module_init(rs5c348_init);
241module_exit(rs5c348_exit);
242
243MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
244MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver");
245MODULE_LICENSE("GPL");
246MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index ab486fbc828d..9cd1cb304bb2 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -45,7 +45,7 @@
45 45
46static unsigned long rtc_freq = 1024; 46static unsigned long rtc_freq = 1024;
47static struct rtc_time rtc_alarm; 47static struct rtc_time rtc_alarm;
48static spinlock_t sa1100_rtc_lock = SPIN_LOCK_UNLOCKED; 48static DEFINE_SPINLOCK(sa1100_rtc_lock);
49 49
50static int rtc_update_alarm(struct rtc_time *alrm) 50static int rtc_update_alarm(struct rtc_time *alrm)
51{ 51{
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index 33e029207e26..4b9291dd4443 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -93,7 +93,7 @@ static void __iomem *rtc2_base;
93 93
94static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */ 94static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */
95 95
96static spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; 96static DEFINE_SPINLOCK(rtc_lock);
97static char rtc_name[] = "RTC"; 97static char rtc_name[] = "RTC";
98static unsigned long periodic_frequency; 98static unsigned long periodic_frequency;
99static unsigned long periodic_count; 99static unsigned long periodic_count;
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index cfb1fff3787c..2dc179b14ce6 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -95,7 +95,7 @@ dasd_alloc_device(void)
95 spin_lock_init(&device->mem_lock); 95 spin_lock_init(&device->mem_lock);
96 spin_lock_init(&device->request_queue_lock); 96 spin_lock_init(&device->request_queue_lock);
97 atomic_set (&device->tasklet_scheduled, 0); 97 atomic_set (&device->tasklet_scheduled, 0);
98 tasklet_init(&device->tasklet, 98 tasklet_init(&device->tasklet,
99 (void (*)(unsigned long)) dasd_tasklet, 99 (void (*)(unsigned long)) dasd_tasklet,
100 (unsigned long) device); 100 (unsigned long) device);
101 INIT_LIST_HEAD(&device->ccw_queue); 101 INIT_LIST_HEAD(&device->ccw_queue);
@@ -128,7 +128,7 @@ dasd_state_new_to_known(struct dasd_device *device)
128 int rc; 128 int rc;
129 129
130 /* 130 /*
131 * As long as the device is not in state DASD_STATE_NEW we want to 131 * As long as the device is not in state DASD_STATE_NEW we want to
132 * keep the reference count > 0. 132 * keep the reference count > 0.
133 */ 133 */
134 dasd_get_device(device); 134 dasd_get_device(device);
@@ -336,7 +336,7 @@ dasd_decrease_state(struct dasd_device *device)
336 if (device->state == DASD_STATE_ONLINE && 336 if (device->state == DASD_STATE_ONLINE &&
337 device->target <= DASD_STATE_READY) 337 device->target <= DASD_STATE_READY)
338 dasd_state_online_to_ready(device); 338 dasd_state_online_to_ready(device);
339 339
340 if (device->state == DASD_STATE_READY && 340 if (device->state == DASD_STATE_READY &&
341 device->target <= DASD_STATE_BASIC) 341 device->target <= DASD_STATE_BASIC)
342 dasd_state_ready_to_basic(device); 342 dasd_state_ready_to_basic(device);
@@ -348,7 +348,7 @@ dasd_decrease_state(struct dasd_device *device)
348 if (device->state == DASD_STATE_BASIC && 348 if (device->state == DASD_STATE_BASIC &&
349 device->target <= DASD_STATE_KNOWN) 349 device->target <= DASD_STATE_KNOWN)
350 dasd_state_basic_to_known(device); 350 dasd_state_basic_to_known(device);
351 351
352 if (device->state == DASD_STATE_KNOWN && 352 if (device->state == DASD_STATE_KNOWN &&
353 device->target <= DASD_STATE_NEW) 353 device->target <= DASD_STATE_NEW)
354 dasd_state_known_to_new(device); 354 dasd_state_known_to_new(device);
@@ -994,7 +994,7 @@ dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
994 ((irb->scsw.cstat << 8) | irb->scsw.dstat), cqr); 994 ((irb->scsw.cstat << 8) | irb->scsw.dstat), cqr);
995 995
996 /* Find out the appropriate era_action. */ 996 /* Find out the appropriate era_action. */
997 if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) 997 if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC)
998 era = dasd_era_fatal; 998 era = dasd_era_fatal;
999 else if (irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && 999 else if (irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
1000 irb->scsw.cstat == 0 && 1000 irb->scsw.cstat == 0 &&
@@ -1004,7 +1004,7 @@ dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
1004 era = dasd_era_fatal; /* don't recover this request */ 1004 era = dasd_era_fatal; /* don't recover this request */
1005 else if (irb->esw.esw0.erw.cons) 1005 else if (irb->esw.esw0.erw.cons)
1006 era = device->discipline->examine_error(cqr, irb); 1006 era = device->discipline->examine_error(cqr, irb);
1007 else 1007 else
1008 era = dasd_era_recover; 1008 era = dasd_era_recover;
1009 1009
1010 DBF_DEV_EVENT(DBF_DEBUG, device, "era_code %d", era); 1010 DBF_DEV_EVENT(DBF_DEBUG, device, "era_code %d", era);
@@ -1287,7 +1287,7 @@ __dasd_start_head(struct dasd_device * device)
1287} 1287}
1288 1288
1289/* 1289/*
1290 * Remove requests from the ccw queue. 1290 * Remove requests from the ccw queue.
1291 */ 1291 */
1292static void 1292static void
1293dasd_flush_ccw_queue(struct dasd_device * device, int all) 1293dasd_flush_ccw_queue(struct dasd_device * device, int all)
@@ -1450,23 +1450,23 @@ dasd_sleep_on(struct dasd_ccw_req * cqr)
1450 wait_queue_head_t wait_q; 1450 wait_queue_head_t wait_q;
1451 struct dasd_device *device; 1451 struct dasd_device *device;
1452 int rc; 1452 int rc;
1453 1453
1454 device = cqr->device; 1454 device = cqr->device;
1455 spin_lock_irq(get_ccwdev_lock(device->cdev)); 1455 spin_lock_irq(get_ccwdev_lock(device->cdev));
1456 1456
1457 init_waitqueue_head (&wait_q); 1457 init_waitqueue_head (&wait_q);
1458 cqr->callback = dasd_wakeup_cb; 1458 cqr->callback = dasd_wakeup_cb;
1459 cqr->callback_data = (void *) &wait_q; 1459 cqr->callback_data = (void *) &wait_q;
1460 cqr->status = DASD_CQR_QUEUED; 1460 cqr->status = DASD_CQR_QUEUED;
1461 list_add_tail(&cqr->list, &device->ccw_queue); 1461 list_add_tail(&cqr->list, &device->ccw_queue);
1462 1462
1463 /* let the bh start the request to keep them in order */ 1463 /* let the bh start the request to keep them in order */
1464 dasd_schedule_bh(device); 1464 dasd_schedule_bh(device);
1465 1465
1466 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1466 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1467 1467
1468 wait_event(wait_q, _wait_for_wakeup(cqr)); 1468 wait_event(wait_q, _wait_for_wakeup(cqr));
1469 1469
1470 /* Request status is either done or failed. */ 1470 /* Request status is either done or failed. */
1471 rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0; 1471 rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
1472 return rc; 1472 return rc;
@@ -1568,7 +1568,7 @@ dasd_sleep_on_immediatly(struct dasd_ccw_req * cqr)
1568 wait_queue_head_t wait_q; 1568 wait_queue_head_t wait_q;
1569 struct dasd_device *device; 1569 struct dasd_device *device;
1570 int rc; 1570 int rc;
1571 1571
1572 device = cqr->device; 1572 device = cqr->device;
1573 spin_lock_irq(get_ccwdev_lock(device->cdev)); 1573 spin_lock_irq(get_ccwdev_lock(device->cdev));
1574 rc = _dasd_term_running_cqr(device); 1574 rc = _dasd_term_running_cqr(device);
@@ -1576,20 +1576,20 @@ dasd_sleep_on_immediatly(struct dasd_ccw_req * cqr)
1576 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1576 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1577 return rc; 1577 return rc;
1578 } 1578 }
1579 1579
1580 init_waitqueue_head (&wait_q); 1580 init_waitqueue_head (&wait_q);
1581 cqr->callback = dasd_wakeup_cb; 1581 cqr->callback = dasd_wakeup_cb;
1582 cqr->callback_data = (void *) &wait_q; 1582 cqr->callback_data = (void *) &wait_q;
1583 cqr->status = DASD_CQR_QUEUED; 1583 cqr->status = DASD_CQR_QUEUED;
1584 list_add(&cqr->list, &device->ccw_queue); 1584 list_add(&cqr->list, &device->ccw_queue);
1585 1585
1586 /* let the bh start the request to keep them in order */ 1586 /* let the bh start the request to keep them in order */
1587 dasd_schedule_bh(device); 1587 dasd_schedule_bh(device);
1588 1588
1589 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1589 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1590 1590
1591 wait_event(wait_q, _wait_for_wakeup(cqr)); 1591 wait_event(wait_q, _wait_for_wakeup(cqr));
1592 1592
1593 /* Request status is either done or failed. */ 1593 /* Request status is either done or failed. */
1594 rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0; 1594 rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
1595 return rc; 1595 return rc;
@@ -1725,7 +1725,7 @@ dasd_flush_request_queue(struct dasd_device * device)
1725 1725
1726 if (!device->request_queue) 1726 if (!device->request_queue)
1727 return; 1727 return;
1728 1728
1729 spin_lock_irq(&device->request_queue_lock); 1729 spin_lock_irq(&device->request_queue_lock);
1730 while (!list_empty(&device->request_queue->queue_head)) { 1730 while (!list_empty(&device->request_queue->queue_head)) {
1731 req = elv_next_request(device->request_queue); 1731 req = elv_next_request(device->request_queue);
@@ -1834,7 +1834,6 @@ dasd_exit(void)
1834 } 1834 }
1835 dasd_gendisk_exit(); 1835 dasd_gendisk_exit();
1836 dasd_devmap_exit(); 1836 dasd_devmap_exit();
1837 devfs_remove("dasd");
1838 if (dasd_debug_area != NULL) { 1837 if (dasd_debug_area != NULL) {
1839 debug_unregister(dasd_debug_area); 1838 debug_unregister(dasd_debug_area);
1840 dasd_debug_area = NULL; 1839 dasd_debug_area = NULL;
@@ -1855,15 +1854,34 @@ dasd_generic_probe (struct ccw_device *cdev,
1855{ 1854{
1856 int ret; 1855 int ret;
1857 1856
1857 ret = ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
1858 if (ret) {
1859 printk(KERN_WARNING
1860 "dasd_generic_probe: could not set ccw-device options "
1861 "for %s\n", cdev->dev.bus_id);
1862 return ret;
1863 }
1858 ret = dasd_add_sysfs_files(cdev); 1864 ret = dasd_add_sysfs_files(cdev);
1859 if (ret) { 1865 if (ret) {
1860 printk(KERN_WARNING 1866 printk(KERN_WARNING
1861 "dasd_generic_probe: could not add sysfs entries " 1867 "dasd_generic_probe: could not add sysfs entries "
1862 "for %s\n", cdev->dev.bus_id); 1868 "for %s\n", cdev->dev.bus_id);
1863 } else { 1869 return ret;
1864 cdev->handler = &dasd_int_handler;
1865 } 1870 }
1871 cdev->handler = &dasd_int_handler;
1866 1872
1873 /*
1874 * Automatically online either all dasd devices (dasd_autodetect)
1875 * or all devices specified with dasd= parameters during
1876 * initial probe.
1877 */
1878 if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) ||
1879 (dasd_autodetect && dasd_busid_known(cdev->dev.bus_id) != 0))
1880 ret = ccw_device_set_online(cdev);
1881 if (ret)
1882 printk(KERN_WARNING
1883 "dasd_generic_probe: could not initially online "
1884 "ccw-device %s\n", cdev->dev.bus_id);
1867 return ret; 1885 return ret;
1868} 1886}
1869 1887
@@ -1911,6 +1929,8 @@ dasd_generic_set_online (struct ccw_device *cdev,
1911 struct dasd_device *device; 1929 struct dasd_device *device;
1912 int rc; 1930 int rc;
1913 1931
1932 /* first online clears initial online feature flag */
1933 dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0);
1914 device = dasd_create_device(cdev); 1934 device = dasd_create_device(cdev);
1915 if (IS_ERR(device)) 1935 if (IS_ERR(device))
1916 return PTR_ERR(device); 1936 return PTR_ERR(device);
@@ -2065,31 +2085,6 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
2065 return ret; 2085 return ret;
2066} 2086}
2067 2087
2068/*
2069 * Automatically online either all dasd devices (dasd_autodetect) or
2070 * all devices specified with dasd= parameters.
2071 */
2072static int
2073__dasd_auto_online(struct device *dev, void *data)
2074{
2075 struct ccw_device *cdev;
2076
2077 cdev = to_ccwdev(dev);
2078 if (dasd_autodetect || dasd_busid_known(cdev->dev.bus_id) == 0)
2079 ccw_device_set_online(cdev);
2080 return 0;
2081}
2082
2083void
2084dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
2085{
2086 struct device_driver *drv;
2087
2088 drv = get_driver(&dasd_discipline_driver->driver);
2089 driver_for_each_device(drv, NULL, NULL, __dasd_auto_online);
2090 put_driver(drv);
2091}
2092
2093 2088
2094static int __init 2089static int __init
2095dasd_init(void) 2090dasd_init(void)
@@ -2111,9 +2106,6 @@ dasd_init(void)
2111 2106
2112 dasd_diag_discipline_pointer = NULL; 2107 dasd_diag_discipline_pointer = NULL;
2113 2108
2114 rc = devfs_mk_dir("dasd");
2115 if (rc)
2116 goto failed;
2117 rc = dasd_devmap_init(); 2109 rc = dasd_devmap_init();
2118 if (rc) 2110 if (rc)
2119 goto failed; 2111 goto failed;
@@ -2170,23 +2162,4 @@ EXPORT_SYMBOL_GPL(dasd_generic_remove);
2170EXPORT_SYMBOL_GPL(dasd_generic_notify); 2162EXPORT_SYMBOL_GPL(dasd_generic_notify);
2171EXPORT_SYMBOL_GPL(dasd_generic_set_online); 2163EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2172EXPORT_SYMBOL_GPL(dasd_generic_set_offline); 2164EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2173EXPORT_SYMBOL_GPL(dasd_generic_auto_online);
2174 2165
2175/*
2176 * Overrides for Emacs so that we follow Linus's tabbing style.
2177 * Emacs will notice this stuff at the end of the file and automatically
2178 * adjust the settings for this buffer only. This must remain at the end
2179 * of the file.
2180 * ---------------------------------------------------------------------------
2181 * Local variables:
2182 * c-indent-level: 4
2183 * c-brace-imaginary-offset: 0
2184 * c-brace-offset: -4
2185 * c-argdecl-indent: 4
2186 * c-label-offset: -4
2187 * c-continued-statement-offset: 4
2188 * c-continued-brace-offset: 0
2189 * indent-tabs-mode: 1
2190 * tab-width: 8
2191 * End:
2192 */
diff --git a/drivers/s390/block/dasd_3370_erp.c b/drivers/s390/block/dasd_3370_erp.c
index 1d11c2a9525d..1ddab8991d92 100644
--- a/drivers/s390/block/dasd_3370_erp.c
+++ b/drivers/s390/block/dasd_3370_erp.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_3370_erp.c 2 * File...........: linux/drivers/s390/block/dasd_3370_erp.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
@@ -12,10 +12,10 @@
12 12
13 13
14/* 14/*
15 * DASD_3370_ERP_EXAMINE 15 * DASD_3370_ERP_EXAMINE
16 * 16 *
17 * DESCRIPTION 17 * DESCRIPTION
18 * Checks only for fatal/no/recover error. 18 * Checks only for fatal/no/recover error.
19 * A detailed examination of the sense data is done later outside 19 * A detailed examination of the sense data is done later outside
20 * the interrupt handler. 20 * the interrupt handler.
21 * 21 *
@@ -23,7 +23,7 @@
23 * 'Chapter 7. 3370 Sense Data'. 23 * 'Chapter 7. 3370 Sense Data'.
24 * 24 *
25 * RETURN VALUES 25 * RETURN VALUES
26 * dasd_era_none no error 26 * dasd_era_none no error
27 * dasd_era_fatal for all fatal (unrecoverable errors) 27 * dasd_era_fatal for all fatal (unrecoverable errors)
28 * dasd_era_recover for all others. 28 * dasd_era_recover for all others.
29 */ 29 */
@@ -82,22 +82,3 @@ dasd_3370_erp_examine(struct dasd_ccw_req * cqr, struct irb * irb)
82 return dasd_era_recover; 82 return dasd_era_recover;
83 83
84} /* END dasd_3370_erp_examine */ 84} /* END dasd_3370_erp_examine */
85
86/*
87 * Overrides for Emacs so that we follow Linus's tabbing style.
88 * Emacs will notice this stuff at the end of the file and automatically
89 * adjust the settings for this buffer only. This must remain at the end
90 * of the file.
91 * ---------------------------------------------------------------------------
92 * Local variables:
93 * c-indent-level: 4
94 * c-brace-imaginary-offset: 0
95 * c-brace-offset: -4
96 * c-argdecl-indent: 4
97 * c-label-offset: -4
98 * c-continued-statement-offset: 4
99 * c-continued-brace-offset: 0
100 * indent-tabs-mode: 1
101 * tab-width: 8
102 * End:
103 */
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index 2ed51562319e..669805d4402d 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_3990_erp.c 2 * File...........: linux/drivers/s390/block/dasd_3990_erp.c
3 * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com> 3 * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
4 * Holger Smolinski <Holger.Smolinski@de.ibm.com> 4 * Holger Smolinski <Holger.Smolinski@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
@@ -25,23 +25,23 @@ struct DCTL_data {
25} __attribute__ ((packed)); 25} __attribute__ ((packed));
26 26
27/* 27/*
28 ***************************************************************************** 28 *****************************************************************************
29 * SECTION ERP EXAMINATION 29 * SECTION ERP EXAMINATION
30 ***************************************************************************** 30 *****************************************************************************
31 */ 31 */
32 32
33/* 33/*
34 * DASD_3990_ERP_EXAMINE_24 34 * DASD_3990_ERP_EXAMINE_24
35 * 35 *
36 * DESCRIPTION 36 * DESCRIPTION
37 * Checks only for fatal (unrecoverable) error. 37 * Checks only for fatal (unrecoverable) error.
38 * A detailed examination of the sense data is done later outside 38 * A detailed examination of the sense data is done later outside
39 * the interrupt handler. 39 * the interrupt handler.
40 * 40 *
41 * Each bit configuration leading to an action code 2 (Exit with 41 * Each bit configuration leading to an action code 2 (Exit with
42 * programming error or unusual condition indication) 42 * programming error or unusual condition indication)
43 * are handled as fatal error´s. 43 * are handled as fatal error´s.
44 * 44 *
45 * All other configurations are handled as recoverable errors. 45 * All other configurations are handled as recoverable errors.
46 * 46 *
47 * RETURN VALUES 47 * RETURN VALUES
@@ -93,15 +93,15 @@ dasd_3990_erp_examine_24(struct dasd_ccw_req * cqr, char *sense)
93} /* END dasd_3990_erp_examine_24 */ 93} /* END dasd_3990_erp_examine_24 */
94 94
95/* 95/*
96 * DASD_3990_ERP_EXAMINE_32 96 * DASD_3990_ERP_EXAMINE_32
97 * 97 *
98 * DESCRIPTION 98 * DESCRIPTION
99 * Checks only for fatal/no/recoverable error. 99 * Checks only for fatal/no/recoverable error.
100 * A detailed examination of the sense data is done later outside 100 * A detailed examination of the sense data is done later outside
101 * the interrupt handler. 101 * the interrupt handler.
102 * 102 *
103 * RETURN VALUES 103 * RETURN VALUES
104 * dasd_era_none no error 104 * dasd_era_none no error
105 * dasd_era_fatal for all fatal (unrecoverable errors) 105 * dasd_era_fatal for all fatal (unrecoverable errors)
106 * dasd_era_recover for recoverable others. 106 * dasd_era_recover for recoverable others.
107 */ 107 */
@@ -128,10 +128,10 @@ dasd_3990_erp_examine_32(struct dasd_ccw_req * cqr, char *sense)
128} /* end dasd_3990_erp_examine_32 */ 128} /* end dasd_3990_erp_examine_32 */
129 129
130/* 130/*
131 * DASD_3990_ERP_EXAMINE 131 * DASD_3990_ERP_EXAMINE
132 * 132 *
133 * DESCRIPTION 133 * DESCRIPTION
134 * Checks only for fatal/no/recover error. 134 * Checks only for fatal/no/recover error.
135 * A detailed examination of the sense data is done later outside 135 * A detailed examination of the sense data is done later outside
136 * the interrupt handler. 136 * the interrupt handler.
137 * 137 *
@@ -139,7 +139,7 @@ dasd_3990_erp_examine_32(struct dasd_ccw_req * cqr, char *sense)
139 * 'Chapter 7. Error Recovery Procedures'. 139 * 'Chapter 7. Error Recovery Procedures'.
140 * 140 *
141 * RETURN VALUES 141 * RETURN VALUES
142 * dasd_era_none no error 142 * dasd_era_none no error
143 * dasd_era_fatal for all fatal (unrecoverable errors) 143 * dasd_era_fatal for all fatal (unrecoverable errors)
144 * dasd_era_recover for all others. 144 * dasd_era_recover for all others.
145 */ 145 */
@@ -178,18 +178,18 @@ dasd_3990_erp_examine(struct dasd_ccw_req * cqr, struct irb * irb)
178} /* END dasd_3990_erp_examine */ 178} /* END dasd_3990_erp_examine */
179 179
180/* 180/*
181 ***************************************************************************** 181 *****************************************************************************
182 * SECTION ERP HANDLING 182 * SECTION ERP HANDLING
183 ***************************************************************************** 183 *****************************************************************************
184 */ 184 */
185/* 185/*
186 ***************************************************************************** 186 *****************************************************************************
187 * 24 and 32 byte sense ERP functions 187 * 24 and 32 byte sense ERP functions
188 ***************************************************************************** 188 *****************************************************************************
189 */ 189 */
190 190
191/* 191/*
192 * DASD_3990_ERP_CLEANUP 192 * DASD_3990_ERP_CLEANUP
193 * 193 *
194 * DESCRIPTION 194 * DESCRIPTION
195 * Removes the already build but not necessary ERP request and sets 195 * Removes the already build but not necessary ERP request and sets
@@ -197,10 +197,10 @@ dasd_3990_erp_examine(struct dasd_ccw_req * cqr, struct irb * irb)
197 * 197 *
198 * PARAMETER 198 * PARAMETER
199 * erp request to be blocked 199 * erp request to be blocked
200 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED 200 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
201 * 201 *
202 * RETURN VALUES 202 * RETURN VALUES
203 * cqr original cqr 203 * cqr original cqr
204 */ 204 */
205static struct dasd_ccw_req * 205static struct dasd_ccw_req *
206dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status) 206dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
@@ -214,7 +214,7 @@ dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
214} /* end dasd_3990_erp_cleanup */ 214} /* end dasd_3990_erp_cleanup */
215 215
216/* 216/*
217 * DASD_3990_ERP_BLOCK_QUEUE 217 * DASD_3990_ERP_BLOCK_QUEUE
218 * 218 *
219 * DESCRIPTION 219 * DESCRIPTION
220 * Block the given device request queue to prevent from further 220 * Block the given device request queue to prevent from further
@@ -237,7 +237,7 @@ dasd_3990_erp_block_queue(struct dasd_ccw_req * erp, int expires)
237} 237}
238 238
239/* 239/*
240 * DASD_3990_ERP_INT_REQ 240 * DASD_3990_ERP_INT_REQ
241 * 241 *
242 * DESCRIPTION 242 * DESCRIPTION
243 * Handles 'Intervention Required' error. 243 * Handles 'Intervention Required' error.
@@ -277,7 +277,7 @@ dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
277} /* end dasd_3990_erp_int_req */ 277} /* end dasd_3990_erp_int_req */
278 278
279/* 279/*
280 * DASD_3990_ERP_ALTERNATE_PATH 280 * DASD_3990_ERP_ALTERNATE_PATH
281 * 281 *
282 * DESCRIPTION 282 * DESCRIPTION
283 * Repeat the operation on a different channel path. 283 * Repeat the operation on a different channel path.
@@ -330,15 +330,15 @@ dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
330 * DASD_3990_ERP_DCTL 330 * DASD_3990_ERP_DCTL
331 * 331 *
332 * DESCRIPTION 332 * DESCRIPTION
333 * Setup cqr to do the Diagnostic Control (DCTL) command with an 333 * Setup cqr to do the Diagnostic Control (DCTL) command with an
334 * Inhibit Write subcommand (0x20) and the given modifier. 334 * Inhibit Write subcommand (0x20) and the given modifier.
335 * 335 *
336 * PARAMETER 336 * PARAMETER
337 * erp pointer to the current (failed) ERP 337 * erp pointer to the current (failed) ERP
338 * modifier subcommand modifier 338 * modifier subcommand modifier
339 * 339 *
340 * RETURN VALUES 340 * RETURN VALUES
341 * dctl_cqr pointer to NEW dctl_cqr 341 * dctl_cqr pointer to NEW dctl_cqr
342 * 342 *
343 */ 343 */
344static struct dasd_ccw_req * 344static struct dasd_ccw_req *
@@ -386,7 +386,7 @@ dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
386} /* end dasd_3990_erp_DCTL */ 386} /* end dasd_3990_erp_DCTL */
387 387
388/* 388/*
389 * DASD_3990_ERP_ACTION_1 389 * DASD_3990_ERP_ACTION_1
390 * 390 *
391 * DESCRIPTION 391 * DESCRIPTION
392 * Setup ERP to do the ERP action 1 (see Reference manual). 392 * Setup ERP to do the ERP action 1 (see Reference manual).
@@ -415,7 +415,7 @@ dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
415} /* end dasd_3990_erp_action_1 */ 415} /* end dasd_3990_erp_action_1 */
416 416
417/* 417/*
418 * DASD_3990_ERP_ACTION_4 418 * DASD_3990_ERP_ACTION_4
419 * 419 *
420 * DESCRIPTION 420 * DESCRIPTION
421 * Setup ERP to do the ERP action 4 (see Reference manual). 421 * Setup ERP to do the ERP action 4 (see Reference manual).
@@ -453,11 +453,11 @@ dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
453 453
454 if (sense[25] == 0x1D) { /* state change pending */ 454 if (sense[25] == 0x1D) { /* state change pending */
455 455
456 DEV_MESSAGE(KERN_INFO, device, 456 DEV_MESSAGE(KERN_INFO, device,
457 "waiting for state change pending " 457 "waiting for state change pending "
458 "interrupt, %d retries left", 458 "interrupt, %d retries left",
459 erp->retries); 459 erp->retries);
460 460
461 dasd_3990_erp_block_queue(erp, 30*HZ); 461 dasd_3990_erp_block_queue(erp, 30*HZ);
462 462
463 } else if (sense[25] == 0x1E) { /* busy */ 463 } else if (sense[25] == 0x1E) { /* busy */
@@ -469,9 +469,9 @@ dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
469 } else { 469 } else {
470 470
471 /* no state change pending - retry */ 471 /* no state change pending - retry */
472 DEV_MESSAGE (KERN_INFO, device, 472 DEV_MESSAGE (KERN_INFO, device,
473 "redriving request immediately, " 473 "redriving request immediately, "
474 "%d retries left", 474 "%d retries left",
475 erp->retries); 475 erp->retries);
476 erp->status = DASD_CQR_QUEUED; 476 erp->status = DASD_CQR_QUEUED;
477 } 477 }
@@ -482,13 +482,13 @@ dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
482} /* end dasd_3990_erp_action_4 */ 482} /* end dasd_3990_erp_action_4 */
483 483
484/* 484/*
485 ***************************************************************************** 485 *****************************************************************************
486 * 24 byte sense ERP functions (only) 486 * 24 byte sense ERP functions (only)
487 ***************************************************************************** 487 *****************************************************************************
488 */ 488 */
489 489
490/* 490/*
491 * DASD_3990_ERP_ACTION_5 491 * DASD_3990_ERP_ACTION_5
492 * 492 *
493 * DESCRIPTION 493 * DESCRIPTION
494 * Setup ERP to do the ERP action 5 (see Reference manual). 494 * Setup ERP to do the ERP action 5 (see Reference manual).
@@ -523,7 +523,7 @@ dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
523 * 523 *
524 * PARAMETER 524 * PARAMETER
525 * sense current sense data 525 * sense current sense data
526 * 526 *
527 * RETURN VALUES 527 * RETURN VALUES
528 * void 528 * void
529 */ 529 */
@@ -1150,9 +1150,9 @@ dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
1150 * PARAMETER 1150 * PARAMETER
1151 * erp current erp_head 1151 * erp current erp_head
1152 * sense current sense data 1152 * sense current sense data
1153 * 1153 *
1154 * RETURN VALUES 1154 * RETURN VALUES
1155 * erp 'new' erp_head - pointer to new ERP 1155 * erp 'new' erp_head - pointer to new ERP
1156 */ 1156 */
1157static struct dasd_ccw_req * 1157static struct dasd_ccw_req *
1158dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense) 1158dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
@@ -1185,7 +1185,7 @@ dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1185} /* end dasd_3990_erp_com_rej */ 1185} /* end dasd_3990_erp_com_rej */
1186 1186
1187/* 1187/*
1188 * DASD_3990_ERP_BUS_OUT 1188 * DASD_3990_ERP_BUS_OUT
1189 * 1189 *
1190 * DESCRIPTION 1190 * DESCRIPTION
1191 * Handles 24 byte 'Bus Out Parity Check' error. 1191 * Handles 24 byte 'Bus Out Parity Check' error.
@@ -1483,7 +1483,7 @@ dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1483 * 1483 *
1484 * PARAMETER 1484 * PARAMETER
1485 * erp already added default ERP 1485 * erp already added default ERP
1486 * 1486 *
1487 * RETURN VALUES 1487 * RETURN VALUES
1488 * erp new erp_head - pointer to new ERP 1488 * erp new erp_head - pointer to new ERP
1489 */ 1489 */
@@ -1527,11 +1527,11 @@ dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1527} /* end dasd_3990_erp_file_prot */ 1527} /* end dasd_3990_erp_file_prot */
1528 1528
1529/* 1529/*
1530 * DASD_3990_ERP_INSPECT_24 1530 * DASD_3990_ERP_INSPECT_24
1531 * 1531 *
1532 * DESCRIPTION 1532 * DESCRIPTION
1533 * Does a detailed inspection of the 24 byte sense data 1533 * Does a detailed inspection of the 24 byte sense data
1534 * and sets up a related error recovery action. 1534 * and sets up a related error recovery action.
1535 * 1535 *
1536 * PARAMETER 1536 * PARAMETER
1537 * sense sense data of the actual error 1537 * sense sense data of the actual error
@@ -1602,13 +1602,13 @@ dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1602} /* END dasd_3990_erp_inspect_24 */ 1602} /* END dasd_3990_erp_inspect_24 */
1603 1603
1604/* 1604/*
1605 ***************************************************************************** 1605 *****************************************************************************
1606 * 32 byte sense ERP functions (only) 1606 * 32 byte sense ERP functions (only)
1607 ***************************************************************************** 1607 *****************************************************************************
1608 */ 1608 */
1609 1609
1610/* 1610/*
1611 * DASD_3990_ERPACTION_10_32 1611 * DASD_3990_ERPACTION_10_32
1612 * 1612 *
1613 * DESCRIPTION 1613 * DESCRIPTION
1614 * Handles 32 byte 'Action 10' of Single Program Action Codes. 1614 * Handles 32 byte 'Action 10' of Single Program Action Codes.
@@ -1616,7 +1616,7 @@ dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1616 * 1616 *
1617 * PARAMETER 1617 * PARAMETER
1618 * erp current erp_head 1618 * erp current erp_head
1619 * sense current sense data 1619 * sense current sense data
1620 * RETURN VALUES 1620 * RETURN VALUES
1621 * erp modified erp_head 1621 * erp modified erp_head
1622 */ 1622 */
@@ -1640,18 +1640,18 @@ dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1640 * 1640 *
1641 * DESCRIPTION 1641 * DESCRIPTION
1642 * Handles 32 byte 'Action 1B' of Single Program Action Codes. 1642 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1643 * A write operation could not be finished because of an unexpected 1643 * A write operation could not be finished because of an unexpected
1644 * condition. 1644 * condition.
1645 * The already created 'default erp' is used to get the link to 1645 * The already created 'default erp' is used to get the link to
1646 * the erp chain, but it can not be used for this recovery 1646 * the erp chain, but it can not be used for this recovery
1647 * action because it contains no DE/LO data space. 1647 * action because it contains no DE/LO data space.
1648 * 1648 *
1649 * PARAMETER 1649 * PARAMETER
1650 * default_erp already added default erp. 1650 * default_erp already added default erp.
1651 * sense current sense data 1651 * sense current sense data
1652 * 1652 *
1653 * RETURN VALUES 1653 * RETURN VALUES
1654 * erp new erp or 1654 * erp new erp or
1655 * default_erp in case of imprecise ending or error 1655 * default_erp in case of imprecise ending or error
1656 */ 1656 */
1657static struct dasd_ccw_req * 1657static struct dasd_ccw_req *
@@ -1789,16 +1789,16 @@ dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1789 * DASD_3990_UPDATE_1B 1789 * DASD_3990_UPDATE_1B
1790 * 1790 *
1791 * DESCRIPTION 1791 * DESCRIPTION
1792 * Handles the update to the 32 byte 'Action 1B' of Single Program 1792 * Handles the update to the 32 byte 'Action 1B' of Single Program
1793 * Action Codes in case the first action was not successful. 1793 * Action Codes in case the first action was not successful.
1794 * The already created 'previous_erp' is the currently not successful 1794 * The already created 'previous_erp' is the currently not successful
1795 * ERP. 1795 * ERP.
1796 * 1796 *
1797 * PARAMETER 1797 * PARAMETER
1798 * previous_erp already created previous erp. 1798 * previous_erp already created previous erp.
1799 * sense current sense data 1799 * sense current sense data
1800 * RETURN VALUES 1800 * RETURN VALUES
1801 * erp modified erp 1801 * erp modified erp
1802 */ 1802 */
1803static struct dasd_ccw_req * 1803static struct dasd_ccw_req *
1804dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense) 1804dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
@@ -1897,7 +1897,7 @@ dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1897} /* end dasd_3990_update_1B */ 1897} /* end dasd_3990_update_1B */
1898 1898
1899/* 1899/*
1900 * DASD_3990_ERP_COMPOUND_RETRY 1900 * DASD_3990_ERP_COMPOUND_RETRY
1901 * 1901 *
1902 * DESCRIPTION 1902 * DESCRIPTION
1903 * Handles the compound ERP action retry code. 1903 * Handles the compound ERP action retry code.
@@ -1943,7 +1943,7 @@ dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1943} /* end dasd_3990_erp_compound_retry */ 1943} /* end dasd_3990_erp_compound_retry */
1944 1944
1945/* 1945/*
1946 * DASD_3990_ERP_COMPOUND_PATH 1946 * DASD_3990_ERP_COMPOUND_PATH
1947 * 1947 *
1948 * DESCRIPTION 1948 * DESCRIPTION
1949 * Handles the compound ERP action for retry on alternate 1949 * Handles the compound ERP action for retry on alternate
@@ -1965,7 +1965,7 @@ dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1965 dasd_3990_erp_alternate_path(erp); 1965 dasd_3990_erp_alternate_path(erp);
1966 1966
1967 if (erp->status == DASD_CQR_FAILED) { 1967 if (erp->status == DASD_CQR_FAILED) {
1968 /* reset the lpm and the status to be able to 1968 /* reset the lpm and the status to be able to
1969 * try further actions. */ 1969 * try further actions. */
1970 1970
1971 erp->lpm = 0; 1971 erp->lpm = 0;
@@ -1980,7 +1980,7 @@ dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1980} /* end dasd_3990_erp_compound_path */ 1980} /* end dasd_3990_erp_compound_path */
1981 1981
1982/* 1982/*
1983 * DASD_3990_ERP_COMPOUND_CODE 1983 * DASD_3990_ERP_COMPOUND_CODE
1984 * 1984 *
1985 * DESCRIPTION 1985 * DESCRIPTION
1986 * Handles the compound ERP action for retry code. 1986 * Handles the compound ERP action for retry code.
@@ -2001,18 +2001,18 @@ dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
2001 2001
2002 switch (sense[28]) { 2002 switch (sense[28]) {
2003 case 0x17: 2003 case 0x17:
2004 /* issue a Diagnostic Control command with an 2004 /* issue a Diagnostic Control command with an
2005 * Inhibit Write subcommand and controler modifier */ 2005 * Inhibit Write subcommand and controler modifier */
2006 erp = dasd_3990_erp_DCTL(erp, 0x20); 2006 erp = dasd_3990_erp_DCTL(erp, 0x20);
2007 break; 2007 break;
2008 2008
2009 case 0x25: 2009 case 0x25:
2010 /* wait for 5 seconds and retry again */ 2010 /* wait for 5 seconds and retry again */
2011 erp->retries = 1; 2011 erp->retries = 1;
2012 2012
2013 dasd_3990_erp_block_queue (erp, 5*HZ); 2013 dasd_3990_erp_block_queue (erp, 5*HZ);
2014 break; 2014 break;
2015 2015
2016 default: 2016 default:
2017 /* should not happen - continue */ 2017 /* should not happen - continue */
2018 break; 2018 break;
@@ -2026,7 +2026,7 @@ dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
2026} /* end dasd_3990_erp_compound_code */ 2026} /* end dasd_3990_erp_compound_code */
2027 2027
2028/* 2028/*
2029 * DASD_3990_ERP_COMPOUND_CONFIG 2029 * DASD_3990_ERP_COMPOUND_CONFIG
2030 * 2030 *
2031 * DESCRIPTION 2031 * DESCRIPTION
2032 * Handles the compound ERP action for configruation 2032 * Handles the compound ERP action for configruation
@@ -2063,10 +2063,10 @@ dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2063} /* end dasd_3990_erp_compound_config */ 2063} /* end dasd_3990_erp_compound_config */
2064 2064
2065/* 2065/*
2066 * DASD_3990_ERP_COMPOUND 2066 * DASD_3990_ERP_COMPOUND
2067 * 2067 *
2068 * DESCRIPTION 2068 * DESCRIPTION
2069 * Does the further compound program action if 2069 * Does the further compound program action if
2070 * compound retry was not successful. 2070 * compound retry was not successful.
2071 * 2071 *
2072 * PARAMETER 2072 * PARAMETER
@@ -2110,11 +2110,11 @@ dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2110} /* end dasd_3990_erp_compound */ 2110} /* end dasd_3990_erp_compound */
2111 2111
2112/* 2112/*
2113 * DASD_3990_ERP_INSPECT_32 2113 * DASD_3990_ERP_INSPECT_32
2114 * 2114 *
2115 * DESCRIPTION 2115 * DESCRIPTION
2116 * Does a detailed inspection of the 32 byte sense data 2116 * Does a detailed inspection of the 32 byte sense data
2117 * and sets up a related error recovery action. 2117 * and sets up a related error recovery action.
2118 * 2118 *
2119 * PARAMETER 2119 * PARAMETER
2120 * sense sense data of the actual error 2120 * sense sense data of the actual error
@@ -2228,9 +2228,9 @@ dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2228} /* end dasd_3990_erp_inspect_32 */ 2228} /* end dasd_3990_erp_inspect_32 */
2229 2229
2230/* 2230/*
2231 ***************************************************************************** 2231 *****************************************************************************
2232 * main ERP control fuctions (24 and 32 byte sense) 2232 * main ERP control fuctions (24 and 32 byte sense)
2233 ***************************************************************************** 2233 *****************************************************************************
2234 */ 2234 */
2235 2235
2236/* 2236/*
@@ -2243,7 +2243,7 @@ dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2243 * PARAMETER 2243 * PARAMETER
2244 * erp pointer to the currently created default ERP 2244 * erp pointer to the currently created default ERP
2245 * RETURN VALUES 2245 * RETURN VALUES
2246 * erp_new contens was possibly modified 2246 * erp_new contens was possibly modified
2247 */ 2247 */
2248static struct dasd_ccw_req * 2248static struct dasd_ccw_req *
2249dasd_3990_erp_inspect(struct dasd_ccw_req * erp) 2249dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
@@ -2272,14 +2272,14 @@ dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
2272 2272
2273/* 2273/*
2274 * DASD_3990_ERP_ADD_ERP 2274 * DASD_3990_ERP_ADD_ERP
2275 * 2275 *
2276 * DESCRIPTION 2276 * DESCRIPTION
2277 * This funtion adds an additional request block (ERP) to the head of 2277 * This funtion adds an additional request block (ERP) to the head of
2278 * the given cqr (or erp). 2278 * the given cqr (or erp).
2279 * This erp is initialized as an default erp (retry TIC) 2279 * This erp is initialized as an default erp (retry TIC)
2280 * 2280 *
2281 * PARAMETER 2281 * PARAMETER
2282 * cqr head of the current ERP-chain (or single cqr if 2282 * cqr head of the current ERP-chain (or single cqr if
2283 * first error) 2283 * first error)
2284 * RETURN VALUES 2284 * RETURN VALUES
2285 * erp pointer to new ERP-chain head 2285 * erp pointer to new ERP-chain head
@@ -2332,15 +2332,15 @@ dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)
2332} 2332}
2333 2333
2334/* 2334/*
2335 * DASD_3990_ERP_ADDITIONAL_ERP 2335 * DASD_3990_ERP_ADDITIONAL_ERP
2336 * 2336 *
2337 * DESCRIPTION 2337 * DESCRIPTION
2338 * An additional ERP is needed to handle the current error. 2338 * An additional ERP is needed to handle the current error.
2339 * Add ERP to the head of the ERP-chain containing the ERP processing 2339 * Add ERP to the head of the ERP-chain containing the ERP processing
2340 * determined based on the sense data. 2340 * determined based on the sense data.
2341 * 2341 *
2342 * PARAMETER 2342 * PARAMETER
2343 * cqr head of the current ERP-chain (or single cqr if 2343 * cqr head of the current ERP-chain (or single cqr if
2344 * first error) 2344 * first error)
2345 * 2345 *
2346 * RETURN VALUES 2346 * RETURN VALUES
@@ -2376,7 +2376,7 @@ dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2376 * 24 byte sense byte 25 and 27 is set as well. 2376 * 24 byte sense byte 25 and 27 is set as well.
2377 * 2377 *
2378 * PARAMETER 2378 * PARAMETER
2379 * cqr1 first cqr, which will be compared with the 2379 * cqr1 first cqr, which will be compared with the
2380 * cqr2 second cqr. 2380 * cqr2 second cqr.
2381 * 2381 *
2382 * RETURN VALUES 2382 * RETURN VALUES
@@ -2415,7 +2415,7 @@ dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, struct dasd_ccw_req *cqr2)
2415 * cqr failed cqr (either original cqr or already an erp) 2415 * cqr failed cqr (either original cqr or already an erp)
2416 * 2416 *
2417 * RETURN VALUES 2417 * RETURN VALUES
2418 * erp erp-pointer to the already defined error 2418 * erp erp-pointer to the already defined error
2419 * recovery procedure OR 2419 * recovery procedure OR
2420 * NULL if a 'new' error occurred. 2420 * NULL if a 'new' error occurred.
2421 */ 2421 */
@@ -2451,10 +2451,10 @@ dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2451 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense) 2451 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2452 * 2452 *
2453 * DESCRIPTION 2453 * DESCRIPTION
2454 * No retry is left for the current ERP. Check what has to be done 2454 * No retry is left for the current ERP. Check what has to be done
2455 * with the ERP. 2455 * with the ERP.
2456 * - do further defined ERP action or 2456 * - do further defined ERP action or
2457 * - wait for interrupt or 2457 * - wait for interrupt or
2458 * - exit with permanent error 2458 * - exit with permanent error
2459 * 2459 *
2460 * PARAMETER 2460 * PARAMETER
@@ -2485,7 +2485,7 @@ dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2485 2485
2486 if (!(sense[2] & DASD_SENSE_BIT_0)) { 2486 if (!(sense[2] & DASD_SENSE_BIT_0)) {
2487 2487
2488 /* issue a Diagnostic Control command with an 2488 /* issue a Diagnostic Control command with an
2489 * Inhibit Write subcommand */ 2489 * Inhibit Write subcommand */
2490 2490
2491 switch (sense[25]) { 2491 switch (sense[25]) {
@@ -2535,14 +2535,14 @@ dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2535} /* end dasd_3990_erp_further_erp */ 2535} /* end dasd_3990_erp_further_erp */
2536 2536
2537/* 2537/*
2538 * DASD_3990_ERP_HANDLE_MATCH_ERP 2538 * DASD_3990_ERP_HANDLE_MATCH_ERP
2539 * 2539 *
2540 * DESCRIPTION 2540 * DESCRIPTION
2541 * An error occurred again and an ERP has been detected which is already 2541 * An error occurred again and an ERP has been detected which is already
2542 * used to handle this error (e.g. retries). 2542 * used to handle this error (e.g. retries).
2543 * All prior ERP's are asumed to be successful and therefore removed 2543 * All prior ERP's are asumed to be successful and therefore removed
2544 * from queue. 2544 * from queue.
2545 * If retry counter of matching erp is already 0, it is checked if further 2545 * If retry counter of matching erp is already 0, it is checked if further
2546 * action is needed (besides retry) or if the ERP has failed. 2546 * action is needed (besides retry) or if the ERP has failed.
2547 * 2547 *
2548 * PARAMETER 2548 * PARAMETER
@@ -2631,7 +2631,7 @@ dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2631 * erp erp-pointer to the head of the ERP action chain. 2631 * erp erp-pointer to the head of the ERP action chain.
2632 * This means: 2632 * This means:
2633 * - either a ptr to an additional ERP cqr or 2633 * - either a ptr to an additional ERP cqr or
2634 * - the original given cqr (which's status might 2634 * - the original given cqr (which's status might
2635 * be modified) 2635 * be modified)
2636 */ 2636 */
2637struct dasd_ccw_req * 2637struct dasd_ccw_req *
@@ -2723,22 +2723,3 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2723 return erp; 2723 return erp;
2724 2724
2725} /* end dasd_3990_erp_action */ 2725} /* end dasd_3990_erp_action */
2726
2727/*
2728 * Overrides for Emacs so that we follow Linus's tabbing style.
2729 * Emacs will notice this stuff at the end of the file and automatically
2730 * adjust the settings for this buffer only. This must remain at the end
2731 * of the file.
2732 * ---------------------------------------------------------------------------
2733 * Local variables:
2734 * c-indent-level: 4
2735 * c-brace-imaginary-offset: 0
2736 * c-brace-offset: -4
2737 * c-argdecl-indent: 4
2738 * c-label-offset: -4
2739 * c-continued-statement-offset: 4
2740 * c-continued-brace-offset: 0
2741 * indent-tabs-mode: 1
2742 * tab-width: 8
2743 * End:
2744 */
diff --git a/drivers/s390/block/dasd_9336_erp.c b/drivers/s390/block/dasd_9336_erp.c
index dc861446d056..6e082688475a 100644
--- a/drivers/s390/block/dasd_9336_erp.c
+++ b/drivers/s390/block/dasd_9336_erp.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_9336_erp.c 2 * File...........: linux/drivers/s390/block/dasd_9336_erp.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
@@ -12,10 +12,10 @@
12 12
13 13
14/* 14/*
15 * DASD_9336_ERP_EXAMINE 15 * DASD_9336_ERP_EXAMINE
16 * 16 *
17 * DESCRIPTION 17 * DESCRIPTION
18 * Checks only for fatal/no/recover error. 18 * Checks only for fatal/no/recover error.
19 * A detailed examination of the sense data is done later outside 19 * A detailed examination of the sense data is done later outside
20 * the interrupt handler. 20 * the interrupt handler.
21 * 21 *
@@ -23,7 +23,7 @@
23 * 'Chapter 7. 9336 Sense Data'. 23 * 'Chapter 7. 9336 Sense Data'.
24 * 24 *
25 * RETURN VALUES 25 * RETURN VALUES
26 * dasd_era_none no error 26 * dasd_era_none no error
27 * dasd_era_fatal for all fatal (unrecoverable errors) 27 * dasd_era_fatal for all fatal (unrecoverable errors)
28 * dasd_era_recover for all others. 28 * dasd_era_recover for all others.
29 */ 29 */
@@ -39,22 +39,3 @@ dasd_9336_erp_examine(struct dasd_ccw_req * cqr, struct irb * irb)
39 return dasd_era_recover; 39 return dasd_era_recover;
40 40
41} /* END dasd_9336_erp_examine */ 41} /* END dasd_9336_erp_examine */
42
43/*
44 * Overrides for Emacs so that we follow Linus's tabbing style.
45 * Emacs will notice this stuff at the end of the file and automatically
46 * adjust the settings for this buffer only. This must remain at the end
47 * of the file.
48 * ---------------------------------------------------------------------------
49 * Local variables:
50 * c-indent-level: 4
51 * c-brace-imaginary-offset: 0
52 * c-brace-offset: -4
53 * c-argdecl-indent: 4
54 * c-label-offset: -4
55 * c-continued-statement-offset: 4
56 * c-continued-brace-offset: 0
57 * indent-tabs-mode: 1
58 * tab-width: 8
59 * End:
60 */
diff --git a/drivers/s390/block/dasd_9343_erp.c b/drivers/s390/block/dasd_9343_erp.c
index 4a5b79569aaa..ddecb9808ed4 100644
--- a/drivers/s390/block/dasd_9343_erp.c
+++ b/drivers/s390/block/dasd_9343_erp.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_9345_erp.c 2 * File...........: linux/drivers/s390/block/dasd_9345_erp.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 216bc4fba199..9e9ae7179602 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -27,7 +27,7 @@
27#include "dasd_int.h" 27#include "dasd_int.h"
28 28
29kmem_cache_t *dasd_page_cache; 29kmem_cache_t *dasd_page_cache;
30EXPORT_SYMBOL(dasd_page_cache); 30EXPORT_SYMBOL_GPL(dasd_page_cache);
31 31
32/* 32/*
33 * dasd_devmap_t is used to store the features and the relation 33 * dasd_devmap_t is used to store the features and the relation
@@ -49,6 +49,20 @@ struct dasd_devmap {
49}; 49};
50 50
51/* 51/*
52 * dasd_servermap is used to store the server_id of all storage servers
53 * accessed by DASD device driver.
54 */
55struct dasd_servermap {
56 struct list_head list;
57 struct server_id {
58 char vendor[4];
59 char serial[15];
60 } sid;
61};
62
63static struct list_head dasd_serverlist;
64
65/*
52 * Parameter parsing functions for dasd= parameter. The syntax is: 66 * Parameter parsing functions for dasd= parameter. The syntax is:
53 * <devno> : (0x)?[0-9a-fA-F]+ 67 * <devno> : (0x)?[0-9a-fA-F]+
54 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+ 68 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
@@ -64,6 +78,8 @@ struct dasd_devmap {
64 78
65int dasd_probeonly = 0; /* is true, when probeonly mode is active */ 79int dasd_probeonly = 0; /* is true, when probeonly mode is active */
66int dasd_autodetect = 0; /* is true, when autodetection is active */ 80int dasd_autodetect = 0; /* is true, when autodetection is active */
81int dasd_nopav = 0; /* is true, when PAV is disabled */
82EXPORT_SYMBOL_GPL(dasd_nopav);
67 83
68/* 84/*
69 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement 85 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
@@ -123,7 +139,7 @@ static inline int
123dasd_busid(char **str, int *id0, int *id1, int *devno) 139dasd_busid(char **str, int *id0, int *id1, int *devno)
124{ 140{
125 int val, old_style; 141 int val, old_style;
126 142
127 /* check for leading '0x' */ 143 /* check for leading '0x' */
128 old_style = 0; 144 old_style = 0;
129 if ((*str)[0] == '0' && (*str)[1] == 'x') { 145 if ((*str)[0] == '0' && (*str)[1] == 'x') {
@@ -179,7 +195,7 @@ dasd_feature_list(char *str, char **endp)
179 features = 0; 195 features = 0;
180 196
181 while (1) { 197 while (1) {
182 for (len = 0; 198 for (len = 0;
183 str[len] && str[len] != ':' && str[len] != ')'; len++); 199 str[len] && str[len] != ':' && str[len] != ')'; len++);
184 if (len == 2 && !strncmp(str, "ro", 2)) 200 if (len == 2 && !strncmp(str, "ro", 2))
185 features |= DASD_FEATURE_READONLY; 201 features |= DASD_FEATURE_READONLY;
@@ -228,19 +244,24 @@ dasd_parse_keyword( char *parsestring ) {
228 length = strlen(parsestring); 244 length = strlen(parsestring);
229 residual_str = parsestring + length; 245 residual_str = parsestring + length;
230 } 246 }
231 if (strncmp ("autodetect", parsestring, length) == 0) { 247 if (strncmp("autodetect", parsestring, length) == 0) {
232 dasd_autodetect = 1; 248 dasd_autodetect = 1;
233 MESSAGE (KERN_INFO, "%s", 249 MESSAGE (KERN_INFO, "%s",
234 "turning to autodetection mode"); 250 "turning to autodetection mode");
235 return residual_str; 251 return residual_str;
236 } 252 }
237 if (strncmp ("probeonly", parsestring, length) == 0) { 253 if (strncmp("probeonly", parsestring, length) == 0) {
238 dasd_probeonly = 1; 254 dasd_probeonly = 1;
239 MESSAGE(KERN_INFO, "%s", 255 MESSAGE(KERN_INFO, "%s",
240 "turning to probeonly mode"); 256 "turning to probeonly mode");
241 return residual_str; 257 return residual_str;
242 } 258 }
243 if (strncmp ("fixedbuffers", parsestring, length) == 0) { 259 if (strncmp("nopav", parsestring, length) == 0) {
260 dasd_nopav = 1;
261 MESSAGE(KERN_INFO, "%s", "disable PAV mode");
262 return residual_str;
263 }
264 if (strncmp("fixedbuffers", parsestring, length) == 0) {
244 if (dasd_page_cache) 265 if (dasd_page_cache)
245 return residual_str; 266 return residual_str;
246 dasd_page_cache = 267 dasd_page_cache =
@@ -294,6 +315,8 @@ dasd_parse_range( char *parsestring ) {
294 features = dasd_feature_list(str, &str); 315 features = dasd_feature_list(str, &str);
295 if (features < 0) 316 if (features < 0)
296 return ERR_PTR(-EINVAL); 317 return ERR_PTR(-EINVAL);
318 /* each device in dasd= parameter should be set initially online */
319 features |= DASD_FEATURE_INITIAL_ONLINE;
297 while (from <= to) { 320 while (from <= to) {
298 sprintf(bus_id, "%01x.%01x.%04x", 321 sprintf(bus_id, "%01x.%01x.%04x",
299 from_id0, from_id1, from++); 322 from_id0, from_id1, from++);
@@ -359,7 +382,7 @@ dasd_parse(void)
359 * Add a devmap for the device specified by busid. It is possible that 382 * Add a devmap for the device specified by busid. It is possible that
360 * the devmap already exists (dasd= parameter). The order of the devices 383 * the devmap already exists (dasd= parameter). The order of the devices
361 * added through this function will define the kdevs for the individual 384 * added through this function will define the kdevs for the individual
362 * devices. 385 * devices.
363 */ 386 */
364static struct dasd_devmap * 387static struct dasd_devmap *
365dasd_add_busid(char *bus_id, int features) 388dasd_add_busid(char *bus_id, int features)
@@ -368,7 +391,7 @@ dasd_add_busid(char *bus_id, int features)
368 int hash; 391 int hash;
369 392
370 new = (struct dasd_devmap *) 393 new = (struct dasd_devmap *)
371 kmalloc(sizeof(struct dasd_devmap), GFP_KERNEL); 394 kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
372 if (!new) 395 if (!new)
373 return ERR_PTR(-ENOMEM); 396 return ERR_PTR(-ENOMEM);
374 spin_lock(&dasd_devmap_lock); 397 spin_lock(&dasd_devmap_lock);
@@ -630,7 +653,8 @@ dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
630} 653}
631 654
632static ssize_t 655static ssize_t
633dasd_ro_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 656dasd_ro_store(struct device *dev, struct device_attribute *attr,
657 const char *buf, size_t count)
634{ 658{
635 struct dasd_devmap *devmap; 659 struct dasd_devmap *devmap;
636 int ro_flag; 660 int ro_flag;
@@ -658,7 +682,7 @@ static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
658 * use_diag controls whether the driver should use diag rather than ssch 682 * use_diag controls whether the driver should use diag rather than ssch
659 * to talk to the device 683 * to talk to the device
660 */ 684 */
661static ssize_t 685static ssize_t
662dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf) 686dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
663{ 687{
664 struct dasd_devmap *devmap; 688 struct dasd_devmap *devmap;
@@ -673,7 +697,8 @@ dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
673} 697}
674 698
675static ssize_t 699static ssize_t
676dasd_use_diag_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 700dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
701 const char *buf, size_t count)
677{ 702{
678 struct dasd_devmap *devmap; 703 struct dasd_devmap *devmap;
679 ssize_t rc; 704 ssize_t rc;
@@ -697,11 +722,11 @@ dasd_use_diag_store(struct device *dev, struct device_attribute *attr, const cha
697 return rc; 722 return rc;
698} 723}
699 724
700static 725static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
701DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
702 726
703static ssize_t 727static ssize_t
704dasd_discipline_show(struct device *dev, struct device_attribute *attr, char *buf) 728dasd_discipline_show(struct device *dev, struct device_attribute *attr,
729 char *buf)
705{ 730{
706 struct dasd_devmap *devmap; 731 struct dasd_devmap *devmap;
707 char *dname; 732 char *dname;
@@ -834,6 +859,38 @@ static struct attribute_group dasd_attr_group = {
834 .attrs = dasd_attrs, 859 .attrs = dasd_attrs,
835}; 860};
836 861
862/*
863 * Check if the related storage server is already contained in the
864 * dasd_serverlist. If server is not contained, create new entry.
865 * Return 0 if server was already in serverlist,
866 * 1 if the server was added successfully
867 * <0 in case of error.
868 */
869static int
870dasd_add_server(struct dasd_uid *uid)
871{
872 struct dasd_servermap *new, *tmp;
873
874 /* check if server is already contained */
875 list_for_each_entry(tmp, &dasd_serverlist, list)
876 // normale cmp?
877 if (strncmp(tmp->sid.vendor, uid->vendor,
878 sizeof(tmp->sid.vendor)) == 0
879 && strncmp(tmp->sid.serial, uid->serial,
880 sizeof(tmp->sid.serial)) == 0)
881 return 0;
882
883 new = (struct dasd_servermap *)
884 kzalloc(sizeof(struct dasd_servermap), GFP_KERNEL);
885 if (!new)
886 return -ENOMEM;
887
888 strncpy(new->sid.vendor, uid->vendor, sizeof(new->sid.vendor));
889 strncpy(new->sid.serial, uid->serial, sizeof(new->sid.serial));
890 list_add(&new->list, &dasd_serverlist);
891 return 1;
892}
893
837 894
838/* 895/*
839 * Return copy of the device unique identifier. 896 * Return copy of the device unique identifier.
@@ -854,21 +911,26 @@ dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid)
854 911
855/* 912/*
856 * Register the given device unique identifier into devmap struct. 913 * Register the given device unique identifier into devmap struct.
914 * Return 0 if server was already in serverlist,
915 * 1 if the server was added successful
916 * <0 in case of error.
857 */ 917 */
858int 918int
859dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid) 919dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid)
860{ 920{
861 struct dasd_devmap *devmap; 921 struct dasd_devmap *devmap;
922 int rc;
862 923
863 devmap = dasd_find_busid(cdev->dev.bus_id); 924 devmap = dasd_find_busid(cdev->dev.bus_id);
864 if (IS_ERR(devmap)) 925 if (IS_ERR(devmap))
865 return PTR_ERR(devmap); 926 return PTR_ERR(devmap);
866 spin_lock(&dasd_devmap_lock); 927 spin_lock(&dasd_devmap_lock);
867 devmap->uid = *uid; 928 devmap->uid = *uid;
929 rc = dasd_add_server(uid);
868 spin_unlock(&dasd_devmap_lock); 930 spin_unlock(&dasd_devmap_lock);
869 return 0; 931 return rc;
870} 932}
871EXPORT_SYMBOL(dasd_set_uid); 933EXPORT_SYMBOL_GPL(dasd_set_uid);
872 934
873/* 935/*
874 * Return value of the specified feature. 936 * Return value of the specified feature.
@@ -880,7 +942,7 @@ dasd_get_feature(struct ccw_device *cdev, int feature)
880 942
881 devmap = dasd_find_busid(cdev->dev.bus_id); 943 devmap = dasd_find_busid(cdev->dev.bus_id);
882 if (IS_ERR(devmap)) 944 if (IS_ERR(devmap))
883 return (int) PTR_ERR(devmap); 945 return PTR_ERR(devmap);
884 946
885 return ((devmap->features & feature) != 0); 947 return ((devmap->features & feature) != 0);
886} 948}
@@ -896,7 +958,7 @@ dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
896 958
897 devmap = dasd_find_busid(cdev->dev.bus_id); 959 devmap = dasd_find_busid(cdev->dev.bus_id);
898 if (IS_ERR(devmap)) 960 if (IS_ERR(devmap))
899 return (int) PTR_ERR(devmap); 961 return PTR_ERR(devmap);
900 962
901 spin_lock(&dasd_devmap_lock); 963 spin_lock(&dasd_devmap_lock);
902 if (flag) 964 if (flag)
@@ -932,8 +994,10 @@ dasd_devmap_init(void)
932 dasd_max_devindex = 0; 994 dasd_max_devindex = 0;
933 for (i = 0; i < 256; i++) 995 for (i = 0; i < 256; i++)
934 INIT_LIST_HEAD(&dasd_hashlists[i]); 996 INIT_LIST_HEAD(&dasd_hashlists[i]);
935 return 0;
936 997
998 /* Initialize servermap structure. */
999 INIT_LIST_HEAD(&dasd_serverlist);
1000 return 0;
937} 1001}
938 1002
939void 1003void
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index 3f9d704d2657..4002f6c1c1b3 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_diag.c 2 * File...........: linux/drivers/s390/block/dasd_diag.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Based on.......: linux/drivers/s390/block/mdisk.c 4 * Based on.......: linux/drivers/s390/block/mdisk.c
@@ -336,7 +336,7 @@ dasd_diag_check_device(struct dasd_device *device)
336 336
337 private = (struct dasd_diag_private *) device->private; 337 private = (struct dasd_diag_private *) device->private;
338 if (private == NULL) { 338 if (private == NULL) {
339 private = kmalloc(sizeof(struct dasd_diag_private),GFP_KERNEL); 339 private = kzalloc(sizeof(struct dasd_diag_private),GFP_KERNEL);
340 if (private == NULL) { 340 if (private == NULL) {
341 DEV_MESSAGE(KERN_WARNING, device, "%s", 341 DEV_MESSAGE(KERN_WARNING, device, "%s",
342 "memory allocation failed for private data"); 342 "memory allocation failed for private data");
@@ -527,7 +527,7 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
527 datasize, device); 527 datasize, device);
528 if (IS_ERR(cqr)) 528 if (IS_ERR(cqr))
529 return cqr; 529 return cqr;
530 530
531 dreq = (struct dasd_diag_req *) cqr->data; 531 dreq = (struct dasd_diag_req *) cqr->data;
532 dreq->block_count = count; 532 dreq->block_count = count;
533 dbio = dreq->bio; 533 dbio = dreq->bio;
diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h
index 38a4e55f8953..b8c78267ff3e 100644
--- a/drivers/s390/block/dasd_diag.h
+++ b/drivers/s390/block/dasd_diag.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_diag.h 2 * File...........: linux/drivers/s390/block/dasd_diag.h
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Based on.......: linux/drivers/s390/block/mdisk.h 4 * Based on.......: linux/drivers/s390/block/mdisk.h
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 7d5a6cee4bd8..0dfab30e8089 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_eckd.c 2 * File...........: linux/drivers/s390/block/dasd_eckd.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com> 4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Carsten Otte <Cotte@de.ibm.com> 5 * Carsten Otte <Cotte@de.ibm.com>
6 * Martin Schwidefsky <schwidefsky@de.ibm.com> 6 * Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
@@ -24,6 +24,7 @@
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/todclk.h> 25#include <asm/todclk.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <asm/cio.h>
27#include <asm/ccwdev.h> 28#include <asm/ccwdev.h>
28 29
29#include "dasd_int.h" 30#include "dasd_int.h"
@@ -89,17 +90,22 @@ dasd_eckd_probe (struct ccw_device *cdev)
89{ 90{
90 int ret; 91 int ret;
91 92
92 ret = dasd_generic_probe (cdev, &dasd_eckd_discipline); 93 /* set ECKD specific ccw-device options */
93 if (ret) 94 ret = ccw_device_set_options(cdev, CCWDEV_ALLOW_FORCE);
95 if (ret) {
96 printk(KERN_WARNING
97 "dasd_eckd_probe: could not set ccw-device options "
98 "for %s\n", cdev->dev.bus_id);
94 return ret; 99 return ret;
95 ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP | CCWDEV_ALLOW_FORCE); 100 }
96 return 0; 101 ret = dasd_generic_probe(cdev, &dasd_eckd_discipline);
102 return ret;
97} 103}
98 104
99static int 105static int
100dasd_eckd_set_online(struct ccw_device *cdev) 106dasd_eckd_set_online(struct ccw_device *cdev)
101{ 107{
102 return dasd_generic_set_online (cdev, &dasd_eckd_discipline); 108 return dasd_generic_set_online(cdev, &dasd_eckd_discipline);
103} 109}
104 110
105static struct ccw_driver dasd_eckd_driver = { 111static struct ccw_driver dasd_eckd_driver = {
@@ -210,14 +216,14 @@ check_XRC (struct ccw1 *de_ccw,
210 216
211 /* switch on System Time Stamp - needed for XRC Support */ 217 /* switch on System Time Stamp - needed for XRC Support */
212 if (private->rdc_data.facilities.XRC_supported) { 218 if (private->rdc_data.facilities.XRC_supported) {
213 219
214 data->ga_extended |= 0x08; /* switch on 'Time Stamp Valid' */ 220 data->ga_extended |= 0x08; /* switch on 'Time Stamp Valid' */
215 data->ga_extended |= 0x02; /* switch on 'Extended Parameter' */ 221 data->ga_extended |= 0x02; /* switch on 'Extended Parameter' */
216 222
217 data->ep_sys_time = get_clock (); 223 data->ep_sys_time = get_clock ();
218 224
219 de_ccw->count = sizeof (struct DE_eckd_data); 225 de_ccw->count = sizeof (struct DE_eckd_data);
220 de_ccw->flags |= CCW_FLAG_SLI; 226 de_ccw->flags |= CCW_FLAG_SLI;
221 } 227 }
222 228
223 return; 229 return;
@@ -296,8 +302,8 @@ define_extent(struct ccw1 * ccw, struct DE_eckd_data * data, int trk,
296 /* check for sequential prestage - enhance cylinder range */ 302 /* check for sequential prestage - enhance cylinder range */
297 if (data->attributes.operation == DASD_SEQ_PRESTAGE || 303 if (data->attributes.operation == DASD_SEQ_PRESTAGE ||
298 data->attributes.operation == DASD_SEQ_ACCESS) { 304 data->attributes.operation == DASD_SEQ_ACCESS) {
299 305
300 if (end.cyl + private->attrib.nr_cyl < geo.cyl) 306 if (end.cyl + private->attrib.nr_cyl < geo.cyl)
301 end.cyl += private->attrib.nr_cyl; 307 end.cyl += private->attrib.nr_cyl;
302 else 308 else
303 end.cyl = (geo.cyl - 1); 309 end.cyl = (geo.cyl - 1);
@@ -317,7 +323,7 @@ locate_record(struct ccw1 *ccw, struct LO_eckd_data *data, int trk,
317 struct dasd_eckd_private *private; 323 struct dasd_eckd_private *private;
318 int sector; 324 int sector;
319 int dn, d; 325 int dn, d;
320 326
321 private = (struct dasd_eckd_private *) device->private; 327 private = (struct dasd_eckd_private *) device->private;
322 328
323 DBF_DEV_EVENT(DBF_INFO, device, 329 DBF_DEV_EVENT(DBF_INFO, device,
@@ -541,6 +547,86 @@ dasd_eckd_read_conf(struct dasd_device *device)
541} 547}
542 548
543/* 549/*
550 * Build CP for Perform Subsystem Function - SSC.
551 */
552struct dasd_ccw_req *
553dasd_eckd_build_psf_ssc(struct dasd_device *device)
554{
555 struct dasd_ccw_req *cqr;
556 struct dasd_psf_ssc_data *psf_ssc_data;
557 struct ccw1 *ccw;
558
559 cqr = dasd_smalloc_request("ECKD", 1 /* PSF */ ,
560 sizeof(struct dasd_psf_ssc_data),
561 device);
562
563 if (IS_ERR(cqr)) {
564 DEV_MESSAGE(KERN_WARNING, device, "%s",
565 "Could not allocate PSF-SSC request");
566 return cqr;
567 }
568 psf_ssc_data = (struct dasd_psf_ssc_data *)cqr->data;
569 psf_ssc_data->order = PSF_ORDER_SSC;
570 psf_ssc_data->suborder = 0x08;
571
572 ccw = cqr->cpaddr;
573 ccw->cmd_code = DASD_ECKD_CCW_PSF;
574 ccw->cda = (__u32)(addr_t)psf_ssc_data;
575 ccw->count = 66;
576
577 cqr->device = device;
578 cqr->expires = 10*HZ;
579 cqr->buildclk = get_clock();
580 cqr->status = DASD_CQR_FILLED;
581 return cqr;
582}
583
584/*
585 * Perform Subsystem Function.
586 * It is necessary to trigger CIO for channel revalidation since this
587 * call might change behaviour of DASD devices.
588 */
589static int
590dasd_eckd_psf_ssc(struct dasd_device *device)
591{
592 struct dasd_ccw_req *cqr;
593 int rc;
594
595 cqr = dasd_eckd_build_psf_ssc(device);
596 if (IS_ERR(cqr))
597 return PTR_ERR(cqr);
598
599 rc = dasd_sleep_on(cqr);
600 if (!rc)
601 /* trigger CIO to reprobe devices */
602 css_schedule_reprobe();
603 dasd_sfree_request(cqr, cqr->device);
604 return rc;
605}
606
607/*
608 * Valide storage server of current device.
609 */
610static int
611dasd_eckd_validate_server(struct dasd_device *device)
612{
613 int rc;
614
615 /* Currently PAV is the only reason to 'validate' server on LPAR */
616 if (dasd_nopav || MACHINE_IS_VM)
617 return 0;
618
619 rc = dasd_eckd_psf_ssc(device);
620 if (rc)
621 /* may be requested feature is not available on server,
622 * therefore just report error and go ahead */
623 DEV_MESSAGE(KERN_INFO, device,
624 "Perform Subsystem Function returned rc=%d", rc);
625 /* RE-Read Configuration Data */
626 return dasd_eckd_read_conf(device);
627}
628
629/*
544 * Check device characteristics. 630 * Check device characteristics.
545 * If the device is accessible using ECKD discipline, the device is enabled. 631 * If the device is accessible using ECKD discipline, the device is enabled.
546 */ 632 */
@@ -554,7 +640,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
554 640
555 private = (struct dasd_eckd_private *) device->private; 641 private = (struct dasd_eckd_private *) device->private;
556 if (private == NULL) { 642 if (private == NULL) {
557 private = kmalloc(sizeof(struct dasd_eckd_private), 643 private = kzalloc(sizeof(struct dasd_eckd_private),
558 GFP_KERNEL | GFP_DMA); 644 GFP_KERNEL | GFP_DMA);
559 if (private == NULL) { 645 if (private == NULL) {
560 DEV_MESSAGE(KERN_WARNING, device, "%s", 646 DEV_MESSAGE(KERN_WARNING, device, "%s",
@@ -562,7 +648,6 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
562 "data"); 648 "data");
563 return -ENOMEM; 649 return -ENOMEM;
564 } 650 }
565 memset(private, 0, sizeof(struct dasd_eckd_private));
566 device->private = (void *) private; 651 device->private = (void *) private;
567 } 652 }
568 /* Invalidate status of initial analysis. */ 653 /* Invalidate status of initial analysis. */
@@ -571,16 +656,29 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
571 private->attrib.operation = DASD_NORMAL_CACHE; 656 private->attrib.operation = DASD_NORMAL_CACHE;
572 private->attrib.nr_cyl = 0; 657 private->attrib.nr_cyl = 0;
573 658
659 /* Read Configuration Data */
660 rc = dasd_eckd_read_conf(device);
661 if (rc)
662 return rc;
663
664 /* Generate device unique id and register in devmap */
665 rc = dasd_eckd_generate_uid(device, &uid);
666 if (rc)
667 return rc;
668 rc = dasd_set_uid(device->cdev, &uid);
669 if (rc == 1) /* new server found */
670 rc = dasd_eckd_validate_server(device);
671 if (rc)
672 return rc;
673
574 /* Read Device Characteristics */ 674 /* Read Device Characteristics */
575 rdc_data = (void *) &(private->rdc_data); 675 rdc_data = (void *) &(private->rdc_data);
576 memset(rdc_data, 0, sizeof(rdc_data)); 676 memset(rdc_data, 0, sizeof(rdc_data));
577 rc = read_dev_chars(device->cdev, &rdc_data, 64); 677 rc = read_dev_chars(device->cdev, &rdc_data, 64);
578 if (rc) { 678 if (rc)
579 DEV_MESSAGE(KERN_WARNING, device, 679 DEV_MESSAGE(KERN_WARNING, device,
580 "Read device characteristics returned error %d", 680 "Read device characteristics returned "
581 rc); 681 "rc=%d", rc);
582 return rc;
583 }
584 682
585 DEV_MESSAGE(KERN_INFO, device, 683 DEV_MESSAGE(KERN_INFO, device,
586 "%04X/%02X(CU:%04X/%02X) Cyl:%d Head:%d Sec:%d", 684 "%04X/%02X(CU:%04X/%02X) Cyl:%d Head:%d Sec:%d",
@@ -591,19 +689,6 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
591 private->rdc_data.no_cyl, 689 private->rdc_data.no_cyl,
592 private->rdc_data.trk_per_cyl, 690 private->rdc_data.trk_per_cyl,
593 private->rdc_data.sec_per_trk); 691 private->rdc_data.sec_per_trk);
594
595 /* Read Configuration Data */
596 rc = dasd_eckd_read_conf (device);
597 if (rc)
598 return rc;
599
600 /* Generate device unique id and register in devmap */
601 rc = dasd_eckd_generate_uid(device, &uid);
602 if (rc)
603 return rc;
604
605 rc = dasd_set_uid(device->cdev, &uid);
606
607 return rc; 692 return rc;
608} 693}
609 694
@@ -773,7 +858,7 @@ dasd_eckd_end_analysis(struct dasd_device *device)
773 ((private->rdc_data.no_cyl * 858 ((private->rdc_data.no_cyl *
774 private->rdc_data.trk_per_cyl * 859 private->rdc_data.trk_per_cyl *
775 blk_per_trk * (device->bp_block >> 9)) >> 1), 860 blk_per_trk * (device->bp_block >> 9)) >> 1),
776 ((blk_per_trk * device->bp_block) >> 10), 861 ((blk_per_trk * device->bp_block) >> 10),
777 private->uses_cdl ? 862 private->uses_cdl ?
778 "compatible disk layout" : "linux disk layout"); 863 "compatible disk layout" : "linux disk layout");
779 864
@@ -970,7 +1055,7 @@ dasd_eckd_format_device(struct dasd_device * device,
970 if (i < 3) { 1055 if (i < 3) {
971 ect->kl = 4; 1056 ect->kl = 4;
972 ect->dl = sizes_trk0[i] - 4; 1057 ect->dl = sizes_trk0[i] - 4;
973 } 1058 }
974 } 1059 }
975 if ((fdata->intensity & 0x08) && 1060 if ((fdata->intensity & 0x08) &&
976 fdata->start_unit == 1) { 1061 fdata->start_unit == 1) {
@@ -1270,7 +1355,7 @@ dasd_eckd_fill_info(struct dasd_device * device,
1270 1355
1271/* 1356/*
1272 * Release device ioctl. 1357 * Release device ioctl.
1273 * Buils a channel programm to releases a prior reserved 1358 * Buils a channel programm to releases a prior reserved
1274 * (see dasd_eckd_reserve) device. 1359 * (see dasd_eckd_reserve) device.
1275 */ 1360 */
1276static int 1361static int
@@ -1310,8 +1395,8 @@ dasd_eckd_release(struct dasd_device *device)
1310/* 1395/*
1311 * Reserve device ioctl. 1396 * Reserve device ioctl.
1312 * Options are set to 'synchronous wait for interrupt' and 1397 * Options are set to 'synchronous wait for interrupt' and
1313 * 'timeout the request'. This leads to a terminate IO if 1398 * 'timeout the request'. This leads to a terminate IO if
1314 * the interrupt is outstanding for a certain time. 1399 * the interrupt is outstanding for a certain time.
1315 */ 1400 */
1316static int 1401static int
1317dasd_eckd_reserve(struct dasd_device *device) 1402dasd_eckd_reserve(struct dasd_device *device)
@@ -1349,7 +1434,7 @@ dasd_eckd_reserve(struct dasd_device *device)
1349 1434
1350/* 1435/*
1351 * Steal lock ioctl - unconditional reserve device. 1436 * Steal lock ioctl - unconditional reserve device.
1352 * Buils a channel programm to break a device's reservation. 1437 * Buils a channel programm to break a device's reservation.
1353 * (unconditional reserve) 1438 * (unconditional reserve)
1354 */ 1439 */
1355static int 1440static int
@@ -1522,6 +1607,40 @@ dasd_eckd_ioctl(struct dasd_device *device, unsigned int cmd, void __user *argp)
1522} 1607}
1523 1608
1524/* 1609/*
1610 * Dump the range of CCWs into 'page' buffer
1611 * and return number of printed chars.
1612 */
1613static inline int
1614dasd_eckd_dump_ccw_range(struct ccw1 *from, struct ccw1 *to, char *page)
1615{
1616 int len, count;
1617 char *datap;
1618
1619 len = 0;
1620 while (from <= to) {
1621 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
1622 " CCW %p: %08X %08X DAT:",
1623 from, ((int *) from)[0], ((int *) from)[1]);
1624
1625 /* get pointer to data (consider IDALs) */
1626 if (from->flags & CCW_FLAG_IDA)
1627 datap = (char *) *((addr_t *) (addr_t) from->cda);
1628 else
1629 datap = (char *) ((addr_t) from->cda);
1630
1631 /* dump data (max 32 bytes) */
1632 for (count = 0; count < from->count && count < 32; count++) {
1633 if (count % 8 == 0) len += sprintf(page + len, " ");
1634 if (count % 4 == 0) len += sprintf(page + len, " ");
1635 len += sprintf(page + len, "%02x", datap[count]);
1636 }
1637 len += sprintf(page + len, "\n");
1638 from++;
1639 }
1640 return len;
1641}
1642
1643/*
1525 * Print sense data and related channel program. 1644 * Print sense data and related channel program.
1526 * Parts are printed because printk buffer is only 1024 bytes. 1645 * Parts are printed because printk buffer is only 1024 bytes.
1527 */ 1646 */
@@ -1530,8 +1649,8 @@ dasd_eckd_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
1530 struct irb *irb) 1649 struct irb *irb)
1531{ 1650{
1532 char *page; 1651 char *page;
1533 struct ccw1 *act, *end, *last; 1652 struct ccw1 *first, *last, *fail, *from, *to;
1534 int len, sl, sct, count; 1653 int len, sl, sct;
1535 1654
1536 page = (char *) get_zeroed_page(GFP_ATOMIC); 1655 page = (char *) get_zeroed_page(GFP_ATOMIC);
1537 if (page == NULL) { 1656 if (page == NULL) {
@@ -1539,7 +1658,8 @@ dasd_eckd_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
1539 "No memory to dump sense data"); 1658 "No memory to dump sense data");
1540 return; 1659 return;
1541 } 1660 }
1542 len = sprintf(page, KERN_ERR PRINTK_HEADER 1661 /* dump the sense data */
1662 len = sprintf(page, KERN_ERR PRINTK_HEADER
1543 " I/O status report for device %s:\n", 1663 " I/O status report for device %s:\n",
1544 device->cdev->dev.bus_id); 1664 device->cdev->dev.bus_id);
1545 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 1665 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
@@ -1564,87 +1684,55 @@ dasd_eckd_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
1564 1684
1565 if (irb->ecw[27] & DASD_SENSE_BIT_0) { 1685 if (irb->ecw[27] & DASD_SENSE_BIT_0) {
1566 /* 24 Byte Sense Data */ 1686 /* 24 Byte Sense Data */
1567 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 1687 sprintf(page + len, KERN_ERR PRINTK_HEADER
1568 " 24 Byte: %x MSG %x, " 1688 " 24 Byte: %x MSG %x, "
1569 "%s MSGb to SYSOP\n", 1689 "%s MSGb to SYSOP\n",
1570 irb->ecw[7] >> 4, irb->ecw[7] & 0x0f, 1690 irb->ecw[7] >> 4, irb->ecw[7] & 0x0f,
1571 irb->ecw[1] & 0x10 ? "" : "no"); 1691 irb->ecw[1] & 0x10 ? "" : "no");
1572 } else { 1692 } else {
1573 /* 32 Byte Sense Data */ 1693 /* 32 Byte Sense Data */
1574 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 1694 sprintf(page + len, KERN_ERR PRINTK_HEADER
1575 " 32 Byte: Format: %x " 1695 " 32 Byte: Format: %x "
1576 "Exception class %x\n", 1696 "Exception class %x\n",
1577 irb->ecw[6] & 0x0f, irb->ecw[22] >> 4); 1697 irb->ecw[6] & 0x0f, irb->ecw[22] >> 4);
1578 } 1698 }
1579 } else { 1699 } else {
1580 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 1700 sprintf(page + len, KERN_ERR PRINTK_HEADER
1581 " SORRY - NO VALID SENSE AVAILABLE\n"); 1701 " SORRY - NO VALID SENSE AVAILABLE\n");
1582 } 1702 }
1583 MESSAGE_LOG(KERN_ERR, "%s", 1703 printk("%s", page);
1584 page + sizeof(KERN_ERR PRINTK_HEADER)); 1704
1585 1705 /* dump the Channel Program (max 140 Bytes per line) */
1586 /* dump the Channel Program */ 1706 /* Count CCW and print first CCWs (maximum 1024 % 140 = 7) */
1587 /* print first CCWs (maximum 8) */ 1707 first = req->cpaddr;
1588 act = req->cpaddr; 1708 for (last = first; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++);
1589 for (last = act; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++); 1709 to = min(first + 6, last);
1590 end = min(act + 8, last); 1710 len = sprintf(page, KERN_ERR PRINTK_HEADER
1591 len = sprintf(page, KERN_ERR PRINTK_HEADER
1592 " Related CP in req: %p\n", req); 1711 " Related CP in req: %p\n", req);
1593 while (act <= end) { 1712 dasd_eckd_dump_ccw_range(first, to, page + len);
1594 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 1713 printk("%s", page);
1595 " CCW %p: %08X %08X DAT:",
1596 act, ((int *) act)[0], ((int *) act)[1]);
1597 for (count = 0; count < 32 && count < act->count;
1598 count += sizeof(int))
1599 len += sprintf(page + len, " %08X",
1600 ((int *) (addr_t) act->cda)
1601 [(count>>2)]);
1602 len += sprintf(page + len, "\n");
1603 act++;
1604 }
1605 MESSAGE_LOG(KERN_ERR, "%s",
1606 page + sizeof(KERN_ERR PRINTK_HEADER));
1607 1714
1608 /* print failing CCW area */ 1715 /* print failing CCW area (maximum 4) */
1716 /* scsw->cda is either valid or zero */
1609 len = 0; 1717 len = 0;
1610 if (act < ((struct ccw1 *)(addr_t) irb->scsw.cpa) - 2) { 1718 from = ++to;
1611 act = ((struct ccw1 *)(addr_t) irb->scsw.cpa) - 2; 1719 fail = (struct ccw1 *)(addr_t) irb->scsw.cpa; /* failing CCW */
1612 len += sprintf(page + len, KERN_ERR PRINTK_HEADER "......\n"); 1720 if (from < fail - 2) {
1613 } 1721 from = fail - 2; /* there is a gap - print header */
1614 end = min((struct ccw1 *)(addr_t) irb->scsw.cpa + 2, last); 1722 len += sprintf(page, KERN_ERR PRINTK_HEADER "......\n");
1615 while (act <= end) {
1616 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
1617 " CCW %p: %08X %08X DAT:",
1618 act, ((int *) act)[0], ((int *) act)[1]);
1619 for (count = 0; count < 32 && count < act->count;
1620 count += sizeof(int))
1621 len += sprintf(page + len, " %08X",
1622 ((int *) (addr_t) act->cda)
1623 [(count>>2)]);
1624 len += sprintf(page + len, "\n");
1625 act++;
1626 } 1723 }
1724 to = min(fail + 1, last);
1725 len += dasd_eckd_dump_ccw_range(from, to, page + len);
1627 1726
1628 /* print last CCWs */ 1727 /* print last CCWs (maximum 2) */
1629 if (act < last - 2) { 1728 from = max(from, ++to);
1630 act = last - 2; 1729 if (from < last - 1) {
1730 from = last - 1; /* there is a gap - print header */
1631 len += sprintf(page + len, KERN_ERR PRINTK_HEADER "......\n"); 1731 len += sprintf(page + len, KERN_ERR PRINTK_HEADER "......\n");
1632 } 1732 }
1633 while (act <= last) { 1733 len += dasd_eckd_dump_ccw_range(from, last, page + len);
1634 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
1635 " CCW %p: %08X %08X DAT:",
1636 act, ((int *) act)[0], ((int *) act)[1]);
1637 for (count = 0; count < 32 && count < act->count;
1638 count += sizeof(int))
1639 len += sprintf(page + len, " %08X",
1640 ((int *) (addr_t) act->cda)
1641 [(count>>2)]);
1642 len += sprintf(page + len, "\n");
1643 act++;
1644 }
1645 if (len > 0) 1734 if (len > 0)
1646 MESSAGE_LOG(KERN_ERR, "%s", 1735 printk("%s", page);
1647 page + sizeof(KERN_ERR PRINTK_HEADER));
1648 free_page((unsigned long) page); 1736 free_page((unsigned long) page);
1649} 1737}
1650 1738
@@ -1685,14 +1773,8 @@ static struct dasd_discipline dasd_eckd_discipline = {
1685static int __init 1773static int __init
1686dasd_eckd_init(void) 1774dasd_eckd_init(void)
1687{ 1775{
1688 int ret;
1689
1690 ASCEBC(dasd_eckd_discipline.ebcname, 4); 1776 ASCEBC(dasd_eckd_discipline.ebcname, 4);
1691 1777 return ccw_driver_register(&dasd_eckd_driver);
1692 ret = ccw_driver_register(&dasd_eckd_driver);
1693 if (!ret)
1694 dasd_generic_auto_online(&dasd_eckd_driver);
1695 return ret;
1696} 1778}
1697 1779
1698static void __exit 1780static void __exit
@@ -1703,22 +1785,3 @@ dasd_eckd_cleanup(void)
1703 1785
1704module_init(dasd_eckd_init); 1786module_init(dasd_eckd_init);
1705module_exit(dasd_eckd_cleanup); 1787module_exit(dasd_eckd_cleanup);
1706
1707/*
1708 * Overrides for Emacs so that we follow Linus's tabbing style.
1709 * Emacs will notice this stuff at the end of the file and automatically
1710 * adjust the settings for this buffer only. This must remain at the end
1711 * of the file.
1712 * ---------------------------------------------------------------------------
1713 * Local variables:
1714 * c-indent-level: 4
1715 * c-brace-imaginary-offset: 0
1716 * c-brace-offset: -4
1717 * c-argdecl-indent: 4
1718 * c-label-offset: -4
1719 * c-continued-statement-offset: 4
1720 * c-continued-brace-offset: 0
1721 * indent-tabs-mode: 1
1722 * tab-width: 8
1723 * End:
1724 */
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h
index d5734e976e1c..712ff1650134 100644
--- a/drivers/s390/block/dasd_eckd.h
+++ b/drivers/s390/block/dasd_eckd.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_eckd.h 2 * File...........: linux/drivers/s390/block/dasd_eckd.h
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com> 4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
7 * 7 *
@@ -41,9 +41,10 @@
41#define DASD_ECKD_CCW_RESERVE 0xB4 41#define DASD_ECKD_CCW_RESERVE 0xB4
42 42
43/* 43/*
44 *Perform Subsystem Function / Sub-Orders 44 * Perform Subsystem Function / Sub-Orders
45 */ 45 */
46#define PSF_ORDER_PRSSD 0x18 46#define PSF_ORDER_PRSSD 0x18
47#define PSF_ORDER_SSC 0x1D
47 48
48/***************************************************************************** 49/*****************************************************************************
49 * SECTION: Type Definitions 50 * SECTION: Type Definitions
@@ -155,7 +156,7 @@ struct dasd_eckd_characteristics {
155 unsigned char reserved2:4; 156 unsigned char reserved2:4;
156 unsigned char reserved3:8; 157 unsigned char reserved3:8;
157 unsigned char defect_wr:1; 158 unsigned char defect_wr:1;
158 unsigned char XRC_supported:1; 159 unsigned char XRC_supported:1;
159 unsigned char reserved4:1; 160 unsigned char reserved4:1;
160 unsigned char striping:1; 161 unsigned char striping:1;
161 unsigned char reserved5:4; 162 unsigned char reserved5:4;
@@ -343,7 +344,7 @@ struct dasd_eckd_path {
343}; 344};
344 345
345/* 346/*
346 * Perform Subsystem Function - Prepare for Read Subsystem Data 347 * Perform Subsystem Function - Prepare for Read Subsystem Data
347 */ 348 */
348struct dasd_psf_prssd_data { 349struct dasd_psf_prssd_data {
349 unsigned char order; 350 unsigned char order;
@@ -353,4 +354,15 @@ struct dasd_psf_prssd_data {
353 unsigned char varies[9]; 354 unsigned char varies[9];
354} __attribute__ ((packed)); 355} __attribute__ ((packed));
355 356
357/*
358 * Perform Subsystem Function - Set Subsystem Characteristics
359 */
360struct dasd_psf_ssc_data {
361 unsigned char order;
362 unsigned char flags;
363 unsigned char cu_type[4];
364 unsigned char suborder;
365 unsigned char reserved[59];
366} __attribute__((packed));
367
356#endif /* DASD_ECKD_H */ 368#endif /* DASD_ECKD_H */
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 2d946b6ca074..da65f1b032f5 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -89,7 +89,7 @@ struct eerbuffer {
89}; 89};
90 90
91static LIST_HEAD(bufferlist); 91static LIST_HEAD(bufferlist);
92static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED; 92static DEFINE_SPINLOCK(bufferlock);
93static DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue); 93static DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue);
94 94
95/* 95/*
@@ -276,7 +276,7 @@ struct dasd_eer_header {
276 __u64 tv_sec; 276 __u64 tv_sec;
277 __u64 tv_usec; 277 __u64 tv_usec;
278 char busid[DASD_EER_BUSID_SIZE]; 278 char busid[DASD_EER_BUSID_SIZE];
279}; 279} __attribute__ ((packed));
280 280
281/* 281/*
282 * The following function can be used for those triggers that have 282 * The following function can be used for those triggers that have
@@ -521,6 +521,8 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
521 unsigned long flags; 521 unsigned long flags;
522 522
523 eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL); 523 eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL);
524 if (!eerb)
525 return -ENOMEM;
524 eerb->buffer_page_count = eer_pages; 526 eerb->buffer_page_count = eer_pages;
525 if (eerb->buffer_page_count < 1 || 527 if (eerb->buffer_page_count < 1 ||
526 eerb->buffer_page_count > INT_MAX / PAGE_SIZE) { 528 eerb->buffer_page_count > INT_MAX / PAGE_SIZE) {
diff --git a/drivers/s390/block/dasd_erp.c b/drivers/s390/block/dasd_erp.c
index b842377cb0c6..4108d96f6a5a 100644
--- a/drivers/s390/block/dasd_erp.c
+++ b/drivers/s390/block/dasd_erp.c
@@ -90,7 +90,7 @@ dasd_default_erp_action(struct dasd_ccw_req * cqr)
90 90
91 /* just retry - there is nothing to save ... I got no sense data.... */ 91 /* just retry - there is nothing to save ... I got no sense data.... */
92 if (cqr->retries > 0) { 92 if (cqr->retries > 0) {
93 DEV_MESSAGE (KERN_DEBUG, device, 93 DEV_MESSAGE (KERN_DEBUG, device,
94 "default ERP called (%i retries left)", 94 "default ERP called (%i retries left)",
95 cqr->retries); 95 cqr->retries);
96 cqr->lpm = LPM_ANYPATH; 96 cqr->lpm = LPM_ANYPATH;
@@ -155,7 +155,7 @@ dasd_default_erp_postaction(struct dasd_ccw_req * cqr)
155 155
156/* 156/*
157 * Print the hex dump of the memory used by a request. This includes 157 * Print the hex dump of the memory used by a request. This includes
158 * all error recovery ccws that have been chained in from of the 158 * all error recovery ccws that have been chained in from of the
159 * real request. 159 * real request.
160 */ 160 */
161static inline void 161static inline void
@@ -227,12 +227,12 @@ dasd_log_ccw(struct dasd_ccw_req * cqr, int caller, __u32 cpa)
227 /* 227 /*
228 * Log bytes arround failed CCW but only if we did 228 * Log bytes arround failed CCW but only if we did
229 * not log the whole CP of the CCW is outside the 229 * not log the whole CP of the CCW is outside the
230 * logged CP. 230 * logged CP.
231 */ 231 */
232 if (cplength > 40 || 232 if (cplength > 40 ||
233 ((addr_t) cpa < (addr_t) lcqr->cpaddr && 233 ((addr_t) cpa < (addr_t) lcqr->cpaddr &&
234 (addr_t) cpa > (addr_t) (lcqr->cpaddr + cplength + 4))) { 234 (addr_t) cpa > (addr_t) (lcqr->cpaddr + cplength + 4))) {
235 235
236 DEV_MESSAGE(KERN_ERR, device, 236 DEV_MESSAGE(KERN_ERR, device,
237 "Failed CCW (%p) (area):", 237 "Failed CCW (%p) (area):",
238 (void *) (long) cpa); 238 (void *) (long) cpa);
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 91145698f8e9..bb7755b9b19d 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_fba.c 2 * File...........: linux/drivers/s390/block/dasd_fba.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
@@ -56,19 +56,13 @@ static struct ccw_driver dasd_fba_driver; /* see below */
56static int 56static int
57dasd_fba_probe(struct ccw_device *cdev) 57dasd_fba_probe(struct ccw_device *cdev)
58{ 58{
59 int ret; 59 return dasd_generic_probe(cdev, &dasd_fba_discipline);
60
61 ret = dasd_generic_probe (cdev, &dasd_fba_discipline);
62 if (ret)
63 return ret;
64 ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
65 return 0;
66} 60}
67 61
68static int 62static int
69dasd_fba_set_online(struct ccw_device *cdev) 63dasd_fba_set_online(struct ccw_device *cdev)
70{ 64{
71 return dasd_generic_set_online (cdev, &dasd_fba_discipline); 65 return dasd_generic_set_online(cdev, &dasd_fba_discipline);
72} 66}
73 67
74static struct ccw_driver dasd_fba_driver = { 68static struct ccw_driver dasd_fba_driver = {
@@ -125,13 +119,13 @@ static int
125dasd_fba_check_characteristics(struct dasd_device *device) 119dasd_fba_check_characteristics(struct dasd_device *device)
126{ 120{
127 struct dasd_fba_private *private; 121 struct dasd_fba_private *private;
128 struct ccw_device *cdev = device->cdev; 122 struct ccw_device *cdev = device->cdev;
129 void *rdc_data; 123 void *rdc_data;
130 int rc; 124 int rc;
131 125
132 private = (struct dasd_fba_private *) device->private; 126 private = (struct dasd_fba_private *) device->private;
133 if (private == NULL) { 127 if (private == NULL) {
134 private = kmalloc(sizeof(struct dasd_fba_private), GFP_KERNEL); 128 private = kzalloc(sizeof(struct dasd_fba_private), GFP_KERNEL);
135 if (private == NULL) { 129 if (private == NULL) {
136 DEV_MESSAGE(KERN_WARNING, device, "%s", 130 DEV_MESSAGE(KERN_WARNING, device, "%s",
137 "memory allocation failed for private " 131 "memory allocation failed for private "
@@ -204,7 +198,7 @@ dasd_fba_examine_error(struct dasd_ccw_req * cqr, struct irb * irb)
204 if (irb->scsw.cstat == 0x00 && 198 if (irb->scsw.cstat == 0x00 &&
205 irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END)) 199 irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END))
206 return dasd_era_none; 200 return dasd_era_none;
207 201
208 cdev = device->cdev; 202 cdev = device->cdev;
209 switch (cdev->id.dev_type) { 203 switch (cdev->id.dev_type) {
210 case 0x3370: 204 case 0x3370:
@@ -539,7 +533,7 @@ dasd_fba_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
539 * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has 533 * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has
540 * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use 534 * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use
541 * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In 535 * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In
542 * addition we have one define extent ccw + 16 bytes of data and a 536 * addition we have one define extent ccw + 16 bytes of data and a
543 * locate record ccw for each block (stupid devices!) + 16 bytes of data. 537 * locate record ccw for each block (stupid devices!) + 16 bytes of data.
544 * That makes: 538 * That makes:
545 * (8192 - 24 - 136 - 8 - 16) / 40 = 200.2 blocks at maximum. 539 * (8192 - 24 - 136 - 8 - 16) / 40 = 200.2 blocks at maximum.
@@ -569,16 +563,8 @@ static struct dasd_discipline dasd_fba_discipline = {
569static int __init 563static int __init
570dasd_fba_init(void) 564dasd_fba_init(void)
571{ 565{
572 int ret;
573
574 ASCEBC(dasd_fba_discipline.ebcname, 4); 566 ASCEBC(dasd_fba_discipline.ebcname, 4);
575 567 return ccw_driver_register(&dasd_fba_driver);
576 ret = ccw_driver_register(&dasd_fba_driver);
577 if (ret)
578 return ret;
579
580 dasd_generic_auto_online(&dasd_fba_driver);
581 return 0;
582} 568}
583 569
584static void __exit 570static void __exit
@@ -589,22 +575,3 @@ dasd_fba_cleanup(void)
589 575
590module_init(dasd_fba_init); 576module_init(dasd_fba_init);
591module_exit(dasd_fba_cleanup); 577module_exit(dasd_fba_cleanup);
592
593/*
594 * Overrides for Emacs so that we follow Linus's tabbing style.
595 * Emacs will notice this stuff at the end of the file and automatically
596 * adjust the settings for this buffer only. This must remain at the end
597 * of the file.
598 * ---------------------------------------------------------------------------
599 * Local variables:
600 * c-indent-level: 4
601 * c-brace-imaginary-offset: 0
602 * c-brace-offset: -4
603 * c-argdecl-indent: 4
604 * c-label-offset: -4
605 * c-continued-statement-offset: 4
606 * c-continued-brace-offset: 0
607 * indent-tabs-mode: 1
608 * tab-width: 8
609 * End:
610 */
diff --git a/drivers/s390/block/dasd_fba.h b/drivers/s390/block/dasd_fba.h
index da1fa91fc01d..14c910baa5fe 100644
--- a/drivers/s390/block/dasd_fba.h
+++ b/drivers/s390/block/dasd_fba.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_fba.h 2 * File...........: linux/drivers/s390/block/dasd_fba.h
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index fce2835e7d19..61ffde718a7a 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -68,8 +68,6 @@ dasd_gendisk_alloc(struct dasd_device *device)
68 } 68 }
69 len += sprintf(gdp->disk_name + len, "%c", 'a'+(device->devindex%26)); 69 len += sprintf(gdp->disk_name + len, "%c", 'a'+(device->devindex%26));
70 70
71 sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id);
72
73 if (device->features & DASD_FEATURE_READONLY) 71 if (device->features & DASD_FEATURE_READONLY)
74 set_disk_ro(gdp, 1); 72 set_disk_ro(gdp, 1);
75 gdp->private_data = device; 73 gdp->private_data = device;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index d4b13e300a76..3ccf06d28ba1 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd_int.h 2 * File...........: linux/drivers/s390/block/dasd_int.h
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com> 4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Martin Schwidefsky <schwidefsky@de.ibm.com> 5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
@@ -54,7 +54,6 @@
54#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/wait.h> 55#include <linux/wait.h>
56#include <linux/blkdev.h> 56#include <linux/blkdev.h>
57#include <linux/devfs_fs_kernel.h>
58#include <linux/genhd.h> 57#include <linux/genhd.h>
59#include <linux/hdreg.h> 58#include <linux/hdreg.h>
60#include <linux/interrupt.h> 59#include <linux/interrupt.h>
@@ -186,7 +185,7 @@ struct dasd_ccw_req {
186 void *callback_data; 185 void *callback_data;
187}; 186};
188 187
189/* 188/*
190 * dasd_ccw_req -> status can be: 189 * dasd_ccw_req -> status can be:
191 */ 190 */
192#define DASD_CQR_FILLED 0x00 /* request is ready to be processed */ 191#define DASD_CQR_FILLED 0x00 /* request is ready to be processed */
@@ -248,7 +247,7 @@ struct dasd_discipline {
248 /* 247 /*
249 * Error recovery functions. examine_error() returns a value that 248 * Error recovery functions. examine_error() returns a value that
250 * indicates what to do for an error condition. If examine_error() 249 * indicates what to do for an error condition. If examine_error()
251 * returns 'dasd_era_recover' erp_action() is called to create a 250 * returns 'dasd_era_recover' erp_action() is called to create a
252 * special error recovery ccw. erp_postaction() is called after 251 * special error recovery ccw. erp_postaction() is called after
253 * an error recovery ccw has finished its execution. dump_sense 252 * an error recovery ccw has finished its execution. dump_sense
254 * is called for every error condition to print the sense data 253 * is called for every error condition to print the sense data
@@ -302,11 +301,11 @@ struct dasd_device {
302 spinlock_t request_queue_lock; 301 spinlock_t request_queue_lock;
303 struct block_device *bdev; 302 struct block_device *bdev;
304 unsigned int devindex; 303 unsigned int devindex;
305 unsigned long blocks; /* size of volume in blocks */ 304 unsigned long blocks; /* size of volume in blocks */
306 unsigned int bp_block; /* bytes per block */ 305 unsigned int bp_block; /* bytes per block */
307 unsigned int s2b_shift; /* log2 (bp_block/512) */ 306 unsigned int s2b_shift; /* log2 (bp_block/512) */
308 unsigned long flags; /* per device flags */ 307 unsigned long flags; /* per device flags */
309 unsigned short features; /* copy of devmap-features (read-only!) */ 308 unsigned short features; /* copy of devmap-features (read-only!) */
310 309
311 /* extended error reporting stuff (eer) */ 310 /* extended error reporting stuff (eer) */
312 struct dasd_ccw_req *eer_cqr; 311 struct dasd_ccw_req *eer_cqr;
@@ -513,12 +512,12 @@ void dasd_generic_remove (struct ccw_device *cdev);
513int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *); 512int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
514int dasd_generic_set_offline (struct ccw_device *cdev); 513int dasd_generic_set_offline (struct ccw_device *cdev);
515int dasd_generic_notify(struct ccw_device *, int); 514int dasd_generic_notify(struct ccw_device *, int);
516void dasd_generic_auto_online (struct ccw_driver *);
517 515
518/* externals in dasd_devmap.c */ 516/* externals in dasd_devmap.c */
519extern int dasd_max_devindex; 517extern int dasd_max_devindex;
520extern int dasd_probeonly; 518extern int dasd_probeonly;
521extern int dasd_autodetect; 519extern int dasd_autodetect;
520extern int dasd_nopav;
522 521
523int dasd_devmap_init(void); 522int dasd_devmap_init(void);
524void dasd_devmap_exit(void); 523void dasd_devmap_exit(void);
@@ -606,22 +605,3 @@ static inline int dasd_eer_enabled(struct dasd_device *device)
606#endif /* __KERNEL__ */ 605#endif /* __KERNEL__ */
607 606
608#endif /* DASD_H */ 607#endif /* DASD_H */
609
610/*
611 * Overrides for Emacs so that we follow Linus's tabbing style.
612 * Emacs will notice this stuff at the end of the file and automatically
613 * adjust the settings for this buffer only. This must remain at the end
614 * of the file.
615 * ---------------------------------------------------------------------------
616 * Local variables:
617 * c-indent-level: 4
618 * c-brace-imaginary-offset: 0
619 * c-brace-offset: -4
620 * c-argdecl-indent: 4
621 * c-label-offset: -4
622 * c-continued-statement-offset: 4
623 * c-continued-brace-offset: 0
624 * indent-tabs-mode: 1
625 * tab-width: 8
626 * End:
627 */
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index b8c80d28df41..302bcd0f28be 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -90,10 +90,10 @@ static int
90dasd_ioctl_quiesce(struct dasd_device *device) 90dasd_ioctl_quiesce(struct dasd_device *device)
91{ 91{
92 unsigned long flags; 92 unsigned long flags;
93 93
94 if (!capable (CAP_SYS_ADMIN)) 94 if (!capable (CAP_SYS_ADMIN))
95 return -EACCES; 95 return -EACCES;
96 96
97 DEV_MESSAGE (KERN_DEBUG, device, "%s", 97 DEV_MESSAGE (KERN_DEBUG, device, "%s",
98 "Quiesce IO on device"); 98 "Quiesce IO on device");
99 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 99 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
@@ -110,13 +110,13 @@ static int
110dasd_ioctl_resume(struct dasd_device *device) 110dasd_ioctl_resume(struct dasd_device *device)
111{ 111{
112 unsigned long flags; 112 unsigned long flags;
113 113
114 if (!capable (CAP_SYS_ADMIN)) 114 if (!capable (CAP_SYS_ADMIN))
115 return -EACCES; 115 return -EACCES;
116 116
117 DEV_MESSAGE (KERN_DEBUG, device, "%s", 117 DEV_MESSAGE (KERN_DEBUG, device, "%s",
118 "resume IO on device"); 118 "resume IO on device");
119 119
120 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 120 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
121 device->stopped &= ~DASD_STOPPED_QUIESCE; 121 device->stopped &= ~DASD_STOPPED_QUIESCE;
122 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 122 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
@@ -287,7 +287,7 @@ dasd_ioctl_information(struct dasd_device *device,
287 dasd_info->open_count = atomic_read(&device->open_count); 287 dasd_info->open_count = atomic_read(&device->open_count);
288 if (!device->bdev) 288 if (!device->bdev)
289 dasd_info->open_count++; 289 dasd_info->open_count++;
290 290
291 /* 291 /*
292 * check if device is really formatted 292 * check if device is really formatted
293 * LDL / CDL was returned by 'fill_info' 293 * LDL / CDL was returned by 'fill_info'
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index 54ecd548c318..4c1e56b9b98d 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -36,7 +36,6 @@
36#include <linux/hdreg.h> /* HDIO_GETGEO */ 36#include <linux/hdreg.h> /* HDIO_GETGEO */
37#include <linux/sysdev.h> 37#include <linux/sysdev.h>
38#include <linux/bio.h> 38#include <linux/bio.h>
39#include <linux/devfs_fs_kernel.h>
40#include <asm/uaccess.h> 39#include <asm/uaccess.h>
41 40
42#define XPRAM_NAME "xpram" 41#define XPRAM_NAME "xpram"
@@ -439,8 +438,6 @@ static int __init xpram_setup_blkdev(void)
439 if (rc < 0) 438 if (rc < 0)
440 goto out; 439 goto out;
441 440
442 devfs_mk_dir("slram");
443
444 /* 441 /*
445 * Assign the other needed values: make request function, sizes and 442 * Assign the other needed values: make request function, sizes and
446 * hardsect size. All the minor devices feature the same value. 443 * hardsect size. All the minor devices feature the same value.
@@ -469,14 +466,12 @@ static int __init xpram_setup_blkdev(void)
469 disk->private_data = &xpram_devices[i]; 466 disk->private_data = &xpram_devices[i];
470 disk->queue = xpram_queue; 467 disk->queue = xpram_queue;
471 sprintf(disk->disk_name, "slram%d", i); 468 sprintf(disk->disk_name, "slram%d", i);
472 sprintf(disk->devfs_name, "slram/%d", i);
473 set_capacity(disk, xpram_sizes[i] << 1); 469 set_capacity(disk, xpram_sizes[i] << 1);
474 add_disk(disk); 470 add_disk(disk);
475 } 471 }
476 472
477 return 0; 473 return 0;
478out_unreg: 474out_unreg:
479 devfs_remove("slram");
480 unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME); 475 unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME);
481out: 476out:
482 while (i--) 477 while (i--)
@@ -495,7 +490,6 @@ static void __exit xpram_exit(void)
495 put_disk(xpram_disks[i]); 490 put_disk(xpram_disks[i]);
496 } 491 }
497 unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME); 492 unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME);
498 devfs_remove("slram");
499 blk_cleanup_queue(xpram_queue); 493 blk_cleanup_queue(xpram_queue);
500 sysdev_unregister(&xpram_sys_device); 494 sysdev_unregister(&xpram_sys_device);
501 sysdev_class_unregister(&xpram_sysclass); 495 sysdev_class_unregister(&xpram_sysclass);
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index fb7bc9e5eebc..a138b1510093 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -586,7 +586,6 @@ static struct file_operations mon_fops = {
586 586
587static struct miscdevice mon_dev = { 587static struct miscdevice mon_dev = {
588 .name = "monreader", 588 .name = "monreader",
589 .devfs_name = "monreader",
590 .fops = &mon_fops, 589 .fops = &mon_fops,
591 .minor = MISC_DYNAMIC_MINOR, 590 .minor = MISC_DYNAMIC_MINOR,
592}; 591};
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index eecb2afad5c2..3c1314b7391b 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -50,6 +50,9 @@ struct raw3270 {
50 unsigned char *ascebc; /* ascii -> ebcdic table */ 50 unsigned char *ascebc; /* ascii -> ebcdic table */
51 struct class_device *clttydev; /* 3270-class tty device ptr */ 51 struct class_device *clttydev; /* 3270-class tty device ptr */
52 struct class_device *cltubdev; /* 3270-class tub device ptr */ 52 struct class_device *cltubdev; /* 3270-class tub device ptr */
53
54 struct raw3270_request init_request;
55 unsigned char init_data[256];
53}; 56};
54 57
55/* raw3270->flags */ 58/* raw3270->flags */
@@ -484,8 +487,6 @@ struct raw3270_ua { /* Query Reply structure for Usable Area */
484 } __attribute__ ((packed)) aua; 487 } __attribute__ ((packed)) aua;
485} __attribute__ ((packed)); 488} __attribute__ ((packed));
486 489
487static unsigned char raw3270_init_data[256];
488static struct raw3270_request raw3270_init_request;
489static struct diag210 raw3270_init_diag210; 490static struct diag210 raw3270_init_diag210;
490static DECLARE_MUTEX(raw3270_init_sem); 491static DECLARE_MUTEX(raw3270_init_sem);
491 492
@@ -644,17 +645,17 @@ __raw3270_size_device(struct raw3270 *rp)
644 * required (3270 device switched to 'stand-by') and command 645 * required (3270 device switched to 'stand-by') and command
645 * rejects (old devices that can't do 'read partition'). 646 * rejects (old devices that can't do 'read partition').
646 */ 647 */
647 memset(&raw3270_init_request, 0, sizeof(raw3270_init_request)); 648 memset(&rp->init_request, 0, sizeof(rp->init_request));
648 memset(raw3270_init_data, 0, sizeof(raw3270_init_data)); 649 memset(&rp->init_data, 0, 256);
649 /* Store 'read partition' data stream to raw3270_init_data */ 650 /* Store 'read partition' data stream to init_data */
650 memcpy(raw3270_init_data, wbuf, sizeof(wbuf)); 651 memcpy(&rp->init_data, wbuf, sizeof(wbuf));
651 INIT_LIST_HEAD(&raw3270_init_request.list); 652 INIT_LIST_HEAD(&rp->init_request.list);
652 raw3270_init_request.ccw.cmd_code = TC_WRITESF; 653 rp->init_request.ccw.cmd_code = TC_WRITESF;
653 raw3270_init_request.ccw.flags = CCW_FLAG_SLI; 654 rp->init_request.ccw.flags = CCW_FLAG_SLI;
654 raw3270_init_request.ccw.count = sizeof(wbuf); 655 rp->init_request.ccw.count = sizeof(wbuf);
655 raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data); 656 rp->init_request.ccw.cda = (__u32) __pa(&rp->init_data);
656 657
657 rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request); 658 rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request);
658 if (rc) 659 if (rc)
659 /* Check error cases: -ERESTARTSYS, -EIO and -EOPNOTSUPP */ 660 /* Check error cases: -ERESTARTSYS, -EIO and -EOPNOTSUPP */
660 return rc; 661 return rc;
@@ -679,18 +680,18 @@ __raw3270_size_device(struct raw3270 *rp)
679 * The device accepted the 'read partition' command. Now 680 * The device accepted the 'read partition' command. Now
680 * set up a read ccw and issue it. 681 * set up a read ccw and issue it.
681 */ 682 */
682 raw3270_init_request.ccw.cmd_code = TC_READMOD; 683 rp->init_request.ccw.cmd_code = TC_READMOD;
683 raw3270_init_request.ccw.flags = CCW_FLAG_SLI; 684 rp->init_request.ccw.flags = CCW_FLAG_SLI;
684 raw3270_init_request.ccw.count = sizeof(raw3270_init_data); 685 rp->init_request.ccw.count = sizeof(rp->init_data);
685 raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data); 686 rp->init_request.ccw.cda = (__u32) __pa(rp->init_data);
686 rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request); 687 rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request);
687 if (rc) 688 if (rc)
688 return rc; 689 return rc;
689 /* Got a Query Reply */ 690 /* Got a Query Reply */
690 count = sizeof(raw3270_init_data) - raw3270_init_request.rescnt; 691 count = sizeof(rp->init_data) - rp->init_request.rescnt;
691 uap = (struct raw3270_ua *) (raw3270_init_data + 1); 692 uap = (struct raw3270_ua *) (rp->init_data + 1);
692 /* Paranoia check. */ 693 /* Paranoia check. */
693 if (raw3270_init_data[0] != 0x88 || uap->uab.qcode != 0x81) 694 if (rp->init_data[0] != 0x88 || uap->uab.qcode != 0x81)
694 return -EOPNOTSUPP; 695 return -EOPNOTSUPP;
695 /* Copy rows/columns of default Usable Area */ 696 /* Copy rows/columns of default Usable Area */
696 rp->rows = uap->uab.h; 697 rp->rows = uap->uab.h;
@@ -749,18 +750,18 @@ raw3270_reset_device(struct raw3270 *rp)
749 int rc; 750 int rc;
750 751
751 down(&raw3270_init_sem); 752 down(&raw3270_init_sem);
752 memset(&raw3270_init_request, 0, sizeof(raw3270_init_request)); 753 memset(&rp->init_request, 0, sizeof(rp->init_request));
753 memset(raw3270_init_data, 0, sizeof(raw3270_init_data)); 754 memset(&rp->init_data, 0, sizeof(rp->init_data));
754 /* Store reset data stream to raw3270_init_data/raw3270_init_request */ 755 /* Store reset data stream to init_data/init_request */
755 raw3270_init_data[0] = TW_KR; 756 rp->init_data[0] = TW_KR;
756 INIT_LIST_HEAD(&raw3270_init_request.list); 757 INIT_LIST_HEAD(&rp->init_request.list);
757 raw3270_init_request.ccw.cmd_code = TC_EWRITEA; 758 rp->init_request.ccw.cmd_code = TC_EWRITEA;
758 raw3270_init_request.ccw.flags = CCW_FLAG_SLI; 759 rp->init_request.ccw.flags = CCW_FLAG_SLI;
759 raw3270_init_request.ccw.count = 1; 760 rp->init_request.ccw.count = 1;
760 raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data); 761 rp->init_request.ccw.cda = (__u32) __pa(rp->init_data);
761 rp->view = &raw3270_init_view; 762 rp->view = &raw3270_init_view;
762 raw3270_init_view.dev = rp; 763 raw3270_init_view.dev = rp;
763 rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request); 764 rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request);
764 raw3270_init_view.dev = 0; 765 raw3270_init_view.dev = 0;
765 rp->view = 0; 766 rp->view = 0;
766 up(&raw3270_init_sem); 767 up(&raw3270_init_sem);
@@ -854,7 +855,7 @@ raw3270_setup_console(struct ccw_device *cdev)
854 char *ascebc; 855 char *ascebc;
855 int rc; 856 int rc;
856 857
857 rp = (struct raw3270 *) alloc_bootmem(sizeof(struct raw3270)); 858 rp = (struct raw3270 *) alloc_bootmem_low(sizeof(struct raw3270));
858 ascebc = (char *) alloc_bootmem(256); 859 ascebc = (char *) alloc_bootmem(256);
859 rc = raw3270_setup_device(cdev, rp, ascebc); 860 rc = raw3270_setup_device(cdev, rp, ascebc);
860 if (rc) 861 if (rc)
@@ -895,7 +896,7 @@ raw3270_create_device(struct ccw_device *cdev)
895 char *ascebc; 896 char *ascebc;
896 int rc; 897 int rc;
897 898
898 rp = kmalloc(sizeof(struct raw3270), GFP_KERNEL); 899 rp = kmalloc(sizeof(struct raw3270), GFP_KERNEL | GFP_DMA);
899 if (!rp) 900 if (!rp)
900 return ERR_PTR(-ENOMEM); 901 return ERR_PTR(-ENOMEM);
901 ascebc = kmalloc(256, GFP_KERNEL); 902 ascebc = kmalloc(256, GFP_KERNEL);
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 9a141776873f..7d26a3e4cb80 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -1785,7 +1785,6 @@ tty3270_init(void)
1785 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc 1785 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
1786 */ 1786 */
1787 driver->owner = THIS_MODULE; 1787 driver->owner = THIS_MODULE;
1788 driver->devfs_name = "ttyTUB/";
1789 driver->driver_name = "ttyTUB"; 1788 driver->driver_name = "ttyTUB";
1790 driver->name = "ttyTUB"; 1789 driver->name = "ttyTUB";
1791 driver->major = IBM_TTY3270_MAJOR; 1790 driver->major = IBM_TTY3270_MAJOR;
@@ -1793,7 +1792,7 @@ tty3270_init(void)
1793 driver->type = TTY_DRIVER_TYPE_SYSTEM; 1792 driver->type = TTY_DRIVER_TYPE_SYSTEM;
1794 driver->subtype = SYSTEM_TYPE_TTY; 1793 driver->subtype = SYSTEM_TYPE_TTY;
1795 driver->init_termios = tty_std_termios; 1794 driver->init_termios = tty_std_termios;
1796 driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_NO_DEVFS; 1795 driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_DYNAMIC_DEV;
1797 tty_set_operations(driver, &tty3270_ops); 1796 tty_set_operations(driver, &tty3270_ops);
1798 ret = tty_register_driver(driver); 1797 ret = tty_register_driver(driver);
1799 if (ret) { 1798 if (ret) {
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 0960bef7b199..15b895496a45 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -224,39 +224,6 @@ is_blacklisted (int ssid, int devno)
224} 224}
225 225
226#ifdef CONFIG_PROC_FS 226#ifdef CONFIG_PROC_FS
227static int
228__s390_redo_validation(struct subchannel_id schid, void *data)
229{
230 int ret;
231 struct subchannel *sch;
232
233 sch = get_subchannel_by_schid(schid);
234 if (sch) {
235 /* Already known. */
236 put_device(&sch->dev);
237 return 0;
238 }
239 ret = css_probe_device(schid);
240 if (ret == -ENXIO)
241 return ret; /* We're through. */
242 if (ret == -ENOMEM)
243 /* Stop validation for now. Bad, but no need for a panic. */
244 return ret;
245 return 0;
246}
247
248/*
249 * Function: s390_redo_validation
250 * Look for no longer blacklisted devices
251 * FIXME: there must be a better way to do this */
252static inline void
253s390_redo_validation (void)
254{
255 CIO_TRACE_EVENT (0, "redoval");
256
257 for_each_subchannel(__s390_redo_validation, NULL);
258}
259
260/* 227/*
261 * Function: blacklist_parse_proc_parameters 228 * Function: blacklist_parse_proc_parameters
262 * parse the stuff which is piped to /proc/cio_ignore 229 * parse the stuff which is piped to /proc/cio_ignore
@@ -281,7 +248,7 @@ blacklist_parse_proc_parameters (char *buf)
281 return; 248 return;
282 } 249 }
283 250
284 s390_redo_validation (); 251 css_schedule_reprobe();
285} 252}
286 253
287/* Iterator struct for all devices. */ 254/* Iterator struct for all devices. */
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index bdfee7fbaa2e..c7319a07ba35 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -404,21 +404,24 @@ ccwgroup_driver_register (struct ccwgroup_driver *cdriver)
404} 404}
405 405
406static int 406static int
407__ccwgroup_driver_unregister_device(struct device *dev, void *data) 407__ccwgroup_match_all(struct device *dev, void *data)
408{ 408{
409 __ccwgroup_remove_symlinks(to_ccwgroupdev(dev)); 409 return 1;
410 device_unregister(dev);
411 put_device(dev);
412 return 0;
413} 410}
414 411
415void 412void
416ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver) 413ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver)
417{ 414{
415 struct device *dev;
416
418 /* We don't want ccwgroup devices to live longer than their driver. */ 417 /* We don't want ccwgroup devices to live longer than their driver. */
419 get_driver(&cdriver->driver); 418 get_driver(&cdriver->driver);
420 driver_for_each_device(&cdriver->driver, NULL, NULL, 419 while ((dev = driver_find_device(&cdriver->driver, NULL, NULL,
421 __ccwgroup_driver_unregister_device); 420 __ccwgroup_match_all))) {
421 __ccwgroup_remove_symlinks(to_ccwgroupdev(dev));
422 device_unregister(dev);
423 put_device(dev);
424 }
422 put_driver(&cdriver->driver); 425 put_driver(&cdriver->driver);
423 driver_unregister(&cdriver->driver); 426 driver_unregister(&cdriver->driver);
424} 427}
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 72187e54dcac..b00f3ed051a0 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -244,8 +244,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
244 244
245 if ((sch->schib.scsw.actl & SCSW_ACTL_DEVACT) && 245 if ((sch->schib.scsw.actl & SCSW_ACTL_DEVACT) &&
246 (sch->schib.scsw.actl & SCSW_ACTL_SCHACT) && 246 (sch->schib.scsw.actl & SCSW_ACTL_SCHACT) &&
247 (sch->schib.pmcw.lpum == mask) && 247 (sch->schib.pmcw.lpum == mask)) {
248 (sch->vpm == 0)) {
249 int cc; 248 int cc;
250 249
251 cc = cio_clear(sch); 250 cc = cio_clear(sch);
@@ -918,12 +917,13 @@ chp_measurement_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
918 chp = to_channelpath(container_of(kobj, struct device, kobj)); 917 chp = to_channelpath(container_of(kobj, struct device, kobj));
919 css = to_css(chp->dev.parent); 918 css = to_css(chp->dev.parent);
920 919
921 size = sizeof(struct cmg_chars); 920 size = sizeof(struct cmg_entry);
922 921
923 /* Only allow single reads. */ 922 /* Only allow single reads. */
924 if (off || count < size) 923 if (off || count < size)
925 return 0; 924 return 0;
926 chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->id); 925 chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->id);
926 count = size;
927 return count; 927 return count;
928} 928}
929 929
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 07ef3f640f4a..1c3e8e9012b0 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -3,9 +3,10 @@
3 * 3 *
4 * Linux on zSeries Channel Measurement Facility support 4 * Linux on zSeries Channel Measurement Facility support
5 * 5 *
6 * Copyright 2000,2003 IBM Corporation 6 * Copyright 2000,2006 IBM Corporation
7 * 7 *
8 * Author: Arnd Bergmann <arndb@de.ibm.com> 8 * Authors: Arnd Bergmann <arndb@de.ibm.com>
9 * Cornelia Huck <cornelia.huck@de.ibm.com>
9 * 10 *
10 * original idea from Natarajan Krishnaswami <nkrishna@us.ibm.com> 11 * original idea from Natarajan Krishnaswami <nkrishna@us.ibm.com>
11 * 12 *
@@ -96,9 +97,9 @@ module_param(format, bool, 0444);
96/** 97/**
97 * struct cmb_operations - functions to use depending on cmb_format 98 * struct cmb_operations - functions to use depending on cmb_format
98 * 99 *
99 * all these functions operate on a struct cmf_device. There is only 100 * Most of these functions operate on a struct ccw_device. There is only
100 * one instance of struct cmb_operations because all cmf_device 101 * one instance of struct cmb_operations because the format of the measurement
101 * objects are guaranteed to be of the same type. 102 * data is guaranteed to be the same for every ccw_device.
102 * 103 *
103 * @alloc: allocate memory for a channel measurement block, 104 * @alloc: allocate memory for a channel measurement block,
104 * either with the help of a special pool or with kmalloc 105 * either with the help of a special pool or with kmalloc
@@ -107,6 +108,7 @@ module_param(format, bool, 0444);
107 * @readall: read a measurement block in a common format 108 * @readall: read a measurement block in a common format
108 * @reset: clear the data in the associated measurement block and 109 * @reset: clear the data in the associated measurement block and
109 * reset its time stamp 110 * reset its time stamp
111 * @align: align an allocated block so that the hardware can use it
110 */ 112 */
111struct cmb_operations { 113struct cmb_operations {
112 int (*alloc) (struct ccw_device*); 114 int (*alloc) (struct ccw_device*);
@@ -115,11 +117,19 @@ struct cmb_operations {
115 u64 (*read) (struct ccw_device*, int); 117 u64 (*read) (struct ccw_device*, int);
116 int (*readall)(struct ccw_device*, struct cmbdata *); 118 int (*readall)(struct ccw_device*, struct cmbdata *);
117 void (*reset) (struct ccw_device*); 119 void (*reset) (struct ccw_device*);
120 void * (*align) (void *);
118 121
119 struct attribute_group *attr_group; 122 struct attribute_group *attr_group;
120}; 123};
121static struct cmb_operations *cmbops; 124static struct cmb_operations *cmbops;
122 125
126struct cmb_data {
127 void *hw_block; /* Pointer to block updated by hardware */
128 void *last_block; /* Last changed block copied from hardware block */
129 int size; /* Size of hw_block and last_block */
130 unsigned long long last_update; /* when last_block was updated */
131};
132
123/* our user interface is designed in terms of nanoseconds, 133/* our user interface is designed in terms of nanoseconds,
124 * while the hardware measures total times in its own 134 * while the hardware measures total times in its own
125 * unit.*/ 135 * unit.*/
@@ -226,63 +236,229 @@ struct set_schib_struct {
226 unsigned long address; 236 unsigned long address;
227 wait_queue_head_t wait; 237 wait_queue_head_t wait;
228 int ret; 238 int ret;
239 struct kref kref;
229}; 240};
230 241
242static void cmf_set_schib_release(struct kref *kref)
243{
244 struct set_schib_struct *set_data;
245
246 set_data = container_of(kref, struct set_schib_struct, kref);
247 kfree(set_data);
248}
249
250#define CMF_PENDING 1
251
231static int set_schib_wait(struct ccw_device *cdev, u32 mme, 252static int set_schib_wait(struct ccw_device *cdev, u32 mme,
232 int mbfc, unsigned long address) 253 int mbfc, unsigned long address)
233{ 254{
234 struct set_schib_struct s = { 255 struct set_schib_struct *set_data;
235 .mme = mme, 256 int ret;
236 .mbfc = mbfc,
237 .address = address,
238 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s.wait),
239 };
240 257
241 spin_lock_irq(cdev->ccwlock); 258 spin_lock_irq(cdev->ccwlock);
242 s.ret = set_schib(cdev, mme, mbfc, address); 259 if (!cdev->private->cmb) {
243 if (s.ret != -EBUSY) { 260 ret = -ENODEV;
244 goto out_nowait; 261 goto out;
245 } 262 }
263 set_data = kzalloc(sizeof(struct set_schib_struct), GFP_ATOMIC);
264 if (!set_data) {
265 ret = -ENOMEM;
266 goto out;
267 }
268 init_waitqueue_head(&set_data->wait);
269 kref_init(&set_data->kref);
270 set_data->mme = mme;
271 set_data->mbfc = mbfc;
272 set_data->address = address;
273
274 ret = set_schib(cdev, mme, mbfc, address);
275 if (ret != -EBUSY)
276 goto out_put;
246 277
247 if (cdev->private->state != DEV_STATE_ONLINE) { 278 if (cdev->private->state != DEV_STATE_ONLINE) {
248 s.ret = -EBUSY;
249 /* if the device is not online, don't even try again */ 279 /* if the device is not online, don't even try again */
250 goto out_nowait; 280 ret = -EBUSY;
281 goto out_put;
251 } 282 }
283
252 cdev->private->state = DEV_STATE_CMFCHANGE; 284 cdev->private->state = DEV_STATE_CMFCHANGE;
253 cdev->private->cmb_wait = &s; 285 set_data->ret = CMF_PENDING;
254 s.ret = 1; 286 cdev->private->cmb_wait = set_data;
255 287
256 spin_unlock_irq(cdev->ccwlock); 288 spin_unlock_irq(cdev->ccwlock);
257 if (wait_event_interruptible(s.wait, s.ret != 1)) { 289 if (wait_event_interruptible(set_data->wait,
290 set_data->ret != CMF_PENDING)) {
258 spin_lock_irq(cdev->ccwlock); 291 spin_lock_irq(cdev->ccwlock);
259 if (s.ret == 1) { 292 if (set_data->ret == CMF_PENDING) {
260 s.ret = -ERESTARTSYS; 293 set_data->ret = -ERESTARTSYS;
261 cdev->private->cmb_wait = 0;
262 if (cdev->private->state == DEV_STATE_CMFCHANGE) 294 if (cdev->private->state == DEV_STATE_CMFCHANGE)
263 cdev->private->state = DEV_STATE_ONLINE; 295 cdev->private->state = DEV_STATE_ONLINE;
264 } 296 }
265 spin_unlock_irq(cdev->ccwlock); 297 spin_unlock_irq(cdev->ccwlock);
266 } 298 }
267 return s.ret; 299 spin_lock_irq(cdev->ccwlock);
268 300 cdev->private->cmb_wait = NULL;
269out_nowait: 301 ret = set_data->ret;
302out_put:
303 kref_put(&set_data->kref, cmf_set_schib_release);
304out:
270 spin_unlock_irq(cdev->ccwlock); 305 spin_unlock_irq(cdev->ccwlock);
271 return s.ret; 306 return ret;
272} 307}
273 308
274void retry_set_schib(struct ccw_device *cdev) 309void retry_set_schib(struct ccw_device *cdev)
275{ 310{
276 struct set_schib_struct *s; 311 struct set_schib_struct *set_data;
312
313 set_data = cdev->private->cmb_wait;
314 if (!set_data) {
315 WARN_ON(1);
316 return;
317 }
318 kref_get(&set_data->kref);
319 set_data->ret = set_schib(cdev, set_data->mme, set_data->mbfc,
320 set_data->address);
321 wake_up(&set_data->wait);
322 kref_put(&set_data->kref, cmf_set_schib_release);
323}
324
325static int cmf_copy_block(struct ccw_device *cdev)
326{
327 struct subchannel *sch;
328 void *reference_buf;
329 void *hw_block;
330 struct cmb_data *cmb_data;
331
332 sch = to_subchannel(cdev->dev.parent);
333
334 if (stsch(sch->schid, &sch->schib))
335 return -ENODEV;
336
337 if (sch->schib.scsw.fctl & SCSW_FCTL_START_FUNC) {
338 /* Don't copy if a start function is in progress. */
339 if ((!sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED) &&
340 (sch->schib.scsw.actl &
341 (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) &&
342 (!sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS))
343 return -EBUSY;
344 }
345 cmb_data = cdev->private->cmb;
346 hw_block = cmbops->align(cmb_data->hw_block);
347 if (!memcmp(cmb_data->last_block, hw_block, cmb_data->size))
348 /* No need to copy. */
349 return 0;
350 reference_buf = kzalloc(cmb_data->size, GFP_ATOMIC);
351 if (!reference_buf)
352 return -ENOMEM;
353 /* Ensure consistency of block copied from hardware. */
354 do {
355 memcpy(cmb_data->last_block, hw_block, cmb_data->size);
356 memcpy(reference_buf, hw_block, cmb_data->size);
357 } while (memcmp(cmb_data->last_block, reference_buf, cmb_data->size));
358 cmb_data->last_update = get_clock();
359 kfree(reference_buf);
360 return 0;
361}
362
363struct copy_block_struct {
364 wait_queue_head_t wait;
365 int ret;
366 struct kref kref;
367};
368
369static void cmf_copy_block_release(struct kref *kref)
370{
371 struct copy_block_struct *copy_block;
372
373 copy_block = container_of(kref, struct copy_block_struct, kref);
374 kfree(copy_block);
375}
376
377static int cmf_cmb_copy_wait(struct ccw_device *cdev)
378{
379 struct copy_block_struct *copy_block;
380 int ret;
381 unsigned long flags;
382
383 spin_lock_irqsave(cdev->ccwlock, flags);
384 if (!cdev->private->cmb) {
385 ret = -ENODEV;
386 goto out;
387 }
388 copy_block = kzalloc(sizeof(struct copy_block_struct), GFP_ATOMIC);
389 if (!copy_block) {
390 ret = -ENOMEM;
391 goto out;
392 }
393 init_waitqueue_head(&copy_block->wait);
394 kref_init(&copy_block->kref);
395
396 ret = cmf_copy_block(cdev);
397 if (ret != -EBUSY)
398 goto out_put;
399
400 if (cdev->private->state != DEV_STATE_ONLINE) {
401 ret = -EBUSY;
402 goto out_put;
403 }
404
405 cdev->private->state = DEV_STATE_CMFUPDATE;
406 copy_block->ret = CMF_PENDING;
407 cdev->private->cmb_wait = copy_block;
408
409 spin_unlock_irqrestore(cdev->ccwlock, flags);
410 if (wait_event_interruptible(copy_block->wait,
411 copy_block->ret != CMF_PENDING)) {
412 spin_lock_irqsave(cdev->ccwlock, flags);
413 if (copy_block->ret == CMF_PENDING) {
414 copy_block->ret = -ERESTARTSYS;
415 if (cdev->private->state == DEV_STATE_CMFUPDATE)
416 cdev->private->state = DEV_STATE_ONLINE;
417 }
418 spin_unlock_irqrestore(cdev->ccwlock, flags);
419 }
420 spin_lock_irqsave(cdev->ccwlock, flags);
421 cdev->private->cmb_wait = NULL;
422 ret = copy_block->ret;
423out_put:
424 kref_put(&copy_block->kref, cmf_copy_block_release);
425out:
426 spin_unlock_irqrestore(cdev->ccwlock, flags);
427 return ret;
428}
429
430void cmf_retry_copy_block(struct ccw_device *cdev)
431{
432 struct copy_block_struct *copy_block;
277 433
278 s = cdev->private->cmb_wait; 434 copy_block = cdev->private->cmb_wait;
279 cdev->private->cmb_wait = 0; 435 if (!copy_block) {
280 if (!s) {
281 WARN_ON(1); 436 WARN_ON(1);
282 return; 437 return;
283 } 438 }
284 s->ret = set_schib(cdev, s->mme, s->mbfc, s->address); 439 kref_get(&copy_block->kref);
285 wake_up(&s->wait); 440 copy_block->ret = cmf_copy_block(cdev);
441 wake_up(&copy_block->wait);
442 kref_put(&copy_block->kref, cmf_copy_block_release);
443}
444
445static void cmf_generic_reset(struct ccw_device *cdev)
446{
447 struct cmb_data *cmb_data;
448
449 spin_lock_irq(cdev->ccwlock);
450 cmb_data = cdev->private->cmb;
451 if (cmb_data) {
452 memset(cmb_data->last_block, 0, cmb_data->size);
453 /*
454 * Need to reset hw block as well to make the hardware start
455 * from 0 again.
456 */
457 memset(cmbops->align(cmb_data->hw_block), 0, cmb_data->size);
458 cmb_data->last_update = 0;
459 }
460 cdev->private->cmb_start_time = get_clock();
461 spin_unlock_irq(cdev->ccwlock);
286} 462}
287 463
288/** 464/**
@@ -343,8 +519,8 @@ struct cmb {
343/* insert a single device into the cmb_area list 519/* insert a single device into the cmb_area list
344 * called with cmb_area.lock held from alloc_cmb 520 * called with cmb_area.lock held from alloc_cmb
345 */ 521 */
346static inline int 522static inline int alloc_cmb_single (struct ccw_device *cdev,
347alloc_cmb_single (struct ccw_device *cdev) 523 struct cmb_data *cmb_data)
348{ 524{
349 struct cmb *cmb; 525 struct cmb *cmb;
350 struct ccw_device_private *node; 526 struct ccw_device_private *node;
@@ -358,10 +534,12 @@ alloc_cmb_single (struct ccw_device *cdev)
358 534
359 /* find first unused cmb in cmb_area.mem. 535 /* find first unused cmb in cmb_area.mem.
360 * this is a little tricky: cmb_area.list 536 * this is a little tricky: cmb_area.list
361 * remains sorted by ->cmb pointers */ 537 * remains sorted by ->cmb->hw_data pointers */
362 cmb = cmb_area.mem; 538 cmb = cmb_area.mem;
363 list_for_each_entry(node, &cmb_area.list, cmb_list) { 539 list_for_each_entry(node, &cmb_area.list, cmb_list) {
364 if ((struct cmb*)node->cmb > cmb) 540 struct cmb_data *data;
541 data = node->cmb;
542 if ((struct cmb*)data->hw_block > cmb)
365 break; 543 break;
366 cmb++; 544 cmb++;
367 } 545 }
@@ -372,7 +550,8 @@ alloc_cmb_single (struct ccw_device *cdev)
372 550
373 /* insert new cmb */ 551 /* insert new cmb */
374 list_add_tail(&cdev->private->cmb_list, &node->cmb_list); 552 list_add_tail(&cdev->private->cmb_list, &node->cmb_list);
375 cdev->private->cmb = cmb; 553 cmb_data->hw_block = cmb;
554 cdev->private->cmb = cmb_data;
376 ret = 0; 555 ret = 0;
377out: 556out:
378 spin_unlock_irq(cdev->ccwlock); 557 spin_unlock_irq(cdev->ccwlock);
@@ -385,7 +564,19 @@ alloc_cmb (struct ccw_device *cdev)
385 int ret; 564 int ret;
386 struct cmb *mem; 565 struct cmb *mem;
387 ssize_t size; 566 ssize_t size;
567 struct cmb_data *cmb_data;
568
569 /* Allocate private cmb_data. */
570 cmb_data = kzalloc(sizeof(struct cmb_data), GFP_KERNEL);
571 if (!cmb_data)
572 return -ENOMEM;
388 573
574 cmb_data->last_block = kzalloc(sizeof(struct cmb), GFP_KERNEL);
575 if (!cmb_data->last_block) {
576 kfree(cmb_data);
577 return -ENOMEM;
578 }
579 cmb_data->size = sizeof(struct cmb);
389 spin_lock(&cmb_area.lock); 580 spin_lock(&cmb_area.lock);
390 581
391 if (!cmb_area.mem) { 582 if (!cmb_area.mem) {
@@ -414,29 +605,36 @@ alloc_cmb (struct ccw_device *cdev)
414 } 605 }
415 606
416 /* do the actual allocation */ 607 /* do the actual allocation */
417 ret = alloc_cmb_single(cdev); 608 ret = alloc_cmb_single(cdev, cmb_data);
418out: 609out:
419 spin_unlock(&cmb_area.lock); 610 spin_unlock(&cmb_area.lock);
420 611 if (ret) {
612 kfree(cmb_data->last_block);
613 kfree(cmb_data);
614 }
421 return ret; 615 return ret;
422} 616}
423 617
424static void 618static void free_cmb(struct ccw_device *cdev)
425free_cmb(struct ccw_device *cdev)
426{ 619{
427 struct ccw_device_private *priv; 620 struct ccw_device_private *priv;
428 621 struct cmb_data *cmb_data;
429 priv = cdev->private;
430 622
431 spin_lock(&cmb_area.lock); 623 spin_lock(&cmb_area.lock);
432 spin_lock_irq(cdev->ccwlock); 624 spin_lock_irq(cdev->ccwlock);
433 625
626 priv = cdev->private;
627
434 if (list_empty(&priv->cmb_list)) { 628 if (list_empty(&priv->cmb_list)) {
435 /* already freed */ 629 /* already freed */
436 goto out; 630 goto out;
437 } 631 }
438 632
633 cmb_data = priv->cmb;
439 priv->cmb = NULL; 634 priv->cmb = NULL;
635 if (cmb_data)
636 kfree(cmb_data->last_block);
637 kfree(cmb_data);
440 list_del_init(&priv->cmb_list); 638 list_del_init(&priv->cmb_list);
441 639
442 if (list_empty(&cmb_area.list)) { 640 if (list_empty(&cmb_area.list)) {
@@ -451,83 +649,97 @@ out:
451 spin_unlock(&cmb_area.lock); 649 spin_unlock(&cmb_area.lock);
452} 650}
453 651
454static int 652static int set_cmb(struct ccw_device *cdev, u32 mme)
455set_cmb(struct ccw_device *cdev, u32 mme)
456{ 653{
457 u16 offset; 654 u16 offset;
655 struct cmb_data *cmb_data;
656 unsigned long flags;
458 657
459 if (!cdev->private->cmb) 658 spin_lock_irqsave(cdev->ccwlock, flags);
659 if (!cdev->private->cmb) {
660 spin_unlock_irqrestore(cdev->ccwlock, flags);
460 return -EINVAL; 661 return -EINVAL;
461 662 }
462 offset = mme ? (struct cmb *)cdev->private->cmb - cmb_area.mem : 0; 663 cmb_data = cdev->private->cmb;
664 offset = mme ? (struct cmb *)cmb_data->hw_block - cmb_area.mem : 0;
665 spin_unlock_irqrestore(cdev->ccwlock, flags);
463 666
464 return set_schib_wait(cdev, mme, 0, offset); 667 return set_schib_wait(cdev, mme, 0, offset);
465} 668}
466 669
467static u64 670static u64 read_cmb (struct ccw_device *cdev, int index)
468read_cmb (struct ccw_device *cdev, int index)
469{ 671{
470 /* yes, we have to put it on the stack 672 struct cmb *cmb;
471 * because the cmb must only be accessed
472 * atomically, e.g. with mvc */
473 struct cmb cmb;
474 unsigned long flags;
475 u32 val; 673 u32 val;
674 int ret;
675 unsigned long flags;
676
677 ret = cmf_cmb_copy_wait(cdev);
678 if (ret < 0)
679 return 0;
476 680
477 spin_lock_irqsave(cdev->ccwlock, flags); 681 spin_lock_irqsave(cdev->ccwlock, flags);
478 if (!cdev->private->cmb) { 682 if (!cdev->private->cmb) {
479 spin_unlock_irqrestore(cdev->ccwlock, flags); 683 ret = 0;
480 return 0; 684 goto out;
481 } 685 }
482 686 cmb = ((struct cmb_data *)cdev->private->cmb)->last_block;
483 cmb = *(struct cmb*)cdev->private->cmb;
484 spin_unlock_irqrestore(cdev->ccwlock, flags);
485 687
486 switch (index) { 688 switch (index) {
487 case cmb_ssch_rsch_count: 689 case cmb_ssch_rsch_count:
488 return cmb.ssch_rsch_count; 690 ret = cmb->ssch_rsch_count;
691 goto out;
489 case cmb_sample_count: 692 case cmb_sample_count:
490 return cmb.sample_count; 693 ret = cmb->sample_count;
694 goto out;
491 case cmb_device_connect_time: 695 case cmb_device_connect_time:
492 val = cmb.device_connect_time; 696 val = cmb->device_connect_time;
493 break; 697 break;
494 case cmb_function_pending_time: 698 case cmb_function_pending_time:
495 val = cmb.function_pending_time; 699 val = cmb->function_pending_time;
496 break; 700 break;
497 case cmb_device_disconnect_time: 701 case cmb_device_disconnect_time:
498 val = cmb.device_disconnect_time; 702 val = cmb->device_disconnect_time;
499 break; 703 break;
500 case cmb_control_unit_queuing_time: 704 case cmb_control_unit_queuing_time:
501 val = cmb.control_unit_queuing_time; 705 val = cmb->control_unit_queuing_time;
502 break; 706 break;
503 case cmb_device_active_only_time: 707 case cmb_device_active_only_time:
504 val = cmb.device_active_only_time; 708 val = cmb->device_active_only_time;
505 break; 709 break;
506 default: 710 default:
507 return 0; 711 ret = 0;
712 goto out;
508 } 713 }
509 return time_to_avg_nsec(val, cmb.sample_count); 714 ret = time_to_avg_nsec(val, cmb->sample_count);
715out:
716 spin_unlock_irqrestore(cdev->ccwlock, flags);
717 return ret;
510} 718}
511 719
512static int 720static int readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
513readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
514{ 721{
515 /* yes, we have to put it on the stack 722 struct cmb *cmb;
516 * because the cmb must only be accessed 723 struct cmb_data *cmb_data;
517 * atomically, e.g. with mvc */
518 struct cmb cmb;
519 unsigned long flags;
520 u64 time; 724 u64 time;
725 unsigned long flags;
726 int ret;
521 727
728 ret = cmf_cmb_copy_wait(cdev);
729 if (ret < 0)
730 return ret;
522 spin_lock_irqsave(cdev->ccwlock, flags); 731 spin_lock_irqsave(cdev->ccwlock, flags);
523 if (!cdev->private->cmb) { 732 cmb_data = cdev->private->cmb;
524 spin_unlock_irqrestore(cdev->ccwlock, flags); 733 if (!cmb_data) {
525 return -ENODEV; 734 ret = -ENODEV;
735 goto out;
526 } 736 }
527 737 if (cmb_data->last_update == 0) {
528 cmb = *(struct cmb*)cdev->private->cmb; 738 ret = -EAGAIN;
529 time = get_clock() - cdev->private->cmb_start_time; 739 goto out;
530 spin_unlock_irqrestore(cdev->ccwlock, flags); 740 }
741 cmb = cmb_data->last_block;
742 time = cmb_data->last_update - cdev->private->cmb_start_time;
531 743
532 memset(data, 0, sizeof(struct cmbdata)); 744 memset(data, 0, sizeof(struct cmbdata));
533 745
@@ -538,31 +750,32 @@ readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
538 data->elapsed_time = (time * 1000) >> 12; 750 data->elapsed_time = (time * 1000) >> 12;
539 751
540 /* copy data to new structure */ 752 /* copy data to new structure */
541 data->ssch_rsch_count = cmb.ssch_rsch_count; 753 data->ssch_rsch_count = cmb->ssch_rsch_count;
542 data->sample_count = cmb.sample_count; 754 data->sample_count = cmb->sample_count;
543 755
544 /* time fields are converted to nanoseconds while copying */ 756 /* time fields are converted to nanoseconds while copying */
545 data->device_connect_time = time_to_nsec(cmb.device_connect_time); 757 data->device_connect_time = time_to_nsec(cmb->device_connect_time);
546 data->function_pending_time = time_to_nsec(cmb.function_pending_time); 758 data->function_pending_time = time_to_nsec(cmb->function_pending_time);
547 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time); 759 data->device_disconnect_time =
760 time_to_nsec(cmb->device_disconnect_time);
548 data->control_unit_queuing_time 761 data->control_unit_queuing_time
549 = time_to_nsec(cmb.control_unit_queuing_time); 762 = time_to_nsec(cmb->control_unit_queuing_time);
550 data->device_active_only_time 763 data->device_active_only_time
551 = time_to_nsec(cmb.device_active_only_time); 764 = time_to_nsec(cmb->device_active_only_time);
765 ret = 0;
766out:
767 spin_unlock_irqrestore(cdev->ccwlock, flags);
768 return ret;
769}
552 770
553 return 0; 771static void reset_cmb(struct ccw_device *cdev)
772{
773 cmf_generic_reset(cdev);
554} 774}
555 775
556static void 776static void * align_cmb(void *area)
557reset_cmb(struct ccw_device *cdev)
558{ 777{
559 struct cmb *cmb; 778 return area;
560 spin_lock_irq(cdev->ccwlock);
561 cmb = cdev->private->cmb;
562 if (cmb)
563 memset (cmb, 0, sizeof (*cmb));
564 cdev->private->cmb_start_time = get_clock();
565 spin_unlock_irq(cdev->ccwlock);
566} 779}
567 780
568static struct attribute_group cmf_attr_group; 781static struct attribute_group cmf_attr_group;
@@ -574,6 +787,7 @@ static struct cmb_operations cmbops_basic = {
574 .read = read_cmb, 787 .read = read_cmb,
575 .readall = readall_cmb, 788 .readall = readall_cmb,
576 .reset = reset_cmb, 789 .reset = reset_cmb,
790 .align = align_cmb,
577 .attr_group = &cmf_attr_group, 791 .attr_group = &cmf_attr_group,
578}; 792};
579 793
@@ -610,22 +824,34 @@ static inline struct cmbe* cmbe_align(struct cmbe *c)
610 return (struct cmbe*)addr; 824 return (struct cmbe*)addr;
611} 825}
612 826
613static int 827static int alloc_cmbe (struct ccw_device *cdev)
614alloc_cmbe (struct ccw_device *cdev)
615{ 828{
616 struct cmbe *cmbe; 829 struct cmbe *cmbe;
617 cmbe = kmalloc (sizeof (*cmbe) * 2, GFP_KERNEL); 830 struct cmb_data *cmb_data;
831 int ret;
832
833 cmbe = kzalloc (sizeof (*cmbe) * 2, GFP_KERNEL);
618 if (!cmbe) 834 if (!cmbe)
619 return -ENOMEM; 835 return -ENOMEM;
620 836 cmb_data = kzalloc(sizeof(struct cmb_data), GFP_KERNEL);
837 if (!cmb_data) {
838 ret = -ENOMEM;
839 goto out_free;
840 }
841 cmb_data->last_block = kzalloc(sizeof(struct cmbe), GFP_KERNEL);
842 if (!cmb_data->last_block) {
843 ret = -ENOMEM;
844 goto out_free;
845 }
846 cmb_data->size = sizeof(struct cmbe);
621 spin_lock_irq(cdev->ccwlock); 847 spin_lock_irq(cdev->ccwlock);
622 if (cdev->private->cmb) { 848 if (cdev->private->cmb) {
623 kfree(cmbe);
624 spin_unlock_irq(cdev->ccwlock); 849 spin_unlock_irq(cdev->ccwlock);
625 return -EBUSY; 850 ret = -EBUSY;
851 goto out_free;
626 } 852 }
627 853 cmb_data->hw_block = cmbe;
628 cdev->private->cmb = cmbe; 854 cdev->private->cmb = cmb_data;
629 spin_unlock_irq(cdev->ccwlock); 855 spin_unlock_irq(cdev->ccwlock);
630 856
631 /* activate global measurement if this is the first channel */ 857 /* activate global measurement if this is the first channel */
@@ -636,14 +862,24 @@ alloc_cmbe (struct ccw_device *cdev)
636 spin_unlock(&cmb_area.lock); 862 spin_unlock(&cmb_area.lock);
637 863
638 return 0; 864 return 0;
865out_free:
866 if (cmb_data)
867 kfree(cmb_data->last_block);
868 kfree(cmb_data);
869 kfree(cmbe);
870 return ret;
639} 871}
640 872
641static void 873static void free_cmbe (struct ccw_device *cdev)
642free_cmbe (struct ccw_device *cdev)
643{ 874{
875 struct cmb_data *cmb_data;
876
644 spin_lock_irq(cdev->ccwlock); 877 spin_lock_irq(cdev->ccwlock);
645 kfree(cdev->private->cmb); 878 cmb_data = cdev->private->cmb;
646 cdev->private->cmb = NULL; 879 cdev->private->cmb = NULL;
880 if (cmb_data)
881 kfree(cmb_data->last_block);
882 kfree(cmb_data);
647 spin_unlock_irq(cdev->ccwlock); 883 spin_unlock_irq(cdev->ccwlock);
648 884
649 /* deactivate global measurement if this is the last channel */ 885 /* deactivate global measurement if this is the last channel */
@@ -654,89 +890,105 @@ free_cmbe (struct ccw_device *cdev)
654 spin_unlock(&cmb_area.lock); 890 spin_unlock(&cmb_area.lock);
655} 891}
656 892
657static int 893static int set_cmbe(struct ccw_device *cdev, u32 mme)
658set_cmbe(struct ccw_device *cdev, u32 mme)
659{ 894{
660 unsigned long mba; 895 unsigned long mba;
896 struct cmb_data *cmb_data;
897 unsigned long flags;
661 898
662 if (!cdev->private->cmb) 899 spin_lock_irqsave(cdev->ccwlock, flags);
900 if (!cdev->private->cmb) {
901 spin_unlock_irqrestore(cdev->ccwlock, flags);
663 return -EINVAL; 902 return -EINVAL;
664 mba = mme ? (unsigned long) cmbe_align(cdev->private->cmb) : 0; 903 }
904 cmb_data = cdev->private->cmb;
905 mba = mme ? (unsigned long) cmbe_align(cmb_data->hw_block) : 0;
906 spin_unlock_irqrestore(cdev->ccwlock, flags);
665 907
666 return set_schib_wait(cdev, mme, 1, mba); 908 return set_schib_wait(cdev, mme, 1, mba);
667} 909}
668 910
669 911
670u64 912static u64 read_cmbe (struct ccw_device *cdev, int index)
671read_cmbe (struct ccw_device *cdev, int index)
672{ 913{
673 /* yes, we have to put it on the stack 914 struct cmbe *cmb;
674 * because the cmb must only be accessed 915 struct cmb_data *cmb_data;
675 * atomically, e.g. with mvc */
676 struct cmbe cmb;
677 unsigned long flags;
678 u32 val; 916 u32 val;
917 int ret;
918 unsigned long flags;
679 919
680 spin_lock_irqsave(cdev->ccwlock, flags); 920 ret = cmf_cmb_copy_wait(cdev);
681 if (!cdev->private->cmb) { 921 if (ret < 0)
682 spin_unlock_irqrestore(cdev->ccwlock, flags);
683 return 0; 922 return 0;
684 }
685 923
686 cmb = *cmbe_align(cdev->private->cmb); 924 spin_lock_irqsave(cdev->ccwlock, flags);
687 spin_unlock_irqrestore(cdev->ccwlock, flags); 925 cmb_data = cdev->private->cmb;
926 if (!cmb_data) {
927 ret = 0;
928 goto out;
929 }
930 cmb = cmb_data->last_block;
688 931
689 switch (index) { 932 switch (index) {
690 case cmb_ssch_rsch_count: 933 case cmb_ssch_rsch_count:
691 return cmb.ssch_rsch_count; 934 ret = cmb->ssch_rsch_count;
935 goto out;
692 case cmb_sample_count: 936 case cmb_sample_count:
693 return cmb.sample_count; 937 ret = cmb->sample_count;
938 goto out;
694 case cmb_device_connect_time: 939 case cmb_device_connect_time:
695 val = cmb.device_connect_time; 940 val = cmb->device_connect_time;
696 break; 941 break;
697 case cmb_function_pending_time: 942 case cmb_function_pending_time:
698 val = cmb.function_pending_time; 943 val = cmb->function_pending_time;
699 break; 944 break;
700 case cmb_device_disconnect_time: 945 case cmb_device_disconnect_time:
701 val = cmb.device_disconnect_time; 946 val = cmb->device_disconnect_time;
702 break; 947 break;
703 case cmb_control_unit_queuing_time: 948 case cmb_control_unit_queuing_time:
704 val = cmb.control_unit_queuing_time; 949 val = cmb->control_unit_queuing_time;
705 break; 950 break;
706 case cmb_device_active_only_time: 951 case cmb_device_active_only_time:
707 val = cmb.device_active_only_time; 952 val = cmb->device_active_only_time;
708 break; 953 break;
709 case cmb_device_busy_time: 954 case cmb_device_busy_time:
710 val = cmb.device_busy_time; 955 val = cmb->device_busy_time;
711 break; 956 break;
712 case cmb_initial_command_response_time: 957 case cmb_initial_command_response_time:
713 val = cmb.initial_command_response_time; 958 val = cmb->initial_command_response_time;
714 break; 959 break;
715 default: 960 default:
716 return 0; 961 ret = 0;
962 goto out;
717 } 963 }
718 return time_to_avg_nsec(val, cmb.sample_count); 964 ret = time_to_avg_nsec(val, cmb->sample_count);
965out:
966 spin_unlock_irqrestore(cdev->ccwlock, flags);
967 return ret;
719} 968}
720 969
721static int 970static int readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
722readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
723{ 971{
724 /* yes, we have to put it on the stack 972 struct cmbe *cmb;
725 * because the cmb must only be accessed 973 struct cmb_data *cmb_data;
726 * atomically, e.g. with mvc */
727 struct cmbe cmb;
728 unsigned long flags;
729 u64 time; 974 u64 time;
975 unsigned long flags;
976 int ret;
730 977
978 ret = cmf_cmb_copy_wait(cdev);
979 if (ret < 0)
980 return ret;
731 spin_lock_irqsave(cdev->ccwlock, flags); 981 spin_lock_irqsave(cdev->ccwlock, flags);
732 if (!cdev->private->cmb) { 982 cmb_data = cdev->private->cmb;
733 spin_unlock_irqrestore(cdev->ccwlock, flags); 983 if (!cmb_data) {
734 return -ENODEV; 984 ret = -ENODEV;
985 goto out;
735 } 986 }
736 987 if (cmb_data->last_update == 0) {
737 cmb = *cmbe_align(cdev->private->cmb); 988 ret = -EAGAIN;
738 time = get_clock() - cdev->private->cmb_start_time; 989 goto out;
739 spin_unlock_irqrestore(cdev->ccwlock, flags); 990 }
991 time = cmb_data->last_update - cdev->private->cmb_start_time;
740 992
741 memset (data, 0, sizeof(struct cmbdata)); 993 memset (data, 0, sizeof(struct cmbdata));
742 994
@@ -746,35 +998,38 @@ readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
746 /* conver to nanoseconds */ 998 /* conver to nanoseconds */
747 data->elapsed_time = (time * 1000) >> 12; 999 data->elapsed_time = (time * 1000) >> 12;
748 1000
1001 cmb = cmb_data->last_block;
749 /* copy data to new structure */ 1002 /* copy data to new structure */
750 data->ssch_rsch_count = cmb.ssch_rsch_count; 1003 data->ssch_rsch_count = cmb->ssch_rsch_count;
751 data->sample_count = cmb.sample_count; 1004 data->sample_count = cmb->sample_count;
752 1005
753 /* time fields are converted to nanoseconds while copying */ 1006 /* time fields are converted to nanoseconds while copying */
754 data->device_connect_time = time_to_nsec(cmb.device_connect_time); 1007 data->device_connect_time = time_to_nsec(cmb->device_connect_time);
755 data->function_pending_time = time_to_nsec(cmb.function_pending_time); 1008 data->function_pending_time = time_to_nsec(cmb->function_pending_time);
756 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time); 1009 data->device_disconnect_time =
1010 time_to_nsec(cmb->device_disconnect_time);
757 data->control_unit_queuing_time 1011 data->control_unit_queuing_time
758 = time_to_nsec(cmb.control_unit_queuing_time); 1012 = time_to_nsec(cmb->control_unit_queuing_time);
759 data->device_active_only_time 1013 data->device_active_only_time
760 = time_to_nsec(cmb.device_active_only_time); 1014 = time_to_nsec(cmb->device_active_only_time);
761 data->device_busy_time = time_to_nsec(cmb.device_busy_time); 1015 data->device_busy_time = time_to_nsec(cmb->device_busy_time);
762 data->initial_command_response_time 1016 data->initial_command_response_time
763 = time_to_nsec(cmb.initial_command_response_time); 1017 = time_to_nsec(cmb->initial_command_response_time);
764 1018
765 return 0; 1019 ret = 0;
1020out:
1021 spin_unlock_irqrestore(cdev->ccwlock, flags);
1022 return ret;
766} 1023}
767 1024
768static void 1025static void reset_cmbe(struct ccw_device *cdev)
769reset_cmbe(struct ccw_device *cdev)
770{ 1026{
771 struct cmbe *cmb; 1027 cmf_generic_reset(cdev);
772 spin_lock_irq(cdev->ccwlock); 1028}
773 cmb = cmbe_align(cdev->private->cmb); 1029
774 if (cmb) 1030static void * align_cmbe(void *area)
775 memset (cmb, 0, sizeof (*cmb)); 1031{
776 cdev->private->cmb_start_time = get_clock(); 1032 return cmbe_align(area);
777 spin_unlock_irq(cdev->ccwlock);
778} 1033}
779 1034
780static struct attribute_group cmf_attr_group_ext; 1035static struct attribute_group cmf_attr_group_ext;
@@ -786,6 +1041,7 @@ static struct cmb_operations cmbops_extended = {
786 .read = read_cmbe, 1041 .read = read_cmbe,
787 .readall = readall_cmbe, 1042 .readall = readall_cmbe,
788 .reset = reset_cmbe, 1043 .reset = reset_cmbe,
1044 .align = align_cmbe,
789 .attr_group = &cmf_attr_group_ext, 1045 .attr_group = &cmf_attr_group_ext,
790}; 1046};
791 1047
@@ -803,14 +1059,19 @@ cmb_show_avg_sample_interval(struct device *dev, struct device_attribute *attr,
803 struct ccw_device *cdev; 1059 struct ccw_device *cdev;
804 long interval; 1060 long interval;
805 unsigned long count; 1061 unsigned long count;
1062 struct cmb_data *cmb_data;
806 1063
807 cdev = to_ccwdev(dev); 1064 cdev = to_ccwdev(dev);
808 interval = get_clock() - cdev->private->cmb_start_time;
809 count = cmf_read(cdev, cmb_sample_count); 1065 count = cmf_read(cdev, cmb_sample_count);
810 if (count) 1066 spin_lock_irq(cdev->ccwlock);
1067 cmb_data = cdev->private->cmb;
1068 if (count) {
1069 interval = cmb_data->last_update -
1070 cdev->private->cmb_start_time;
811 interval /= count; 1071 interval /= count;
812 else 1072 } else
813 interval = -1; 1073 interval = -1;
1074 spin_unlock_irq(cdev->ccwlock);
814 return sprintf(buf, "%ld\n", interval); 1075 return sprintf(buf, "%ld\n", interval);
815} 1076}
816 1077
@@ -823,7 +1084,10 @@ cmb_show_avg_utilization(struct device *dev, struct device_attribute *attr, char
823 int ret; 1084 int ret;
824 1085
825 ret = cmf_readall(to_ccwdev(dev), &data); 1086 ret = cmf_readall(to_ccwdev(dev), &data);
826 if (ret) 1087 if (ret == -EAGAIN || ret == -ENODEV)
1088 /* No data (yet/currently) available to use for calculation. */
1089 return sprintf(buf, "n/a\n");
1090 else if (ret)
827 return ret; 1091 return ret;
828 1092
829 utilization = data.device_connect_time + 1093 utilization = data.device_connect_time +
@@ -982,6 +1246,13 @@ cmf_readall(struct ccw_device *cdev, struct cmbdata *data)
982 return cmbops->readall(cdev, data); 1246 return cmbops->readall(cdev, data);
983} 1247}
984 1248
1249/* Reenable cmf when a disconnected device becomes available again. */
1250int cmf_reenable(struct ccw_device *cdev)
1251{
1252 cmbops->reset(cdev);
1253 return cmbops->set(cdev, 2);
1254}
1255
985static int __init 1256static int __init
986init_cmf(void) 1257init_cmf(void)
987{ 1258{
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 74ea8aac4b7d..1d3be80797f8 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -19,9 +19,11 @@
19#include "cio_debug.h" 19#include "cio_debug.h"
20#include "ioasm.h" 20#include "ioasm.h"
21#include "chsc.h" 21#include "chsc.h"
22#include "device.h"
22 23
23int need_rescan = 0; 24int need_rescan = 0;
24int css_init_done = 0; 25int css_init_done = 0;
26static int need_reprobe = 0;
25static int max_ssid = 0; 27static int max_ssid = 0;
26 28
27struct channel_subsystem *css[__MAX_CSSID + 1]; 29struct channel_subsystem *css[__MAX_CSSID + 1];
@@ -339,6 +341,67 @@ typedef void (*workfunc)(void *);
339DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL); 341DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL);
340struct workqueue_struct *slow_path_wq; 342struct workqueue_struct *slow_path_wq;
341 343
344/* Reprobe subchannel if unregistered. */
345static int reprobe_subchannel(struct subchannel_id schid, void *data)
346{
347 struct subchannel *sch;
348 int ret;
349
350 CIO_DEBUG(KERN_INFO, 6, "cio: reprobe 0.%x.%04x\n",
351 schid.ssid, schid.sch_no);
352 if (need_reprobe)
353 return -EAGAIN;
354
355 sch = get_subchannel_by_schid(schid);
356 if (sch) {
357 /* Already known. */
358 put_device(&sch->dev);
359 return 0;
360 }
361
362 ret = css_probe_device(schid);
363 switch (ret) {
364 case 0:
365 break;
366 case -ENXIO:
367 case -ENOMEM:
368 /* These should abort looping */
369 break;
370 default:
371 ret = 0;
372 }
373
374 return ret;
375}
376
377/* Work function used to reprobe all unregistered subchannels. */
378static void reprobe_all(void *data)
379{
380 int ret;
381
382 CIO_MSG_EVENT(2, "reprobe start\n");
383
384 need_reprobe = 0;
385 /* Make sure initial subchannel scan is done. */
386 wait_event(ccw_device_init_wq,
387 atomic_read(&ccw_device_init_count) == 0);
388 ret = for_each_subchannel(reprobe_subchannel, NULL);
389
390 CIO_MSG_EVENT(2, "reprobe done (rc=%d, need_reprobe=%d)\n", ret,
391 need_reprobe);
392}
393
394DECLARE_WORK(css_reprobe_work, reprobe_all, NULL);
395
396/* Schedule reprobing of all unregistered subchannels. */
397void css_schedule_reprobe(void)
398{
399 need_reprobe = 1;
400 queue_work(ccw_device_work, &css_reprobe_work);
401}
402
403EXPORT_SYMBOL_GPL(css_schedule_reprobe);
404
342/* 405/*
343 * Rescan for new devices. FIXME: This is slow. 406 * Rescan for new devices. FIXME: This is slow.
344 * This function is called when we have lost CRWs due to overflows and we have 407 * This function is called when we have lost CRWs due to overflows and we have
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 8e3053c2a451..eafde43e8410 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -133,8 +133,8 @@ struct css_driver io_subchannel_driver = {
133 133
134struct workqueue_struct *ccw_device_work; 134struct workqueue_struct *ccw_device_work;
135struct workqueue_struct *ccw_device_notify_work; 135struct workqueue_struct *ccw_device_notify_work;
136static wait_queue_head_t ccw_device_init_wq; 136wait_queue_head_t ccw_device_init_wq;
137static atomic_t ccw_device_init_count; 137atomic_t ccw_device_init_count;
138 138
139static int __init 139static int __init
140init_ccw_bus_type (void) 140init_ccw_bus_type (void)
diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h
index 11587ebb7289..00be9a5b4acd 100644
--- a/drivers/s390/cio/device.h
+++ b/drivers/s390/cio/device.h
@@ -1,6 +1,10 @@
1#ifndef S390_DEVICE_H 1#ifndef S390_DEVICE_H
2#define S390_DEVICE_H 2#define S390_DEVICE_H
3 3
4#include <asm/ccwdev.h>
5#include <asm/atomic.h>
6#include <linux/wait.h>
7
4/* 8/*
5 * states of the device statemachine 9 * states of the device statemachine
6 */ 10 */
@@ -23,6 +27,7 @@ enum dev_state {
23 DEV_STATE_DISCONNECTED, 27 DEV_STATE_DISCONNECTED,
24 DEV_STATE_DISCONNECTED_SENSE_ID, 28 DEV_STATE_DISCONNECTED_SENSE_ID,
25 DEV_STATE_CMFCHANGE, 29 DEV_STATE_CMFCHANGE,
30 DEV_STATE_CMFUPDATE,
26 /* last element! */ 31 /* last element! */
27 NR_DEV_STATES 32 NR_DEV_STATES
28}; 33};
@@ -67,6 +72,8 @@ dev_fsm_final_state(struct ccw_device *cdev)
67 72
68extern struct workqueue_struct *ccw_device_work; 73extern struct workqueue_struct *ccw_device_work;
69extern struct workqueue_struct *ccw_device_notify_work; 74extern struct workqueue_struct *ccw_device_notify_work;
75extern wait_queue_head_t ccw_device_init_wq;
76extern atomic_t ccw_device_init_count;
70 77
71void io_subchannel_recog_done(struct ccw_device *cdev); 78void io_subchannel_recog_done(struct ccw_device *cdev);
72 79
@@ -112,5 +119,8 @@ int ccw_device_stlck(struct ccw_device *);
112void ccw_device_set_timeout(struct ccw_device *, int); 119void ccw_device_set_timeout(struct ccw_device *, int);
113extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *); 120extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *);
114 121
122/* Channel measurement facility related */
115void retry_set_schib(struct ccw_device *cdev); 123void retry_set_schib(struct ccw_device *cdev);
124void cmf_retry_copy_block(struct ccw_device *);
125int cmf_reenable(struct ccw_device *);
116#endif 126#endif
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index 49ec562d7f60..7d0dd72635eb 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -336,8 +336,11 @@ ccw_device_oper_notify(void *data)
336 if (!ret) 336 if (!ret)
337 /* Driver doesn't want device back. */ 337 /* Driver doesn't want device back. */
338 ccw_device_do_unreg_rereg((void *)cdev); 338 ccw_device_do_unreg_rereg((void *)cdev);
339 else 339 else {
340 /* Reenable channel measurements, if needed. */
341 cmf_reenable(cdev);
340 wake_up(&cdev->private->wait_q); 342 wake_up(&cdev->private->wait_q);
343 }
341} 344}
342 345
343/* 346/*
@@ -861,6 +864,8 @@ ccw_device_clear_verify(struct ccw_device *cdev, enum dev_event dev_event)
861 irb = (struct irb *) __LC_IRB; 864 irb = (struct irb *) __LC_IRB;
862 /* Accumulate status. We don't do basic sense. */ 865 /* Accumulate status. We don't do basic sense. */
863 ccw_device_accumulate_irb(cdev, irb); 866 ccw_device_accumulate_irb(cdev, irb);
867 /* Remember to clear irb to avoid residuals. */
868 memset(&cdev->private->irb, 0, sizeof(struct irb));
864 /* Try to start delayed device verification. */ 869 /* Try to start delayed device verification. */
865 ccw_device_online_verify(cdev, 0); 870 ccw_device_online_verify(cdev, 0);
866 /* Note: Don't call handler for cio initiated clear! */ 871 /* Note: Don't call handler for cio initiated clear! */
@@ -1093,6 +1098,13 @@ ccw_device_change_cmfstate(struct ccw_device *cdev, enum dev_event dev_event)
1093 dev_fsm_event(cdev, dev_event); 1098 dev_fsm_event(cdev, dev_event);
1094} 1099}
1095 1100
1101static void ccw_device_update_cmfblock(struct ccw_device *cdev,
1102 enum dev_event dev_event)
1103{
1104 cmf_retry_copy_block(cdev);
1105 cdev->private->state = DEV_STATE_ONLINE;
1106 dev_fsm_event(cdev, dev_event);
1107}
1096 1108
1097static void 1109static void
1098ccw_device_quiesce_done(struct ccw_device *cdev, enum dev_event dev_event) 1110ccw_device_quiesce_done(struct ccw_device *cdev, enum dev_event dev_event)
@@ -1247,6 +1259,12 @@ fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS] = {
1247 [DEV_EVENT_TIMEOUT] = ccw_device_change_cmfstate, 1259 [DEV_EVENT_TIMEOUT] = ccw_device_change_cmfstate,
1248 [DEV_EVENT_VERIFY] = ccw_device_change_cmfstate, 1260 [DEV_EVENT_VERIFY] = ccw_device_change_cmfstate,
1249 }, 1261 },
1262 [DEV_STATE_CMFUPDATE] = {
1263 [DEV_EVENT_NOTOPER] = ccw_device_update_cmfblock,
1264 [DEV_EVENT_INTERRUPT] = ccw_device_update_cmfblock,
1265 [DEV_EVENT_TIMEOUT] = ccw_device_update_cmfblock,
1266 [DEV_EVENT_VERIFY] = ccw_device_update_cmfblock,
1267 },
1250}; 1268};
1251 1269
1252/* 1270/*
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 795abb5a65ba..b266ad8e14ff 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -78,7 +78,8 @@ ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa,
78 return -ENODEV; 78 return -ENODEV;
79 if (cdev->private->state == DEV_STATE_NOT_OPER) 79 if (cdev->private->state == DEV_STATE_NOT_OPER)
80 return -ENODEV; 80 return -ENODEV;
81 if (cdev->private->state == DEV_STATE_VERIFY) { 81 if (cdev->private->state == DEV_STATE_VERIFY ||
82 cdev->private->state == DEV_STATE_CLEAR_VERIFY) {
82 /* Remember to fake irb when finished. */ 83 /* Remember to fake irb when finished. */
83 if (!cdev->private->flags.fake_irb) { 84 if (!cdev->private->flags.fake_irb) {
84 cdev->private->flags.fake_irb = 1; 85 cdev->private->flags.fake_irb = 1;
@@ -270,7 +271,8 @@ ccw_device_wake_up(struct ccw_device *cdev, unsigned long ip, struct irb *irb)
270 * We didn't get channel end / device end. Check if path 271 * We didn't get channel end / device end. Check if path
271 * verification has been started; we can retry after it has 272 * verification has been started; we can retry after it has
272 * finished. We also retry unit checks except for command reject 273 * finished. We also retry unit checks except for command reject
273 * or intervention required. 274 * or intervention required. Also check for long busy
275 * conditions.
274 */ 276 */
275 if (cdev->private->flags.doverify || 277 if (cdev->private->flags.doverify ||
276 cdev->private->state == DEV_STATE_VERIFY) 278 cdev->private->state == DEV_STATE_VERIFY)
@@ -279,6 +281,10 @@ ccw_device_wake_up(struct ccw_device *cdev, unsigned long ip, struct irb *irb)
279 !(irb->ecw[0] & 281 !(irb->ecw[0] &
280 (SNS0_CMD_REJECT | SNS0_INTERVENTION_REQ))) 282 (SNS0_CMD_REJECT | SNS0_INTERVENTION_REQ)))
281 cdev->private->intparm = -EAGAIN; 283 cdev->private->intparm = -EAGAIN;
284 else if ((irb->scsw.dstat & DEV_STAT_ATTENTION) &&
285 (irb->scsw.dstat & DEV_STAT_DEV_END) &&
286 (irb->scsw.dstat & DEV_STAT_UNIT_EXCEP))
287 cdev->private->intparm = -EAGAIN;
282 else 288 else
283 cdev->private->intparm = -EIO; 289 cdev->private->intparm = -EIO;
284 290
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 982acc7303ea..b2f20ab8431a 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -411,7 +411,6 @@ static struct miscdevice z90crypt_misc_device = {
411 .minor = Z90CRYPT_MINOR, 411 .minor = Z90CRYPT_MINOR,
412 .name = DEV_NAME, 412 .name = DEV_NAME,
413 .fops = &z90crypt_fops, 413 .fops = &z90crypt_fops,
414 .devfs_name = DEV_NAME
415}; 414};
416 415
417/** 416/**
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c
index f99e55308b32..8dc75002acbe 100644
--- a/drivers/s390/s390mach.c
+++ b/drivers/s390/s390mach.c
@@ -14,6 +14,7 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/workqueue.h> 15#include <linux/workqueue.h>
16#include <linux/time.h> 16#include <linux/time.h>
17#include <linux/kthread.h>
17 18
18#include <asm/lowcore.h> 19#include <asm/lowcore.h>
19 20
@@ -56,8 +57,6 @@ s390_collect_crw_info(void *param)
56 unsigned int chain; 57 unsigned int chain;
57 58
58 sem = (struct semaphore *)param; 59 sem = (struct semaphore *)param;
59 /* Set a nice name. */
60 daemonize("kmcheck");
61repeat: 60repeat:
62 down_interruptible(sem); 61 down_interruptible(sem);
63 slow = 0; 62 slow = 0;
@@ -516,7 +515,7 @@ arch_initcall(machine_check_init);
516static int __init 515static int __init
517machine_check_crw_init (void) 516machine_check_crw_init (void)
518{ 517{
519 kernel_thread(s390_collect_crw_info, &m_sem, CLONE_FS|CLONE_FILES); 518 kthread_run(s390_collect_crw_info, &m_sem, "kmcheck");
520 ctl_set_bit(14, 28); /* enable channel report MCH */ 519 ctl_set_bit(14, 28); /* enable channel report MCH */
521 return 0; 520 return 0;
522} 521}
diff --git a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
index ccb20a6f5f36..385f4f768311 100644
--- a/drivers/sbus/char/bpp.c
+++ b/drivers/sbus/char/bpp.c
@@ -20,7 +20,6 @@
20#include <linux/timer.h> 20#include <linux/timer.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/major.h> 22#include <linux/major.h>
23#include <linux/devfs_fs_kernel.h>
24 23
25#include <asm/uaccess.h> 24#include <asm/uaccess.h>
26#include <asm/io.h> 25#include <asm/io.h>
@@ -1031,11 +1030,6 @@ static int __init bpp_init(void)
1031 instances[idx].opened = 0; 1030 instances[idx].opened = 0;
1032 probeLptPort(idx); 1031 probeLptPort(idx);
1033 } 1032 }
1034 devfs_mk_dir("bpp");
1035 for (idx = 0; idx < BPP_NO; idx++) {
1036 devfs_mk_cdev(MKDEV(BPP_MAJOR, idx),
1037 S_IFCHR | S_IRUSR | S_IWUSR, "bpp/%d", idx);
1038 }
1039 1033
1040 return 0; 1034 return 0;
1041} 1035}
@@ -1044,9 +1038,6 @@ static void __exit bpp_cleanup(void)
1044{ 1038{
1045 unsigned idx; 1039 unsigned idx;
1046 1040
1047 for (idx = 0; idx < BPP_NO; idx++)
1048 devfs_remove("bpp/%d", idx);
1049 devfs_remove("bpp");
1050 unregister_chrdev(BPP_MAJOR, dev_name); 1041 unregister_chrdev(BPP_MAJOR, dev_name);
1051 1042
1052 for (idx = 0; idx < BPP_NO; idx++) { 1043 for (idx = 0; idx < BPP_NO; idx++) {
diff --git a/drivers/sbus/char/vfc.h b/drivers/sbus/char/vfc.h
index 8045cd5e7cb3..63941a259b92 100644
--- a/drivers/sbus/char/vfc.h
+++ b/drivers/sbus/char/vfc.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_VFC_H_ 1#ifndef _LINUX_VFC_H_
2#define _LINUX_VFC_H_ 2#define _LINUX_VFC_H_
3 3
4#include <linux/devfs_fs_kernel.h>
5
6/* 4/*
7 * The control register for the vfc is at offset 0x4000 5 * The control register for the vfc is at offset 0x4000
8 * The first field ram bank is located at offset 0x5000 6 * The first field ram bank is located at offset 0x5000
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
index ddcd330b9e89..55b2b31bd7ab 100644
--- a/drivers/sbus/char/vfc_dev.c
+++ b/drivers/sbus/char/vfc_dev.c
@@ -164,10 +164,6 @@ int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance)
164 return -EINVAL; 164 return -EINVAL;
165 if (init_vfc_hw(dev)) 165 if (init_vfc_hw(dev))
166 return -EIO; 166 return -EIO;
167
168 devfs_mk_cdev(MKDEV(VFC_MAJOR, instance),
169 S_IFCHR | S_IRUSR | S_IWUSR,
170 "vfc/%d", instance);
171 return 0; 167 return 0;
172} 168}
173 169
@@ -677,7 +673,6 @@ static int vfc_probe(void)
677 kfree(vfc_dev_lst); 673 kfree(vfc_dev_lst);
678 return -EIO; 674 return -EIO;
679 } 675 }
680 devfs_mk_dir("vfc");
681 instance = 0; 676 instance = 0;
682 for_all_sbusdev(sdev, sbus) { 677 for_all_sbusdev(sdev, sbus) {
683 if (strcmp(sdev->prom_name, "vfc") == 0) { 678 if (strcmp(sdev->prom_name, "vfc") == 0) {
@@ -717,7 +712,6 @@ static void deinit_vfc_device(struct vfc_dev *dev)
717{ 712{
718 if(dev == NULL) 713 if(dev == NULL)
719 return; 714 return;
720 devfs_remove("vfc/%d", dev->instance);
721 sbus_iounmap(dev->regs, sizeof(struct vfc_regs)); 715 sbus_iounmap(dev->regs, sizeof(struct vfc_regs));
722 kfree(dev); 716 kfree(dev);
723} 717}
@@ -731,7 +725,6 @@ void cleanup_module(void)
731 for (devp = vfc_dev_lst; *devp; devp++) 725 for (devp = vfc_dev_lst; *devp; devp++)
732 deinit_vfc_device(*devp); 726 deinit_vfc_device(*devp);
733 727
734 devfs_remove("vfc");
735 kfree(vfc_dev_lst); 728 kfree(vfc_dev_lst);
736 return; 729 return;
737} 730}
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c84b02aec1f3..96a81cd17617 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -501,7 +501,7 @@ config SCSI_ATA_PIIX
501 tristate "Intel PIIX/ICH SATA support" 501 tristate "Intel PIIX/ICH SATA support"
502 depends on SCSI_SATA && PCI 502 depends on SCSI_SATA && PCI
503 help 503 help
504 This option enables support for ICH5 Serial ATA. 504 This option enables support for ICH5/6/7/8 Serial ATA.
505 If PATA support was enabled previously, this enables 505 If PATA support was enabled previously, this enables
506 support for select Intel PIIX/ICH PATA host controllers. 506 support for select Intel PIIX/ICH PATA host controllers.
507 507
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 4bb77f62b3b9..f05946777718 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -48,7 +48,7 @@
48#include <asm/io.h> 48#include <asm/io.h>
49 49
50#define DRV_NAME "ahci" 50#define DRV_NAME "ahci"
51#define DRV_VERSION "1.3" 51#define DRV_VERSION "2.0"
52 52
53 53
54enum { 54enum {
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 521b718763f6..94b1261a259d 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -93,7 +93,7 @@
93#include <linux/libata.h> 93#include <linux/libata.h>
94 94
95#define DRV_NAME "ata_piix" 95#define DRV_NAME "ata_piix"
96#define DRV_VERSION "1.10" 96#define DRV_VERSION "2.00"
97 97
98enum { 98enum {
99 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ 99 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 6c66877be2bf..d1c1c30d123f 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -88,6 +88,10 @@ int libata_fua = 0;
88module_param_named(fua, libata_fua, int, 0444); 88module_param_named(fua, libata_fua, int, 0444);
89MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); 89MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)");
90 90
91static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ;
92module_param(ata_probe_timeout, int, 0444);
93MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)");
94
91MODULE_AUTHOR("Jeff Garzik"); 95MODULE_AUTHOR("Jeff Garzik");
92MODULE_DESCRIPTION("Library module for ATA devices"); 96MODULE_DESCRIPTION("Library module for ATA devices");
93MODULE_LICENSE("GPL"); 97MODULE_LICENSE("GPL");
@@ -777,11 +781,9 @@ void ata_std_dev_select (struct ata_port *ap, unsigned int device)
777void ata_dev_select(struct ata_port *ap, unsigned int device, 781void ata_dev_select(struct ata_port *ap, unsigned int device,
778 unsigned int wait, unsigned int can_sleep) 782 unsigned int wait, unsigned int can_sleep)
779{ 783{
780 if (ata_msg_probe(ap)) { 784 if (ata_msg_probe(ap))
781 ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, ata%u: " 785 ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, ata%u: "
782 "device %u, wait %u\n", 786 "device %u, wait %u\n", ap->id, device, wait);
783 ap->id, device, wait);
784 }
785 787
786 if (wait) 788 if (wait)
787 ata_wait_idle(ap); 789 ata_wait_idle(ap);
@@ -950,7 +952,8 @@ void ata_port_flush_task(struct ata_port *ap)
950 */ 952 */
951 if (!cancel_delayed_work(&ap->port_task)) { 953 if (!cancel_delayed_work(&ap->port_task)) {
952 if (ata_msg_ctl(ap)) 954 if (ata_msg_ctl(ap))
953 ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", __FUNCTION__); 955 ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n",
956 __FUNCTION__);
954 flush_workqueue(ata_wq); 957 flush_workqueue(ata_wq);
955 } 958 }
956 959
@@ -1059,7 +1062,7 @@ unsigned ata_exec_internal(struct ata_device *dev,
1059 1062
1060 spin_unlock_irqrestore(ap->lock, flags); 1063 spin_unlock_irqrestore(ap->lock, flags);
1061 1064
1062 rc = wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL); 1065 rc = wait_for_completion_timeout(&wait, ata_probe_timeout);
1063 1066
1064 ata_port_flush_task(ap); 1067 ata_port_flush_task(ap);
1065 1068
@@ -1081,7 +1084,7 @@ unsigned ata_exec_internal(struct ata_device *dev,
1081 1084
1082 if (ata_msg_warn(ap)) 1085 if (ata_msg_warn(ap))
1083 ata_dev_printk(dev, KERN_WARNING, 1086 ata_dev_printk(dev, KERN_WARNING,
1084 "qc timeout (cmd 0x%x)\n", command); 1087 "qc timeout (cmd 0x%x)\n", command);
1085 } 1088 }
1086 1089
1087 spin_unlock_irqrestore(ap->lock, flags); 1090 spin_unlock_irqrestore(ap->lock, flags);
@@ -1093,9 +1096,9 @@ unsigned ata_exec_internal(struct ata_device *dev,
1093 1096
1094 if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) { 1097 if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) {
1095 if (ata_msg_warn(ap)) 1098 if (ata_msg_warn(ap))
1096 ata_dev_printk(dev, KERN_WARNING, 1099 ata_dev_printk(dev, KERN_WARNING,
1097 "zero err_mask for failed " 1100 "zero err_mask for failed "
1098 "internal command, assuming AC_ERR_OTHER\n"); 1101 "internal command, assuming AC_ERR_OTHER\n");
1099 qc->err_mask |= AC_ERR_OTHER; 1102 qc->err_mask |= AC_ERR_OTHER;
1100 } 1103 }
1101 1104
@@ -1132,6 +1135,33 @@ unsigned ata_exec_internal(struct ata_device *dev,
1132} 1135}
1133 1136
1134/** 1137/**
1138 * ata_do_simple_cmd - execute simple internal command
1139 * @dev: Device to which the command is sent
1140 * @cmd: Opcode to execute
1141 *
1142 * Execute a 'simple' command, that only consists of the opcode
1143 * 'cmd' itself, without filling any other registers
1144 *
1145 * LOCKING:
1146 * Kernel thread context (may sleep).
1147 *
1148 * RETURNS:
1149 * Zero on success, AC_ERR_* mask on failure
1150 */
1151unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)
1152{
1153 struct ata_taskfile tf;
1154
1155 ata_tf_init(dev, &tf);
1156
1157 tf.command = cmd;
1158 tf.flags |= ATA_TFLAG_DEVICE;
1159 tf.protocol = ATA_PROT_NODATA;
1160
1161 return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
1162}
1163
1164/**
1135 * ata_pio_need_iordy - check if iordy needed 1165 * ata_pio_need_iordy - check if iordy needed
1136 * @adev: ATA device 1166 * @adev: ATA device
1137 * 1167 *
@@ -1193,8 +1223,8 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1193 int rc; 1223 int rc;
1194 1224
1195 if (ata_msg_ctl(ap)) 1225 if (ata_msg_ctl(ap))
1196 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", 1226 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n",
1197 __FUNCTION__, ap->id, dev->devno); 1227 __FUNCTION__, ap->id, dev->devno);
1198 1228
1199 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ 1229 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
1200 1230
@@ -1263,9 +1293,9 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1263 return 0; 1293 return 0;
1264 1294
1265 err_out: 1295 err_out:
1266 if (ata_msg_warn(ap)) 1296 if (ata_msg_warn(ap))
1267 ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY " 1297 ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY "
1268 "(%s, err_mask=0x%x)\n", reason, err_mask); 1298 "(%s, err_mask=0x%x)\n", reason, err_mask);
1269 return rc; 1299 return rc;
1270} 1300}
1271 1301
@@ -1318,19 +1348,21 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1318 int i, rc; 1348 int i, rc;
1319 1349
1320 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 1350 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
1321 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n", 1351 ata_dev_printk(dev, KERN_INFO,
1322 __FUNCTION__, ap->id, dev->devno); 1352 "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n",
1353 __FUNCTION__, ap->id, dev->devno);
1323 return 0; 1354 return 0;
1324 } 1355 }
1325 1356
1326 if (ata_msg_probe(ap)) 1357 if (ata_msg_probe(ap))
1327 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", 1358 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n",
1328 __FUNCTION__, ap->id, dev->devno); 1359 __FUNCTION__, ap->id, dev->devno);
1329 1360
1330 /* print device capabilities */ 1361 /* print device capabilities */
1331 if (ata_msg_probe(ap)) 1362 if (ata_msg_probe(ap))
1332 ata_dev_printk(dev, KERN_DEBUG, "%s: cfg 49:%04x 82:%04x 83:%04x " 1363 ata_dev_printk(dev, KERN_DEBUG,
1333 "84:%04x 85:%04x 86:%04x 87:%04x 88:%04x\n", 1364 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x "
1365 "85:%04x 86:%04x 87:%04x 88:%04x\n",
1334 __FUNCTION__, 1366 __FUNCTION__,
1335 id[49], id[82], id[83], id[84], 1367 id[49], id[82], id[83], id[84],
1336 id[85], id[86], id[87], id[88]); 1368 id[85], id[86], id[87], id[88]);
@@ -1402,14 +1434,16 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1402 ata_id_major_version(id), 1434 ata_id_major_version(id),
1403 ata_mode_string(xfer_mask), 1435 ata_mode_string(xfer_mask),
1404 (unsigned long long)dev->n_sectors, 1436 (unsigned long long)dev->n_sectors,
1405 dev->cylinders, dev->heads, dev->sectors); 1437 dev->cylinders, dev->heads,
1438 dev->sectors);
1406 } 1439 }
1407 1440
1408 if (dev->id[59] & 0x100) { 1441 if (dev->id[59] & 0x100) {
1409 dev->multi_count = dev->id[59] & 0xff; 1442 dev->multi_count = dev->id[59] & 0xff;
1410 if (ata_msg_info(ap)) 1443 if (ata_msg_info(ap))
1411 ata_dev_printk(dev, KERN_INFO, "ata%u: dev %u multi count %u\n", 1444 ata_dev_printk(dev, KERN_INFO,
1412 ap->id, dev->devno, dev->multi_count); 1445 "ata%u: dev %u multi count %u\n",
1446 ap->id, dev->devno, dev->multi_count);
1413 } 1447 }
1414 1448
1415 dev->cdb_len = 16; 1449 dev->cdb_len = 16;
@@ -1422,8 +1456,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1422 rc = atapi_cdb_len(id); 1456 rc = atapi_cdb_len(id);
1423 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { 1457 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
1424 if (ata_msg_warn(ap)) 1458 if (ata_msg_warn(ap))
1425 ata_dev_printk(dev, KERN_WARNING, 1459 ata_dev_printk(dev, KERN_WARNING,
1426 "unsupported CDB len\n"); 1460 "unsupported CDB len\n");
1427 rc = -EINVAL; 1461 rc = -EINVAL;
1428 goto err_out_nosup; 1462 goto err_out_nosup;
1429 } 1463 }
@@ -1466,8 +1500,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1466 1500
1467err_out_nosup: 1501err_out_nosup:
1468 if (ata_msg_probe(ap)) 1502 if (ata_msg_probe(ap))
1469 ata_dev_printk(dev, KERN_DEBUG, 1503 ata_dev_printk(dev, KERN_DEBUG,
1470 "%s: EXIT, err\n", __FUNCTION__); 1504 "%s: EXIT, err\n", __FUNCTION__);
1471 return rc; 1505 return rc;
1472} 1506}
1473 1507
@@ -3527,7 +3561,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
3527 * Inherited from caller. 3561 * Inherited from caller.
3528 */ 3562 */
3529 3563
3530void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, 3564void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
3531 unsigned int buflen, int write_data) 3565 unsigned int buflen, int write_data)
3532{ 3566{
3533 struct ata_port *ap = adev->ap; 3567 struct ata_port *ap = adev->ap;
@@ -3573,7 +3607,7 @@ void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
3573 * Inherited from caller. 3607 * Inherited from caller.
3574 */ 3608 */
3575 3609
3576void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, 3610void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
3577 unsigned int buflen, int write_data) 3611 unsigned int buflen, int write_data)
3578{ 3612{
3579 struct ata_port *ap = adev->ap; 3613 struct ata_port *ap = adev->ap;
@@ -3607,7 +3641,7 @@ void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
3607 * @buflen: buffer length 3641 * @buflen: buffer length
3608 * @write_data: read/write 3642 * @write_data: read/write
3609 * 3643 *
3610 * Transfer data from/to the device data register by PIO. Do the 3644 * Transfer data from/to the device data register by PIO. Do the
3611 * transfer with interrupts disabled. 3645 * transfer with interrupts disabled.
3612 * 3646 *
3613 * LOCKING: 3647 * LOCKING:
@@ -4946,31 +4980,9 @@ int ata_port_offline(struct ata_port *ap)
4946 return 0; 4980 return 0;
4947} 4981}
4948 4982
4949/* 4983int ata_flush_cache(struct ata_device *dev)
4950 * Execute a 'simple' command, that only consists of the opcode 'cmd' itself,
4951 * without filling any other registers
4952 */
4953static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)
4954{
4955 struct ata_taskfile tf;
4956 int err;
4957
4958 ata_tf_init(dev, &tf);
4959
4960 tf.command = cmd;
4961 tf.flags |= ATA_TFLAG_DEVICE;
4962 tf.protocol = ATA_PROT_NODATA;
4963
4964 err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
4965 if (err)
4966 ata_dev_printk(dev, KERN_ERR, "%s: ata command failed: %d\n",
4967 __FUNCTION__, err);
4968
4969 return err;
4970}
4971
4972static int ata_flush_cache(struct ata_device *dev)
4973{ 4984{
4985 unsigned int err_mask;
4974 u8 cmd; 4986 u8 cmd;
4975 4987
4976 if (!ata_try_flush_cache(dev)) 4988 if (!ata_try_flush_cache(dev))
@@ -4981,17 +4993,41 @@ static int ata_flush_cache(struct ata_device *dev)
4981 else 4993 else
4982 cmd = ATA_CMD_FLUSH; 4994 cmd = ATA_CMD_FLUSH;
4983 4995
4984 return ata_do_simple_cmd(dev, cmd); 4996 err_mask = ata_do_simple_cmd(dev, cmd);
4997 if (err_mask) {
4998 ata_dev_printk(dev, KERN_ERR, "failed to flush cache\n");
4999 return -EIO;
5000 }
5001
5002 return 0;
4985} 5003}
4986 5004
4987static int ata_standby_drive(struct ata_device *dev) 5005static int ata_standby_drive(struct ata_device *dev)
4988{ 5006{
4989 return ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); 5007 unsigned int err_mask;
5008
5009 err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1);
5010 if (err_mask) {
5011 ata_dev_printk(dev, KERN_ERR, "failed to standby drive "
5012 "(err_mask=0x%x)\n", err_mask);
5013 return -EIO;
5014 }
5015
5016 return 0;
4990} 5017}
4991 5018
4992static int ata_start_drive(struct ata_device *dev) 5019static int ata_start_drive(struct ata_device *dev)
4993{ 5020{
4994 return ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE); 5021 unsigned int err_mask;
5022
5023 err_mask = ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE);
5024 if (err_mask) {
5025 ata_dev_printk(dev, KERN_ERR, "failed to start drive "
5026 "(err_mask=0x%x)\n", err_mask);
5027 return -EIO;
5028 }
5029
5030 return 0;
4995} 5031}
4996 5032
4997/** 5033/**
@@ -5212,7 +5248,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
5212 ap->msg_enable = 0x00FF; 5248 ap->msg_enable = 0x00FF;
5213#elif defined(ATA_DEBUG) 5249#elif defined(ATA_DEBUG)
5214 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR; 5250 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR;
5215#else 5251#else
5216 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; 5252 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
5217#endif 5253#endif
5218 5254
@@ -5709,6 +5745,7 @@ int ata_pci_device_resume(struct pci_dev *pdev)
5709 5745
5710static int __init ata_init(void) 5746static int __init ata_init(void)
5711{ 5747{
5748 ata_probe_timeout *= HZ;
5712 ata_wq = create_workqueue("ata"); 5749 ata_wq = create_workqueue("ata");
5713 if (!ata_wq) 5750 if (!ata_wq)
5714 return -ENOMEM; 5751 return -ENOMEM;
@@ -5733,7 +5770,7 @@ module_init(ata_init);
5733module_exit(ata_exit); 5770module_exit(ata_exit);
5734 5771
5735static unsigned long ratelimit_time; 5772static unsigned long ratelimit_time;
5736static spinlock_t ata_ratelimit_lock = SPIN_LOCK_UNLOCKED; 5773static DEFINE_SPINLOCK(ata_ratelimit_lock);
5737 5774
5738int ata_ratelimit(void) 5775int ata_ratelimit(void)
5739{ 5776{
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 823385981a7a..bf5a72aca8a4 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -93,6 +93,38 @@ static int ata_ering_map(struct ata_ering *ering,
93 return rc; 93 return rc;
94} 94}
95 95
96static unsigned int ata_eh_dev_action(struct ata_device *dev)
97{
98 struct ata_eh_context *ehc = &dev->ap->eh_context;
99
100 return ehc->i.action | ehc->i.dev_action[dev->devno];
101}
102
103static void ata_eh_clear_action(struct ata_device *dev,
104 struct ata_eh_info *ehi, unsigned int action)
105{
106 int i;
107
108 if (!dev) {
109 ehi->action &= ~action;
110 for (i = 0; i < ATA_MAX_DEVICES; i++)
111 ehi->dev_action[i] &= ~action;
112 } else {
113 /* doesn't make sense for port-wide EH actions */
114 WARN_ON(!(action & ATA_EH_PERDEV_MASK));
115
116 /* break ehi->action into ehi->dev_action */
117 if (ehi->action & action) {
118 for (i = 0; i < ATA_MAX_DEVICES; i++)
119 ehi->dev_action[i] |= ehi->action & action;
120 ehi->action &= ~action;
121 }
122
123 /* turn off the specified per-dev action */
124 ehi->dev_action[dev->devno] &= ~action;
125 }
126}
127
96/** 128/**
97 * ata_scsi_timed_out - SCSI layer time out callback 129 * ata_scsi_timed_out - SCSI layer time out callback
98 * @cmd: timed out SCSI command 130 * @cmd: timed out SCSI command
@@ -702,32 +734,11 @@ static void ata_eh_detach_dev(struct ata_device *dev)
702 ap->flags |= ATA_FLAG_SCSI_HOTPLUG; 734 ap->flags |= ATA_FLAG_SCSI_HOTPLUG;
703 } 735 }
704 736
705 spin_unlock_irqrestore(ap->lock, flags); 737 /* clear per-dev EH actions */
706} 738 ata_eh_clear_action(dev, &ap->eh_info, ATA_EH_PERDEV_MASK);
707 739 ata_eh_clear_action(dev, &ap->eh_context.i, ATA_EH_PERDEV_MASK);
708static void ata_eh_clear_action(struct ata_device *dev,
709 struct ata_eh_info *ehi, unsigned int action)
710{
711 int i;
712 740
713 if (!dev) { 741 spin_unlock_irqrestore(ap->lock, flags);
714 ehi->action &= ~action;
715 for (i = 0; i < ATA_MAX_DEVICES; i++)
716 ehi->dev_action[i] &= ~action;
717 } else {
718 /* doesn't make sense for port-wide EH actions */
719 WARN_ON(!(action & ATA_EH_PERDEV_MASK));
720
721 /* break ehi->action into ehi->dev_action */
722 if (ehi->action & action) {
723 for (i = 0; i < ATA_MAX_DEVICES; i++)
724 ehi->dev_action[i] |= ehi->action & action;
725 ehi->action &= ~action;
726 }
727
728 /* turn off the specified per-dev action */
729 ehi->dev_action[dev->devno] &= ~action;
730 }
731} 742}
732 743
733/** 744/**
@@ -1592,7 +1603,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1592 unsigned int action; 1603 unsigned int action;
1593 1604
1594 dev = &ap->device[i]; 1605 dev = &ap->device[i];
1595 action = ehc->i.action | ehc->i.dev_action[dev->devno]; 1606 action = ata_eh_dev_action(dev);
1596 1607
1597 if (action & ATA_EH_REVALIDATE && ata_dev_enabled(dev)) { 1608 if (action & ATA_EH_REVALIDATE && ata_dev_enabled(dev)) {
1598 if (ata_port_offline(ap)) { 1609 if (ata_port_offline(ap)) {
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 93d18a74c401..2915bca691e8 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
222 && copy_to_user(arg + sizeof(args), argbuf, argsize)) 222 && copy_to_user(arg + sizeof(args), argbuf, argsize))
223 rc = -EFAULT; 223 rc = -EFAULT;
224error: 224error:
225 if (argbuf) 225 kfree(argbuf);
226 kfree(argbuf);
227
228 return rc; 226 return rc;
229} 227}
230 228
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index bdd488897096..c325679d9b54 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -29,7 +29,7 @@
29#define __LIBATA_H__ 29#define __LIBATA_H__
30 30
31#define DRV_NAME "libata" 31#define DRV_NAME "libata"
32#define DRV_VERSION "1.30" /* must be exactly four chars */ 32#define DRV_VERSION "2.00" /* must be exactly four chars */
33 33
34struct ata_scsi_args { 34struct ata_scsi_args {
35 struct ata_device *dev; 35 struct ata_device *dev;
@@ -50,6 +50,7 @@ extern void ata_port_flush_task(struct ata_port *ap);
50extern unsigned ata_exec_internal(struct ata_device *dev, 50extern unsigned ata_exec_internal(struct ata_device *dev,
51 struct ata_taskfile *tf, const u8 *cdb, 51 struct ata_taskfile *tf, const u8 *cdb,
52 int dma_dir, void *buf, unsigned int buflen); 52 int dma_dir, void *buf, unsigned int buflen);
53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
53extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
54 int post_reset, u16 *id); 55 int post_reset, u16 *id);
55extern int ata_dev_configure(struct ata_device *dev, int print_info); 56extern int ata_dev_configure(struct ata_device *dev, int print_info);
@@ -64,6 +65,7 @@ extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
64extern void ata_dev_select(struct ata_port *ap, unsigned int device, 65extern void ata_dev_select(struct ata_port *ap, unsigned int device,
65 unsigned int wait, unsigned int can_sleep); 66 unsigned int wait, unsigned int can_sleep);
66extern void swap_buf_le16(u16 *buf, unsigned int buf_words); 67extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
68extern int ata_flush_cache(struct ata_device *dev);
67extern void ata_dev_init(struct ata_device *dev); 69extern void ata_dev_init(struct ata_device *dev);
68extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); 70extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
69extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); 71extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index d18e7e0932ef..5cc42c6054eb 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -44,7 +44,7 @@
44#include <linux/libata.h> 44#include <linux/libata.h>
45 45
46#define DRV_NAME "sata_nv" 46#define DRV_NAME "sata_nv"
47#define DRV_VERSION "0.9" 47#define DRV_VERSION "2.0"
48 48
49enum { 49enum {
50 NV_PORTS = 2, 50 NV_PORTS = 2,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index bc9f918a7f28..51d86d750e84 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -46,12 +46,13 @@
46#include <linux/libata.h> 46#include <linux/libata.h>
47 47
48#define DRV_NAME "sata_sil" 48#define DRV_NAME "sata_sil"
49#define DRV_VERSION "1.0" 49#define DRV_VERSION "2.0"
50 50
51enum { 51enum {
52 /* 52 /*
53 * host flags 53 * host flags
54 */ 54 */
55 SIL_FLAG_NO_SATA_IRQ = (1 << 28),
55 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), 56 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29),
56 SIL_FLAG_MOD15WRITE = (1 << 30), 57 SIL_FLAG_MOD15WRITE = (1 << 30),
57 58
@@ -62,8 +63,9 @@ enum {
62 * Controller IDs 63 * Controller IDs
63 */ 64 */
64 sil_3112 = 0, 65 sil_3112 = 0,
65 sil_3512 = 1, 66 sil_3112_no_sata_irq = 1,
66 sil_3114 = 2, 67 sil_3512 = 2,
68 sil_3114 = 3,
67 69
68 /* 70 /*
69 * Register offsets 71 * Register offsets
@@ -123,8 +125,8 @@ static const struct pci_device_id sil_pci_tbl[] = {
123 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 }, 125 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 },
124 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, 126 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
125 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 127 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
126 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 128 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_no_sata_irq },
127 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 129 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_no_sata_irq },
128 { } /* terminate list */ 130 { } /* terminate list */
129}; 131};
130 132
@@ -217,6 +219,16 @@ static const struct ata_port_info sil_port_info[] = {
217 .udma_mask = 0x3f, /* udma0-5 */ 219 .udma_mask = 0x3f, /* udma0-5 */
218 .port_ops = &sil_ops, 220 .port_ops = &sil_ops,
219 }, 221 },
222 /* sil_3112_no_sata_irq */
223 {
224 .sht = &sil_sht,
225 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE |
226 SIL_FLAG_NO_SATA_IRQ,
227 .pio_mask = 0x1f, /* pio0-4 */
228 .mwdma_mask = 0x07, /* mwdma0-2 */
229 .udma_mask = 0x3f, /* udma0-5 */
230 .port_ops = &sil_ops,
231 },
220 /* sil_3512 */ 232 /* sil_3512 */
221 { 233 {
222 .sht = &sil_sht, 234 .sht = &sil_sht,
@@ -437,6 +449,10 @@ static irqreturn_t sil_interrupt(int irq, void *dev_instance,
437 if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED)) 449 if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED))
438 continue; 450 continue;
439 451
452 /* turn off SATA_IRQ if not supported */
453 if (ap->flags & SIL_FLAG_NO_SATA_IRQ)
454 bmdma2 &= ~SIL_DMA_SATA_IRQ;
455
440 if (bmdma2 == 0xffffffff || 456 if (bmdma2 == 0xffffffff ||
441 !(bmdma2 & (SIL_DMA_COMPLETE | SIL_DMA_SATA_IRQ))) 457 !(bmdma2 & (SIL_DMA_COMPLETE | SIL_DMA_SATA_IRQ)))
442 continue; 458 continue;
@@ -474,8 +490,9 @@ static void sil_thaw(struct ata_port *ap)
474 ata_chk_status(ap); 490 ata_chk_status(ap);
475 ata_bmdma_irq_clear(ap); 491 ata_bmdma_irq_clear(ap);
476 492
477 /* turn on SATA IRQ */ 493 /* turn on SATA IRQ if supported */
478 writel(SIL_SIEN_N, mmio_base + sil_port[ap->port_no].sien); 494 if (!(ap->flags & SIL_FLAG_NO_SATA_IRQ))
495 writel(SIL_SIEN_N, mmio_base + sil_port[ap->port_no].sien);
479 496
480 /* turn on IRQ */ 497 /* turn on IRQ */
481 tmp = readl(mmio_base + SIL_SYSCFG); 498 tmp = readl(mmio_base + SIL_SYSCFG);
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index c8b477c67247..b5f8fa955679 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -31,7 +31,7 @@
31#include <asm/io.h> 31#include <asm/io.h>
32 32
33#define DRV_NAME "sata_sil24" 33#define DRV_NAME "sata_sil24"
34#define DRV_VERSION "0.24" 34#define DRV_VERSION "0.3"
35 35
36/* 36/*
37 * Port request block (PRB) 32 bytes 37 * Port request block (PRB) 32 bytes
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index c94b870cf378..7566c2cabaf7 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -54,7 +54,7 @@
54#endif /* CONFIG_PPC_OF */ 54#endif /* CONFIG_PPC_OF */
55 55
56#define DRV_NAME "sata_svw" 56#define DRV_NAME "sata_svw"
57#define DRV_VERSION "1.8" 57#define DRV_VERSION "2.0"
58 58
59enum { 59enum {
60 /* Taskfile registers offsets */ 60 /* Taskfile registers offsets */
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index f668c997e9af..64f3c1aeed21 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -37,7 +37,7 @@
37#include <linux/libata.h> 37#include <linux/libata.h>
38 38
39#define DRV_NAME "sata_uli" 39#define DRV_NAME "sata_uli"
40#define DRV_VERSION "0.6" 40#define DRV_VERSION "1.0"
41 41
42enum { 42enum {
43 uli_5289 = 0, 43 uli_5289 = 0,
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 322890b400a6..501ce1791782 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -47,7 +47,7 @@
47#include <asm/io.h> 47#include <asm/io.h>
48 48
49#define DRV_NAME "sata_via" 49#define DRV_NAME "sata_via"
50#define DRV_VERSION "1.2" 50#define DRV_VERSION "2.0"
51 51
52enum board_ids_enum { 52enum board_ids_enum {
53 vt6420, 53 vt6420,
@@ -335,10 +335,10 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
335 if ((pci_resource_start(pdev, i) == 0) || 335 if ((pci_resource_start(pdev, i) == 0) ||
336 (pci_resource_len(pdev, i) < bar_sizes[i])) { 336 (pci_resource_len(pdev, i) < bar_sizes[i])) {
337 dev_printk(KERN_ERR, &pdev->dev, 337 dev_printk(KERN_ERR, &pdev->dev,
338 "invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", 338 "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n",
339 i, 339 i,
340 pci_resource_start(pdev, i), 340 (unsigned long long)pci_resource_start(pdev, i),
341 pci_resource_len(pdev, i)); 341 (unsigned long long)pci_resource_len(pdev, i));
342 rc = -ENODEV; 342 rc = -ENODEV;
343 goto err_out_regions; 343 goto err_out_regions;
344 } 344 }
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 6d0c4f18e652..616fd9634b4b 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -47,7 +47,7 @@
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.2" 50#define DRV_VERSION "2.0"
51 51
52enum { 52enum {
53 /* Interrupt register offsets (from chip base address) */ 53 /* Interrupt register offsets (from chip base address) */
@@ -443,16 +443,12 @@ err_out:
443} 443}
444 444
445 445
446/*
447 * Intel 31244 is supposed to be identical.
448 * Compatibility is untested as of yet.
449 */
450static const struct pci_device_id vsc_sata_pci_tbl[] = { 446static const struct pci_device_id vsc_sata_pci_tbl[] = {
451 { PCI_VENDOR_ID_VITESSE, PCI_DEVICE_ID_VITESSE_VSC7174, 447 { PCI_VENDOR_ID_VITESSE, 0x7174,
452 PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 }, 448 PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 },
453 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GD31244, 449 { PCI_VENDOR_ID_INTEL, 0x3200,
454 PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 }, 450 PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 },
455 { } 451 { } /* terminate list */
456}; 452};
457 453
458 454
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 7572665a8855..9fd0de4b7afd 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -479,7 +479,6 @@ static struct uart_driver serial21285_reg = {
479 .owner = THIS_MODULE, 479 .owner = THIS_MODULE,
480 .driver_name = "ttyFB", 480 .driver_name = "ttyFB",
481 .dev_name = "ttyFB", 481 .dev_name = "ttyFB",
482 .devfs_name = "ttyFB",
483 .major = SERIAL_21285_MAJOR, 482 .major = SERIAL_21285_MAJOR,
484 .minor = SERIAL_21285_MINOR, 483 .minor = SERIAL_21285_MINOR,
485 .nr = 1, 484 .nr = 1,
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index b88a7c1158af..bff94541991c 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -131,17 +131,6 @@ static int m68328_console_baud = CONSOLE_BAUD_RATE;
131static int m68328_console_cbaud = DEFAULT_CBAUD; 131static int m68328_console_cbaud = DEFAULT_CBAUD;
132 132
133 133
134/*
135 * tmp_buf is used as a temporary buffer by serial_write. We need to
136 * lock it in case the memcpy_fromfs blocks while swapping in a page,
137 * and some other program tries to do a serial write at the same time.
138 * Since the lock will only come under contention when the system is
139 * swapping and available memory is low, it makes sense to share one
140 * buffer across all the serial ports, since it significantly saves
141 * memory if large numbers of serial ports are open.
142 */
143static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */
144
145static inline int serial_paranoia_check(struct m68k_serial *info, 134static inline int serial_paranoia_check(struct m68k_serial *info,
146 char *name, const char *routine) 135 char *name, const char *routine)
147{ 136{
@@ -211,16 +200,16 @@ static void rs_stop(struct tty_struct *tty)
211 if (serial_paranoia_check(info, tty->name, "rs_stop")) 200 if (serial_paranoia_check(info, tty->name, "rs_stop"))
212 return; 201 return;
213 202
214 save_flags(flags); cli(); 203 local_irq_save(flags);
215 uart->ustcnt &= ~USTCNT_TXEN; 204 uart->ustcnt &= ~USTCNT_TXEN;
216 restore_flags(flags); 205 local_irq_restore(flags);
217} 206}
218 207
219static void rs_put_char(char ch) 208static void rs_put_char(char ch)
220{ 209{
221 int flags, loops = 0; 210 int flags, loops = 0;
222 211
223 save_flags(flags); cli(); 212 local_irq_save(flags);
224 213
225 while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) { 214 while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
226 loops++; 215 loops++;
@@ -229,7 +218,7 @@ static void rs_put_char(char ch)
229 218
230 UTX_TXDATA = ch; 219 UTX_TXDATA = ch;
231 udelay(5); 220 udelay(5);
232 restore_flags(flags); 221 local_irq_restore(flags);
233} 222}
234 223
235static void rs_start(struct tty_struct *tty) 224static void rs_start(struct tty_struct *tty)
@@ -241,7 +230,7 @@ static void rs_start(struct tty_struct *tty)
241 if (serial_paranoia_check(info, tty->name, "rs_start")) 230 if (serial_paranoia_check(info, tty->name, "rs_start"))
242 return; 231 return;
243 232
244 save_flags(flags); cli(); 233 local_irq_save(flags);
245 if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) { 234 if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
246#ifdef USE_INTS 235#ifdef USE_INTS
247 uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK; 236 uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
@@ -249,7 +238,7 @@ static void rs_start(struct tty_struct *tty)
249 uart->ustcnt |= USTCNT_TXEN; 238 uart->ustcnt |= USTCNT_TXEN;
250#endif 239#endif
251 } 240 }
252 restore_flags(flags); 241 local_irq_restore(flags);
253} 242}
254 243
255/* Drop into either the boot monitor or kadb upon receiving a break 244/* Drop into either the boot monitor or kadb upon receiving a break
@@ -327,14 +316,6 @@ static void receive_chars(struct m68k_serial *info, struct pt_regs *regs,
327 if(!tty) 316 if(!tty)
328 goto clear_and_exit; 317 goto clear_and_exit;
329 318
330 /*
331 * Make sure that we do not overflow the buffer
332 */
333 if (tty_request_buffer_room(tty, 1) == 0) {
334 tty_schedule_flip(tty);
335 return;
336 }
337
338 flag = TTY_NORMAL; 319 flag = TTY_NORMAL;
339 320
340 if(rx & URX_PARITY_ERROR) { 321 if(rx & URX_PARITY_ERROR) {
@@ -473,7 +454,7 @@ static int startup(struct m68k_serial * info)
473 return -ENOMEM; 454 return -ENOMEM;
474 } 455 }
475 456
476 save_flags(flags); cli(); 457 local_irq_save(flags);
477 458
478 /* 459 /*
479 * Clear the FIFO buffers and disable them 460 * Clear the FIFO buffers and disable them
@@ -506,7 +487,7 @@ static int startup(struct m68k_serial * info)
506 change_speed(info); 487 change_speed(info);
507 488
508 info->flags |= S_INITIALIZED; 489 info->flags |= S_INITIALIZED;
509 restore_flags(flags); 490 local_irq_restore(flags);
510 return 0; 491 return 0;
511} 492}
512 493
@@ -523,7 +504,7 @@ static void shutdown(struct m68k_serial * info)
523 if (!(info->flags & S_INITIALIZED)) 504 if (!(info->flags & S_INITIALIZED))
524 return; 505 return;
525 506
526 save_flags(flags); cli(); /* Disable interrupts */ 507 local_irq_save(flags);
527 508
528 if (info->xmit_buf) { 509 if (info->xmit_buf) {
529 free_page((unsigned long) info->xmit_buf); 510 free_page((unsigned long) info->xmit_buf);
@@ -534,7 +515,7 @@ static void shutdown(struct m68k_serial * info)
534 set_bit(TTY_IO_ERROR, &info->tty->flags); 515 set_bit(TTY_IO_ERROR, &info->tty->flags);
535 516
536 info->flags &= ~S_INITIALIZED; 517 info->flags &= ~S_INITIALIZED;
537 restore_flags(flags); 518 local_irq_restore(flags);
538} 519}
539 520
540struct { 521struct {
@@ -655,24 +636,24 @@ static void rs_fair_output(void)
655 if (info == 0) return; 636 if (info == 0) return;
656 if (info->xmit_buf == 0) return; 637 if (info->xmit_buf == 0) return;
657 638
658 save_flags(flags); cli(); 639 local_irq_save(flags);
659 left = info->xmit_cnt; 640 left = info->xmit_cnt;
660 while (left != 0) { 641 while (left != 0) {
661 c = info->xmit_buf[info->xmit_tail]; 642 c = info->xmit_buf[info->xmit_tail];
662 info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1); 643 info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
663 info->xmit_cnt--; 644 info->xmit_cnt--;
664 restore_flags(flags); 645 local_irq_restore(flags);
665 646
666 rs_put_char(c); 647 rs_put_char(c);
667 648
668 save_flags(flags); cli(); 649 local_irq_save(flags);
669 left = min(info->xmit_cnt, left-1); 650 left = min(info->xmit_cnt, left-1);
670 } 651 }
671 652
672 /* Last character is being transmitted now (hopefully). */ 653 /* Last character is being transmitted now (hopefully). */
673 udelay(5); 654 udelay(5);
674 655
675 restore_flags(flags); 656 local_irq_restore(flags);
676 return; 657 return;
677} 658}
678 659
@@ -720,11 +701,11 @@ static void rs_flush_chars(struct tty_struct *tty)
720#endif 701#endif
721 702
722 /* Enable transmitter */ 703 /* Enable transmitter */
723 save_flags(flags); cli(); 704 local_irq_save(flags);
724 705
725 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 706 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
726 !info->xmit_buf) { 707 !info->xmit_buf) {
727 restore_flags(flags); 708 local_irq_restore(flags);
728 return; 709 return;
729 } 710 }
730 711
@@ -749,7 +730,7 @@ static void rs_flush_chars(struct tty_struct *tty)
749 while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5); 730 while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
750 } 731 }
751#endif 732#endif
752 restore_flags(flags); 733 local_irq_restore(flags);
753} 734}
754 735
755extern void console_printn(const char * b, int count); 736extern void console_printn(const char * b, int count);
@@ -768,18 +749,22 @@ static int rs_write(struct tty_struct * tty,
768 if (!tty || !info->xmit_buf) 749 if (!tty || !info->xmit_buf)
769 return 0; 750 return 0;
770 751
771 save_flags(flags); 752 local_save_flags(flags);
772 while (1) { 753 while (1) {
773 cli(); 754 local_irq_disable();
774 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, 755 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
775 SERIAL_XMIT_SIZE - info->xmit_head)); 756 SERIAL_XMIT_SIZE - info->xmit_head));
757 local_irq_restore(flags);
758
776 if (c <= 0) 759 if (c <= 0)
777 break; 760 break;
778 761
779 memcpy(info->xmit_buf + info->xmit_head, buf, c); 762 memcpy(info->xmit_buf + info->xmit_head, buf, c);
763
764 local_irq_disable();
780 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); 765 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
781 info->xmit_cnt += c; 766 info->xmit_cnt += c;
782 restore_flags(flags); 767 local_irq_restore(flags);
783 buf += c; 768 buf += c;
784 count -= c; 769 count -= c;
785 total += c; 770 total += c;
@@ -787,7 +772,7 @@ static int rs_write(struct tty_struct * tty,
787 772
788 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 773 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
789 /* Enable transmitter */ 774 /* Enable transmitter */
790 cli(); 775 local_irq_disable();
791#ifndef USE_INTS 776#ifndef USE_INTS
792 while(info->xmit_cnt) { 777 while(info->xmit_cnt) {
793#endif 778#endif
@@ -807,9 +792,9 @@ static int rs_write(struct tty_struct * tty,
807#ifndef USE_INTS 792#ifndef USE_INTS
808 } 793 }
809#endif 794#endif
810 restore_flags(flags); 795 local_irq_restore(flags);
811 } 796 }
812 restore_flags(flags); 797
813 return total; 798 return total;
814} 799}
815 800
@@ -838,12 +823,13 @@ static int rs_chars_in_buffer(struct tty_struct *tty)
838static void rs_flush_buffer(struct tty_struct *tty) 823static void rs_flush_buffer(struct tty_struct *tty)
839{ 824{
840 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; 825 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
826 unsigned long flags;
841 827
842 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) 828 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
843 return; 829 return;
844 cli(); 830 local_irq_save(flags);
845 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 831 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
846 sti(); 832 local_irq_restore(flags);
847 tty_wakeup(tty); 833 tty_wakeup(tty);
848} 834}
849 835
@@ -973,14 +959,15 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
973 m68328_uart *uart = &uart_addr[info->line]; 959 m68328_uart *uart = &uart_addr[info->line];
974#endif 960#endif
975 unsigned char status; 961 unsigned char status;
962 unsigned long flags;
976 963
977 cli(); 964 local_irq_save(flags);
978#ifdef CONFIG_SERIAL_68328_RTS_CTS 965#ifdef CONFIG_SERIAL_68328_RTS_CTS
979 status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0; 966 status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
980#else 967#else
981 status = 0; 968 status = 0;
982#endif 969#endif
983 sti(); 970 local_irq_restore(flags);
984 put_user(status,value); 971 put_user(status,value);
985 return 0; 972 return 0;
986} 973}
@@ -994,14 +981,13 @@ static void send_break(struct m68k_serial * info, unsigned int duration)
994 unsigned long flags; 981 unsigned long flags;
995 if (!info->port) 982 if (!info->port)
996 return; 983 return;
997 save_flags(flags); 984 local_irq_save(flags);
998 cli();
999#ifdef USE_INTS 985#ifdef USE_INTS
1000 uart->utx.w |= UTX_SEND_BREAK; 986 uart->utx.w |= UTX_SEND_BREAK;
1001 msleep_interruptible(duration); 987 msleep_interruptible(duration);
1002 uart->utx.w &= ~UTX_SEND_BREAK; 988 uart->utx.w &= ~UTX_SEND_BREAK;
1003#endif 989#endif
1004 restore_flags(flags); 990 local_irq_restore(flags);
1005} 991}
1006 992
1007static int rs_ioctl(struct tty_struct *tty, struct file * file, 993static int rs_ioctl(struct tty_struct *tty, struct file * file,
@@ -1060,7 +1046,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
1060 (struct serial_struct *) arg); 1046 (struct serial_struct *) arg);
1061 case TIOCSERGETLSR: /* Get line status register */ 1047 case TIOCSERGETLSR: /* Get line status register */
1062 if (access_ok(VERIFY_WRITE, (void *) arg, 1048 if (access_ok(VERIFY_WRITE, (void *) arg,
1063 sizeof(unsigned int)); 1049 sizeof(unsigned int)))
1064 return get_lsr_info(info, (unsigned int *) arg); 1050 return get_lsr_info(info, (unsigned int *) arg);
1065 return -EFAULT; 1051 return -EFAULT;
1066 case TIOCSERGSTRUCT: 1052 case TIOCSERGSTRUCT:
@@ -1113,10 +1099,10 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1113 if (!info || serial_paranoia_check(info, tty->name, "rs_close")) 1099 if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
1114 return; 1100 return;
1115 1101
1116 save_flags(flags); cli(); 1102 local_irq_save(flags);
1117 1103
1118 if (tty_hung_up_p(filp)) { 1104 if (tty_hung_up_p(filp)) {
1119 restore_flags(flags); 1105 local_irq_restore(flags);
1120 return; 1106 return;
1121 } 1107 }
1122 1108
@@ -1138,7 +1124,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1138 info->count = 0; 1124 info->count = 0;
1139 } 1125 }
1140 if (info->count) { 1126 if (info->count) {
1141 restore_flags(flags); 1127 local_irq_restore(flags);
1142 return; 1128 return;
1143 } 1129 }
1144 info->flags |= S_CLOSING; 1130 info->flags |= S_CLOSING;
@@ -1186,7 +1172,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1186 } 1172 }
1187 info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING); 1173 info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING);
1188 wake_up_interruptible(&info->close_wait); 1174 wake_up_interruptible(&info->close_wait);
1189 restore_flags(flags); 1175 local_irq_restore(flags);
1190} 1176}
1191 1177
1192/* 1178/*
@@ -1262,9 +1248,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1262 info->count--; 1248 info->count--;
1263 info->blocked_open++; 1249 info->blocked_open++;
1264 while (1) { 1250 while (1) {
1265 cli(); 1251 local_irq_disable();
1266 m68k_rtsdtr(info, 1); 1252 m68k_rtsdtr(info, 1);
1267 sti(); 1253 local_irq_enable();
1268 current->state = TASK_INTERRUPTIBLE; 1254 current->state = TASK_INTERRUPTIBLE;
1269 if (tty_hung_up_p(filp) || 1255 if (tty_hung_up_p(filp) ||
1270 !(info->flags & S_INITIALIZED)) { 1256 !(info->flags & S_INITIALIZED)) {
@@ -1444,7 +1430,7 @@ rs68328_init(void)
1444 return -ENOMEM; 1430 return -ENOMEM;
1445 } 1431 }
1446 1432
1447 save_flags(flags); cli(); 1433 local_irq_save(flags);
1448 1434
1449 for(i=0;i<NR_PORTS;i++) { 1435 for(i=0;i<NR_PORTS;i++) {
1450 1436
@@ -1489,7 +1475,7 @@ rs68328_init(void)
1489 serial_pm[i]->data = info; 1475 serial_pm[i]->data = info;
1490#endif 1476#endif
1491 } 1477 }
1492 restore_flags(flags); 1478 local_irq_restore(flags);
1493 return 0; 1479 return 0;
1494} 1480}
1495 1481
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index bbf78aaf9e01..f361b356bd1d 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2354,7 +2354,6 @@ int __init serial8250_start_console(struct uart_port *port, char *options)
2354static struct uart_driver serial8250_reg = { 2354static struct uart_driver serial8250_reg = {
2355 .owner = THIS_MODULE, 2355 .owner = THIS_MODULE,
2356 .driver_name = "serial", 2356 .driver_name = "serial",
2357 .devfs_name = "tts/",
2358 .dev_name = "ttyS", 2357 .dev_name = "ttyS",
2359 .major = TTY_MAJOR, 2358 .major = TTY_MAJOR,
2360 .minor = 64, 2359 .minor = 64,
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 94886c000d2a..864ef859be56 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -594,8 +594,8 @@ pci_default_setup(struct serial_private *priv, struct pciserial_board *board,
594 else 594 else
595 offset += idx * board->uart_offset; 595 offset += idx * board->uart_offset;
596 596
597 maxnr = (pci_resource_len(priv->dev, bar) - board->first_offset) / 597 maxnr = (pci_resource_len(priv->dev, bar) - board->first_offset) >>
598 (8 << board->reg_shift); 598 (board->reg_shift + 3);
599 599
600 if (board->flags & FL_REGION_SZ_CAP && idx >= maxnr) 600 if (board->flags & FL_REGION_SZ_CAP && idx >= maxnr)
601 return 1; 601 return 1;
diff --git a/drivers/serial/at91_serial.c b/drivers/serial/at91_serial.c
index db5b25fafed4..df9500bdaded 100644
--- a/drivers/serial/at91_serial.c
+++ b/drivers/serial/at91_serial.c
@@ -863,7 +863,6 @@ static struct uart_driver at91_uart = {
863 .owner = THIS_MODULE, 863 .owner = THIS_MODULE,
864 .driver_name = "at91_serial", 864 .driver_name = "at91_serial",
865 .dev_name = AT91_DEVICENAME, 865 .dev_name = AT91_DEVICENAME,
866 .devfs_name = AT91_DEVICENAME,
867 .major = SERIAL_AT91_MAJOR, 866 .major = SERIAL_AT91_MAJOR,
868 .minor = MINOR_START, 867 .minor = MINOR_START,
869 .nr = AT91_NR_UART, 868 .nr = AT91_NR_UART,
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 89700141f87e..b84137cdeb2b 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -2573,12 +2573,6 @@ static void flush_to_flip_buffer(struct e100_serial *info)
2573 2573
2574 DFLIP( 2574 DFLIP(
2575 if (1) { 2575 if (1) {
2576
2577 if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
2578 DEBUG_LOG(info->line, "*** TTY_DONT_FLIP set flip.count %i ***\n", tty->flip.count);
2579 DEBUG_LOG(info->line, "*** recv_cnt %i\n", info->recv_cnt);
2580 } else {
2581 }
2582 DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx); 2576 DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx);
2583 DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty)); 2577 DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty));
2584 DEBUG_LOG(info->line, "room %lu\n", tty->ldisc.receive_room(tty)); 2578 DEBUG_LOG(info->line, "room %lu\n", tty->ldisc.receive_room(tty));
@@ -4884,7 +4878,7 @@ rs_init(void)
4884 driver->init_termios = tty_std_termios; 4878 driver->init_termios = tty_std_termios;
4885 driver->init_termios.c_cflag = 4879 driver->init_termios.c_cflag =
4886 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */ 4880 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
4887 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 4881 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4888 driver->termios = serial_termios; 4882 driver->termios = serial_termios;
4889 driver->termios_locked = serial_termios_locked; 4883 driver->termios_locked = serial_termios_locked;
4890 4884
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index bf71bad5c34f..466d06cc7d37 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -768,11 +768,7 @@ void __init dz_serial_console_init(void)
768static struct uart_driver dz_reg = { 768static struct uart_driver dz_reg = {
769 .owner = THIS_MODULE, 769 .owner = THIS_MODULE,
770 .driver_name = "serial", 770 .driver_name = "serial",
771#ifdef CONFIG_DEVFS
772 .dev_name = "tts/%d",
773#else
774 .dev_name = "ttyS%d", 771 .dev_name = "ttyS%d",
775#endif
776 .major = TTY_MAJOR, 772 .major = TTY_MAJOR,
777 .minor = 64, 773 .minor = 64,
778 .nr = DZ_NB_PORT, 774 .nr = DZ_NB_PORT,
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index d202eb4f3848..da85bafa0942 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -888,7 +888,6 @@ static struct uart_driver imx_reg = {
888 .owner = THIS_MODULE, 888 .owner = THIS_MODULE,
889 .driver_name = DRIVER_NAME, 889 .driver_name = DRIVER_NAME,
890 .dev_name = "ttySMX", 890 .dev_name = "ttySMX",
891 .devfs_name = "ttsmx/",
892 .major = SERIAL_IMX_MAJOR, 891 .major = SERIAL_IMX_MAJOR,
893 .minor = MINOR_START, 892 .minor = MINOR_START,
894 .nr = ARRAY_SIZE(imx_ports), 893 .nr = ARRAY_SIZE(imx_ports),
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 651772474ac1..56b093ecd779 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -1085,7 +1085,6 @@ static struct console ip22zilog_console = {
1085static struct uart_driver ip22zilog_reg = { 1085static struct uart_driver ip22zilog_reg = {
1086 .owner = THIS_MODULE, 1086 .owner = THIS_MODULE,
1087 .driver_name = "serial", 1087 .driver_name = "serial",
1088 .devfs_name = "tts/",
1089 .dev_name = "ttyS", 1088 .dev_name = "ttyS",
1090 .major = TTY_MAJOR, 1089 .major = TTY_MAJOR,
1091 .minor = 64, 1090 .minor = 64,
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 7d823705193c..f8262e6ad8d3 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -589,13 +589,6 @@ void jsm_input(struct jsm_channel *ch)
589 ld = tty_ldisc_ref(tp); 589 ld = tty_ldisc_ref(tp);
590 590
591 /* 591 /*
592 * If the DONT_FLIP flag is on, don't flush our buffer, and act
593 * like the ld doesn't have any space to put the data right now.
594 */
595 if (test_bit(TTY_DONT_FLIP, &tp->flags))
596 len = 0;
597
598 /*
599 * If we were unable to get a reference to the ld, 592 * If we were unable to get a reference to the ld,
600 * don't flush our buffer, and act like the ld doesn't 593 * don't flush our buffer, and act like the ld doesn't
601 * have any space to put the data right now. 594 * have any space to put the data right now.
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c
index 321a40f33b50..6a2a25d9b596 100644
--- a/drivers/serial/m32r_sio.c
+++ b/drivers/serial/m32r_sio.c
@@ -1131,7 +1131,6 @@ console_initcall(m32r_sio_console_init);
1131static struct uart_driver m32r_sio_reg = { 1131static struct uart_driver m32r_sio_reg = {
1132 .owner = THIS_MODULE, 1132 .owner = THIS_MODULE,
1133 .driver_name = "sio", 1133 .driver_name = "sio",
1134 .devfs_name = "tts/",
1135 .dev_name = "ttyS", 1134 .dev_name = "ttyS",
1136 .major = TTY_MAJOR, 1135 .major = TTY_MAJOR,
1137 .minor = 64, 1136 .minor = 64,
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 8ad242934368..29c0630e3e64 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -1713,7 +1713,6 @@ mcfrs_init(void)
1713 /* Initialize the tty_driver structure */ 1713 /* Initialize the tty_driver structure */
1714 mcfrs_serial_driver->owner = THIS_MODULE; 1714 mcfrs_serial_driver->owner = THIS_MODULE;
1715 mcfrs_serial_driver->name = "ttyS"; 1715 mcfrs_serial_driver->name = "ttyS";
1716 mcfrs_serial_driver->devfs_name = "ttys/";
1717 mcfrs_serial_driver->driver_name = "serial"; 1716 mcfrs_serial_driver->driver_name = "serial";
1718 mcfrs_serial_driver->major = TTY_MAJOR; 1717 mcfrs_serial_driver->major = TTY_MAJOR;
1719 mcfrs_serial_driver->minor_start = 64; 1718 mcfrs_serial_driver->minor_start = 64;
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 6459edc7f5c5..1aa34844218c 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -693,7 +693,6 @@ static struct uart_driver mpc52xx_uart_driver = {
693 .owner = THIS_MODULE, 693 .owner = THIS_MODULE,
694 .driver_name = "mpc52xx_psc_uart", 694 .driver_name = "mpc52xx_psc_uart",
695 .dev_name = "ttyPSC", 695 .dev_name = "ttyPSC",
696 .devfs_name = "ttyPSC",
697 .major = SERIAL_PSC_MAJOR, 696 .major = SERIAL_PSC_MAJOR,
698 .minor = SERIAL_PSC_MINOR, 697 .minor = SERIAL_PSC_MINOR,
699 .nr = MPC52xx_PSC_MAXNUM, 698 .nr = MPC52xx_PSC_MAXNUM,
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 94681922ea0a..1cd102f84bfa 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -315,7 +315,6 @@ struct mpsc_port_info *mpsc_device_remove(int index);
315#define MPSC_MAJOR 204 315#define MPSC_MAJOR 204
316#define MPSC_MINOR_START 44 316#define MPSC_MINOR_START 44
317#define MPSC_DRIVER_NAME "MPSC" 317#define MPSC_DRIVER_NAME "MPSC"
318#define MPSC_DEVFS_NAME "ttymm/"
319#define MPSC_DEV_NAME "ttyMM" 318#define MPSC_DEV_NAME "ttyMM"
320#define MPSC_VERSION "1.00" 319#define MPSC_VERSION "1.00"
321 320
@@ -1863,7 +1862,6 @@ static struct platform_driver mpsc_shared_driver = {
1863static struct uart_driver mpsc_reg = { 1862static struct uart_driver mpsc_reg = {
1864 .owner = THIS_MODULE, 1863 .owner = THIS_MODULE,
1865 .driver_name = MPSC_DRIVER_NAME, 1864 .driver_name = MPSC_DRIVER_NAME,
1866 .devfs_name = MPSC_DEVFS_NAME,
1867 .dev_name = MPSC_DEV_NAME, 1865 .dev_name = MPSC_DEV_NAME,
1868 .major = MPSC_MAJOR, 1866 .major = MPSC_MAJOR,
1869 .minor = MPSC_MINOR_START, 1867 .minor = MPSC_MINOR_START,
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 513ff8597707..e3ba7e17a240 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -101,7 +101,6 @@ static DEFINE_MUTEX(pmz_irq_mutex);
101static struct uart_driver pmz_uart_reg = { 101static struct uart_driver pmz_uart_reg = {
102 .owner = THIS_MODULE, 102 .owner = THIS_MODULE,
103 .driver_name = "ttyS", 103 .driver_name = "ttyS",
104 .devfs_name = "tts/",
105 .dev_name = "ttyS", 104 .dev_name = "ttyS",
106 .major = TTY_MAJOR, 105 .major = TTY_MAJOR,
107}; 106};
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index ae3649568541..0fa0ccc9ed27 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -780,7 +780,6 @@ static struct uart_pxa_port serial_pxa_ports[] = {
780static struct uart_driver serial_pxa_reg = { 780static struct uart_driver serial_pxa_reg = {
781 .owner = THIS_MODULE, 781 .owner = THIS_MODULE,
782 .driver_name = "PXA serial", 782 .driver_name = "PXA serial",
783 .devfs_name = "tts/",
784 .dev_name = "ttyS", 783 .dev_name = "ttyS",
785 .major = TTY_MAJOR, 784 .major = TTY_MAJOR,
786 .minor = 64, 785 .minor = 64,
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 837b6da520b3..4c62ab949ecc 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -149,7 +149,6 @@ s3c24xx_serial_dbg(const char *fmt, ...)
149/* UART name and device definitions */ 149/* UART name and device definitions */
150 150
151#define S3C24XX_SERIAL_NAME "ttySAC" 151#define S3C24XX_SERIAL_NAME "ttySAC"
152#define S3C24XX_SERIAL_DEVFS "tts/"
153#define S3C24XX_SERIAL_MAJOR 204 152#define S3C24XX_SERIAL_MAJOR 204
154#define S3C24XX_SERIAL_MINOR 64 153#define S3C24XX_SERIAL_MINOR 64
155 154
@@ -952,7 +951,6 @@ static struct uart_driver s3c24xx_uart_drv = {
952 .nr = 3, 951 .nr = 3,
953 .cons = S3C24XX_SERIAL_CONSOLE, 952 .cons = S3C24XX_SERIAL_CONSOLE,
954 .driver_name = S3C24XX_SERIAL_NAME, 953 .driver_name = S3C24XX_SERIAL_NAME,
955 .devfs_name = S3C24XX_SERIAL_DEVFS,
956 .major = S3C24XX_SERIAL_MAJOR, 954 .major = S3C24XX_SERIAL_MAJOR,
957 .minor = S3C24XX_SERIAL_MINOR, 955 .minor = S3C24XX_SERIAL_MINOR,
958}; 956};
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index c2d9068b491d..8bbd8567669c 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -816,7 +816,6 @@ static struct uart_driver sa1100_reg = {
816 .owner = THIS_MODULE, 816 .owner = THIS_MODULE,
817 .driver_name = "ttySA", 817 .driver_name = "ttySA",
818 .dev_name = "ttySA", 818 .dev_name = "ttySA",
819 .devfs_name = "ttySA",
820 .major = SERIAL_SA1100_MAJOR, 819 .major = SERIAL_SA1100_MAJOR,
821 .minor = MINOR_START, 820 .minor = MINOR_START,
822 .nr = NR_PORTS, 821 .nr = NR_PORTS,
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 17839e753e4c..7dc1e67b6851 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2153,7 +2153,6 @@ int uart_register_driver(struct uart_driver *drv)
2153 2153
2154 normal->owner = drv->owner; 2154 normal->owner = drv->owner;
2155 normal->driver_name = drv->driver_name; 2155 normal->driver_name = drv->driver_name;
2156 normal->devfs_name = drv->devfs_name;
2157 normal->name = drv->dev_name; 2156 normal->name = drv->dev_name;
2158 normal->major = drv->major; 2157 normal->major = drv->major;
2159 normal->minor_start = drv->minor; 2158 normal->minor_start = drv->minor;
@@ -2161,7 +2160,7 @@ int uart_register_driver(struct uart_driver *drv)
2161 normal->subtype = SERIAL_TYPE_NORMAL; 2160 normal->subtype = SERIAL_TYPE_NORMAL;
2162 normal->init_termios = tty_std_termios; 2161 normal->init_termios = tty_std_termios;
2163 normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2162 normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2164 normal->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 2163 normal->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
2165 normal->driver_state = drv; 2164 normal->driver_state = drv;
2166 tty_set_operations(normal, &uart_ops); 2165 tty_set_operations(normal, &uart_ops);
2167 2166
@@ -2312,7 +2311,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
2312 mutex_unlock(&state->mutex); 2311 mutex_unlock(&state->mutex);
2313 2312
2314 /* 2313 /*
2315 * Remove the devices from devfs 2314 * Remove the devices from the tty layer
2316 */ 2315 */
2317 tty_unregister_device(drv->tty_driver, port->line); 2316 tty_unregister_device(drv->tty_driver, port->line);
2318 2317
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 3bdee64d1a99..a901a7e446f3 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -69,12 +69,10 @@ static char *serial_name = "TX39/49 Serial driver";
69#if !defined(CONFIG_SERIAL_TXX9_STDSERIAL) 69#if !defined(CONFIG_SERIAL_TXX9_STDSERIAL)
70/* "ttyS" is used for standard serial driver */ 70/* "ttyS" is used for standard serial driver */
71#define TXX9_TTY_NAME "ttyTX" 71#define TXX9_TTY_NAME "ttyTX"
72#define TXX9_TTY_DEVFS_NAME "tttx/"
73#define TXX9_TTY_MINOR_START (64 + 64) /* ttyTX0(128), ttyTX1(129) */ 72#define TXX9_TTY_MINOR_START (64 + 64) /* ttyTX0(128), ttyTX1(129) */
74#else 73#else
75/* acts like standard serial driver */ 74/* acts like standard serial driver */
76#define TXX9_TTY_NAME "ttyS" 75#define TXX9_TTY_NAME "ttyS"
77#define TXX9_TTY_DEVFS_NAME "tts/"
78#define TXX9_TTY_MINOR_START 64 76#define TXX9_TTY_MINOR_START 64
79#endif 77#endif
80#define TXX9_TTY_MAJOR TTY_MAJOR 78#define TXX9_TTY_MAJOR TTY_MAJOR
@@ -971,7 +969,6 @@ console_initcall(serial_txx9_console_init);
971static struct uart_driver serial_txx9_reg = { 969static struct uart_driver serial_txx9_reg = {
972 .owner = THIS_MODULE, 970 .owner = THIS_MODULE,
973 .driver_name = "serial_txx9", 971 .driver_name = "serial_txx9",
974 .devfs_name = TXX9_TTY_DEVFS_NAME,
975 .dev_name = TXX9_TTY_NAME, 972 .dev_name = TXX9_TTY_NAME,
976 .major = TXX9_TTY_MAJOR, 973 .major = TXX9_TTY_MAJOR,
977 .minor = TXX9_TTY_MINOR_START, 974 .minor = TXX9_TTY_MINOR_START,
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 44f6bf79bbe1..d97f3ca6cc29 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -1699,9 +1699,6 @@ static char banner[] __initdata =
1699static struct uart_driver sci_uart_driver = { 1699static struct uart_driver sci_uart_driver = {
1700 .owner = THIS_MODULE, 1700 .owner = THIS_MODULE,
1701 .driver_name = "sci", 1701 .driver_name = "sci",
1702#ifdef CONFIG_DEVFS_FS
1703 .devfs_name = "ttsc/",
1704#endif
1705 .dev_name = "ttySC", 1702 .dev_name = "ttySC",
1706 .major = SCI_MAJOR, 1703 .major = SCI_MAJOR,
1707 .minor = SCI_MINOR_START, 1704 .minor = SCI_MINOR_START,
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c
index ba22e256c6f7..d36bc4003399 100644
--- a/drivers/serial/sunhv.c
+++ b/drivers/serial/sunhv.c
@@ -353,7 +353,6 @@ static struct uart_ops sunhv_pops = {
353static struct uart_driver sunhv_reg = { 353static struct uart_driver sunhv_reg = {
354 .owner = THIS_MODULE, 354 .owner = THIS_MODULE,
355 .driver_name = "serial", 355 .driver_name = "serial",
356 .devfs_name = "tts/",
357 .dev_name = "ttyS", 356 .dev_name = "ttyS",
358 .major = TTY_MAJOR, 357 .major = TTY_MAJOR,
359}; 358};
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index e4c0fd2d6a9d..7da02d11c364 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -851,7 +851,6 @@ static struct uart_ops sunsab_pops = {
851static struct uart_driver sunsab_reg = { 851static struct uart_driver sunsab_reg = {
852 .owner = THIS_MODULE, 852 .owner = THIS_MODULE,
853 .driver_name = "serial", 853 .driver_name = "serial",
854 .devfs_name = "tts/",
855 .dev_name = "ttyS", 854 .dev_name = "ttyS",
856 .major = TTY_MAJOR, 855 .major = TTY_MAJOR,
857}; 856};
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 0268b307c01e..6e28c25138cf 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1265,7 +1265,6 @@ out:
1265static struct uart_driver sunsu_reg = { 1265static struct uart_driver sunsu_reg = {
1266 .owner = THIS_MODULE, 1266 .owner = THIS_MODULE,
1267 .driver_name = "serial", 1267 .driver_name = "serial",
1268 .devfs_name = "tts/",
1269 .dev_name = "ttyS", 1268 .dev_name = "ttyS",
1270 .major = TTY_MAJOR, 1269 .major = TTY_MAJOR,
1271}; 1270};
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 76c9bac9271f..9f42677287ad 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1017,7 +1017,6 @@ static int zilog_irq = -1;
1017static struct uart_driver sunzilog_reg = { 1017static struct uart_driver sunzilog_reg = {
1018 .owner = THIS_MODULE, 1018 .owner = THIS_MODULE,
1019 .driver_name = "ttyS", 1019 .driver_name = "ttyS",
1020 .devfs_name = "tts/",
1021 .dev_name = "ttyS", 1020 .dev_name = "ttyS",
1022 .major = TTY_MAJOR, 1021 .major = TTY_MAJOR,
1023}; 1022};
diff --git a/drivers/serial/v850e_uart.c b/drivers/serial/v850e_uart.c
index df705fda4243..a0da2aaf71c4 100644
--- a/drivers/serial/v850e_uart.c
+++ b/drivers/serial/v850e_uart.c
@@ -468,7 +468,6 @@ static struct uart_ops v850e_uart_ops = {
468static struct uart_driver v850e_uart_driver = { 468static struct uart_driver v850e_uart_driver = {
469 .owner = THIS_MODULE, 469 .owner = THIS_MODULE,
470 .driver_name = "v850e_uart", 470 .driver_name = "v850e_uart",
471 .devfs_name = "tts/",
472 .dev_name = "ttyS", 471 .dev_name = "ttyS",
473 .major = TTY_MAJOR, 472 .major = TTY_MAJOR,
474 .minor = V850E_UART_MINOR_BASE, 473 .minor = V850E_UART_MINOR_BASE,
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index df5e8713fa31..017571ffa19c 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -911,7 +911,6 @@ static struct uart_driver siu_uart_driver = {
911 .owner = THIS_MODULE, 911 .owner = THIS_MODULE,
912 .driver_name = "SIU", 912 .driver_name = "SIU",
913 .dev_name = "ttyVR", 913 .dev_name = "ttyVR",
914 .devfs_name = "ttvr/",
915 .major = SIU_MAJOR, 914 .major = SIU_MAJOR,
916 .minor = SIU_MINOR_BASE, 915 .minor = SIU_MINOR_BASE,
917 .cons = SERIAL_VR41XX_CONSOLE, 916 .cons = SERIAL_VR41XX_CONSOLE,
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c
index 501316b198e5..ed946311d3a4 100644
--- a/drivers/sn/ioc3.c
+++ b/drivers/sn/ioc3.c
@@ -26,7 +26,7 @@ static DECLARE_RWSEM(ioc3_devices_rwsem);
26 26
27static struct ioc3_submodule *ioc3_submodules[IOC3_MAX_SUBMODULES]; 27static struct ioc3_submodule *ioc3_submodules[IOC3_MAX_SUBMODULES];
28static struct ioc3_submodule *ioc3_ethernet; 28static struct ioc3_submodule *ioc3_ethernet;
29static rwlock_t ioc3_submodules_lock = RW_LOCK_UNLOCKED; 29static DEFINE_RWLOCK(ioc3_submodules_lock);
30 30
31/* NIC probing code */ 31/* NIC probing code */
32 32
diff --git a/drivers/sn/ioc4.c b/drivers/sn/ioc4.c
index 8256a97eb508..8562821e6498 100644
--- a/drivers/sn/ioc4.c
+++ b/drivers/sn/ioc4.c
@@ -438,7 +438,7 @@ static struct pci_device_id ioc4_id_table[] = {
438 {0} 438 {0}
439}; 439};
440 440
441static struct pci_driver __devinitdata ioc4_driver = { 441static struct pci_driver ioc4_driver = {
442 .name = "IOC4", 442 .name = "IOC4",
443 .id_table = ioc4_id_table, 443 .id_table = ioc4_id_table,
444 .probe = ioc4_probe, 444 .probe = ioc4_probe,
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 1cea4a6799fe..ed1cdf6ac8f3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -210,6 +210,7 @@ spi_new_device(struct spi_master *master, struct spi_board_info *chip)
210 proxy->master = master; 210 proxy->master = master;
211 proxy->chip_select = chip->chip_select; 211 proxy->chip_select = chip->chip_select;
212 proxy->max_speed_hz = chip->max_speed_hz; 212 proxy->max_speed_hz = chip->max_speed_hz;
213 proxy->mode = chip->mode;
213 proxy->irq = chip->irq; 214 proxy->irq = chip->irq;
214 proxy->modalias = chip->modalias; 215 proxy->modalias = chip->modalias;
215 216
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 2dffa8e303b2..7f27b356eaf7 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -1745,7 +1745,6 @@ int __init zs_init(void)
1745 /* Not all of this is exactly right for us. */ 1745 /* Not all of this is exactly right for us. */
1746 1746
1747 serial_driver->owner = THIS_MODULE; 1747 serial_driver->owner = THIS_MODULE;
1748 serial_driver->devfs_name = "tts/";
1749 serial_driver->name = "ttyS"; 1748 serial_driver->name = "ttyS";
1750 serial_driver->major = TTY_MAJOR; 1749 serial_driver->major = TTY_MAJOR;
1751 serial_driver->minor_start = 64; 1750 serial_driver->minor_start = 64;
@@ -1754,7 +1753,7 @@ int __init zs_init(void)
1754 serial_driver->init_termios = tty_std_termios; 1753 serial_driver->init_termios = tty_std_termios;
1755 serial_driver->init_termios.c_cflag = 1754 serial_driver->init_termios.c_cflag =
1756 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1755 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1757 serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 1756 serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1758 tty_set_operations(serial_driver, &serial_ops); 1757 tty_set_operations(serial_driver, &serial_ops);
1759 1758
1760 if (tty_register_driver(serial_driver)) 1759 if (tty_register_driver(serial_driver))
diff --git a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
index e166fffea86b..e41f49afd0f4 100644
--- a/drivers/telephony/phonedev.c
+++ b/drivers/telephony/phonedev.c
@@ -28,7 +28,6 @@
28 28
29#include <linux/kmod.h> 29#include <linux/kmod.h>
30#include <linux/sem.h> 30#include <linux/sem.h>
31#include <linux/devfs_fs_kernel.h>
32#include <linux/mutex.h> 31#include <linux/mutex.h>
33 32
34#define PHONE_NUM_DEVICES 256 33#define PHONE_NUM_DEVICES 256
@@ -106,8 +105,6 @@ int phone_register_device(struct phone_device *p, int unit)
106 if (phone_device[i] == NULL) { 105 if (phone_device[i] == NULL) {
107 phone_device[i] = p; 106 phone_device[i] = p;
108 p->minor = i; 107 p->minor = i;
109 devfs_mk_cdev(MKDEV(PHONE_MAJOR,i),
110 S_IFCHR|S_IRUSR|S_IWUSR, "phone/%d", i);
111 mutex_unlock(&phone_lock); 108 mutex_unlock(&phone_lock);
112 return 0; 109 return 0;
113 } 110 }
@@ -125,7 +122,6 @@ void phone_unregister_device(struct phone_device *pfd)
125 mutex_lock(&phone_lock); 122 mutex_lock(&phone_lock);
126 if (phone_device[pfd->minor] != pfd) 123 if (phone_device[pfd->minor] != pfd)
127 panic("phone: bad unregister"); 124 panic("phone: bad unregister");
128 devfs_remove("phone/%d", pfd->minor);
129 phone_device[pfd->minor] = NULL; 125 phone_device[pfd->minor] = NULL;
130 mutex_unlock(&phone_lock); 126 mutex_unlock(&phone_lock);
131} 127}
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index d41dc67ba4cc..3670d77e912c 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1145,12 +1145,11 @@ static int __init acm_init(void)
1145 acm_tty_driver->owner = THIS_MODULE, 1145 acm_tty_driver->owner = THIS_MODULE,
1146 acm_tty_driver->driver_name = "acm", 1146 acm_tty_driver->driver_name = "acm",
1147 acm_tty_driver->name = "ttyACM", 1147 acm_tty_driver->name = "ttyACM",
1148 acm_tty_driver->devfs_name = "usb/acm/",
1149 acm_tty_driver->major = ACM_TTY_MAJOR, 1148 acm_tty_driver->major = ACM_TTY_MAJOR,
1150 acm_tty_driver->minor_start = 0, 1149 acm_tty_driver->minor_start = 0,
1151 acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL, 1150 acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL,
1152 acm_tty_driver->subtype = SERIAL_TYPE_NORMAL, 1151 acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
1153 acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS, 1152 acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1154 acm_tty_driver->init_termios = tty_std_termios; 1153 acm_tty_driver->init_termios = tty_std_termios;
1155 acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1154 acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1156 tty_set_operations(acm_tty_driver, &acm_ops); 1155 tty_set_operations(acm_tty_driver, &acm_ops);
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 269ce7f4ad66..735e9dbd39fd 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -60,7 +60,7 @@
60#include <linux/usb_ch9.h> 60#include <linux/usb_ch9.h>
61#include <linux/usb_gadget.h> 61#include <linux/usb_gadget.h>
62 62
63#include <asm/arch/hardware/intel_udc.h> 63#include <asm/arch/udc.h>
64 64
65 65
66/* 66/*
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 9d6e1d295528..416acac879df 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -588,12 +588,11 @@ static int __init gs_module_init(void)
588 gs_tty_driver->owner = THIS_MODULE; 588 gs_tty_driver->owner = THIS_MODULE;
589 gs_tty_driver->driver_name = GS_SHORT_NAME; 589 gs_tty_driver->driver_name = GS_SHORT_NAME;
590 gs_tty_driver->name = "ttygs"; 590 gs_tty_driver->name = "ttygs";
591 gs_tty_driver->devfs_name = "usb/ttygs/";
592 gs_tty_driver->major = GS_MAJOR; 591 gs_tty_driver->major = GS_MAJOR;
593 gs_tty_driver->minor_start = GS_MINOR_START; 592 gs_tty_driver->minor_start = GS_MINOR_START;
594 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 593 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
595 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL; 594 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
596 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 595 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
597 gs_tty_driver->init_termios = tty_std_termios; 596 gs_tty_driver->init_termios = tty_std_termios;
598 gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 597 gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
599 tty_set_operations(gs_tty_driver, &gs_tty_ops); 598 tty_set_operations(gs_tty_driver, &gs_tty_ops);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 6b4bc3f2bd86..89bcda5a3298 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1684,9 +1684,13 @@ sl811h_probe(struct platform_device *dev)
1684 if (!addr || !data) 1684 if (!addr || !data)
1685 return -ENODEV; 1685 return -ENODEV;
1686 ioaddr = 1; 1686 ioaddr = 1;
1687 1687 /*
1688 addr_reg = (void __iomem *) addr->start; 1688 * NOTE: 64-bit resource->start is getting truncated
1689 data_reg = (void __iomem *) data->start; 1689 * to avoid compiler warning, assuming that ->start
1690 * is always 32-bit for this case
1691 */
1692 addr_reg = (void __iomem *) (unsigned long) addr->start;
1693 data_reg = (void __iomem *) (unsigned long) data->start;
1690 } else { 1694 } else {
1691 addr_reg = ioremap(addr->start, 1); 1695 addr_reg = ioremap(addr->start, 1);
1692 if (addr_reg == NULL) { 1696 if (addr_reg == NULL) {
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 9432c7302275..d7f3f736a692 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -453,8 +453,7 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
453 tty = port->tty; 453 tty = port->tty;
454 454
455 /* 455 /*
456 * FIXME: must not do this in IRQ context, 456 * FIXME: must not do this in IRQ context
457 * must honour TTY_DONT_FLIP
458 */ 457 */
459 tty->ldisc.receive_buf( 458 tty->ldisc.receive_buf(
460 tty, 459 tty,
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a30135c7cfe6..f466f89eeb6d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1059,13 +1059,12 @@ static int __init usb_serial_init(void)
1059 1059
1060 usb_serial_tty_driver->owner = THIS_MODULE; 1060 usb_serial_tty_driver->owner = THIS_MODULE;
1061 usb_serial_tty_driver->driver_name = "usbserial"; 1061 usb_serial_tty_driver->driver_name = "usbserial";
1062 usb_serial_tty_driver->devfs_name = "usb/tts/";
1063 usb_serial_tty_driver->name = "ttyUSB"; 1062 usb_serial_tty_driver->name = "ttyUSB";
1064 usb_serial_tty_driver->major = SERIAL_TTY_MAJOR; 1063 usb_serial_tty_driver->major = SERIAL_TTY_MAJOR;
1065 usb_serial_tty_driver->minor_start = 0; 1064 usb_serial_tty_driver->minor_start = 0;
1066 usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1065 usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1067 usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1066 usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL;
1068 usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 1067 usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1069 usb_serial_tty_driver->init_termios = tty_std_termios; 1068 usb_serial_tty_driver->init_termios = tty_std_termios;
1070 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1069 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1071 tty_set_operations(usb_serial_tty_driver, &serial_ops); 1070 tty_set_operations(usb_serial_tty_driver, &serial_ops);
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index 7de66b855d4e..1755dddf1899 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -40,14 +40,14 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata,
40 40
41 mutex_unlock(&info->bl_mutex); 41 mutex_unlock(&info->bl_mutex);
42 42
43 if (pdata->negative)
44 rlevel = MAX_RADEON_LEVEL - rlevel;
45
46 if (rlevel < 0) 43 if (rlevel < 0)
47 rlevel = 0; 44 rlevel = 0;
48 else if (rlevel > MAX_RADEON_LEVEL) 45 else if (rlevel > MAX_RADEON_LEVEL)
49 rlevel = MAX_RADEON_LEVEL; 46 rlevel = MAX_RADEON_LEVEL;
50 47
48 if (pdata->negative)
49 rlevel = MAX_RADEON_LEVEL - rlevel;
50
51 return rlevel; 51 return rlevel;
52} 52}
53 53
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index d63c3f485853..9ef68cd83bb4 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void)
743{ 743{
744 driver_unregister(&au1100fb_driver); 744 driver_unregister(&au1100fb_driver);
745 745
746 if (drv_info.opt_mode) 746 kfree(drv_info.opt_mode);
747 kfree(drv_info.opt_mode);
748} 747}
749 748
750module_init(au1100fb_init); 749module_init(au1100fb_init);
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index a71e984c93d4..ffc72ae3ada8 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -27,7 +27,7 @@
27 27
28static int hp680bl_suspended; 28static int hp680bl_suspended;
29static int current_intensity = 0; 29static int current_intensity = 0;
30static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED; 30static DEFINE_SPINLOCK(bl_lock);
31static struct backlight_device *hp680_backlight_device; 31static struct backlight_device *hp680_backlight_device;
32 32
33static void hp680bl_send_intensity(struct backlight_device *bd) 33static void hp680bl_send_intensity(struct backlight_device *bd)
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index f32b590730f2..01401cd63ac0 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -390,7 +390,7 @@ static const char *vgacon_startup(void)
390 vga_video_port_val = VGA_CRT_DM; 390 vga_video_port_val = VGA_CRT_DM;
391 if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) { 391 if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) {
392 static struct resource ega_console_resource = 392 static struct resource ega_console_resource =
393 { "ega", 0x3B0, 0x3BF }; 393 { .name = "ega", .start = 0x3B0, .end = 0x3BF };
394 vga_video_type = VIDEO_TYPE_EGAM; 394 vga_video_type = VIDEO_TYPE_EGAM;
395 vga_vram_size = 0x8000; 395 vga_vram_size = 0x8000;
396 display_desc = "EGA+"; 396 display_desc = "EGA+";
@@ -398,9 +398,9 @@ static const char *vgacon_startup(void)
398 &ega_console_resource); 398 &ega_console_resource);
399 } else { 399 } else {
400 static struct resource mda1_console_resource = 400 static struct resource mda1_console_resource =
401 { "mda", 0x3B0, 0x3BB }; 401 { .name = "mda", .start = 0x3B0, .end = 0x3BB };
402 static struct resource mda2_console_resource = 402 static struct resource mda2_console_resource =
403 { "mda", 0x3BF, 0x3BF }; 403 { .name = "mda", .start = 0x3BF, .end = 0x3BF };
404 vga_video_type = VIDEO_TYPE_MDA; 404 vga_video_type = VIDEO_TYPE_MDA;
405 vga_vram_size = 0x2000; 405 vga_vram_size = 0x2000;
406 display_desc = "*MDA"; 406 display_desc = "*MDA";
@@ -423,14 +423,14 @@ static const char *vgacon_startup(void)
423 423
424 if (!ORIG_VIDEO_ISVGA) { 424 if (!ORIG_VIDEO_ISVGA) {
425 static struct resource ega_console_resource 425 static struct resource ega_console_resource
426 = { "ega", 0x3C0, 0x3DF }; 426 = { .name = "ega", .start = 0x3C0, .end = 0x3DF };
427 vga_video_type = VIDEO_TYPE_EGAC; 427 vga_video_type = VIDEO_TYPE_EGAC;
428 display_desc = "EGA"; 428 display_desc = "EGA";
429 request_resource(&ioport_resource, 429 request_resource(&ioport_resource,
430 &ega_console_resource); 430 &ega_console_resource);
431 } else { 431 } else {
432 static struct resource vga_console_resource 432 static struct resource vga_console_resource
433 = { "vga+", 0x3C0, 0x3DF }; 433 = { .name = "vga+", .start = 0x3C0, .end = 0x3DF };
434 vga_video_type = VIDEO_TYPE_VGAC; 434 vga_video_type = VIDEO_TYPE_VGAC;
435 display_desc = "VGA+"; 435 display_desc = "VGA+";
436 request_resource(&ioport_resource, 436 request_resource(&ioport_resource,
@@ -474,7 +474,7 @@ static const char *vgacon_startup(void)
474 } 474 }
475 } else { 475 } else {
476 static struct resource cga_console_resource = 476 static struct resource cga_console_resource =
477 { "cga", 0x3D4, 0x3D5 }; 477 { .name = "cga", .start = 0x3D4, .end = 0x3D5 };
478 vga_video_type = VIDEO_TYPE_CGA; 478 vga_video_type = VIDEO_TYPE_CGA;
479 vga_vram_size = 0x2000; 479 vga_vram_size = 0x2000;
480 display_desc = "*CGA"; 480 display_desc = "*CGA";
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 31143afe7c95..a171daab0ad0 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -32,7 +32,6 @@
32#ifdef CONFIG_KMOD 32#ifdef CONFIG_KMOD
33#include <linux/kmod.h> 33#include <linux/kmod.h>
34#endif 34#endif
35#include <linux/devfs_fs_kernel.h>
36#include <linux/err.h> 35#include <linux/err.h>
37#include <linux/device.h> 36#include <linux/device.h>
38#include <linux/efi.h> 37#include <linux/efi.h>
@@ -1331,8 +1330,6 @@ register_framebuffer(struct fb_info *fb_info)
1331 fb_add_videomode(&mode, &fb_info->modelist); 1330 fb_add_videomode(&mode, &fb_info->modelist);
1332 registered_fb[i] = fb_info; 1331 registered_fb[i] = fb_info;
1333 1332
1334 devfs_mk_cdev(MKDEV(FB_MAJOR, i),
1335 S_IFCHR | S_IRUGO | S_IWUGO, "fb/%d", i);
1336 event.info = fb_info; 1333 event.info = fb_info;
1337 blocking_notifier_call_chain(&fb_notifier_list, 1334 blocking_notifier_call_chain(&fb_notifier_list,
1338 FB_EVENT_FB_REGISTERED, &event); 1335 FB_EVENT_FB_REGISTERED, &event);
@@ -1359,7 +1356,6 @@ unregister_framebuffer(struct fb_info *fb_info)
1359 i = fb_info->node; 1356 i = fb_info->node;
1360 if (!registered_fb[i]) 1357 if (!registered_fb[i])
1361 return -EINVAL; 1358 return -EINVAL;
1362 devfs_remove("fb/%d", i);
1363 1359
1364 if (fb_info->pixmap.addr && 1360 if (fb_info->pixmap.addr &&
1365 (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT)) 1361 (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
@@ -1432,7 +1428,6 @@ fbmem_init(void)
1432{ 1428{
1433 create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL); 1429 create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL);
1434 1430
1435 devfs_mk_dir("fb");
1436 if (register_chrdev(FB_MAJOR,"fb",&fb_fops)) 1431 if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
1437 printk("unable to get major %d for fb devs\n", FB_MAJOR); 1432 printk("unable to get major %d for fb devs\n", FB_MAJOR);
1438 1433
diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
index 2e6df1fcb2b9..c0cc5e3ba7b5 100644
--- a/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -23,6 +23,8 @@
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/mtrr.h> 24#include <asm/mtrr.h>
25 25
26#include <setup_arch.h>
27
26#define INCLUDE_TIMING_TABLE_DATA 28#define INCLUDE_TIMING_TABLE_DATA
27#define DBE_REG_BASE par->regs 29#define DBE_REG_BASE par->regs
28#include <video/sgivw.h> 30#include <video/sgivw.h>
@@ -42,10 +44,6 @@ struct sgivw_par {
42 * The default can be overridden if the driver is compiled as a module 44 * The default can be overridden if the driver is compiled as a module
43 */ 45 */
44 46
45/* set by arch/i386/kernel/setup.c */
46extern unsigned long sgivwfb_mem_phys;
47extern unsigned long sgivwfb_mem_size;
48
49static int ypan = 0; 47static int ypan = 0;
50static int ywrap = 0; 48static int ywrap = 0;
51 49
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index 12e1baa4508d..8d45ed668837 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -932,6 +932,8 @@ v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
932 r.rcall || r.err); 932 r.rcall || r.err);
933 } while (!r.rcall && !r.err && err==-ERESTARTSYS && 933 } while (!r.rcall && !r.err && err==-ERESTARTSYS &&
934 m->trans->status==Connected && !m->err); 934 m->trans->status==Connected && !m->err);
935
936 err = -ERESTARTSYS;
935 } 937 }
936 sigpending = 1; 938 sigpending = 1;
937 } 939 }
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index f867b8d3e973..450b0c1b385e 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -38,7 +38,7 @@
38 */ 38 */
39 39
40extern struct file_system_type v9fs_fs_type; 40extern struct file_system_type v9fs_fs_type;
41extern struct address_space_operations v9fs_addr_operations; 41extern const struct address_space_operations v9fs_addr_operations;
42extern const struct file_operations v9fs_file_operations; 42extern const struct file_operations v9fs_file_operations;
43extern const struct file_operations v9fs_dir_operations; 43extern const struct file_operations v9fs_dir_operations;
44extern struct dentry_operations v9fs_dentry_operations; 44extern struct dentry_operations v9fs_dentry_operations;
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index efda46fb64d9..d4f0aa3c87f2 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -103,6 +103,6 @@ UnmapAndUnlock:
103 return retval; 103 return retval;
104} 104}
105 105
106struct address_space_operations v9fs_addr_operations = { 106const struct address_space_operations v9fs_addr_operations = {
107 .readpage = v9fs_vfs_readpage, 107 .readpage = v9fs_vfs_readpage,
108}; 108};
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 5c6bdf82146c..2f580a197b8d 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -300,7 +300,7 @@ clunk_fid:
300 fid = V9FS_NOFID; 300 fid = V9FS_NOFID;
301 301
302put_fid: 302put_fid:
303 if (fid >= 0) 303 if (fid != V9FS_NOFID)
304 v9fs_put_idpool(fid, &v9ses->fidpool); 304 v9fs_put_idpool(fid, &v9ses->fidpool);
305 305
306 kfree(fcall); 306 kfree(fcall);
diff --git a/fs/Kconfig b/fs/Kconfig
index 6c5051802bd2..6dc8cfd6d80c 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1116,7 +1116,7 @@ config JFFS2_SUMMARY
1116 1116
1117config JFFS2_FS_XATTR 1117config JFFS2_FS_XATTR
1118 bool "JFFS2 XATTR support (EXPERIMENTAL)" 1118 bool "JFFS2 XATTR support (EXPERIMENTAL)"
1119 depends on JFFS2_FS && EXPERIMENTAL && !JFFS2_FS_WRITEBUFFER 1119 depends on JFFS2_FS && EXPERIMENTAL
1120 default n 1120 default n
1121 help 1121 help
1122 Extended attributes are name:value pairs associated with inodes by 1122 Extended attributes are name:value pairs associated with inodes by
@@ -1722,7 +1722,7 @@ config CIFS_STATS
1722 mounted by the cifs client to be displayed in /proc/fs/cifs/Stats 1722 mounted by the cifs client to be displayed in /proc/fs/cifs/Stats
1723 1723
1724config CIFS_STATS2 1724config CIFS_STATS2
1725 bool "CIFS extended statistics" 1725 bool "Extended statistics"
1726 depends on CIFS_STATS 1726 depends on CIFS_STATS
1727 help 1727 help
1728 Enabling this option will allow more detailed statistics on SMB 1728 Enabling this option will allow more detailed statistics on SMB
@@ -1735,6 +1735,32 @@ config CIFS_STATS2
1735 Unless you are a developer or are doing network performance analysis 1735 Unless you are a developer or are doing network performance analysis
1736 or tuning, say N. 1736 or tuning, say N.
1737 1737
1738config CIFS_WEAK_PW_HASH
1739 bool "Support legacy servers which use weaker LANMAN security"
1740 depends on CIFS
1741 help
1742 Modern CIFS servers including Samba and most Windows versions
1743 (since 1997) support stronger NTLM (and even NTLMv2 and Kerberos)
1744 security mechanisms. These hash the password more securely
1745 than the mechanisms used in the older LANMAN version of the
1746 SMB protocol needed to establish sessions with old SMB servers.
1747
1748 Enabling this option allows the cifs module to mount to older
1749 LANMAN based servers such as OS/2 and Windows 95, but such
1750 mounts may be less secure than mounts using NTLM or more recent
1751 security mechanisms if you are on a public network. Unless you
1752 have a need to access old SMB servers (and are on a private
1753 network) you probably want to say N. Even if this support
1754 is enabled in the kernel build, they will not be used
1755 automatically. At runtime LANMAN mounts are disabled but
1756 can be set to required (or optional) either in
1757 /proc/fs/cifs (see fs/cifs/README for more detail) or via an
1758 option on the mount command. This support is disabled by
1759 default in order to reduce the possibility of a downgrade
1760 attack.
1761
1762 If unsure, say N.
1763
1738config CIFS_XATTR 1764config CIFS_XATTR
1739 bool "CIFS extended attributes" 1765 bool "CIFS extended attributes"
1740 depends on CIFS 1766 depends on CIFS
@@ -1763,6 +1789,16 @@ config CIFS_POSIX
1763 (such as Samba 3.10 and later) which can negotiate 1789 (such as Samba 3.10 and later) which can negotiate
1764 CIFS POSIX ACL support. If unsure, say N. 1790 CIFS POSIX ACL support. If unsure, say N.
1765 1791
1792config CIFS_DEBUG2
1793 bool "Enable additional CIFS debugging routines"
1794 help
1795 Enabling this option adds a few more debugging routines
1796 to the cifs code which slightly increases the size of
1797 the cifs module and can cause additional logging of debug
1798 messages in some error paths, slowing performance. This
1799 option can be turned off unless you are debugging
1800 cifs problems. If unsure, say N.
1801
1766config CIFS_EXPERIMENTAL 1802config CIFS_EXPERIMENTAL
1767 bool "CIFS Experimental Features (EXPERIMENTAL)" 1803 bool "CIFS Experimental Features (EXPERIMENTAL)"
1768 depends on CIFS && EXPERIMENTAL 1804 depends on CIFS && EXPERIMENTAL
@@ -1778,7 +1814,7 @@ config CIFS_EXPERIMENTAL
1778 If unsure, say N. 1814 If unsure, say N.
1779 1815
1780config CIFS_UPCALL 1816config CIFS_UPCALL
1781 bool "CIFS Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)" 1817 bool "Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)"
1782 depends on CIFS_EXPERIMENTAL 1818 depends on CIFS_EXPERIMENTAL
1783 select CONNECTOR 1819 select CONNECTOR
1784 help 1820 help
diff --git a/fs/Makefile b/fs/Makefile
index d0ea6bfccf29..89135428a539 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -66,7 +66,6 @@ obj-$(CONFIG_MSDOS_FS) += msdos/
66obj-$(CONFIG_VFAT_FS) += vfat/ 66obj-$(CONFIG_VFAT_FS) += vfat/
67obj-$(CONFIG_BFS_FS) += bfs/ 67obj-$(CONFIG_BFS_FS) += bfs/
68obj-$(CONFIG_ISO9660_FS) += isofs/ 68obj-$(CONFIG_ISO9660_FS) += isofs/
69obj-$(CONFIG_DEVFS_FS) += devfs/
70obj-$(CONFIG_HFSPLUS_FS) += hfsplus/ # Before hfs to find wrapped HFS+ 69obj-$(CONFIG_HFSPLUS_FS) += hfsplus/ # Before hfs to find wrapped HFS+
71obj-$(CONFIG_HFS_FS) += hfs/ 70obj-$(CONFIG_HFS_FS) += hfs/
72obj-$(CONFIG_VXFS_FS) += freevxfs/ 71obj-$(CONFIG_VXFS_FS) += freevxfs/
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index a02802a30798..534f3eecc985 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -72,7 +72,7 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)
72 return generic_block_bmap(mapping, block, adfs_get_block); 72 return generic_block_bmap(mapping, block, adfs_get_block);
73} 73}
74 74
75static struct address_space_operations adfs_aops = { 75static const struct address_space_operations adfs_aops = {
76 .readpage = adfs_readpage, 76 .readpage = adfs_readpage,
77 .writepage = adfs_writepage, 77 .writepage = adfs_writepage,
78 .sync_page = block_sync_page, 78 .sync_page = block_sync_page,
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index a43a876742b8..0ddd4cc0d1a0 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -195,9 +195,9 @@ extern struct inode_operations affs_symlink_inode_operations;
195extern const struct file_operations affs_file_operations; 195extern const struct file_operations affs_file_operations;
196extern const struct file_operations affs_file_operations_ofs; 196extern const struct file_operations affs_file_operations_ofs;
197extern const struct file_operations affs_dir_operations; 197extern const struct file_operations affs_dir_operations;
198extern struct address_space_operations affs_symlink_aops; 198extern const struct address_space_operations affs_symlink_aops;
199extern struct address_space_operations affs_aops; 199extern const struct address_space_operations affs_aops;
200extern struct address_space_operations affs_aops_ofs; 200extern const struct address_space_operations affs_aops_ofs;
201 201
202extern struct dentry_operations affs_dentry_operations; 202extern struct dentry_operations affs_dentry_operations;
203extern struct dentry_operations affs_dentry_operations_intl; 203extern struct dentry_operations affs_dentry_operations_intl;
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 7076262af39b..3de8590e4f6a 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -406,7 +406,7 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
406{ 406{
407 return generic_block_bmap(mapping,block,affs_get_block); 407 return generic_block_bmap(mapping,block,affs_get_block);
408} 408}
409struct address_space_operations affs_aops = { 409const struct address_space_operations affs_aops = {
410 .readpage = affs_readpage, 410 .readpage = affs_readpage,
411 .writepage = affs_writepage, 411 .writepage = affs_writepage,
412 .sync_page = block_sync_page, 412 .sync_page = block_sync_page,
@@ -759,7 +759,7 @@ out:
759 goto done; 759 goto done;
760} 760}
761 761
762struct address_space_operations affs_aops_ofs = { 762const struct address_space_operations affs_aops_ofs = {
763 .readpage = affs_readpage_ofs, 763 .readpage = affs_readpage_ofs,
764 //.writepage = affs_writepage_ofs, 764 //.writepage = affs_writepage_ofs,
765 //.sync_page = affs_sync_page_ofs, 765 //.sync_page = affs_sync_page_ofs,
diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c
index 426f0f094f23..f802256a5933 100644
--- a/fs/affs/symlink.c
+++ b/fs/affs/symlink.c
@@ -66,7 +66,7 @@ fail:
66 return err; 66 return err;
67} 67}
68 68
69struct address_space_operations affs_symlink_aops = { 69const struct address_space_operations affs_symlink_aops = {
70 .readpage = affs_symlink_readpage, 70 .readpage = affs_symlink_readpage,
71}; 71};
72 72
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 7bb716887e29..67d6634101fd 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -35,7 +35,7 @@ struct inode_operations afs_file_inode_operations = {
35 .getattr = afs_inode_getattr, 35 .getattr = afs_inode_getattr,
36}; 36};
37 37
38struct address_space_operations afs_fs_aops = { 38const struct address_space_operations afs_fs_aops = {
39 .readpage = afs_file_readpage, 39 .readpage = afs_file_readpage,
40 .sync_page = block_sync_page, 40 .sync_page = block_sync_page,
41 .set_page_dirty = __set_page_dirty_nobuffers, 41 .set_page_dirty = __set_page_dirty_nobuffers,
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 72febdf9a35a..e88b3b65ae49 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -69,7 +69,7 @@ extern const struct file_operations afs_dir_file_operations;
69/* 69/*
70 * file.c 70 * file.c
71 */ 71 */
72extern struct address_space_operations afs_fs_aops; 72extern const struct address_space_operations afs_fs_aops;
73extern struct inode_operations afs_file_inode_operations; 73extern struct inode_operations afs_file_inode_operations;
74 74
75#ifdef AFS_CACHING_SUPPORT 75#ifdef AFS_CACHING_SUPPORT
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 08201fab26cd..a83e889a97cd 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -73,7 +73,7 @@ static struct inode_operations befs_dir_inode_operations = {
73 .lookup = befs_lookup, 73 .lookup = befs_lookup,
74}; 74};
75 75
76static struct address_space_operations befs_aops = { 76static const struct address_space_operations befs_aops = {
77 .readpage = befs_readpage, 77 .readpage = befs_readpage,
78 .sync_page = block_sync_page, 78 .sync_page = block_sync_page,
79 .bmap = befs_bmap, 79 .bmap = befs_bmap,
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index 9d791004b21c..31973bbbf057 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -50,7 +50,7 @@ static inline struct bfs_inode_info *BFS_I(struct inode *inode)
50/* file.c */ 50/* file.c */
51extern struct inode_operations bfs_file_inops; 51extern struct inode_operations bfs_file_inops;
52extern const struct file_operations bfs_file_operations; 52extern const struct file_operations bfs_file_operations;
53extern struct address_space_operations bfs_aops; 53extern const struct address_space_operations bfs_aops;
54 54
55/* dir.c */ 55/* dir.c */
56extern struct inode_operations bfs_dir_inops; 56extern struct inode_operations bfs_dir_inops;
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index d83cd74a2e4e..3d5aca28a0a0 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -153,7 +153,7 @@ static sector_t bfs_bmap(struct address_space *mapping, sector_t block)
153 return generic_block_bmap(mapping, block, bfs_get_block); 153 return generic_block_bmap(mapping, block, bfs_get_block);
154} 154}
155 155
156struct address_space_operations bfs_aops = { 156const struct address_space_operations bfs_aops = {
157 .readpage = bfs_readpage, 157 .readpage = bfs_readpage,
158 .writepage = bfs_writepage, 158 .writepage = bfs_writepage,
159 .sync_page = block_sync_page, 159 .sync_page = block_sync_page,
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 028d9fb9c2d5..909cb0595b4e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -12,7 +12,6 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/kmod.h> 13#include <linux/kmod.h>
14#include <linux/major.h> 14#include <linux/major.h>
15#include <linux/devfs_fs_kernel.h>
16#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
17#include <linux/highmem.h> 16#include <linux/highmem.h>
18#include <linux/blkdev.h> 17#include <linux/blkdev.h>
@@ -1095,7 +1094,7 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1095 return blkdev_ioctl(file->f_mapping->host, file, cmd, arg); 1094 return blkdev_ioctl(file->f_mapping->host, file, cmd, arg);
1096} 1095}
1097 1096
1098struct address_space_operations def_blk_aops = { 1097const struct address_space_operations def_blk_aops = {
1099 .readpage = blkdev_readpage, 1098 .readpage = blkdev_readpage,
1100 .writepage = blkdev_writepage, 1099 .writepage = blkdev_writepage,
1101 .sync_page = block_sync_page, 1100 .sync_page = block_sync_page,
diff --git a/fs/buffer.c b/fs/buffer.c
index 373bb6292bdc..e9994722f4a3 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -564,7 +564,7 @@ still_busy:
564 * Completion handler for block_write_full_page() - pages which are unlocked 564 * Completion handler for block_write_full_page() - pages which are unlocked
565 * during I/O, and which have PageWriteback cleared upon I/O completion. 565 * during I/O, and which have PageWriteback cleared upon I/O completion.
566 */ 566 */
567void end_buffer_async_write(struct buffer_head *bh, int uptodate) 567static void end_buffer_async_write(struct buffer_head *bh, int uptodate)
568{ 568{
569 char b[BDEVNAME_SIZE]; 569 char b[BDEVNAME_SIZE];
570 unsigned long flags; 570 unsigned long flags;
@@ -2598,7 +2598,7 @@ int nobh_truncate_page(struct address_space *mapping, loff_t from)
2598 unsigned offset = from & (PAGE_CACHE_SIZE-1); 2598 unsigned offset = from & (PAGE_CACHE_SIZE-1);
2599 unsigned to; 2599 unsigned to;
2600 struct page *page; 2600 struct page *page;
2601 struct address_space_operations *a_ops = mapping->a_ops; 2601 const struct address_space_operations *a_ops = mapping->a_ops;
2602 char *kaddr; 2602 char *kaddr;
2603 int ret = 0; 2603 int ret = 0;
2604 2604
@@ -3166,7 +3166,6 @@ EXPORT_SYMBOL(block_sync_page);
3166EXPORT_SYMBOL(block_truncate_page); 3166EXPORT_SYMBOL(block_truncate_page);
3167EXPORT_SYMBOL(block_write_full_page); 3167EXPORT_SYMBOL(block_write_full_page);
3168EXPORT_SYMBOL(cont_prepare_write); 3168EXPORT_SYMBOL(cont_prepare_write);
3169EXPORT_SYMBOL(end_buffer_async_write);
3170EXPORT_SYMBOL(end_buffer_read_sync); 3169EXPORT_SYMBOL(end_buffer_read_sync);
3171EXPORT_SYMBOL(end_buffer_write_sync); 3170EXPORT_SYMBOL(end_buffer_write_sync);
3172EXPORT_SYMBOL(file_fsync); 3171EXPORT_SYMBOL(file_fsync);
diff --git a/fs/char_dev.c b/fs/char_dev.c
index f3418f7a6e9d..97986635b641 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -14,7 +14,6 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
17#include <linux/devfs_fs_kernel.h>
18#include <linux/seq_file.h> 17#include <linux/seq_file.h>
19 18
20#include <linux/kobject.h> 19#include <linux/kobject.h>
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 7271bb0257f6..a61d17ed1827 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,9 +1,24 @@
1Version 1.44
2------------
3Rewritten sessionsetup support, including support for legacy SMB
4session setup needed for OS/2 and older servers such as Windows 95 and 98.
5Fix oops on ls to OS/2 servers. Add support for level 1 FindFirst
6so we can do search (ls etc.) to OS/2. Do not send NTCreateX
7or recent levels of FindFirst unless server says it supports NT SMBs
8(instead use legacy equivalents from LANMAN dialect). Fix to allow
9NTLMv2 authentication support (now can use stronger password hashing
10on mount if corresponding /proc/fs/cifs/SecurityFlags is set (0x4004).
11Allow override of global cifs security flags on mount via "sec=" option(s).
12
1Version 1.43 13Version 1.43
2------------ 14------------
3POSIX locking to servers which support CIFS POSIX Extensions 15POSIX locking to servers which support CIFS POSIX Extensions
4(disabled by default controlled by proc/fs/cifs/Experimental). 16(disabled by default controlled by proc/fs/cifs/Experimental).
5Handle conversion of long share names (especially Asian languages) 17Handle conversion of long share names (especially Asian languages)
6to Unicode during mount. 18to Unicode during mount. Fix memory leak in sess struct on reconnect.
19Fix rare oops after acpi suspend. Fix O_TRUNC opens to overwrite on
20cifs open which helps rare case when setpathinfo fails or server does
21not support it.
7 22
8Version 1.42 23Version 1.42
9------------ 24------------
diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile
index 58c77254a23b..a26f26ed5a17 100644
--- a/fs/cifs/Makefile
+++ b/fs/cifs/Makefile
@@ -3,4 +3,4 @@
3# 3#
4obj-$(CONFIG_CIFS) += cifs.o 4obj-$(CONFIG_CIFS) += cifs.o
5 5
6cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o ntlmssp.o 6cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o sess.o
diff --git a/fs/cifs/README b/fs/cifs/README
index 0355003f4f0a..7986d0d97ace 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -443,7 +443,10 @@ A partial list of the supported mount options follows:
443 SFU does). In the future the bottom 9 bits of the mode 443 SFU does). In the future the bottom 9 bits of the mode
444 mode also will be emulated using queries of the security 444 mode also will be emulated using queries of the security
445 descriptor (ACL). 445 descriptor (ACL).
446sec Security mode. Allowed values are: 446 sign Must use packet signing (helps avoid unwanted data modification
447 by intermediate systems in the route). Note that signing
448 does not work with lanman or plaintext authentication.
449 sec Security mode. Allowed values are:
447 none attempt to connection as a null user (no name) 450 none attempt to connection as a null user (no name)
448 krb5 Use Kerberos version 5 authentication 451 krb5 Use Kerberos version 5 authentication
449 krb5i Use Kerberos authentication and packet signing 452 krb5i Use Kerberos authentication and packet signing
@@ -453,6 +456,8 @@ sec Security mode. Allowed values are:
453 server requires signing also can be the default) 456 server requires signing also can be the default)
454 ntlmv2 Use NTLMv2 password hashing 457 ntlmv2 Use NTLMv2 password hashing
455 ntlmv2i Use NTLMv2 password hashing with packet signing 458 ntlmv2i Use NTLMv2 password hashing with packet signing
459 lanman (if configured in kernel config) use older
460 lanman hash
456 461
457The mount.cifs mount helper also accepts a few mount options before -o 462The mount.cifs mount helper also accepts a few mount options before -o
458including: 463including:
@@ -485,14 +490,34 @@ PacketSigningEnabled If set to one, cifs packet signing is enabled
485 it. If set to two, cifs packet signing is 490 it. If set to two, cifs packet signing is
486 required even if the server considers packet 491 required even if the server considers packet
487 signing optional. (default 1) 492 signing optional. (default 1)
493SecurityFlags Flags which control security negotiation and
494 also packet signing. Authentication (may/must)
495 flags (e.g. for NTLM and/or NTLMv2) may be combined with
496 the signing flags. Specifying two different password
497 hashing mechanisms (as "must use") on the other hand
498 does not make much sense. Default flags are
499 0x07007
500 (NTLM, NTLMv2 and packet signing allowed). Maximum
501 allowable flags if you want to allow mounts to servers
502 using weaker password hashes is 0x37037 (lanman,
503 plaintext, ntlm, ntlmv2, signing allowed):
504
505 may use packet signing 0x00001
506 must use packet signing 0x01001
507 may use NTLM (most common password hash) 0x00002
508 must use NTLM 0x02002
509 may use NTLMv2 0x00004
510 must use NTLMv2 0x04004
511 may use Kerberos security (not implemented yet) 0x00008
512 must use Kerberos (not implemented yet) 0x08008
513 may use lanman (weak) password hash 0x00010
514 must use lanman password hash 0x10010
515 may use plaintext passwords 0x00020
516 must use plaintext passwords 0x20020
517 (reserved for future packet encryption) 0x00040
518
488cifsFYI If set to one, additional debug information is 519cifsFYI If set to one, additional debug information is
489 logged to the system error log. (default 0) 520 logged to the system error log. (default 0)
490ExtendedSecurity If set to one, SPNEGO session establishment
491 is allowed which enables more advanced
492 secure CIFS session establishment (default 0)
493NTLMV2Enabled If set to one, more secure password hashes
494 are used when the server supports them and
495 when kerberos is not negotiated (default 0)
496traceSMB If set to one, debug information is logged to the 521traceSMB If set to one, debug information is logged to the
497 system error log with the start of smb requests 522 system error log with the start of smb requests
498 and responses (default 0) 523 and responses (default 0)
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index 086ae8f4a207..031cdf293256 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -467,7 +467,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
467 asn1_open(&ctx, security_blob, length); 467 asn1_open(&ctx, security_blob, length);
468 468
469 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 469 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
470 cFYI(1, ("Error decoding negTokenInit header ")); 470 cFYI(1, ("Error decoding negTokenInit header"));
471 return 0; 471 return 0;
472 } else if ((cls != ASN1_APL) || (con != ASN1_CON) 472 } else if ((cls != ASN1_APL) || (con != ASN1_CON)
473 || (tag != ASN1_EOC)) { 473 || (tag != ASN1_EOC)) {
@@ -495,7 +495,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
495 } 495 }
496 496
497 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 497 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
498 cFYI(1, ("Error decoding negTokenInit ")); 498 cFYI(1, ("Error decoding negTokenInit"));
499 return 0; 499 return 0;
500 } else if ((cls != ASN1_CTX) || (con != ASN1_CON) 500 } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
501 || (tag != ASN1_EOC)) { 501 || (tag != ASN1_EOC)) {
@@ -505,7 +505,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
505 } 505 }
506 506
507 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 507 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
508 cFYI(1, ("Error decoding negTokenInit ")); 508 cFYI(1, ("Error decoding negTokenInit"));
509 return 0; 509 return 0;
510 } else if ((cls != ASN1_UNI) || (con != ASN1_CON) 510 } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
511 || (tag != ASN1_SEQ)) { 511 || (tag != ASN1_SEQ)) {
@@ -515,7 +515,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
515 } 515 }
516 516
517 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 517 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
518 cFYI(1, ("Error decoding 2nd part of negTokenInit ")); 518 cFYI(1, ("Error decoding 2nd part of negTokenInit"));
519 return 0; 519 return 0;
520 } else if ((cls != ASN1_CTX) || (con != ASN1_CON) 520 } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
521 || (tag != ASN1_EOC)) { 521 || (tag != ASN1_EOC)) {
@@ -527,7 +527,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
527 527
528 if (asn1_header_decode 528 if (asn1_header_decode
529 (&ctx, &sequence_end, &cls, &con, &tag) == 0) { 529 (&ctx, &sequence_end, &cls, &con, &tag) == 0) {
530 cFYI(1, ("Error decoding 2nd part of negTokenInit ")); 530 cFYI(1, ("Error decoding 2nd part of negTokenInit"));
531 return 0; 531 return 0;
532 } else if ((cls != ASN1_UNI) || (con != ASN1_CON) 532 } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
533 || (tag != ASN1_SEQ)) { 533 || (tag != ASN1_SEQ)) {
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index f4124a32bef8..96abeb738978 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -39,7 +39,7 @@ cifs_dump_mem(char *label, void *data, int length)
39 char *charptr = data; 39 char *charptr = data;
40 char buf[10], line[80]; 40 char buf[10], line[80];
41 41
42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\n", 42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
43 label, length, data); 43 label, length, data);
44 for (i = 0; i < length; i += 16) { 44 for (i = 0; i < length; i += 16) {
45 line[0] = 0; 45 line[0] = 0;
@@ -57,6 +57,57 @@ cifs_dump_mem(char *label, void *data, int length)
57 } 57 }
58} 58}
59 59
60#ifdef CONFIG_CIFS_DEBUG2
61void cifs_dump_detail(struct smb_hdr * smb)
62{
63 cERROR(1,("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
64 smb->Command, smb->Status.CifsError,
65 smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
66 cERROR(1,("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
67}
68
69
70void cifs_dump_mids(struct TCP_Server_Info * server)
71{
72 struct list_head *tmp;
73 struct mid_q_entry * mid_entry;
74
75 if(server == NULL)
76 return;
77
78 cERROR(1,("Dump pending requests:"));
79 spin_lock(&GlobalMid_Lock);
80 list_for_each(tmp, &server->pending_mid_q) {
81 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82 if(mid_entry) {
83 cERROR(1,("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
84 mid_entry->midState,
85 (int)mid_entry->command,
86 mid_entry->pid,
87 mid_entry->tsk,
88 mid_entry->mid));
89#ifdef CONFIG_CIFS_STATS2
90 cERROR(1,("IsLarge: %d buf: %p time rcv: %ld now: %ld",
91 mid_entry->largeBuf,
92 mid_entry->resp_buf,
93 mid_entry->when_received,
94 jiffies));
95#endif /* STATS2 */
96 cERROR(1,("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
97 mid_entry->multiEnd));
98 if(mid_entry->resp_buf) {
99 cifs_dump_detail(mid_entry->resp_buf);
100 cifs_dump_mem("existing buf: ",
101 mid_entry->resp_buf,
102 62 /* fixme */);
103 }
104
105 }
106 }
107 spin_unlock(&GlobalMid_Lock);
108}
109#endif /* CONFIG_CIFS_DEBUG2 */
110
60#ifdef CONFIG_PROC_FS 111#ifdef CONFIG_PROC_FS
61static int 112static int
62cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, 113cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
@@ -73,7 +124,6 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
73 124
74 *beginBuffer = buf + offset; 125 *beginBuffer = buf + offset;
75 126
76
77 length = 127 length =
78 sprintf(buf, 128 sprintf(buf,
79 "Display Internal CIFS Data Structures for Debugging\n" 129 "Display Internal CIFS Data Structures for Debugging\n"
@@ -395,12 +445,12 @@ static read_proc_t traceSMB_read;
395static write_proc_t traceSMB_write; 445static write_proc_t traceSMB_write;
396static read_proc_t multiuser_mount_read; 446static read_proc_t multiuser_mount_read;
397static write_proc_t multiuser_mount_write; 447static write_proc_t multiuser_mount_write;
398static read_proc_t extended_security_read; 448static read_proc_t security_flags_read;
399static write_proc_t extended_security_write; 449static write_proc_t security_flags_write;
400static read_proc_t ntlmv2_enabled_read; 450/* static read_proc_t ntlmv2_enabled_read;
401static write_proc_t ntlmv2_enabled_write; 451static write_proc_t ntlmv2_enabled_write;
402static read_proc_t packet_signing_enabled_read; 452static read_proc_t packet_signing_enabled_read;
403static write_proc_t packet_signing_enabled_write; 453static write_proc_t packet_signing_enabled_write;*/
404static read_proc_t experimEnabled_read; 454static read_proc_t experimEnabled_read;
405static write_proc_t experimEnabled_write; 455static write_proc_t experimEnabled_write;
406static read_proc_t linuxExtensionsEnabled_read; 456static read_proc_t linuxExtensionsEnabled_read;
@@ -458,10 +508,10 @@ cifs_proc_init(void)
458 pde->write_proc = multiuser_mount_write; 508 pde->write_proc = multiuser_mount_write;
459 509
460 pde = 510 pde =
461 create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs, 511 create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs,
462 extended_security_read, NULL); 512 security_flags_read, NULL);
463 if (pde) 513 if (pde)
464 pde->write_proc = extended_security_write; 514 pde->write_proc = security_flags_write;
465 515
466 pde = 516 pde =
467 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs, 517 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
@@ -469,7 +519,7 @@ cifs_proc_init(void)
469 if (pde) 519 if (pde)
470 pde->write_proc = lookupFlag_write; 520 pde->write_proc = lookupFlag_write;
471 521
472 pde = 522/* pde =
473 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs, 523 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
474 ntlmv2_enabled_read, NULL); 524 ntlmv2_enabled_read, NULL);
475 if (pde) 525 if (pde)
@@ -479,7 +529,7 @@ cifs_proc_init(void)
479 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs, 529 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
480 packet_signing_enabled_read, NULL); 530 packet_signing_enabled_read, NULL);
481 if (pde) 531 if (pde)
482 pde->write_proc = packet_signing_enabled_write; 532 pde->write_proc = packet_signing_enabled_write;*/
483} 533}
484 534
485void 535void
@@ -496,9 +546,9 @@ cifs_proc_clean(void)
496#endif 546#endif
497 remove_proc_entry("MultiuserMount", proc_fs_cifs); 547 remove_proc_entry("MultiuserMount", proc_fs_cifs);
498 remove_proc_entry("OplockEnabled", proc_fs_cifs); 548 remove_proc_entry("OplockEnabled", proc_fs_cifs);
499 remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); 549/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
500 remove_proc_entry("ExtendedSecurity",proc_fs_cifs); 550 remove_proc_entry("SecurityFlags",proc_fs_cifs);
501 remove_proc_entry("PacketSigningEnabled",proc_fs_cifs); 551/* remove_proc_entry("PacketSigningEnabled",proc_fs_cifs); */
502 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs); 552 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
503 remove_proc_entry("Experimental",proc_fs_cifs); 553 remove_proc_entry("Experimental",proc_fs_cifs);
504 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs); 554 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
@@ -782,12 +832,12 @@ multiuser_mount_write(struct file *file, const char __user *buffer,
782} 832}
783 833
784static int 834static int
785extended_security_read(char *page, char **start, off_t off, 835security_flags_read(char *page, char **start, off_t off,
786 int count, int *eof, void *data) 836 int count, int *eof, void *data)
787{ 837{
788 int len; 838 int len;
789 839
790 len = sprintf(page, "%d\n", extended_security); 840 len = sprintf(page, "0x%x\n", extended_security);
791 841
792 len -= off; 842 len -= off;
793 *start = page + off; 843 *start = page + off;
@@ -803,24 +853,52 @@ extended_security_read(char *page, char **start, off_t off,
803 return len; 853 return len;
804} 854}
805static int 855static int
806extended_security_write(struct file *file, const char __user *buffer, 856security_flags_write(struct file *file, const char __user *buffer,
807 unsigned long count, void *data) 857 unsigned long count, void *data)
808{ 858{
859 unsigned int flags;
860 char flags_string[12];
809 char c; 861 char c;
810 int rc;
811 862
812 rc = get_user(c, buffer); 863 if((count < 1) || (count > 11))
813 if (rc) 864 return -EINVAL;
814 return rc; 865
815 if (c == '0' || c == 'n' || c == 'N') 866 memset(flags_string, 0, 12);
816 extended_security = 0; 867
817 else if (c == '1' || c == 'y' || c == 'Y') 868 if(copy_from_user(flags_string, buffer, count))
818 extended_security = 1; 869 return -EFAULT;
870
871 if(count < 3) {
872 /* single char or single char followed by null */
873 c = flags_string[0];
874 if (c == '0' || c == 'n' || c == 'N')
875 extended_security = CIFSSEC_DEF; /* default */
876 else if (c == '1' || c == 'y' || c == 'Y')
877 extended_security = CIFSSEC_MAX;
878 return count;
879 }
880 /* else we have a number */
881
882 flags = simple_strtoul(flags_string, NULL, 0);
883
884 cFYI(1,("sec flags 0x%x", flags));
885
886 if(flags <= 0) {
887 cERROR(1,("invalid security flags %s",flags_string));
888 return -EINVAL;
889 }
819 890
891 if(flags & ~CIFSSEC_MASK) {
892 cERROR(1,("attempt to set unsupported security flags 0x%x",
893 flags & ~CIFSSEC_MASK));
894 return -EINVAL;
895 }
896 /* flags look ok - update the global security flags for cifs module */
897 extended_security = flags;
820 return count; 898 return count;
821} 899}
822 900
823static int 901/* static int
824ntlmv2_enabled_read(char *page, char **start, off_t off, 902ntlmv2_enabled_read(char *page, char **start, off_t off,
825 int count, int *eof, void *data) 903 int count, int *eof, void *data)
826{ 904{
@@ -855,6 +933,8 @@ ntlmv2_enabled_write(struct file *file, const char __user *buffer,
855 ntlmv2_support = 0; 933 ntlmv2_support = 0;
856 else if (c == '1' || c == 'y' || c == 'Y') 934 else if (c == '1' || c == 'y' || c == 'Y')
857 ntlmv2_support = 1; 935 ntlmv2_support = 1;
936 else if (c == '2')
937 ntlmv2_support = 2;
858 938
859 return count; 939 return count;
860} 940}
@@ -898,7 +978,7 @@ packet_signing_enabled_write(struct file *file, const char __user *buffer,
898 sign_CIFS_PDUs = 2; 978 sign_CIFS_PDUs = 2;
899 979
900 return count; 980 return count;
901} 981} */
902 982
903 983
904#endif 984#endif
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
index 4304d9dcfb6c..c26cd0d2c6d5 100644
--- a/fs/cifs/cifs_debug.h
+++ b/fs/cifs/cifs_debug.h
@@ -24,6 +24,10 @@
24#define _H_CIFS_DEBUG 24#define _H_CIFS_DEBUG
25 25
26void cifs_dump_mem(char *label, void *data, int length); 26void cifs_dump_mem(char *label, void *data, int length);
27#ifdef CONFIG_CIFS_DEBUG2
28void cifs_dump_detail(struct smb_hdr *);
29void cifs_dump_mids(struct TCP_Server_Info *);
30#endif
27extern int traceSMB; /* flag which enables the function below */ 31extern int traceSMB; /* flag which enables the function below */
28void dump_smb(struct smb_hdr *, int); 32void dump_smb(struct smb_hdr *, int);
29#define CIFS_INFO 0x01 33#define CIFS_INFO 0x01
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index d2b128255944..d2a8b2941fc2 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -22,6 +22,7 @@
22#include "cifs_unicode.h" 22#include "cifs_unicode.h"
23#include "cifs_uniupr.h" 23#include "cifs_uniupr.h"
24#include "cifspdu.h" 24#include "cifspdu.h"
25#include "cifsglob.h"
25#include "cifs_debug.h" 26#include "cifs_debug.h"
26 27
27/* 28/*
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index e7d63737e651..a89efaf78a26 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -26,6 +26,8 @@
26#include "md5.h" 26#include "md5.h"
27#include "cifs_unicode.h" 27#include "cifs_unicode.h"
28#include "cifsproto.h" 28#include "cifsproto.h"
29#include <linux/ctype.h>
30#include <linux/random.h>
29 31
30/* Calculate and return the CIFS signature based on the mac key and the smb pdu */ 32/* Calculate and return the CIFS signature based on the mac key and the smb pdu */
31/* the 16 byte signature must be allocated by the caller */ 33/* the 16 byte signature must be allocated by the caller */
@@ -35,6 +37,8 @@
35 37
36extern void mdfour(unsigned char *out, unsigned char *in, int n); 38extern void mdfour(unsigned char *out, unsigned char *in, int n);
37extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); 39extern void E_md4hash(const unsigned char *passwd, unsigned char *p16);
40extern void SMBencrypt(unsigned char *passwd, unsigned char *c8,
41 unsigned char *p24);
38 42
39static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu, 43static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu,
40 const char * key, char * signature) 44 const char * key, char * signature)
@@ -45,7 +49,7 @@ static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu,
45 return -EINVAL; 49 return -EINVAL;
46 50
47 MD5Init(&context); 51 MD5Init(&context);
48 MD5Update(&context,key,CIFS_SESSION_KEY_SIZE+16); 52 MD5Update(&context,key,CIFS_SESS_KEY_SIZE+16);
49 MD5Update(&context,cifs_pdu->Protocol,cifs_pdu->smb_buf_length); 53 MD5Update(&context,cifs_pdu->Protocol,cifs_pdu->smb_buf_length);
50 MD5Final(signature,&context); 54 MD5Final(signature,&context);
51 return 0; 55 return 0;
@@ -90,7 +94,7 @@ static int cifs_calc_signature2(const struct kvec * iov, int n_vec,
90 return -EINVAL; 94 return -EINVAL;
91 95
92 MD5Init(&context); 96 MD5Init(&context);
93 MD5Update(&context,key,CIFS_SESSION_KEY_SIZE+16); 97 MD5Update(&context,key,CIFS_SESS_KEY_SIZE+16);
94 for(i=0;i<n_vec;i++) { 98 for(i=0;i<n_vec;i++) {
95 if(iov[i].iov_base == NULL) { 99 if(iov[i].iov_base == NULL) {
96 cERROR(1,("null iovec entry")); 100 cERROR(1,("null iovec entry"));
@@ -204,11 +208,12 @@ int cifs_calculate_mac_key(char * key, const char * rn, const char * password)
204 208
205 E_md4hash(password, temp_key); 209 E_md4hash(password, temp_key);
206 mdfour(key,temp_key,16); 210 mdfour(key,temp_key,16);
207 memcpy(key+16,rn, CIFS_SESSION_KEY_SIZE); 211 memcpy(key+16,rn, CIFS_SESS_KEY_SIZE);
208 return 0; 212 return 0;
209} 213}
210 214
211int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_info) 215int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses,
216 const struct nls_table * nls_info)
212{ 217{
213 char temp_hash[16]; 218 char temp_hash[16];
214 struct HMACMD5Context ctx; 219 struct HMACMD5Context ctx;
@@ -225,6 +230,8 @@ int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_
225 user_name_len = strlen(ses->userName); 230 user_name_len = strlen(ses->userName);
226 if(user_name_len > MAX_USERNAME_SIZE) 231 if(user_name_len > MAX_USERNAME_SIZE)
227 return -EINVAL; 232 return -EINVAL;
233 if(ses->domainName == NULL)
234 return -EINVAL; /* BB should we use CIFS_LINUX_DOM */
228 dom_name_len = strlen(ses->domainName); 235 dom_name_len = strlen(ses->domainName);
229 if(dom_name_len > MAX_USERNAME_SIZE) 236 if(dom_name_len > MAX_USERNAME_SIZE)
230 return -EINVAL; 237 return -EINVAL;
@@ -259,16 +266,131 @@ int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_
259 kfree(unicode_buf); 266 kfree(unicode_buf);
260 return 0; 267 return 0;
261} 268}
262void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response) 269
270#ifdef CONFIG_CIFS_WEAK_PW_HASH
271void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key)
272{
273 int i;
274 char password_with_pad[CIFS_ENCPWD_SIZE];
275
276 if(ses->server == NULL)
277 return;
278
279 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
280 strncpy(password_with_pad, ses->password, CIFS_ENCPWD_SIZE);
281
282 if((ses->server->secMode & SECMODE_PW_ENCRYPT) == 0)
283 if(extended_security & CIFSSEC_MAY_PLNTXT) {
284 memcpy(lnm_session_key, password_with_pad, CIFS_ENCPWD_SIZE);
285 return;
286 }
287
288 /* calculate old style session key */
289 /* calling toupper is less broken than repeatedly
290 calling nls_toupper would be since that will never
291 work for UTF8, but neither handles multibyte code pages
292 but the only alternative would be converting to UCS-16 (Unicode)
293 (using a routine something like UniStrupr) then
294 uppercasing and then converting back from Unicode - which
295 would only worth doing it if we knew it were utf8. Basically
296 utf8 and other multibyte codepages each need their own strupper
297 function since a byte at a time will ont work. */
298
299 for(i = 0; i < CIFS_ENCPWD_SIZE; i++) {
300 password_with_pad[i] = toupper(password_with_pad[i]);
301 }
302
303 SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key);
304 /* clear password before we return/free memory */
305 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
306}
307#endif /* CIFS_WEAK_PW_HASH */
308
309static int calc_ntlmv2_hash(struct cifsSesInfo *ses,
310 const struct nls_table * nls_cp)
311{
312 int rc = 0;
313 int len;
314 char nt_hash[16];
315 struct HMACMD5Context * pctxt;
316 wchar_t * user;
317 wchar_t * domain;
318
319 pctxt = kmalloc(sizeof(struct HMACMD5Context), GFP_KERNEL);
320
321 if(pctxt == NULL)
322 return -ENOMEM;
323
324 /* calculate md4 hash of password */
325 E_md4hash(ses->password, nt_hash);
326
327 /* convert Domainname to unicode and uppercase */
328 hmac_md5_init_limK_to_64(nt_hash, 16, pctxt);
329
330 /* convert ses->userName to unicode and uppercase */
331 len = strlen(ses->userName);
332 user = kmalloc(2 + (len * 2), GFP_KERNEL);
333 if(user == NULL)
334 goto calc_exit_2;
335 len = cifs_strtoUCS(user, ses->userName, len, nls_cp);
336 UniStrupr(user);
337 hmac_md5_update((char *)user, 2*len, pctxt);
338
339 /* convert ses->domainName to unicode and uppercase */
340 if(ses->domainName) {
341 len = strlen(ses->domainName);
342
343 domain = kmalloc(2 + (len * 2), GFP_KERNEL);
344 if(domain == NULL)
345 goto calc_exit_1;
346 len = cifs_strtoUCS(domain, ses->domainName, len, nls_cp);
347 UniStrupr(domain);
348
349 hmac_md5_update((char *)domain, 2*len, pctxt);
350
351 kfree(domain);
352 }
353calc_exit_1:
354 kfree(user);
355calc_exit_2:
356 /* BB FIXME what about bytes 24 through 40 of the signing key?
357 compare with the NTLM example */
358 hmac_md5_final(ses->server->mac_signing_key, pctxt);
359
360 return rc;
361}
362
363void setup_ntlmv2_rsp(struct cifsSesInfo * ses, char * resp_buf,
364 const struct nls_table * nls_cp)
365{
366 int rc;
367 struct ntlmv2_resp * buf = (struct ntlmv2_resp *)resp_buf;
368
369 buf->blob_signature = cpu_to_le32(0x00000101);
370 buf->reserved = 0;
371 buf->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
372 get_random_bytes(&buf->client_chal, sizeof(buf->client_chal));
373 buf->reserved2 = 0;
374 buf->names[0].type = 0;
375 buf->names[0].length = 0;
376
377 /* calculate buf->ntlmv2_hash */
378 rc = calc_ntlmv2_hash(ses, nls_cp);
379 if(rc)
380 cERROR(1,("could not get v2 hash rc %d",rc));
381 CalcNTLMv2_response(ses, resp_buf);
382}
383
384void CalcNTLMv2_response(const struct cifsSesInfo * ses, char * v2_session_response)
263{ 385{
264 struct HMACMD5Context context; 386 struct HMACMD5Context context;
387 /* rest of v2 struct already generated */
265 memcpy(v2_session_response + 8, ses->server->cryptKey,8); 388 memcpy(v2_session_response + 8, ses->server->cryptKey,8);
266 /* gen_blob(v2_session_response + 16); */
267 hmac_md5_init_limK_to_64(ses->server->mac_signing_key, 16, &context); 389 hmac_md5_init_limK_to_64(ses->server->mac_signing_key, 16, &context);
268 390
269 hmac_md5_update(ses->server->cryptKey,8,&context); 391 hmac_md5_update(v2_session_response+8,
270/* hmac_md5_update(v2_session_response+16)client thing,8,&context); */ /* BB fix */ 392 sizeof(struct ntlmv2_resp) - 8, &context);
271 393
272 hmac_md5_final(v2_session_response,&context); 394 hmac_md5_final(v2_session_response,&context);
273 cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); /* BB removeme BB */ 395/* cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */
274} 396}
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 8b4de6eaabd0..c28ede599946 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -56,8 +56,8 @@ unsigned int experimEnabled = 0;
56unsigned int linuxExtEnabled = 1; 56unsigned int linuxExtEnabled = 1;
57unsigned int lookupCacheEnabled = 1; 57unsigned int lookupCacheEnabled = 1;
58unsigned int multiuser_mount = 0; 58unsigned int multiuser_mount = 0;
59unsigned int extended_security = 0; 59unsigned int extended_security = CIFSSEC_DEF;
60unsigned int ntlmv2_support = 0; 60/* unsigned int ntlmv2_support = 0; */
61unsigned int sign_CIFS_PDUs = 1; 61unsigned int sign_CIFS_PDUs = 1;
62extern struct task_struct * oplockThread; /* remove sparse warning */ 62extern struct task_struct * oplockThread; /* remove sparse warning */
63struct task_struct * oplockThread = NULL; 63struct task_struct * oplockThread = NULL;
@@ -908,7 +908,7 @@ static int cifs_dnotify_thread(void * dummyarg)
908 struct cifsSesInfo *ses; 908 struct cifsSesInfo *ses;
909 909
910 do { 910 do {
911 if(try_to_freeze()) 911 if (try_to_freeze())
912 continue; 912 continue;
913 set_current_state(TASK_INTERRUPTIBLE); 913 set_current_state(TASK_INTERRUPTIBLE);
914 schedule_timeout(15*HZ); 914 schedule_timeout(15*HZ);
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index d56c0577c710..8f75c6f24701 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -32,7 +32,8 @@
32#define TRUE 1 32#define TRUE 1
33#endif 33#endif
34 34
35extern struct address_space_operations cifs_addr_ops; 35extern const struct address_space_operations cifs_addr_ops;
36extern const struct address_space_operations cifs_addr_ops_smallbuf;
36 37
37/* Functions related to super block operations */ 38/* Functions related to super block operations */
38extern struct super_operations cifs_super_ops; 39extern struct super_operations cifs_super_ops;
@@ -99,5 +100,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
99extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); 100extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
100extern int cifs_ioctl (struct inode * inode, struct file * filep, 101extern int cifs_ioctl (struct inode * inode, struct file * filep,
101 unsigned int command, unsigned long arg); 102 unsigned int command, unsigned long arg);
102#define CIFS_VERSION "1.43" 103#define CIFS_VERSION "1.44"
103#endif /* _CIFSFS_H */ 104#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 006eb33bff5f..6d7cf5f3bc0b 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -88,7 +88,8 @@ enum statusEnum {
88}; 88};
89 89
90enum securityEnum { 90enum securityEnum {
91 NTLM = 0, /* Legacy NTLM012 auth with NTLM hash */ 91 LANMAN = 0, /* Legacy LANMAN auth */
92 NTLM, /* Legacy NTLM012 auth with NTLM hash */
92 NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */ 93 NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */
93 RawNTLMSSP, /* NTLMSSP without SPNEGO */ 94 RawNTLMSSP, /* NTLMSSP without SPNEGO */
94 NTLMSSP, /* NTLMSSP via SPNEGO */ 95 NTLMSSP, /* NTLMSSP via SPNEGO */
@@ -157,7 +158,7 @@ struct TCP_Server_Info {
157 /* 16th byte of RFC1001 workstation name is always null */ 158 /* 16th byte of RFC1001 workstation name is always null */
158 char workstation_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; 159 char workstation_RFC1001_name[SERVER_NAME_LEN_WITH_NULL];
159 __u32 sequence_number; /* needed for CIFS PDU signature */ 160 __u32 sequence_number; /* needed for CIFS PDU signature */
160 char mac_signing_key[CIFS_SESSION_KEY_SIZE + 16]; 161 char mac_signing_key[CIFS_SESS_KEY_SIZE + 16];
161}; 162};
162 163
163/* 164/*
@@ -179,10 +180,13 @@ struct cifsUidInfo {
179struct cifsSesInfo { 180struct cifsSesInfo {
180 struct list_head cifsSessionList; 181 struct list_head cifsSessionList;
181 struct semaphore sesSem; 182 struct semaphore sesSem;
183#if 0
182 struct cifsUidInfo *uidInfo; /* pointer to user info */ 184 struct cifsUidInfo *uidInfo; /* pointer to user info */
185#endif
183 struct TCP_Server_Info *server; /* pointer to server info */ 186 struct TCP_Server_Info *server; /* pointer to server info */
184 atomic_t inUse; /* # of mounts (tree connections) on this ses */ 187 atomic_t inUse; /* # of mounts (tree connections) on this ses */
185 enum statusEnum status; 188 enum statusEnum status;
189 unsigned overrideSecFlg; /* if non-zero override global sec flags */
186 __u16 ipc_tid; /* special tid for connection to IPC share */ 190 __u16 ipc_tid; /* special tid for connection to IPC share */
187 __u16 flags; 191 __u16 flags;
188 char *serverOS; /* name of operating system underlying server */ 192 char *serverOS; /* name of operating system underlying server */
@@ -194,7 +198,7 @@ struct cifsSesInfo {
194 char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for 198 char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
195 TCP names - will ipv6 and sctp addresses fit? */ 199 TCP names - will ipv6 and sctp addresses fit? */
196 char userName[MAX_USERNAME_SIZE + 1]; 200 char userName[MAX_USERNAME_SIZE + 1];
197 char domainName[MAX_USERNAME_SIZE + 1]; 201 char * domainName;
198 char * password; 202 char * password;
199}; 203};
200/* session flags */ 204/* session flags */
@@ -209,12 +213,12 @@ struct cifsTconInfo {
209 struct list_head openFileList; 213 struct list_head openFileList;
210 struct semaphore tconSem; 214 struct semaphore tconSem;
211 struct cifsSesInfo *ses; /* pointer to session associated with */ 215 struct cifsSesInfo *ses; /* pointer to session associated with */
212 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource (in ASCII not UTF) */ 216 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
213 char *nativeFileSystem; 217 char *nativeFileSystem;
214 __u16 tid; /* The 2 byte tree id */ 218 __u16 tid; /* The 2 byte tree id */
215 __u16 Flags; /* optional support bits */ 219 __u16 Flags; /* optional support bits */
216 enum statusEnum tidStatus; 220 enum statusEnum tidStatus;
217 atomic_t useCount; /* how many mounts (explicit or implicit) to this share */ 221 atomic_t useCount; /* how many explicit/implicit mounts to share */
218#ifdef CONFIG_CIFS_STATS 222#ifdef CONFIG_CIFS_STATS
219 atomic_t num_smbs_sent; 223 atomic_t num_smbs_sent;
220 atomic_t num_writes; 224 atomic_t num_writes;
@@ -254,7 +258,7 @@ struct cifsTconInfo {
254 spinlock_t stat_lock; 258 spinlock_t stat_lock;
255#endif /* CONFIG_CIFS_STATS */ 259#endif /* CONFIG_CIFS_STATS */
256 FILE_SYSTEM_DEVICE_INFO fsDevInfo; 260 FILE_SYSTEM_DEVICE_INFO fsDevInfo;
257 FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if file system name truncated */ 261 FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
258 FILE_SYSTEM_UNIX_INFO fsUnixInfo; 262 FILE_SYSTEM_UNIX_INFO fsUnixInfo;
259 unsigned retry:1; 263 unsigned retry:1;
260 unsigned nocase:1; 264 unsigned nocase:1;
@@ -305,7 +309,6 @@ struct cifsFileInfo {
305 atomic_t wrtPending; /* handle in use - defer close */ 309 atomic_t wrtPending; /* handle in use - defer close */
306 struct semaphore fh_sem; /* prevents reopen race after dead ses*/ 310 struct semaphore fh_sem; /* prevents reopen race after dead ses*/
307 char * search_resume_name; /* BB removeme BB */ 311 char * search_resume_name; /* BB removeme BB */
308 unsigned int resume_name_length; /* BB removeme - field renamed and moved BB */
309 struct cifs_search_info srch_inf; 312 struct cifs_search_info srch_inf;
310}; 313};
311 314
@@ -391,9 +394,9 @@ struct mid_q_entry {
391 struct smb_hdr *resp_buf; /* response buffer */ 394 struct smb_hdr *resp_buf; /* response buffer */
392 int midState; /* wish this were enum but can not pass to wait_event */ 395 int midState; /* wish this were enum but can not pass to wait_event */
393 __u8 command; /* smb command code */ 396 __u8 command; /* smb command code */
394 unsigned multiPart:1; /* multiple responses to one SMB request */
395 unsigned largeBuf:1; /* if valid response, is pointer to large buf */ 397 unsigned largeBuf:1; /* if valid response, is pointer to large buf */
396 unsigned multiResp:1; /* multiple trans2 responses for one request */ 398 unsigned multiRsp:1; /* multiple trans2 responses for one request */
399 unsigned multiEnd:1; /* both received */
397}; 400};
398 401
399struct oplock_q_entry { 402struct oplock_q_entry {
@@ -430,15 +433,35 @@ struct dir_notify_req {
430#define CIFS_LARGE_BUFFER 2 433#define CIFS_LARGE_BUFFER 2
431#define CIFS_IOVEC 4 /* array of response buffers */ 434#define CIFS_IOVEC 4 /* array of response buffers */
432 435
433/* Type of session setup needed */ 436/* Security Flags: indicate type of session setup needed */
434#define CIFS_PLAINTEXT 0 437#define CIFSSEC_MAY_SIGN 0x00001
435#define CIFS_LANMAN 1 438#define CIFSSEC_MAY_NTLM 0x00002
436#define CIFS_NTLM 2 439#define CIFSSEC_MAY_NTLMV2 0x00004
437#define CIFS_NTLMSSP_NEG 3 440#define CIFSSEC_MAY_KRB5 0x00008
438#define CIFS_NTLMSSP_AUTH 4 441#ifdef CONFIG_CIFS_WEAK_PW_HASH
439#define CIFS_SPNEGO_INIT 5 442#define CIFSSEC_MAY_LANMAN 0x00010
440#define CIFS_SPNEGO_TARG 6 443#define CIFSSEC_MAY_PLNTXT 0x00020
441 444#endif /* weak passwords */
445#define CIFSSEC_MAY_SEAL 0x00040 /* not supported yet */
446
447#define CIFSSEC_MUST_SIGN 0x01001
448/* note that only one of the following can be set so the
449result of setting MUST flags more than once will be to
450require use of the stronger protocol */
451#define CIFSSEC_MUST_NTLM 0x02002
452#define CIFSSEC_MUST_NTLMV2 0x04004
453#define CIFSSEC_MUST_KRB5 0x08008
454#ifdef CONFIG_CIFS_WEAK_PW_HASH
455#define CIFSSEC_MUST_LANMAN 0x10010
456#define CIFSSEC_MUST_PLNTXT 0x20020
457#define CIFSSEC_MASK 0x37037 /* current flags supported if weak */
458#else
459#define CIFSSEC_MASK 0x07007 /* flags supported if no weak config */
460#endif /* WEAK_PW_HASH */
461#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
462
463#define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2
464#define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2
442/* 465/*
443 ***************************************************************** 466 *****************************************************************
444 * All constants go here 467 * All constants go here
@@ -500,16 +523,16 @@ GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */
500GLOBAL_EXTERN struct list_head GlobalOplock_Q; 523GLOBAL_EXTERN struct list_head GlobalOplock_Q;
501 524
502GLOBAL_EXTERN struct list_head GlobalDnotifyReqList; /* Outstanding dir notify requests */ 525GLOBAL_EXTERN struct list_head GlobalDnotifyReqList; /* Outstanding dir notify requests */
503GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q; /* Dir notify response queue */ 526GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;/* DirNotify response queue */
504 527
505/* 528/*
506 * Global transaction id (XID) information 529 * Global transaction id (XID) information
507 */ 530 */
508GLOBAL_EXTERN unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */ 531GLOBAL_EXTERN unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */
509GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */ 532GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
510GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */ 533GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */
511GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above and list operations */ 534GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above & list operations */
512 /* on midQ entries */ 535 /* on midQ entries */
513GLOBAL_EXTERN char Local_System_Name[15]; 536GLOBAL_EXTERN char Local_System_Name[15];
514 537
515/* 538/*
@@ -531,7 +554,7 @@ GLOBAL_EXTERN atomic_t smBufAllocCount;
531GLOBAL_EXTERN atomic_t midCount; 554GLOBAL_EXTERN atomic_t midCount;
532 555
533/* Misc globals */ 556/* Misc globals */
534GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions 557GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions
535 to be established on existing mount if we 558 to be established on existing mount if we
536 have the uid/password or Kerberos credential 559 have the uid/password or Kerberos credential
537 or equivalent for current user */ 560 or equivalent for current user */
@@ -540,8 +563,8 @@ GLOBAL_EXTERN unsigned int experimEnabled;
540GLOBAL_EXTERN unsigned int lookupCacheEnabled; 563GLOBAL_EXTERN unsigned int lookupCacheEnabled;
541GLOBAL_EXTERN unsigned int extended_security; /* if on, session setup sent 564GLOBAL_EXTERN unsigned int extended_security; /* if on, session setup sent
542 with more secure ntlmssp2 challenge/resp */ 565 with more secure ntlmssp2 challenge/resp */
543GLOBAL_EXTERN unsigned int ntlmv2_support; /* better optional password hash */
544GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */ 566GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */
567GLOBAL_EXTERN unsigned int secFlags;
545GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/ 568GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
546GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */ 569GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */
547GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */ 570GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index b2233ac05bd2..86239023545b 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -16,7 +16,7 @@
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public License 17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software 18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#ifndef _CIFSPDU_H 22#ifndef _CIFSPDU_H
@@ -24,8 +24,14 @@
24 24
25#include <net/sock.h> 25#include <net/sock.h>
26 26
27#ifdef CONFIG_CIFS_WEAK_PW_HASH
28#define LANMAN_PROT 0
29#define CIFS_PROT 1
30#else
27#define CIFS_PROT 0 31#define CIFS_PROT 0
28#define BAD_PROT CIFS_PROT+1 32#endif
33#define POSIX_PROT CIFS_PROT+1
34#define BAD_PROT 0xFFFF
29 35
30/* SMB command codes */ 36/* SMB command codes */
31/* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses 37/* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
@@ -110,7 +116,7 @@
110/* 116/*
111 * Size of the session key (crypto key encrypted with the password 117 * Size of the session key (crypto key encrypted with the password
112 */ 118 */
113#define CIFS_SESSION_KEY_SIZE (24) 119#define CIFS_SESS_KEY_SIZE (24)
114 120
115/* 121/*
116 * Maximum user name length 122 * Maximum user name length
@@ -400,6 +406,29 @@ typedef struct negotiate_req {
400 unsigned char DialectsArray[1]; 406 unsigned char DialectsArray[1];
401} __attribute__((packed)) NEGOTIATE_REQ; 407} __attribute__((packed)) NEGOTIATE_REQ;
402 408
409/* Dialect index is 13 for LANMAN */
410
411typedef struct lanman_neg_rsp {
412 struct smb_hdr hdr; /* wct = 13 */
413 __le16 DialectIndex;
414 __le16 SecurityMode;
415 __le16 MaxBufSize;
416 __le16 MaxMpxCount;
417 __le16 MaxNumberVcs;
418 __le16 RawMode;
419 __le32 SessionKey;
420 __le32 ServerTime;
421 __le16 ServerTimeZone;
422 __le16 EncryptionKeyLength;
423 __le16 Reserved;
424 __u16 ByteCount;
425 unsigned char EncryptionKey[1];
426} __attribute__((packed)) LANMAN_NEG_RSP;
427
428#define READ_RAW_ENABLE 1
429#define WRITE_RAW_ENABLE 2
430#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
431
403typedef struct negotiate_rsp { 432typedef struct negotiate_rsp {
404 struct smb_hdr hdr; /* wct = 17 */ 433 struct smb_hdr hdr; /* wct = 17 */
405 __le16 DialectIndex; 434 __le16 DialectIndex;
@@ -509,7 +538,7 @@ typedef union smb_com_session_setup_andx {
509/* unsigned char * NativeOS; */ 538/* unsigned char * NativeOS; */
510/* unsigned char * NativeLanMan; */ 539/* unsigned char * NativeLanMan; */
511/* unsigned char * PrimaryDomain; */ 540/* unsigned char * PrimaryDomain; */
512 } __attribute__((packed)) resp; /* NTLM response format (with or without extended security */ 541 } __attribute__((packed)) resp; /* NTLM response with or without extended sec*/
513 542
514 struct { /* request format */ 543 struct { /* request format */
515 struct smb_hdr hdr; /* wct = 10 */ 544 struct smb_hdr hdr; /* wct = 10 */
@@ -520,8 +549,8 @@ typedef union smb_com_session_setup_andx {
520 __le16 MaxMpxCount; 549 __le16 MaxMpxCount;
521 __le16 VcNumber; 550 __le16 VcNumber;
522 __u32 SessionKey; 551 __u32 SessionKey;
523 __le16 PassswordLength; 552 __le16 PasswordLength;
524 __u32 Reserved; 553 __u32 Reserved; /* encrypt key len and offset */
525 __le16 ByteCount; 554 __le16 ByteCount;
526 unsigned char AccountPassword[1]; /* followed by */ 555 unsigned char AccountPassword[1]; /* followed by */
527 /* STRING AccountName */ 556 /* STRING AccountName */
@@ -543,6 +572,26 @@ typedef union smb_com_session_setup_andx {
543 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */ 572 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
544} __attribute__((packed)) SESSION_SETUP_ANDX; 573} __attribute__((packed)) SESSION_SETUP_ANDX;
545 574
575/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
576
577struct ntlmssp2_name {
578 __le16 type;
579 __le16 length;
580/* char name[length]; */
581} __attribute__((packed));
582
583struct ntlmv2_resp {
584 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
585 __le32 blob_signature;
586 __u32 reserved;
587 __le64 time;
588 __u64 client_chal; /* random */
589 __u32 reserved2;
590 struct ntlmssp2_name names[1];
591 /* array of name entries could follow ending in minimum 4 byte struct */
592} __attribute__((packed));
593
594
546#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" 595#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
547 596
548/* Capabilities bits (for NTLM SessSetup request) */ 597/* Capabilities bits (for NTLM SessSetup request) */
@@ -573,7 +622,9 @@ typedef struct smb_com_tconx_req {
573} __attribute__((packed)) TCONX_REQ; 622} __attribute__((packed)) TCONX_REQ;
574 623
575typedef struct smb_com_tconx_rsp { 624typedef struct smb_com_tconx_rsp {
576 struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */ 625 struct smb_hdr hdr; /* wct = 3 note that Win2000 has sent wct = 7
626 in some cases on responses. Four unspecified
627 words followed OptionalSupport */
577 __u8 AndXCommand; 628 __u8 AndXCommand;
578 __u8 AndXReserved; 629 __u8 AndXReserved;
579 __le16 AndXOffset; 630 __le16 AndXOffset;
@@ -1323,6 +1374,9 @@ struct smb_t2_rsp {
1323#define SMB_FILE_MAXIMUM_INFO 0x40d 1374#define SMB_FILE_MAXIMUM_INFO 0x40d
1324 1375
1325/* Find File infolevels */ 1376/* Find File infolevels */
1377#define SMB_FIND_FILE_INFO_STANDARD 0x001
1378#define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1379#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1326#define SMB_FIND_FILE_DIRECTORY_INFO 0x101 1380#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1327#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102 1381#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1328#define SMB_FIND_FILE_NAMES_INFO 0x103 1382#define SMB_FIND_FILE_NAMES_INFO 0x103
@@ -1844,13 +1898,13 @@ typedef struct {
1844typedef struct { 1898typedef struct {
1845 __le32 DeviceType; 1899 __le32 DeviceType;
1846 __le32 DeviceCharacteristics; 1900 __le32 DeviceCharacteristics;
1847} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info, level 0x104 */ 1901} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
1848 1902
1849typedef struct { 1903typedef struct {
1850 __le32 Attributes; 1904 __le32 Attributes;
1851 __le32 MaxPathNameComponentLength; 1905 __le32 MaxPathNameComponentLength;
1852 __le32 FileSystemNameLen; 1906 __le32 FileSystemNameLen;
1853 char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */ 1907 char FileSystemName[52]; /* do not have to save this - get subset? */
1854} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO; 1908} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
1855 1909
1856/******************************************************************************/ 1910/******************************************************************************/
@@ -1947,7 +2001,8 @@ typedef struct {
1947 2001
1948struct file_allocation_info { 2002struct file_allocation_info {
1949 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */ 2003 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
1950} __attribute__((packed)); /* size used on disk, level 0x103 for set, 0x105 for query */ 2004} __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2005 0x105 for query */
1951 2006
1952struct file_end_of_file_info { 2007struct file_end_of_file_info {
1953 __le64 FileSize; /* offset to end of file */ 2008 __le64 FileSize; /* offset to end of file */
@@ -2054,7 +2109,7 @@ typedef struct {
2054 __le32 ExtFileAttributes; 2109 __le32 ExtFileAttributes;
2055 __le32 FileNameLength; 2110 __le32 FileNameLength;
2056 char FileName[1]; 2111 char FileName[1];
2057} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF response data area */ 2112} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
2058 2113
2059typedef struct { 2114typedef struct {
2060 __le32 NextEntryOffset; 2115 __le32 NextEntryOffset;
@@ -2069,7 +2124,7 @@ typedef struct {
2069 __le32 FileNameLength; 2124 __le32 FileNameLength;
2070 __le32 EaSize; /* length of the xattrs */ 2125 __le32 EaSize; /* length of the xattrs */
2071 char FileName[1]; 2126 char FileName[1];
2072} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 FF response data area */ 2127} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
2073 2128
2074typedef struct { 2129typedef struct {
2075 __le32 NextEntryOffset; 2130 __le32 NextEntryOffset;
@@ -2086,7 +2141,7 @@ typedef struct {
2086 __le32 Reserved; 2141 __le32 Reserved;
2087 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ 2142 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2088 char FileName[1]; 2143 char FileName[1];
2089} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF response data area */ 2144} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
2090 2145
2091typedef struct { 2146typedef struct {
2092 __le32 NextEntryOffset; 2147 __le32 NextEntryOffset;
@@ -2104,7 +2159,22 @@ typedef struct {
2104 __u8 Reserved; 2159 __u8 Reserved;
2105 __u8 ShortName[12]; 2160 __u8 ShortName[12];
2106 char FileName[1]; 2161 char FileName[1];
2107} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FF response data area */ 2162} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2163
2164typedef struct {
2165 __u32 ResumeKey;
2166 __le16 CreationDate; /* SMB Date */
2167 __le16 CreationTime; /* SMB Time */
2168 __le16 LastAccessDate;
2169 __le16 LastAccessTime;
2170 __le16 LastWriteDate;
2171 __le16 LastWriteTime;
2172 __le32 DataSize; /* File Size (EOF) */
2173 __le32 AllocationSize;
2174 __le16 Attributes; /* verify not u32 */
2175 __u8 FileNameLength;
2176 char FileName[1];
2177} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
2108 2178
2109 2179
2110struct win_dev { 2180struct win_dev {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 310ea2f0e0bf..a5ddc62d6fe6 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -64,14 +64,12 @@ extern int map_smb_to_linux_error(struct smb_hdr *smb);
64extern void header_assemble(struct smb_hdr *, char /* command */ , 64extern void header_assemble(struct smb_hdr *, char /* command */ ,
65 const struct cifsTconInfo *, int /* length of 65 const struct cifsTconInfo *, int /* length of
66 fixed section (word count) in two byte units */); 66 fixed section (word count) in two byte units */);
67#ifdef CONFIG_CIFS_EXPERIMENTAL
68extern int small_smb_init_no_tc(const int smb_cmd, const int wct, 67extern int small_smb_init_no_tc(const int smb_cmd, const int wct,
69 struct cifsSesInfo *ses, 68 struct cifsSesInfo *ses,
70 void ** request_buf); 69 void ** request_buf);
71extern int CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, 70extern int CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses,
72 const int stage, int * pNTLMv2_flg, 71 const int stage,
73 const struct nls_table *nls_cp); 72 const struct nls_table *nls_cp);
74#endif
75extern __u16 GetNextMid(struct TCP_Server_Info *server); 73extern __u16 GetNextMid(struct TCP_Server_Info *server);
76extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, 74extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16,
77 struct cifsTconInfo *); 75 struct cifsTconInfo *);
@@ -285,8 +283,14 @@ extern int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *,
285extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key, 283extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key,
286 __u32 expected_sequence_number); 284 __u32 expected_sequence_number);
287extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); 285extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass);
288extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *); 286extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *,
289extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * ); 287 const struct nls_table *);
288extern void CalcNTLMv2_response(const struct cifsSesInfo *, char * );
289extern void setup_ntlmv2_rsp(struct cifsSesInfo *, char *,
290 const struct nls_table *);
291#ifdef CONFIG_CIFS_WEAK_PW_HASH
292extern void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key);
293#endif /* CIFS_WEAK_PW_HASH */
290extern int CIFSSMBCopy(int xid, 294extern int CIFSSMBCopy(int xid,
291 struct cifsTconInfo *source_tcon, 295 struct cifsTconInfo *source_tcon,
292 const char *fromName, 296 const char *fromName,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 925881e00ff2..19678c575dfc 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -44,8 +44,11 @@ static struct {
44 int index; 44 int index;
45 char *name; 45 char *name;
46} protocols[] = { 46} protocols[] = {
47#ifdef CONFIG_CIFS_WEAK_PW_HASH
48 {LANMAN_PROT, "\2LM1.2X002"},
49#endif /* weak password hashing for legacy clients */
47 {CIFS_PROT, "\2NT LM 0.12"}, 50 {CIFS_PROT, "\2NT LM 0.12"},
48 {CIFS_PROT, "\2POSIX 2"}, 51 {POSIX_PROT, "\2POSIX 2"},
49 {BAD_PROT, "\2"} 52 {BAD_PROT, "\2"}
50}; 53};
51#else 54#else
@@ -53,11 +56,29 @@ static struct {
53 int index; 56 int index;
54 char *name; 57 char *name;
55} protocols[] = { 58} protocols[] = {
59#ifdef CONFIG_CIFS_WEAK_PW_HASH
60 {LANMAN_PROT, "\2LM1.2X002"},
61#endif /* weak password hashing for legacy clients */
56 {CIFS_PROT, "\2NT LM 0.12"}, 62 {CIFS_PROT, "\2NT LM 0.12"},
57 {BAD_PROT, "\2"} 63 {BAD_PROT, "\2"}
58}; 64};
59#endif 65#endif
60 66
67/* define the number of elements in the cifs dialect array */
68#ifdef CONFIG_CIFS_POSIX
69#ifdef CONFIG_CIFS_WEAK_PW_HASH
70#define CIFS_NUM_PROT 3
71#else
72#define CIFS_NUM_PROT 2
73#endif /* CIFS_WEAK_PW_HASH */
74#else /* not posix */
75#ifdef CONFIG_CIFS_WEAK_PW_HASH
76#define CIFS_NUM_PROT 2
77#else
78#define CIFS_NUM_PROT 1
79#endif /* CONFIG_CIFS_WEAK_PW_HASH */
80#endif /* CIFS_POSIX */
81
61 82
62/* Mark as invalid, all open files on tree connections since they 83/* Mark as invalid, all open files on tree connections since they
63 were closed when session to server was lost */ 84 were closed when session to server was lost */
@@ -188,7 +209,6 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
188 return rc; 209 return rc;
189} 210}
190 211
191#ifdef CONFIG_CIFS_EXPERIMENTAL
192int 212int
193small_smb_init_no_tc(const int smb_command, const int wct, 213small_smb_init_no_tc(const int smb_command, const int wct,
194 struct cifsSesInfo *ses, void **request_buf) 214 struct cifsSesInfo *ses, void **request_buf)
@@ -214,7 +234,6 @@ small_smb_init_no_tc(const int smb_command, const int wct,
214 234
215 return rc; 235 return rc;
216} 236}
217#endif /* CONFIG_CIFS_EXPERIMENTAL */
218 237
219/* If the return code is zero, this function must fill in request_buf pointer */ 238/* If the return code is zero, this function must fill in request_buf pointer */
220static int 239static int
@@ -322,7 +341,8 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
322 /* potential retries of smb operations it turns out we can determine */ 341 /* potential retries of smb operations it turns out we can determine */
323 /* from the mid flags when the request buffer can be resent without */ 342 /* from the mid flags when the request buffer can be resent without */
324 /* having to use a second distinct buffer for the response */ 343 /* having to use a second distinct buffer for the response */
325 *response_buf = *request_buf; 344 if(response_buf)
345 *response_buf = *request_buf;
326 346
327 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, 347 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
328 wct /*wct */ ); 348 wct /*wct */ );
@@ -373,8 +393,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
373 NEGOTIATE_RSP *pSMBr; 393 NEGOTIATE_RSP *pSMBr;
374 int rc = 0; 394 int rc = 0;
375 int bytes_returned; 395 int bytes_returned;
396 int i;
376 struct TCP_Server_Info * server; 397 struct TCP_Server_Info * server;
377 u16 count; 398 u16 count;
399 unsigned int secFlags;
378 400
379 if(ses->server) 401 if(ses->server)
380 server = ses->server; 402 server = ses->server;
@@ -386,101 +408,200 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
386 (void **) &pSMB, (void **) &pSMBr); 408 (void **) &pSMB, (void **) &pSMBr);
387 if (rc) 409 if (rc)
388 return rc; 410 return rc;
411
412 /* if any of auth flags (ie not sign or seal) are overriden use them */
413 if(ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL)))
414 secFlags = ses->overrideSecFlg;
415 else /* if override flags set only sign/seal OR them with global auth */
416 secFlags = extended_security | ses->overrideSecFlg;
417
418 cFYI(1,("secFlags 0x%x",secFlags));
419
389 pSMB->hdr.Mid = GetNextMid(server); 420 pSMB->hdr.Mid = GetNextMid(server);
390 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; 421 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
391 if (extended_security) 422 if((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
392 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; 423 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
393 424
394 count = strlen(protocols[0].name) + 1; 425 count = 0;
395 strncpy(pSMB->DialectsArray, protocols[0].name, 30); 426 for(i=0;i<CIFS_NUM_PROT;i++) {
396 /* null guaranteed to be at end of source and target buffers anyway */ 427 strncpy(pSMB->DialectsArray+count, protocols[i].name, 16);
397 428 count += strlen(protocols[i].name) + 1;
429 /* null at end of source and target buffers anyway */
430 }
398 pSMB->hdr.smb_buf_length += count; 431 pSMB->hdr.smb_buf_length += count;
399 pSMB->ByteCount = cpu_to_le16(count); 432 pSMB->ByteCount = cpu_to_le16(count);
400 433
401 rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, 434 rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB,
402 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 435 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
403 if (rc == 0) { 436 if (rc != 0)
404 server->secMode = pSMBr->SecurityMode; 437 goto neg_err_exit;
405 if((server->secMode & SECMODE_USER) == 0) 438
406 cFYI(1,("share mode security")); 439 cFYI(1,("Dialect: %d", pSMBr->DialectIndex));
407 server->secType = NTLM; /* BB override default for 440 /* Check wct = 1 error case */
408 NTLMv2 or kerberos v5 */ 441 if((pSMBr->hdr.WordCount < 13) || (pSMBr->DialectIndex == BAD_PROT)) {
409 /* one byte - no need to convert this or EncryptionKeyLen 442 /* core returns wct = 1, but we do not ask for core - otherwise
410 from little endian */ 443 small wct just comes when dialect index is -1 indicating we
411 server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount); 444 could not negotiate a common dialect */
412 /* probably no need to store and check maxvcs */ 445 rc = -EOPNOTSUPP;
413 server->maxBuf = 446 goto neg_err_exit;
414 min(le32_to_cpu(pSMBr->MaxBufferSize), 447#ifdef CONFIG_CIFS_WEAK_PW_HASH
448 } else if((pSMBr->hdr.WordCount == 13)
449 && (pSMBr->DialectIndex == LANMAN_PROT)) {
450 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr;
451
452 if((secFlags & CIFSSEC_MAY_LANMAN) ||
453 (secFlags & CIFSSEC_MAY_PLNTXT))
454 server->secType = LANMAN;
455 else {
456 cERROR(1, ("mount failed weak security disabled"
457 " in /proc/fs/cifs/SecurityFlags"));
458 rc = -EOPNOTSUPP;
459 goto neg_err_exit;
460 }
461 server->secMode = (__u8)le16_to_cpu(rsp->SecurityMode);
462 server->maxReq = le16_to_cpu(rsp->MaxMpxCount);
463 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize),
464 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
465 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey);
466 /* even though we do not use raw we might as well set this
467 accurately, in case we ever find a need for it */
468 if((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {
469 server->maxRw = 0xFF00;
470 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE;
471 } else {
472 server->maxRw = 0;/* we do not need to use raw anyway */
473 server->capabilities = CAP_MPX_MODE;
474 }
475 server->timeZone = le16_to_cpu(rsp->ServerTimeZone);
476
477 /* BB get server time for time conversions and add
478 code to use it and timezone since this is not UTC */
479
480 if (rsp->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) {
481 memcpy(server->cryptKey, rsp->EncryptionKey,
482 CIFS_CRYPTO_KEY_SIZE);
483 } else if (server->secMode & SECMODE_PW_ENCRYPT) {
484 rc = -EIO; /* need cryptkey unless plain text */
485 goto neg_err_exit;
486 }
487
488 cFYI(1,("LANMAN negotiated"));
489 /* we will not end up setting signing flags - as no signing
490 was in LANMAN and server did not return the flags on */
491 goto signing_check;
492#else /* weak security disabled */
493 } else if(pSMBr->hdr.WordCount == 13) {
494 cERROR(1,("mount failed, cifs module not built "
495 "with CIFS_WEAK_PW_HASH support"));
496 rc = -EOPNOTSUPP;
497#endif /* WEAK_PW_HASH */
498 goto neg_err_exit;
499 } else if(pSMBr->hdr.WordCount != 17) {
500 /* unknown wct */
501 rc = -EOPNOTSUPP;
502 goto neg_err_exit;
503 }
504 /* else wct == 17 NTLM */
505 server->secMode = pSMBr->SecurityMode;
506 if((server->secMode & SECMODE_USER) == 0)
507 cFYI(1,("share mode security"));
508
509 if((server->secMode & SECMODE_PW_ENCRYPT) == 0)
510#ifdef CONFIG_CIFS_WEAK_PW_HASH
511 if ((secFlags & CIFSSEC_MAY_PLNTXT) == 0)
512#endif /* CIFS_WEAK_PW_HASH */
513 cERROR(1,("Server requests plain text password"
514 " but client support disabled"));
515
516 if((secFlags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2)
517 server->secType = NTLMv2;
518 else if(secFlags & CIFSSEC_MAY_NTLM)
519 server->secType = NTLM;
520 else if(secFlags & CIFSSEC_MAY_NTLMV2)
521 server->secType = NTLMv2;
522 /* else krb5 ... any others ... */
523
524 /* one byte, so no need to convert this or EncryptionKeyLen from
525 little endian */
526 server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount);
527 /* probably no need to store and check maxvcs */
528 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize),
415 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 529 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
416 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize); 530 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
417 cFYI(0, ("Max buf = %d", ses->server->maxBuf)); 531 cFYI(0, ("Max buf = %d", ses->server->maxBuf));
418 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); 532 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
419 server->capabilities = le32_to_cpu(pSMBr->Capabilities); 533 server->capabilities = le32_to_cpu(pSMBr->Capabilities);
420 server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone); 534 server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone);
421 /* BB with UTC do we ever need to be using srvr timezone? */ 535 if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) {
422 if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) { 536 memcpy(server->cryptKey, pSMBr->u.EncryptionKey,
423 memcpy(server->cryptKey, pSMBr->u.EncryptionKey, 537 CIFS_CRYPTO_KEY_SIZE);
424 CIFS_CRYPTO_KEY_SIZE); 538 } else if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC)
425 } else if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) 539 && (pSMBr->EncryptionKeyLength == 0)) {
426 && (pSMBr->EncryptionKeyLength == 0)) { 540 /* decode security blob */
427 /* decode security blob */ 541 } else if (server->secMode & SECMODE_PW_ENCRYPT) {
428 } else 542 rc = -EIO; /* no crypt key only if plain text pwd */
429 rc = -EIO; 543 goto neg_err_exit;
544 }
430 545
431 /* BB might be helpful to save off the domain of server here */ 546 /* BB might be helpful to save off the domain of server here */
432 547
433 if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) && 548 if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) &&
434 (server->capabilities & CAP_EXTENDED_SECURITY)) { 549 (server->capabilities & CAP_EXTENDED_SECURITY)) {
435 count = pSMBr->ByteCount; 550 count = pSMBr->ByteCount;
436 if (count < 16) 551 if (count < 16)
437 rc = -EIO; 552 rc = -EIO;
438 else if (count == 16) { 553 else if (count == 16) {
439 server->secType = RawNTLMSSP; 554 server->secType = RawNTLMSSP;
440 if (server->socketUseCount.counter > 1) { 555 if (server->socketUseCount.counter > 1) {
441 if (memcmp 556 if (memcmp(server->server_GUID,
442 (server->server_GUID, 557 pSMBr->u.extended_response.
443 pSMBr->u.extended_response. 558 GUID, 16) != 0) {
444 GUID, 16) != 0) { 559 cFYI(1, ("server UID changed"));
445 cFYI(1, ("server UID changed"));
446 memcpy(server->
447 server_GUID,
448 pSMBr->u.
449 extended_response.
450 GUID, 16);
451 }
452 } else
453 memcpy(server->server_GUID, 560 memcpy(server->server_GUID,
454 pSMBr->u.extended_response. 561 pSMBr->u.extended_response.GUID,
455 GUID, 16); 562 16);
456 } else {
457 rc = decode_negTokenInit(pSMBr->u.
458 extended_response.
459 SecurityBlob,
460 count - 16,
461 &server->secType);
462 if(rc == 1) {
463 /* BB Need to fill struct for sessetup here */
464 rc = -EOPNOTSUPP;
465 } else {
466 rc = -EINVAL;
467 } 563 }
564 } else
565 memcpy(server->server_GUID,
566 pSMBr->u.extended_response.GUID, 16);
567 } else {
568 rc = decode_negTokenInit(pSMBr->u.extended_response.
569 SecurityBlob,
570 count - 16,
571 &server->secType);
572 if(rc == 1) {
573 /* BB Need to fill struct for sessetup here */
574 rc = -EOPNOTSUPP;
575 } else {
576 rc = -EINVAL;
468 } 577 }
469 } else
470 server->capabilities &= ~CAP_EXTENDED_SECURITY;
471 if(sign_CIFS_PDUs == FALSE) {
472 if(server->secMode & SECMODE_SIGN_REQUIRED)
473 cERROR(1,
474 ("Server requires /proc/fs/cifs/PacketSigningEnabled"));
475 server->secMode &= ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
476 } else if(sign_CIFS_PDUs == 1) {
477 if((server->secMode & SECMODE_SIGN_REQUIRED) == 0)
478 server->secMode &= ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
479 } 578 }
480 579 } else
580 server->capabilities &= ~CAP_EXTENDED_SECURITY;
581
582#ifdef CONFIG_CIFS_WEAK_PW_HASH
583signing_check:
584#endif
585 if(sign_CIFS_PDUs == FALSE) {
586 if(server->secMode & SECMODE_SIGN_REQUIRED)
587 cERROR(1,("Server requires "
588 "/proc/fs/cifs/PacketSigningEnabled to be on"));
589 server->secMode &=
590 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
591 } else if(sign_CIFS_PDUs == 1) {
592 if((server->secMode & SECMODE_SIGN_REQUIRED) == 0)
593 server->secMode &=
594 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
595 } else if(sign_CIFS_PDUs == 2) {
596 if((server->secMode &
597 (SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED)) == 0) {
598 cERROR(1,("signing required but server lacks support"));
599 }
481 } 600 }
482 601neg_err_exit:
483 cifs_buf_release(pSMB); 602 cifs_buf_release(pSMB);
603
604 cFYI(1,("negprot rc %d",rc));
484 return rc; 605 return rc;
485} 606}
486 607
@@ -2239,7 +2360,7 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
2239 } 2360 }
2240 symlinkinfo[buflen] = 0; /* just in case so the caller 2361 symlinkinfo[buflen] = 0; /* just in case so the caller
2241 does not go off the end of the buffer */ 2362 does not go off the end of the buffer */
2242 cFYI(1,("readlink result - %s ",symlinkinfo)); 2363 cFYI(1,("readlink result - %s",symlinkinfo));
2243 } 2364 }
2244 } 2365 }
2245qreparse_out: 2366qreparse_out:
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index bae1479318d1..876eb9ef85fe 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -49,8 +49,6 @@
49 49
50static DECLARE_COMPLETION(cifsd_complete); 50static DECLARE_COMPLETION(cifsd_complete);
51 51
52extern void SMBencrypt(unsigned char *passwd, unsigned char *c8,
53 unsigned char *p24);
54extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, 52extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
55 unsigned char *p24); 53 unsigned char *p24);
56 54
@@ -70,6 +68,7 @@ struct smb_vol {
70 gid_t linux_gid; 68 gid_t linux_gid;
71 mode_t file_mode; 69 mode_t file_mode;
72 mode_t dir_mode; 70 mode_t dir_mode;
71 unsigned secFlg;
73 unsigned rw:1; 72 unsigned rw:1;
74 unsigned retry:1; 73 unsigned retry:1;
75 unsigned intr:1; 74 unsigned intr:1;
@@ -83,12 +82,7 @@ struct smb_vol {
83 unsigned remap:1; /* set to remap seven reserved chars in filenames */ 82 unsigned remap:1; /* set to remap seven reserved chars in filenames */
84 unsigned posix_paths:1; /* unset to not ask for posix pathnames. */ 83 unsigned posix_paths:1; /* unset to not ask for posix pathnames. */
85 unsigned sfu_emul:1; 84 unsigned sfu_emul:1;
86 unsigned krb5:1;
87 unsigned ntlm:1;
88 unsigned ntlmv2:1;
89 unsigned nullauth:1; /* attempt to authenticate with null user */ 85 unsigned nullauth:1; /* attempt to authenticate with null user */
90 unsigned sign:1;
91 unsigned seal:1; /* encrypt */
92 unsigned nocase; /* request case insensitive filenames */ 86 unsigned nocase; /* request case insensitive filenames */
93 unsigned nobrl; /* disable sending byte range locks to srv */ 87 unsigned nobrl; /* disable sending byte range locks to srv */
94 unsigned int rsize; 88 unsigned int rsize;
@@ -369,21 +363,21 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
369 continue; 363 continue;
370 if (bigbuf == NULL) { 364 if (bigbuf == NULL) {
371 bigbuf = cifs_buf_get(); 365 bigbuf = cifs_buf_get();
372 if(bigbuf == NULL) { 366 if (!bigbuf) {
373 cERROR(1,("No memory for large SMB response")); 367 cERROR(1, ("No memory for large SMB response"));
374 msleep(3000); 368 msleep(3000);
375 /* retry will check if exiting */ 369 /* retry will check if exiting */
376 continue; 370 continue;
377 } 371 }
378 } else if(isLargeBuf) { 372 } else if (isLargeBuf) {
379 /* we are reusing a dirtry large buf, clear its start */ 373 /* we are reusing a dirty large buf, clear its start */
380 memset(bigbuf, 0, sizeof (struct smb_hdr)); 374 memset(bigbuf, 0, sizeof (struct smb_hdr));
381 } 375 }
382 376
383 if (smallbuf == NULL) { 377 if (smallbuf == NULL) {
384 smallbuf = cifs_small_buf_get(); 378 smallbuf = cifs_small_buf_get();
385 if(smallbuf == NULL) { 379 if (!smallbuf) {
386 cERROR(1,("No memory for SMB response")); 380 cERROR(1, ("No memory for SMB response"));
387 msleep(1000); 381 msleep(1000);
388 /* retry will check if exiting */ 382 /* retry will check if exiting */
389 continue; 383 continue;
@@ -403,12 +397,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
403 kernel_recvmsg(csocket, &smb_msg, 397 kernel_recvmsg(csocket, &smb_msg,
404 &iov, 1, 4, 0 /* BB see socket.h flags */); 398 &iov, 1, 4, 0 /* BB see socket.h flags */);
405 399
406 if(server->tcpStatus == CifsExiting) { 400 if (server->tcpStatus == CifsExiting) {
407 break; 401 break;
408 } else if (server->tcpStatus == CifsNeedReconnect) { 402 } else if (server->tcpStatus == CifsNeedReconnect) {
409 cFYI(1,("Reconnect after server stopped responding")); 403 cFYI(1, ("Reconnect after server stopped responding"));
410 cifs_reconnect(server); 404 cifs_reconnect(server);
411 cFYI(1,("call to reconnect done")); 405 cFYI(1, ("call to reconnect done"));
412 csocket = server->ssocket; 406 csocket = server->ssocket;
413 continue; 407 continue;
414 } else if ((length == -ERESTARTSYS) || (length == -EAGAIN)) { 408 } else if ((length == -ERESTARTSYS) || (length == -EAGAIN)) {
@@ -417,15 +411,15 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
417 tcpStatus CifsNeedReconnect if server hung */ 411 tcpStatus CifsNeedReconnect if server hung */
418 continue; 412 continue;
419 } else if (length <= 0) { 413 } else if (length <= 0) {
420 if(server->tcpStatus == CifsNew) { 414 if (server->tcpStatus == CifsNew) {
421 cFYI(1,("tcp session abend after SMBnegprot")); 415 cFYI(1, ("tcp session abend after SMBnegprot"));
422 /* some servers kill the TCP session rather than 416 /* some servers kill the TCP session rather than
423 returning an SMB negprot error, in which 417 returning an SMB negprot error, in which
424 case reconnecting here is not going to help, 418 case reconnecting here is not going to help,
425 and so simply return error to mount */ 419 and so simply return error to mount */
426 break; 420 break;
427 } 421 }
428 if(length == -EINTR) { 422 if (!try_to_freeze() && (length == -EINTR)) {
429 cFYI(1,("cifsd thread killed")); 423 cFYI(1,("cifsd thread killed"));
430 break; 424 break;
431 } 425 }
@@ -585,9 +579,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
585 /* merge response - fix up 1st*/ 579 /* merge response - fix up 1st*/
586 if(coalesce_t2(smb_buffer, 580 if(coalesce_t2(smb_buffer,
587 mid_entry->resp_buf)) { 581 mid_entry->resp_buf)) {
582 mid_entry->multiRsp = 1;
588 break; 583 break;
589 } else { 584 } else {
590 /* all parts received */ 585 /* all parts received */
586 mid_entry->multiEnd = 1;
591 goto multi_t2_fnd; 587 goto multi_t2_fnd;
592 } 588 }
593 } else { 589 } else {
@@ -632,9 +628,14 @@ multi_t2_fnd:
632 wake_up_process(task_to_wake); 628 wake_up_process(task_to_wake);
633 } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) 629 } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE)
634 && (isMultiRsp == FALSE)) { 630 && (isMultiRsp == FALSE)) {
635 cERROR(1, ("No task to wake, unknown frame rcvd!")); 631 cERROR(1, ("No task to wake, unknown frame rcvd! NumMids %d", midCount.counter));
636 cifs_dump_mem("Received Data is: ",(char *)smb_buffer, 632 cifs_dump_mem("Received Data is: ",(char *)smb_buffer,
637 sizeof(struct smb_hdr)); 633 sizeof(struct smb_hdr));
634#ifdef CONFIG_CIFS_DEBUG2
635 cifs_dump_detail(smb_buffer);
636 cifs_dump_mids(server);
637#endif /* CIFS_DEBUG2 */
638
638 } 639 }
639 } /* end while !EXITING */ 640 } /* end while !EXITING */
640 641
@@ -784,7 +785,6 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
784 785
785 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ 786 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
786 vol->rw = TRUE; 787 vol->rw = TRUE;
787 vol->ntlm = TRUE;
788 /* default is always to request posix paths. */ 788 /* default is always to request posix paths. */
789 vol->posix_paths = 1; 789 vol->posix_paths = 1;
790 790
@@ -915,30 +915,35 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
915 cERROR(1,("no security value specified")); 915 cERROR(1,("no security value specified"));
916 continue; 916 continue;
917 } else if (strnicmp(value, "krb5i", 5) == 0) { 917 } else if (strnicmp(value, "krb5i", 5) == 0) {
918 vol->sign = 1; 918 vol->secFlg |= CIFSSEC_MAY_KRB5 |
919 vol->krb5 = 1; 919 CIFSSEC_MUST_SIGN;
920 } else if (strnicmp(value, "krb5p", 5) == 0) { 920 } else if (strnicmp(value, "krb5p", 5) == 0) {
921 /* vol->seal = 1; 921 /* vol->secFlg |= CIFSSEC_MUST_SEAL |
922 vol->krb5 = 1; */ 922 CIFSSEC_MAY_KRB5; */
923 cERROR(1,("Krb5 cifs privacy not supported")); 923 cERROR(1,("Krb5 cifs privacy not supported"));
924 return 1; 924 return 1;
925 } else if (strnicmp(value, "krb5", 4) == 0) { 925 } else if (strnicmp(value, "krb5", 4) == 0) {
926 vol->krb5 = 1; 926 vol->secFlg |= CIFSSEC_MAY_KRB5;
927 } else if (strnicmp(value, "ntlmv2i", 7) == 0) { 927 } else if (strnicmp(value, "ntlmv2i", 7) == 0) {
928 vol->ntlmv2 = 1; 928 vol->secFlg |= CIFSSEC_MAY_NTLMV2 |
929 vol->sign = 1; 929 CIFSSEC_MUST_SIGN;
930 } else if (strnicmp(value, "ntlmv2", 6) == 0) { 930 } else if (strnicmp(value, "ntlmv2", 6) == 0) {
931 vol->ntlmv2 = 1; 931 vol->secFlg |= CIFSSEC_MAY_NTLMV2;
932 } else if (strnicmp(value, "ntlmi", 5) == 0) { 932 } else if (strnicmp(value, "ntlmi", 5) == 0) {
933 vol->ntlm = 1; 933 vol->secFlg |= CIFSSEC_MAY_NTLM |
934 vol->sign = 1; 934 CIFSSEC_MUST_SIGN;
935 } else if (strnicmp(value, "ntlm", 4) == 0) { 935 } else if (strnicmp(value, "ntlm", 4) == 0) {
936 /* ntlm is default so can be turned off too */ 936 /* ntlm is default so can be turned off too */
937 vol->ntlm = 1; 937 vol->secFlg |= CIFSSEC_MAY_NTLM;
938 } else if (strnicmp(value, "nontlm", 6) == 0) { 938 } else if (strnicmp(value, "nontlm", 6) == 0) {
939 vol->ntlm = 0; 939 /* BB is there a better way to do this? */
940 vol->secFlg |= CIFSSEC_MAY_NTLMV2;
941#ifdef CONFIG_CIFS_WEAK_PW_HASH
942 } else if (strnicmp(value, "lanman", 6) == 0) {
943 vol->secFlg |= CIFSSEC_MAY_LANMAN;
944#endif
940 } else if (strnicmp(value, "none", 4) == 0) { 945 } else if (strnicmp(value, "none", 4) == 0) {
941 vol->nullauth = 1; 946 vol->nullauth = 1;
942 } else { 947 } else {
943 cERROR(1,("bad security option: %s", value)); 948 cERROR(1,("bad security option: %s", value));
944 return 1; 949 return 1;
@@ -976,7 +981,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
976 } 981 }
977 /* BB are there cases in which a comma can be valid in 982 /* BB are there cases in which a comma can be valid in
978 a domain name and need special handling? */ 983 a domain name and need special handling? */
979 if (strnlen(value, 65) < 65) { 984 if (strnlen(value, 256) < 256) {
980 vol->domainname = value; 985 vol->domainname = value;
981 cFYI(1, ("Domain name set")); 986 cFYI(1, ("Domain name set"));
982 } else { 987 } else {
@@ -1168,6 +1173,10 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
1168 vol->no_psx_acl = 0; 1173 vol->no_psx_acl = 0;
1169 } else if (strnicmp(data, "noacl",5) == 0) { 1174 } else if (strnicmp(data, "noacl",5) == 0) {
1170 vol->no_psx_acl = 1; 1175 vol->no_psx_acl = 1;
1176 } else if (strnicmp(data, "sign",4) == 0) {
1177 vol->secFlg |= CIFSSEC_MUST_SIGN;
1178/* } else if (strnicmp(data, "seal",4) == 0) {
1179 vol->secFlg |= CIFSSEC_MUST_SEAL; */
1171 } else if (strnicmp(data, "direct",6) == 0) { 1180 } else if (strnicmp(data, "direct",6) == 0) {
1172 vol->direct_io = 1; 1181 vol->direct_io = 1;
1173 } else if (strnicmp(data, "forcedirectio",13) == 0) { 1182 } else if (strnicmp(data, "forcedirectio",13) == 0) {
@@ -1762,11 +1771,18 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1762 if (volume_info.username) 1771 if (volume_info.username)
1763 strncpy(pSesInfo->userName, 1772 strncpy(pSesInfo->userName,
1764 volume_info.username,MAX_USERNAME_SIZE); 1773 volume_info.username,MAX_USERNAME_SIZE);
1765 if (volume_info.domainname) 1774 if (volume_info.domainname) {
1766 strncpy(pSesInfo->domainName, 1775 int len = strlen(volume_info.domainname);
1767 volume_info.domainname,MAX_USERNAME_SIZE); 1776 pSesInfo->domainName =
1777 kmalloc(len + 1, GFP_KERNEL);
1778 if(pSesInfo->domainName)
1779 strcpy(pSesInfo->domainName,
1780 volume_info.domainname);
1781 }
1768 pSesInfo->linux_uid = volume_info.linux_uid; 1782 pSesInfo->linux_uid = volume_info.linux_uid;
1783 pSesInfo->overrideSecFlg = volume_info.secFlg;
1769 down(&pSesInfo->sesSem); 1784 down(&pSesInfo->sesSem);
1785 /* BB FIXME need to pass vol->secFlgs BB */
1770 rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); 1786 rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls);
1771 up(&pSesInfo->sesSem); 1787 up(&pSesInfo->sesSem);
1772 if(!rc) 1788 if(!rc)
@@ -1980,7 +1996,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1980 1996
1981static int 1997static int
1982CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, 1998CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1983 char session_key[CIFS_SESSION_KEY_SIZE], 1999 char session_key[CIFS_SESS_KEY_SIZE],
1984 const struct nls_table *nls_codepage) 2000 const struct nls_table *nls_codepage)
1985{ 2001{
1986 struct smb_hdr *smb_buffer; 2002 struct smb_hdr *smb_buffer;
@@ -2038,15 +2054,15 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2038 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); 2054 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
2039 2055
2040 pSMB->req_no_secext.CaseInsensitivePasswordLength = 2056 pSMB->req_no_secext.CaseInsensitivePasswordLength =
2041 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 2057 cpu_to_le16(CIFS_SESS_KEY_SIZE);
2042 2058
2043 pSMB->req_no_secext.CaseSensitivePasswordLength = 2059 pSMB->req_no_secext.CaseSensitivePasswordLength =
2044 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 2060 cpu_to_le16(CIFS_SESS_KEY_SIZE);
2045 bcc_ptr = pByteArea(smb_buffer); 2061 bcc_ptr = pByteArea(smb_buffer);
2046 memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE); 2062 memcpy(bcc_ptr, (char *) session_key, CIFS_SESS_KEY_SIZE);
2047 bcc_ptr += CIFS_SESSION_KEY_SIZE; 2063 bcc_ptr += CIFS_SESS_KEY_SIZE;
2048 memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE); 2064 memcpy(bcc_ptr, (char *) session_key, CIFS_SESS_KEY_SIZE);
2049 bcc_ptr += CIFS_SESSION_KEY_SIZE; 2065 bcc_ptr += CIFS_SESS_KEY_SIZE;
2050 2066
2051 if (ses->capabilities & CAP_UNICODE) { 2067 if (ses->capabilities & CAP_UNICODE) {
2052 if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode */ 2068 if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode */
@@ -2054,7 +2070,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2054 bcc_ptr++; 2070 bcc_ptr++;
2055 } 2071 }
2056 if(user == NULL) 2072 if(user == NULL)
2057 bytes_returned = 0; /* skill null user */ 2073 bytes_returned = 0; /* skip null user */
2058 else 2074 else
2059 bytes_returned = 2075 bytes_returned =
2060 cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, 2076 cifs_strtoUCS((__le16 *) bcc_ptr, user, 100,
@@ -2162,8 +2178,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2162 if (remaining_words > 0) { 2178 if (remaining_words > 0) {
2163 len = UniStrnlen((wchar_t *)bcc_ptr, 2179 len = UniStrnlen((wchar_t *)bcc_ptr,
2164 remaining_words-1); 2180 remaining_words-1);
2165 if(ses->serverNOS) 2181 kfree(ses->serverNOS);
2166 kfree(ses->serverNOS);
2167 ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); 2182 ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL);
2168 if(ses->serverNOS == NULL) 2183 if(ses->serverNOS == NULL)
2169 goto sesssetup_nomem; 2184 goto sesssetup_nomem;
@@ -2203,12 +2218,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2203 /* if these kcallocs fail not much we 2218 /* if these kcallocs fail not much we
2204 can do, but better to not fail the 2219 can do, but better to not fail the
2205 sesssetup itself */ 2220 sesssetup itself */
2206 if(ses->serverDomain) 2221 kfree(ses->serverDomain);
2207 kfree(ses->serverDomain);
2208 ses->serverDomain = 2222 ses->serverDomain =
2209 kzalloc(2, GFP_KERNEL); 2223 kzalloc(2, GFP_KERNEL);
2210 if(ses->serverNOS) 2224 kfree(ses->serverNOS);
2211 kfree(ses->serverNOS);
2212 ses->serverNOS = 2225 ses->serverNOS =
2213 kzalloc(2, GFP_KERNEL); 2226 kzalloc(2, GFP_KERNEL);
2214 } 2227 }
@@ -2217,8 +2230,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2217 if (((long) bcc_ptr + len) - (long) 2230 if (((long) bcc_ptr + len) - (long)
2218 pByteArea(smb_buffer_response) 2231 pByteArea(smb_buffer_response)
2219 <= BCC(smb_buffer_response)) { 2232 <= BCC(smb_buffer_response)) {
2220 if(ses->serverOS) 2233 kfree(ses->serverOS);
2221 kfree(ses->serverOS);
2222 ses->serverOS = kzalloc(len + 1,GFP_KERNEL); 2234 ses->serverOS = kzalloc(len + 1,GFP_KERNEL);
2223 if(ses->serverOS == NULL) 2235 if(ses->serverOS == NULL)
2224 goto sesssetup_nomem; 2236 goto sesssetup_nomem;
@@ -2229,8 +2241,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2229 bcc_ptr++; 2241 bcc_ptr++;
2230 2242
2231 len = strnlen(bcc_ptr, 1024); 2243 len = strnlen(bcc_ptr, 1024);
2232 if(ses->serverNOS) 2244 kfree(ses->serverNOS);
2233 kfree(ses->serverNOS);
2234 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); 2245 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL);
2235 if(ses->serverNOS == NULL) 2246 if(ses->serverNOS == NULL)
2236 goto sesssetup_nomem; 2247 goto sesssetup_nomem;
@@ -2274,292 +2285,6 @@ sesssetup_nomem: /* do not return an error on nomem for the info strings,
2274} 2285}
2275 2286
2276static int 2287static int
2277CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2278 char *SecurityBlob,int SecurityBlobLength,
2279 const struct nls_table *nls_codepage)
2280{
2281 struct smb_hdr *smb_buffer;
2282 struct smb_hdr *smb_buffer_response;
2283 SESSION_SETUP_ANDX *pSMB;
2284 SESSION_SETUP_ANDX *pSMBr;
2285 char *bcc_ptr;
2286 char *user;
2287 char *domain;
2288 int rc = 0;
2289 int remaining_words = 0;
2290 int bytes_returned = 0;
2291 int len;
2292 __u32 capabilities;
2293 __u16 count;
2294
2295 cFYI(1, ("In spnego sesssetup "));
2296 if(ses == NULL)
2297 return -EINVAL;
2298 user = ses->userName;
2299 domain = ses->domainName;
2300
2301 smb_buffer = cifs_buf_get();
2302 if (smb_buffer == NULL) {
2303 return -ENOMEM;
2304 }
2305 smb_buffer_response = smb_buffer;
2306 pSMBr = pSMB = (SESSION_SETUP_ANDX *) smb_buffer;
2307
2308 /* send SMBsessionSetup here */
2309 header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
2310 NULL /* no tCon exists yet */ , 12 /* wct */ );
2311
2312 smb_buffer->Mid = GetNextMid(ses->server);
2313 pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
2314 pSMB->req.AndXCommand = 0xFF;
2315 if(ses->server->maxBuf > 64*1024)
2316 ses->server->maxBuf = (64*1023);
2317 pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
2318 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
2319
2320 if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
2321 smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
2322
2323 capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
2324 CAP_EXTENDED_SECURITY;
2325 if (ses->capabilities & CAP_UNICODE) {
2326 smb_buffer->Flags2 |= SMBFLG2_UNICODE;
2327 capabilities |= CAP_UNICODE;
2328 }
2329 if (ses->capabilities & CAP_STATUS32) {
2330 smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
2331 capabilities |= CAP_STATUS32;
2332 }
2333 if (ses->capabilities & CAP_DFS) {
2334 smb_buffer->Flags2 |= SMBFLG2_DFS;
2335 capabilities |= CAP_DFS;
2336 }
2337 pSMB->req.Capabilities = cpu_to_le32(capabilities);
2338
2339 pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength);
2340 bcc_ptr = pByteArea(smb_buffer);
2341 memcpy(bcc_ptr, SecurityBlob, SecurityBlobLength);
2342 bcc_ptr += SecurityBlobLength;
2343
2344 if (ses->capabilities & CAP_UNICODE) {
2345 if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode strings */
2346 *bcc_ptr = 0;
2347 bcc_ptr++;
2348 }
2349 bytes_returned =
2350 cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, nls_codepage);
2351 bcc_ptr += 2 * bytes_returned; /* convert num of 16 bit words to bytes */
2352 bcc_ptr += 2; /* trailing null */
2353 if (domain == NULL)
2354 bytes_returned =
2355 cifs_strtoUCS((__le16 *) bcc_ptr,
2356 "CIFS_LINUX_DOM", 32, nls_codepage);
2357 else
2358 bytes_returned =
2359 cifs_strtoUCS((__le16 *) bcc_ptr, domain, 64,
2360 nls_codepage);
2361 bcc_ptr += 2 * bytes_returned;
2362 bcc_ptr += 2;
2363 bytes_returned =
2364 cifs_strtoUCS((__le16 *) bcc_ptr, "Linux version ",
2365 32, nls_codepage);
2366 bcc_ptr += 2 * bytes_returned;
2367 bytes_returned =
2368 cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release, 32,
2369 nls_codepage);
2370 bcc_ptr += 2 * bytes_returned;
2371 bcc_ptr += 2;
2372 bytes_returned =
2373 cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
2374 64, nls_codepage);
2375 bcc_ptr += 2 * bytes_returned;
2376 bcc_ptr += 2;
2377 } else {
2378 strncpy(bcc_ptr, user, 200);
2379 bcc_ptr += strnlen(user, 200);
2380 *bcc_ptr = 0;
2381 bcc_ptr++;
2382 if (domain == NULL) {
2383 strcpy(bcc_ptr, "CIFS_LINUX_DOM");
2384 bcc_ptr += strlen("CIFS_LINUX_DOM") + 1;
2385 } else {
2386 strncpy(bcc_ptr, domain, 64);
2387 bcc_ptr += strnlen(domain, 64);
2388 *bcc_ptr = 0;
2389 bcc_ptr++;
2390 }
2391 strcpy(bcc_ptr, "Linux version ");
2392 bcc_ptr += strlen("Linux version ");
2393 strcpy(bcc_ptr, system_utsname.release);
2394 bcc_ptr += strlen(system_utsname.release) + 1;
2395 strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
2396 bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
2397 }
2398 count = (long) bcc_ptr - (long) pByteArea(smb_buffer);
2399 smb_buffer->smb_buf_length += count;
2400 pSMB->req.ByteCount = cpu_to_le16(count);
2401
2402 rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response,
2403 &bytes_returned, 1);
2404 if (rc) {
2405/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */
2406 } else if ((smb_buffer_response->WordCount == 3)
2407 || (smb_buffer_response->WordCount == 4)) {
2408 __u16 action = le16_to_cpu(pSMBr->resp.Action);
2409 __u16 blob_len =
2410 le16_to_cpu(pSMBr->resp.SecurityBlobLength);
2411 if (action & GUEST_LOGIN)
2412 cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */
2413 if (ses) {
2414 ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */
2415 cFYI(1, ("UID = %d ", ses->Suid));
2416 bcc_ptr = pByteArea(smb_buffer_response); /* response can have either 3 or 4 word count - Samba sends 3 */
2417
2418 /* BB Fix below to make endian neutral !! */
2419
2420 if ((pSMBr->resp.hdr.WordCount == 3)
2421 || ((pSMBr->resp.hdr.WordCount == 4)
2422 && (blob_len <
2423 pSMBr->resp.ByteCount))) {
2424 if (pSMBr->resp.hdr.WordCount == 4) {
2425 bcc_ptr +=
2426 blob_len;
2427 cFYI(1,
2428 ("Security Blob Length %d ",
2429 blob_len));
2430 }
2431
2432 if (smb_buffer->Flags2 & SMBFLG2_UNICODE) {
2433 if ((long) (bcc_ptr) % 2) {
2434 remaining_words =
2435 (BCC(smb_buffer_response)
2436 - 1) / 2;
2437 bcc_ptr++; /* Unicode strings must be word aligned */
2438 } else {
2439 remaining_words =
2440 BCC
2441 (smb_buffer_response) / 2;
2442 }
2443 len =
2444 UniStrnlen((wchar_t *) bcc_ptr,
2445 remaining_words - 1);
2446/* We look for obvious messed up bcc or strings in response so we do not go off
2447 the end since (at least) WIN2K and Windows XP have a major bug in not null
2448 terminating last Unicode string in response */
2449 if(ses->serverOS)
2450 kfree(ses->serverOS);
2451 ses->serverOS =
2452 kzalloc(2 * (len + 1), GFP_KERNEL);
2453 cifs_strfromUCS_le(ses->serverOS,
2454 (__le16 *)
2455 bcc_ptr, len,
2456 nls_codepage);
2457 bcc_ptr += 2 * (len + 1);
2458 remaining_words -= len + 1;
2459 ses->serverOS[2 * len] = 0;
2460 ses->serverOS[1 + (2 * len)] = 0;
2461 if (remaining_words > 0) {
2462 len = UniStrnlen((wchar_t *)bcc_ptr,
2463 remaining_words
2464 - 1);
2465 if(ses->serverNOS)
2466 kfree(ses->serverNOS);
2467 ses->serverNOS =
2468 kzalloc(2 * (len + 1),
2469 GFP_KERNEL);
2470 cifs_strfromUCS_le(ses->serverNOS,
2471 (__le16 *)bcc_ptr,
2472 len,
2473 nls_codepage);
2474 bcc_ptr += 2 * (len + 1);
2475 ses->serverNOS[2 * len] = 0;
2476 ses->serverNOS[1 + (2 * len)] = 0;
2477 remaining_words -= len + 1;
2478 if (remaining_words > 0) {
2479 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2480 /* last string not null terminated (e.g.Windows XP/2000) */
2481 if(ses->serverDomain)
2482 kfree(ses->serverDomain);
2483 ses->serverDomain = kzalloc(2*(len+1),GFP_KERNEL);
2484 cifs_strfromUCS_le(ses->serverDomain,
2485 (__le16 *)bcc_ptr,
2486 len, nls_codepage);
2487 bcc_ptr += 2*(len+1);
2488 ses->serverDomain[2*len] = 0;
2489 ses->serverDomain[1+(2*len)] = 0;
2490 } /* else no more room so create dummy domain string */
2491 else {
2492 if(ses->serverDomain)
2493 kfree(ses->serverDomain);
2494 ses->serverDomain =
2495 kzalloc(2,GFP_KERNEL);
2496 }
2497 } else {/* no room use dummy domain&NOS */
2498 if(ses->serverDomain)
2499 kfree(ses->serverDomain);
2500 ses->serverDomain = kzalloc(2, GFP_KERNEL);
2501 if(ses->serverNOS)
2502 kfree(ses->serverNOS);
2503 ses->serverNOS = kzalloc(2, GFP_KERNEL);
2504 }
2505 } else { /* ASCII */
2506
2507 len = strnlen(bcc_ptr, 1024);
2508 if (((long) bcc_ptr + len) - (long)
2509 pByteArea(smb_buffer_response)
2510 <= BCC(smb_buffer_response)) {
2511 if(ses->serverOS)
2512 kfree(ses->serverOS);
2513 ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
2514 strncpy(ses->serverOS, bcc_ptr, len);
2515
2516 bcc_ptr += len;
2517 bcc_ptr[0] = 0; /* null terminate the string */
2518 bcc_ptr++;
2519
2520 len = strnlen(bcc_ptr, 1024);
2521 if(ses->serverNOS)
2522 kfree(ses->serverNOS);
2523 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL);
2524 strncpy(ses->serverNOS, bcc_ptr, len);
2525 bcc_ptr += len;
2526 bcc_ptr[0] = 0;
2527 bcc_ptr++;
2528
2529 len = strnlen(bcc_ptr, 1024);
2530 if(ses->serverDomain)
2531 kfree(ses->serverDomain);
2532 ses->serverDomain = kzalloc(len + 1, GFP_KERNEL);
2533 strncpy(ses->serverDomain, bcc_ptr, len);
2534 bcc_ptr += len;
2535 bcc_ptr[0] = 0;
2536 bcc_ptr++;
2537 } else
2538 cFYI(1,
2539 ("Variable field of length %d extends beyond end of smb ",
2540 len));
2541 }
2542 } else {
2543 cERROR(1,
2544 (" Security Blob Length extends beyond end of SMB"));
2545 }
2546 } else {
2547 cERROR(1, ("No session structure passed in."));
2548 }
2549 } else {
2550 cERROR(1,
2551 (" Invalid Word count %d: ",
2552 smb_buffer_response->WordCount));
2553 rc = -EIO;
2554 }
2555
2556 if (smb_buffer)
2557 cifs_buf_release(smb_buffer);
2558
2559 return rc;
2560}
2561
2562static int
2563CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, 2288CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2564 struct cifsSesInfo *ses, int * pNTLMv2_flag, 2289 struct cifsSesInfo *ses, int * pNTLMv2_flag,
2565 const struct nls_table *nls_codepage) 2290 const struct nls_table *nls_codepage)
@@ -2635,8 +2360,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2635 /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; 2360 /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128;
2636 if(sign_CIFS_PDUs) 2361 if(sign_CIFS_PDUs)
2637 negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; 2362 negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN;
2638 if(ntlmv2_support) 2363/* if(ntlmv2_support)
2639 negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; 2364 negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/
2640 /* setup pointers to domain name and workstation name */ 2365 /* setup pointers to domain name and workstation name */
2641 bcc_ptr += SecurityBlobLength; 2366 bcc_ptr += SecurityBlobLength;
2642 2367
@@ -2783,8 +2508,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2783 bcc_ptr, 2508 bcc_ptr,
2784 remaining_words 2509 remaining_words
2785 - 1); 2510 - 1);
2786 if(ses->serverNOS) 2511 kfree(ses->serverNOS);
2787 kfree(ses->serverNOS);
2788 ses->serverNOS = 2512 ses->serverNOS =
2789 kzalloc(2 * (len + 1), 2513 kzalloc(2 * (len + 1),
2790 GFP_KERNEL); 2514 GFP_KERNEL);
@@ -2802,8 +2526,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2802 if (remaining_words > 0) { 2526 if (remaining_words > 0) {
2803 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2527 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2804 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2528 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
2805 if(ses->serverDomain) 2529 kfree(ses->serverDomain);
2806 kfree(ses->serverDomain);
2807 ses->serverDomain = 2530 ses->serverDomain =
2808 kzalloc(2 * 2531 kzalloc(2 *
2809 (len + 2532 (len +
@@ -2822,19 +2545,16 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2822 = 0; 2545 = 0;
2823 } /* else no more room so create dummy domain string */ 2546 } /* else no more room so create dummy domain string */
2824 else { 2547 else {
2825 if(ses->serverDomain) 2548 kfree(ses->serverDomain);
2826 kfree(ses->serverDomain);
2827 ses->serverDomain = 2549 ses->serverDomain =
2828 kzalloc(2, 2550 kzalloc(2,
2829 GFP_KERNEL); 2551 GFP_KERNEL);
2830 } 2552 }
2831 } else { /* no room so create dummy domain and NOS string */ 2553 } else { /* no room so create dummy domain and NOS string */
2832 if(ses->serverDomain); 2554 kfree(ses->serverDomain);
2833 kfree(ses->serverDomain);
2834 ses->serverDomain = 2555 ses->serverDomain =
2835 kzalloc(2, GFP_KERNEL); 2556 kzalloc(2, GFP_KERNEL);
2836 if(ses->serverNOS) 2557 kfree(ses->serverNOS);
2837 kfree(ses->serverNOS);
2838 ses->serverNOS = 2558 ses->serverNOS =
2839 kzalloc(2, GFP_KERNEL); 2559 kzalloc(2, GFP_KERNEL);
2840 } 2560 }
@@ -2856,8 +2576,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2856 bcc_ptr++; 2576 bcc_ptr++;
2857 2577
2858 len = strnlen(bcc_ptr, 1024); 2578 len = strnlen(bcc_ptr, 1024);
2859 if(ses->serverNOS) 2579 kfree(ses->serverNOS);
2860 kfree(ses->serverNOS);
2861 ses->serverNOS = 2580 ses->serverNOS =
2862 kzalloc(len + 1, 2581 kzalloc(len + 1,
2863 GFP_KERNEL); 2582 GFP_KERNEL);
@@ -2867,8 +2586,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2867 bcc_ptr++; 2586 bcc_ptr++;
2868 2587
2869 len = strnlen(bcc_ptr, 1024); 2588 len = strnlen(bcc_ptr, 1024);
2870 if(ses->serverDomain) 2589 kfree(ses->serverDomain);
2871 kfree(ses->serverDomain);
2872 ses->serverDomain = 2590 ses->serverDomain =
2873 kzalloc(len + 1, 2591 kzalloc(len + 1,
2874 GFP_KERNEL); 2592 GFP_KERNEL);
@@ -2994,14 +2712,14 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2994 SecurityBlob->LmChallengeResponse.Buffer = 0; 2712 SecurityBlob->LmChallengeResponse.Buffer = 0;
2995 2713
2996 SecurityBlob->NtChallengeResponse.Length = 2714 SecurityBlob->NtChallengeResponse.Length =
2997 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 2715 cpu_to_le16(CIFS_SESS_KEY_SIZE);
2998 SecurityBlob->NtChallengeResponse.MaximumLength = 2716 SecurityBlob->NtChallengeResponse.MaximumLength =
2999 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 2717 cpu_to_le16(CIFS_SESS_KEY_SIZE);
3000 memcpy(bcc_ptr, ntlm_session_key, CIFS_SESSION_KEY_SIZE); 2718 memcpy(bcc_ptr, ntlm_session_key, CIFS_SESS_KEY_SIZE);
3001 SecurityBlob->NtChallengeResponse.Buffer = 2719 SecurityBlob->NtChallengeResponse.Buffer =
3002 cpu_to_le32(SecurityBlobLength); 2720 cpu_to_le32(SecurityBlobLength);
3003 SecurityBlobLength += CIFS_SESSION_KEY_SIZE; 2721 SecurityBlobLength += CIFS_SESS_KEY_SIZE;
3004 bcc_ptr += CIFS_SESSION_KEY_SIZE; 2722 bcc_ptr += CIFS_SESS_KEY_SIZE;
3005 2723
3006 if (ses->capabilities & CAP_UNICODE) { 2724 if (ses->capabilities & CAP_UNICODE) {
3007 if (domain == NULL) { 2725 if (domain == NULL) {
@@ -3190,8 +2908,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3190 bcc_ptr, 2908 bcc_ptr,
3191 remaining_words 2909 remaining_words
3192 - 1); 2910 - 1);
3193 if(ses->serverNOS) 2911 kfree(ses->serverNOS);
3194 kfree(ses->serverNOS);
3195 ses->serverNOS = 2912 ses->serverNOS =
3196 kzalloc(2 * (len + 1), 2913 kzalloc(2 * (len + 1),
3197 GFP_KERNEL); 2914 GFP_KERNEL);
@@ -3244,8 +2961,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3244 if(ses->serverDomain) 2961 if(ses->serverDomain)
3245 kfree(ses->serverDomain); 2962 kfree(ses->serverDomain);
3246 ses->serverDomain = kzalloc(2, GFP_KERNEL); 2963 ses->serverDomain = kzalloc(2, GFP_KERNEL);
3247 if(ses->serverNOS) 2964 kfree(ses->serverNOS);
3248 kfree(ses->serverNOS);
3249 ses->serverNOS = kzalloc(2, GFP_KERNEL); 2965 ses->serverNOS = kzalloc(2, GFP_KERNEL);
3250 } 2966 }
3251 } else { /* ASCII */ 2967 } else { /* ASCII */
@@ -3263,8 +2979,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3263 bcc_ptr++; 2979 bcc_ptr++;
3264 2980
3265 len = strnlen(bcc_ptr, 1024); 2981 len = strnlen(bcc_ptr, 1024);
3266 if(ses->serverNOS) 2982 kfree(ses->serverNOS);
3267 kfree(ses->serverNOS);
3268 ses->serverNOS = kzalloc(len+1,GFP_KERNEL); 2983 ses->serverNOS = kzalloc(len+1,GFP_KERNEL);
3269 strncpy(ses->serverNOS, bcc_ptr, len); 2984 strncpy(ses->serverNOS, bcc_ptr, len);
3270 bcc_ptr += len; 2985 bcc_ptr += len;
@@ -3340,22 +3055,33 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3340 bcc_ptr = &pSMB->Password[0]; 3055 bcc_ptr = &pSMB->Password[0];
3341 if((ses->server->secMode) & SECMODE_USER) { 3056 if((ses->server->secMode) & SECMODE_USER) {
3342 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ 3057 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
3058 *bcc_ptr = 0; /* password is null byte */
3343 bcc_ptr++; /* skip password */ 3059 bcc_ptr++; /* skip password */
3060 /* already aligned so no need to do it below */
3344 } else { 3061 } else {
3345 pSMB->PasswordLength = cpu_to_le16(CIFS_SESSION_KEY_SIZE); 3062 pSMB->PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
3346 /* BB FIXME add code to fail this if NTLMv2 or Kerberos 3063 /* BB FIXME add code to fail this if NTLMv2 or Kerberos
3347 specified as required (when that support is added to 3064 specified as required (when that support is added to
3348 the vfs in the future) as only NTLM or the much 3065 the vfs in the future) as only NTLM or the much
3349 weaker LANMAN (which we do not send) is accepted 3066 weaker LANMAN (which we do not send by default) is accepted
3350 by Samba (not sure whether other servers allow 3067 by Samba (not sure whether other servers allow
3351 NTLMv2 password here) */ 3068 NTLMv2 password here) */
3069#ifdef CONFIG_CIFS_WEAK_PW_HASH
3070 if((extended_security & CIFSSEC_MAY_LANMAN) &&
3071 (ses->server->secType == LANMAN))
3072 calc_lanman_hash(ses, bcc_ptr);
3073 else
3074#endif /* CIFS_WEAK_PW_HASH */
3352 SMBNTencrypt(ses->password, 3075 SMBNTencrypt(ses->password,
3353 ses->server->cryptKey, 3076 ses->server->cryptKey,
3354 bcc_ptr); 3077 bcc_ptr);
3355 3078
3356 bcc_ptr += CIFS_SESSION_KEY_SIZE; 3079 bcc_ptr += CIFS_SESS_KEY_SIZE;
3357 *bcc_ptr = 0; 3080 if(ses->capabilities & CAP_UNICODE) {
3358 bcc_ptr++; /* align */ 3081 /* must align unicode strings */
3082 *bcc_ptr = 0; /* null byte password */
3083 bcc_ptr++;
3084 }
3359 } 3085 }
3360 3086
3361 if(ses->server->secMode & 3087 if(ses->server->secMode &
@@ -3429,7 +3155,10 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3429 } 3155 }
3430 /* else do not bother copying these informational fields */ 3156 /* else do not bother copying these informational fields */
3431 } 3157 }
3432 tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); 3158 if(smb_buffer_response->WordCount == 3)
3159 tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport);
3160 else
3161 tcon->Flags = 0;
3433 cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags)); 3162 cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags));
3434 } else if ((rc == 0) && tcon == NULL) { 3163 } else if ((rc == 0) && tcon == NULL) {
3435 /* all we need to save for IPC$ connection */ 3164 /* all we need to save for IPC$ connection */
@@ -3494,7 +3223,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3494 struct nls_table * nls_info) 3223 struct nls_table * nls_info)
3495{ 3224{
3496 int rc = 0; 3225 int rc = 0;
3497 char ntlm_session_key[CIFS_SESSION_KEY_SIZE]; 3226 char ntlm_session_key[CIFS_SESS_KEY_SIZE];
3498 int ntlmv2_flag = FALSE; 3227 int ntlmv2_flag = FALSE;
3499 int first_time = 0; 3228 int first_time = 0;
3500 3229
@@ -3526,20 +3255,13 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3526 pSesInfo->server->secMode, 3255 pSesInfo->server->secMode,
3527 pSesInfo->server->capabilities, 3256 pSesInfo->server->capabilities,
3528 pSesInfo->server->timeZone)); 3257 pSesInfo->server->timeZone));
3529#ifdef CONFIG_CIFS_EXPERIMENTAL 3258 if(experimEnabled < 2)
3530 if(experimEnabled > 1) 3259 rc = CIFS_SessSetup(xid, pSesInfo,
3531 rc = CIFS_SessSetup(xid, pSesInfo, CIFS_NTLM /* type */, 3260 first_time, nls_info);
3532 &ntlmv2_flag, nls_info); 3261 else if (extended_security
3533 else
3534#endif
3535 if (extended_security
3536 && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) 3262 && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY)
3537 && (pSesInfo->server->secType == NTLMSSP)) { 3263 && (pSesInfo->server->secType == NTLMSSP)) {
3538 cFYI(1, ("New style sesssetup")); 3264 rc = -EOPNOTSUPP;
3539 rc = CIFSSpnegoSessSetup(xid, pSesInfo,
3540 NULL /* security blob */,
3541 0 /* blob length */,
3542 nls_info);
3543 } else if (extended_security 3265 } else if (extended_security
3544 && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) 3266 && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY)
3545 && (pSesInfo->server->secType == RawNTLMSSP)) { 3267 && (pSesInfo->server->secType == RawNTLMSSP)) {
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 82315edc77d7..ba4cbe9b0684 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -113,7 +113,7 @@ cifs_bp_rename_retry:
113 full_path[namelen+2] = 0; 113 full_path[namelen+2] = 0;
114BB remove above eight lines BB */ 114BB remove above eight lines BB */
115 115
116/* Inode operations in similar order to how they appear in the Linux file fs.h */ 116/* Inode operations in similar order to how they appear in Linux file fs.h */
117 117
118int 118int
119cifs_create(struct inode *inode, struct dentry *direntry, int mode, 119cifs_create(struct inode *inode, struct dentry *direntry, int mode,
@@ -178,11 +178,14 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
178 FreeXid(xid); 178 FreeXid(xid);
179 return -ENOMEM; 179 return -ENOMEM;
180 } 180 }
181 181 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
182 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 182 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
183 desiredAccess, CREATE_NOT_DIR, 183 desiredAccess, CREATE_NOT_DIR,
184 &fileHandle, &oplock, buf, cifs_sb->local_nls, 184 &fileHandle, &oplock, buf, cifs_sb->local_nls,
185 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 185 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
186 else
187 rc = -EIO; /* no NT SMB support fall into legacy open below */
188
186 if(rc == -EIO) { 189 if(rc == -EIO) {
187 /* old server, retry the open legacy style */ 190 /* old server, retry the open legacy style */
188 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 191 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
@@ -191,7 +194,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
191 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 194 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
192 } 195 }
193 if (rc) { 196 if (rc) {
194 cFYI(1, ("cifs_create returned 0x%x ", rc)); 197 cFYI(1, ("cifs_create returned 0x%x", rc));
195 } else { 198 } else {
196 /* If Open reported that we actually created a file 199 /* If Open reported that we actually created a file
197 then we now have to set the mode if possible */ 200 then we now have to set the mode if possible */
@@ -369,6 +372,10 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
369 cifs_sb->mnt_cifs_flags & 372 cifs_sb->mnt_cifs_flags &
370 CIFS_MOUNT_MAP_SPECIAL_CHR); 373 CIFS_MOUNT_MAP_SPECIAL_CHR);
371 374
375 /* BB FIXME - add handling for backlevel servers
376 which need legacy open and check for all
377 calls to SMBOpen for fallback to
378 SMBLeagcyOpen */
372 if(!rc) { 379 if(!rc) {
373 /* BB Do not bother to decode buf since no 380 /* BB Do not bother to decode buf since no
374 local inode yet to put timestamps in, 381 local inode yet to put timestamps in,
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index 633a93811328..d91a3d44e9e3 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -91,14 +91,14 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
91 if(full_path == NULL) { 91 if(full_path == NULL) {
92 rc = -ENOMEM; 92 rc = -ENOMEM;
93 } else { 93 } else {
94 cERROR(1,("cifs dir notify on file %s with arg 0x%lx",full_path,arg)); /* BB removeme BB */ 94 cFYI(1,("dir notify on file %s Arg 0x%lx",full_path,arg));
95 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 95 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
96 GENERIC_READ | SYNCHRONIZE, 0 /* create options */, 96 GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
97 &netfid, &oplock,NULL, cifs_sb->local_nls, 97 &netfid, &oplock,NULL, cifs_sb->local_nls,
98 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 98 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
99 /* BB fixme - add this handle to a notify handle list */ 99 /* BB fixme - add this handle to a notify handle list */
100 if(rc) { 100 if(rc) {
101 cERROR(1,("Could not open directory for notify")); /* BB remove BB */ 101 cFYI(1,("Could not open directory for notify"));
102 } else { 102 } else {
103 filter = convert_to_cifs_notify_flags(arg); 103 filter = convert_to_cifs_notify_flags(arg);
104 if(filter != 0) { 104 if(filter != 0) {
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index b4a18c1cab0a..5861eb42e626 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -110,7 +110,6 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
110 &pCifsInode->openFileList); 110 &pCifsInode->openFileList);
111 } 111 }
112 write_unlock(&GlobalSMBSeslock); 112 write_unlock(&GlobalSMBSeslock);
113 write_unlock(&file->f_owner.lock);
114 if (pCifsInode->clientCanCacheRead) { 113 if (pCifsInode->clientCanCacheRead) {
115 /* we have the inode open somewhere else 114 /* we have the inode open somewhere else
116 no need to discard cache data */ 115 no need to discard cache data */
@@ -201,7 +200,7 @@ int cifs_open(struct inode *inode, struct file *file)
201 } else { 200 } else {
202 if (file->f_flags & O_EXCL) 201 if (file->f_flags & O_EXCL)
203 cERROR(1, ("could not find file instance for " 202 cERROR(1, ("could not find file instance for "
204 "new file %p ", file)); 203 "new file %p", file));
205 } 204 }
206 } 205 }
207 206
@@ -260,10 +259,15 @@ int cifs_open(struct inode *inode, struct file *file)
260 rc = -ENOMEM; 259 rc = -ENOMEM;
261 goto out; 260 goto out;
262 } 261 }
263 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, 262
264 CREATE_NOT_DIR, &netfid, &oplock, buf, 263 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
264 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
265 desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
265 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags 266 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
266 & CIFS_MOUNT_MAP_SPECIAL_CHR); 267 & CIFS_MOUNT_MAP_SPECIAL_CHR);
268 else
269 rc = -EIO; /* no NT SMB support fall into legacy open below */
270
267 if (rc == -EIO) { 271 if (rc == -EIO) {
268 /* Old server, try legacy style OpenX */ 272 /* Old server, try legacy style OpenX */
269 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 273 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
@@ -272,7 +276,7 @@ int cifs_open(struct inode *inode, struct file *file)
272 & CIFS_MOUNT_MAP_SPECIAL_CHR); 276 & CIFS_MOUNT_MAP_SPECIAL_CHR);
273 } 277 }
274 if (rc) { 278 if (rc) {
275 cFYI(1, ("cifs_open returned 0x%x ", rc)); 279 cFYI(1, ("cifs_open returned 0x%x", rc));
276 goto out; 280 goto out;
277 } 281 }
278 file->private_data = 282 file->private_data =
@@ -282,7 +286,6 @@ int cifs_open(struct inode *inode, struct file *file)
282 goto out; 286 goto out;
283 } 287 }
284 pCifsFile = cifs_init_private(file->private_data, inode, file, netfid); 288 pCifsFile = cifs_init_private(file->private_data, inode, file, netfid);
285 write_lock(&file->f_owner.lock);
286 write_lock(&GlobalSMBSeslock); 289 write_lock(&GlobalSMBSeslock);
287 list_add(&pCifsFile->tlist, &pTcon->openFileList); 290 list_add(&pCifsFile->tlist, &pTcon->openFileList);
288 291
@@ -293,7 +296,6 @@ int cifs_open(struct inode *inode, struct file *file)
293 &oplock, buf, full_path, xid); 296 &oplock, buf, full_path, xid);
294 } else { 297 } else {
295 write_unlock(&GlobalSMBSeslock); 298 write_unlock(&GlobalSMBSeslock);
296 write_unlock(&file->f_owner.lock);
297 } 299 }
298 300
299 if (oplock & CIFS_CREATE_ACTION) { 301 if (oplock & CIFS_CREATE_ACTION) {
@@ -409,8 +411,8 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
409 CIFS_MOUNT_MAP_SPECIAL_CHR); 411 CIFS_MOUNT_MAP_SPECIAL_CHR);
410 if (rc) { 412 if (rc) {
411 up(&pCifsFile->fh_sem); 413 up(&pCifsFile->fh_sem);
412 cFYI(1, ("cifs_open returned 0x%x ", rc)); 414 cFYI(1, ("cifs_open returned 0x%x", rc));
413 cFYI(1, ("oplock: %d ", oplock)); 415 cFYI(1, ("oplock: %d", oplock));
414 } else { 416 } else {
415 pCifsFile->netfid = netfid; 417 pCifsFile->netfid = netfid;
416 pCifsFile->invalidHandle = FALSE; 418 pCifsFile->invalidHandle = FALSE;
@@ -472,7 +474,6 @@ int cifs_close(struct inode *inode, struct file *file)
472 pTcon = cifs_sb->tcon; 474 pTcon = cifs_sb->tcon;
473 if (pSMBFile) { 475 if (pSMBFile) {
474 pSMBFile->closePend = TRUE; 476 pSMBFile->closePend = TRUE;
475 write_lock(&file->f_owner.lock);
476 if (pTcon) { 477 if (pTcon) {
477 /* no sense reconnecting to close a file that is 478 /* no sense reconnecting to close a file that is
478 already closed */ 479 already closed */
@@ -487,23 +488,18 @@ int cifs_close(struct inode *inode, struct file *file)
487 the struct would be in each open file, 488 the struct would be in each open file,
488 but this should give enough time to 489 but this should give enough time to
489 clear the socket */ 490 clear the socket */
490 write_unlock(&file->f_owner.lock);
491 cERROR(1,("close with pending writes")); 491 cERROR(1,("close with pending writes"));
492 msleep(timeout); 492 msleep(timeout);
493 write_lock(&file->f_owner.lock);
494 timeout *= 4; 493 timeout *= 4;
495 } 494 }
496 write_unlock(&file->f_owner.lock);
497 rc = CIFSSMBClose(xid, pTcon, 495 rc = CIFSSMBClose(xid, pTcon,
498 pSMBFile->netfid); 496 pSMBFile->netfid);
499 write_lock(&file->f_owner.lock);
500 } 497 }
501 } 498 }
502 write_lock(&GlobalSMBSeslock); 499 write_lock(&GlobalSMBSeslock);
503 list_del(&pSMBFile->flist); 500 list_del(&pSMBFile->flist);
504 list_del(&pSMBFile->tlist); 501 list_del(&pSMBFile->tlist);
505 write_unlock(&GlobalSMBSeslock); 502 write_unlock(&GlobalSMBSeslock);
506 write_unlock(&file->f_owner.lock);
507 kfree(pSMBFile->search_resume_name); 503 kfree(pSMBFile->search_resume_name);
508 kfree(file->private_data); 504 kfree(file->private_data);
509 file->private_data = NULL; 505 file->private_data = NULL;
@@ -531,7 +527,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
531 (struct cifsFileInfo *)file->private_data; 527 (struct cifsFileInfo *)file->private_data;
532 char *ptmp; 528 char *ptmp;
533 529
534 cFYI(1, ("Closedir inode = 0x%p with ", inode)); 530 cFYI(1, ("Closedir inode = 0x%p", inode));
535 531
536 xid = GetXid(); 532 xid = GetXid();
537 533
@@ -605,7 +601,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
605 } 601 }
606 if (pfLock->fl_flags & FL_ACCESS) 602 if (pfLock->fl_flags & FL_ACCESS)
607 cFYI(1, ("Process suspended by mandatory locking - " 603 cFYI(1, ("Process suspended by mandatory locking - "
608 "not implemented yet ")); 604 "not implemented yet"));
609 if (pfLock->fl_flags & FL_LEASE) 605 if (pfLock->fl_flags & FL_LEASE)
610 cFYI(1, ("Lease on file - not implemented yet")); 606 cFYI(1, ("Lease on file - not implemented yet"));
611 if (pfLock->fl_flags & 607 if (pfLock->fl_flags &
@@ -1375,7 +1371,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
1375 1371
1376 xid = GetXid(); 1372 xid = GetXid();
1377 1373
1378 cFYI(1, ("Sync file - name: %s datasync: 0x%x ", 1374 cFYI(1, ("Sync file - name: %s datasync: 0x%x",
1379 dentry->d_name.name, datasync)); 1375 dentry->d_name.name, datasync));
1380 1376
1381 rc = filemap_fdatawrite(inode->i_mapping); 1377 rc = filemap_fdatawrite(inode->i_mapping);
@@ -1404,7 +1400,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
1404/* fill in rpages then 1400/* fill in rpages then
1405 result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */ 1401 result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */
1406 1402
1407/* cFYI(1, ("rpages is %d for sync page of Index %ld ", rpages, index)); 1403/* cFYI(1, ("rpages is %d for sync page of Index %ld", rpages, index));
1408 1404
1409#if 0 1405#if 0
1410 if (rc < 0) 1406 if (rc < 0)
@@ -1836,7 +1832,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
1836 if (rc < 0) 1832 if (rc < 0)
1837 goto io_error; 1833 goto io_error;
1838 else 1834 else
1839 cFYI(1, ("Bytes read %d ",rc)); 1835 cFYI(1, ("Bytes read %d",rc));
1840 1836
1841 file->f_dentry->d_inode->i_atime = 1837 file->f_dentry->d_inode->i_atime =
1842 current_fs_time(file->f_dentry->d_inode->i_sb); 1838 current_fs_time(file->f_dentry->d_inode->i_sb);
@@ -1946,7 +1942,7 @@ static int cifs_prepare_write(struct file *file, struct page *page,
1946 return 0; 1942 return 0;
1947} 1943}
1948 1944
1949struct address_space_operations cifs_addr_ops = { 1945const struct address_space_operations cifs_addr_ops = {
1950 .readpage = cifs_readpage, 1946 .readpage = cifs_readpage,
1951 .readpages = cifs_readpages, 1947 .readpages = cifs_readpages,
1952 .writepage = cifs_writepage, 1948 .writepage = cifs_writepage,
@@ -1957,3 +1953,19 @@ struct address_space_operations cifs_addr_ops = {
1957 /* .sync_page = cifs_sync_page, */ 1953 /* .sync_page = cifs_sync_page, */
1958 /* .direct_IO = */ 1954 /* .direct_IO = */
1959}; 1955};
1956
1957/*
1958 * cifs_readpages requires the server to support a buffer large enough to
1959 * contain the header plus one complete page of data. Otherwise, we need
1960 * to leave cifs_readpages out of the address space operations.
1961 */
1962const struct address_space_operations cifs_addr_ops_smallbuf = {
1963 .readpage = cifs_readpage,
1964 .writepage = cifs_writepage,
1965 .writepages = cifs_writepages,
1966 .prepare_write = cifs_prepare_write,
1967 .commit_write = cifs_commit_write,
1968 .set_page_dirty = __set_page_dirty_nobuffers,
1969 /* .sync_page = cifs_sync_page, */
1970 /* .direct_IO = */
1971};
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 4093764ef461..b88147c1dc27 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -41,7 +41,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
41 char *tmp_path; 41 char *tmp_path;
42 42
43 pTcon = cifs_sb->tcon; 43 pTcon = cifs_sb->tcon;
44 cFYI(1, ("Getting info on %s ", search_path)); 44 cFYI(1, ("Getting info on %s", search_path));
45 /* could have done a find first instead but this returns more info */ 45 /* could have done a find first instead but this returns more info */
46 rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData, 46 rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData,
47 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 47 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
@@ -97,9 +97,9 @@ int cifs_get_inode_info_unix(struct inode **pinode,
97 inode = *pinode; 97 inode = *pinode;
98 cifsInfo = CIFS_I(inode); 98 cifsInfo = CIFS_I(inode);
99 99
100 cFYI(1, ("Old time %ld ", cifsInfo->time)); 100 cFYI(1, ("Old time %ld", cifsInfo->time));
101 cifsInfo->time = jiffies; 101 cifsInfo->time = jiffies;
102 cFYI(1, ("New time %ld ", cifsInfo->time)); 102 cFYI(1, ("New time %ld", cifsInfo->time));
103 /* this is ok to set on every inode revalidate */ 103 /* this is ok to set on every inode revalidate */
104 atomic_set(&cifsInfo->inUse,1); 104 atomic_set(&cifsInfo->inUse,1);
105 105
@@ -180,11 +180,12 @@ int cifs_get_inode_info_unix(struct inode **pinode,
180 else /* not direct, send byte range locks */ 180 else /* not direct, send byte range locks */
181 inode->i_fop = &cifs_file_ops; 181 inode->i_fop = &cifs_file_ops;
182 182
183 inode->i_data.a_ops = &cifs_addr_ops;
184 /* check if server can support readpages */ 183 /* check if server can support readpages */
185 if(pTcon->ses->server->maxBuf < 184 if(pTcon->ses->server->maxBuf <
186 4096 + MAX_CIFS_HDR_SIZE) 185 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
187 inode->i_data.a_ops->readpages = NULL; 186 inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
187 else
188 inode->i_data.a_ops = &cifs_addr_ops;
188 } else if (S_ISDIR(inode->i_mode)) { 189 } else if (S_ISDIR(inode->i_mode)) {
189 cFYI(1, ("Directory inode")); 190 cFYI(1, ("Directory inode"));
190 inode->i_op = &cifs_dir_inode_ops; 191 inode->i_op = &cifs_dir_inode_ops;
@@ -421,23 +422,23 @@ int cifs_get_inode_info(struct inode **pinode,
421 inode = *pinode; 422 inode = *pinode;
422 cifsInfo = CIFS_I(inode); 423 cifsInfo = CIFS_I(inode);
423 cifsInfo->cifsAttrs = attr; 424 cifsInfo->cifsAttrs = attr;
424 cFYI(1, ("Old time %ld ", cifsInfo->time)); 425 cFYI(1, ("Old time %ld", cifsInfo->time));
425 cifsInfo->time = jiffies; 426 cifsInfo->time = jiffies;
426 cFYI(1, ("New time %ld ", cifsInfo->time)); 427 cFYI(1, ("New time %ld", cifsInfo->time));
427 428
428 /* blksize needs to be multiple of two. So safer to default to 429 /* blksize needs to be multiple of two. So safer to default to
429 blksize and blkbits set in superblock so 2**blkbits and blksize 430 blksize and blkbits set in superblock so 2**blkbits and blksize
430 will match rather than setting to: 431 will match rather than setting to:
431 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ 432 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
432 433
433 /* Linux can not store file creation time unfortunately so we ignore it */ 434 /* Linux can not store file creation time so ignore it */
434 inode->i_atime = 435 inode->i_atime =
435 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); 436 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime));
436 inode->i_mtime = 437 inode->i_mtime =
437 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); 438 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime));
438 inode->i_ctime = 439 inode->i_ctime =
439 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 440 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
440 cFYI(0, ("Attributes came in as 0x%x ", attr)); 441 cFYI(0, ("Attributes came in as 0x%x", attr));
441 442
442 /* set default mode. will override for dirs below */ 443 /* set default mode. will override for dirs below */
443 if (atomic_read(&cifsInfo->inUse) == 0) 444 if (atomic_read(&cifsInfo->inUse) == 0)
@@ -519,10 +520,11 @@ int cifs_get_inode_info(struct inode **pinode,
519 else /* not direct, send byte range locks */ 520 else /* not direct, send byte range locks */
520 inode->i_fop = &cifs_file_ops; 521 inode->i_fop = &cifs_file_ops;
521 522
522 inode->i_data.a_ops = &cifs_addr_ops;
523 if(pTcon->ses->server->maxBuf < 523 if(pTcon->ses->server->maxBuf <
524 4096 + MAX_CIFS_HDR_SIZE) 524 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
525 inode->i_data.a_ops->readpages = NULL; 525 inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
526 else
527 inode->i_data.a_ops = &cifs_addr_ops;
526 } else if (S_ISDIR(inode->i_mode)) { 528 } else if (S_ISDIR(inode->i_mode)) {
527 cFYI(1, ("Directory inode")); 529 cFYI(1, ("Directory inode"));
528 inode->i_op = &cifs_dir_inode_ops; 530 inode->i_op = &cifs_dir_inode_ops;
@@ -731,7 +733,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
731 rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, 733 rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls,
732 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 734 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
733 if (rc) { 735 if (rc) {
734 cFYI(1, ("cifs_mkdir returned 0x%x ", rc)); 736 cFYI(1, ("cifs_mkdir returned 0x%x", rc));
735 d_drop(direntry); 737 d_drop(direntry);
736 } else { 738 } else {
737 inode->i_nlink++; 739 inode->i_nlink++;
@@ -798,7 +800,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
798 char *full_path = NULL; 800 char *full_path = NULL;
799 struct cifsInodeInfo *cifsInode; 801 struct cifsInodeInfo *cifsInode;
800 802
801 cFYI(1, ("cifs_rmdir, inode = 0x%p with ", inode)); 803 cFYI(1, ("cifs_rmdir, inode = 0x%p", inode));
802 804
803 xid = GetXid(); 805 xid = GetXid();
804 806
@@ -1121,7 +1123,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1121 1123
1122 xid = GetXid(); 1124 xid = GetXid();
1123 1125
1124 cFYI(1, ("In cifs_setattr, name = %s attrs->iavalid 0x%x ", 1126 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x",
1125 direntry->d_name.name, attrs->ia_valid)); 1127 direntry->d_name.name, attrs->ia_valid));
1126 1128
1127 cifs_sb = CIFS_SB(direntry->d_inode->i_sb); 1129 cifs_sb = CIFS_SB(direntry->d_inode->i_sb);
@@ -1157,6 +1159,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1157 when the local oplock break takes longer to flush 1159 when the local oplock break takes longer to flush
1158 writebehind data than the SMB timeout for the SetPathInfo 1160 writebehind data than the SMB timeout for the SetPathInfo
1159 request would allow */ 1161 request would allow */
1162
1160 open_file = find_writable_file(cifsInode); 1163 open_file = find_writable_file(cifsInode);
1161 if (open_file) { 1164 if (open_file) {
1162 __u16 nfid = open_file->netfid; 1165 __u16 nfid = open_file->netfid;
@@ -1289,7 +1292,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1289 it may be useful to Windows - but we do 1292 it may be useful to Windows - but we do
1290 not want to set ctime unless some other 1293 not want to set ctime unless some other
1291 timestamp is changing */ 1294 timestamp is changing */
1292 cFYI(1, ("CIFS - CTIME changed ")); 1295 cFYI(1, ("CIFS - CTIME changed"));
1293 time_buf.ChangeTime = 1296 time_buf.ChangeTime =
1294 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime)); 1297 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));
1295 } else 1298 } else
@@ -1356,7 +1359,7 @@ cifs_setattr_exit:
1356 1359
1357void cifs_delete_inode(struct inode *inode) 1360void cifs_delete_inode(struct inode *inode)
1358{ 1361{
1359 cFYI(1, ("In cifs_delete_inode, inode = 0x%p ", inode)); 1362 cFYI(1, ("In cifs_delete_inode, inode = 0x%p", inode));
1360 /* may have to add back in if and when safe distributed caching of 1363 /* may have to add back in if and when safe distributed caching of
1361 directories added e.g. via FindNotify */ 1364 directories added e.g. via FindNotify */
1362} 1365}
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 2ec99f833142..a57f5d6e6213 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -167,7 +167,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
167 return -ENOMEM; 167 return -ENOMEM;
168 } 168 }
169 169
170 cFYI(1, ("Full path: %s ", full_path)); 170 cFYI(1, ("Full path: %s", full_path));
171 cFYI(1, ("symname is %s", symname)); 171 cFYI(1, ("symname is %s", symname));
172 172
173 /* BB what if DFS and this volume is on different share? BB */ 173 /* BB what if DFS and this volume is on different share? BB */
@@ -186,8 +186,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
186 inode->i_sb,xid); 186 inode->i_sb,xid);
187 187
188 if (rc != 0) { 188 if (rc != 0) {
189 cFYI(1, 189 cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d",
190 ("Create symlink worked but get_inode_info failed with rc = %d ",
191 rc)); 190 rc));
192 } else { 191 } else {
193 if (pTcon->nocase) 192 if (pTcon->nocase)
@@ -289,7 +288,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
289 else { 288 else {
290 cFYI(1,("num referral: %d",num_referrals)); 289 cFYI(1,("num referral: %d",num_referrals));
291 if(referrals) { 290 if(referrals) {
292 cFYI(1,("referral string: %s ",referrals)); 291 cFYI(1,("referral string: %s",referrals));
293 strncpy(tmpbuffer, referrals, len-1); 292 strncpy(tmpbuffer, referrals, len-1);
294 } 293 }
295 } 294 }
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index fafd056426e4..22c937e5884f 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -101,6 +101,7 @@ sesInfoFree(struct cifsSesInfo *buf_to_free)
101 kfree(buf_to_free->serverDomain); 101 kfree(buf_to_free->serverDomain);
102 kfree(buf_to_free->serverNOS); 102 kfree(buf_to_free->serverNOS);
103 kfree(buf_to_free->password); 103 kfree(buf_to_free->password);
104 kfree(buf_to_free->domainName);
104 kfree(buf_to_free); 105 kfree(buf_to_free);
105} 106}
106 107
@@ -499,11 +500,12 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
499 if(pSMBr->ByteCount > sizeof(struct file_notify_information)) { 500 if(pSMBr->ByteCount > sizeof(struct file_notify_information)) {
500 data_offset = le32_to_cpu(pSMBr->DataOffset); 501 data_offset = le32_to_cpu(pSMBr->DataOffset);
501 502
502 pnotify = (struct file_notify_information *)((char *)&pSMBr->hdr.Protocol 503 pnotify = (struct file_notify_information *)
503 + data_offset); 504 ((char *)&pSMBr->hdr.Protocol + data_offset);
504 cFYI(1,("dnotify on %s with action: 0x%x",pnotify->FileName, 505 cFYI(1,("dnotify on %s Action: 0x%x",pnotify->FileName,
505 pnotify->Action)); /* BB removeme BB */ 506 pnotify->Action)); /* BB removeme BB */
506 /* cifs_dump_mem("Received notify Data is: ",buf,sizeof(struct smb_hdr)+60); */ 507 /* cifs_dump_mem("Rcvd notify Data: ",buf,
508 sizeof(struct smb_hdr)+60); */
507 return TRUE; 509 return TRUE;
508 } 510 }
509 if(pSMBr->hdr.Status.CifsError) { 511 if(pSMBr->hdr.Status.CifsError) {
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 5de74d216fdd..b66eff5dc624 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -84,11 +84,11 @@ static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
84 84
85static const struct smb_to_posix_error mapping_table_ERRSRV[] = { 85static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
86 {ERRerror, -EIO}, 86 {ERRerror, -EIO},
87 {ERRbadpw, -EPERM}, 87 {ERRbadpw, -EACCES}, /* was EPERM */
88 {ERRbadtype, -EREMOTE}, 88 {ERRbadtype, -EREMOTE},
89 {ERRaccess, -EACCES}, 89 {ERRaccess, -EACCES},
90 {ERRinvtid, -ENXIO}, 90 {ERRinvtid, -ENXIO},
91 {ERRinvnetname, -ENODEV}, 91 {ERRinvnetname, -ENXIO},
92 {ERRinvdevice, -ENXIO}, 92 {ERRinvdevice, -ENXIO},
93 {ERRqfull, -ENOSPC}, 93 {ERRqfull, -ENOSPC},
94 {ERRqtoobig, -ENOSPC}, 94 {ERRqtoobig, -ENOSPC},
diff --git a/fs/cifs/ntlmssp.c b/fs/cifs/ntlmssp.c
deleted file mode 100644
index 115359cc7a32..000000000000
--- a/fs/cifs/ntlmssp.c
+++ /dev/null
@@ -1,143 +0,0 @@
1/*
2 * fs/cifs/ntlmssp.h
3 *
4 * Copyright (c) International Business Machines Corp., 2006
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include "cifspdu.h"
23#include "cifsglob.h"
24#include "cifsproto.h"
25#include "cifs_unicode.h"
26#include "cifs_debug.h"
27#include "ntlmssp.h"
28#include "nterr.h"
29
30#ifdef CONFIG_CIFS_EXPERIMENTAL
31static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
32{
33 __u32 capabilities = 0;
34
35 /* init fields common to all four types of SessSetup */
36 /* note that header is initialized to zero in header_assemble */
37 pSMB->req.AndXCommand = 0xFF;
38 pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
39 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
40
41 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
42
43 /* BB verify whether signing required on neg or just on auth frame
44 (and NTLM case) */
45
46 capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
47 CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
48
49 if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
50 pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
51
52 if (ses->capabilities & CAP_UNICODE) {
53 pSMB->req.hdr.Flags2 |= SMBFLG2_UNICODE;
54 capabilities |= CAP_UNICODE;
55 }
56 if (ses->capabilities & CAP_STATUS32) {
57 pSMB->req.hdr.Flags2 |= SMBFLG2_ERR_STATUS;
58 capabilities |= CAP_STATUS32;
59 }
60 if (ses->capabilities & CAP_DFS) {
61 pSMB->req.hdr.Flags2 |= SMBFLG2_DFS;
62 capabilities |= CAP_DFS;
63 }
64
65 /* BB check whether to init vcnum BB */
66 return capabilities;
67}
68int
69CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, const int type,
70 int * pNTLMv2_flg, const struct nls_table *nls_cp)
71{
72 int rc = 0;
73 int wct;
74 struct smb_hdr *smb_buffer;
75 char *bcc_ptr;
76 SESSION_SETUP_ANDX *pSMB;
77 __u32 capabilities;
78
79 if(ses == NULL)
80 return -EINVAL;
81
82 cFYI(1,("SStp type: %d",type));
83 if(type < CIFS_NTLM) {
84#ifndef CONFIG_CIFS_WEAK_PW_HASH
85 /* LANMAN and plaintext are less secure and off by default.
86 So we make this explicitly be turned on in kconfig (in the
87 build) and turned on at runtime (changed from the default)
88 in proc/fs/cifs or via mount parm. Unfortunately this is
89 needed for old Win (e.g. Win95), some obscure NAS and OS/2 */
90 return -EOPNOTSUPP;
91#endif
92 wct = 10; /* lanman 2 style sessionsetup */
93 } else if(type < CIFS_NTLMSSP_NEG)
94 wct = 13; /* old style NTLM sessionsetup */
95 else /* same size for negotiate or auth, NTLMSSP or extended security */
96 wct = 12;
97
98 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses,
99 (void **)&smb_buffer);
100 if(rc)
101 return rc;
102
103 pSMB = (SESSION_SETUP_ANDX *)smb_buffer;
104
105 capabilities = cifs_ssetup_hdr(ses, pSMB);
106 bcc_ptr = pByteArea(smb_buffer);
107 if(type > CIFS_NTLM) {
108 pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
109 capabilities |= CAP_EXTENDED_SECURITY;
110 pSMB->req.Capabilities = cpu_to_le32(capabilities);
111 /* BB set password lengths */
112 } else if(type < CIFS_NTLM) /* lanman */ {
113 /* no capabilities flags in old lanman negotiation */
114 /* pSMB->old_req.PasswordLength = */ /* BB fixme BB */
115 } else /* type CIFS_NTLM */ {
116 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
117 pSMB->req_no_secext.CaseInsensitivePasswordLength =
118 cpu_to_le16(CIFS_SESSION_KEY_SIZE);
119 pSMB->req_no_secext.CaseSensitivePasswordLength =
120 cpu_to_le16(CIFS_SESSION_KEY_SIZE);
121 }
122
123
124 /* copy session key */
125
126 /* if Unicode, align strings to two byte boundary */
127
128 /* copy user name */ /* BB Do we need to special case null user name? */
129
130 /* copy domain name */
131
132 /* copy Linux version */
133
134 /* copy network operating system name */
135
136 /* update bcc and smb buffer length */
137
138/* rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buf_type, 0); */
139 /* SMB request buf freed in SendReceive2 */
140
141 return rc;
142}
143#endif /* CONFIG_CIFS_EXPERIMENTAL */
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index b689c5035124..03bbcb377913 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -21,6 +21,7 @@
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23#include <linux/fs.h> 23#include <linux/fs.h>
24#include <linux/pagemap.h>
24#include <linux/stat.h> 25#include <linux/stat.h>
25#include <linux/smp_lock.h> 26#include <linux/smp_lock.h>
26#include "cifspdu.h" 27#include "cifspdu.h"
@@ -31,8 +32,8 @@
31#include "cifs_fs_sb.h" 32#include "cifs_fs_sb.h"
32#include "cifsfs.h" 33#include "cifsfs.h"
33 34
34/* BB fixme - add debug wrappers around this function to disable it fixme BB */ 35#ifdef CONFIG_CIFS_DEBUG2
35/* static void dump_cifs_file_struct(struct file *file, char *label) 36static void dump_cifs_file_struct(struct file *file, char *label)
36{ 37{
37 struct cifsFileInfo * cf; 38 struct cifsFileInfo * cf;
38 39
@@ -53,7 +54,8 @@
53 } 54 }
54 55
55 } 56 }
56} */ 57}
58#endif /* DEBUG2 */
57 59
58/* Returns one if new inode created (which therefore needs to be hashed) */ 60/* Returns one if new inode created (which therefore needs to be hashed) */
59/* Might check in the future if inode number changed so we can rehash inode */ 61/* Might check in the future if inode number changed so we can rehash inode */
@@ -107,32 +109,52 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
107 return rc; 109 return rc;
108} 110}
109 111
110static void fill_in_inode(struct inode *tmp_inode, 112static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
111 FILE_DIRECTORY_INFO *pfindData, int *pobject_type, int isNewInode) 113 char * buf, int *pobject_type, int isNewInode)
112{ 114{
113 loff_t local_size; 115 loff_t local_size;
114 struct timespec local_mtime; 116 struct timespec local_mtime;
115 117
116 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); 118 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
117 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); 119 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
118 __u32 attr = le32_to_cpu(pfindData->ExtFileAttributes); 120 __u32 attr;
119 __u64 allocation_size = le64_to_cpu(pfindData->AllocationSize); 121 __u64 allocation_size;
120 __u64 end_of_file = le64_to_cpu(pfindData->EndOfFile); 122 __u64 end_of_file;
121
122 cifsInfo->cifsAttrs = attr;
123 cifsInfo->time = jiffies;
124 123
125 /* save mtime and size */ 124 /* save mtime and size */
126 local_mtime = tmp_inode->i_mtime; 125 local_mtime = tmp_inode->i_mtime;
127 local_size = tmp_inode->i_size; 126 local_size = tmp_inode->i_size;
128 127
128 if(new_buf_type) {
129 FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf;
130
131 attr = le32_to_cpu(pfindData->ExtFileAttributes);
132 allocation_size = le64_to_cpu(pfindData->AllocationSize);
133 end_of_file = le64_to_cpu(pfindData->EndOfFile);
134 tmp_inode->i_atime =
135 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime));
136 tmp_inode->i_mtime =
137 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime));
138 tmp_inode->i_ctime =
139 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
140 } else { /* legacy, OS2 and DOS style */
141 FIND_FILE_STANDARD_INFO * pfindData =
142 (FIND_FILE_STANDARD_INFO *)buf;
143
144 attr = le16_to_cpu(pfindData->Attributes);
145 allocation_size = le32_to_cpu(pfindData->AllocationSize);
146 end_of_file = le32_to_cpu(pfindData->DataSize);
147 tmp_inode->i_atime = CURRENT_TIME;
148 /* tmp_inode->i_mtime = BB FIXME - add dos time handling
149 tmp_inode->i_ctime = 0; BB FIXME */
150
151 }
152
129 /* Linux can not store file creation time unfortunately so ignore it */ 153 /* Linux can not store file creation time unfortunately so ignore it */
130 tmp_inode->i_atime = 154
131 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); 155 cifsInfo->cifsAttrs = attr;
132 tmp_inode->i_mtime = 156 cifsInfo->time = jiffies;
133 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); 157
134 tmp_inode->i_ctime =
135 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
136 /* treat dos attribute of read-only as read-only mode bit e.g. 555? */ 158 /* treat dos attribute of read-only as read-only mode bit e.g. 555? */
137 /* 2767 perms - indicate mandatory locking */ 159 /* 2767 perms - indicate mandatory locking */
138 /* BB fill in uid and gid here? with help from winbind? 160 /* BB fill in uid and gid here? with help from winbind?
@@ -215,11 +237,13 @@ static void fill_in_inode(struct inode *tmp_inode,
215 else 237 else
216 tmp_inode->i_fop = &cifs_file_ops; 238 tmp_inode->i_fop = &cifs_file_ops;
217 239
218 tmp_inode->i_data.a_ops = &cifs_addr_ops;
219 if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && 240 if((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
220 (cifs_sb->tcon->ses->server->maxBuf < 241 (cifs_sb->tcon->ses->server->maxBuf <
221 4096 + MAX_CIFS_HDR_SIZE)) 242 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
222 tmp_inode->i_data.a_ops->readpages = NULL; 243 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
244 else
245 tmp_inode->i_data.a_ops = &cifs_addr_ops;
246
223 if(isNewInode) 247 if(isNewInode)
224 return; /* No sense invalidating pages for new inode 248 return; /* No sense invalidating pages for new inode
225 since have not started caching readahead file 249 since have not started caching readahead file
@@ -338,11 +362,12 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
338 else 362 else
339 tmp_inode->i_fop = &cifs_file_ops; 363 tmp_inode->i_fop = &cifs_file_ops;
340 364
341 tmp_inode->i_data.a_ops = &cifs_addr_ops;
342 if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && 365 if((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
343 (cifs_sb->tcon->ses->server->maxBuf < 366 (cifs_sb->tcon->ses->server->maxBuf <
344 4096 + MAX_CIFS_HDR_SIZE)) 367 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
345 tmp_inode->i_data.a_ops->readpages = NULL; 368 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
369 else
370 tmp_inode->i_data.a_ops = &cifs_addr_ops;
346 371
347 if(isNewInode) 372 if(isNewInode)
348 return; /* No sense invalidating pages for new inode since we 373 return; /* No sense invalidating pages for new inode since we
@@ -415,7 +440,10 @@ static int initiate_cifs_search(const int xid, struct file *file)
415ffirst_retry: 440ffirst_retry:
416 /* test for Unix extensions */ 441 /* test for Unix extensions */
417 if (pTcon->ses->capabilities & CAP_UNIX) { 442 if (pTcon->ses->capabilities & CAP_UNIX) {
418 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; 443 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
444 } else if ((pTcon->ses->capabilities &
445 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) {
446 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD;
419 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 447 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
420 cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; 448 cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO;
421 } else /* not srvinos - BB fixme add check for backlevel? */ { 449 } else /* not srvinos - BB fixme add check for backlevel? */ {
@@ -451,12 +479,19 @@ static int cifs_unicode_bytelen(char *str)
451 return len << 1; 479 return len << 1;
452} 480}
453 481
454static char *nxt_dir_entry(char *old_entry, char *end_of_smb) 482static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
455{ 483{
456 char * new_entry; 484 char * new_entry;
457 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; 485 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
458 486
459 new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); 487 if(level == SMB_FIND_FILE_INFO_STANDARD) {
488 FIND_FILE_STANDARD_INFO * pfData;
489 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo;
490
491 new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) +
492 pfData->FileNameLength;
493 } else
494 new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
460 cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); 495 cFYI(1,("new entry %p old entry %p",new_entry,old_entry));
461 /* validate that new_entry is not past end of SMB */ 496 /* validate that new_entry is not past end of SMB */
462 if(new_entry >= end_of_smb) { 497 if(new_entry >= end_of_smb) {
@@ -464,7 +499,10 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb)
464 ("search entry %p began after end of SMB %p old entry %p", 499 ("search entry %p began after end of SMB %p old entry %p",
465 new_entry, end_of_smb, old_entry)); 500 new_entry, end_of_smb, old_entry));
466 return NULL; 501 return NULL;
467 } else if (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb) { 502 } else if(((level == SMB_FIND_FILE_INFO_STANDARD) &&
503 (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) ||
504 ((level != SMB_FIND_FILE_INFO_STANDARD) &&
505 (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) {
468 cERROR(1,("search entry %p extends after end of SMB %p", 506 cERROR(1,("search entry %p extends after end of SMB %p",
469 new_entry, end_of_smb)); 507 new_entry, end_of_smb));
470 return NULL; 508 return NULL;
@@ -482,7 +520,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
482 char * filename = NULL; 520 char * filename = NULL;
483 int len = 0; 521 int len = 0;
484 522
485 if(cfile->srch_inf.info_level == 0x202) { 523 if(cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
486 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 524 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
487 filename = &pFindData->FileName[0]; 525 filename = &pFindData->FileName[0];
488 if(cfile->srch_inf.unicode) { 526 if(cfile->srch_inf.unicode) {
@@ -491,26 +529,34 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
491 /* BB should we make this strnlen of PATH_MAX? */ 529 /* BB should we make this strnlen of PATH_MAX? */
492 len = strnlen(filename, 5); 530 len = strnlen(filename, 5);
493 } 531 }
494 } else if(cfile->srch_inf.info_level == 0x101) { 532 } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) {
495 FILE_DIRECTORY_INFO * pFindData = 533 FILE_DIRECTORY_INFO * pFindData =
496 (FILE_DIRECTORY_INFO *)current_entry; 534 (FILE_DIRECTORY_INFO *)current_entry;
497 filename = &pFindData->FileName[0]; 535 filename = &pFindData->FileName[0];
498 len = le32_to_cpu(pFindData->FileNameLength); 536 len = le32_to_cpu(pFindData->FileNameLength);
499 } else if(cfile->srch_inf.info_level == 0x102) { 537 } else if(cfile->srch_inf.info_level ==
538 SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
500 FILE_FULL_DIRECTORY_INFO * pFindData = 539 FILE_FULL_DIRECTORY_INFO * pFindData =
501 (FILE_FULL_DIRECTORY_INFO *)current_entry; 540 (FILE_FULL_DIRECTORY_INFO *)current_entry;
502 filename = &pFindData->FileName[0]; 541 filename = &pFindData->FileName[0];
503 len = le32_to_cpu(pFindData->FileNameLength); 542 len = le32_to_cpu(pFindData->FileNameLength);
504 } else if(cfile->srch_inf.info_level == 0x105) { 543 } else if(cfile->srch_inf.info_level ==
544 SMB_FIND_FILE_ID_FULL_DIR_INFO) {
505 SEARCH_ID_FULL_DIR_INFO * pFindData = 545 SEARCH_ID_FULL_DIR_INFO * pFindData =
506 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 546 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
507 filename = &pFindData->FileName[0]; 547 filename = &pFindData->FileName[0];
508 len = le32_to_cpu(pFindData->FileNameLength); 548 len = le32_to_cpu(pFindData->FileNameLength);
509 } else if(cfile->srch_inf.info_level == 0x104) { 549 } else if(cfile->srch_inf.info_level ==
550 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
510 FILE_BOTH_DIRECTORY_INFO * pFindData = 551 FILE_BOTH_DIRECTORY_INFO * pFindData =
511 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 552 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
512 filename = &pFindData->FileName[0]; 553 filename = &pFindData->FileName[0];
513 len = le32_to_cpu(pFindData->FileNameLength); 554 len = le32_to_cpu(pFindData->FileNameLength);
555 } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) {
556 FIND_FILE_STANDARD_INFO * pFindData =
557 (FIND_FILE_STANDARD_INFO *)current_entry;
558 filename = &pFindData->FileName[0];
559 len = le32_to_cpu(pFindData->FileNameLength);
514 } else { 560 } else {
515 cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); 561 cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level));
516 } 562 }
@@ -597,7 +643,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
597 . and .. for the root of a drive and for those we need 643 . and .. for the root of a drive and for those we need
598 to start two entries earlier */ 644 to start two entries earlier */
599 645
600/* dump_cifs_file_struct(file, "In fce ");*/ 646#ifdef CONFIG_CIFS_DEBUG2
647 dump_cifs_file_struct(file, "In fce ");
648#endif
601 if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && 649 if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
602 is_dir_changed(file)) || 650 is_dir_changed(file)) ||
603 (index_to_find < first_entry_in_buffer)) { 651 (index_to_find < first_entry_in_buffer)) {
@@ -644,10 +692,12 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
644 first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry 692 first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry
645 - cifsFile->srch_inf.entries_in_buffer; 693 - cifsFile->srch_inf.entries_in_buffer;
646 pos_in_buf = index_to_find - first_entry_in_buffer; 694 pos_in_buf = index_to_find - first_entry_in_buffer;
647 cFYI(1,("found entry - pos_in_buf %d",pos_in_buf)); 695 cFYI(1,("found entry - pos_in_buf %d",pos_in_buf));
696
648 for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) { 697 for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) {
649 /* go entry by entry figuring out which is first */ 698 /* go entry by entry figuring out which is first */
650 current_entry = nxt_dir_entry(current_entry,end_of_smb); 699 current_entry = nxt_dir_entry(current_entry,end_of_smb,
700 cifsFile->srch_inf.info_level);
651 } 701 }
652 if((current_entry == NULL) && (i < pos_in_buf)) { 702 if((current_entry == NULL) && (i < pos_in_buf)) {
653 /* BB fixme - check if we should flag this error */ 703 /* BB fixme - check if we should flag this error */
@@ -674,7 +724,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
674/* inode num, inode type and filename returned */ 724/* inode num, inode type and filename returned */
675static int cifs_get_name_from_search_buf(struct qstr *pqst, 725static int cifs_get_name_from_search_buf(struct qstr *pqst,
676 char *current_entry, __u16 level, unsigned int unicode, 726 char *current_entry, __u16 level, unsigned int unicode,
677 struct cifs_sb_info * cifs_sb, ino_t *pinum) 727 struct cifs_sb_info * cifs_sb, int max_len, ino_t *pinum)
678{ 728{
679 int rc = 0; 729 int rc = 0;
680 unsigned int len = 0; 730 unsigned int len = 0;
@@ -718,10 +768,22 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
718 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 768 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
719 filename = &pFindData->FileName[0]; 769 filename = &pFindData->FileName[0];
720 len = le32_to_cpu(pFindData->FileNameLength); 770 len = le32_to_cpu(pFindData->FileNameLength);
771 } else if(level == SMB_FIND_FILE_INFO_STANDARD) {
772 FIND_FILE_STANDARD_INFO * pFindData =
773 (FIND_FILE_STANDARD_INFO *)current_entry;
774 filename = &pFindData->FileName[0];
775 /* one byte length, no name conversion */
776 len = (unsigned int)pFindData->FileNameLength;
721 } else { 777 } else {
722 cFYI(1,("Unknown findfirst level %d",level)); 778 cFYI(1,("Unknown findfirst level %d",level));
723 return -EINVAL; 779 return -EINVAL;
724 } 780 }
781
782 if(len > max_len) {
783 cERROR(1,("bad search response length %d past smb end", len));
784 return -EINVAL;
785 }
786
725 if(unicode) { 787 if(unicode) {
726 /* BB fixme - test with long names */ 788 /* BB fixme - test with long names */
727 /* Note converted filename can be longer than in unicode */ 789 /* Note converted filename can be longer than in unicode */
@@ -741,7 +803,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
741} 803}
742 804
743static int cifs_filldir(char *pfindEntry, struct file *file, 805static int cifs_filldir(char *pfindEntry, struct file *file,
744 filldir_t filldir, void *direntry, char *scratch_buf) 806 filldir_t filldir, void *direntry, char *scratch_buf, int max_len)
745{ 807{
746 int rc = 0; 808 int rc = 0;
747 struct qstr qstring; 809 struct qstr qstring;
@@ -777,6 +839,7 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
777 rc = cifs_get_name_from_search_buf(&qstring,pfindEntry, 839 rc = cifs_get_name_from_search_buf(&qstring,pfindEntry,
778 pCifsF->srch_inf.info_level, 840 pCifsF->srch_inf.info_level,
779 pCifsF->srch_inf.unicode,cifs_sb, 841 pCifsF->srch_inf.unicode,cifs_sb,
842 max_len,
780 &inum /* returned */); 843 &inum /* returned */);
781 844
782 if(rc) 845 if(rc)
@@ -798,13 +861,16 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
798 /* we pass in rc below, indicating whether it is a new inode, 861 /* we pass in rc below, indicating whether it is a new inode,
799 so we can figure out whether to invalidate the inode cached 862 so we can figure out whether to invalidate the inode cached
800 data if the file has changed */ 863 data if the file has changed */
801 if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) { 864 if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX)
802 unix_fill_in_inode(tmp_inode, 865 unix_fill_in_inode(tmp_inode,
803 (FILE_UNIX_INFO *)pfindEntry,&obj_type, rc); 866 (FILE_UNIX_INFO *)pfindEntry,
804 } else { 867 &obj_type, rc);
805 fill_in_inode(tmp_inode, 868 else if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
806 (FILE_DIRECTORY_INFO *)pfindEntry,&obj_type, rc); 869 fill_in_inode(tmp_inode, 0 /* old level 1 buffer type */,
807 } 870 pfindEntry, &obj_type, rc);
871 else
872 fill_in_inode(tmp_inode, 1 /* NT */, pfindEntry, &obj_type, rc);
873
808 874
809 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos, 875 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,
810 tmp_inode->i_ino,obj_type); 876 tmp_inode->i_ino,obj_type);
@@ -864,6 +930,12 @@ static int cifs_save_resume_key(const char *current_entry,
864 filename = &pFindData->FileName[0]; 930 filename = &pFindData->FileName[0];
865 len = le32_to_cpu(pFindData->FileNameLength); 931 len = le32_to_cpu(pFindData->FileNameLength);
866 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 932 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
933 } else if(level == SMB_FIND_FILE_INFO_STANDARD) {
934 FIND_FILE_STANDARD_INFO * pFindData =
935 (FIND_FILE_STANDARD_INFO *)current_entry;
936 filename = &pFindData->FileName[0];
937 /* one byte length, no name conversion */
938 len = (unsigned int)pFindData->FileNameLength;
867 } else { 939 } else {
868 cFYI(1,("Unknown findfirst level %d",level)); 940 cFYI(1,("Unknown findfirst level %d",level));
869 return -EINVAL; 941 return -EINVAL;
@@ -884,6 +956,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
884 int num_to_fill = 0; 956 int num_to_fill = 0;
885 char * tmp_buf = NULL; 957 char * tmp_buf = NULL;
886 char * end_of_smb; 958 char * end_of_smb;
959 int max_len;
887 960
888 xid = GetXid(); 961 xid = GetXid();
889 962
@@ -909,7 +982,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
909 case 1: 982 case 1:
910 if (filldir(direntry, "..", 2, file->f_pos, 983 if (filldir(direntry, "..", 2, file->f_pos,
911 file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { 984 file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
912 cERROR(1, ("Filldir for parent dir failed ")); 985 cERROR(1, ("Filldir for parent dir failed"));
913 rc = -ENOMEM; 986 rc = -ENOMEM;
914 break; 987 break;
915 } 988 }
@@ -959,10 +1032,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
959 goto rddir2_exit; 1032 goto rddir2_exit;
960 } 1033 }
961 cFYI(1,("loop through %d times filling dir for net buf %p", 1034 cFYI(1,("loop through %d times filling dir for net buf %p",
962 num_to_fill,cifsFile->srch_inf.ntwrk_buf_start)); 1035 num_to_fill,cifsFile->srch_inf.ntwrk_buf_start));
963 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + 1036 max_len = smbCalcSize((struct smb_hdr *)
964 smbCalcSize((struct smb_hdr *) 1037 cifsFile->srch_inf.ntwrk_buf_start);
965 cifsFile->srch_inf.ntwrk_buf_start); 1038 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
1039
966 /* To be safe - for UCS to UTF-8 with strings loaded 1040 /* To be safe - for UCS to UTF-8 with strings loaded
967 with the rare long characters alloc more to account for 1041 with the rare long characters alloc more to account for
968 such multibyte target UTF-8 characters. cifs_unicode.c, 1042 such multibyte target UTF-8 characters. cifs_unicode.c,
@@ -977,17 +1051,19 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
977 } 1051 }
978 /* if buggy server returns . and .. late do 1052 /* if buggy server returns . and .. late do
979 we want to check for that here? */ 1053 we want to check for that here? */
980 rc = cifs_filldir(current_entry, file, 1054 rc = cifs_filldir(current_entry, file,
981 filldir, direntry,tmp_buf); 1055 filldir, direntry, tmp_buf, max_len);
982 file->f_pos++; 1056 file->f_pos++;
983 if(file->f_pos == cifsFile->srch_inf.index_of_last_entry) { 1057 if(file->f_pos ==
1058 cifsFile->srch_inf.index_of_last_entry) {
984 cFYI(1,("last entry in buf at pos %lld %s", 1059 cFYI(1,("last entry in buf at pos %lld %s",
985 file->f_pos,tmp_buf)); /* BB removeme BB */ 1060 file->f_pos,tmp_buf));
986 cifs_save_resume_key(current_entry,cifsFile); 1061 cifs_save_resume_key(current_entry,cifsFile);
987 break; 1062 break;
988 } else 1063 } else
989 current_entry = nxt_dir_entry(current_entry, 1064 current_entry =
990 end_of_smb); 1065 nxt_dir_entry(current_entry, end_of_smb,
1066 cifsFile->srch_inf.info_level);
991 } 1067 }
992 kfree(tmp_buf); 1068 kfree(tmp_buf);
993 break; 1069 break;
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
new file mode 100644
index 000000000000..7202d534ef0b
--- /dev/null
+++ b/fs/cifs/sess.c
@@ -0,0 +1,538 @@
1/*
2 * fs/cifs/sess.c
3 *
4 * SMB/CIFS session setup handling routines
5 *
6 * Copyright (c) International Business Machines Corp., 2006
7 * Author(s): Steve French (sfrench@us.ibm.com)
8 *
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include "cifspdu.h"
25#include "cifsglob.h"
26#include "cifsproto.h"
27#include "cifs_unicode.h"
28#include "cifs_debug.h"
29#include "ntlmssp.h"
30#include "nterr.h"
31#include <linux/utsname.h>
32
33extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
34 unsigned char *p24);
35
36static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
37{
38 __u32 capabilities = 0;
39
40 /* init fields common to all four types of SessSetup */
41 /* note that header is initialized to zero in header_assemble */
42 pSMB->req.AndXCommand = 0xFF;
43 pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
44 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
45
46 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
47
48 /* BB verify whether signing required on neg or just on auth frame
49 (and NTLM case) */
50
51 capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
52 CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
53
54 if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
55 pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
56
57 if (ses->capabilities & CAP_UNICODE) {
58 pSMB->req.hdr.Flags2 |= SMBFLG2_UNICODE;
59 capabilities |= CAP_UNICODE;
60 }
61 if (ses->capabilities & CAP_STATUS32) {
62 pSMB->req.hdr.Flags2 |= SMBFLG2_ERR_STATUS;
63 capabilities |= CAP_STATUS32;
64 }
65 if (ses->capabilities & CAP_DFS) {
66 pSMB->req.hdr.Flags2 |= SMBFLG2_DFS;
67 capabilities |= CAP_DFS;
68 }
69 if (ses->capabilities & CAP_UNIX) {
70 capabilities |= CAP_UNIX;
71 }
72
73 /* BB check whether to init vcnum BB */
74 return capabilities;
75}
76
77static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
78 const struct nls_table * nls_cp)
79{
80 char * bcc_ptr = *pbcc_area;
81 int bytes_ret = 0;
82
83 /* BB FIXME add check that strings total less
84 than 335 or will need to send them as arrays */
85
86 /* unicode strings, must be word aligned before the call */
87/* if ((long) bcc_ptr % 2) {
88 *bcc_ptr = 0;
89 bcc_ptr++;
90 } */
91 /* copy user */
92 if(ses->userName == NULL) {
93 /* BB what about null user mounts - check that we do this BB */
94 } else { /* 300 should be long enough for any conceivable user name */
95 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->userName,
96 300, nls_cp);
97 }
98 bcc_ptr += 2 * bytes_ret;
99 bcc_ptr += 2; /* account for null termination */
100 /* copy domain */
101 if(ses->domainName == NULL)
102 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr,
103 "CIFS_LINUX_DOM", 32, nls_cp);
104 else
105 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->domainName,
106 256, nls_cp);
107 bcc_ptr += 2 * bytes_ret;
108 bcc_ptr += 2; /* account for null terminator */
109
110 /* Copy OS version */
111 bytes_ret = cifs_strtoUCS((__le16 *)bcc_ptr, "Linux version ", 32,
112 nls_cp);
113 bcc_ptr += 2 * bytes_ret;
114 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release,
115 32, nls_cp);
116 bcc_ptr += 2 * bytes_ret;
117 bcc_ptr += 2; /* trailing null */
118
119 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
120 32, nls_cp);
121 bcc_ptr += 2 * bytes_ret;
122 bcc_ptr += 2; /* trailing null */
123
124 *pbcc_area = bcc_ptr;
125}
126
127static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
128 const struct nls_table * nls_cp)
129{
130 char * bcc_ptr = *pbcc_area;
131
132 /* copy user */
133 /* BB what about null user mounts - check that we do this BB */
134 /* copy user */
135 if(ses->userName == NULL) {
136 /* BB what about null user mounts - check that we do this BB */
137 } else { /* 300 should be long enough for any conceivable user name */
138 strncpy(bcc_ptr, ses->userName, 300);
139 }
140 /* BB improve check for overflow */
141 bcc_ptr += strnlen(ses->userName, 300);
142 *bcc_ptr = 0;
143 bcc_ptr++; /* account for null termination */
144
145 /* copy domain */
146
147 if(ses->domainName == NULL) {
148 strcpy(bcc_ptr, "CIFS_LINUX_DOM");
149 bcc_ptr += 14; /* strlen(CIFS_LINUX_DOM) */
150 } else {
151 strncpy(bcc_ptr, ses->domainName, 256);
152 bcc_ptr += strnlen(ses->domainName, 256);
153 }
154 *bcc_ptr = 0;
155 bcc_ptr++;
156
157 /* BB check for overflow here */
158
159 strcpy(bcc_ptr, "Linux version ");
160 bcc_ptr += strlen("Linux version ");
161 strcpy(bcc_ptr, system_utsname.release);
162 bcc_ptr += strlen(system_utsname.release) + 1;
163
164 strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
165 bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
166
167 *pbcc_area = bcc_ptr;
168}
169
170static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses,
171 const struct nls_table * nls_cp)
172{
173 int rc = 0;
174 int words_left, len;
175 char * data = *pbcc_area;
176
177
178
179 cFYI(1,("bleft %d",bleft));
180
181
182 /* word align, if bytes remaining is not even */
183 if(bleft % 2) {
184 bleft--;
185 data++;
186 }
187 words_left = bleft / 2;
188
189 /* save off server operating system */
190 len = UniStrnlen((wchar_t *) data, words_left);
191
192/* We look for obvious messed up bcc or strings in response so we do not go off
193 the end since (at least) WIN2K and Windows XP have a major bug in not null
194 terminating last Unicode string in response */
195 if(len >= words_left)
196 return rc;
197
198 if(ses->serverOS)
199 kfree(ses->serverOS);
200 /* UTF-8 string will not grow more than four times as big as UCS-16 */
201 ses->serverOS = kzalloc(4 * len, GFP_KERNEL);
202 if(ses->serverOS != NULL) {
203 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len,
204 nls_cp);
205 }
206 data += 2 * (len + 1);
207 words_left -= len + 1;
208
209 /* save off server network operating system */
210 len = UniStrnlen((wchar_t *) data, words_left);
211
212 if(len >= words_left)
213 return rc;
214
215 if(ses->serverNOS)
216 kfree(ses->serverNOS);
217 ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */
218 if(ses->serverNOS != NULL) {
219 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len,
220 nls_cp);
221 if(strncmp(ses->serverNOS, "NT LAN Manager 4",16) == 0) {
222 cFYI(1,("NT4 server"));
223 ses->flags |= CIFS_SES_NT4;
224 }
225 }
226 data += 2 * (len + 1);
227 words_left -= len + 1;
228
229 /* save off server domain */
230 len = UniStrnlen((wchar_t *) data, words_left);
231
232 if(len > words_left)
233 return rc;
234
235 if(ses->serverDomain)
236 kfree(ses->serverDomain);
237 ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */
238 if(ses->serverDomain != NULL) {
239 cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len,
240 nls_cp);
241 ses->serverDomain[2*len] = 0;
242 ses->serverDomain[(2*len) + 1] = 0;
243 }
244 data += 2 * (len + 1);
245 words_left -= len + 1;
246
247 cFYI(1,("words left: %d",words_left));
248
249 return rc;
250}
251
252static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses,
253 const struct nls_table * nls_cp)
254{
255 int rc = 0;
256 int len;
257 char * bcc_ptr = *pbcc_area;
258
259 cFYI(1,("decode sessetup ascii. bleft %d", bleft));
260
261 len = strnlen(bcc_ptr, bleft);
262 if(len >= bleft)
263 return rc;
264
265 if(ses->serverOS)
266 kfree(ses->serverOS);
267
268 ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
269 if(ses->serverOS)
270 strncpy(ses->serverOS, bcc_ptr, len);
271
272 bcc_ptr += len + 1;
273 bleft -= len + 1;
274
275 len = strnlen(bcc_ptr, bleft);
276 if(len >= bleft)
277 return rc;
278
279 if(ses->serverNOS)
280 kfree(ses->serverNOS);
281
282 ses->serverNOS = kzalloc(len + 1, GFP_KERNEL);
283 if(ses->serverNOS)
284 strncpy(ses->serverNOS, bcc_ptr, len);
285
286 bcc_ptr += len + 1;
287 bleft -= len + 1;
288
289 len = strnlen(bcc_ptr, bleft);
290 if(len > bleft)
291 return rc;
292
293 if(ses->serverDomain)
294 kfree(ses->serverDomain);
295
296 ses->serverDomain = kzalloc(len + 1, GFP_KERNEL);
297 if(ses->serverOS)
298 strncpy(ses->serverOS, bcc_ptr, len);
299
300 bcc_ptr += len + 1;
301 bleft -= len + 1;
302
303 cFYI(1,("ascii: bytes left %d",bleft));
304
305 return rc;
306}
307
308int
309CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
310 const struct nls_table *nls_cp)
311{
312 int rc = 0;
313 int wct;
314 struct smb_hdr *smb_buf;
315 char *bcc_ptr;
316 char *str_area;
317 SESSION_SETUP_ANDX *pSMB;
318 __u32 capabilities;
319 int count;
320 int resp_buf_type = 0;
321 struct kvec iov[2];
322 enum securityEnum type;
323 __u16 action;
324 int bytes_remaining;
325
326 if(ses == NULL)
327 return -EINVAL;
328
329 type = ses->server->secType;
330
331 cFYI(1,("sess setup type %d",type));
332 if(type == LANMAN) {
333#ifndef CONFIG_CIFS_WEAK_PW_HASH
334 /* LANMAN and plaintext are less secure and off by default.
335 So we make this explicitly be turned on in kconfig (in the
336 build) and turned on at runtime (changed from the default)
337 in proc/fs/cifs or via mount parm. Unfortunately this is
338 needed for old Win (e.g. Win95), some obscure NAS and OS/2 */
339 return -EOPNOTSUPP;
340#endif
341 wct = 10; /* lanman 2 style sessionsetup */
342 } else if((type == NTLM) || (type == NTLMv2)) {
343 /* For NTLMv2 failures eventually may need to retry NTLM */
344 wct = 13; /* old style NTLM sessionsetup */
345 } else /* same size for negotiate or auth, NTLMSSP or extended security */
346 wct = 12;
347
348 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses,
349 (void **)&smb_buf);
350 if(rc)
351 return rc;
352
353 pSMB = (SESSION_SETUP_ANDX *)smb_buf;
354
355 capabilities = cifs_ssetup_hdr(ses, pSMB);
356
357 /* we will send the SMB in two pieces,
358 a fixed length beginning part, and a
359 second part which will include the strings
360 and rest of bcc area, in order to avoid having
361 to do a large buffer 17K allocation */
362 iov[0].iov_base = (char *)pSMB;
363 iov[0].iov_len = smb_buf->smb_buf_length + 4;
364
365 /* 2000 big enough to fit max user, domain, NOS name etc. */
366 str_area = kmalloc(2000, GFP_KERNEL);
367 bcc_ptr = str_area;
368
369 if(type == LANMAN) {
370#ifdef CONFIG_CIFS_WEAK_PW_HASH
371 char lnm_session_key[CIFS_SESS_KEY_SIZE];
372
373 /* no capabilities flags in old lanman negotiation */
374
375 pSMB->old_req.PasswordLength = CIFS_SESS_KEY_SIZE;
376 /* BB calculate hash with password */
377 /* and copy into bcc */
378
379 calc_lanman_hash(ses, lnm_session_key);
380
381/* #ifdef CONFIG_CIFS_DEBUG2
382 cifs_dump_mem("cryptkey: ",ses->server->cryptKey,
383 CIFS_SESS_KEY_SIZE);
384#endif */
385 memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
386 bcc_ptr += CIFS_SESS_KEY_SIZE;
387
388 /* can not sign if LANMAN negotiated so no need
389 to calculate signing key? but what if server
390 changed to do higher than lanman dialect and
391 we reconnected would we ever calc signing_key? */
392
393 cFYI(1,("Negotiating LANMAN setting up strings"));
394 /* Unicode not allowed for LANMAN dialects */
395 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
396#endif
397 } else if (type == NTLM) {
398 char ntlm_session_key[CIFS_SESS_KEY_SIZE];
399
400 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
401 pSMB->req_no_secext.CaseInsensitivePasswordLength =
402 cpu_to_le16(CIFS_SESS_KEY_SIZE);
403 pSMB->req_no_secext.CaseSensitivePasswordLength =
404 cpu_to_le16(CIFS_SESS_KEY_SIZE);
405
406 /* calculate session key */
407 SMBNTencrypt(ses->password, ses->server->cryptKey,
408 ntlm_session_key);
409
410 if(first_time) /* should this be moved into common code
411 with similar ntlmv2 path? */
412 cifs_calculate_mac_key(ses->server->mac_signing_key,
413 ntlm_session_key, ses->password);
414 /* copy session key */
415
416 memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE);
417 bcc_ptr += CIFS_SESS_KEY_SIZE;
418 memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE);
419 bcc_ptr += CIFS_SESS_KEY_SIZE;
420 if(ses->capabilities & CAP_UNICODE) {
421 /* unicode strings must be word aligned */
422 if (iov[0].iov_len % 2) {
423 *bcc_ptr = 0;
424 bcc_ptr++;
425 }
426 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
427 } else
428 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
429 } else if (type == NTLMv2) {
430 char * v2_sess_key =
431 kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL);
432
433 /* BB FIXME change all users of v2_sess_key to
434 struct ntlmv2_resp */
435
436 if(v2_sess_key == NULL) {
437 cifs_small_buf_release(smb_buf);
438 return -ENOMEM;
439 }
440
441 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
442
443 /* LM2 password would be here if we supported it */
444 pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
445 /* cpu_to_le16(LM2_SESS_KEY_SIZE); */
446
447 pSMB->req_no_secext.CaseSensitivePasswordLength =
448 cpu_to_le16(sizeof(struct ntlmv2_resp));
449
450 /* calculate session key */
451 setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
452 if(first_time) /* should this be moved into common code
453 with similar ntlmv2 path? */
454 /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key,
455 response BB FIXME, v2_sess_key); */
456
457 /* copy session key */
458
459 /* memcpy(bcc_ptr, (char *)ntlm_session_key,LM2_SESS_KEY_SIZE);
460 bcc_ptr += LM2_SESS_KEY_SIZE; */
461 memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp));
462 bcc_ptr += sizeof(struct ntlmv2_resp);
463 kfree(v2_sess_key);
464 if(ses->capabilities & CAP_UNICODE) {
465 if(iov[0].iov_len % 2) {
466 *bcc_ptr = 0;
467 } bcc_ptr++;
468 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
469 } else
470 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
471 } else /* NTLMSSP or SPNEGO */ {
472 pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
473 capabilities |= CAP_EXTENDED_SECURITY;
474 pSMB->req.Capabilities = cpu_to_le32(capabilities);
475 /* BB set password lengths */
476 }
477
478 count = (long) bcc_ptr - (long) str_area;
479 smb_buf->smb_buf_length += count;
480
481 BCC_LE(smb_buf) = cpu_to_le16(count);
482
483 iov[1].iov_base = str_area;
484 iov[1].iov_len = count;
485 rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0);
486 /* SMB request buf freed in SendReceive2 */
487
488 cFYI(1,("ssetup rc from sendrecv2 is %d",rc));
489 if(rc)
490 goto ssetup_exit;
491
492 pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base;
493 smb_buf = (struct smb_hdr *)iov[0].iov_base;
494
495 if((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) {
496 rc = -EIO;
497 cERROR(1,("bad word count %d", smb_buf->WordCount));
498 goto ssetup_exit;
499 }
500 action = le16_to_cpu(pSMB->resp.Action);
501 if (action & GUEST_LOGIN)
502 cFYI(1, ("Guest login")); /* BB mark SesInfo struct? */
503 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
504 cFYI(1, ("UID = %d ", ses->Suid));
505 /* response can have either 3 or 4 word count - Samba sends 3 */
506 /* and lanman response is 3 */
507 bytes_remaining = BCC(smb_buf);
508 bcc_ptr = pByteArea(smb_buf);
509
510 if(smb_buf->WordCount == 4) {
511 __u16 blob_len;
512 blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
513 bcc_ptr += blob_len;
514 if(blob_len > bytes_remaining) {
515 cERROR(1,("bad security blob length %d", blob_len));
516 rc = -EINVAL;
517 goto ssetup_exit;
518 }
519 bytes_remaining -= blob_len;
520 }
521
522 /* BB check if Unicode and decode strings */
523 if(smb_buf->Flags2 & SMBFLG2_UNICODE)
524 rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining,
525 ses, nls_cp);
526 else
527 rc = decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,nls_cp);
528
529ssetup_exit:
530 kfree(str_area);
531 if(resp_buf_type == CIFS_SMALL_BUFFER) {
532 cFYI(1,("ssetup freeing small buf %p", iov[0].iov_base));
533 cifs_small_buf_release(iov[0].iov_base);
534 } else if(resp_buf_type == CIFS_LARGE_BUFFER)
535 cifs_buf_release(iov[0].iov_base);
536
537 return rc;
538}
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index 6103bcdfb16d..f518c5e45035 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -30,6 +30,7 @@
30#include <linux/random.h> 30#include <linux/random.h>
31#include "cifs_unicode.h" 31#include "cifs_unicode.h"
32#include "cifspdu.h" 32#include "cifspdu.h"
33#include "cifsglob.h"
33#include "md5.h" 34#include "md5.h"
34#include "cifs_debug.h" 35#include "cifs_debug.h"
35#include "cifsencrypt.h" 36#include "cifsencrypt.h"
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 3da80409466c..17ba329e2b3d 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -654,8 +654,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
654 654
655 if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { 655 if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
656 up(&ses->server->tcpSem); 656 up(&ses->server->tcpSem);
657 cERROR(1, 657 cERROR(1, ("Illegal length, greater than maximum frame, %d",
658 ("Illegal length, greater than maximum frame, %d ",
659 in_buf->smb_buf_length)); 658 in_buf->smb_buf_length));
660 DeleteMidQEntry(midQ); 659 DeleteMidQEntry(midQ);
661 /* If not lock req, update # of requests on wire to server */ 660 /* If not lock req, update # of requests on wire to server */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 7caee8d8ea3b..803aacf0d49c 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -28,7 +28,6 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/devfs_fs_kernel.h>
32#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
33#include <linux/fs.h> 32#include <linux/fs.h>
34#include <linux/file.h> 33#include <linux/file.h>
@@ -365,22 +364,12 @@ static int init_coda_psdev(void)
365 err = PTR_ERR(coda_psdev_class); 364 err = PTR_ERR(coda_psdev_class);
366 goto out_chrdev; 365 goto out_chrdev;
367 } 366 }
368 devfs_mk_dir ("coda"); 367 for (i = 0; i < MAX_CODADEVS; i++)
369 for (i = 0; i < MAX_CODADEVS; i++) {
370 class_device_create(coda_psdev_class, NULL, 368 class_device_create(coda_psdev_class, NULL,
371 MKDEV(CODA_PSDEV_MAJOR,i), NULL, "cfs%d", i); 369 MKDEV(CODA_PSDEV_MAJOR,i), NULL, "cfs%d", i);
372 err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
373 S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
374 if (err)
375 goto out_class;
376 }
377 coda_sysctl_init(); 370 coda_sysctl_init();
378 goto out; 371 goto out;
379 372
380out_class:
381 for (i = 0; i < MAX_CODADEVS; i++)
382 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
383 class_destroy(coda_psdev_class);
384out_chrdev: 373out_chrdev:
385 unregister_chrdev(CODA_PSDEV_MAJOR, "coda"); 374 unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
386out: 375out:
@@ -419,12 +408,9 @@ static int __init init_coda(void)
419 } 408 }
420 return 0; 409 return 0;
421out: 410out:
422 for (i = 0; i < MAX_CODADEVS; i++) { 411 for (i = 0; i < MAX_CODADEVS; i++)
423 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i)); 412 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
424 devfs_remove("coda/%d", i);
425 }
426 class_destroy(coda_psdev_class); 413 class_destroy(coda_psdev_class);
427 devfs_remove("coda");
428 unregister_chrdev(CODA_PSDEV_MAJOR, "coda"); 414 unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
429 coda_sysctl_clean(); 415 coda_sysctl_clean();
430out1: 416out1:
@@ -441,12 +427,9 @@ static void __exit exit_coda(void)
441 if ( err != 0 ) { 427 if ( err != 0 ) {
442 printk("coda: failed to unregister filesystem\n"); 428 printk("coda: failed to unregister filesystem\n");
443 } 429 }
444 for (i = 0; i < MAX_CODADEVS; i++) { 430 for (i = 0; i < MAX_CODADEVS; i++)
445 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i)); 431 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
446 devfs_remove("coda/%d", i);
447 }
448 class_destroy(coda_psdev_class); 432 class_destroy(coda_psdev_class);
449 devfs_remove("coda");
450 unregister_chrdev(CODA_PSDEV_MAJOR, "coda"); 433 unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
451 coda_sysctl_clean(); 434 coda_sysctl_clean();
452 coda_destroy_inodecache(); 435 coda_destroy_inodecache();
diff --git a/fs/coda/symlink.c b/fs/coda/symlink.c
index b35e5bbd9c99..76e00a65a75b 100644
--- a/fs/coda/symlink.c
+++ b/fs/coda/symlink.c
@@ -50,6 +50,6 @@ fail:
50 return error; 50 return error;
51} 51}
52 52
53struct address_space_operations coda_symlink_aops = { 53const struct address_space_operations coda_symlink_aops = {
54 .readpage = coda_symlink_filler, 54 .readpage = coda_symlink_filler,
55}; 55};
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index d8ecfedef189..d8d50a70c58d 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -44,7 +44,6 @@
44#include <linux/loop.h> 44#include <linux/loop.h>
45#include <linux/auto_fs.h> 45#include <linux/auto_fs.h>
46#include <linux/auto_fs4.h> 46#include <linux/auto_fs4.h>
47#include <linux/devfs_fs.h>
48#include <linux/tty.h> 47#include <linux/tty.h>
49#include <linux/vt_kern.h> 48#include <linux/vt_kern.h>
50#include <linux/fb.h> 49#include <linux/fb.h>
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index c153bd9534cb..e14488ca6411 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -38,7 +38,7 @@
38 38
39extern struct super_block * configfs_sb; 39extern struct super_block * configfs_sb;
40 40
41static struct address_space_operations configfs_aops = { 41static const struct address_space_operations configfs_aops = {
42 .readpage = simple_readpage, 42 .readpage = simple_readpage,
43 .prepare_write = simple_prepare_write, 43 .prepare_write = simple_prepare_write,
44 .commit_write = simple_commit_write 44 .commit_write = simple_commit_write
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index c45d73860803..223c0431042d 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -30,7 +30,7 @@
30static struct super_operations cramfs_ops; 30static struct super_operations cramfs_ops;
31static struct inode_operations cramfs_dir_inode_operations; 31static struct inode_operations cramfs_dir_inode_operations;
32static const struct file_operations cramfs_directory_operations; 32static const struct file_operations cramfs_directory_operations;
33static struct address_space_operations cramfs_aops; 33static const struct address_space_operations cramfs_aops;
34 34
35static DEFINE_MUTEX(read_mutex); 35static DEFINE_MUTEX(read_mutex);
36 36
@@ -501,7 +501,7 @@ static int cramfs_readpage(struct file *file, struct page * page)
501 return 0; 501 return 0;
502} 502}
503 503
504static struct address_space_operations cramfs_aops = { 504static const struct address_space_operations cramfs_aops = {
505 .readpage = cramfs_readpage 505 .readpage = cramfs_readpage
506}; 506};
507 507
diff --git a/fs/devfs/Makefile b/fs/devfs/Makefile
deleted file mode 100644
index 6dd8d1245e2c..000000000000
--- a/fs/devfs/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for the linux devfs-filesystem routines.
3#
4
5obj-$(CONFIG_DEVFS_FS) += devfs.o
6
7devfs-objs := base.o util.o
8
diff --git a/fs/devfs/base.c b/fs/devfs/base.c
deleted file mode 100644
index 51a97f132745..000000000000
--- a/fs/devfs/base.c
+++ /dev/null
@@ -1,2836 +0,0 @@
1/* devfs (Device FileSystem) driver.
2
3 Copyright (C) 1998-2002 Richard Gooch
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 Richard Gooch may be reached by email at rgooch@atnf.csiro.au
20 The postal address is:
21 Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
22
23 ChangeLog
24
25 19980110 Richard Gooch <rgooch@atnf.csiro.au>
26 Original version.
27 v0.1
28 19980111 Richard Gooch <rgooch@atnf.csiro.au>
29 Created per-fs inode table rather than using inode->u.generic_ip
30 v0.2
31 19980111 Richard Gooch <rgooch@atnf.csiro.au>
32 Created .epoch inode which has a ctime of 0.
33 Fixed loss of named pipes when dentries lost.
34 Fixed loss of inode data when devfs_register() follows mknod().
35 v0.3
36 19980111 Richard Gooch <rgooch@atnf.csiro.au>
37 Fix for when compiling with CONFIG_KERNELD.
38 19980112 Richard Gooch <rgooch@atnf.csiro.au>
39 Fix for readdir() which sometimes didn't show entries.
40 Added <<tolerant>> option to <devfs_register>.
41 v0.4
42 19980113 Richard Gooch <rgooch@atnf.csiro.au>
43 Created <devfs_fill_file> function.
44 v0.5
45 19980115 Richard Gooch <rgooch@atnf.csiro.au>
46 Added subdirectory support. Major restructuring.
47 19980116 Richard Gooch <rgooch@atnf.csiro.au>
48 Fixed <find_by_dev> to not search major=0,minor=0.
49 Added symlink support.
50 v0.6
51 19980120 Richard Gooch <rgooch@atnf.csiro.au>
52 Created <devfs_mk_dir> function and support directory unregister
53 19980120 Richard Gooch <rgooch@atnf.csiro.au>
54 Auto-ownership uses real uid/gid rather than effective uid/gid.
55 v0.7
56 19980121 Richard Gooch <rgooch@atnf.csiro.au>
57 Supported creation of sockets.
58 v0.8
59 19980122 Richard Gooch <rgooch@atnf.csiro.au>
60 Added DEVFS_FL_HIDE_UNREG flag.
61 Interface change to <devfs_mk_symlink>.
62 Created <devfs_symlink> to support symlink(2).
63 v0.9
64 19980123 Richard Gooch <rgooch@atnf.csiro.au>
65 Added check to <devfs_fill_file> to check inode is in devfs.
66 Added optional traversal of symlinks.
67 v0.10
68 19980124 Richard Gooch <rgooch@atnf.csiro.au>
69 Created <devfs_get_flags> and <devfs_set_flags>.
70 v0.11
71 19980125 C. Scott Ananian <cananian@alumni.princeton.edu>
72 Created <devfs_find_handle>.
73 19980125 Richard Gooch <rgooch@atnf.csiro.au>
74 Allow removal of symlinks.
75 v0.12
76 19980125 Richard Gooch <rgooch@atnf.csiro.au>
77 Created <devfs_set_symlink_destination>.
78 19980126 Richard Gooch <rgooch@atnf.csiro.au>
79 Moved DEVFS_SUPER_MAGIC into header file.
80 Added DEVFS_FL_HIDE flag.
81 Created <devfs_get_maj_min>.
82 Created <devfs_get_handle_from_inode>.
83 Fixed minor bug in <find_by_dev>.
84 19980127 Richard Gooch <rgooch@atnf.csiro.au>
85 Changed interface to <find_by_dev>, <find_entry>,
86 <devfs_unregister>, <devfs_fill_file> and <devfs_find_handle>.
87 Fixed inode times when symlink created with symlink(2).
88 v0.13
89 19980129 C. Scott Ananian <cananian@alumni.princeton.edu>
90 Exported <devfs_set_symlink_destination>, <devfs_get_maj_min>
91 and <devfs_get_handle_from_inode>.
92 19980129 Richard Gooch <rgooch@atnf.csiro.au>
93 Created <devfs_unlink> to support unlink(2).
94 v0.14
95 19980129 Richard Gooch <rgooch@atnf.csiro.au>
96 Fixed kerneld support for entries in devfs subdirectories.
97 19980130 Richard Gooch <rgooch@atnf.csiro.au>
98 Bugfixes in <call_kerneld>.
99 v0.15
100 19980207 Richard Gooch <rgooch@atnf.csiro.au>
101 Call kerneld when looking up unregistered entries.
102 v0.16
103 19980326 Richard Gooch <rgooch@atnf.csiro.au>
104 Modified interface to <devfs_find_handle> for symlink traversal.
105 v0.17
106 19980331 Richard Gooch <rgooch@atnf.csiro.au>
107 Fixed persistence bug with device numbers for manually created
108 device files.
109 Fixed problem with recreating symlinks with different content.
110 v0.18
111 19980401 Richard Gooch <rgooch@atnf.csiro.au>
112 Changed to CONFIG_KMOD.
113 Hide entries which are manually unlinked.
114 Always invalidate devfs dentry cache when registering entries.
115 Created <devfs_rmdir> to support rmdir(2).
116 Ensure directories created by <devfs_mk_dir> are visible.
117 v0.19
118 19980402 Richard Gooch <rgooch@atnf.csiro.au>
119 Invalidate devfs dentry cache when making directories.
120 Invalidate devfs dentry cache when removing entries.
121 Fixed persistence bug with fifos.
122 v0.20
123 19980421 Richard Gooch <rgooch@atnf.csiro.au>
124 Print process command when debugging kerneld/kmod.
125 Added debugging for register/unregister/change operations.
126 19980422 Richard Gooch <rgooch@atnf.csiro.au>
127 Added "devfs=" boot options.
128 v0.21
129 19980426 Richard Gooch <rgooch@atnf.csiro.au>
130 No longer lock/unlock superblock in <devfs_put_super>.
131 Drop negative dentries when they are released.
132 Manage dcache more efficiently.
133 v0.22
134 19980427 Richard Gooch <rgooch@atnf.csiro.au>
135 Added DEVFS_FL_AUTO_DEVNUM flag.
136 v0.23
137 19980430 Richard Gooch <rgooch@atnf.csiro.au>
138 No longer set unnecessary methods.
139 v0.24
140 19980504 Richard Gooch <rgooch@atnf.csiro.au>
141 Added PID display to <call_kerneld> debugging message.
142 Added "after" debugging message to <call_kerneld>.
143 19980519 Richard Gooch <rgooch@atnf.csiro.au>
144 Added "diread" and "diwrite" boot options.
145 19980520 Richard Gooch <rgooch@atnf.csiro.au>
146 Fixed persistence problem with permissions.
147 v0.25
148 19980602 Richard Gooch <rgooch@atnf.csiro.au>
149 Support legacy device nodes.
150 Fixed bug where recreated inodes were hidden.
151 v0.26
152 19980602 Richard Gooch <rgooch@atnf.csiro.au>
153 Improved debugging in <get_vfs_inode>.
154 19980607 Richard Gooch <rgooch@atnf.csiro.au>
155 No longer free old dentries in <devfs_mk_dir>.
156 Free all dentries for a given entry when deleting inodes.
157 v0.27
158 19980627 Richard Gooch <rgooch@atnf.csiro.au>
159 Limit auto-device numbering to majors 128 to 239.
160 v0.28
161 19980629 Richard Gooch <rgooch@atnf.csiro.au>
162 Fixed inode times persistence problem.
163 v0.29
164 19980704 Richard Gooch <rgooch@atnf.csiro.au>
165 Fixed spelling in <devfs_readlink> debug.
166 Fixed bug in <devfs_setup> parsing "dilookup".
167 v0.30
168 19980705 Richard Gooch <rgooch@atnf.csiro.au>
169 Fixed devfs inode leak when manually recreating inodes.
170 Fixed permission persistence problem when recreating inodes.
171 v0.31
172 19980727 Richard Gooch <rgooch@atnf.csiro.au>
173 Removed harmless "unused variable" compiler warning.
174 Fixed modes for manually recreated device nodes.
175 v0.32
176 19980728 Richard Gooch <rgooch@atnf.csiro.au>
177 Added NULL devfs inode warning in <devfs_read_inode>.
178 Force all inode nlink values to 1.
179 v0.33
180 19980730 Richard Gooch <rgooch@atnf.csiro.au>
181 Added "dimknod" boot option.
182 Set inode nlink to 0 when freeing dentries.
183 Fixed modes for manually recreated symlinks.
184 v0.34
185 19980802 Richard Gooch <rgooch@atnf.csiro.au>
186 Fixed bugs in recreated directories and symlinks.
187 v0.35
188 19980806 Richard Gooch <rgooch@atnf.csiro.au>
189 Fixed bugs in recreated device nodes.
190 19980807 Richard Gooch <rgooch@atnf.csiro.au>
191 Fixed bug in currently unused <devfs_get_handle_from_inode>.
192 Defined new <devfs_handle_t> type.
193 Improved debugging when getting entries.
194 Fixed bug where directories could be emptied.
195 v0.36
196 19980809 Richard Gooch <rgooch@atnf.csiro.au>
197 Replaced dummy .epoch inode with .devfsd character device.
198 19980810 Richard Gooch <rgooch@atnf.csiro.au>
199 Implemented devfsd protocol revision 0.
200 v0.37
201 19980819 Richard Gooch <rgooch@atnf.csiro.au>
202 Added soothing message to warning in <devfs_d_iput>.
203 v0.38
204 19980829 Richard Gooch <rgooch@atnf.csiro.au>
205 Use GCC extensions for structure initialisations.
206 Implemented async open notification.
207 Incremented devfsd protocol revision to 1.
208 v0.39
209 19980908 Richard Gooch <rgooch@atnf.csiro.au>
210 Moved async open notification to end of <devfs_open>.
211 v0.40
212 19980910 Richard Gooch <rgooch@atnf.csiro.au>
213 Prepended "/dev/" to module load request.
214 Renamed <call_kerneld> to <call_kmod>.
215 v0.41
216 19980910 Richard Gooch <rgooch@atnf.csiro.au>
217 Fixed typo "AYSNC" -> "ASYNC".
218 v0.42
219 19980910 Richard Gooch <rgooch@atnf.csiro.au>
220 Added open flag for files.
221 v0.43
222 19980927 Richard Gooch <rgooch@atnf.csiro.au>
223 Set i_blocks=0 and i_blksize=1024 in <devfs_read_inode>.
224 v0.44
225 19981005 Richard Gooch <rgooch@atnf.csiro.au>
226 Added test for empty <<name>> in <devfs_find_handle>.
227 Renamed <generate_path> to <devfs_generate_path> and published.
228 v0.45
229 19981006 Richard Gooch <rgooch@atnf.csiro.au>
230 Created <devfs_get_fops>.
231 v0.46
232 19981007 Richard Gooch <rgooch@atnf.csiro.au>
233 Limit auto-device numbering to majors 144 to 239.
234 v0.47
235 19981010 Richard Gooch <rgooch@atnf.csiro.au>
236 Updated <devfs_follow_link> for VFS change in 2.1.125.
237 v0.48
238 19981022 Richard Gooch <rgooch@atnf.csiro.au>
239 Created DEVFS_ FL_COMPAT flag.
240 v0.49
241 19981023 Richard Gooch <rgooch@atnf.csiro.au>
242 Created "nocompat" boot option.
243 v0.50
244 19981025 Richard Gooch <rgooch@atnf.csiro.au>
245 Replaced "mount" boot option with "nomount".
246 v0.51
247 19981110 Richard Gooch <rgooch@atnf.csiro.au>
248 Created "only" boot option.
249 v0.52
250 19981112 Richard Gooch <rgooch@atnf.csiro.au>
251 Added DEVFS_FL_REMOVABLE flag.
252 v0.53
253 19981114 Richard Gooch <rgooch@atnf.csiro.au>
254 Only call <scan_dir_for_removable> on first call to
255 <devfs_readdir>.
256 v0.54
257 19981205 Richard Gooch <rgooch@atnf.csiro.au>
258 Updated <devfs_rmdir> for VFS change in 2.1.131.
259 v0.55
260 19981218 Richard Gooch <rgooch@atnf.csiro.au>
261 Created <devfs_mk_compat>.
262 19981220 Richard Gooch <rgooch@atnf.csiro.au>
263 Check for partitions on removable media in <devfs_lookup>.
264 v0.56
265 19990118 Richard Gooch <rgooch@atnf.csiro.au>
266 Added support for registering regular files.
267 Created <devfs_set_file_size>.
268 Update devfs inodes from entries if not changed through FS.
269 v0.57
270 19990124 Richard Gooch <rgooch@atnf.csiro.au>
271 Fixed <devfs_fill_file> to only initialise temporary inodes.
272 Trap for NULL fops in <devfs_register>.
273 Return -ENODEV in <devfs_fill_file> for non-driver inodes.
274 v0.58
275 19990126 Richard Gooch <rgooch@atnf.csiro.au>
276 Switched from PATH_MAX to DEVFS_PATHLEN.
277 v0.59
278 19990127 Richard Gooch <rgooch@atnf.csiro.au>
279 Created "nottycompat" boot option.
280 v0.60
281 19990318 Richard Gooch <rgooch@atnf.csiro.au>
282 Fixed <devfsd_read> to not overrun event buffer.
283 v0.61
284 19990329 Richard Gooch <rgooch@atnf.csiro.au>
285 Created <devfs_auto_unregister>.
286 v0.62
287 19990330 Richard Gooch <rgooch@atnf.csiro.au>
288 Don't return unregistred entries in <devfs_find_handle>.
289 Panic in <devfs_unregister> if entry unregistered.
290 19990401 Richard Gooch <rgooch@atnf.csiro.au>
291 Don't panic in <devfs_auto_unregister> for duplicates.
292 v0.63
293 19990402 Richard Gooch <rgooch@atnf.csiro.au>
294 Don't unregister already unregistered entries in <unregister>.
295 v0.64
296 19990510 Richard Gooch <rgooch@atnf.csiro.au>
297 Disable warning messages when unable to read partition table for
298 removable media.
299 v0.65
300 19990512 Richard Gooch <rgooch@atnf.csiro.au>
301 Updated <devfs_lookup> for VFS change in 2.3.1-pre1.
302 Created "oops-on-panic" boot option.
303 Improved debugging in <devfs_register> and <devfs_unregister>.
304 v0.66
305 19990519 Richard Gooch <rgooch@atnf.csiro.au>
306 Added documentation for some functions.
307 19990525 Richard Gooch <rgooch@atnf.csiro.au>
308 Removed "oops-on-panic" boot option: now always Oops.
309 v0.67
310 19990531 Richard Gooch <rgooch@atnf.csiro.au>
311 Improved debugging in <devfs_register>.
312 v0.68
313 19990604 Richard Gooch <rgooch@atnf.csiro.au>
314 Added "diunlink" and "nokmod" boot options.
315 Removed superfluous warning message in <devfs_d_iput>.
316 v0.69
317 19990611 Richard Gooch <rgooch@atnf.csiro.au>
318 Took account of change to <d_alloc_root>.
319 v0.70
320 19990614 Richard Gooch <rgooch@atnf.csiro.au>
321 Created separate event queue for each mounted devfs.
322 Removed <devfs_invalidate_dcache>.
323 Created new ioctl()s.
324 Incremented devfsd protocol revision to 3.
325 Fixed bug when re-creating directories: contents were lost.
326 Block access to inodes until devfsd updates permissions.
327 19990615 Richard Gooch <rgooch@atnf.csiro.au>
328 Support 2.2.x kernels.
329 v0.71
330 19990623 Richard Gooch <rgooch@atnf.csiro.au>
331 Switched to sending process uid/gid to devfsd.
332 Renamed <call_kmod> to <try_modload>.
333 Added DEVFSD_NOTIFY_LOOKUP event.
334 19990624 Richard Gooch <rgooch@atnf.csiro.au>
335 Added DEVFSD_NOTIFY_CHANGE event.
336 Incremented devfsd protocol revision to 4.
337 v0.72
338 19990713 Richard Gooch <rgooch@atnf.csiro.au>
339 Return EISDIR rather than EINVAL for read(2) on directories.
340 v0.73
341 19990809 Richard Gooch <rgooch@atnf.csiro.au>
342 Changed <devfs_setup> to new __init scheme.
343 v0.74
344 19990901 Richard Gooch <rgooch@atnf.csiro.au>
345 Changed remaining function declarations to new __init scheme.
346 v0.75
347 19991013 Richard Gooch <rgooch@atnf.csiro.au>
348 Created <devfs_get_info>, <devfs_set_info>,
349 <devfs_get_first_child> and <devfs_get_next_sibling>.
350 Added <<dir>> parameter to <devfs_register>, <devfs_mk_compat>,
351 <devfs_mk_dir> and <devfs_find_handle>.
352 Work sponsored by SGI.
353 v0.76
354 19991017 Richard Gooch <rgooch@atnf.csiro.au>
355 Allow multiple unregistrations.
356 Work sponsored by SGI.
357 v0.77
358 19991026 Richard Gooch <rgooch@atnf.csiro.au>
359 Added major and minor number to devfsd protocol.
360 Incremented devfsd protocol revision to 5.
361 Work sponsored by SGI.
362 v0.78
363 19991030 Richard Gooch <rgooch@atnf.csiro.au>
364 Support info pointer for all devfs entry types.
365 Added <<info>> parameter to <devfs_mk_dir> and
366 <devfs_mk_symlink>.
367 Work sponsored by SGI.
368 v0.79
369 19991031 Richard Gooch <rgooch@atnf.csiro.au>
370 Support "../" when searching devfs namespace.
371 Work sponsored by SGI.
372 v0.80
373 19991101 Richard Gooch <rgooch@atnf.csiro.au>
374 Created <devfs_get_unregister_slave>.
375 Work sponsored by SGI.
376 v0.81
377 19991103 Richard Gooch <rgooch@atnf.csiro.au>
378 Exported <devfs_get_parent>.
379 Work sponsored by SGI.
380 v0.82
381 19991104 Richard Gooch <rgooch@atnf.csiro.au>
382 Removed unused <devfs_set_symlink_destination>.
383 19991105 Richard Gooch <rgooch@atnf.csiro.au>
384 Do not hide entries from devfsd or children.
385 Removed DEVFS_ FL_TTY_COMPAT flag.
386 Removed "nottycompat" boot option.
387 Removed <devfs_mk_compat>.
388 Work sponsored by SGI.
389 v0.83
390 19991107 Richard Gooch <rgooch@atnf.csiro.au>
391 Added DEVFS_FL_WAIT flag.
392 Work sponsored by SGI.
393 v0.84
394 19991107 Richard Gooch <rgooch@atnf.csiro.au>
395 Support new "disc" naming scheme in <get_removable_partition>.
396 Allow NULL fops in <devfs_register>.
397 Work sponsored by SGI.
398 v0.85
399 19991110 Richard Gooch <rgooch@atnf.csiro.au>
400 Fall back to major table if NULL fops given to <devfs_register>.
401 Work sponsored by SGI.
402 v0.86
403 19991204 Richard Gooch <rgooch@atnf.csiro.au>
404 Support fifos when unregistering.
405 Work sponsored by SGI.
406 v0.87
407 19991209 Richard Gooch <rgooch@atnf.csiro.au>
408 Removed obsolete DEVFS_ FL_COMPAT and DEVFS_ FL_TOLERANT flags.
409 Work sponsored by SGI.
410 v0.88
411 19991214 Richard Gooch <rgooch@atnf.csiro.au>
412 Removed kmod support.
413 Work sponsored by SGI.
414 v0.89
415 19991216 Richard Gooch <rgooch@atnf.csiro.au>
416 Improved debugging in <get_vfs_inode>.
417 Ensure dentries created by devfsd will be cleaned up.
418 Work sponsored by SGI.
419 v0.90
420 19991223 Richard Gooch <rgooch@atnf.csiro.au>
421 Created <devfs_get_name>.
422 Work sponsored by SGI.
423 v0.91
424 20000203 Richard Gooch <rgooch@atnf.csiro.au>
425 Ported to kernel 2.3.42.
426 Removed <devfs_fill_file>.
427 Work sponsored by SGI.
428 v0.92
429 20000306 Richard Gooch <rgooch@atnf.csiro.au>
430 Added DEVFS_ FL_NO_PERSISTENCE flag.
431 Removed unnecessary call to <update_devfs_inode_from_entry> in
432 <devfs_readdir>.
433 Work sponsored by SGI.
434 v0.93
435 20000413 Richard Gooch <rgooch@atnf.csiro.au>
436 Set inode->i_size to correct size for symlinks.
437 20000414 Richard Gooch <rgooch@atnf.csiro.au>
438 Only give lookup() method to directories to comply with new VFS
439 assumptions.
440 Work sponsored by SGI.
441 20000415 Richard Gooch <rgooch@atnf.csiro.au>
442 Remove unnecessary tests in symlink methods.
443 Don't kill existing block ops in <devfs_read_inode>.
444 Work sponsored by SGI.
445 v0.94
446 20000424 Richard Gooch <rgooch@atnf.csiro.au>
447 Don't create missing directories in <devfs_find_handle>.
448 Work sponsored by SGI.
449 v0.95
450 20000430 Richard Gooch <rgooch@atnf.csiro.au>
451 Added CONFIG_DEVFS_MOUNT.
452 Work sponsored by SGI.
453 v0.96
454 20000608 Richard Gooch <rgooch@atnf.csiro.au>
455 Disabled multi-mount capability (use VFS bindings instead).
456 Work sponsored by SGI.
457 v0.97
458 20000610 Richard Gooch <rgooch@atnf.csiro.au>
459 Switched to FS_SINGLE to disable multi-mounts.
460 20000612 Richard Gooch <rgooch@atnf.csiro.au>
461 Removed module support.
462 Removed multi-mount code.
463 Removed compatibility macros: VFS has changed too much.
464 Work sponsored by SGI.
465 v0.98
466 20000614 Richard Gooch <rgooch@atnf.csiro.au>
467 Merged devfs inode into devfs entry.
468 Work sponsored by SGI.
469 v0.99
470 20000619 Richard Gooch <rgooch@atnf.csiro.au>
471 Removed dead code in <devfs_register> which used to call
472 <free_dentries>.
473 Work sponsored by SGI.
474 v0.100
475 20000621 Richard Gooch <rgooch@atnf.csiro.au>
476 Changed interface to <devfs_register>.
477 Work sponsored by SGI.
478 v0.101
479 20000622 Richard Gooch <rgooch@atnf.csiro.au>
480 Simplified interface to <devfs_mk_symlink> and <devfs_mk_dir>.
481 Simplified interface to <devfs_find_handle>.
482 Work sponsored by SGI.
483 v0.102
484 20010519 Richard Gooch <rgooch@atnf.csiro.au>
485 Ensure <devfs_generate_path> terminates string for root entry.
486 Exported <devfs_get_name> to modules.
487 20010520 Richard Gooch <rgooch@atnf.csiro.au>
488 Make <devfs_mk_symlink> send events to devfsd.
489 Cleaned up option processing in <devfs_setup>.
490 20010521 Richard Gooch <rgooch@atnf.csiro.au>
491 Fixed bugs in handling symlinks: could leak or cause Oops.
492 20010522 Richard Gooch <rgooch@atnf.csiro.au>
493 Cleaned up directory handling by separating fops.
494 v0.103
495 20010601 Richard Gooch <rgooch@atnf.csiro.au>
496 Fixed handling of inverted options in <devfs_setup>.
497 v0.104
498 20010604 Richard Gooch <rgooch@atnf.csiro.au>
499 Adjusted <try_modload> to account for <devfs_generate_path> fix.
500 v0.105
501 20010617 Richard Gooch <rgooch@atnf.csiro.au>
502 Answered question posed by Al Viro and removed his comments.
503 Moved setting of registered flag after other fields are changed.
504 Fixed race between <devfsd_close> and <devfsd_notify_one>.
505 Global VFS changes added bogus BKL to <devfsd_close>: removed.
506 Widened locking in <devfs_readlink> and <devfs_follow_link>.
507 Replaced <devfsd_read> stack usage with <devfsd_ioctl> kmalloc.
508 Simplified locking in <devfsd_ioctl> and fixed memory leak.
509 v0.106
510 20010709 Richard Gooch <rgooch@atnf.csiro.au>
511 Removed broken devnum allocation and use <devfs_alloc_devnum>.
512 Fixed old devnum leak by calling new <devfs_dealloc_devnum>.
513 v0.107
514 20010712 Richard Gooch <rgooch@atnf.csiro.au>
515 Fixed bug in <devfs_setup> which could hang boot process.
516 v0.108
517 20010730 Richard Gooch <rgooch@atnf.csiro.au>
518 Added DEVFSD_NOTIFY_DELETE event.
519 20010801 Richard Gooch <rgooch@atnf.csiro.au>
520 Removed #include <asm/segment.h>.
521 v0.109
522 20010807 Richard Gooch <rgooch@atnf.csiro.au>
523 Fixed inode table races by removing it and using
524 inode->u.generic_ip instead.
525 Moved <devfs_read_inode> into <get_vfs_inode>.
526 Moved <devfs_write_inode> into <devfs_notify_change>.
527 v0.110
528 20010808 Richard Gooch <rgooch@atnf.csiro.au>
529 Fixed race in <devfs_do_symlink> for uni-processor.
530 v0.111
531 20010818 Richard Gooch <rgooch@atnf.csiro.au>
532 Removed remnant of multi-mount support in <devfs_mknod>.
533 Removed unused DEVFS_FL_SHOW_UNREG flag.
534 v0.112
535 20010820 Richard Gooch <rgooch@atnf.csiro.au>
536 Removed nlink field from struct devfs_inode.
537 v0.113
538 20010823 Richard Gooch <rgooch@atnf.csiro.au>
539 Replaced BKL with global rwsem to protect symlink data (quick
540 and dirty hack).
541 v0.114
542 20010827 Richard Gooch <rgooch@atnf.csiro.au>
543 Replaced global rwsem for symlink with per-link refcount.
544 v0.115
545 20010919 Richard Gooch <rgooch@atnf.csiro.au>
546 Set inode->i_mapping->a_ops for block nodes in <get_vfs_inode>.
547 v0.116
548 20011008 Richard Gooch <rgooch@atnf.csiro.au>
549 Fixed overrun in <devfs_link> by removing function (not needed).
550 20011009 Richard Gooch <rgooch@atnf.csiro.au>
551 Fixed buffer underrun in <try_modload>.
552 20011029 Richard Gooch <rgooch@atnf.csiro.au>
553 Fixed race in <devfsd_ioctl> when setting event mask.
554 20011114 Richard Gooch <rgooch@atnf.csiro.au>
555 First release of new locking code.
556 v1.0
557 20011117 Richard Gooch <rgooch@atnf.csiro.au>
558 Discard temporary buffer, now use "%s" for dentry names.
559 20011118 Richard Gooch <rgooch@atnf.csiro.au>
560 Don't generate path in <try_modload>: use fake entry instead.
561 Use "existing" directory in <_devfs_make_parent_for_leaf>.
562 20011122 Richard Gooch <rgooch@atnf.csiro.au>
563 Use slab cache rather than fixed buffer for devfsd events.
564 v1.1
565 20011125 Richard Gooch <rgooch@atnf.csiro.au>
566 Send DEVFSD_NOTIFY_REGISTERED events in <devfs_mk_dir>.
567 20011127 Richard Gooch <rgooch@atnf.csiro.au>
568 Fixed locking bug in <devfs_d_revalidate_wait> due to typo.
569 Do not send CREATE, CHANGE, ASYNC_OPEN or DELETE events from
570 devfsd or children.
571 v1.2
572 20011202 Richard Gooch <rgooch@atnf.csiro.au>
573 Fixed bug in <devfsd_read>: was dereferencing freed pointer.
574 v1.3
575 20011203 Richard Gooch <rgooch@atnf.csiro.au>
576 Fixed bug in <devfsd_close>: was dereferencing freed pointer.
577 Added process group check for devfsd privileges.
578 v1.4
579 20011204 Richard Gooch <rgooch@atnf.csiro.au>
580 Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete>.
581 v1.5
582 20011211 Richard Gooch <rgooch@atnf.csiro.au>
583 Return old entry in <devfs_mk_dir> for 2.4.x kernels.
584 20011212 Richard Gooch <rgooch@atnf.csiro.au>
585 Increment refcount on module in <check_disc_changed>.
586 20011215 Richard Gooch <rgooch@atnf.csiro.au>
587 Created <devfs_get_handle> and exported <devfs_put>.
588 Increment refcount on module in <devfs_get_ops>.
589 Created <devfs_put_ops>.
590 v1.6
591 20011216 Richard Gooch <rgooch@atnf.csiro.au>
592 Added poisoning to <devfs_put>.
593 Improved debugging messages.
594 v1.7
595 20011221 Richard Gooch <rgooch@atnf.csiro.au>
596 Corrected (made useful) debugging message in <unregister>.
597 Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs>
598 20011224 Richard Gooch <rgooch@atnf.csiro.au>
599 Added magic number to guard against scribbling drivers.
600 20011226 Richard Gooch <rgooch@atnf.csiro.au>
601 Only return old entry in <devfs_mk_dir> if a directory.
602 Defined macros for error and debug messages.
603 v1.8
604 20020113 Richard Gooch <rgooch@atnf.csiro.au>
605 Fixed (rare, old) race in <devfs_lookup>.
606 v1.9
607 20020120 Richard Gooch <rgooch@atnf.csiro.au>
608 Fixed deadlock bug in <devfs_d_revalidate_wait>.
609 Tag VFS deletable in <devfs_mk_symlink> if handle ignored.
610 v1.10
611 20020129 Richard Gooch <rgooch@atnf.csiro.au>
612 Added KERN_* to remaining messages.
613 Cleaned up declaration of <stat_read>.
614 v1.11
615 20020219 Richard Gooch <rgooch@atnf.csiro.au>
616 Changed <devfs_rmdir> to allow later additions if not yet empty.
617 v1.12
618 20020406 Richard Gooch <rgooch@atnf.csiro.au>
619 Removed silently introduced calls to lock_kernel() and
620 unlock_kernel() due to recent VFS locking changes. BKL isn't
621 required in devfs.
622 v1.13
623 20020428 Richard Gooch <rgooch@atnf.csiro.au>
624 Removed 2.4.x compatibility code.
625 v1.14
626 20020510 Richard Gooch <rgooch@atnf.csiro.au>
627 Added BKL to <devfs_open> because drivers still need it.
628 v1.15
629 20020512 Richard Gooch <rgooch@atnf.csiro.au>
630 Protected <scan_dir_for_removable> and <get_removable_partition>
631 from changing directory contents.
632 v1.16
633 20020514 Richard Gooch <rgooch@atnf.csiro.au>
634 Minor cleanup of <scan_dir_for_removable>.
635 v1.17
636 20020721 Richard Gooch <rgooch@atnf.csiro.au>
637 Switched to ISO C structure field initialisers.
638 Switch to set_current_state() and move before add_wait_queue().
639 20020722 Richard Gooch <rgooch@atnf.csiro.au>
640 Fixed devfs entry leak in <devfs_readdir> when *readdir fails.
641 v1.18
642 20020725 Richard Gooch <rgooch@atnf.csiro.au>
643 Created <devfs_find_and_unregister>.
644 v1.19
645 20020728 Richard Gooch <rgooch@atnf.csiro.au>
646 Removed deprecated <devfs_find_handle>.
647 v1.20
648 20020820 Richard Gooch <rgooch@atnf.csiro.au>
649 Fixed module unload race in <devfs_open>.
650 v1.21
651 20021013 Richard Gooch <rgooch@atnf.csiro.au>
652 Removed DEVFS_ FL_AUTO_OWNER.
653 Switched lingering structure field initialiser to ISO C.
654 Added locking when updating FCB flags.
655 v1.22
656*/
657#include <linux/types.h>
658#include <linux/errno.h>
659#include <linux/time.h>
660#include <linux/tty.h>
661#include <linux/timer.h>
662#include <linux/config.h>
663#include <linux/kernel.h>
664#include <linux/wait.h>
665#include <linux/string.h>
666#include <linux/slab.h>
667#include <linux/ioport.h>
668#include <linux/delay.h>
669#include <linux/ctype.h>
670#include <linux/mm.h>
671#include <linux/module.h>
672#include <linux/init.h>
673#include <linux/devfs_fs.h>
674#include <linux/devfs_fs_kernel.h>
675#include <linux/smp_lock.h>
676#include <linux/smp.h>
677#include <linux/rwsem.h>
678#include <linux/sched.h>
679#include <linux/namei.h>
680#include <linux/bitops.h>
681
682#include <asm/uaccess.h>
683#include <asm/io.h>
684#include <asm/processor.h>
685#include <asm/system.h>
686#include <asm/pgtable.h>
687#include <asm/atomic.h>
688
689#define DEVFS_VERSION "2004-01-31"
690
691#define DEVFS_NAME "devfs"
692
693#define FIRST_INODE 1
694
695#define STRING_LENGTH 256
696#define FAKE_BLOCK_SIZE 1024
697#define POISON_PTR ( *(void **) poison_array )
698#define MAGIC_VALUE 0x327db823
699
700#ifndef TRUE
701# define TRUE 1
702# define FALSE 0
703#endif
704
705#define MODE_DIR (S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO)
706
707#define DEBUG_NONE 0x0000000
708#define DEBUG_MODULE_LOAD 0x0000001
709#define DEBUG_REGISTER 0x0000002
710#define DEBUG_UNREGISTER 0x0000004
711#define DEBUG_FREE 0x0000008
712#define DEBUG_SET_FLAGS 0x0000010
713#define DEBUG_S_READ 0x0000100 /* Break */
714#define DEBUG_I_LOOKUP 0x0001000 /* Break */
715#define DEBUG_I_CREATE 0x0002000
716#define DEBUG_I_GET 0x0004000
717#define DEBUG_I_CHANGE 0x0008000
718#define DEBUG_I_UNLINK 0x0010000
719#define DEBUG_I_RLINK 0x0020000
720#define DEBUG_I_FLINK 0x0040000
721#define DEBUG_I_MKNOD 0x0080000
722#define DEBUG_F_READDIR 0x0100000 /* Break */
723#define DEBUG_D_DELETE 0x1000000 /* Break */
724#define DEBUG_D_RELEASE 0x2000000
725#define DEBUG_D_IPUT 0x4000000
726#define DEBUG_ALL 0xfffffff
727#define DEBUG_DISABLED DEBUG_NONE
728
729#define OPTION_NONE 0x00
730#define OPTION_MOUNT 0x01
731
732#define PRINTK(format, args...) \
733 {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
734
735#define OOPS(format, args...) \
736 {printk (KERN_CRIT "%s" format, __FUNCTION__ , ## args); \
737 printk ("Forcing Oops\n"); \
738 BUG();}
739
740#ifdef CONFIG_DEVFS_DEBUG
741# define VERIFY_ENTRY(de) \
742 {if ((de) && (de)->magic_number != MAGIC_VALUE) \
743 OOPS ("(%p): bad magic value: %x\n", (de), (de)->magic_number);}
744# define WRITE_ENTRY_MAGIC(de,magic) (de)->magic_number = (magic)
745# define DPRINTK(flag, format, args...) \
746 {if (devfs_debug & flag) \
747 printk (KERN_INFO "%s" format, __FUNCTION__ , ## args);}
748#else
749# define VERIFY_ENTRY(de)
750# define WRITE_ENTRY_MAGIC(de,magic)
751# define DPRINTK(flag, format, args...)
752#endif
753
754typedef struct devfs_entry *devfs_handle_t;
755
756struct directory_type {
757 rwlock_t lock; /* Lock for searching(R)/updating(W) */
758 struct devfs_entry *first;
759 struct devfs_entry *last;
760 unsigned char no_more_additions:1;
761};
762
763struct symlink_type {
764 unsigned int length; /* Not including the NULL-termimator */
765 char *linkname; /* This is NULL-terminated */
766};
767
768struct devfs_inode { /* This structure is for "persistent" inode storage */
769 struct dentry *dentry;
770 struct timespec atime;
771 struct timespec mtime;
772 struct timespec ctime;
773 unsigned int ino; /* Inode number as seen in the VFS */
774 uid_t uid;
775 gid_t gid;
776};
777
778struct devfs_entry {
779#ifdef CONFIG_DEVFS_DEBUG
780 unsigned int magic_number;
781#endif
782 void *info;
783 atomic_t refcount; /* When this drops to zero, it's unused */
784 union {
785 struct directory_type dir;
786 dev_t dev;
787 struct symlink_type symlink;
788 const char *name; /* Only used for (mode == 0) */
789 } u;
790 struct devfs_entry *prev; /* Previous entry in the parent directory */
791 struct devfs_entry *next; /* Next entry in the parent directory */
792 struct devfs_entry *parent; /* The parent directory */
793 struct devfs_inode inode;
794 umode_t mode;
795 unsigned short namelen; /* I think 64k+ filenames are a way off... */
796 unsigned char vfs:1; /* Whether the VFS may delete the entry */
797 char name[1]; /* This is just a dummy: the allocated array
798 is bigger. This is NULL-terminated */
799};
800
801/* The root of the device tree */
802static struct devfs_entry *root_entry;
803
804struct devfsd_buf_entry {
805 struct devfs_entry *de; /* The name is generated with this */
806 unsigned short type; /* The type of event */
807 umode_t mode;
808 uid_t uid;
809 gid_t gid;
810 struct devfsd_buf_entry *next;
811};
812
813struct fs_info { /* This structure is for the mounted devfs */
814 struct super_block *sb;
815 spinlock_t devfsd_buffer_lock; /* Lock when inserting/deleting events */
816 struct devfsd_buf_entry *devfsd_first_event;
817 struct devfsd_buf_entry *devfsd_last_event;
818 volatile int devfsd_sleeping;
819 volatile struct task_struct *devfsd_task;
820 volatile pid_t devfsd_pgrp;
821 volatile struct file *devfsd_file;
822 struct devfsd_notify_struct *devfsd_info;
823 volatile unsigned long devfsd_event_mask;
824 atomic_t devfsd_overrun_count;
825 wait_queue_head_t devfsd_wait_queue; /* Wake devfsd on input */
826 wait_queue_head_t revalidate_wait_queue; /* Wake when devfsd sleeps */
827};
828
829static struct fs_info fs_info = {.devfsd_buffer_lock = SPIN_LOCK_UNLOCKED };
830static kmem_cache_t *devfsd_buf_cache;
831#ifdef CONFIG_DEVFS_DEBUG
832static unsigned int devfs_debug_init __initdata = DEBUG_NONE;
833static unsigned int devfs_debug = DEBUG_NONE;
834static DEFINE_SPINLOCK(stat_lock);
835static unsigned int stat_num_entries;
836static unsigned int stat_num_bytes;
837#endif
838static unsigned char poison_array[8] =
839 { 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a };
840
841#ifdef CONFIG_DEVFS_MOUNT
842static unsigned int boot_options = OPTION_MOUNT;
843#else
844static unsigned int boot_options = OPTION_NONE;
845#endif
846
847/* Forward function declarations */
848static devfs_handle_t _devfs_walk_path(struct devfs_entry *dir,
849 const char *name, int namelen,
850 int traverse_symlink);
851static ssize_t devfsd_read(struct file *file, char __user *buf, size_t len,
852 loff_t * ppos);
853static int devfsd_ioctl(struct inode *inode, struct file *file,
854 unsigned int cmd, unsigned long arg);
855static int devfsd_close(struct inode *inode, struct file *file);
856#ifdef CONFIG_DEVFS_DEBUG
857static ssize_t stat_read(struct file *file, char __user *buf, size_t len,
858 loff_t * ppos);
859static const struct file_operations stat_fops = {
860 .open = nonseekable_open,
861 .read = stat_read,
862};
863#endif
864
865/* Devfs daemon file operations */
866static const struct file_operations devfsd_fops = {
867 .open = nonseekable_open,
868 .read = devfsd_read,
869 .ioctl = devfsd_ioctl,
870 .release = devfsd_close,
871};
872
873/* Support functions follow */
874
875/**
876 * devfs_get - Get a reference to a devfs entry.
877 * @de: The devfs entry.
878 */
879
880static struct devfs_entry *devfs_get(struct devfs_entry *de)
881{
882 VERIFY_ENTRY(de);
883 if (de)
884 atomic_inc(&de->refcount);
885 return de;
886} /* End Function devfs_get */
887
888/**
889 * devfs_put - Put (release) a reference to a devfs entry.
890 * @de: The handle to the devfs entry.
891 */
892
893static void devfs_put(devfs_handle_t de)
894{
895 if (!de)
896 return;
897 VERIFY_ENTRY(de);
898 if (de->info == POISON_PTR)
899 OOPS("(%p): poisoned pointer\n", de);
900 if (!atomic_dec_and_test(&de->refcount))
901 return;
902 if (de == root_entry)
903 OOPS("(%p): root entry being freed\n", de);
904 DPRINTK(DEBUG_FREE, "(%s): de: %p, parent: %p \"%s\"\n",
905 de->name, de, de->parent,
906 de->parent ? de->parent->name : "no parent");
907 if (S_ISLNK(de->mode))
908 kfree(de->u.symlink.linkname);
909 WRITE_ENTRY_MAGIC(de, 0);
910#ifdef CONFIG_DEVFS_DEBUG
911 spin_lock(&stat_lock);
912 --stat_num_entries;
913 stat_num_bytes -= sizeof *de + de->namelen;
914 if (S_ISLNK(de->mode))
915 stat_num_bytes -= de->u.symlink.length + 1;
916 spin_unlock(&stat_lock);
917#endif
918 de->info = POISON_PTR;
919 kfree(de);
920} /* End Function devfs_put */
921
922/**
923 * _devfs_search_dir - Search for a devfs entry in a directory.
924 * @dir: The directory to search.
925 * @name: The name of the entry to search for.
926 * @namelen: The number of characters in @name.
927 *
928 * Search for a devfs entry in a directory and returns a pointer to the entry
929 * on success, else %NULL. The directory must be locked already.
930 * An implicit devfs_get() is performed on the returned entry.
931 */
932
933static struct devfs_entry *_devfs_search_dir(struct devfs_entry *dir,
934 const char *name,
935 unsigned int namelen)
936{
937 struct devfs_entry *curr;
938
939 if (!S_ISDIR(dir->mode)) {
940 PRINTK("(%s): not a directory\n", dir->name);
941 return NULL;
942 }
943 for (curr = dir->u.dir.first; curr != NULL; curr = curr->next) {
944 if (curr->namelen != namelen)
945 continue;
946 if (memcmp(curr->name, name, namelen) == 0)
947 break;
948 /* Not found: try the next one */
949 }
950 return devfs_get(curr);
951} /* End Function _devfs_search_dir */
952
953/**
954 * _devfs_alloc_entry - Allocate a devfs entry.
955 * @name: the name of the entry
956 * @namelen: the number of characters in @name
957 * @mode: the mode for the entry
958 *
959 * Allocate a devfs entry and returns a pointer to the entry on success, else
960 * %NULL.
961 */
962
963static struct devfs_entry *_devfs_alloc_entry(const char *name,
964 unsigned int namelen,
965 umode_t mode)
966{
967 struct devfs_entry *new;
968 static unsigned long inode_counter = FIRST_INODE;
969 static DEFINE_SPINLOCK(counter_lock);
970
971 if (name && (namelen < 1))
972 namelen = strlen(name);
973 if ((new = kmalloc(sizeof *new + namelen, GFP_KERNEL)) == NULL)
974 return NULL;
975 memset(new, 0, sizeof *new + namelen); /* Will set '\0' on name */
976 new->mode = mode;
977 if (S_ISDIR(mode))
978 rwlock_init(&new->u.dir.lock);
979 atomic_set(&new->refcount, 1);
980 spin_lock(&counter_lock);
981 new->inode.ino = inode_counter++;
982 spin_unlock(&counter_lock);
983 if (name)
984 memcpy(new->name, name, namelen);
985 new->namelen = namelen;
986 WRITE_ENTRY_MAGIC(new, MAGIC_VALUE);
987#ifdef CONFIG_DEVFS_DEBUG
988 spin_lock(&stat_lock);
989 ++stat_num_entries;
990 stat_num_bytes += sizeof *new + namelen;
991 spin_unlock(&stat_lock);
992#endif
993 return new;
994} /* End Function _devfs_alloc_entry */
995
996/**
997 * _devfs_append_entry - Append a devfs entry to a directory's child list.
998 * @dir: The directory to add to.
999 * @de: The devfs entry to append.
1000 * @old_de: If an existing entry exists, it will be written here. This may
1001 * be %NULL. An implicit devfs_get() is performed on this entry.
1002 *
1003 * Append a devfs entry to a directory's list of children, checking first to
1004 * see if an entry of the same name exists. The directory will be locked.
1005 * The value 0 is returned on success, else a negative error code.
1006 * On failure, an implicit devfs_put() is performed on %de.
1007 */
1008
1009static int _devfs_append_entry(devfs_handle_t dir, devfs_handle_t de,
1010 devfs_handle_t * old_de)
1011{
1012 int retval;
1013
1014 if (old_de)
1015 *old_de = NULL;
1016 if (!S_ISDIR(dir->mode)) {
1017 PRINTK("(%s): dir: \"%s\" is not a directory\n", de->name,
1018 dir->name);
1019 devfs_put(de);
1020 return -ENOTDIR;
1021 }
1022 write_lock(&dir->u.dir.lock);
1023 if (dir->u.dir.no_more_additions)
1024 retval = -ENOENT;
1025 else {
1026 struct devfs_entry *old;
1027
1028 old = _devfs_search_dir(dir, de->name, de->namelen);
1029 if (old_de)
1030 *old_de = old;
1031 else
1032 devfs_put(old);
1033 if (old == NULL) {
1034 de->parent = dir;
1035 de->prev = dir->u.dir.last;
1036 /* Append to the directory's list of children */
1037 if (dir->u.dir.first == NULL)
1038 dir->u.dir.first = de;
1039 else
1040 dir->u.dir.last->next = de;
1041 dir->u.dir.last = de;
1042 retval = 0;
1043 } else
1044 retval = -EEXIST;
1045 }
1046 write_unlock(&dir->u.dir.lock);
1047 if (retval)
1048 devfs_put(de);
1049 return retval;
1050} /* End Function _devfs_append_entry */
1051
1052/**
1053 * _devfs_get_root_entry - Get the root devfs entry.
1054 *
1055 * Returns the root devfs entry on success, else %NULL.
1056 *
1057 * TODO it must be called asynchronously due to the fact
1058 * that devfs is initialized relatively late. Proper way
1059 * is to remove module_init from init_devfs_fs and manually
1060 * call it early enough during system init
1061 */
1062
1063static struct devfs_entry *_devfs_get_root_entry(void)
1064{
1065 struct devfs_entry *new;
1066 static DEFINE_SPINLOCK(root_lock);
1067
1068 if (root_entry)
1069 return root_entry;
1070
1071 new = _devfs_alloc_entry(NULL, 0, MODE_DIR);
1072 if (new == NULL)
1073 return NULL;
1074
1075 spin_lock(&root_lock);
1076 if (root_entry) {
1077 spin_unlock(&root_lock);
1078 devfs_put(new);
1079 return root_entry;
1080 }
1081 root_entry = new;
1082 spin_unlock(&root_lock);
1083
1084 return root_entry;
1085} /* End Function _devfs_get_root_entry */
1086
1087/**
1088 * _devfs_descend - Descend down a tree using the next component name.
1089 * @dir: The directory to search.
1090 * @name: The component name to search for.
1091 * @namelen: The length of %name.
1092 * @next_pos: The position of the next '/' or '\0' is written here.
1093 *
1094 * Descend into a directory, searching for a component. This function forms
1095 * the core of a tree-walking algorithm. The directory will be locked.
1096 * The devfs entry corresponding to the component is returned. If there is
1097 * no matching entry, %NULL is returned.
1098 * An implicit devfs_get() is performed on the returned entry.
1099 */
1100
1101static struct devfs_entry *_devfs_descend(struct devfs_entry *dir,
1102 const char *name, int namelen,
1103 int *next_pos)
1104{
1105 const char *stop, *ptr;
1106 struct devfs_entry *entry;
1107
1108 if ((namelen >= 3) && (strncmp(name, "../", 3) == 0)) { /* Special-case going to parent directory */
1109 *next_pos = 3;
1110 return devfs_get(dir->parent);
1111 }
1112 stop = name + namelen;
1113 /* Search for a possible '/' */
1114 for (ptr = name; (ptr < stop) && (*ptr != '/'); ++ptr) ;
1115 *next_pos = ptr - name;
1116 read_lock(&dir->u.dir.lock);
1117 entry = _devfs_search_dir(dir, name, *next_pos);
1118 read_unlock(&dir->u.dir.lock);
1119 return entry;
1120} /* End Function _devfs_descend */
1121
1122static devfs_handle_t _devfs_make_parent_for_leaf(struct devfs_entry *dir,
1123 const char *name,
1124 int namelen, int *leaf_pos)
1125{
1126 int next_pos = 0;
1127
1128 if (dir == NULL)
1129 dir = _devfs_get_root_entry();
1130 if (dir == NULL)
1131 return NULL;
1132 devfs_get(dir);
1133 /* Search for possible trailing component and ignore it */
1134 for (--namelen; (namelen > 0) && (name[namelen] != '/'); --namelen) ;
1135 *leaf_pos = (name[namelen] == '/') ? (namelen + 1) : 0;
1136 for (; namelen > 0; name += next_pos, namelen -= next_pos) {
1137 struct devfs_entry *de, *old = NULL;
1138
1139 if ((de =
1140 _devfs_descend(dir, name, namelen, &next_pos)) == NULL) {
1141 de = _devfs_alloc_entry(name, next_pos, MODE_DIR);
1142 devfs_get(de);
1143 if (!de || _devfs_append_entry(dir, de, &old)) {
1144 devfs_put(de);
1145 if (!old || !S_ISDIR(old->mode)) {
1146 devfs_put(old);
1147 devfs_put(dir);
1148 return NULL;
1149 }
1150 de = old; /* Use the existing directory */
1151 }
1152 }
1153 if (de == dir->parent) {
1154 devfs_put(dir);
1155 devfs_put(de);
1156 return NULL;
1157 }
1158 devfs_put(dir);
1159 dir = de;
1160 if (name[next_pos] == '/')
1161 ++next_pos;
1162 }
1163 return dir;
1164} /* End Function _devfs_make_parent_for_leaf */
1165
1166static devfs_handle_t _devfs_prepare_leaf(devfs_handle_t * dir,
1167 const char *name, umode_t mode)
1168{
1169 int namelen, leaf_pos;
1170 struct devfs_entry *de;
1171
1172 namelen = strlen(name);
1173 if ((*dir = _devfs_make_parent_for_leaf(*dir, name, namelen,
1174 &leaf_pos)) == NULL) {
1175 PRINTK("(%s): could not create parent path\n", name);
1176 return NULL;
1177 }
1178 if ((de = _devfs_alloc_entry(name + leaf_pos, namelen - leaf_pos, mode))
1179 == NULL) {
1180 PRINTK("(%s): could not allocate entry\n", name);
1181 devfs_put(*dir);
1182 return NULL;
1183 }
1184 return de;
1185} /* End Function _devfs_prepare_leaf */
1186
1187static devfs_handle_t _devfs_walk_path(struct devfs_entry *dir,
1188 const char *name, int namelen,
1189 int traverse_symlink)
1190{
1191 int next_pos = 0;
1192
1193 if (dir == NULL)
1194 dir = _devfs_get_root_entry();
1195 if (dir == NULL)
1196 return NULL;
1197 devfs_get(dir);
1198 for (; namelen > 0; name += next_pos, namelen -= next_pos) {
1199 struct devfs_entry *de, *link;
1200
1201 if (!S_ISDIR(dir->mode)) {
1202 devfs_put(dir);
1203 return NULL;
1204 }
1205
1206 if ((de =
1207 _devfs_descend(dir, name, namelen, &next_pos)) == NULL) {
1208 devfs_put(dir);
1209 return NULL;
1210 }
1211 if (S_ISLNK(de->mode) && traverse_symlink) { /* Need to follow the link: this is a stack chomper */
1212 /* FIXME what if it puts outside of mounted tree? */
1213 link = _devfs_walk_path(dir, de->u.symlink.linkname,
1214 de->u.symlink.length, TRUE);
1215 devfs_put(de);
1216 if (!link) {
1217 devfs_put(dir);
1218 return NULL;
1219 }
1220 de = link;
1221 }
1222 devfs_put(dir);
1223 dir = de;
1224 if (name[next_pos] == '/')
1225 ++next_pos;
1226 }
1227 return dir;
1228} /* End Function _devfs_walk_path */
1229
1230/**
1231 * _devfs_find_entry - Find a devfs entry.
1232 * @dir: The handle to the parent devfs directory entry. If this is %NULL the
1233 * name is relative to the root of the devfs.
1234 * @name: The name of the entry. This may be %NULL.
1235 * @traverse_symlink: If %TRUE then symbolic links are traversed.
1236 *
1237 * Returns the devfs_entry pointer on success, else %NULL. An implicit
1238 * devfs_get() is performed.
1239 */
1240
1241static struct devfs_entry *_devfs_find_entry(devfs_handle_t dir,
1242 const char *name,
1243 int traverse_symlink)
1244{
1245 unsigned int namelen = strlen(name);
1246
1247 if (name[0] == '/') {
1248 /* Skip leading pathname component */
1249 if (namelen < 2) {
1250 PRINTK("(%s): too short\n", name);
1251 return NULL;
1252 }
1253 for (++name, --namelen; (*name != '/') && (namelen > 0);
1254 ++name, --namelen) ;
1255 if (namelen < 2) {
1256 PRINTK("(%s): too short\n", name);
1257 return NULL;
1258 }
1259 ++name;
1260 --namelen;
1261 }
1262 return _devfs_walk_path(dir, name, namelen, traverse_symlink);
1263} /* End Function _devfs_find_entry */
1264
1265static struct devfs_entry *get_devfs_entry_from_vfs_inode(struct inode *inode)
1266{
1267 if (inode == NULL)
1268 return NULL;
1269 VERIFY_ENTRY((struct devfs_entry *)inode->u.generic_ip);
1270 return inode->u.generic_ip;
1271} /* End Function get_devfs_entry_from_vfs_inode */
1272
1273/**
1274 * free_dentry - Free the dentry for a device entry and invalidate inode.
1275 * @de: The entry.
1276 *
1277 * This must only be called after the entry has been unhooked from its
1278 * parent directory.
1279 */
1280
1281static void free_dentry(struct devfs_entry *de)
1282{
1283 struct dentry *dentry = de->inode.dentry;
1284
1285 if (!dentry)
1286 return;
1287 spin_lock(&dcache_lock);
1288 dget_locked(dentry);
1289 spin_unlock(&dcache_lock);
1290 /* Forcefully remove the inode */
1291 if (dentry->d_inode != NULL)
1292 dentry->d_inode->i_nlink = 0;
1293 d_drop(dentry);
1294 dput(dentry);
1295} /* End Function free_dentry */
1296
1297/**
1298 * is_devfsd_or_child - Test if the current process is devfsd or one of its children.
1299 * @fs_info: The filesystem information.
1300 *
1301 * Returns %TRUE if devfsd or child, else %FALSE.
1302 */
1303
1304static int is_devfsd_or_child(struct fs_info *fs_info)
1305{
1306 struct task_struct *p = current;
1307
1308 if (p == fs_info->devfsd_task)
1309 return (TRUE);
1310 if (process_group(p) == fs_info->devfsd_pgrp)
1311 return (TRUE);
1312 read_lock(&tasklist_lock);
1313 for (; p != &init_task; p = p->real_parent) {
1314 if (p == fs_info->devfsd_task) {
1315 read_unlock(&tasklist_lock);
1316 return (TRUE);
1317 }
1318 }
1319 read_unlock(&tasklist_lock);
1320 return (FALSE);
1321} /* End Function is_devfsd_or_child */
1322
1323/**
1324 * devfsd_queue_empty - Test if devfsd has work pending in its event queue.
1325 * @fs_info: The filesystem information.
1326 *
1327 * Returns %TRUE if the queue is empty, else %FALSE.
1328 */
1329
1330static inline int devfsd_queue_empty(struct fs_info *fs_info)
1331{
1332 return (fs_info->devfsd_last_event) ? FALSE : TRUE;
1333} /* End Function devfsd_queue_empty */
1334
1335/**
1336 * wait_for_devfsd_finished - Wait for devfsd to finish processing its event queue.
1337 * @fs_info: The filesystem information.
1338 *
1339 * Returns %TRUE if no more waiting will be required, else %FALSE.
1340 */
1341
1342static int wait_for_devfsd_finished(struct fs_info *fs_info)
1343{
1344 DECLARE_WAITQUEUE(wait, current);
1345
1346 if (fs_info->devfsd_task == NULL)
1347 return (TRUE);
1348 if (devfsd_queue_empty(fs_info) && fs_info->devfsd_sleeping)
1349 return TRUE;
1350 if (is_devfsd_or_child(fs_info))
1351 return (FALSE);
1352 set_current_state(TASK_UNINTERRUPTIBLE);
1353 add_wait_queue(&fs_info->revalidate_wait_queue, &wait);
1354 if (!devfsd_queue_empty(fs_info) || !fs_info->devfsd_sleeping)
1355 if (fs_info->devfsd_task)
1356 schedule();
1357 remove_wait_queue(&fs_info->revalidate_wait_queue, &wait);
1358 __set_current_state(TASK_RUNNING);
1359 return (TRUE);
1360} /* End Function wait_for_devfsd_finished */
1361
1362/**
1363 * devfsd_notify_de - Notify the devfsd daemon of a change.
1364 * @de: The devfs entry that has changed. This and all parent entries will
1365 * have their reference counts incremented if the event was queued.
1366 * @type: The type of change.
1367 * @mode: The mode of the entry.
1368 * @uid: The user ID.
1369 * @gid: The group ID.
1370 * @fs_info: The filesystem info.
1371 *
1372 * Returns %TRUE if an event was queued and devfsd woken up, else %FALSE.
1373 */
1374
1375static int devfsd_notify_de(struct devfs_entry *de,
1376 unsigned short type, umode_t mode,
1377 uid_t uid, gid_t gid, struct fs_info *fs_info)
1378{
1379 struct devfsd_buf_entry *entry;
1380 struct devfs_entry *curr;
1381
1382 if (!(fs_info->devfsd_event_mask & (1 << type)))
1383 return (FALSE);
1384 if ((entry = kmem_cache_alloc(devfsd_buf_cache, SLAB_KERNEL)) == NULL) {
1385 atomic_inc(&fs_info->devfsd_overrun_count);
1386 return (FALSE);
1387 }
1388 for (curr = de; curr != NULL; curr = curr->parent)
1389 devfs_get(curr);
1390 entry->de = de;
1391 entry->type = type;
1392 entry->mode = mode;
1393 entry->uid = uid;
1394 entry->gid = gid;
1395 entry->next = NULL;
1396 spin_lock(&fs_info->devfsd_buffer_lock);
1397 if (!fs_info->devfsd_first_event)
1398 fs_info->devfsd_first_event = entry;
1399 if (fs_info->devfsd_last_event)
1400 fs_info->devfsd_last_event->next = entry;
1401 fs_info->devfsd_last_event = entry;
1402 spin_unlock(&fs_info->devfsd_buffer_lock);
1403 wake_up_interruptible(&fs_info->devfsd_wait_queue);
1404 return (TRUE);
1405} /* End Function devfsd_notify_de */
1406
1407/**
1408 * devfsd_notify - Notify the devfsd daemon of a change.
1409 * @de: The devfs entry that has changed.
1410 * @type: The type of change event.
1411 * @wait: If TRUE, the function waits for the daemon to finish processing
1412 * the event.
1413 */
1414
1415static void devfsd_notify(struct devfs_entry *de, unsigned short type)
1416{
1417 devfsd_notify_de(de, type, de->mode, current->euid,
1418 current->egid, &fs_info);
1419}
1420
1421static int devfs_mk_dev(dev_t dev, umode_t mode, const char *fmt, va_list args)
1422{
1423 struct devfs_entry *dir = NULL, *de;
1424 char buf[64];
1425 int error, n;
1426
1427 n = vsnprintf(buf, sizeof(buf), fmt, args);
1428 if (n >= sizeof(buf) || !buf[0]) {
1429 printk(KERN_WARNING "%s: invalid format string %s\n",
1430 __FUNCTION__, fmt);
1431 return -EINVAL;
1432 }
1433
1434 de = _devfs_prepare_leaf(&dir, buf, mode);
1435 if (!de) {
1436 printk(KERN_WARNING "%s: could not prepare leaf for %s\n",
1437 __FUNCTION__, buf);
1438 return -ENOMEM; /* could be more accurate... */
1439 }
1440
1441 de->u.dev = dev;
1442
1443 error = _devfs_append_entry(dir, de, NULL);
1444 if (error) {
1445 printk(KERN_WARNING "%s: could not append to parent for %s\n",
1446 __FUNCTION__, buf);
1447 goto out;
1448 }
1449
1450 devfsd_notify(de, DEVFSD_NOTIFY_REGISTERED);
1451 out:
1452 devfs_put(dir);
1453 return error;
1454}
1455
1456int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
1457{
1458 va_list args;
1459
1460 if (!S_ISBLK(mode)) {
1461 printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
1462 __FUNCTION__, mode, fmt);
1463 return -EINVAL;
1464 }
1465
1466 va_start(args, fmt);
1467 return devfs_mk_dev(dev, mode, fmt, args);
1468}
1469
1470EXPORT_SYMBOL(devfs_mk_bdev);
1471
1472int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
1473{
1474 va_list args;
1475
1476 if (!S_ISCHR(mode)) {
1477 printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
1478 __FUNCTION__, mode, fmt);
1479 return -EINVAL;
1480 }
1481
1482 va_start(args, fmt);
1483 return devfs_mk_dev(dev, mode, fmt, args);
1484}
1485
1486EXPORT_SYMBOL(devfs_mk_cdev);
1487
1488/**
1489 * _devfs_unhook - Unhook a device entry from its parents list
1490 * @de: The entry to unhook.
1491 *
1492 * Returns %TRUE if the entry was unhooked, else %FALSE if it was
1493 * previously unhooked.
1494 * The caller must have a write lock on the parent directory.
1495 */
1496
1497static int _devfs_unhook(struct devfs_entry *de)
1498{
1499 struct devfs_entry *parent;
1500
1501 if (!de || (de->prev == de))
1502 return FALSE;
1503 parent = de->parent;
1504 if (de->prev == NULL)
1505 parent->u.dir.first = de->next;
1506 else
1507 de->prev->next = de->next;
1508 if (de->next == NULL)
1509 parent->u.dir.last = de->prev;
1510 else
1511 de->next->prev = de->prev;
1512 de->prev = de; /* Indicate we're unhooked */
1513 de->next = NULL; /* Force early termination for <devfs_readdir> */
1514 return TRUE;
1515} /* End Function _devfs_unhook */
1516
1517/**
1518 * _devfs_unregister - Unregister a device entry from its parent.
1519 * @dir: The parent directory.
1520 * @de: The entry to unregister.
1521 *
1522 * The caller must have a write lock on the parent directory, which is
1523 * unlocked by this function.
1524 */
1525
1526static void _devfs_unregister(struct devfs_entry *dir, struct devfs_entry *de)
1527{
1528 int unhooked = _devfs_unhook(de);
1529
1530 write_unlock(&dir->u.dir.lock);
1531 if (!unhooked)
1532 return;
1533 devfs_get(dir);
1534 devfsd_notify(de, DEVFSD_NOTIFY_UNREGISTERED);
1535 free_dentry(de);
1536 devfs_put(dir);
1537 if (!S_ISDIR(de->mode))
1538 return;
1539 while (TRUE) { /* Recursively unregister: this is a stack chomper */
1540 struct devfs_entry *child;
1541
1542 write_lock(&de->u.dir.lock);
1543 de->u.dir.no_more_additions = TRUE;
1544 child = de->u.dir.first;
1545 VERIFY_ENTRY(child);
1546 _devfs_unregister(de, child);
1547 if (!child)
1548 break;
1549 DPRINTK(DEBUG_UNREGISTER, "(%s): child: %p refcount: %d\n",
1550 child->name, child, atomic_read(&child->refcount));
1551 devfs_put(child);
1552 }
1553} /* End Function _devfs_unregister */
1554
1555static int devfs_do_symlink(devfs_handle_t dir, const char *name,
1556 const char *link, devfs_handle_t * handle)
1557{
1558 int err;
1559 unsigned int linklength;
1560 char *newlink;
1561 struct devfs_entry *de;
1562
1563 if (handle != NULL)
1564 *handle = NULL;
1565 if (name == NULL) {
1566 PRINTK("(): NULL name pointer\n");
1567 return -EINVAL;
1568 }
1569 if (link == NULL) {
1570 PRINTK("(%s): NULL link pointer\n", name);
1571 return -EINVAL;
1572 }
1573 linklength = strlen(link);
1574 if ((newlink = kmalloc(linklength + 1, GFP_KERNEL)) == NULL)
1575 return -ENOMEM;
1576 memcpy(newlink, link, linklength);
1577 newlink[linklength] = '\0';
1578 if ((de = _devfs_prepare_leaf(&dir, name, S_IFLNK | S_IRUGO | S_IXUGO))
1579 == NULL) {
1580 PRINTK("(%s): could not prepare leaf\n", name);
1581 kfree(newlink);
1582 return -ENOTDIR;
1583 }
1584 de->info = NULL;
1585 de->u.symlink.linkname = newlink;
1586 de->u.symlink.length = linklength;
1587 if ((err = _devfs_append_entry(dir, de, NULL)) != 0) {
1588 PRINTK("(%s): could not append to parent, err: %d\n", name,
1589 err);
1590 devfs_put(dir);
1591 return err;
1592 }
1593 devfs_put(dir);
1594#ifdef CONFIG_DEVFS_DEBUG
1595 spin_lock(&stat_lock);
1596 stat_num_bytes += linklength + 1;
1597 spin_unlock(&stat_lock);
1598#endif
1599 if (handle != NULL)
1600 *handle = de;
1601 return 0;
1602} /* End Function devfs_do_symlink */
1603
1604/**
1605 * devfs_mk_symlink Create a symbolic link in the devfs namespace.
1606 * @from: The name of the entry.
1607 * @to: Name of the destination
1608 *
1609 * Returns 0 on success, else a negative error code is returned.
1610 */
1611
1612int devfs_mk_symlink(const char *from, const char *to)
1613{
1614 devfs_handle_t de;
1615 int err;
1616
1617 err = devfs_do_symlink(NULL, from, to, &de);
1618 if (!err) {
1619 de->vfs = TRUE;
1620 devfsd_notify(de, DEVFSD_NOTIFY_REGISTERED);
1621 }
1622
1623 return err;
1624}
1625
1626/**
1627 * devfs_mk_dir - Create a directory in the devfs namespace.
1628 * new name is relative to the root of the devfs.
1629 * @fmt: The name of the entry.
1630 *
1631 * Use of this function is optional. The devfs_register() function
1632 * will automatically create intermediate directories as needed. This function
1633 * is provided for efficiency reasons, as it provides a handle to a directory.
1634 * On failure %NULL is returned.
1635 */
1636
1637int devfs_mk_dir(const char *fmt, ...)
1638{
1639 struct devfs_entry *dir = NULL, *de = NULL, *old;
1640 char buf[64];
1641 va_list args;
1642 int error, n;
1643
1644 va_start(args, fmt);
1645 n = vsnprintf(buf, 64, fmt, args);
1646 if (n >= 64 || !buf[0]) {
1647 printk(KERN_WARNING "%s: invalid argument.", __FUNCTION__);
1648 return -EINVAL;
1649 }
1650
1651 de = _devfs_prepare_leaf(&dir, buf, MODE_DIR);
1652 if (!de) {
1653 PRINTK("(%s): could not prepare leaf\n", buf);
1654 return -EINVAL;
1655 }
1656
1657 error = _devfs_append_entry(dir, de, &old);
1658 if (error == -EEXIST && S_ISDIR(old->mode)) {
1659 /*
1660 * devfs_mk_dir() of an already-existing directory will
1661 * return success.
1662 */
1663 error = 0;
1664 goto out_put;
1665 } else if (error) {
1666 PRINTK("(%s): could not append to dir: %p \"%s\"\n",
1667 buf, dir, dir->name);
1668 devfs_put(old);
1669 goto out_put;
1670 }
1671
1672 devfsd_notify(de, DEVFSD_NOTIFY_REGISTERED);
1673
1674 out_put:
1675 devfs_put(dir);
1676 return error;
1677}
1678
1679void devfs_remove(const char *fmt, ...)
1680{
1681 char buf[64];
1682 va_list args;
1683 int n;
1684
1685 va_start(args, fmt);
1686 n = vsnprintf(buf, sizeof(buf), fmt, args);
1687 if (n < sizeof(buf) && buf[0]) {
1688 devfs_handle_t de = _devfs_find_entry(NULL, buf, 0);
1689
1690 if (!de) {
1691 printk(KERN_ERR "%s: %s not found, cannot remove\n",
1692 __FUNCTION__, buf);
1693 dump_stack();
1694 return;
1695 }
1696
1697 write_lock(&de->parent->u.dir.lock);
1698 _devfs_unregister(de->parent, de);
1699 devfs_put(de);
1700 devfs_put(de);
1701 }
1702}
1703
1704/**
1705 * devfs_generate_path - Generate a pathname for an entry, relative to the devfs root.
1706 * @de: The devfs entry.
1707 * @path: The buffer to write the pathname to. The pathname and '\0'
1708 * terminator will be written at the end of the buffer.
1709 * @buflen: The length of the buffer.
1710 *
1711 * Returns the offset in the buffer where the pathname starts on success,
1712 * else a negative error code.
1713 */
1714
1715static int devfs_generate_path(devfs_handle_t de, char *path, int buflen)
1716{
1717 int pos;
1718#define NAMEOF(de) ( (de)->mode ? (de)->name : (de)->u.name )
1719
1720 if (de == NULL)
1721 return -EINVAL;
1722 VERIFY_ENTRY(de);
1723 if (de->namelen >= buflen)
1724 return -ENAMETOOLONG; /* Must be first */
1725 path[buflen - 1] = '\0';
1726 if (de->parent == NULL)
1727 return buflen - 1; /* Don't prepend root */
1728 pos = buflen - de->namelen - 1;
1729 memcpy(path + pos, NAMEOF(de), de->namelen);
1730 for (de = de->parent; de->parent != NULL; de = de->parent) {
1731 if (pos - de->namelen - 1 < 0)
1732 return -ENAMETOOLONG;
1733 path[--pos] = '/';
1734 pos -= de->namelen;
1735 memcpy(path + pos, NAMEOF(de), de->namelen);
1736 }
1737 return pos;
1738} /* End Function devfs_generate_path */
1739
1740/**
1741 * devfs_setup - Process kernel boot options.
1742 * @str: The boot options after the "devfs=".
1743 */
1744
1745static int __init devfs_setup(char *str)
1746{
1747 static struct {
1748 char *name;
1749 unsigned int mask;
1750 unsigned int *opt;
1751 } devfs_options_tab[] __initdata = {
1752#ifdef CONFIG_DEVFS_DEBUG
1753 {
1754 "dall", DEBUG_ALL, &devfs_debug_init}, {
1755 "dmod", DEBUG_MODULE_LOAD, &devfs_debug_init}, {
1756 "dreg", DEBUG_REGISTER, &devfs_debug_init}, {
1757 "dunreg", DEBUG_UNREGISTER, &devfs_debug_init}, {
1758 "dfree", DEBUG_FREE, &devfs_debug_init}, {
1759 "diget", DEBUG_I_GET, &devfs_debug_init}, {
1760 "dchange", DEBUG_SET_FLAGS, &devfs_debug_init}, {
1761 "dsread", DEBUG_S_READ, &devfs_debug_init}, {
1762 "dichange", DEBUG_I_CHANGE, &devfs_debug_init}, {
1763 "dimknod", DEBUG_I_MKNOD, &devfs_debug_init}, {
1764 "dilookup", DEBUG_I_LOOKUP, &devfs_debug_init}, {
1765 "diunlink", DEBUG_I_UNLINK, &devfs_debug_init},
1766#endif /* CONFIG_DEVFS_DEBUG */
1767 {
1768 "mount", OPTION_MOUNT, &boot_options}, {
1769 NULL, 0, NULL}
1770 };
1771
1772 while ((*str != '\0') && !isspace(*str)) {
1773 int i, found = 0, invert = 0;
1774
1775 if (strncmp(str, "no", 2) == 0) {
1776 invert = 1;
1777 str += 2;
1778 }
1779 for (i = 0; devfs_options_tab[i].name != NULL; i++) {
1780 int len = strlen(devfs_options_tab[i].name);
1781
1782 if (strncmp(str, devfs_options_tab[i].name, len) == 0) {
1783 if (invert)
1784 *devfs_options_tab[i].opt &=
1785 ~devfs_options_tab[i].mask;
1786 else
1787 *devfs_options_tab[i].opt |=
1788 devfs_options_tab[i].mask;
1789 str += len;
1790 found = 1;
1791 break;
1792 }
1793 }
1794 if (!found)
1795 return 0; /* No match */
1796 if (*str != ',')
1797 return 0; /* No more options */
1798 ++str;
1799 }
1800 return 1;
1801} /* End Function devfs_setup */
1802
1803__setup("devfs=", devfs_setup);
1804
1805EXPORT_SYMBOL(devfs_mk_dir);
1806EXPORT_SYMBOL(devfs_remove);
1807
1808/**
1809 * try_modload - Notify devfsd of an inode lookup by a non-devfsd process.
1810 * @parent: The parent devfs entry.
1811 * @fs_info: The filesystem info.
1812 * @name: The device name.
1813 * @namelen: The number of characters in @name.
1814 * @buf: A working area that will be used. This must not go out of scope
1815 * until devfsd is idle again.
1816 *
1817 * Returns 0 on success (event was queued), else a negative error code.
1818 */
1819
1820static int try_modload(struct devfs_entry *parent, struct fs_info *fs_info,
1821 const char *name, unsigned namelen,
1822 struct devfs_entry *buf)
1823{
1824 if (!(fs_info->devfsd_event_mask & (1 << DEVFSD_NOTIFY_LOOKUP)))
1825 return -ENOENT;
1826 if (is_devfsd_or_child(fs_info))
1827 return -ENOENT;
1828 memset(buf, 0, sizeof *buf);
1829 atomic_set(&buf->refcount, 1);
1830 buf->parent = parent;
1831 buf->namelen = namelen;
1832 buf->u.name = name;
1833 WRITE_ENTRY_MAGIC(buf, MAGIC_VALUE);
1834 if (!devfsd_notify_de(buf, DEVFSD_NOTIFY_LOOKUP, 0,
1835 current->euid, current->egid, fs_info))
1836 return -ENOENT;
1837 /* Possible success: event has been queued */
1838 return 0;
1839} /* End Function try_modload */
1840
1841/* Superblock operations follow */
1842
1843static struct inode_operations devfs_iops;
1844static struct inode_operations devfs_dir_iops;
1845static const struct file_operations devfs_fops;
1846static const struct file_operations devfs_dir_fops;
1847static struct inode_operations devfs_symlink_iops;
1848
1849static int devfs_notify_change(struct dentry *dentry, struct iattr *iattr)
1850{
1851 int retval;
1852 struct devfs_entry *de;
1853 struct inode *inode = dentry->d_inode;
1854 struct fs_info *fs_info = inode->i_sb->s_fs_info;
1855
1856 de = get_devfs_entry_from_vfs_inode(inode);
1857 if (de == NULL)
1858 return -ENODEV;
1859 retval = inode_change_ok(inode, iattr);
1860 if (retval != 0)
1861 return retval;
1862 retval = inode_setattr(inode, iattr);
1863 if (retval != 0)
1864 return retval;
1865 DPRINTK(DEBUG_I_CHANGE, "(%d): VFS inode: %p devfs_entry: %p\n",
1866 (int)inode->i_ino, inode, de);
1867 DPRINTK(DEBUG_I_CHANGE, "(): mode: 0%o uid: %d gid: %d\n",
1868 (int)inode->i_mode, (int)inode->i_uid, (int)inode->i_gid);
1869 /* Inode is not on hash chains, thus must save permissions here rather
1870 than in a write_inode() method */
1871 de->mode = inode->i_mode;
1872 de->inode.uid = inode->i_uid;
1873 de->inode.gid = inode->i_gid;
1874 de->inode.atime = inode->i_atime;
1875 de->inode.mtime = inode->i_mtime;
1876 de->inode.ctime = inode->i_ctime;
1877 if ((iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) &&
1878 !is_devfsd_or_child(fs_info))
1879 devfsd_notify_de(de, DEVFSD_NOTIFY_CHANGE, inode->i_mode,
1880 inode->i_uid, inode->i_gid, fs_info);
1881 return 0;
1882} /* End Function devfs_notify_change */
1883
1884static struct super_operations devfs_sops = {
1885 .drop_inode = generic_delete_inode,
1886 .statfs = simple_statfs,
1887};
1888
1889/**
1890 * _devfs_get_vfs_inode - Get a VFS inode.
1891 * @sb: The super block.
1892 * @de: The devfs inode.
1893 * @dentry: The dentry to register with the devfs inode.
1894 *
1895 * Returns the inode on success, else %NULL. An implicit devfs_get() is
1896 * performed if the inode is created.
1897 */
1898
1899static struct inode *_devfs_get_vfs_inode(struct super_block *sb,
1900 struct devfs_entry *de,
1901 struct dentry *dentry)
1902{
1903 struct inode *inode;
1904
1905 if (de->prev == de)
1906 return NULL; /* Quick check to see if unhooked */
1907 if ((inode = new_inode(sb)) == NULL) {
1908 PRINTK("(%s): new_inode() failed, de: %p\n", de->name, de);
1909 return NULL;
1910 }
1911 if (de->parent) {
1912 read_lock(&de->parent->u.dir.lock);
1913 if (de->prev != de)
1914 de->inode.dentry = dentry; /* Not unhooked */
1915 read_unlock(&de->parent->u.dir.lock);
1916 } else
1917 de->inode.dentry = dentry; /* Root: no locking needed */
1918 if (de->inode.dentry != dentry) { /* Must have been unhooked */
1919 iput(inode);
1920 return NULL;
1921 }
1922 /* FIXME where is devfs_put? */
1923 inode->u.generic_ip = devfs_get(de);
1924 inode->i_ino = de->inode.ino;
1925 DPRINTK(DEBUG_I_GET, "(%d): VFS inode: %p devfs_entry: %p\n",
1926 (int)inode->i_ino, inode, de);
1927 inode->i_blocks = 0;
1928 inode->i_blksize = FAKE_BLOCK_SIZE;
1929 inode->i_op = &devfs_iops;
1930 inode->i_mode = de->mode;
1931 if (S_ISDIR(de->mode)) {
1932 inode->i_op = &devfs_dir_iops;
1933 inode->i_fop = &devfs_dir_fops;
1934 } else if (S_ISLNK(de->mode)) {
1935 inode->i_op = &devfs_symlink_iops;
1936 inode->i_size = de->u.symlink.length;
1937 } else if (S_ISCHR(de->mode) || S_ISBLK(de->mode)) {
1938 init_special_inode(inode, de->mode, de->u.dev);
1939 } else if (S_ISFIFO(de->mode) || S_ISSOCK(de->mode)) {
1940 init_special_inode(inode, de->mode, 0);
1941 } else {
1942 PRINTK("(%s): unknown mode %o de: %p\n",
1943 de->name, de->mode, de);
1944 iput(inode);
1945 devfs_put(de);
1946 return NULL;
1947 }
1948
1949 inode->i_uid = de->inode.uid;
1950 inode->i_gid = de->inode.gid;
1951 inode->i_atime = de->inode.atime;
1952 inode->i_mtime = de->inode.mtime;
1953 inode->i_ctime = de->inode.ctime;
1954 DPRINTK(DEBUG_I_GET, "(): mode: 0%o uid: %d gid: %d\n",
1955 (int)inode->i_mode, (int)inode->i_uid, (int)inode->i_gid);
1956 return inode;
1957} /* End Function _devfs_get_vfs_inode */
1958
1959/* File operations for device entries follow */
1960
1961static int devfs_readdir(struct file *file, void *dirent, filldir_t filldir)
1962{
1963 int err, count;
1964 int stored = 0;
1965 struct fs_info *fs_info;
1966 struct devfs_entry *parent, *de, *next = NULL;
1967 struct inode *inode = file->f_dentry->d_inode;
1968
1969 fs_info = inode->i_sb->s_fs_info;
1970 parent = get_devfs_entry_from_vfs_inode(file->f_dentry->d_inode);
1971 if ((long)file->f_pos < 0)
1972 return -EINVAL;
1973 DPRINTK(DEBUG_F_READDIR, "(%s): fs_info: %p pos: %ld\n",
1974 parent->name, fs_info, (long)file->f_pos);
1975 switch ((long)file->f_pos) {
1976 case 0:
1977 err = (*filldir) (dirent, "..", 2, file->f_pos,
1978 parent_ino(file->f_dentry), DT_DIR);
1979 if (err == -EINVAL)
1980 break;
1981 if (err < 0)
1982 return err;
1983 file->f_pos++;
1984 ++stored;
1985 /* Fall through */
1986 case 1:
1987 err =
1988 (*filldir) (dirent, ".", 1, file->f_pos, inode->i_ino,
1989 DT_DIR);
1990 if (err == -EINVAL)
1991 break;
1992 if (err < 0)
1993 return err;
1994 file->f_pos++;
1995 ++stored;
1996 /* Fall through */
1997 default:
1998 /* Skip entries */
1999 count = file->f_pos - 2;
2000 read_lock(&parent->u.dir.lock);
2001 for (de = parent->u.dir.first; de && (count > 0); de = de->next)
2002 --count;
2003 devfs_get(de);
2004 read_unlock(&parent->u.dir.lock);
2005 /* Now add all remaining entries */
2006 while (de) {
2007 err = (*filldir) (dirent, de->name, de->namelen,
2008 file->f_pos, de->inode.ino,
2009 de->mode >> 12);
2010 if (err < 0)
2011 devfs_put(de);
2012 else {
2013 file->f_pos++;
2014 ++stored;
2015 }
2016 if (err == -EINVAL)
2017 break;
2018 if (err < 0)
2019 return err;
2020 read_lock(&parent->u.dir.lock);
2021 next = devfs_get(de->next);
2022 read_unlock(&parent->u.dir.lock);
2023 devfs_put(de);
2024 de = next;
2025 }
2026 break;
2027 }
2028 return stored;
2029} /* End Function devfs_readdir */
2030
2031/* Open devfs specific special files */
2032static int devfs_open(struct inode *inode, struct file *file)
2033{
2034 int err;
2035 int minor = MINOR(inode->i_rdev);
2036 struct file_operations *old_fops, *new_fops;
2037
2038 switch (minor) {
2039 case 0: /* /dev/.devfsd */
2040 new_fops = fops_get(&devfsd_fops);
2041 break;
2042#ifdef CONFIG_DEVFS_DEBUG
2043 case 1: /* /dev/.stat */
2044 new_fops = fops_get(&stat_fops);
2045 break;
2046#endif
2047 default:
2048 return -ENODEV;
2049 }
2050
2051 if (new_fops == NULL)
2052 return -ENODEV;
2053 old_fops = file->f_op;
2054 file->f_op = new_fops;
2055 err = new_fops->open ? new_fops->open(inode, file) : 0;
2056 if (err) {
2057 file->f_op = old_fops;
2058 fops_put(new_fops);
2059 } else
2060 fops_put(old_fops);
2061 return err;
2062} /* End Function devfs_open */
2063
2064static const struct file_operations devfs_fops = {
2065 .open = devfs_open,
2066};
2067
2068static const struct file_operations devfs_dir_fops = {
2069 .read = generic_read_dir,
2070 .readdir = devfs_readdir,
2071};
2072
2073/* Dentry operations for device entries follow */
2074
2075/**
2076 * devfs_d_release - Callback for when a dentry is freed.
2077 * @dentry: The dentry.
2078 */
2079
2080static void devfs_d_release(struct dentry *dentry)
2081{
2082 DPRINTK(DEBUG_D_RELEASE, "(%p): inode: %p\n", dentry, dentry->d_inode);
2083} /* End Function devfs_d_release */
2084
2085/**
2086 * devfs_d_iput - Callback for when a dentry loses its inode.
2087 * @dentry: The dentry.
2088 * @inode: The inode.
2089 */
2090
2091static void devfs_d_iput(struct dentry *dentry, struct inode *inode)
2092{
2093 struct devfs_entry *de;
2094
2095 de = get_devfs_entry_from_vfs_inode(inode);
2096 DPRINTK(DEBUG_D_IPUT,
2097 "(%s): dentry: %p inode: %p de: %p de->dentry: %p\n", de->name,
2098 dentry, inode, de, de->inode.dentry);
2099 if (de->inode.dentry && (de->inode.dentry != dentry))
2100 OOPS("(%s): de: %p dentry: %p de->dentry: %p\n",
2101 de->name, de, dentry, de->inode.dentry);
2102 de->inode.dentry = NULL;
2103 iput(inode);
2104 devfs_put(de);
2105} /* End Function devfs_d_iput */
2106
2107static int devfs_d_delete(struct dentry *dentry);
2108
2109static struct dentry_operations devfs_dops = {
2110 .d_delete = devfs_d_delete,
2111 .d_release = devfs_d_release,
2112 .d_iput = devfs_d_iput,
2113};
2114
2115static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *);
2116
2117static struct dentry_operations devfs_wait_dops = {
2118 .d_delete = devfs_d_delete,
2119 .d_release = devfs_d_release,
2120 .d_iput = devfs_d_iput,
2121 .d_revalidate = devfs_d_revalidate_wait,
2122};
2123
2124/**
2125 * devfs_d_delete - Callback for when all files for a dentry are closed.
2126 * @dentry: The dentry.
2127 */
2128
2129static int devfs_d_delete(struct dentry *dentry)
2130{
2131 struct inode *inode = dentry->d_inode;
2132
2133 if (dentry->d_op == &devfs_wait_dops)
2134 dentry->d_op = &devfs_dops;
2135 /* Unhash dentry if negative (has no inode) */
2136 if (inode == NULL) {
2137 DPRINTK(DEBUG_D_DELETE, "(%p): dropping negative dentry\n",
2138 dentry);
2139 return 1;
2140 }
2141 return 0;
2142} /* End Function devfs_d_delete */
2143
2144struct devfs_lookup_struct {
2145 devfs_handle_t de;
2146 wait_queue_head_t wait_queue;
2147};
2148
2149/* XXX: this doesn't handle the case where we got a negative dentry
2150 but a devfs entry has been registered in the meanwhile */
2151static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *nd)
2152{
2153 struct inode *dir = dentry->d_parent->d_inode;
2154 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2155 devfs_handle_t parent = get_devfs_entry_from_vfs_inode(dir);
2156 struct devfs_lookup_struct *lookup_info = dentry->d_fsdata;
2157 DECLARE_WAITQUEUE(wait, current);
2158 int need_lock;
2159
2160 /*
2161 * FIXME HACK
2162 *
2163 * make sure that
2164 * d_instantiate always runs under lock
2165 * we release i_mutex lock before going to sleep
2166 *
2167 * unfortunately sometimes d_revalidate is called with
2168 * and sometimes without i_mutex lock held. The following checks
2169 * attempt to deduce when we need to add (and drop resp.) lock
2170 * here. This relies on current (2.6.2) calling coventions:
2171 *
2172 * lookup_hash is always run under i_mutex and is passing NULL
2173 * as nd
2174 *
2175 * open(...,O_CREATE,...) calls _lookup_hash under i_mutex
2176 * and sets flags to LOOKUP_OPEN|LOOKUP_CREATE
2177 *
2178 * all other invocations of ->d_revalidate seem to happen
2179 * outside of i_mutex
2180 */
2181 need_lock = nd &&
2182 (!(nd->flags & LOOKUP_CREATE) || (nd->flags & LOOKUP_PARENT));
2183
2184 if (need_lock)
2185 mutex_lock(&dir->i_mutex);
2186
2187 if (is_devfsd_or_child(fs_info)) {
2188 devfs_handle_t de = lookup_info->de;
2189 struct inode *inode;
2190
2191 DPRINTK(DEBUG_I_LOOKUP,
2192 "(%s): dentry: %p inode: %p de: %p by: \"%s\"\n",
2193 dentry->d_name.name, dentry, dentry->d_inode, de,
2194 current->comm);
2195 if (dentry->d_inode)
2196 goto out;
2197 if (de == NULL) {
2198 read_lock(&parent->u.dir.lock);
2199 de = _devfs_search_dir(parent, dentry->d_name.name,
2200 dentry->d_name.len);
2201 read_unlock(&parent->u.dir.lock);
2202 if (de == NULL)
2203 goto out;
2204 lookup_info->de = de;
2205 }
2206 /* Create an inode, now that the driver information is available */
2207 inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry);
2208 if (!inode)
2209 goto out;
2210 DPRINTK(DEBUG_I_LOOKUP,
2211 "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n",
2212 de->name, de->inode.ino, inode, de, current->comm);
2213 d_instantiate(dentry, inode);
2214 goto out;
2215 }
2216 if (lookup_info == NULL)
2217 goto out; /* Early termination */
2218 read_lock(&parent->u.dir.lock);
2219 if (dentry->d_fsdata) {
2220 set_current_state(TASK_UNINTERRUPTIBLE);
2221 add_wait_queue(&lookup_info->wait_queue, &wait);
2222 read_unlock(&parent->u.dir.lock);
2223 /* at this point it is always (hopefully) locked */
2224 mutex_unlock(&dir->i_mutex);
2225 schedule();
2226 mutex_lock(&dir->i_mutex);
2227 /*
2228 * This does not need nor should remove wait from wait_queue.
2229 * Wait queue head is never reused - nothing is ever added to it
2230 * after all waiters have been waked up and head itself disappears
2231 * very soon after it. Moreover it is local variable on stack that
2232 * is likely to have already disappeared so any reference to it
2233 * at this point is buggy.
2234 */
2235
2236 } else
2237 read_unlock(&parent->u.dir.lock);
2238
2239 out:
2240 if (need_lock)
2241 mutex_unlock(&dir->i_mutex);
2242 return 1;
2243} /* End Function devfs_d_revalidate_wait */
2244
2245/* Inode operations for device entries follow */
2246
2247static struct dentry *devfs_lookup(struct inode *dir, struct dentry *dentry,
2248 struct nameidata *nd)
2249{
2250 struct devfs_entry tmp; /* Must stay in scope until devfsd idle again */
2251 struct devfs_lookup_struct lookup_info;
2252 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2253 struct devfs_entry *parent, *de;
2254 struct inode *inode;
2255 struct dentry *retval = NULL;
2256
2257 /* Set up the dentry operations before anything else, to ensure cleaning
2258 up on any error */
2259 dentry->d_op = &devfs_dops;
2260 /* First try to get the devfs entry for this directory */
2261 parent = get_devfs_entry_from_vfs_inode(dir);
2262 DPRINTK(DEBUG_I_LOOKUP, "(%s): dentry: %p parent: %p by: \"%s\"\n",
2263 dentry->d_name.name, dentry, parent, current->comm);
2264 if (parent == NULL)
2265 return ERR_PTR(-ENOENT);
2266 read_lock(&parent->u.dir.lock);
2267 de = _devfs_search_dir(parent, dentry->d_name.name, dentry->d_name.len);
2268 read_unlock(&parent->u.dir.lock);
2269 lookup_info.de = de;
2270 init_waitqueue_head(&lookup_info.wait_queue);
2271 dentry->d_fsdata = &lookup_info;
2272 if (de == NULL) { /* Try with devfsd. For any kind of failure, leave a negative dentry
2273 so someone else can deal with it (in the case where the sysadmin
2274 does a mknod()). It's important to do this before hashing the
2275 dentry, so that the devfsd queue is filled before revalidates
2276 can start */
2277 if (try_modload(parent, fs_info, dentry->d_name.name, dentry->d_name.len, &tmp) < 0) { /* Lookup event was not queued to devfsd */
2278 d_add(dentry, NULL);
2279 return NULL;
2280 }
2281 }
2282 dentry->d_op = &devfs_wait_dops;
2283 d_add(dentry, NULL); /* Open the floodgates */
2284 /* Unlock directory semaphore, which will release any waiters. They
2285 will get the hashed dentry, and may be forced to wait for
2286 revalidation */
2287 mutex_unlock(&dir->i_mutex);
2288 wait_for_devfsd_finished(fs_info); /* If I'm not devfsd, must wait */
2289 mutex_lock(&dir->i_mutex); /* Grab it again because them's the rules */
2290 de = lookup_info.de;
2291 /* If someone else has been so kind as to make the inode, we go home
2292 early */
2293 if (dentry->d_inode)
2294 goto out;
2295 if (de == NULL) {
2296 read_lock(&parent->u.dir.lock);
2297 de = _devfs_search_dir(parent, dentry->d_name.name,
2298 dentry->d_name.len);
2299 read_unlock(&parent->u.dir.lock);
2300 if (de == NULL)
2301 goto out;
2302 /* OK, there's an entry now, but no VFS inode yet */
2303 }
2304 /* Create an inode, now that the driver information is available */
2305 inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry);
2306 if (!inode) {
2307 retval = ERR_PTR(-ENOMEM);
2308 goto out;
2309 }
2310 DPRINTK(DEBUG_I_LOOKUP,
2311 "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n", de->name,
2312 de->inode.ino, inode, de, current->comm);
2313 d_instantiate(dentry, inode);
2314 out:
2315 write_lock(&parent->u.dir.lock);
2316 dentry->d_op = &devfs_dops;
2317 dentry->d_fsdata = NULL;
2318 wake_up(&lookup_info.wait_queue);
2319 write_unlock(&parent->u.dir.lock);
2320 devfs_put(de);
2321 return retval;
2322} /* End Function devfs_lookup */
2323
2324static int devfs_unlink(struct inode *dir, struct dentry *dentry)
2325{
2326 int unhooked;
2327 struct devfs_entry *de;
2328 struct inode *inode = dentry->d_inode;
2329 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2330
2331 de = get_devfs_entry_from_vfs_inode(inode);
2332 DPRINTK(DEBUG_I_UNLINK, "(%s): de: %p\n", dentry->d_name.name, de);
2333 if (de == NULL)
2334 return -ENOENT;
2335 if (!de->vfs)
2336 return -EPERM;
2337 write_lock(&de->parent->u.dir.lock);
2338 unhooked = _devfs_unhook(de);
2339 write_unlock(&de->parent->u.dir.lock);
2340 if (!unhooked)
2341 return -ENOENT;
2342 if (!is_devfsd_or_child(fs_info))
2343 devfsd_notify_de(de, DEVFSD_NOTIFY_DELETE, inode->i_mode,
2344 inode->i_uid, inode->i_gid, fs_info);
2345 free_dentry(de);
2346 devfs_put(de);
2347 return 0;
2348} /* End Function devfs_unlink */
2349
2350static int devfs_symlink(struct inode *dir, struct dentry *dentry,
2351 const char *symname)
2352{
2353 int err;
2354 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2355 struct devfs_entry *parent, *de;
2356 struct inode *inode;
2357
2358 /* First try to get the devfs entry for this directory */
2359 parent = get_devfs_entry_from_vfs_inode(dir);
2360 if (parent == NULL)
2361 return -ENOENT;
2362 err = devfs_do_symlink(parent, dentry->d_name.name, symname, &de);
2363 DPRINTK(DEBUG_DISABLED, "(%s): errcode from <devfs_do_symlink>: %d\n",
2364 dentry->d_name.name, err);
2365 if (err < 0)
2366 return err;
2367 de->vfs = TRUE;
2368 de->inode.uid = current->euid;
2369 de->inode.gid = current->egid;
2370 de->inode.atime = CURRENT_TIME;
2371 de->inode.mtime = CURRENT_TIME;
2372 de->inode.ctime = CURRENT_TIME;
2373 if ((inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry)) == NULL)
2374 return -ENOMEM;
2375 DPRINTK(DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n",
2376 dentry->d_name.name, de->inode.ino, inode, dentry);
2377 d_instantiate(dentry, inode);
2378 if (!is_devfsd_or_child(fs_info))
2379 devfsd_notify_de(de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
2380 inode->i_uid, inode->i_gid, fs_info);
2381 return 0;
2382} /* End Function devfs_symlink */
2383
2384static int devfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
2385{
2386 int err;
2387 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2388 struct devfs_entry *parent, *de;
2389 struct inode *inode;
2390
2391 mode = (mode & ~S_IFMT) | S_IFDIR; /* VFS doesn't pass S_IFMT part */
2392 parent = get_devfs_entry_from_vfs_inode(dir);
2393 if (parent == NULL)
2394 return -ENOENT;
2395 de = _devfs_alloc_entry(dentry->d_name.name, dentry->d_name.len, mode);
2396 if (!de)
2397 return -ENOMEM;
2398 de->vfs = TRUE;
2399 if ((err = _devfs_append_entry(parent, de, NULL)) != 0)
2400 return err;
2401 de->inode.uid = current->euid;
2402 de->inode.gid = current->egid;
2403 de->inode.atime = CURRENT_TIME;
2404 de->inode.mtime = CURRENT_TIME;
2405 de->inode.ctime = CURRENT_TIME;
2406 if ((inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry)) == NULL)
2407 return -ENOMEM;
2408 DPRINTK(DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n",
2409 dentry->d_name.name, de->inode.ino, inode, dentry);
2410 d_instantiate(dentry, inode);
2411 if (!is_devfsd_or_child(fs_info))
2412 devfsd_notify_de(de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
2413 inode->i_uid, inode->i_gid, fs_info);
2414 return 0;
2415} /* End Function devfs_mkdir */
2416
2417static int devfs_rmdir(struct inode *dir, struct dentry *dentry)
2418{
2419 int err = 0;
2420 struct devfs_entry *de;
2421 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2422 struct inode *inode = dentry->d_inode;
2423
2424 if (dir->i_sb->s_fs_info != inode->i_sb->s_fs_info)
2425 return -EINVAL;
2426 de = get_devfs_entry_from_vfs_inode(inode);
2427 if (de == NULL)
2428 return -ENOENT;
2429 if (!S_ISDIR(de->mode))
2430 return -ENOTDIR;
2431 if (!de->vfs)
2432 return -EPERM;
2433 /* First ensure the directory is empty and will stay that way */
2434 write_lock(&de->u.dir.lock);
2435 if (de->u.dir.first)
2436 err = -ENOTEMPTY;
2437 else
2438 de->u.dir.no_more_additions = TRUE;
2439 write_unlock(&de->u.dir.lock);
2440 if (err)
2441 return err;
2442 /* Now unhook the directory from its parent */
2443 write_lock(&de->parent->u.dir.lock);
2444 if (!_devfs_unhook(de))
2445 err = -ENOENT;
2446 write_unlock(&de->parent->u.dir.lock);
2447 if (err)
2448 return err;
2449 if (!is_devfsd_or_child(fs_info))
2450 devfsd_notify_de(de, DEVFSD_NOTIFY_DELETE, inode->i_mode,
2451 inode->i_uid, inode->i_gid, fs_info);
2452 free_dentry(de);
2453 devfs_put(de);
2454 return 0;
2455} /* End Function devfs_rmdir */
2456
2457static int devfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
2458 dev_t rdev)
2459{
2460 int err;
2461 struct fs_info *fs_info = dir->i_sb->s_fs_info;
2462 struct devfs_entry *parent, *de;
2463 struct inode *inode;
2464
2465 DPRINTK(DEBUG_I_MKNOD, "(%s): mode: 0%o dev: %u:%u\n",
2466 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
2467 parent = get_devfs_entry_from_vfs_inode(dir);
2468 if (parent == NULL)
2469 return -ENOENT;
2470 de = _devfs_alloc_entry(dentry->d_name.name, dentry->d_name.len, mode);
2471 if (!de)
2472 return -ENOMEM;
2473 de->vfs = TRUE;
2474 if (S_ISCHR(mode) || S_ISBLK(mode))
2475 de->u.dev = rdev;
2476 if ((err = _devfs_append_entry(parent, de, NULL)) != 0)
2477 return err;
2478 de->inode.uid = current->euid;
2479 de->inode.gid = current->egid;
2480 de->inode.atime = CURRENT_TIME;
2481 de->inode.mtime = CURRENT_TIME;
2482 de->inode.ctime = CURRENT_TIME;
2483 if ((inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry)) == NULL)
2484 return -ENOMEM;
2485 DPRINTK(DEBUG_I_MKNOD, ": new VFS inode(%u): %p dentry: %p\n",
2486 de->inode.ino, inode, dentry);
2487 d_instantiate(dentry, inode);
2488 if (!is_devfsd_or_child(fs_info))
2489 devfsd_notify_de(de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
2490 inode->i_uid, inode->i_gid, fs_info);
2491 return 0;
2492} /* End Function devfs_mknod */
2493
2494static void *devfs_follow_link(struct dentry *dentry, struct nameidata *nd)
2495{
2496 struct devfs_entry *p = get_devfs_entry_from_vfs_inode(dentry->d_inode);
2497 nd_set_link(nd, p ? p->u.symlink.linkname : ERR_PTR(-ENODEV));
2498 return NULL;
2499} /* End Function devfs_follow_link */
2500
2501static struct inode_operations devfs_iops = {
2502 .setattr = devfs_notify_change,
2503};
2504
2505static struct inode_operations devfs_dir_iops = {
2506 .lookup = devfs_lookup,
2507 .unlink = devfs_unlink,
2508 .symlink = devfs_symlink,
2509 .mkdir = devfs_mkdir,
2510 .rmdir = devfs_rmdir,
2511 .mknod = devfs_mknod,
2512 .setattr = devfs_notify_change,
2513};
2514
2515static struct inode_operations devfs_symlink_iops = {
2516 .readlink = generic_readlink,
2517 .follow_link = devfs_follow_link,
2518 .setattr = devfs_notify_change,
2519};
2520
2521static int devfs_fill_super(struct super_block *sb, void *data, int silent)
2522{
2523 struct inode *root_inode = NULL;
2524
2525 if (_devfs_get_root_entry() == NULL)
2526 goto out_no_root;
2527 atomic_set(&fs_info.devfsd_overrun_count, 0);
2528 init_waitqueue_head(&fs_info.devfsd_wait_queue);
2529 init_waitqueue_head(&fs_info.revalidate_wait_queue);
2530 fs_info.sb = sb;
2531 sb->s_fs_info = &fs_info;
2532 sb->s_blocksize = 1024;
2533 sb->s_blocksize_bits = 10;
2534 sb->s_magic = DEVFS_SUPER_MAGIC;
2535 sb->s_op = &devfs_sops;
2536 sb->s_time_gran = 1;
2537 if ((root_inode = _devfs_get_vfs_inode(sb, root_entry, NULL)) == NULL)
2538 goto out_no_root;
2539 sb->s_root = d_alloc_root(root_inode);
2540 if (!sb->s_root)
2541 goto out_no_root;
2542 DPRINTK(DEBUG_S_READ, "(): made devfs ptr: %p\n", sb->s_fs_info);
2543 return 0;
2544
2545 out_no_root:
2546 PRINTK("(): get root inode failed\n");
2547 if (root_inode)
2548 iput(root_inode);
2549 return -EINVAL;
2550} /* End Function devfs_fill_super */
2551
2552static int devfs_get_sb(struct file_system_type *fs_type,
2553 int flags, const char *dev_name,
2554 void *data, struct vfsmount *mnt)
2555{
2556 return get_sb_single(fs_type, flags, data, devfs_fill_super, mnt);
2557}
2558
2559static struct file_system_type devfs_fs_type = {
2560 .name = DEVFS_NAME,
2561 .get_sb = devfs_get_sb,
2562 .kill_sb = kill_anon_super,
2563};
2564
2565/* File operations for devfsd follow */
2566
2567static ssize_t devfsd_read(struct file *file, char __user *buf, size_t len,
2568 loff_t * ppos)
2569{
2570 int done = FALSE;
2571 int ival;
2572 loff_t pos, devname_offset, tlen, rpos;
2573 devfs_handle_t de;
2574 struct devfsd_buf_entry *entry;
2575 struct fs_info *fs_info = file->f_dentry->d_inode->i_sb->s_fs_info;
2576 struct devfsd_notify_struct *info = fs_info->devfsd_info;
2577 DECLARE_WAITQUEUE(wait, current);
2578
2579 /* Verify the task has grabbed the queue */
2580 if (fs_info->devfsd_task != current)
2581 return -EPERM;
2582 info->major = 0;
2583 info->minor = 0;
2584 /* Block for a new entry */
2585 set_current_state(TASK_INTERRUPTIBLE);
2586 add_wait_queue(&fs_info->devfsd_wait_queue, &wait);
2587 while (devfsd_queue_empty(fs_info)) {
2588 fs_info->devfsd_sleeping = TRUE;
2589 wake_up(&fs_info->revalidate_wait_queue);
2590 schedule();
2591 fs_info->devfsd_sleeping = FALSE;
2592 if (signal_pending(current)) {
2593 remove_wait_queue(&fs_info->devfsd_wait_queue, &wait);
2594 __set_current_state(TASK_RUNNING);
2595 return -EINTR;
2596 }
2597 set_current_state(TASK_INTERRUPTIBLE);
2598 }
2599 remove_wait_queue(&fs_info->devfsd_wait_queue, &wait);
2600 __set_current_state(TASK_RUNNING);
2601 /* Now play with the data */
2602 ival = atomic_read(&fs_info->devfsd_overrun_count);
2603 info->overrun_count = ival;
2604 entry = fs_info->devfsd_first_event;
2605 info->type = entry->type;
2606 info->mode = entry->mode;
2607 info->uid = entry->uid;
2608 info->gid = entry->gid;
2609 de = entry->de;
2610 if (S_ISCHR(de->mode) || S_ISBLK(de->mode)) {
2611 info->major = MAJOR(de->u.dev);
2612 info->minor = MINOR(de->u.dev);
2613 }
2614 pos = devfs_generate_path(de, info->devname, DEVFS_PATHLEN);
2615 if (pos < 0)
2616 return pos;
2617 info->namelen = DEVFS_PATHLEN - pos - 1;
2618 if (info->mode == 0)
2619 info->mode = de->mode;
2620 devname_offset = info->devname - (char *)info;
2621 rpos = *ppos;
2622 if (rpos < devname_offset) {
2623 /* Copy parts of the header */
2624 tlen = devname_offset - rpos;
2625 if (tlen > len)
2626 tlen = len;
2627 if (copy_to_user(buf, (char *)info + rpos, tlen)) {
2628 return -EFAULT;
2629 }
2630 rpos += tlen;
2631 buf += tlen;
2632 len -= tlen;
2633 }
2634 if ((rpos >= devname_offset) && (len > 0)) {
2635 /* Copy the name */
2636 tlen = info->namelen + 1;
2637 if (tlen > len)
2638 tlen = len;
2639 else
2640 done = TRUE;
2641 if (copy_to_user
2642 (buf, info->devname + pos + rpos - devname_offset, tlen)) {
2643 return -EFAULT;
2644 }
2645 rpos += tlen;
2646 }
2647 tlen = rpos - *ppos;
2648 if (done) {
2649 devfs_handle_t parent;
2650
2651 spin_lock(&fs_info->devfsd_buffer_lock);
2652 fs_info->devfsd_first_event = entry->next;
2653 if (entry->next == NULL)
2654 fs_info->devfsd_last_event = NULL;
2655 spin_unlock(&fs_info->devfsd_buffer_lock);
2656 for (; de != NULL; de = parent) {
2657 parent = de->parent;
2658 devfs_put(de);
2659 }
2660 kmem_cache_free(devfsd_buf_cache, entry);
2661 if (ival > 0)
2662 atomic_sub(ival, &fs_info->devfsd_overrun_count);
2663 *ppos = 0;
2664 } else
2665 *ppos = rpos;
2666 return tlen;
2667} /* End Function devfsd_read */
2668
2669static int devfsd_ioctl(struct inode *inode, struct file *file,
2670 unsigned int cmd, unsigned long arg)
2671{
2672 int ival;
2673 struct fs_info *fs_info = inode->i_sb->s_fs_info;
2674
2675 switch (cmd) {
2676 case DEVFSDIOC_GET_PROTO_REV:
2677 ival = DEVFSD_PROTOCOL_REVISION_KERNEL;
2678 if (copy_to_user((void __user *)arg, &ival, sizeof ival))
2679 return -EFAULT;
2680 break;
2681 case DEVFSDIOC_SET_EVENT_MASK:
2682 /* Ensure only one reader has access to the queue. This scheme will
2683 work even if the global kernel lock were to be removed, because it
2684 doesn't matter who gets in first, as long as only one gets it */
2685 if (fs_info->devfsd_task == NULL) {
2686 static DEFINE_SPINLOCK(lock);
2687
2688 if (!spin_trylock(&lock))
2689 return -EBUSY;
2690 if (fs_info->devfsd_task != NULL) { /* We lost the race... */
2691 spin_unlock(&lock);
2692 return -EBUSY;
2693 }
2694 fs_info->devfsd_task = current;
2695 spin_unlock(&lock);
2696 fs_info->devfsd_pgrp =
2697 (process_group(current) ==
2698 current->pid) ? process_group(current) : 0;
2699 fs_info->devfsd_file = file;
2700 fs_info->devfsd_info =
2701 kmalloc(sizeof *fs_info->devfsd_info, GFP_KERNEL);
2702 if (!fs_info->devfsd_info) {
2703 devfsd_close(inode, file);
2704 return -ENOMEM;
2705 }
2706 } else if (fs_info->devfsd_task != current)
2707 return -EBUSY;
2708 fs_info->devfsd_event_mask = arg; /* Let the masses come forth */
2709 break;
2710 case DEVFSDIOC_RELEASE_EVENT_QUEUE:
2711 if (fs_info->devfsd_file != file)
2712 return -EPERM;
2713 return devfsd_close(inode, file);
2714 /*break; */
2715#ifdef CONFIG_DEVFS_DEBUG
2716 case DEVFSDIOC_SET_DEBUG_MASK:
2717 if (copy_from_user(&ival, (void __user *)arg, sizeof ival))
2718 return -EFAULT;
2719 devfs_debug = ival;
2720 break;
2721#endif
2722 default:
2723 return -ENOIOCTLCMD;
2724 }
2725 return 0;
2726} /* End Function devfsd_ioctl */
2727
2728static int devfsd_close(struct inode *inode, struct file *file)
2729{
2730 struct devfsd_buf_entry *entry, *next;
2731 struct fs_info *fs_info = inode->i_sb->s_fs_info;
2732
2733 if (fs_info->devfsd_file != file)
2734 return 0;
2735 fs_info->devfsd_event_mask = 0;
2736 fs_info->devfsd_file = NULL;
2737 spin_lock(&fs_info->devfsd_buffer_lock);
2738 entry = fs_info->devfsd_first_event;
2739 fs_info->devfsd_first_event = NULL;
2740 fs_info->devfsd_last_event = NULL;
2741 kfree(fs_info->devfsd_info);
2742 fs_info->devfsd_info = NULL;
2743 spin_unlock(&fs_info->devfsd_buffer_lock);
2744 fs_info->devfsd_pgrp = 0;
2745 fs_info->devfsd_task = NULL;
2746 wake_up(&fs_info->revalidate_wait_queue);
2747 for (; entry; entry = next) {
2748 next = entry->next;
2749 kmem_cache_free(devfsd_buf_cache, entry);
2750 }
2751 return 0;
2752} /* End Function devfsd_close */
2753
2754#ifdef CONFIG_DEVFS_DEBUG
2755static ssize_t stat_read(struct file *file, char __user *buf, size_t len,
2756 loff_t * ppos)
2757{
2758 ssize_t num;
2759 char txt[80];
2760
2761 num = sprintf(txt, "Number of entries: %u number of bytes: %u\n",
2762 stat_num_entries, stat_num_bytes) + 1;
2763 if (*ppos >= num)
2764 return 0;
2765 if (*ppos + len > num)
2766 len = num - *ppos;
2767 if (copy_to_user(buf, txt + *ppos, len))
2768 return -EFAULT;
2769 *ppos += len;
2770 return len;
2771} /* End Function stat_read */
2772#endif
2773
2774static int __init init_devfs_fs(void)
2775{
2776 int err;
2777 int major;
2778 struct devfs_entry *devfsd;
2779#ifdef CONFIG_DEVFS_DEBUG
2780 struct devfs_entry *stat;
2781#endif
2782
2783 if (_devfs_get_root_entry() == NULL)
2784 return -ENOMEM;
2785
2786 printk(KERN_INFO "%s: %s Richard Gooch (rgooch@atnf.csiro.au)\n",
2787 DEVFS_NAME, DEVFS_VERSION);
2788 devfsd_buf_cache = kmem_cache_create("devfsd_event",
2789 sizeof(struct devfsd_buf_entry),
2790 0, 0, NULL, NULL);
2791 if (!devfsd_buf_cache)
2792 OOPS("(): unable to allocate event slab\n");
2793#ifdef CONFIG_DEVFS_DEBUG
2794 devfs_debug = devfs_debug_init;
2795 printk(KERN_INFO "%s: devfs_debug: 0x%0x\n", DEVFS_NAME, devfs_debug);
2796#endif
2797 printk(KERN_INFO "%s: boot_options: 0x%0x\n", DEVFS_NAME, boot_options);
2798
2799 /* register special device for devfsd communication */
2800 major = register_chrdev(0, "devfs", &devfs_fops);
2801 if (major < 0)
2802 return major;
2803
2804 /* And create the entry for ".devfsd" */
2805 devfsd = _devfs_alloc_entry(".devfsd", 0, S_IFCHR | S_IRUSR | S_IWUSR);
2806 if (devfsd == NULL)
2807 return -ENOMEM;
2808 devfsd->u.dev = MKDEV(major, 0);
2809 _devfs_append_entry(root_entry, devfsd, NULL);
2810
2811#ifdef CONFIG_DEVFS_DEBUG
2812 stat = _devfs_alloc_entry(".stat", 0, S_IFCHR | S_IRUGO);
2813 if (stat == NULL)
2814 return -ENOMEM;
2815 stat->u.dev = MKDEV(major, 1);
2816 _devfs_append_entry(root_entry, stat, NULL);
2817#endif
2818
2819 err = register_filesystem(&devfs_fs_type);
2820 return err;
2821} /* End Function init_devfs_fs */
2822
2823void __init mount_devfs_fs(void)
2824{
2825 int err;
2826
2827 if (!(boot_options & OPTION_MOUNT))
2828 return;
2829 err = do_mount("none", "/dev", "devfs", 0, NULL);
2830 if (err == 0)
2831 printk(KERN_INFO "Mounted devfs on /dev\n");
2832 else
2833 PRINTK("(): unable to mount devfs, err: %d\n", err);
2834} /* End Function mount_devfs_fs */
2835
2836module_init(init_devfs_fs)
diff --git a/fs/devfs/util.c b/fs/devfs/util.c
deleted file mode 100644
index db06d388c9ac..000000000000
--- a/fs/devfs/util.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/* devfs (Device FileSystem) utilities.
2
3 Copyright (C) 1999-2002 Richard Gooch
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 Richard Gooch may be reached by email at rgooch@atnf.csiro.au
20 The postal address is:
21 Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
22
23 ChangeLog
24
25 19991031 Richard Gooch <rgooch@atnf.csiro.au>
26 Created.
27 19991103 Richard Gooch <rgooch@atnf.csiro.au>
28 Created <_devfs_convert_name> and supported SCSI and IDE CD-ROMs
29 20000203 Richard Gooch <rgooch@atnf.csiro.au>
30 Changed operations pointer type to void *.
31 20000621 Richard Gooch <rgooch@atnf.csiro.au>
32 Changed interface to <devfs_register_series>.
33 20000622 Richard Gooch <rgooch@atnf.csiro.au>
34 Took account of interface change to <devfs_mk_symlink>.
35 Took account of interface change to <devfs_mk_dir>.
36 20010519 Richard Gooch <rgooch@atnf.csiro.au>
37 Documentation cleanup.
38 20010709 Richard Gooch <rgooch@atnf.csiro.au>
39 Created <devfs_*alloc_major> and <devfs_*alloc_devnum>.
40 20010710 Richard Gooch <rgooch@atnf.csiro.au>
41 Created <devfs_*alloc_unique_number>.
42 20010730 Richard Gooch <rgooch@atnf.csiro.au>
43 Documentation typo fix.
44 20010806 Richard Gooch <rgooch@atnf.csiro.au>
45 Made <block_semaphore> and <char_semaphore> private.
46 20010813 Richard Gooch <rgooch@atnf.csiro.au>
47 Fixed bug in <devfs_alloc_unique_number>: limited to 128 numbers
48 20010818 Richard Gooch <rgooch@atnf.csiro.au>
49 Updated major masks up to Linus' "no new majors" proclamation.
50 Block: were 126 now 122 free, char: were 26 now 19 free.
51 20020324 Richard Gooch <rgooch@atnf.csiro.au>
52 Fixed bug in <devfs_alloc_unique_number>: was clearing beyond
53 bitfield.
54 20020326 Richard Gooch <rgooch@atnf.csiro.au>
55 Fixed bitfield data type for <devfs_*alloc_devnum>.
56 Made major bitfield type and initialiser 64 bit safe.
57 20020413 Richard Gooch <rgooch@atnf.csiro.au>
58 Fixed shift warning on 64 bit machines.
59 20020428 Richard Gooch <rgooch@atnf.csiro.au>
60 Copied and used macro for error messages from fs/devfs/base.c
61 20021013 Richard Gooch <rgooch@atnf.csiro.au>
62 Documentation fix.
63 20030101 Adam J. Richter <adam@yggdrasil.com>
64 Eliminate DEVFS_SPECIAL_{CHR,BLK}. Use mode_t instead.
65 20030106 Christoph Hellwig <hch@infradead.org>
66 Rewrite devfs_{,de}alloc_devnum to look like C code.
67*/
68#include <linux/module.h>
69#include <linux/init.h>
70#include <linux/devfs_fs_kernel.h>
71#include <linux/slab.h>
72#include <linux/vmalloc.h>
73#include <linux/genhd.h>
74#include <linux/bitops.h>
75
76int devfs_register_tape(const char *name)
77{
78 char tname[32], dest[64];
79 static unsigned int tape_counter;
80 unsigned int n = tape_counter++;
81
82 sprintf(dest, "../%s", name);
83 sprintf(tname, "tapes/tape%u", n);
84 devfs_mk_symlink(tname, dest);
85
86 return n;
87}
88
89EXPORT_SYMBOL(devfs_register_tape);
90
91void devfs_unregister_tape(int num)
92{
93 if (num >= 0)
94 devfs_remove("tapes/tape%u", num);
95}
96
97EXPORT_SYMBOL(devfs_unregister_tape);
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index 180607f9314d..174696f9bf14 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -21,7 +21,7 @@ static sector_t _efs_bmap(struct address_space *mapping, sector_t block)
21{ 21{
22 return generic_block_bmap(mapping,block,efs_get_block); 22 return generic_block_bmap(mapping,block,efs_get_block);
23} 23}
24static struct address_space_operations efs_aops = { 24static const struct address_space_operations efs_aops = {
25 .readpage = efs_readpage, 25 .readpage = efs_readpage,
26 .sync_page = block_sync_page, 26 .sync_page = block_sync_page,
27 .bmap = _efs_bmap 27 .bmap = _efs_bmap
diff --git a/fs/efs/symlink.c b/fs/efs/symlink.c
index 3d9a350e3e7f..e249cf733a6b 100644
--- a/fs/efs/symlink.c
+++ b/fs/efs/symlink.c
@@ -53,6 +53,6 @@ fail:
53 return err; 53 return err;
54} 54}
55 55
56struct address_space_operations efs_symlink_aops = { 56const struct address_space_operations efs_symlink_aops = {
57 .readpage = efs_symlink_readpage 57 .readpage = efs_symlink_readpage
58}; 58};
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9f74a62be555..e65a019fc7a5 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -162,9 +162,9 @@ extern const struct file_operations ext2_file_operations;
162extern const struct file_operations ext2_xip_file_operations; 162extern const struct file_operations ext2_xip_file_operations;
163 163
164/* inode.c */ 164/* inode.c */
165extern struct address_space_operations ext2_aops; 165extern const struct address_space_operations ext2_aops;
166extern struct address_space_operations ext2_aops_xip; 166extern const struct address_space_operations ext2_aops_xip;
167extern struct address_space_operations ext2_nobh_aops; 167extern const struct address_space_operations ext2_nobh_aops;
168 168
169/* namei.c */ 169/* namei.c */
170extern struct inode_operations ext2_dir_inode_operations; 170extern struct inode_operations ext2_dir_inode_operations;
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 04af9c45dce2..fb4d3220eb8d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -684,7 +684,7 @@ ext2_writepages(struct address_space *mapping, struct writeback_control *wbc)
684 return mpage_writepages(mapping, wbc, ext2_get_block); 684 return mpage_writepages(mapping, wbc, ext2_get_block);
685} 685}
686 686
687struct address_space_operations ext2_aops = { 687const struct address_space_operations ext2_aops = {
688 .readpage = ext2_readpage, 688 .readpage = ext2_readpage,
689 .readpages = ext2_readpages, 689 .readpages = ext2_readpages,
690 .writepage = ext2_writepage, 690 .writepage = ext2_writepage,
@@ -697,12 +697,12 @@ struct address_space_operations ext2_aops = {
697 .migratepage = buffer_migrate_page, 697 .migratepage = buffer_migrate_page,
698}; 698};
699 699
700struct address_space_operations ext2_aops_xip = { 700const struct address_space_operations ext2_aops_xip = {
701 .bmap = ext2_bmap, 701 .bmap = ext2_bmap,
702 .get_xip_page = ext2_get_xip_page, 702 .get_xip_page = ext2_get_xip_page,
703}; 703};
704 704
705struct address_space_operations ext2_nobh_aops = { 705const struct address_space_operations ext2_nobh_aops = {
706 .readpage = ext2_readpage, 706 .readpage = ext2_readpage,
707 .readpages = ext2_readpages, 707 .readpages = ext2_readpages,
708 .writepage = ext2_nobh_writepage, 708 .writepage = ext2_nobh_writepage,
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 0321e1b9034a..f804d5e9d60c 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1698,7 +1698,7 @@ static int ext3_journalled_set_page_dirty(struct page *page)
1698 return __set_page_dirty_nobuffers(page); 1698 return __set_page_dirty_nobuffers(page);
1699} 1699}
1700 1700
1701static struct address_space_operations ext3_ordered_aops = { 1701static const struct address_space_operations ext3_ordered_aops = {
1702 .readpage = ext3_readpage, 1702 .readpage = ext3_readpage,
1703 .readpages = ext3_readpages, 1703 .readpages = ext3_readpages,
1704 .writepage = ext3_ordered_writepage, 1704 .writepage = ext3_ordered_writepage,
@@ -1712,7 +1712,7 @@ static struct address_space_operations ext3_ordered_aops = {
1712 .migratepage = buffer_migrate_page, 1712 .migratepage = buffer_migrate_page,
1713}; 1713};
1714 1714
1715static struct address_space_operations ext3_writeback_aops = { 1715static const struct address_space_operations ext3_writeback_aops = {
1716 .readpage = ext3_readpage, 1716 .readpage = ext3_readpage,
1717 .readpages = ext3_readpages, 1717 .readpages = ext3_readpages,
1718 .writepage = ext3_writeback_writepage, 1718 .writepage = ext3_writeback_writepage,
@@ -1726,7 +1726,7 @@ static struct address_space_operations ext3_writeback_aops = {
1726 .migratepage = buffer_migrate_page, 1726 .migratepage = buffer_migrate_page,
1727}; 1727};
1728 1728
1729static struct address_space_operations ext3_journalled_aops = { 1729static const struct address_space_operations ext3_journalled_aops = {
1730 .readpage = ext3_readpage, 1730 .readpage = ext3_readpage,
1731 .readpages = ext3_readpages, 1731 .readpages = ext3_readpages,
1732 .writepage = ext3_journalled_writepage, 1732 .writepage = ext3_journalled_writepage,
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 7c35d582ec10..31b7174176ba 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -196,7 +196,7 @@ static sector_t _fat_bmap(struct address_space *mapping, sector_t block)
196 return generic_block_bmap(mapping, block, fat_get_block); 196 return generic_block_bmap(mapping, block, fat_get_block);
197} 197}
198 198
199static struct address_space_operations fat_aops = { 199static const struct address_space_operations fat_aops = {
200 .readpage = fat_readpage, 200 .readpage = fat_readpage,
201 .readpages = fat_readpages, 201 .readpages = fat_readpages,
202 .writepage = fat_writepage, 202 .writepage = fat_writepage,
diff --git a/fs/freevxfs/vxfs_immed.c b/fs/freevxfs/vxfs_immed.c
index 6f5df1700e95..4e25f3fbed86 100644
--- a/fs/freevxfs/vxfs_immed.c
+++ b/fs/freevxfs/vxfs_immed.c
@@ -56,7 +56,7 @@ struct inode_operations vxfs_immed_symlink_iops = {
56/* 56/*
57 * Adress space operations for immed files and directories. 57 * Adress space operations for immed files and directories.
58 */ 58 */
59struct address_space_operations vxfs_immed_aops = { 59const struct address_space_operations vxfs_immed_aops = {
60 .readpage = vxfs_immed_readpage, 60 .readpage = vxfs_immed_readpage,
61}; 61};
62 62
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index f544aae9169f..ca6a39714771 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -41,8 +41,8 @@
41#include "vxfs_extern.h" 41#include "vxfs_extern.h"
42 42
43 43
44extern struct address_space_operations vxfs_aops; 44extern const struct address_space_operations vxfs_aops;
45extern struct address_space_operations vxfs_immed_aops; 45extern const struct address_space_operations vxfs_immed_aops;
46 46
47extern struct inode_operations vxfs_immed_symlink_iops; 47extern struct inode_operations vxfs_immed_symlink_iops;
48 48
@@ -295,7 +295,7 @@ vxfs_read_inode(struct inode *ip)
295{ 295{
296 struct super_block *sbp = ip->i_sb; 296 struct super_block *sbp = ip->i_sb;
297 struct vxfs_inode_info *vip; 297 struct vxfs_inode_info *vip;
298 struct address_space_operations *aops; 298 const struct address_space_operations *aops;
299 ino_t ino = ip->i_ino; 299 ino_t ino = ip->i_ino;
300 300
301 if (!(vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist))) 301 if (!(vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist)))
diff --git a/fs/freevxfs/vxfs_subr.c b/fs/freevxfs/vxfs_subr.c
index c1be118fc067..decac62efe57 100644
--- a/fs/freevxfs/vxfs_subr.c
+++ b/fs/freevxfs/vxfs_subr.c
@@ -42,7 +42,7 @@
42static int vxfs_readpage(struct file *, struct page *); 42static int vxfs_readpage(struct file *, struct page *);
43static sector_t vxfs_bmap(struct address_space *, sector_t); 43static sector_t vxfs_bmap(struct address_space *, sector_t);
44 44
45struct address_space_operations vxfs_aops = { 45const struct address_space_operations vxfs_aops = {
46 .readpage = vxfs_readpage, 46 .readpage = vxfs_readpage,
47 .bmap = vxfs_bmap, 47 .bmap = vxfs_bmap,
48 .sync_page = block_sync_page, 48 .sync_page = block_sync_page,
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 28aa81eae2cc..63614ed16336 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -770,7 +770,7 @@ static const struct file_operations fuse_direct_io_file_operations = {
770 /* no mmap and sendfile */ 770 /* no mmap and sendfile */
771}; 771};
772 772
773static struct address_space_operations fuse_file_aops = { 773static const struct address_space_operations fuse_file_aops = {
774 .readpage = fuse_readpage, 774 .readpage = fuse_readpage,
775 .prepare_write = fuse_prepare_write, 775 .prepare_write = fuse_prepare_write,
776 .commit_write = fuse_commit_write, 776 .commit_write = fuse_commit_write,
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 3ed8663a8db1..735332dfd1b8 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -182,8 +182,8 @@ extern void hfs_file_truncate(struct inode *);
182extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int); 182extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
183 183
184/* inode.c */ 184/* inode.c */
185extern struct address_space_operations hfs_aops; 185extern const struct address_space_operations hfs_aops;
186extern struct address_space_operations hfs_btree_aops; 186extern const struct address_space_operations hfs_btree_aops;
187 187
188extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int); 188extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int);
189extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *); 189extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 2d4ced22201b..315cf44a90b2 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -114,7 +114,7 @@ static int hfs_writepages(struct address_space *mapping,
114 return mpage_writepages(mapping, wbc, hfs_get_block); 114 return mpage_writepages(mapping, wbc, hfs_get_block);
115} 115}
116 116
117struct address_space_operations hfs_btree_aops = { 117const struct address_space_operations hfs_btree_aops = {
118 .readpage = hfs_readpage, 118 .readpage = hfs_readpage,
119 .writepage = hfs_writepage, 119 .writepage = hfs_writepage,
120 .sync_page = block_sync_page, 120 .sync_page = block_sync_page,
@@ -124,7 +124,7 @@ struct address_space_operations hfs_btree_aops = {
124 .releasepage = hfs_releasepage, 124 .releasepage = hfs_releasepage,
125}; 125};
126 126
127struct address_space_operations hfs_aops = { 127const struct address_space_operations hfs_aops = {
128 .readpage = hfs_readpage, 128 .readpage = hfs_readpage,
129 .writepage = hfs_writepage, 129 .writepage = hfs_writepage,
130 .sync_page = block_sync_page, 130 .sync_page = block_sync_page,
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 7ae393637a0c..8a1ca5ef7ada 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -323,8 +323,8 @@ int hfsplus_file_extend(struct inode *);
323void hfsplus_file_truncate(struct inode *); 323void hfsplus_file_truncate(struct inode *);
324 324
325/* inode.c */ 325/* inode.c */
326extern struct address_space_operations hfsplus_aops; 326extern const struct address_space_operations hfsplus_aops;
327extern struct address_space_operations hfsplus_btree_aops; 327extern const struct address_space_operations hfsplus_btree_aops;
328 328
329void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *); 329void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *);
330void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); 330void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index acf66dba3e01..924ecdef8091 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -109,7 +109,7 @@ static int hfsplus_writepages(struct address_space *mapping,
109 return mpage_writepages(mapping, wbc, hfsplus_get_block); 109 return mpage_writepages(mapping, wbc, hfsplus_get_block);
110} 110}
111 111
112struct address_space_operations hfsplus_btree_aops = { 112const struct address_space_operations hfsplus_btree_aops = {
113 .readpage = hfsplus_readpage, 113 .readpage = hfsplus_readpage,
114 .writepage = hfsplus_writepage, 114 .writepage = hfsplus_writepage,
115 .sync_page = block_sync_page, 115 .sync_page = block_sync_page,
@@ -119,7 +119,7 @@ struct address_space_operations hfsplus_btree_aops = {
119 .releasepage = hfsplus_releasepage, 119 .releasepage = hfsplus_releasepage,
120}; 120};
121 121
122struct address_space_operations hfsplus_aops = { 122const struct address_space_operations hfsplus_aops = {
123 .readpage = hfsplus_readpage, 123 .readpage = hfsplus_readpage,
124 .writepage = hfsplus_writepage, 124 .writepage = hfsplus_writepage,
125 .sync_page = block_sync_page, 125 .sync_page = block_sync_page,
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 8e0d37743e7c..b82e3d9c8790 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -54,7 +54,7 @@ static int append = 0;
54 54
55static struct inode_operations hostfs_iops; 55static struct inode_operations hostfs_iops;
56static struct inode_operations hostfs_dir_iops; 56static struct inode_operations hostfs_dir_iops;
57static struct address_space_operations hostfs_link_aops; 57static const struct address_space_operations hostfs_link_aops;
58 58
59#ifndef MODULE 59#ifndef MODULE
60static int __init hostfs_args(char *options, int *add) 60static int __init hostfs_args(char *options, int *add)
@@ -518,7 +518,7 @@ int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
518 return(err); 518 return(err);
519} 519}
520 520
521static struct address_space_operations hostfs_aops = { 521static const struct address_space_operations hostfs_aops = {
522 .writepage = hostfs_writepage, 522 .writepage = hostfs_writepage,
523 .readpage = hostfs_readpage, 523 .readpage = hostfs_readpage,
524 .set_page_dirty = __set_page_dirty_nobuffers, 524 .set_page_dirty = __set_page_dirty_nobuffers,
@@ -935,7 +935,7 @@ int hostfs_link_readpage(struct file *file, struct page *page)
935 return(err); 935 return(err);
936} 936}
937 937
938static struct address_space_operations hostfs_link_aops = { 938static const struct address_space_operations hostfs_link_aops = {
939 .readpage = hostfs_link_readpage, 939 .readpage = hostfs_link_readpage,
940}; 940};
941 941
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index d3b9fffe45a1..d9eb19b7b8ae 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -99,7 +99,7 @@ static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block)
99{ 99{
100 return generic_block_bmap(mapping,block,hpfs_get_block); 100 return generic_block_bmap(mapping,block,hpfs_get_block);
101} 101}
102struct address_space_operations hpfs_aops = { 102const struct address_space_operations hpfs_aops = {
103 .readpage = hpfs_readpage, 103 .readpage = hpfs_readpage,
104 .writepage = hpfs_writepage, 104 .writepage = hpfs_writepage,
105 .sync_page = block_sync_page, 105 .sync_page = block_sync_page,
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 29b7a3e55173..f687d54ed442 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -268,7 +268,7 @@ void hpfs_set_ea(struct inode *, struct fnode *, char *, char *, int);
268int hpfs_file_fsync(struct file *, struct dentry *, int); 268int hpfs_file_fsync(struct file *, struct dentry *, int);
269extern const struct file_operations hpfs_file_ops; 269extern const struct file_operations hpfs_file_ops;
270extern struct inode_operations hpfs_file_iops; 270extern struct inode_operations hpfs_file_iops;
271extern struct address_space_operations hpfs_aops; 271extern const struct address_space_operations hpfs_aops;
272 272
273/* inode.c */ 273/* inode.c */
274 274
@@ -304,7 +304,7 @@ void hpfs_decide_conv(struct inode *, unsigned char *, unsigned);
304/* namei.c */ 304/* namei.c */
305 305
306extern struct inode_operations hpfs_dir_iops; 306extern struct inode_operations hpfs_dir_iops;
307extern struct address_space_operations hpfs_symlink_aops; 307extern const struct address_space_operations hpfs_symlink_aops;
308 308
309static inline struct hpfs_inode_info *hpfs_i(struct inode *inode) 309static inline struct hpfs_inode_info *hpfs_i(struct inode *inode)
310{ 310{
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index a03abb12c610..59e7dc182a0c 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -538,7 +538,7 @@ fail:
538 return err; 538 return err;
539} 539}
540 540
541struct address_space_operations hpfs_symlink_aops = { 541const struct address_space_operations hpfs_symlink_aops = {
542 .readpage = hpfs_symlink_readpage 542 .readpage = hpfs_symlink_readpage
543}; 543};
544 544
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index e6410d8edd0e..6449cb697967 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -34,7 +34,7 @@
34#define HUGETLBFS_MAGIC 0x958458f6 34#define HUGETLBFS_MAGIC 0x958458f6
35 35
36static struct super_operations hugetlbfs_ops; 36static struct super_operations hugetlbfs_ops;
37static struct address_space_operations hugetlbfs_aops; 37static const struct address_space_operations hugetlbfs_aops;
38const struct file_operations hugetlbfs_file_operations; 38const struct file_operations hugetlbfs_file_operations;
39static struct inode_operations hugetlbfs_dir_inode_operations; 39static struct inode_operations hugetlbfs_dir_inode_operations;
40static struct inode_operations hugetlbfs_inode_operations; 40static struct inode_operations hugetlbfs_inode_operations;
@@ -547,7 +547,7 @@ static void hugetlbfs_destroy_inode(struct inode *inode)
547 kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); 547 kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode));
548} 548}
549 549
550static struct address_space_operations hugetlbfs_aops = { 550static const struct address_space_operations hugetlbfs_aops = {
551 .readpage = hugetlbfs_readpage, 551 .readpage = hugetlbfs_readpage,
552 .prepare_write = hugetlbfs_prepare_write, 552 .prepare_write = hugetlbfs_prepare_write,
553 .commit_write = hugetlbfs_commit_write, 553 .commit_write = hugetlbfs_commit_write,
diff --git a/fs/inode.c b/fs/inode.c
index 3a2446a27d2c..f42961eb983b 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -102,7 +102,7 @@ static kmem_cache_t * inode_cachep __read_mostly;
102 102
103static struct inode *alloc_inode(struct super_block *sb) 103static struct inode *alloc_inode(struct super_block *sb)
104{ 104{
105 static struct address_space_operations empty_aops; 105 static const struct address_space_operations empty_aops;
106 static struct inode_operations empty_iops; 106 static struct inode_operations empty_iops;
107 static const struct file_operations empty_fops; 107 static const struct file_operations empty_fops;
108 struct inode *inode; 108 struct inode *inode;
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index 4917315db732..3a39158cca96 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -312,7 +312,7 @@ eio:
312 return err; 312 return err;
313} 313}
314 314
315struct address_space_operations zisofs_aops = { 315const struct address_space_operations zisofs_aops = {
316 .readpage = zisofs_readpage, 316 .readpage = zisofs_readpage,
317 /* No sync_page operation supported? */ 317 /* No sync_page operation supported? */
318 /* No bmap operation supported */ 318 /* No bmap operation supported */
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 3f9c8ba1fa1f..bb11c7fb4019 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1054,7 +1054,7 @@ static sector_t _isofs_bmap(struct address_space *mapping, sector_t block)
1054 return generic_block_bmap(mapping,block,isofs_get_block); 1054 return generic_block_bmap(mapping,block,isofs_get_block);
1055} 1055}
1056 1056
1057static struct address_space_operations isofs_aops = { 1057static const struct address_space_operations isofs_aops = {
1058 .readpage = isofs_readpage, 1058 .readpage = isofs_readpage,
1059 .sync_page = block_sync_page, 1059 .sync_page = block_sync_page,
1060 .bmap = _isofs_bmap 1060 .bmap = _isofs_bmap
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index b87ba066f5e7..e6308c8b5735 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -176,5 +176,5 @@ isofs_normalize_block_and_offset(struct iso_directory_record* de,
176 176
177extern struct inode_operations isofs_dir_inode_operations; 177extern struct inode_operations isofs_dir_inode_operations;
178extern const struct file_operations isofs_dir_operations; 178extern const struct file_operations isofs_dir_operations;
179extern struct address_space_operations isofs_symlink_aops; 179extern const struct address_space_operations isofs_symlink_aops;
180extern struct export_operations isofs_export_ops; 180extern struct export_operations isofs_export_ops;
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 4326cb47f8fa..f3a1db3098de 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -754,6 +754,6 @@ error:
754 return -EIO; 754 return -EIO;
755} 755}
756 756
757struct address_space_operations isofs_symlink_aops = { 757const struct address_space_operations isofs_symlink_aops = {
758 .readpage = rock_ridge_symlink_readpage 758 .readpage = rock_ridge_symlink_readpage
759}; 759};
diff --git a/fs/isofs/zisofs.h b/fs/isofs/zisofs.h
index d78485d101c2..273795709155 100644
--- a/fs/isofs/zisofs.h
+++ b/fs/isofs/zisofs.h
@@ -15,7 +15,7 @@
15 */ 15 */
16 16
17#ifdef CONFIG_ZISOFS 17#ifdef CONFIG_ZISOFS
18extern struct address_space_operations zisofs_aops; 18extern const struct address_space_operations zisofs_aops;
19extern int __init zisofs_init(void); 19extern int __init zisofs_init(void);
20extern void zisofs_cleanup(void); 20extern void zisofs_cleanup(void);
21#endif 21#endif
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 7f96b5cb6781..8c9b28dff119 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -34,6 +34,7 @@
34#include <linux/suspend.h> 34#include <linux/suspend.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/poison.h>
37#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
38 39
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
@@ -1675,7 +1676,7 @@ static void journal_free_journal_head(struct journal_head *jh)
1675{ 1676{
1676#ifdef CONFIG_JBD_DEBUG 1677#ifdef CONFIG_JBD_DEBUG
1677 atomic_dec(&nr_journal_heads); 1678 atomic_dec(&nr_journal_heads);
1678 memset(jh, 0x5b, sizeof(*jh)); 1679 memset(jh, JBD_POISON_FREE, sizeof(*jh));
1679#endif 1680#endif
1680 kmem_cache_free(journal_head_cache, jh); 1681 kmem_cache_free(journal_head_cache, jh);
1681} 1682}
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 9e46ea6da752..93068697a9bf 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -59,7 +59,7 @@ static const struct file_operations jffs_file_operations;
59static struct inode_operations jffs_file_inode_operations; 59static struct inode_operations jffs_file_inode_operations;
60static const struct file_operations jffs_dir_operations; 60static const struct file_operations jffs_dir_operations;
61static struct inode_operations jffs_dir_inode_operations; 61static struct inode_operations jffs_dir_inode_operations;
62static struct address_space_operations jffs_address_operations; 62static const struct address_space_operations jffs_address_operations;
63 63
64kmem_cache_t *node_cache = NULL; 64kmem_cache_t *node_cache = NULL;
65kmem_cache_t *fm_cache = NULL; 65kmem_cache_t *fm_cache = NULL;
@@ -1614,7 +1614,7 @@ jffs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1614} /* jffs_ioctl() */ 1614} /* jffs_ioctl() */
1615 1615
1616 1616
1617static struct address_space_operations jffs_address_operations = { 1617static const struct address_space_operations jffs_address_operations = {
1618 .readpage = jffs_readpage, 1618 .readpage = jffs_readpage,
1619 .prepare_write = jffs_prepare_write, 1619 .prepare_write = jffs_prepare_write,
1620 .commit_write = jffs_commit_write, 1620 .commit_write = jffs_commit_write,
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 320dd48b834e..9c2077e7e081 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -267,6 +267,8 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
267 } 267 }
268 268
269 rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0); 269 rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0);
270 if (!value && rc == -ENODATA)
271 rc = 0;
270 if (value) 272 if (value)
271 kfree(value); 273 kfree(value);
272 if (!rc) { 274 if (!rc) {
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index b8886f048eaa..ad0121088dde 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -225,7 +225,6 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
225 at the end of the linked list. Stash it and continue 225 at the end of the linked list. Stash it and continue
226 from the beginning of the list */ 226 from the beginning of the list */
227 ic = (struct jffs2_inode_cache *)(*prev); 227 ic = (struct jffs2_inode_cache *)(*prev);
228 BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
229 prev = &ic->nodes; 228 prev = &ic->nodes;
230 continue; 229 continue;
231 } 230 }
@@ -249,7 +248,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
249 248
250 /* PARANOIA */ 249 /* PARANOIA */
251 if (!ic) { 250 if (!ic) {
252 printk(KERN_WARNING "inode_cache not found in remove_node_refs()!!\n"); 251 JFFS2_WARNING("inode_cache/xattr_datum/xattr_ref"
252 " not found in remove_node_refs()!!\n");
253 return; 253 return;
254 } 254 }
255 255
@@ -274,8 +274,19 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
274 printk("\n"); 274 printk("\n");
275 }); 275 });
276 276
277 if (ic->nodes == (void *)ic && ic->nlink == 0) 277 switch (ic->class) {
278 jffs2_del_ino_cache(c, ic); 278#ifdef CONFIG_JFFS2_FS_XATTR
279 case RAWNODE_CLASS_XATTR_DATUM:
280 jffs2_release_xattr_datum(c, (struct jffs2_xattr_datum *)ic);
281 break;
282 case RAWNODE_CLASS_XATTR_REF:
283 jffs2_release_xattr_ref(c, (struct jffs2_xattr_ref *)ic);
284 break;
285#endif
286 default:
287 if (ic->nodes == (void *)ic && ic->nlink == 0)
288 jffs2_del_ino_cache(c, ic);
289 }
279} 290}
280 291
281void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) 292void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index bb8844f40e48..3ed6e3e120b6 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -62,7 +62,7 @@ struct inode_operations jffs2_file_inode_operations =
62 .removexattr = jffs2_removexattr 62 .removexattr = jffs2_removexattr
63}; 63};
64 64
65struct address_space_operations jffs2_file_address_operations = 65const struct address_space_operations jffs2_file_address_operations =
66{ 66{
67 .readpage = jffs2_readpage, 67 .readpage = jffs2_readpage,
68 .prepare_write =jffs2_prepare_write, 68 .prepare_write =jffs2_prepare_write,
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 2900ec3ec3af..97caa77d60cf 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -227,8 +227,6 @@ void jffs2_clear_inode (struct inode *inode)
227 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 227 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
228 228
229 D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); 229 D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));
230
231 jffs2_xattr_delete_inode(c, f->inocache);
232 jffs2_do_clear_inode(c, f); 230 jffs2_do_clear_inode(c, f);
233} 231}
234 232
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 477c526d638b..daff3341ff92 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -165,6 +165,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
165 D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink zero\n", 165 D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink zero\n",
166 ic->ino)); 166 ic->ino));
167 spin_unlock(&c->inocache_lock); 167 spin_unlock(&c->inocache_lock);
168 jffs2_xattr_delete_inode(c, ic);
168 continue; 169 continue;
169 } 170 }
170 switch(ic->state) { 171 switch(ic->state) {
@@ -275,13 +276,12 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
275 * We can decide whether this node is inode or xattr by ic->class. */ 276 * We can decide whether this node is inode or xattr by ic->class. */
276 if (ic->class == RAWNODE_CLASS_XATTR_DATUM 277 if (ic->class == RAWNODE_CLASS_XATTR_DATUM
277 || ic->class == RAWNODE_CLASS_XATTR_REF) { 278 || ic->class == RAWNODE_CLASS_XATTR_REF) {
278 BUG_ON(raw->next_in_ino != (void *)ic);
279 spin_unlock(&c->erase_completion_lock); 279 spin_unlock(&c->erase_completion_lock);
280 280
281 if (ic->class == RAWNODE_CLASS_XATTR_DATUM) { 281 if (ic->class == RAWNODE_CLASS_XATTR_DATUM) {
282 ret = jffs2_garbage_collect_xattr_datum(c, (struct jffs2_xattr_datum *)ic); 282 ret = jffs2_garbage_collect_xattr_datum(c, (struct jffs2_xattr_datum *)ic, raw);
283 } else { 283 } else {
284 ret = jffs2_garbage_collect_xattr_ref(c, (struct jffs2_xattr_ref *)ic); 284 ret = jffs2_garbage_collect_xattr_ref(c, (struct jffs2_xattr_ref *)ic, raw);
285 } 285 }
286 goto release_sem; 286 goto release_sem;
287 } 287 }
diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h
index 935fec1b1201..b98594992eed 100644
--- a/fs/jffs2/jffs2_fs_sb.h
+++ b/fs/jffs2/jffs2_fs_sb.h
@@ -119,8 +119,11 @@ struct jffs2_sb_info {
119#ifdef CONFIG_JFFS2_FS_XATTR 119#ifdef CONFIG_JFFS2_FS_XATTR
120#define XATTRINDEX_HASHSIZE (57) 120#define XATTRINDEX_HASHSIZE (57)
121 uint32_t highest_xid; 121 uint32_t highest_xid;
122 uint32_t highest_xseqno;
122 struct list_head xattrindex[XATTRINDEX_HASHSIZE]; 123 struct list_head xattrindex[XATTRINDEX_HASHSIZE];
123 struct list_head xattr_unchecked; 124 struct list_head xattr_unchecked;
125 struct list_head xattr_dead_list;
126 struct jffs2_xattr_ref *xref_dead_list;
124 struct jffs2_xattr_ref *xref_temp; 127 struct jffs2_xattr_ref *xref_temp;
125 struct rw_semaphore xattr_sem; 128 struct rw_semaphore xattr_sem;
126 uint32_t xdatum_mem_usage; 129 uint32_t xdatum_mem_usage;
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
index 4889d0700c0e..8310c95478e9 100644
--- a/fs/jffs2/malloc.c
+++ b/fs/jffs2/malloc.c
@@ -291,6 +291,7 @@ struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void)
291 291
292 memset(xd, 0, sizeof(struct jffs2_xattr_datum)); 292 memset(xd, 0, sizeof(struct jffs2_xattr_datum));
293 xd->class = RAWNODE_CLASS_XATTR_DATUM; 293 xd->class = RAWNODE_CLASS_XATTR_DATUM;
294 xd->node = (void *)xd;
294 INIT_LIST_HEAD(&xd->xindex); 295 INIT_LIST_HEAD(&xd->xindex);
295 return xd; 296 return xd;
296} 297}
@@ -309,6 +310,7 @@ struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void)
309 310
310 memset(ref, 0, sizeof(struct jffs2_xattr_ref)); 311 memset(ref, 0, sizeof(struct jffs2_xattr_ref));
311 ref->class = RAWNODE_CLASS_XATTR_REF; 312 ref->class = RAWNODE_CLASS_XATTR_REF;
313 ref->node = (void *)ref;
312 return ref; 314 return ref;
313} 315}
314 316
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 927dfe42ba76..7675b33396c7 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -906,6 +906,9 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
906{ 906{
907 struct jffs2_inode_cache **prev; 907 struct jffs2_inode_cache **prev;
908 908
909#ifdef CONFIG_JFFS2_FS_XATTR
910 BUG_ON(old->xref);
911#endif
909 dbg_inocache("del %p (ino #%u)\n", old, old->ino); 912 dbg_inocache("del %p (ino #%u)\n", old, old->ino);
910 spin_lock(&c->inocache_lock); 913 spin_lock(&c->inocache_lock);
911 914
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index ac0c350ed7d7..d88376992ed9 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -683,19 +683,26 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
683 spin_lock(&c->erase_completion_lock); 683 spin_lock(&c->erase_completion_lock);
684 684
685 ic = jffs2_raw_ref_to_ic(ref); 685 ic = jffs2_raw_ref_to_ic(ref);
686 /* It seems we should never call jffs2_mark_node_obsolete() for
687 XATTR nodes.... yet. Make sure we notice if/when we change
688 that :) */
689 BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
690 for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino)) 686 for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
691 ; 687 ;
692 688
693 *p = ref->next_in_ino; 689 *p = ref->next_in_ino;
694 ref->next_in_ino = NULL; 690 ref->next_in_ino = NULL;
695 691
696 if (ic->nodes == (void *)ic && ic->nlink == 0) 692 switch (ic->class) {
697 jffs2_del_ino_cache(c, ic); 693#ifdef CONFIG_JFFS2_FS_XATTR
698 694 case RAWNODE_CLASS_XATTR_DATUM:
695 jffs2_release_xattr_datum(c, (struct jffs2_xattr_datum *)ic);
696 break;
697 case RAWNODE_CLASS_XATTR_REF:
698 jffs2_release_xattr_ref(c, (struct jffs2_xattr_ref *)ic);
699 break;
700#endif
701 default:
702 if (ic->nodes == (void *)ic && ic->nlink == 0)
703 jffs2_del_ino_cache(c, ic);
704 break;
705 }
699 spin_unlock(&c->erase_completion_lock); 706 spin_unlock(&c->erase_completion_lock);
700 } 707 }
701 708
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 6b5223565405..9f41fc01a371 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -158,7 +158,7 @@ extern struct inode_operations jffs2_dir_inode_operations;
158/* file.c */ 158/* file.c */
159extern const struct file_operations jffs2_file_operations; 159extern const struct file_operations jffs2_file_operations;
160extern struct inode_operations jffs2_file_inode_operations; 160extern struct inode_operations jffs2_file_inode_operations;
161extern struct address_space_operations jffs2_file_address_operations; 161extern const struct address_space_operations jffs2_file_address_operations;
162int jffs2_fsync(struct file *, struct dentry *, int); 162int jffs2_fsync(struct file *, struct dentry *, int);
163int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg); 163int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg);
164 164
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 5fec012b02ed..cc1899268c43 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -968,6 +968,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
968 struct jffs2_full_dirent *fd, *fds; 968 struct jffs2_full_dirent *fd, *fds;
969 int deleted; 969 int deleted;
970 970
971 jffs2_xattr_delete_inode(c, f->inocache);
971 down(&f->sem); 972 down(&f->sem);
972 deleted = f->inocache && !f->inocache->nlink; 973 deleted = f->inocache && !f->inocache->nlink;
973 974
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 61618080b86f..2bfdc33752d3 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -317,20 +317,23 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
317 struct jffs2_summary *s) 317 struct jffs2_summary *s)
318{ 318{
319 struct jffs2_xattr_datum *xd; 319 struct jffs2_xattr_datum *xd;
320 uint32_t totlen, crc; 320 uint32_t xid, version, totlen, crc;
321 int err; 321 int err;
322 322
323 crc = crc32(0, rx, sizeof(struct jffs2_raw_xattr) - 4); 323 crc = crc32(0, rx, sizeof(struct jffs2_raw_xattr) - 4);
324 if (crc != je32_to_cpu(rx->node_crc)) { 324 if (crc != je32_to_cpu(rx->node_crc)) {
325 if (je32_to_cpu(rx->node_crc) != 0xffffffff) 325 JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
326 JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", 326 ofs, je32_to_cpu(rx->node_crc), crc);
327 ofs, je32_to_cpu(rx->node_crc), crc);
328 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) 327 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen))))
329 return err; 328 return err;
330 return 0; 329 return 0;
331 } 330 }
332 331
333 totlen = PAD(sizeof(*rx) + rx->name_len + 1 + je16_to_cpu(rx->value_len)); 332 xid = je32_to_cpu(rx->xid);
333 version = je32_to_cpu(rx->version);
334
335 totlen = PAD(sizeof(struct jffs2_raw_xattr)
336 + rx->name_len + 1 + je16_to_cpu(rx->value_len));
334 if (totlen != je32_to_cpu(rx->totlen)) { 337 if (totlen != je32_to_cpu(rx->totlen)) {
335 JFFS2_WARNING("node length mismatch at %#08x, read=%u, calc=%u\n", 338 JFFS2_WARNING("node length mismatch at %#08x, read=%u, calc=%u\n",
336 ofs, je32_to_cpu(rx->totlen), totlen); 339 ofs, je32_to_cpu(rx->totlen), totlen);
@@ -339,22 +342,24 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
339 return 0; 342 return 0;
340 } 343 }
341 344
342 xd = jffs2_setup_xattr_datum(c, je32_to_cpu(rx->xid), je32_to_cpu(rx->version)); 345 xd = jffs2_setup_xattr_datum(c, xid, version);
343 if (IS_ERR(xd)) { 346 if (IS_ERR(xd))
344 if (PTR_ERR(xd) == -EEXIST) {
345 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rx->totlen)))))
346 return err;
347 return 0;
348 }
349 return PTR_ERR(xd); 347 return PTR_ERR(xd);
350 }
351 xd->xprefix = rx->xprefix;
352 xd->name_len = rx->name_len;
353 xd->value_len = je16_to_cpu(rx->value_len);
354 xd->data_crc = je32_to_cpu(rx->data_crc);
355 348
356 xd->node = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL); 349 if (xd->version > version) {
357 /* FIXME */ xd->node->next_in_ino = (void *)xd; 350 struct jffs2_raw_node_ref *raw
351 = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL);
352 raw->next_in_ino = xd->node->next_in_ino;
353 xd->node->next_in_ino = raw;
354 } else {
355 xd->version = version;
356 xd->xprefix = rx->xprefix;
357 xd->name_len = rx->name_len;
358 xd->value_len = je16_to_cpu(rx->value_len);
359 xd->data_crc = je32_to_cpu(rx->data_crc);
360
361 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, (void *)xd);
362 }
358 363
359 if (jffs2_sum_active()) 364 if (jffs2_sum_active())
360 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); 365 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset);
@@ -373,9 +378,8 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
373 378
374 crc = crc32(0, rr, sizeof(*rr) - 4); 379 crc = crc32(0, rr, sizeof(*rr) - 4);
375 if (crc != je32_to_cpu(rr->node_crc)) { 380 if (crc != je32_to_cpu(rr->node_crc)) {
376 if (je32_to_cpu(rr->node_crc) != 0xffffffff) 381 JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
377 JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", 382 ofs, je32_to_cpu(rr->node_crc), crc);
378 ofs, je32_to_cpu(rr->node_crc), crc);
379 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen))))) 383 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen)))))
380 return err; 384 return err;
381 return 0; 385 return 0;
@@ -395,6 +399,7 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
395 return -ENOMEM; 399 return -ENOMEM;
396 400
397 /* BEFORE jffs2_build_xattr_subsystem() called, 401 /* BEFORE jffs2_build_xattr_subsystem() called,
402 * and AFTER xattr_ref is marked as a dead xref,
398 * ref->xid is used to store 32bit xid, xd is not used 403 * ref->xid is used to store 32bit xid, xd is not used
399 * ref->ino is used to store 32bit inode-number, ic is not used 404 * ref->ino is used to store 32bit inode-number, ic is not used
400 * Thoes variables are declared as union, thus using those 405 * Thoes variables are declared as union, thus using those
@@ -404,11 +409,13 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
404 */ 409 */
405 ref->ino = je32_to_cpu(rr->ino); 410 ref->ino = je32_to_cpu(rr->ino);
406 ref->xid = je32_to_cpu(rr->xid); 411 ref->xid = je32_to_cpu(rr->xid);
412 ref->xseqno = je32_to_cpu(rr->xseqno);
413 if (ref->xseqno > c->highest_xseqno)
414 c->highest_xseqno = (ref->xseqno & ~XREF_DELETE_MARKER);
407 ref->next = c->xref_temp; 415 ref->next = c->xref_temp;
408 c->xref_temp = ref; 416 c->xref_temp = ref;
409 417
410 ref->node = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), NULL); 418 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), (void *)ref);
411 /* FIXME */ ref->node->next_in_ino = (void *)ref;
412 419
413 if (jffs2_sum_active()) 420 if (jffs2_sum_active())
414 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); 421 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index be1acc3dad97..c19bd476e8ec 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -5,7 +5,7 @@
5 * Zoltan Sogor <weth@inf.u-szeged.hu>, 5 * Zoltan Sogor <weth@inf.u-szeged.hu>,
6 * Patrik Kluba <pajko@halom.u-szeged.hu>, 6 * Patrik Kluba <pajko@halom.u-szeged.hu>,
7 * University of Szeged, Hungary 7 * University of Szeged, Hungary
8 * 2005 KaiGai Kohei <kaigai@ak.jp.nec.com> 8 * 2006 KaiGai Kohei <kaigai@ak.jp.nec.com>
9 * 9 *
10 * For licensing information, see the file 'LICENCE' in this directory. 10 * For licensing information, see the file 'LICENCE' in this directory.
11 * 11 *
@@ -310,8 +310,6 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
310#ifdef CONFIG_JFFS2_FS_XATTR 310#ifdef CONFIG_JFFS2_FS_XATTR
311 case JFFS2_NODETYPE_XATTR: { 311 case JFFS2_NODETYPE_XATTR: {
312 struct jffs2_sum_xattr_mem *temp; 312 struct jffs2_sum_xattr_mem *temp;
313 if (je32_to_cpu(node->x.version) == 0xffffffff)
314 return 0;
315 temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL); 313 temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
316 if (!temp) 314 if (!temp)
317 goto no_mem; 315 goto no_mem;
@@ -327,10 +325,6 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
327 } 325 }
328 case JFFS2_NODETYPE_XREF: { 326 case JFFS2_NODETYPE_XREF: {
329 struct jffs2_sum_xref_mem *temp; 327 struct jffs2_sum_xref_mem *temp;
330
331 if (je32_to_cpu(node->r.ino) == 0xffffffff
332 && je32_to_cpu(node->r.xid) == 0xffffffff)
333 return 0;
334 temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL); 328 temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
335 if (!temp) 329 if (!temp)
336 goto no_mem; 330 goto no_mem;
@@ -483,22 +477,20 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
483 477
484 xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid), 478 xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
485 je32_to_cpu(spx->version)); 479 je32_to_cpu(spx->version));
486 if (IS_ERR(xd)) { 480 if (IS_ERR(xd))
487 if (PTR_ERR(xd) == -EEXIST) {
488 /* a newer version of xd exists */
489 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(spx->totlen))))
490 return err;
491 sp += JFFS2_SUMMARY_XATTR_SIZE;
492 break;
493 }
494 JFFS2_NOTICE("allocation of xattr_datum failed\n");
495 return PTR_ERR(xd); 481 return PTR_ERR(xd);
482 if (xd->version > je32_to_cpu(spx->version)) {
483 /* node is not the newest one */
484 struct jffs2_raw_node_ref *raw
485 = sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
486 PAD(je32_to_cpu(spx->totlen)), NULL);
487 raw->next_in_ino = xd->node->next_in_ino;
488 xd->node->next_in_ino = raw;
489 } else {
490 xd->version = je32_to_cpu(spx->version);
491 sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
492 PAD(je32_to_cpu(spx->totlen)), (void *)xd);
496 } 493 }
497
498 xd->node = sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
499 PAD(je32_to_cpu(spx->totlen)), NULL);
500 /* FIXME */ xd->node->next_in_ino = (void *)xd;
501
502 *pseudo_random += je32_to_cpu(spx->xid); 494 *pseudo_random += je32_to_cpu(spx->xid);
503 sp += JFFS2_SUMMARY_XATTR_SIZE; 495 sp += JFFS2_SUMMARY_XATTR_SIZE;
504 496
@@ -519,14 +511,11 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
519 JFFS2_NOTICE("allocation of xattr_datum failed\n"); 511 JFFS2_NOTICE("allocation of xattr_datum failed\n");
520 return -ENOMEM; 512 return -ENOMEM;
521 } 513 }
522 ref->ino = 0xfffffffe;
523 ref->xid = 0xfffffffd;
524 ref->next = c->xref_temp; 514 ref->next = c->xref_temp;
525 c->xref_temp = ref; 515 c->xref_temp = ref;
526 516
527 ref->node = sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED, 517 sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED,
528 PAD(sizeof(struct jffs2_raw_xref)), NULL); 518 PAD(sizeof(struct jffs2_raw_xref)), (void *)ref);
529 /* FIXME */ ref->node->next_in_ino = (void *)ref;
530 519
531 *pseudo_random += ref->node->flash_offset; 520 *pseudo_random += ref->node->flash_offset;
532 sp += JFFS2_SUMMARY_XREF_SIZE; 521 sp += JFFS2_SUMMARY_XREF_SIZE;
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 2d82e250be34..18e66dbf23b4 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -23,18 +23,15 @@
23 * xattr_datum_hashkey(xprefix, xname, xvalue, xsize) 23 * xattr_datum_hashkey(xprefix, xname, xvalue, xsize)
24 * is used to calcurate xdatum hashkey. The reminder of hashkey into XATTRINDEX_HASHSIZE is 24 * is used to calcurate xdatum hashkey. The reminder of hashkey into XATTRINDEX_HASHSIZE is
25 * the index of the xattr name/value pair cache (c->xattrindex). 25 * the index of the xattr name/value pair cache (c->xattrindex).
26 * is_xattr_datum_unchecked(c, xd)
27 * returns 1, if xdatum contains any unchecked raw nodes. if all raw nodes are not
28 * unchecked, it returns 0.
26 * unload_xattr_datum(c, xd) 29 * unload_xattr_datum(c, xd)
27 * is used to release xattr name/value pair and detach from c->xattrindex. 30 * is used to release xattr name/value pair and detach from c->xattrindex.
28 * reclaim_xattr_datum(c) 31 * reclaim_xattr_datum(c)
29 * is used to reclaim xattr name/value pairs on the xattr name/value pair cache when 32 * is used to reclaim xattr name/value pairs on the xattr name/value pair cache when
30 * memory usage by cache is over c->xdatum_mem_threshold. Currentry, this threshold 33 * memory usage by cache is over c->xdatum_mem_threshold. Currentry, this threshold
31 * is hard coded as 32KiB. 34 * is hard coded as 32KiB.
32 * delete_xattr_datum_node(c, xd)
33 * is used to delete a jffs2 node is dominated by xdatum. When EBS(Erase Block Summary) is
34 * enabled, it overwrites the obsolete node by myself.
35 * delete_xattr_datum(c, xd)
36 * is used to delete jffs2_xattr_datum object. It must be called with 0-value of reference
37 * counter. (It means how many jffs2_xattr_ref object refers this xdatum.)
38 * do_verify_xattr_datum(c, xd) 35 * do_verify_xattr_datum(c, xd)
39 * is used to load the xdatum informations without name/value pair from the medium. 36 * is used to load the xdatum informations without name/value pair from the medium.
40 * It's necessary once, because those informations are not collected during mounting 37 * It's necessary once, because those informations are not collected during mounting
@@ -53,8 +50,10 @@
53 * is used to write xdatum to medium. xd->version will be incremented. 50 * is used to write xdatum to medium. xd->version will be incremented.
54 * create_xattr_datum(c, xprefix, xname, xvalue, xsize) 51 * create_xattr_datum(c, xprefix, xname, xvalue, xsize)
55 * is used to create new xdatum and write to medium. 52 * is used to create new xdatum and write to medium.
53 * delete_xattr_datum(c, xd)
54 * is used to delete a xdatum. It marks xd JFFS2_XFLAGS_DEAD, and allows
55 * GC to reclaim those physical nodes.
56 * -------------------------------------------------- */ 56 * -------------------------------------------------- */
57
58static uint32_t xattr_datum_hashkey(int xprefix, const char *xname, const char *xvalue, int xsize) 57static uint32_t xattr_datum_hashkey(int xprefix, const char *xname, const char *xvalue, int xsize)
59{ 58{
60 int name_len = strlen(xname); 59 int name_len = strlen(xname);
@@ -62,6 +61,22 @@ static uint32_t xattr_datum_hashkey(int xprefix, const char *xname, const char *
62 return crc32(xprefix, xname, name_len) ^ crc32(xprefix, xvalue, xsize); 61 return crc32(xprefix, xname, name_len) ^ crc32(xprefix, xvalue, xsize);
63} 62}
64 63
64static int is_xattr_datum_unchecked(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
65{
66 struct jffs2_raw_node_ref *raw;
67 int rc = 0;
68
69 spin_lock(&c->erase_completion_lock);
70 for (raw=xd->node; raw != (void *)xd; raw=raw->next_in_ino) {
71 if (ref_flags(raw) == REF_UNCHECKED) {
72 rc = 1;
73 break;
74 }
75 }
76 spin_unlock(&c->erase_completion_lock);
77 return rc;
78}
79
65static void unload_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 80static void unload_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
66{ 81{
67 /* must be called under down_write(xattr_sem) */ 82 /* must be called under down_write(xattr_sem) */
@@ -107,77 +122,33 @@ static void reclaim_xattr_datum(struct jffs2_sb_info *c)
107 before, c->xdatum_mem_usage, before - c->xdatum_mem_usage); 122 before, c->xdatum_mem_usage, before - c->xdatum_mem_usage);
108} 123}
109 124
110static void delete_xattr_datum_node(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
111{
112 /* must be called under down_write(xattr_sem) */
113 struct jffs2_raw_xattr rx;
114 size_t length;
115 int rc;
116
117 if (!xd->node) {
118 JFFS2_WARNING("xdatum (xid=%u) is removed twice.\n", xd->xid);
119 return;
120 }
121 if (jffs2_sum_active()) {
122 memset(&rx, 0xff, sizeof(struct jffs2_raw_xattr));
123 rc = jffs2_flash_read(c, ref_offset(xd->node),
124 sizeof(struct jffs2_unknown_node),
125 &length, (char *)&rx);
126 if (rc || length != sizeof(struct jffs2_unknown_node)) {
127 JFFS2_ERROR("jffs2_flash_read()=%d, req=%zu, read=%zu at %#08x\n",
128 rc, sizeof(struct jffs2_unknown_node),
129 length, ref_offset(xd->node));
130 }
131 rc = jffs2_flash_write(c, ref_offset(xd->node), sizeof(rx),
132 &length, (char *)&rx);
133 if (rc || length != sizeof(struct jffs2_raw_xattr)) {
134 JFFS2_ERROR("jffs2_flash_write()=%d, req=%zu, wrote=%zu ar %#08x\n",
135 rc, sizeof(rx), length, ref_offset(xd->node));
136 }
137 }
138 spin_lock(&c->erase_completion_lock);
139 xd->node->next_in_ino = NULL;
140 spin_unlock(&c->erase_completion_lock);
141 jffs2_mark_node_obsolete(c, xd->node);
142 xd->node = NULL;
143}
144
145static void delete_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
146{
147 /* must be called under down_write(xattr_sem) */
148 BUG_ON(xd->refcnt);
149
150 unload_xattr_datum(c, xd);
151 if (xd->node) {
152 delete_xattr_datum_node(c, xd);
153 xd->node = NULL;
154 }
155 jffs2_free_xattr_datum(xd);
156}
157
158static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 125static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
159{ 126{
160 /* must be called under down_write(xattr_sem) */ 127 /* must be called under down_write(xattr_sem) */
161 struct jffs2_eraseblock *jeb; 128 struct jffs2_eraseblock *jeb;
129 struct jffs2_raw_node_ref *raw;
162 struct jffs2_raw_xattr rx; 130 struct jffs2_raw_xattr rx;
163 size_t readlen; 131 size_t readlen;
164 uint32_t crc, totlen; 132 uint32_t crc, offset, totlen;
165 int rc; 133 int rc;
166 134
167 BUG_ON(!xd->node); 135 spin_lock(&c->erase_completion_lock);
168 BUG_ON(ref_flags(xd->node) != REF_UNCHECKED); 136 offset = ref_offset(xd->node);
137 if (ref_flags(xd->node) == REF_PRISTINE)
138 goto complete;
139 spin_unlock(&c->erase_completion_lock);
169 140
170 rc = jffs2_flash_read(c, ref_offset(xd->node), sizeof(rx), &readlen, (char *)&rx); 141 rc = jffs2_flash_read(c, offset, sizeof(rx), &readlen, (char *)&rx);
171 if (rc || readlen != sizeof(rx)) { 142 if (rc || readlen != sizeof(rx)) {
172 JFFS2_WARNING("jffs2_flash_read()=%d, req=%zu, read=%zu at %#08x\n", 143 JFFS2_WARNING("jffs2_flash_read()=%d, req=%zu, read=%zu at %#08x\n",
173 rc, sizeof(rx), readlen, ref_offset(xd->node)); 144 rc, sizeof(rx), readlen, offset);
174 return rc ? rc : -EIO; 145 return rc ? rc : -EIO;
175 } 146 }
176 crc = crc32(0, &rx, sizeof(rx) - 4); 147 crc = crc32(0, &rx, sizeof(rx) - 4);
177 if (crc != je32_to_cpu(rx.node_crc)) { 148 if (crc != je32_to_cpu(rx.node_crc)) {
178 if (je32_to_cpu(rx.node_crc) != 0xffffffff) 149 JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
179 JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", 150 offset, je32_to_cpu(rx.hdr_crc), crc);
180 ref_offset(xd->node), je32_to_cpu(rx.hdr_crc), crc); 151 xd->flags |= JFFS2_XFLAGS_INVALID;
181 return EIO; 152 return EIO;
182 } 153 }
183 totlen = PAD(sizeof(rx) + rx.name_len + 1 + je16_to_cpu(rx.value_len)); 154 totlen = PAD(sizeof(rx) + rx.name_len + 1 + je16_to_cpu(rx.value_len));
@@ -188,11 +159,12 @@ static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_dat
188 || je32_to_cpu(rx.version) != xd->version) { 159 || je32_to_cpu(rx.version) != xd->version) {
189 JFFS2_ERROR("inconsistent xdatum at %#08x, magic=%#04x/%#04x, " 160 JFFS2_ERROR("inconsistent xdatum at %#08x, magic=%#04x/%#04x, "
190 "nodetype=%#04x/%#04x, totlen=%u/%u, xid=%u/%u, version=%u/%u\n", 161 "nodetype=%#04x/%#04x, totlen=%u/%u, xid=%u/%u, version=%u/%u\n",
191 ref_offset(xd->node), je16_to_cpu(rx.magic), JFFS2_MAGIC_BITMASK, 162 offset, je16_to_cpu(rx.magic), JFFS2_MAGIC_BITMASK,
192 je16_to_cpu(rx.nodetype), JFFS2_NODETYPE_XATTR, 163 je16_to_cpu(rx.nodetype), JFFS2_NODETYPE_XATTR,
193 je32_to_cpu(rx.totlen), totlen, 164 je32_to_cpu(rx.totlen), totlen,
194 je32_to_cpu(rx.xid), xd->xid, 165 je32_to_cpu(rx.xid), xd->xid,
195 je32_to_cpu(rx.version), xd->version); 166 je32_to_cpu(rx.version), xd->version);
167 xd->flags |= JFFS2_XFLAGS_INVALID;
196 return EIO; 168 return EIO;
197 } 169 }
198 xd->xprefix = rx.xprefix; 170 xd->xprefix = rx.xprefix;
@@ -200,14 +172,17 @@ static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_dat
200 xd->value_len = je16_to_cpu(rx.value_len); 172 xd->value_len = je16_to_cpu(rx.value_len);
201 xd->data_crc = je32_to_cpu(rx.data_crc); 173 xd->data_crc = je32_to_cpu(rx.data_crc);
202 174
203 /* This JFFS2_NODETYPE_XATTR node is checked */
204 jeb = &c->blocks[ref_offset(xd->node) / c->sector_size];
205 totlen = PAD(je32_to_cpu(rx.totlen));
206
207 spin_lock(&c->erase_completion_lock); 175 spin_lock(&c->erase_completion_lock);
208 c->unchecked_size -= totlen; c->used_size += totlen; 176 complete:
209 jeb->unchecked_size -= totlen; jeb->used_size += totlen; 177 for (raw=xd->node; raw != (void *)xd; raw=raw->next_in_ino) {
210 xd->node->flash_offset = ref_offset(xd->node) | REF_PRISTINE; 178 jeb = &c->blocks[ref_offset(raw) / c->sector_size];
179 totlen = PAD(ref_totlen(c, jeb, raw));
180 if (ref_flags(raw) == REF_UNCHECKED) {
181 c->unchecked_size -= totlen; c->used_size += totlen;
182 jeb->unchecked_size -= totlen; jeb->used_size += totlen;
183 }
184 raw->flash_offset = ref_offset(raw) | ((xd->node==raw) ? REF_PRISTINE : REF_NORMAL);
185 }
211 spin_unlock(&c->erase_completion_lock); 186 spin_unlock(&c->erase_completion_lock);
212 187
213 /* unchecked xdatum is chained with c->xattr_unchecked */ 188 /* unchecked xdatum is chained with c->xattr_unchecked */
@@ -227,7 +202,6 @@ static int do_load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum
227 uint32_t crc, length; 202 uint32_t crc, length;
228 int i, ret, retry = 0; 203 int i, ret, retry = 0;
229 204
230 BUG_ON(!xd->node);
231 BUG_ON(ref_flags(xd->node) != REF_PRISTINE); 205 BUG_ON(ref_flags(xd->node) != REF_PRISTINE);
232 BUG_ON(!list_empty(&xd->xindex)); 206 BUG_ON(!list_empty(&xd->xindex));
233 retry: 207 retry:
@@ -253,6 +227,7 @@ static int do_load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum
253 " at %#08x, read: 0x%08x calculated: 0x%08x\n", 227 " at %#08x, read: 0x%08x calculated: 0x%08x\n",
254 ref_offset(xd->node), xd->data_crc, crc); 228 ref_offset(xd->node), xd->data_crc, crc);
255 kfree(data); 229 kfree(data);
230 xd->flags |= JFFS2_XFLAGS_INVALID;
256 return EIO; 231 return EIO;
257 } 232 }
258 233
@@ -286,16 +261,14 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
286 * rc > 0 : Unrecoverable error, this node should be deleted. 261 * rc > 0 : Unrecoverable error, this node should be deleted.
287 */ 262 */
288 int rc = 0; 263 int rc = 0;
289 BUG_ON(xd->xname); 264
290 if (!xd->node) 265 BUG_ON(xd->flags & JFFS2_XFLAGS_DEAD);
266 if (xd->xname)
267 return 0;
268 if (xd->flags & JFFS2_XFLAGS_INVALID)
291 return EIO; 269 return EIO;
292 if (unlikely(ref_flags(xd->node) != REF_PRISTINE)) { 270 if (unlikely(is_xattr_datum_unchecked(c, xd)))
293 rc = do_verify_xattr_datum(c, xd); 271 rc = do_verify_xattr_datum(c, xd);
294 if (rc > 0) {
295 list_del_init(&xd->xindex);
296 delete_xattr_datum_node(c, xd);
297 }
298 }
299 if (!rc) 272 if (!rc)
300 rc = do_load_xattr_datum(c, xd); 273 rc = do_load_xattr_datum(c, xd);
301 return rc; 274 return rc;
@@ -304,7 +277,6 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
304static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 277static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
305{ 278{
306 /* must be called under down_write(xattr_sem) */ 279 /* must be called under down_write(xattr_sem) */
307 struct jffs2_raw_node_ref *raw;
308 struct jffs2_raw_xattr rx; 280 struct jffs2_raw_xattr rx;
309 struct kvec vecs[2]; 281 struct kvec vecs[2];
310 size_t length; 282 size_t length;
@@ -312,14 +284,16 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
312 uint32_t phys_ofs = write_ofs(c); 284 uint32_t phys_ofs = write_ofs(c);
313 285
314 BUG_ON(!xd->xname); 286 BUG_ON(!xd->xname);
287 BUG_ON(xd->flags & (JFFS2_XFLAGS_DEAD|JFFS2_XFLAGS_INVALID));
315 288
316 vecs[0].iov_base = &rx; 289 vecs[0].iov_base = &rx;
317 vecs[0].iov_len = PAD(sizeof(rx)); 290 vecs[0].iov_len = sizeof(rx);
318 vecs[1].iov_base = xd->xname; 291 vecs[1].iov_base = xd->xname;
319 vecs[1].iov_len = xd->name_len + 1 + xd->value_len; 292 vecs[1].iov_len = xd->name_len + 1 + xd->value_len;
320 totlen = vecs[0].iov_len + vecs[1].iov_len; 293 totlen = vecs[0].iov_len + vecs[1].iov_len;
321 294
322 /* Setup raw-xattr */ 295 /* Setup raw-xattr */
296 memset(&rx, 0, sizeof(rx));
323 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 297 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
324 rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR); 298 rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR);
325 rx.totlen = cpu_to_je32(PAD(totlen)); 299 rx.totlen = cpu_to_je32(PAD(totlen));
@@ -343,14 +317,8 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
343 317
344 return rc; 318 return rc;
345 } 319 }
346
347 /* success */ 320 /* success */
348 raw = jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(totlen), NULL); 321 jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(totlen), (void *)xd);
349 /* FIXME */ raw->next_in_ino = (void *)xd;
350
351 if (xd->node)
352 delete_xattr_datum_node(c, xd);
353 xd->node = raw;
354 322
355 dbg_xattr("success on saving xdatum (xid=%u, version=%u, xprefix=%u, xname='%s')\n", 323 dbg_xattr("success on saving xdatum (xid=%u, version=%u, xprefix=%u, xname='%s')\n",
356 xd->xid, xd->version, xd->xprefix, xd->xname); 324 xd->xid, xd->version, xd->xprefix, xd->xname);
@@ -377,7 +345,7 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
377 && xd->value_len==xsize 345 && xd->value_len==xsize
378 && !strcmp(xd->xname, xname) 346 && !strcmp(xd->xname, xname)
379 && !memcmp(xd->xvalue, xvalue, xsize)) { 347 && !memcmp(xd->xvalue, xvalue, xsize)) {
380 xd->refcnt++; 348 atomic_inc(&xd->refcnt);
381 return xd; 349 return xd;
382 } 350 }
383 } 351 }
@@ -397,7 +365,7 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
397 strcpy(data, xname); 365 strcpy(data, xname);
398 memcpy(data + name_len + 1, xvalue, xsize); 366 memcpy(data + name_len + 1, xvalue, xsize);
399 367
400 xd->refcnt = 1; 368 atomic_set(&xd->refcnt, 1);
401 xd->xid = ++c->highest_xid; 369 xd->xid = ++c->highest_xid;
402 xd->flags |= JFFS2_XFLAGS_HOT; 370 xd->flags |= JFFS2_XFLAGS_HOT;
403 xd->xprefix = xprefix; 371 xd->xprefix = xprefix;
@@ -426,20 +394,36 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
426 return xd; 394 return xd;
427} 395}
428 396
397static void delete_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
398{
399 /* must be called under down_write(xattr_sem) */
400 BUG_ON(atomic_read(&xd->refcnt));
401
402 unload_xattr_datum(c, xd);
403 xd->flags |= JFFS2_XFLAGS_DEAD;
404 spin_lock(&c->erase_completion_lock);
405 if (xd->node == (void *)xd) {
406 BUG_ON(!(xd->flags & JFFS2_XFLAGS_INVALID));
407 jffs2_free_xattr_datum(xd);
408 } else {
409 list_add(&xd->xindex, &c->xattr_dead_list);
410 }
411 spin_unlock(&c->erase_completion_lock);
412 dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n", xd->xid, xd->version);
413}
414
429/* -------- xref related functions ------------------ 415/* -------- xref related functions ------------------
430 * verify_xattr_ref(c, ref) 416 * verify_xattr_ref(c, ref)
431 * is used to load xref information from medium. Because summary data does not 417 * is used to load xref information from medium. Because summary data does not
432 * contain xid/ino, it's necessary to verify once while mounting process. 418 * contain xid/ino, it's necessary to verify once while mounting process.
433 * delete_xattr_ref_node(c, ref)
434 * is used to delete a jffs2 node is dominated by xref. When EBS is enabled,
435 * it overwrites the obsolete node by myself.
436 * delete_xattr_ref(c, ref)
437 * is used to delete jffs2_xattr_ref object. If the reference counter of xdatum
438 * is refered by this xref become 0, delete_xattr_datum() is called later.
439 * save_xattr_ref(c, ref) 419 * save_xattr_ref(c, ref)
440 * is used to write xref to medium. 420 * is used to write xref to medium. If delete marker is marked, it write
421 * a delete marker of xref into medium.
441 * create_xattr_ref(c, ic, xd) 422 * create_xattr_ref(c, ic, xd)
442 * is used to create a new xref and write to medium. 423 * is used to create a new xref and write to medium.
424 * delete_xattr_ref(c, ref)
425 * is used to delete jffs2_xattr_ref. It marks xref XREF_DELETE_MARKER,
426 * and allows GC to reclaim those physical nodes.
443 * jffs2_xattr_delete_inode(c, ic) 427 * jffs2_xattr_delete_inode(c, ic)
444 * is called to remove xrefs related to obsolete inode when inode is unlinked. 428 * is called to remove xrefs related to obsolete inode when inode is unlinked.
445 * jffs2_xattr_free_inode(c, ic) 429 * jffs2_xattr_free_inode(c, ic)
@@ -450,25 +434,29 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
450static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) 434static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
451{ 435{
452 struct jffs2_eraseblock *jeb; 436 struct jffs2_eraseblock *jeb;
437 struct jffs2_raw_node_ref *raw;
453 struct jffs2_raw_xref rr; 438 struct jffs2_raw_xref rr;
454 size_t readlen; 439 size_t readlen;
455 uint32_t crc, totlen; 440 uint32_t crc, offset, totlen;
456 int rc; 441 int rc;
457 442
458 BUG_ON(ref_flags(ref->node) != REF_UNCHECKED); 443 spin_lock(&c->erase_completion_lock);
444 if (ref_flags(ref->node) != REF_UNCHECKED)
445 goto complete;
446 offset = ref_offset(ref->node);
447 spin_unlock(&c->erase_completion_lock);
459 448
460 rc = jffs2_flash_read(c, ref_offset(ref->node), sizeof(rr), &readlen, (char *)&rr); 449 rc = jffs2_flash_read(c, offset, sizeof(rr), &readlen, (char *)&rr);
461 if (rc || sizeof(rr) != readlen) { 450 if (rc || sizeof(rr) != readlen) {
462 JFFS2_WARNING("jffs2_flash_read()=%d, req=%zu, read=%zu, at %#08x\n", 451 JFFS2_WARNING("jffs2_flash_read()=%d, req=%zu, read=%zu, at %#08x\n",
463 rc, sizeof(rr), readlen, ref_offset(ref->node)); 452 rc, sizeof(rr), readlen, offset);
464 return rc ? rc : -EIO; 453 return rc ? rc : -EIO;
465 } 454 }
466 /* obsolete node */ 455 /* obsolete node */
467 crc = crc32(0, &rr, sizeof(rr) - 4); 456 crc = crc32(0, &rr, sizeof(rr) - 4);
468 if (crc != je32_to_cpu(rr.node_crc)) { 457 if (crc != je32_to_cpu(rr.node_crc)) {
469 if (je32_to_cpu(rr.node_crc) != 0xffffffff) 458 JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
470 JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", 459 offset, je32_to_cpu(rr.node_crc), crc);
471 ref_offset(ref->node), je32_to_cpu(rr.node_crc), crc);
472 return EIO; 460 return EIO;
473 } 461 }
474 if (je16_to_cpu(rr.magic) != JFFS2_MAGIC_BITMASK 462 if (je16_to_cpu(rr.magic) != JFFS2_MAGIC_BITMASK
@@ -476,22 +464,28 @@ static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref
476 || je32_to_cpu(rr.totlen) != PAD(sizeof(rr))) { 464 || je32_to_cpu(rr.totlen) != PAD(sizeof(rr))) {
477 JFFS2_ERROR("inconsistent xref at %#08x, magic=%#04x/%#04x, " 465 JFFS2_ERROR("inconsistent xref at %#08x, magic=%#04x/%#04x, "
478 "nodetype=%#04x/%#04x, totlen=%u/%zu\n", 466 "nodetype=%#04x/%#04x, totlen=%u/%zu\n",
479 ref_offset(ref->node), je16_to_cpu(rr.magic), JFFS2_MAGIC_BITMASK, 467 offset, je16_to_cpu(rr.magic), JFFS2_MAGIC_BITMASK,
480 je16_to_cpu(rr.nodetype), JFFS2_NODETYPE_XREF, 468 je16_to_cpu(rr.nodetype), JFFS2_NODETYPE_XREF,
481 je32_to_cpu(rr.totlen), PAD(sizeof(rr))); 469 je32_to_cpu(rr.totlen), PAD(sizeof(rr)));
482 return EIO; 470 return EIO;
483 } 471 }
484 ref->ino = je32_to_cpu(rr.ino); 472 ref->ino = je32_to_cpu(rr.ino);
485 ref->xid = je32_to_cpu(rr.xid); 473 ref->xid = je32_to_cpu(rr.xid);
486 474 ref->xseqno = je32_to_cpu(rr.xseqno);
487 /* fixup superblock/eraseblock info */ 475 if (ref->xseqno > c->highest_xseqno)
488 jeb = &c->blocks[ref_offset(ref->node) / c->sector_size]; 476 c->highest_xseqno = (ref->xseqno & ~XREF_DELETE_MARKER);
489 totlen = PAD(sizeof(rr));
490 477
491 spin_lock(&c->erase_completion_lock); 478 spin_lock(&c->erase_completion_lock);
492 c->unchecked_size -= totlen; c->used_size += totlen; 479 complete:
493 jeb->unchecked_size -= totlen; jeb->used_size += totlen; 480 for (raw=ref->node; raw != (void *)ref; raw=raw->next_in_ino) {
494 ref->node->flash_offset = ref_offset(ref->node) | REF_PRISTINE; 481 jeb = &c->blocks[ref_offset(raw) / c->sector_size];
482 totlen = PAD(ref_totlen(c, jeb, raw));
483 if (ref_flags(raw) == REF_UNCHECKED) {
484 c->unchecked_size -= totlen; c->used_size += totlen;
485 jeb->unchecked_size -= totlen; jeb->used_size += totlen;
486 }
487 raw->flash_offset = ref_offset(raw) | ((ref->node==raw) ? REF_PRISTINE : REF_NORMAL);
488 }
495 spin_unlock(&c->erase_completion_lock); 489 spin_unlock(&c->erase_completion_lock);
496 490
497 dbg_xattr("success on verifying xref (ino=%u, xid=%u) at %#08x\n", 491 dbg_xattr("success on verifying xref (ino=%u, xid=%u) at %#08x\n",
@@ -499,58 +493,12 @@ static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref
499 return 0; 493 return 0;
500} 494}
501 495
502static void delete_xattr_ref_node(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
503{
504 struct jffs2_raw_xref rr;
505 size_t length;
506 int rc;
507
508 if (jffs2_sum_active()) {
509 memset(&rr, 0xff, sizeof(rr));
510 rc = jffs2_flash_read(c, ref_offset(ref->node),
511 sizeof(struct jffs2_unknown_node),
512 &length, (char *)&rr);
513 if (rc || length != sizeof(struct jffs2_unknown_node)) {
514 JFFS2_ERROR("jffs2_flash_read()=%d, req=%zu, read=%zu at %#08x\n",
515 rc, sizeof(struct jffs2_unknown_node),
516 length, ref_offset(ref->node));
517 }
518 rc = jffs2_flash_write(c, ref_offset(ref->node), sizeof(rr),
519 &length, (char *)&rr);
520 if (rc || length != sizeof(struct jffs2_raw_xref)) {
521 JFFS2_ERROR("jffs2_flash_write()=%d, req=%zu, wrote=%zu at %#08x\n",
522 rc, sizeof(rr), length, ref_offset(ref->node));
523 }
524 }
525 spin_lock(&c->erase_completion_lock);
526 ref->node->next_in_ino = NULL;
527 spin_unlock(&c->erase_completion_lock);
528 jffs2_mark_node_obsolete(c, ref->node);
529 ref->node = NULL;
530}
531
532static void delete_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
533{
534 /* must be called under down_write(xattr_sem) */
535 struct jffs2_xattr_datum *xd;
536
537 BUG_ON(!ref->node);
538 delete_xattr_ref_node(c, ref);
539
540 xd = ref->xd;
541 xd->refcnt--;
542 if (!xd->refcnt)
543 delete_xattr_datum(c, xd);
544 jffs2_free_xattr_ref(ref);
545}
546
547static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) 496static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
548{ 497{
549 /* must be called under down_write(xattr_sem) */ 498 /* must be called under down_write(xattr_sem) */
550 struct jffs2_raw_node_ref *raw;
551 struct jffs2_raw_xref rr; 499 struct jffs2_raw_xref rr;
552 size_t length; 500 size_t length;
553 uint32_t phys_ofs = write_ofs(c); 501 uint32_t xseqno, phys_ofs = write_ofs(c);
554 int ret; 502 int ret;
555 503
556 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 504 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -558,8 +506,16 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
558 rr.totlen = cpu_to_je32(PAD(sizeof(rr))); 506 rr.totlen = cpu_to_je32(PAD(sizeof(rr)));
559 rr.hdr_crc = cpu_to_je32(crc32(0, &rr, sizeof(struct jffs2_unknown_node) - 4)); 507 rr.hdr_crc = cpu_to_je32(crc32(0, &rr, sizeof(struct jffs2_unknown_node) - 4));
560 508
561 rr.ino = cpu_to_je32(ref->ic->ino); 509 xseqno = (c->highest_xseqno += 2);
562 rr.xid = cpu_to_je32(ref->xd->xid); 510 if (is_xattr_ref_dead(ref)) {
511 xseqno |= XREF_DELETE_MARKER;
512 rr.ino = cpu_to_je32(ref->ino);
513 rr.xid = cpu_to_je32(ref->xid);
514 } else {
515 rr.ino = cpu_to_je32(ref->ic->ino);
516 rr.xid = cpu_to_je32(ref->xd->xid);
517 }
518 rr.xseqno = cpu_to_je32(xseqno);
563 rr.node_crc = cpu_to_je32(crc32(0, &rr, sizeof(rr) - 4)); 519 rr.node_crc = cpu_to_je32(crc32(0, &rr, sizeof(rr) - 4));
564 520
565 ret = jffs2_flash_write(c, phys_ofs, sizeof(rr), &length, (char *)&rr); 521 ret = jffs2_flash_write(c, phys_ofs, sizeof(rr), &length, (char *)&rr);
@@ -572,12 +528,9 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
572 528
573 return ret; 529 return ret;
574 } 530 }
575 531 /* success */
576 raw = jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(sizeof(rr)), NULL); 532 ref->xseqno = xseqno;
577 /* FIXME */ raw->next_in_ino = (void *)ref; 533 jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(sizeof(rr)), (void *)ref);
578 if (ref->node)
579 delete_xattr_ref_node(c, ref);
580 ref->node = raw;
581 534
582 dbg_xattr("success on saving xref (ino=%u, xid=%u)\n", ref->ic->ino, ref->xd->xid); 535 dbg_xattr("success on saving xref (ino=%u, xid=%u)\n", ref->ic->ino, ref->xd->xid);
583 536
@@ -610,6 +563,27 @@ static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct
610 return ref; /* success */ 563 return ref; /* success */
611} 564}
612 565
566static void delete_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
567{
568 /* must be called under down_write(xattr_sem) */
569 struct jffs2_xattr_datum *xd;
570
571 xd = ref->xd;
572 ref->xseqno |= XREF_DELETE_MARKER;
573 ref->ino = ref->ic->ino;
574 ref->xid = ref->xd->xid;
575 spin_lock(&c->erase_completion_lock);
576 ref->next = c->xref_dead_list;
577 c->xref_dead_list = ref;
578 spin_unlock(&c->erase_completion_lock);
579
580 dbg_xattr("xref(ino=%u, xid=%u, xseqno=%u) was removed.\n",
581 ref->ino, ref->xid, ref->xseqno);
582
583 if (atomic_dec_and_test(&xd->refcnt))
584 delete_xattr_datum(c, xd);
585}
586
613void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) 587void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic)
614{ 588{
615 /* It's called from jffs2_clear_inode() on inode removing. 589 /* It's called from jffs2_clear_inode() on inode removing.
@@ -638,8 +612,7 @@ void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *i
638 for (ref = ic->xref; ref; ref = _ref) { 612 for (ref = ic->xref; ref; ref = _ref) {
639 _ref = ref->next; 613 _ref = ref->next;
640 xd = ref->xd; 614 xd = ref->xd;
641 xd->refcnt--; 615 if (atomic_dec_and_test(&xd->refcnt)) {
642 if (!xd->refcnt) {
643 unload_xattr_datum(c, xd); 616 unload_xattr_datum(c, xd);
644 jffs2_free_xattr_datum(xd); 617 jffs2_free_xattr_datum(xd);
645 } 618 }
@@ -655,7 +628,7 @@ static int check_xattr_ref_inode(struct jffs2_sb_info *c, struct jffs2_inode_cac
655 * duplicate name/value pairs. If duplicate name/value pair would be found, 628 * duplicate name/value pairs. If duplicate name/value pair would be found,
656 * one will be removed. 629 * one will be removed.
657 */ 630 */
658 struct jffs2_xattr_ref *ref, *cmp, **pref; 631 struct jffs2_xattr_ref *ref, *cmp, **pref, **pcmp;
659 int rc = 0; 632 int rc = 0;
660 633
661 if (likely(ic->flags & INO_FLAGS_XATTR_CHECKED)) 634 if (likely(ic->flags & INO_FLAGS_XATTR_CHECKED))
@@ -673,13 +646,13 @@ static int check_xattr_ref_inode(struct jffs2_sb_info *c, struct jffs2_inode_cac
673 } else if (unlikely(rc < 0)) 646 } else if (unlikely(rc < 0))
674 goto out; 647 goto out;
675 } 648 }
676 for (cmp=ref->next, pref=&ref->next; cmp; pref=&cmp->next, cmp=cmp->next) { 649 for (cmp=ref->next, pcmp=&ref->next; cmp; pcmp=&cmp->next, cmp=cmp->next) {
677 if (!cmp->xd->xname) { 650 if (!cmp->xd->xname) {
678 ref->xd->flags |= JFFS2_XFLAGS_BIND; 651 ref->xd->flags |= JFFS2_XFLAGS_BIND;
679 rc = load_xattr_datum(c, cmp->xd); 652 rc = load_xattr_datum(c, cmp->xd);
680 ref->xd->flags &= ~JFFS2_XFLAGS_BIND; 653 ref->xd->flags &= ~JFFS2_XFLAGS_BIND;
681 if (unlikely(rc > 0)) { 654 if (unlikely(rc > 0)) {
682 *pref = cmp->next; 655 *pcmp = cmp->next;
683 delete_xattr_ref(c, cmp); 656 delete_xattr_ref(c, cmp);
684 goto retry; 657 goto retry;
685 } else if (unlikely(rc < 0)) 658 } else if (unlikely(rc < 0))
@@ -687,8 +660,13 @@ static int check_xattr_ref_inode(struct jffs2_sb_info *c, struct jffs2_inode_cac
687 } 660 }
688 if (ref->xd->xprefix == cmp->xd->xprefix 661 if (ref->xd->xprefix == cmp->xd->xprefix
689 && !strcmp(ref->xd->xname, cmp->xd->xname)) { 662 && !strcmp(ref->xd->xname, cmp->xd->xname)) {
690 *pref = cmp->next; 663 if (ref->xseqno > cmp->xseqno) {
691 delete_xattr_ref(c, cmp); 664 *pcmp = cmp->next;
665 delete_xattr_ref(c, cmp);
666 } else {
667 *pref = ref->next;
668 delete_xattr_ref(c, ref);
669 }
692 goto retry; 670 goto retry;
693 } 671 }
694 } 672 }
@@ -719,9 +697,13 @@ void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c)
719 for (i=0; i < XATTRINDEX_HASHSIZE; i++) 697 for (i=0; i < XATTRINDEX_HASHSIZE; i++)
720 INIT_LIST_HEAD(&c->xattrindex[i]); 698 INIT_LIST_HEAD(&c->xattrindex[i]);
721 INIT_LIST_HEAD(&c->xattr_unchecked); 699 INIT_LIST_HEAD(&c->xattr_unchecked);
700 INIT_LIST_HEAD(&c->xattr_dead_list);
701 c->xref_dead_list = NULL;
722 c->xref_temp = NULL; 702 c->xref_temp = NULL;
723 703
724 init_rwsem(&c->xattr_sem); 704 init_rwsem(&c->xattr_sem);
705 c->highest_xid = 0;
706 c->highest_xseqno = 0;
725 c->xdatum_mem_usage = 0; 707 c->xdatum_mem_usage = 0;
726 c->xdatum_mem_threshold = 32 * 1024; /* Default 32KB */ 708 c->xdatum_mem_threshold = 32 * 1024; /* Default 32KB */
727} 709}
@@ -751,7 +733,11 @@ void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c)
751 _ref = ref->next; 733 _ref = ref->next;
752 jffs2_free_xattr_ref(ref); 734 jffs2_free_xattr_ref(ref);
753 } 735 }
754 c->xref_temp = NULL; 736
737 for (ref=c->xref_dead_list; ref; ref = _ref) {
738 _ref = ref->next;
739 jffs2_free_xattr_ref(ref);
740 }
755 741
756 for (i=0; i < XATTRINDEX_HASHSIZE; i++) { 742 for (i=0; i < XATTRINDEX_HASHSIZE; i++) {
757 list_for_each_entry_safe(xd, _xd, &c->xattrindex[i], xindex) { 743 list_for_each_entry_safe(xd, _xd, &c->xattrindex[i], xindex) {
@@ -761,100 +747,143 @@ void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c)
761 jffs2_free_xattr_datum(xd); 747 jffs2_free_xattr_datum(xd);
762 } 748 }
763 } 749 }
750
751 list_for_each_entry_safe(xd, _xd, &c->xattr_dead_list, xindex) {
752 list_del(&xd->xindex);
753 jffs2_free_xattr_datum(xd);
754 }
764} 755}
765 756
757#define XREF_TMPHASH_SIZE (128)
766void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) 758void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
767{ 759{
768 struct jffs2_xattr_ref *ref, *_ref; 760 struct jffs2_xattr_ref *ref, *_ref;
761 struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE];
769 struct jffs2_xattr_datum *xd, *_xd; 762 struct jffs2_xattr_datum *xd, *_xd;
770 struct jffs2_inode_cache *ic; 763 struct jffs2_inode_cache *ic;
771 int i, xdatum_count =0, xdatum_unchecked_count = 0, xref_count = 0; 764 struct jffs2_raw_node_ref *raw;
765 int i, xdatum_count = 0, xdatum_unchecked_count = 0, xref_count = 0;
766 int xdatum_orphan_count = 0, xref_orphan_count = 0, xref_dead_count = 0;
772 767
773 BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING)); 768 BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING));
774 769
775 /* Phase.1 */ 770 /* Phase.1 : Merge same xref */
771 for (i=0; i < XREF_TMPHASH_SIZE; i++)
772 xref_tmphash[i] = NULL;
776 for (ref=c->xref_temp; ref; ref=_ref) { 773 for (ref=c->xref_temp; ref; ref=_ref) {
774 struct jffs2_xattr_ref *tmp;
775
777 _ref = ref->next; 776 _ref = ref->next;
778 /* checking REF_UNCHECKED nodes */
779 if (ref_flags(ref->node) != REF_PRISTINE) { 777 if (ref_flags(ref->node) != REF_PRISTINE) {
780 if (verify_xattr_ref(c, ref)) { 778 if (verify_xattr_ref(c, ref)) {
781 delete_xattr_ref_node(c, ref); 779 BUG_ON(ref->node->next_in_ino != (void *)ref);
780 ref->node->next_in_ino = NULL;
781 jffs2_mark_node_obsolete(c, ref->node);
782 jffs2_free_xattr_ref(ref); 782 jffs2_free_xattr_ref(ref);
783 continue; 783 continue;
784 } 784 }
785 } 785 }
786 /* At this point, ref->xid and ref->ino contain XID and inode number. 786
787 ref->xd and ref->ic are not valid yet. */ 787 i = (ref->ino ^ ref->xid) % XREF_TMPHASH_SIZE;
788 xd = jffs2_find_xattr_datum(c, ref->xid); 788 for (tmp=xref_tmphash[i]; tmp; tmp=tmp->next) {
789 ic = jffs2_get_ino_cache(c, ref->ino); 789 if (tmp->ino == ref->ino && tmp->xid == ref->xid)
790 if (!xd || !ic) { 790 break;
791 if (ref_flags(ref->node) != REF_UNCHECKED) 791 }
792 JFFS2_WARNING("xref(ino=%u, xid=%u) is orphan. \n", 792 if (tmp) {
793 ref->ino, ref->xid); 793 raw = ref->node;
794 delete_xattr_ref_node(c, ref); 794 if (ref->xseqno > tmp->xseqno) {
795 tmp->xseqno = ref->xseqno;
796 raw->next_in_ino = tmp->node;
797 tmp->node = raw;
798 } else {
799 raw->next_in_ino = tmp->node->next_in_ino;
800 tmp->node->next_in_ino = raw;
801 }
795 jffs2_free_xattr_ref(ref); 802 jffs2_free_xattr_ref(ref);
796 continue; 803 continue;
804 } else {
805 ref->next = xref_tmphash[i];
806 xref_tmphash[i] = ref;
797 } 807 }
798 ref->xd = xd;
799 ref->ic = ic;
800 xd->refcnt++;
801 ref->next = ic->xref;
802 ic->xref = ref;
803 xref_count++;
804 } 808 }
805 c->xref_temp = NULL; 809 c->xref_temp = NULL;
806 /* After this, ref->xid/ino are NEVER used. */
807 810
808 /* Phase.2 */ 811 /* Phase.2 : Bind xref with inode_cache and xattr_datum */
812 for (i=0; i < XREF_TMPHASH_SIZE; i++) {
813 for (ref=xref_tmphash[i]; ref; ref=_ref) {
814 xref_count++;
815 _ref = ref->next;
816 if (is_xattr_ref_dead(ref)) {
817 ref->next = c->xref_dead_list;
818 c->xref_dead_list = ref;
819 xref_dead_count++;
820 continue;
821 }
822 /* At this point, ref->xid and ref->ino contain XID and inode number.
823 ref->xd and ref->ic are not valid yet. */
824 xd = jffs2_find_xattr_datum(c, ref->xid);
825 ic = jffs2_get_ino_cache(c, ref->ino);
826 if (!xd || !ic) {
827 dbg_xattr("xref(ino=%u, xid=%u, xseqno=%u) is orphan.\n",
828 ref->ino, ref->xid, ref->xseqno);
829 ref->xseqno |= XREF_DELETE_MARKER;
830 ref->next = c->xref_dead_list;
831 c->xref_dead_list = ref;
832 xref_orphan_count++;
833 continue;
834 }
835 ref->xd = xd;
836 ref->ic = ic;
837 atomic_inc(&xd->refcnt);
838 ref->next = ic->xref;
839 ic->xref = ref;
840 }
841 }
842
843 /* Phase.3 : Link unchecked xdatum to xattr_unchecked list */
809 for (i=0; i < XATTRINDEX_HASHSIZE; i++) { 844 for (i=0; i < XATTRINDEX_HASHSIZE; i++) {
810 list_for_each_entry_safe(xd, _xd, &c->xattrindex[i], xindex) { 845 list_for_each_entry_safe(xd, _xd, &c->xattrindex[i], xindex) {
846 xdatum_count++;
811 list_del_init(&xd->xindex); 847 list_del_init(&xd->xindex);
812 if (!xd->refcnt) { 848 if (!atomic_read(&xd->refcnt)) {
813 if (ref_flags(xd->node) != REF_UNCHECKED) 849 dbg_xattr("xdatum(xid=%u, version=%u) is orphan.\n",
814 JFFS2_WARNING("orphan xdatum(xid=%u, version=%u) at %#08x\n", 850 xd->xid, xd->version);
815 xd->xid, xd->version, ref_offset(xd->node)); 851 xd->flags |= JFFS2_XFLAGS_DEAD;
816 delete_xattr_datum(c, xd); 852 list_add(&xd->xindex, &c->xattr_unchecked);
853 xdatum_orphan_count++;
817 continue; 854 continue;
818 } 855 }
819 if (ref_flags(xd->node) != REF_PRISTINE) { 856 if (is_xattr_datum_unchecked(c, xd)) {
820 dbg_xattr("unchecked xdatum(xid=%u) at %#08x\n", 857 dbg_xattr("unchecked xdatum(xid=%u, version=%u)\n",
821 xd->xid, ref_offset(xd->node)); 858 xd->xid, xd->version);
822 list_add(&xd->xindex, &c->xattr_unchecked); 859 list_add(&xd->xindex, &c->xattr_unchecked);
823 xdatum_unchecked_count++; 860 xdatum_unchecked_count++;
824 } 861 }
825 xdatum_count++;
826 } 862 }
827 } 863 }
828 /* build complete */ 864 /* build complete */
829 JFFS2_NOTICE("complete building xattr subsystem, %u of xdatum (%u unchecked) and " 865 JFFS2_NOTICE("complete building xattr subsystem, %u of xdatum"
830 "%u of xref found.\n", xdatum_count, xdatum_unchecked_count, xref_count); 866 " (%u unchecked, %u orphan) and "
867 "%u of xref (%u dead, %u orphan) found.\n",
868 xdatum_count, xdatum_unchecked_count, xdatum_orphan_count,
869 xref_count, xref_dead_count, xref_orphan_count);
831} 870}
832 871
833struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, 872struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
834 uint32_t xid, uint32_t version) 873 uint32_t xid, uint32_t version)
835{ 874{
836 struct jffs2_xattr_datum *xd, *_xd; 875 struct jffs2_xattr_datum *xd;
837 876
838 _xd = jffs2_find_xattr_datum(c, xid); 877 xd = jffs2_find_xattr_datum(c, xid);
839 if (_xd) { 878 if (!xd) {
840 dbg_xattr("duplicate xdatum (xid=%u, version=%u/%u) at %#08x\n", 879 xd = jffs2_alloc_xattr_datum();
841 xid, version, _xd->version, ref_offset(_xd->node)); 880 if (!xd)
842 if (version < _xd->version) 881 return ERR_PTR(-ENOMEM);
843 return ERR_PTR(-EEXIST); 882 xd->xid = xid;
844 } 883 xd->version = version;
845 xd = jffs2_alloc_xattr_datum(); 884 if (xd->xid > c->highest_xid)
846 if (!xd) 885 c->highest_xid = xd->xid;
847 return ERR_PTR(-ENOMEM); 886 list_add_tail(&xd->xindex, &c->xattrindex[xid % XATTRINDEX_HASHSIZE]);
848 xd->xid = xid;
849 xd->version = version;
850 if (xd->xid > c->highest_xid)
851 c->highest_xid = xd->xid;
852 list_add_tail(&xd->xindex, &c->xattrindex[xid % XATTRINDEX_HASHSIZE]);
853
854 if (_xd) {
855 list_del_init(&_xd->xindex);
856 delete_xattr_datum_node(c, _xd);
857 jffs2_free_xattr_datum(_xd);
858 } 887 }
859 return xd; 888 return xd;
860} 889}
@@ -1080,9 +1109,23 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1080 goto out; 1109 goto out;
1081 } 1110 }
1082 if (!buffer) { 1111 if (!buffer) {
1083 *pref = ref->next; 1112 ref->ino = ic->ino;
1084 delete_xattr_ref(c, ref); 1113 ref->xid = xd->xid;
1085 rc = 0; 1114 ref->xseqno |= XREF_DELETE_MARKER;
1115 rc = save_xattr_ref(c, ref);
1116 if (!rc) {
1117 *pref = ref->next;
1118 spin_lock(&c->erase_completion_lock);
1119 ref->next = c->xref_dead_list;
1120 c->xref_dead_list = ref;
1121 spin_unlock(&c->erase_completion_lock);
1122 if (atomic_dec_and_test(&xd->refcnt))
1123 delete_xattr_datum(c, xd);
1124 } else {
1125 ref->ic = ic;
1126 ref->xd = xd;
1127 ref->xseqno &= ~XREF_DELETE_MARKER;
1128 }
1086 goto out; 1129 goto out;
1087 } 1130 }
1088 goto found; 1131 goto found;
@@ -1094,7 +1137,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1094 goto out; 1137 goto out;
1095 } 1138 }
1096 if (!buffer) { 1139 if (!buffer) {
1097 rc = -EINVAL; 1140 rc = -ENODATA;
1098 goto out; 1141 goto out;
1099 } 1142 }
1100 found: 1143 found:
@@ -1110,16 +1153,14 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1110 request = PAD(sizeof(struct jffs2_raw_xref)); 1153 request = PAD(sizeof(struct jffs2_raw_xref));
1111 rc = jffs2_reserve_space(c, request, &length, 1154 rc = jffs2_reserve_space(c, request, &length,
1112 ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE); 1155 ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE);
1156 down_write(&c->xattr_sem);
1113 if (rc) { 1157 if (rc) {
1114 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); 1158 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request);
1115 down_write(&c->xattr_sem); 1159 if (atomic_dec_and_test(&xd->refcnt))
1116 xd->refcnt--;
1117 if (!xd->refcnt)
1118 delete_xattr_datum(c, xd); 1160 delete_xattr_datum(c, xd);
1119 up_write(&c->xattr_sem); 1161 up_write(&c->xattr_sem);
1120 return rc; 1162 return rc;
1121 } 1163 }
1122 down_write(&c->xattr_sem);
1123 if (ref) 1164 if (ref)
1124 *pref = ref->next; 1165 *pref = ref->next;
1125 newref = create_xattr_ref(c, ic, xd); 1166 newref = create_xattr_ref(c, ic, xd);
@@ -1129,8 +1170,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1129 ic->xref = ref; 1170 ic->xref = ref;
1130 } 1171 }
1131 rc = PTR_ERR(newref); 1172 rc = PTR_ERR(newref);
1132 xd->refcnt--; 1173 if (atomic_dec_and_test(&xd->refcnt))
1133 if (!xd->refcnt)
1134 delete_xattr_datum(c, xd); 1174 delete_xattr_datum(c, xd);
1135 } else if (ref) { 1175 } else if (ref) {
1136 delete_xattr_ref(c, ref); 1176 delete_xattr_ref(c, ref);
@@ -1142,38 +1182,40 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1142} 1182}
1143 1183
1144/* -------- garbage collector functions ------------- 1184/* -------- garbage collector functions -------------
1145 * jffs2_garbage_collect_xattr_datum(c, xd) 1185 * jffs2_garbage_collect_xattr_datum(c, xd, raw)
1146 * is used to move xdatum into new node. 1186 * is used to move xdatum into new node.
1147 * jffs2_garbage_collect_xattr_ref(c, ref) 1187 * jffs2_garbage_collect_xattr_ref(c, ref, raw)
1148 * is used to move xref into new node. 1188 * is used to move xref into new node.
1149 * jffs2_verify_xattr(c) 1189 * jffs2_verify_xattr(c)
1150 * is used to call do_verify_xattr_datum() before garbage collecting. 1190 * is used to call do_verify_xattr_datum() before garbage collecting.
1191 * jffs2_release_xattr_datum(c, xd)
1192 * is used to release an in-memory object of xdatum.
1193 * jffs2_release_xattr_ref(c, ref)
1194 * is used to release an in-memory object of xref.
1151 * -------------------------------------------------- */ 1195 * -------------------------------------------------- */
1152int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 1196int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
1197 struct jffs2_raw_node_ref *raw)
1153{ 1198{
1154 uint32_t totlen, length, old_ofs; 1199 uint32_t totlen, length, old_ofs;
1155 int rc = -EINVAL; 1200 int rc = 0;
1156 1201
1157 down_write(&c->xattr_sem); 1202 down_write(&c->xattr_sem);
1158 BUG_ON(!xd->node); 1203 if (xd->node != raw)
1159 1204 goto out;
1160 old_ofs = ref_offset(xd->node); 1205 if (xd->flags & (JFFS2_XFLAGS_DEAD|JFFS2_XFLAGS_INVALID))
1161 totlen = ref_totlen(c, c->gcblock, xd->node);
1162 if (totlen < sizeof(struct jffs2_raw_xattr))
1163 goto out; 1206 goto out;
1164 1207
1165 if (!xd->xname) { 1208 rc = load_xattr_datum(c, xd);
1166 rc = load_xattr_datum(c, xd); 1209 if (unlikely(rc)) {
1167 if (unlikely(rc > 0)) { 1210 rc = (rc > 0) ? 0 : rc;
1168 delete_xattr_datum_node(c, xd); 1211 goto out;
1169 rc = 0;
1170 goto out;
1171 } else if (unlikely(rc < 0))
1172 goto out;
1173 } 1212 }
1213 old_ofs = ref_offset(xd->node);
1214 totlen = PAD(sizeof(struct jffs2_raw_xattr)
1215 + xd->name_len + 1 + xd->value_len);
1174 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XATTR_SIZE); 1216 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XATTR_SIZE);
1175 if (rc || length < totlen) { 1217 if (rc) {
1176 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen); 1218 JFFS2_WARNING("jffs2_reserve_space_gc()=%d, request=%u\n", rc, totlen);
1177 rc = rc ? rc : -EBADFD; 1219 rc = rc ? rc : -EBADFD;
1178 goto out; 1220 goto out;
1179 } 1221 }
@@ -1182,27 +1224,32 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt
1182 dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n", 1224 dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n",
1183 xd->xid, xd->version, old_ofs, ref_offset(xd->node)); 1225 xd->xid, xd->version, old_ofs, ref_offset(xd->node));
1184 out: 1226 out:
1227 if (!rc)
1228 jffs2_mark_node_obsolete(c, raw);
1185 up_write(&c->xattr_sem); 1229 up_write(&c->xattr_sem);
1186 return rc; 1230 return rc;
1187} 1231}
1188 1232
1189 1233int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
1190int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) 1234 struct jffs2_raw_node_ref *raw)
1191{ 1235{
1192 uint32_t totlen, length, old_ofs; 1236 uint32_t totlen, length, old_ofs;
1193 int rc = -EINVAL; 1237 int rc = 0;
1194 1238
1195 down_write(&c->xattr_sem); 1239 down_write(&c->xattr_sem);
1196 BUG_ON(!ref->node); 1240 BUG_ON(!ref->node);
1197 1241
1242 if (ref->node != raw)
1243 goto out;
1244 if (is_xattr_ref_dead(ref) && (raw->next_in_ino == (void *)ref))
1245 goto out;
1246
1198 old_ofs = ref_offset(ref->node); 1247 old_ofs = ref_offset(ref->node);
1199 totlen = ref_totlen(c, c->gcblock, ref->node); 1248 totlen = ref_totlen(c, c->gcblock, ref->node);
1200 if (totlen != sizeof(struct jffs2_raw_xref))
1201 goto out;
1202 1249
1203 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE); 1250 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE);
1204 if (rc || length < totlen) { 1251 if (rc) {
1205 JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n", 1252 JFFS2_WARNING("%s: jffs2_reserve_space_gc() = %d, request = %u\n",
1206 __FUNCTION__, rc, totlen); 1253 __FUNCTION__, rc, totlen);
1207 rc = rc ? rc : -EBADFD; 1254 rc = rc ? rc : -EBADFD;
1208 goto out; 1255 goto out;
@@ -1212,6 +1259,8 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_
1212 dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n", 1259 dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n",
1213 ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node)); 1260 ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node));
1214 out: 1261 out:
1262 if (!rc)
1263 jffs2_mark_node_obsolete(c, raw);
1215 up_write(&c->xattr_sem); 1264 up_write(&c->xattr_sem);
1216 return rc; 1265 return rc;
1217} 1266}
@@ -1219,20 +1268,59 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_
1219int jffs2_verify_xattr(struct jffs2_sb_info *c) 1268int jffs2_verify_xattr(struct jffs2_sb_info *c)
1220{ 1269{
1221 struct jffs2_xattr_datum *xd, *_xd; 1270 struct jffs2_xattr_datum *xd, *_xd;
1271 struct jffs2_eraseblock *jeb;
1272 struct jffs2_raw_node_ref *raw;
1273 uint32_t totlen;
1222 int rc; 1274 int rc;
1223 1275
1224 down_write(&c->xattr_sem); 1276 down_write(&c->xattr_sem);
1225 list_for_each_entry_safe(xd, _xd, &c->xattr_unchecked, xindex) { 1277 list_for_each_entry_safe(xd, _xd, &c->xattr_unchecked, xindex) {
1226 rc = do_verify_xattr_datum(c, xd); 1278 rc = do_verify_xattr_datum(c, xd);
1227 if (rc == 0) { 1279 if (rc < 0)
1228 list_del_init(&xd->xindex); 1280 continue;
1229 break; 1281 list_del_init(&xd->xindex);
1230 } else if (rc > 0) { 1282 spin_lock(&c->erase_completion_lock);
1231 list_del_init(&xd->xindex); 1283 for (raw=xd->node; raw != (void *)xd; raw=raw->next_in_ino) {
1232 delete_xattr_datum_node(c, xd); 1284 if (ref_flags(raw) != REF_UNCHECKED)
1285 continue;
1286 jeb = &c->blocks[ref_offset(raw) / c->sector_size];
1287 totlen = PAD(ref_totlen(c, jeb, raw));
1288 c->unchecked_size -= totlen; c->used_size += totlen;
1289 jeb->unchecked_size -= totlen; jeb->used_size += totlen;
1290 raw->flash_offset = ref_offset(raw)
1291 | ((xd->node == (void *)raw) ? REF_PRISTINE : REF_NORMAL);
1233 } 1292 }
1293 if (xd->flags & JFFS2_XFLAGS_DEAD)
1294 list_add(&xd->xindex, &c->xattr_dead_list);
1295 spin_unlock(&c->erase_completion_lock);
1234 } 1296 }
1235 up_write(&c->xattr_sem); 1297 up_write(&c->xattr_sem);
1236
1237 return list_empty(&c->xattr_unchecked) ? 1 : 0; 1298 return list_empty(&c->xattr_unchecked) ? 1 : 0;
1238} 1299}
1300
1301void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
1302{
1303 /* must be called under spin_lock(&c->erase_completion_lock) */
1304 if (atomic_read(&xd->refcnt) || xd->node != (void *)xd)
1305 return;
1306
1307 list_del(&xd->xindex);
1308 jffs2_free_xattr_datum(xd);
1309}
1310
1311void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
1312{
1313 /* must be called under spin_lock(&c->erase_completion_lock) */
1314 struct jffs2_xattr_ref *tmp, **ptmp;
1315
1316 if (ref->node != (void *)ref)
1317 return;
1318
1319 for (tmp=c->xref_dead_list, ptmp=&c->xref_dead_list; tmp; ptmp=&tmp->next, tmp=tmp->next) {
1320 if (ref == tmp) {
1321 *ptmp = tmp->next;
1322 break;
1323 }
1324 }
1325 jffs2_free_xattr_ref(ref);
1326}
diff --git a/fs/jffs2/xattr.h b/fs/jffs2/xattr.h
index 2c199856c582..06a5c69dcf8b 100644
--- a/fs/jffs2/xattr.h
+++ b/fs/jffs2/xattr.h
@@ -16,6 +16,8 @@
16 16
17#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */ 17#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
18#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */ 18#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
19#define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */
20#define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */
19 21
20struct jffs2_xattr_datum 22struct jffs2_xattr_datum
21{ 23{
@@ -23,10 +25,10 @@ struct jffs2_xattr_datum
23 struct jffs2_raw_node_ref *node; 25 struct jffs2_raw_node_ref *node;
24 uint8_t class; 26 uint8_t class;
25 uint8_t flags; 27 uint8_t flags;
26 uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */ 28 uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
27 29
28 struct list_head xindex; /* chained from c->xattrindex[n] */ 30 struct list_head xindex; /* chained from c->xattrindex[n] */
29 uint32_t refcnt; /* # of xattr_ref refers this */ 31 atomic_t refcnt; /* # of xattr_ref refers this */
30 uint32_t xid; 32 uint32_t xid;
31 uint32_t version; 33 uint32_t version;
32 34
@@ -47,6 +49,7 @@ struct jffs2_xattr_ref
47 uint8_t flags; /* Currently unused */ 49 uint8_t flags; /* Currently unused */
48 u16 unused; 50 u16 unused;
49 51
52 uint32_t xseqno;
50 union { 53 union {
51 struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */ 54 struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
52 uint32_t ino; /* only used in scanning/building */ 55 uint32_t ino; /* only used in scanning/building */
@@ -58,6 +61,12 @@ struct jffs2_xattr_ref
58 struct jffs2_xattr_ref *next; /* chained from ic->xref_list */ 61 struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
59}; 62};
60 63
64#define XREF_DELETE_MARKER (0x00000001)
65static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
66{
67 return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
68}
69
61#ifdef CONFIG_JFFS2_FS_XATTR 70#ifdef CONFIG_JFFS2_FS_XATTR
62 71
63extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); 72extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
@@ -70,9 +79,13 @@ extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c
70extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 79extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
71extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 80extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
72 81
73extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd); 82extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
74extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref); 83 struct jffs2_raw_node_ref *raw);
84extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
85 struct jffs2_raw_node_ref *raw);
75extern int jffs2_verify_xattr(struct jffs2_sb_info *c); 86extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
87extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
88extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
76 89
77extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname, 90extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
78 char *buffer, size_t size); 91 char *buffer, size_t size);
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 04eb78f1252e..43e3f566aad6 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -305,7 +305,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
305 offset, nr_segs, jfs_get_block, NULL); 305 offset, nr_segs, jfs_get_block, NULL);
306} 306}
307 307
308struct address_space_operations jfs_aops = { 308const struct address_space_operations jfs_aops = {
309 .readpage = jfs_readpage, 309 .readpage = jfs_readpage,
310 .readpages = jfs_readpages, 310 .readpages = jfs_readpages,
311 .writepage = jfs_writepage, 311 .writepage = jfs_writepage,
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index c30072674464..b5c7da6190dc 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -33,7 +33,7 @@ extern void jfs_free_zero_link(struct inode *);
33extern struct dentry *jfs_get_parent(struct dentry *dentry); 33extern struct dentry *jfs_get_parent(struct dentry *dentry);
34extern void jfs_set_inode_flags(struct inode *); 34extern void jfs_set_inode_flags(struct inode *);
35 35
36extern struct address_space_operations jfs_aops; 36extern const struct address_space_operations jfs_aops;
37extern struct inode_operations jfs_dir_inode_operations; 37extern struct inode_operations jfs_dir_inode_operations;
38extern const struct file_operations jfs_dir_operations; 38extern const struct file_operations jfs_dir_operations;
39extern struct inode_operations jfs_file_inode_operations; 39extern struct inode_operations jfs_file_inode_operations;
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 7f6e88039700..e1e0a6e6ebdf 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -577,7 +577,7 @@ static void metapage_invalidatepage(struct page *page, unsigned long offset)
577 metapage_releasepage(page, 0); 577 metapage_releasepage(page, 0);
578} 578}
579 579
580struct address_space_operations jfs_metapage_aops = { 580const struct address_space_operations jfs_metapage_aops = {
581 .readpage = metapage_readpage, 581 .readpage = metapage_readpage,
582 .writepage = metapage_writepage, 582 .writepage = metapage_writepage,
583 .sync_page = block_sync_page, 583 .sync_page = block_sync_page,
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
index f0b7d3282b07..d17a3290f5aa 100644
--- a/fs/jfs/jfs_metapage.h
+++ b/fs/jfs/jfs_metapage.h
@@ -139,7 +139,7 @@ static inline void metapage_homeok(struct metapage *mp)
139 put_metapage(mp); 139 put_metapage(mp);
140} 140}
141 141
142extern struct address_space_operations jfs_metapage_aops; 142extern const struct address_space_operations jfs_metapage_aops;
143 143
144/* 144/*
145 * This routines invalidate all pages for an extent. 145 * This routines invalidate all pages for an extent.
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index a6fb509b7341..9ea91c5eeb7b 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -335,7 +335,7 @@ static sector_t minix_bmap(struct address_space *mapping, sector_t block)
335{ 335{
336 return generic_block_bmap(mapping,block,minix_get_block); 336 return generic_block_bmap(mapping,block,minix_get_block);
337} 337}
338static struct address_space_operations minix_aops = { 338static const struct address_space_operations minix_aops = {
339 .readpage = minix_readpage, 339 .readpage = minix_readpage,
340 .writepage = minix_writepage, 340 .writepage = minix_writepage,
341 .sync_page = block_sync_page, 341 .sync_page = block_sync_page,
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 90d2ea28f333..6c51c1198464 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -105,7 +105,7 @@ static struct super_operations ncp_sops =
105 105
106extern struct dentry_operations ncp_root_dentry_operations; 106extern struct dentry_operations ncp_root_dentry_operations;
107#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS) 107#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
108extern struct address_space_operations ncp_symlink_aops; 108extern const struct address_space_operations ncp_symlink_aops;
109extern int ncp_symlink(struct inode*, struct dentry*, const char*); 109extern int ncp_symlink(struct inode*, struct dentry*, const char*);
110#endif 110#endif
111 111
diff --git a/fs/ncpfs/symlink.c b/fs/ncpfs/symlink.c
index e935f1b34bc2..f76b1392a012 100644
--- a/fs/ncpfs/symlink.c
+++ b/fs/ncpfs/symlink.c
@@ -99,7 +99,7 @@ fail:
99/* 99/*
100 * symlinks can't do much... 100 * symlinks can't do much...
101 */ 101 */
102struct address_space_operations ncp_symlink_aops = { 102const struct address_space_operations ncp_symlink_aops = {
103 .readpage = ncp_symlink_readpage, 103 .readpage = ncp_symlink_readpage,
104}; 104};
105 105
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 402005c35ab3..8ca9707be6c9 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -909,7 +909,7 @@ int __init nfs_init_directcache(void)
909 * nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures 909 * nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures
910 * 910 *
911 */ 911 */
912void __exit nfs_destroy_directcache(void) 912void nfs_destroy_directcache(void)
913{ 913{
914 if (kmem_cache_destroy(nfs_direct_cachep)) 914 if (kmem_cache_destroy(nfs_direct_cachep))
915 printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n"); 915 printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n");
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index add289138836..cc2b874ad5a4 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -315,7 +315,7 @@ static int nfs_release_page(struct page *page, gfp_t gfp)
315 return !nfs_wb_page(page->mapping->host, page); 315 return !nfs_wb_page(page->mapping->host, page);
316} 316}
317 317
318struct address_space_operations nfs_file_aops = { 318const struct address_space_operations nfs_file_aops = {
319 .readpage = nfs_readpage, 319 .readpage = nfs_readpage,
320 .readpages = nfs_readpages, 320 .readpages = nfs_readpages,
321 .set_page_dirty = __set_page_dirty_nobuffers, 321 .set_page_dirty = __set_page_dirty_nobuffers,
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 51bc88b662fe..c5b916605fb0 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1132,7 +1132,7 @@ static int __init nfs_init_inodecache(void)
1132 return 0; 1132 return 0;
1133} 1133}
1134 1134
1135static void __exit nfs_destroy_inodecache(void) 1135static void nfs_destroy_inodecache(void)
1136{ 1136{
1137 if (kmem_cache_destroy(nfs_inode_cachep)) 1137 if (kmem_cache_destroy(nfs_inode_cachep))
1138 printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n"); 1138 printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n");
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index bd2815e2dec1..4fe51c1292bb 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -31,15 +31,15 @@ extern struct svc_version nfs4_callback_version1;
31 31
32/* pagelist.c */ 32/* pagelist.c */
33extern int __init nfs_init_nfspagecache(void); 33extern int __init nfs_init_nfspagecache(void);
34extern void __exit nfs_destroy_nfspagecache(void); 34extern void nfs_destroy_nfspagecache(void);
35extern int __init nfs_init_readpagecache(void); 35extern int __init nfs_init_readpagecache(void);
36extern void __exit nfs_destroy_readpagecache(void); 36extern void nfs_destroy_readpagecache(void);
37extern int __init nfs_init_writepagecache(void); 37extern int __init nfs_init_writepagecache(void);
38extern void __exit nfs_destroy_writepagecache(void); 38extern void nfs_destroy_writepagecache(void);
39 39
40#ifdef CONFIG_NFS_DIRECTIO 40#ifdef CONFIG_NFS_DIRECTIO
41extern int __init nfs_init_directcache(void); 41extern int __init nfs_init_directcache(void);
42extern void __exit nfs_destroy_directcache(void); 42extern void nfs_destroy_directcache(void);
43#else 43#else
44#define nfs_init_directcache() (0) 44#define nfs_init_directcache() (0)
45#define nfs_destroy_directcache() do {} while(0) 45#define nfs_destroy_directcache() do {} while(0)
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index ef9429643ebc..d89f6fb3b3a3 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -390,7 +390,7 @@ int __init nfs_init_nfspagecache(void)
390 return 0; 390 return 0;
391} 391}
392 392
393void __exit nfs_destroy_nfspagecache(void) 393void nfs_destroy_nfspagecache(void)
394{ 394{
395 if (kmem_cache_destroy(nfs_page_cachep)) 395 if (kmem_cache_destroy(nfs_page_cachep))
396 printk(KERN_INFO "nfs_page: not all structures were freed\n"); 396 printk(KERN_INFO "nfs_page: not all structures were freed\n");
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 41c2ffee24f5..32cf3773af0c 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -711,7 +711,7 @@ int __init nfs_init_readpagecache(void)
711 return 0; 711 return 0;
712} 712}
713 713
714void __exit nfs_destroy_readpagecache(void) 714void nfs_destroy_readpagecache(void)
715{ 715{
716 mempool_destroy(nfs_rdata_mempool); 716 mempool_destroy(nfs_rdata_mempool);
717 if (kmem_cache_destroy(nfs_rdata_cachep)) 717 if (kmem_cache_destroy(nfs_rdata_cachep))
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index b383fdd3a15c..8fccb9cb173b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1551,7 +1551,7 @@ int __init nfs_init_writepagecache(void)
1551 return 0; 1551 return 0;
1552} 1552}
1553 1553
1554void __exit nfs_destroy_writepagecache(void) 1554void nfs_destroy_writepagecache(void)
1555{ 1555{
1556 mempool_destroy(nfs_commit_mempool); 1556 mempool_destroy(nfs_commit_mempool);
1557 mempool_destroy(nfs_wdata_mempool); 1557 mempool_destroy(nfs_wdata_mempool);
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 1630b5670dc2..7c7d01672d35 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -123,7 +123,7 @@ static void release_stateid(struct nfs4_stateid *stp, int flags);
123 */ 123 */
124 124
125/* recall_lock protects the del_recall_lru */ 125/* recall_lock protects the del_recall_lru */
126static spinlock_t recall_lock = SPIN_LOCK_UNLOCKED; 126static DEFINE_SPINLOCK(recall_lock);
127static struct list_head del_recall_lru; 127static struct list_head del_recall_lru;
128 128
129static void 129static void
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 580412d330cb..bc579bfdfbd8 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -1544,7 +1544,7 @@ err_out:
1544/** 1544/**
1545 * ntfs_aops - general address space operations for inodes and attributes 1545 * ntfs_aops - general address space operations for inodes and attributes
1546 */ 1546 */
1547struct address_space_operations ntfs_aops = { 1547const struct address_space_operations ntfs_aops = {
1548 .readpage = ntfs_readpage, /* Fill page with data. */ 1548 .readpage = ntfs_readpage, /* Fill page with data. */
1549 .sync_page = block_sync_page, /* Currently, just unplugs the 1549 .sync_page = block_sync_page, /* Currently, just unplugs the
1550 disk request queue. */ 1550 disk request queue. */
@@ -1560,7 +1560,7 @@ struct address_space_operations ntfs_aops = {
1560 * ntfs_mst_aops - general address space operations for mst protecteed inodes 1560 * ntfs_mst_aops - general address space operations for mst protecteed inodes
1561 * and attributes 1561 * and attributes
1562 */ 1562 */
1563struct address_space_operations ntfs_mst_aops = { 1563const struct address_space_operations ntfs_mst_aops = {
1564 .readpage = ntfs_readpage, /* Fill page with data. */ 1564 .readpage = ntfs_readpage, /* Fill page with data. */
1565 .sync_page = block_sync_page, /* Currently, just unplugs the 1565 .sync_page = block_sync_page, /* Currently, just unplugs the
1566 disk request queue. */ 1566 disk request queue. */
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h
index bf7b3d7c0930..ddd3d503097c 100644
--- a/fs/ntfs/ntfs.h
+++ b/fs/ntfs/ntfs.h
@@ -57,8 +57,8 @@ extern struct kmem_cache *ntfs_attr_ctx_cache;
57extern struct kmem_cache *ntfs_index_ctx_cache; 57extern struct kmem_cache *ntfs_index_ctx_cache;
58 58
59/* The various operations structs defined throughout the driver files. */ 59/* The various operations structs defined throughout the driver files. */
60extern struct address_space_operations ntfs_aops; 60extern const struct address_space_operations ntfs_aops;
61extern struct address_space_operations ntfs_mst_aops; 61extern const struct address_space_operations ntfs_mst_aops;
62 62
63extern const struct file_operations ntfs_file_ops; 63extern const struct file_operations ntfs_file_ops;
64extern struct inode_operations ntfs_file_inode_ops; 64extern struct inode_operations ntfs_file_inode_ops;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 47152bf9a7f2..cca71317b6d6 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -666,7 +666,7 @@ out:
666 return ret; 666 return ret;
667} 667}
668 668
669struct address_space_operations ocfs2_aops = { 669const struct address_space_operations ocfs2_aops = {
670 .readpage = ocfs2_readpage, 670 .readpage = ocfs2_readpage,
671 .writepage = ocfs2_writepage, 671 .writepage = ocfs2_writepage,
672 .prepare_write = ocfs2_prepare_write, 672 .prepare_write = ocfs2_prepare_write,
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 21f38accd039..1d26cfcd9f84 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -54,7 +54,7 @@ static DECLARE_RWSEM(o2hb_callback_sem);
54 * multiple hb threads are watching multiple regions. A node is live 54 * multiple hb threads are watching multiple regions. A node is live
55 * whenever any of the threads sees activity from the node in its region. 55 * whenever any of the threads sees activity from the node in its region.
56 */ 56 */
57static spinlock_t o2hb_live_lock = SPIN_LOCK_UNLOCKED; 57static DEFINE_SPINLOCK(o2hb_live_lock);
58static struct list_head o2hb_live_slots[O2NM_MAX_NODES]; 58static struct list_head o2hb_live_slots[O2NM_MAX_NODES];
59static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; 59static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
60static LIST_HEAD(o2hb_node_events); 60static LIST_HEAD(o2hb_node_events);
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 0f60cc0d3985..1591eb37a723 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -108,7 +108,7 @@
108 ##args); \ 108 ##args); \
109} while (0) 109} while (0)
110 110
111static rwlock_t o2net_handler_lock = RW_LOCK_UNLOCKED; 111static DEFINE_RWLOCK(o2net_handler_lock);
112static struct rb_root o2net_handler_tree = RB_ROOT; 112static struct rb_root o2net_handler_tree = RB_ROOT;
113 113
114static struct o2net_node o2net_nodes[O2NM_MAX_NODES]; 114static struct o2net_node o2net_nodes[O2NM_MAX_NODES];
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index ba27c5c5e959..b8c23f7ba67e 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -88,7 +88,7 @@ out_free:
88 * 88 *
89 */ 89 */
90 90
91spinlock_t dlm_domain_lock = SPIN_LOCK_UNLOCKED; 91DEFINE_SPINLOCK(dlm_domain_lock);
92LIST_HEAD(dlm_domains); 92LIST_HEAD(dlm_domains);
93static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events); 93static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events);
94 94
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index d6f89577e25f..5ca57ec650c7 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -53,7 +53,7 @@
53#define MLOG_MASK_PREFIX ML_DLM 53#define MLOG_MASK_PREFIX ML_DLM
54#include "cluster/masklog.h" 54#include "cluster/masklog.h"
55 55
56static spinlock_t dlm_cookie_lock = SPIN_LOCK_UNLOCKED; 56static DEFINE_SPINLOCK(dlm_cookie_lock);
57static u64 dlm_next_cookie = 1; 57static u64 dlm_next_cookie = 1;
58 58
59static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm, 59static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm,
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index da399013516f..29b2845f370d 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -98,8 +98,8 @@ static void dlm_mig_lockres_worker(struct dlm_work_item *item, void *data);
98 98
99static u64 dlm_get_next_mig_cookie(void); 99static u64 dlm_get_next_mig_cookie(void);
100 100
101static spinlock_t dlm_reco_state_lock = SPIN_LOCK_UNLOCKED; 101static DEFINE_SPINLOCK(dlm_reco_state_lock);
102static spinlock_t dlm_mig_cookie_lock = SPIN_LOCK_UNLOCKED; 102static DEFINE_SPINLOCK(dlm_mig_cookie_lock);
103static u64 dlm_mig_cookie = 1; 103static u64 dlm_mig_cookie = 1;
104 104
105static u64 dlm_get_next_mig_cookie(void) 105static u64 dlm_get_next_mig_cookie(void)
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 64cd52860c87..4acd37286bdd 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -242,7 +242,7 @@ static void ocfs2_build_lock_name(enum ocfs2_lock_type type,
242 mlog_exit_void(); 242 mlog_exit_void();
243} 243}
244 244
245static spinlock_t ocfs2_dlm_tracking_lock = SPIN_LOCK_UNLOCKED; 245static DEFINE_SPINLOCK(ocfs2_dlm_tracking_lock);
246 246
247static void ocfs2_add_lockres_tracking(struct ocfs2_lock_res *res, 247static void ocfs2_add_lockres_tracking(struct ocfs2_lock_res *res,
248 struct ocfs2_dlm_debug *dlm_debug) 248 struct ocfs2_dlm_debug *dlm_debug)
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 84c507961287..35140f6cf840 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -114,7 +114,7 @@ static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
114 114
115extern kmem_cache_t *ocfs2_inode_cache; 115extern kmem_cache_t *ocfs2_inode_cache;
116 116
117extern struct address_space_operations ocfs2_aops; 117extern const struct address_space_operations ocfs2_aops;
118 118
119struct buffer_head *ocfs2_bread(struct inode *inode, int block, 119struct buffer_head *ocfs2_bread(struct inode *inode, int block,
120 int *err, int reada); 120 int *err, int reada);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 3fe8781c22cb..910a601b2e98 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -49,7 +49,7 @@
49 49
50#include "buffer_head_io.h" 50#include "buffer_head_io.h"
51 51
52spinlock_t trans_inc_lock = SPIN_LOCK_UNLOCKED; 52DEFINE_SPINLOCK(trans_inc_lock);
53 53
54static int ocfs2_force_read_journal(struct inode *inode); 54static int ocfs2_force_read_journal(struct inode *inode);
55static int ocfs2_recover_node(struct ocfs2_super *osb, 55static int ocfs2_recover_node(struct ocfs2_super *osb,
diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c
index ee42765a8553..cf70fe2075b8 100644
--- a/fs/ocfs2/vote.c
+++ b/fs/ocfs2/vote.c
@@ -988,9 +988,7 @@ int ocfs2_request_mount_vote(struct ocfs2_super *osb)
988 } 988 }
989 989
990bail: 990bail:
991 if (request) 991 kfree(request);
992 kfree(request);
993
994 return status; 992 return status;
995} 993}
996 994
@@ -1021,9 +1019,7 @@ int ocfs2_request_umount_vote(struct ocfs2_super *osb)
1021 } 1019 }
1022 1020
1023bail: 1021bail:
1024 if (request) 1022 kfree(request);
1025 kfree(request);
1026
1027 return status; 1023 return status;
1028} 1024}
1029 1025
diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile
index 42c7d3878ed0..d713ce6b3e12 100644
--- a/fs/partitions/Makefile
+++ b/fs/partitions/Makefile
@@ -4,7 +4,6 @@
4 4
5obj-y := check.o 5obj-y := check.o
6 6
7obj-$(CONFIG_DEVFS_FS) += devfs.o
8obj-$(CONFIG_ACORN_PARTITION) += acorn.o 7obj-$(CONFIG_ACORN_PARTITION) += acorn.o
9obj-$(CONFIG_AMIGA_PARTITION) += amiga.o 8obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
10obj-$(CONFIG_ATARI_PARTITION) += atari.o 9obj-$(CONFIG_ATARI_PARTITION) += atari.o
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 2ef313a96b66..839634026eb5 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -18,10 +18,8 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/kmod.h> 19#include <linux/kmod.h>
20#include <linux/ctype.h> 20#include <linux/ctype.h>
21#include <linux/devfs_fs_kernel.h>
22 21
23#include "check.h" 22#include "check.h"
24#include "devfs.h"
25 23
26#include "acorn.h" 24#include "acorn.h"
27#include "amiga.h" 25#include "amiga.h"
@@ -161,18 +159,11 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
161 if (!state) 159 if (!state)
162 return NULL; 160 return NULL;
163 161
164#ifdef CONFIG_DEVFS_FS 162 disk_name(hd, 0, state->name);
165 if (hd->devfs_name[0] != '\0') { 163 printk(KERN_INFO " %s:", state->name);
166 printk(KERN_INFO " /dev/%s:", hd->devfs_name); 164 if (isdigit(state->name[strlen(state->name)-1]))
167 sprintf(state->name, "p"); 165 sprintf(state->name, "p");
168 } 166
169#endif
170 else {
171 disk_name(hd, 0, state->name);
172 printk(KERN_INFO " %s:", state->name);
173 if (isdigit(state->name[strlen(state->name)-1]))
174 sprintf(state->name, "p");
175 }
176 state->limit = hd->minors; 167 state->limit = hd->minors;
177 i = res = 0; 168 i = res = 0;
178 while (!res && check_part[i]) { 169 while (!res && check_part[i]) {
@@ -328,7 +319,6 @@ void delete_partition(struct gendisk *disk, int part)
328 p->nr_sects = 0; 319 p->nr_sects = 0;
329 p->ios[0] = p->ios[1] = 0; 320 p->ios[0] = p->ios[1] = 0;
330 p->sectors[0] = p->sectors[1] = 0; 321 p->sectors[0] = p->sectors[1] = 0;
331 devfs_remove("%s/part%d", disk->devfs_name, part);
332 sysfs_remove_link(&p->kobj, "subsystem"); 322 sysfs_remove_link(&p->kobj, "subsystem");
333 if (p->holder_dir) 323 if (p->holder_dir)
334 kobject_unregister(p->holder_dir); 324 kobject_unregister(p->holder_dir);
@@ -350,10 +340,6 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
350 p->nr_sects = len; 340 p->nr_sects = len;
351 p->partno = part; 341 p->partno = part;
352 342
353 devfs_mk_bdev(MKDEV(disk->major, disk->first_minor + part),
354 S_IFBLK|S_IRUSR|S_IWUSR,
355 "%s/part%d", disk->devfs_name, part);
356
357 if (isdigit(disk->kobj.name[strlen(disk->kobj.name)-1])) 343 if (isdigit(disk->kobj.name[strlen(disk->kobj.name)-1]))
358 snprintf(p->kobj.name,KOBJ_NAME_LEN,"%sp%d",disk->kobj.name,part); 344 snprintf(p->kobj.name,KOBJ_NAME_LEN,"%sp%d",disk->kobj.name,part);
359 else 345 else
@@ -423,14 +409,8 @@ void register_disk(struct gendisk *disk)
423 disk_sysfs_add_subdirs(disk); 409 disk_sysfs_add_subdirs(disk);
424 410
425 /* No minors to use for partitions */ 411 /* No minors to use for partitions */
426 if (disk->minors == 1) { 412 if (disk->minors == 1)
427 if (disk->devfs_name[0] != '\0')
428 devfs_add_disk(disk);
429 goto exit; 413 goto exit;
430 }
431
432 /* always add handle for the whole disk */
433 devfs_add_partitioned(disk);
434 414
435 /* No such device (e.g., media were just removed) */ 415 /* No such device (e.g., media were just removed) */
436 if (!get_capacity(disk)) 416 if (!get_capacity(disk))
@@ -538,8 +518,6 @@ void del_gendisk(struct gendisk *disk)
538 disk_stat_set_all(disk, 0); 518 disk_stat_set_all(disk, 0);
539 disk->stamp = 0; 519 disk->stamp = 0;
540 520
541 devfs_remove_disk(disk);
542
543 kobject_uevent(&disk->kobj, KOBJ_REMOVE); 521 kobject_uevent(&disk->kobj, KOBJ_REMOVE);
544 if (disk->holder_dir) 522 if (disk->holder_dir)
545 kobject_unregister(disk->holder_dir); 523 kobject_unregister(disk->holder_dir);
diff --git a/fs/partitions/devfs.c b/fs/partitions/devfs.c
deleted file mode 100644
index 3f0a780c9cec..000000000000
--- a/fs/partitions/devfs.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * This tries to keep block devices away from devfs as much as possible.
3 */
4#include <linux/fs.h>
5#include <linux/devfs_fs_kernel.h>
6#include <linux/vmalloc.h>
7#include <linux/genhd.h>
8#include <linux/bitops.h>
9#include <linux/mutex.h>
10
11
12struct unique_numspace {
13 u32 num_free; /* Num free in bits */
14 u32 length; /* Array length in bytes */
15 unsigned long *bits;
16 struct semaphore mutex;
17};
18
19static DEFINE_MUTEX(numspace_mutex);
20
21static int expand_numspace(struct unique_numspace *s)
22{
23 u32 length;
24 void *bits;
25
26 if (s->length < 16)
27 length = 16;
28 else
29 length = s->length << 1;
30
31 bits = vmalloc(length);
32 if (!bits)
33 return -ENOMEM;
34 if (s->bits) {
35 memcpy(bits, s->bits, s->length);
36 vfree(s->bits);
37 }
38
39 s->num_free = (length - s->length) << 3;
40 s->bits = bits;
41 memset(bits + s->length, 0, length - s->length);
42 s->length = length;
43
44 return 0;
45}
46
47static int alloc_unique_number(struct unique_numspace *s)
48{
49 int rval = 0;
50
51 mutex_lock(&numspace_mutex);
52 if (s->num_free < 1)
53 rval = expand_numspace(s);
54 if (!rval) {
55 rval = find_first_zero_bit(s->bits, s->length << 3);
56 --s->num_free;
57 __set_bit(rval, s->bits);
58 }
59 mutex_unlock(&numspace_mutex);
60
61 return rval;
62}
63
64static void dealloc_unique_number(struct unique_numspace *s, int number)
65{
66 int old_val;
67
68 if (number >= 0) {
69 mutex_lock(&numspace_mutex);
70 old_val = __test_and_clear_bit(number, s->bits);
71 if (old_val)
72 ++s->num_free;
73 mutex_unlock(&numspace_mutex);
74 }
75}
76
77static struct unique_numspace disc_numspace;
78static struct unique_numspace cdrom_numspace;
79
80void devfs_add_partitioned(struct gendisk *disk)
81{
82 char dirname[64], symlink[16];
83
84 devfs_mk_dir(disk->devfs_name);
85 devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
86 S_IFBLK|S_IRUSR|S_IWUSR,
87 "%s/disc", disk->devfs_name);
88
89 disk->number = alloc_unique_number(&disc_numspace);
90
91 sprintf(symlink, "discs/disc%d", disk->number);
92 sprintf(dirname, "../%s", disk->devfs_name);
93 devfs_mk_symlink(symlink, dirname);
94
95}
96
97void devfs_add_disk(struct gendisk *disk)
98{
99 devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
100 (disk->flags & GENHD_FL_CD) ?
101 S_IFBLK|S_IRUGO|S_IWUGO :
102 S_IFBLK|S_IRUSR|S_IWUSR,
103 "%s", disk->devfs_name);
104
105 if (disk->flags & GENHD_FL_CD) {
106 char dirname[64], symlink[16];
107
108 disk->number = alloc_unique_number(&cdrom_numspace);
109
110 sprintf(symlink, "cdroms/cdrom%d", disk->number);
111 sprintf(dirname, "../%s", disk->devfs_name);
112 devfs_mk_symlink(symlink, dirname);
113 }
114}
115
116void devfs_remove_disk(struct gendisk *disk)
117{
118 if (disk->minors != 1) {
119 devfs_remove("discs/disc%d", disk->number);
120 dealloc_unique_number(&disc_numspace, disk->number);
121 devfs_remove("%s/disc", disk->devfs_name);
122 }
123 if (disk->flags & GENHD_FL_CD) {
124 devfs_remove("cdroms/cdrom%d", disk->number);
125 dealloc_unique_number(&cdrom_numspace, disk->number);
126 }
127 devfs_remove(disk->devfs_name);
128}
129
130
diff --git a/fs/partitions/devfs.h b/fs/partitions/devfs.h
deleted file mode 100644
index 176118b4e492..000000000000
--- a/fs/partitions/devfs.h
+++ /dev/null
@@ -1,10 +0,0 @@
1
2#ifdef CONFIG_DEVFS_FS
3void devfs_add_disk(struct gendisk *dev);
4void devfs_add_partitioned(struct gendisk *dev);
5void devfs_remove_disk(struct gendisk *dev);
6#else
7# define devfs_add_disk(disk) do { } while (0)
8# define devfs_add_partitioned(disk) do { } while (0)
9# define devfs_remove_disk(disk) do { } while (0)
10#endif
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 0137ec4c1368..0a163a4f7764 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -122,6 +122,11 @@ struct mem_size_stats
122 unsigned long private_dirty; 122 unsigned long private_dirty;
123}; 123};
124 124
125__attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma)
126{
127 return NULL;
128}
129
125static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats *mss) 130static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats *mss)
126{ 131{
127 struct proc_maps_private *priv = m->private; 132 struct proc_maps_private *priv = m->private;
@@ -158,22 +163,23 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
158 pad_len_spaces(m, len); 163 pad_len_spaces(m, len);
159 seq_path(m, file->f_vfsmnt, file->f_dentry, "\n"); 164 seq_path(m, file->f_vfsmnt, file->f_dentry, "\n");
160 } else { 165 } else {
161 if (mm) { 166 const char *name = arch_vma_name(vma);
162 if (vma->vm_start <= mm->start_brk && 167 if (!name) {
168 if (mm) {
169 if (vma->vm_start <= mm->start_brk &&
163 vma->vm_end >= mm->brk) { 170 vma->vm_end >= mm->brk) {
164 pad_len_spaces(m, len); 171 name = "[heap]";
165 seq_puts(m, "[heap]"); 172 } else if (vma->vm_start <= mm->start_stack &&
166 } else { 173 vma->vm_end >= mm->start_stack) {
167 if (vma->vm_start <= mm->start_stack && 174 name = "[stack]";
168 vma->vm_end >= mm->start_stack) {
169
170 pad_len_spaces(m, len);
171 seq_puts(m, "[stack]");
172 } 175 }
176 } else {
177 name = "[vdso]";
173 } 178 }
174 } else { 179 }
180 if (name) {
175 pad_len_spaces(m, len); 181 pad_len_spaces(m, len);
176 seq_puts(m, "[vdso]"); 182 seq_puts(m, name);
177 } 183 }
178 } 184 }
179 seq_putc(m, '\n'); 185 seq_putc(m, '\n');
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 2f24c46f72a1..8bc182a88748 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -450,7 +450,7 @@ static sector_t qnx4_bmap(struct address_space *mapping, sector_t block)
450{ 450{
451 return generic_block_bmap(mapping,block,qnx4_get_block); 451 return generic_block_bmap(mapping,block,qnx4_get_block);
452} 452}
453static struct address_space_operations qnx4_aops = { 453static const struct address_space_operations qnx4_aops = {
454 .readpage = qnx4_readpage, 454 .readpage = qnx4_readpage,
455 .writepage = qnx4_writepage, 455 .writepage = qnx4_writepage,
456 .sync_page = block_sync_page, 456 .sync_page = block_sync_page,
diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c
index 00a933eb820c..86f14cacf641 100644
--- a/fs/ramfs/file-mmu.c
+++ b/fs/ramfs/file-mmu.c
@@ -26,7 +26,7 @@
26 26
27#include <linux/fs.h> 27#include <linux/fs.h>
28 28
29struct address_space_operations ramfs_aops = { 29const struct address_space_operations ramfs_aops = {
30 .readpage = simple_readpage, 30 .readpage = simple_readpage,
31 .prepare_write = simple_prepare_write, 31 .prepare_write = simple_prepare_write,
32 .commit_write = simple_commit_write 32 .commit_write = simple_commit_write
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index f443a84b98a5..99fffc9e1bfd 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -27,7 +27,7 @@
27 27
28static int ramfs_nommu_setattr(struct dentry *, struct iattr *); 28static int ramfs_nommu_setattr(struct dentry *, struct iattr *);
29 29
30struct address_space_operations ramfs_aops = { 30const struct address_space_operations ramfs_aops = {
31 .readpage = simple_readpage, 31 .readpage = simple_readpage,
32 .prepare_write = simple_prepare_write, 32 .prepare_write = simple_prepare_write,
33 .commit_write = simple_commit_write 33 .commit_write = simple_commit_write
diff --git a/fs/ramfs/internal.h b/fs/ramfs/internal.h
index 313237631b49..c2bb58e74653 100644
--- a/fs/ramfs/internal.h
+++ b/fs/ramfs/internal.h
@@ -10,6 +10,6 @@
10 */ 10 */
11 11
12 12
13extern struct address_space_operations ramfs_aops; 13extern const struct address_space_operations ramfs_aops;
14extern const struct file_operations ramfs_file_operations; 14extern const struct file_operations ramfs_file_operations;
15extern struct inode_operations ramfs_file_inode_operations; 15extern struct inode_operations ramfs_file_inode_operations;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 9857e50f85e7..a24858a632fa 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2996,7 +2996,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
2996 return error; 2996 return error;
2997} 2997}
2998 2998
2999struct address_space_operations reiserfs_address_space_operations = { 2999const struct address_space_operations reiserfs_address_space_operations = {
3000 .writepage = reiserfs_writepage, 3000 .writepage = reiserfs_writepage,
3001 .readpage = reiserfs_readpage, 3001 .readpage = reiserfs_readpage,
3002 .readpages = reiserfs_readpages, 3002 .readpages = reiserfs_readpages,
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 283fbc6b8eea..22eed61ebf69 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -459,7 +459,7 @@ err_out:
459 459
460/* Mapping from our types to the kernel */ 460/* Mapping from our types to the kernel */
461 461
462static struct address_space_operations romfs_aops = { 462static const struct address_space_operations romfs_aops = {
463 .readpage = romfs_readpage 463 .readpage = romfs_readpage
464}; 464};
465 465
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index ed9a24d19d7d..dae67048baba 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -306,7 +306,7 @@ static int smb_commit_write(struct file *file, struct page *page,
306 return status; 306 return status;
307} 307}
308 308
309struct address_space_operations smb_file_aops = { 309const struct address_space_operations smb_file_aops = {
310 .readpage = smb_readpage, 310 .readpage = smb_readpage,
311 .writepage = smb_writepage, 311 .writepage = smb_writepage,
312 .prepare_write = smb_prepare_write, 312 .prepare_write = smb_prepare_write,
diff --git a/fs/smbfs/proto.h b/fs/smbfs/proto.h
index 972ed7dad388..34fb462b2379 100644
--- a/fs/smbfs/proto.h
+++ b/fs/smbfs/proto.h
@@ -63,7 +63,7 @@ extern int smb_revalidate_inode(struct dentry *dentry);
63extern int smb_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); 63extern int smb_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
64extern int smb_notify_change(struct dentry *dentry, struct iattr *attr); 64extern int smb_notify_change(struct dentry *dentry, struct iattr *attr);
65/* file.c */ 65/* file.c */
66extern struct address_space_operations smb_file_aops; 66extern const struct address_space_operations smb_file_aops;
67extern const struct file_operations smb_file_operations; 67extern const struct file_operations smb_file_operations;
68extern struct inode_operations smb_file_inode_operations; 68extern struct inode_operations smb_file_inode_operations;
69/* ioctl.c */ 69/* ioctl.c */
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index f0b347bd12ca..5e0e31cc46f5 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -16,7 +16,7 @@
16 16
17extern struct super_block * sysfs_sb; 17extern struct super_block * sysfs_sb;
18 18
19static struct address_space_operations sysfs_aops = { 19static const struct address_space_operations sysfs_aops = {
20 .readpage = simple_readpage, 20 .readpage = simple_readpage,
21 .prepare_write = simple_prepare_write, 21 .prepare_write = simple_prepare_write,
22 .commit_write = simple_commit_write 22 .commit_write = simple_commit_write
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index 86f5f8d43d0f..f2bcccd1d6fc 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -465,7 +465,7 @@ static sector_t sysv_bmap(struct address_space *mapping, sector_t block)
465{ 465{
466 return generic_block_bmap(mapping,block,get_block); 466 return generic_block_bmap(mapping,block,get_block);
467} 467}
468struct address_space_operations sysv_aops = { 468const struct address_space_operations sysv_aops = {
469 .readpage = sysv_readpage, 469 .readpage = sysv_readpage,
470 .writepage = sysv_writepage, 470 .writepage = sysv_writepage,
471 .sync_page = block_sync_page, 471 .sync_page = block_sync_page,
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index 393a480e4deb..9dcc82120935 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -161,7 +161,7 @@ extern struct inode_operations sysv_dir_inode_operations;
161extern struct inode_operations sysv_fast_symlink_inode_operations; 161extern struct inode_operations sysv_fast_symlink_inode_operations;
162extern const struct file_operations sysv_file_operations; 162extern const struct file_operations sysv_file_operations;
163extern const struct file_operations sysv_dir_operations; 163extern const struct file_operations sysv_dir_operations;
164extern struct address_space_operations sysv_aops; 164extern const struct address_space_operations sysv_aops;
165extern struct super_operations sysv_sops; 165extern struct super_operations sysv_sops;
166extern struct dentry_operations sysv_dentry_operations; 166extern struct dentry_operations sysv_dentry_operations;
167 167
diff --git a/fs/udf/file.c b/fs/udf/file.c
index e34b00e303f1..a59e5f33daf6 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -95,7 +95,7 @@ static int udf_adinicb_commit_write(struct file *file, struct page *page, unsign
95 return 0; 95 return 0;
96} 96}
97 97
98struct address_space_operations udf_adinicb_aops = { 98const struct address_space_operations udf_adinicb_aops = {
99 .readpage = udf_adinicb_readpage, 99 .readpage = udf_adinicb_readpage,
100 .writepage = udf_adinicb_writepage, 100 .writepage = udf_adinicb_writepage,
101 .sync_page = block_sync_page, 101 .sync_page = block_sync_page,
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 2983afd5e7fd..605f5111b6d8 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -132,7 +132,7 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block)
132 return generic_block_bmap(mapping,block,udf_get_block); 132 return generic_block_bmap(mapping,block,udf_get_block);
133} 133}
134 134
135struct address_space_operations udf_aops = { 135const struct address_space_operations udf_aops = {
136 .readpage = udf_readpage, 136 .readpage = udf_readpage,
137 .writepage = udf_writepage, 137 .writepage = udf_writepage,
138 .sync_page = block_sync_page, 138 .sync_page = block_sync_page,
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 674bb40edc83..ba068a786563 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -113,6 +113,6 @@ out:
113/* 113/*
114 * symlinks can't do much... 114 * symlinks can't do much...
115 */ 115 */
116struct address_space_operations udf_symlink_aops = { 116const struct address_space_operations udf_symlink_aops = {
117 .readpage = udf_symlink_filler, 117 .readpage = udf_symlink_filler,
118}; 118};
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 023e19ba5a2e..2f992387cc9e 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -47,9 +47,9 @@ extern struct inode_operations udf_dir_inode_operations;
47extern const struct file_operations udf_dir_operations; 47extern const struct file_operations udf_dir_operations;
48extern struct inode_operations udf_file_inode_operations; 48extern struct inode_operations udf_file_inode_operations;
49extern const struct file_operations udf_file_operations; 49extern const struct file_operations udf_file_operations;
50extern struct address_space_operations udf_aops; 50extern const struct address_space_operations udf_aops;
51extern struct address_space_operations udf_adinicb_aops; 51extern const struct address_space_operations udf_adinicb_aops;
52extern struct address_space_operations udf_symlink_aops; 52extern const struct address_space_operations udf_symlink_aops;
53 53
54struct udf_fileident_bh 54struct udf_fileident_bh
55{ 55{
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index f2dbdf5a8769..488b5ff48afb 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -98,7 +98,9 @@ static u64 ufs_frag_map(struct inode *inode, sector_t frag)
98 u64 temp = 0L; 98 u64 temp = 0L;
99 99
100 UFSD(": frag = %llu depth = %d\n", (unsigned long long)frag, depth); 100 UFSD(": frag = %llu depth = %d\n", (unsigned long long)frag, depth);
101 UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",uspi->s_fpbshift,uspi->s_apbmask,mask); 101 UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",
102 uspi->s_fpbshift, uspi->s_apbmask,
103 (unsigned long long)mask);
102 104
103 if (depth == 0) 105 if (depth == 0)
104 return 0; 106 return 0;
@@ -429,7 +431,7 @@ int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head
429 431
430 if (!create) { 432 if (!create) {
431 phys64 = ufs_frag_map(inode, fragment); 433 phys64 = ufs_frag_map(inode, fragment);
432 UFSD("phys64 = %llu \n",phys64); 434 UFSD("phys64 = %llu\n", (unsigned long long)phys64);
433 if (phys64) 435 if (phys64)
434 map_bh(bh_result, sb, phys64); 436 map_bh(bh_result, sb, phys64);
435 return 0; 437 return 0;
@@ -574,7 +576,7 @@ static sector_t ufs_bmap(struct address_space *mapping, sector_t block)
574{ 576{
575 return generic_block_bmap(mapping,block,ufs_getfrag_block); 577 return generic_block_bmap(mapping,block,ufs_getfrag_block);
576} 578}
577struct address_space_operations ufs_aops = { 579const struct address_space_operations ufs_aops = {
578 .readpage = ufs_readpage, 580 .readpage = ufs_readpage,
579 .writepage = ufs_writepage, 581 .writepage = ufs_writepage,
580 .sync_page = block_sync_page, 582 .sync_page = block_sync_page,
@@ -605,39 +607,12 @@ static void ufs_set_inode_ops(struct inode *inode)
605 ufs_get_inode_dev(inode->i_sb, UFS_I(inode))); 607 ufs_get_inode_dev(inode->i_sb, UFS_I(inode)));
606} 608}
607 609
608void ufs_read_inode (struct inode * inode) 610static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
609{ 611{
610 struct ufs_inode_info *ufsi = UFS_I(inode); 612 struct ufs_inode_info *ufsi = UFS_I(inode);
611 struct super_block * sb; 613 struct super_block *sb = inode->i_sb;
612 struct ufs_sb_private_info * uspi;
613 struct ufs_inode * ufs_inode;
614 struct ufs2_inode *ufs2_inode;
615 struct buffer_head * bh;
616 mode_t mode; 614 mode_t mode;
617 unsigned i; 615 unsigned i;
618 unsigned flags;
619
620 UFSD("ENTER, ino %lu\n", inode->i_ino);
621
622 sb = inode->i_sb;
623 uspi = UFS_SB(sb)->s_uspi;
624 flags = UFS_SB(sb)->s_flags;
625
626 if (inode->i_ino < UFS_ROOTINO ||
627 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
628 ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino);
629 goto bad_inode;
630 }
631
632 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
633 if (!bh) {
634 ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
635 goto bad_inode;
636 }
637 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
638 goto ufs2_inode;
639
640 ufs_inode = (struct ufs_inode *) (bh->b_data + sizeof(struct ufs_inode) * ufs_inotofsbo(inode->i_ino));
641 616
642 /* 617 /*
643 * Copy data to the in-core inode. 618 * Copy data to the in-core inode.
@@ -661,14 +636,11 @@ void ufs_read_inode (struct inode * inode)
661 inode->i_atime.tv_nsec = 0; 636 inode->i_atime.tv_nsec = 0;
662 inode->i_ctime.tv_nsec = 0; 637 inode->i_ctime.tv_nsec = 0;
663 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); 638 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
664 inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat) */
665 inode->i_version++;
666 ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags); 639 ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
667 ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen); 640 ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen);
668 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); 641 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
669 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); 642 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
670 ufsi->i_lastfrag = (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift; 643
671 ufsi->i_dir_start_lookup = 0;
672 644
673 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { 645 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
674 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 646 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
@@ -677,24 +649,16 @@ void ufs_read_inode (struct inode * inode)
677 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 649 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
678 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i]; 650 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i];
679 } 651 }
680 ufsi->i_osync = 0; 652}
681
682 ufs_set_inode_ops(inode);
683
684 brelse (bh);
685
686 UFSD("EXIT\n");
687 return;
688 653
689bad_inode: 654static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
690 make_bad_inode(inode); 655{
691 return; 656 struct ufs_inode_info *ufsi = UFS_I(inode);
657 struct super_block *sb = inode->i_sb;
658 mode_t mode;
659 unsigned i;
692 660
693ufs2_inode :
694 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); 661 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino);
695
696 ufs2_inode = (struct ufs2_inode *)(bh->b_data + sizeof(struct ufs2_inode) * ufs_inotofsbo(inode->i_ino));
697
698 /* 662 /*
699 * Copy data to the in-core inode. 663 * Copy data to the in-core inode.
700 */ 664 */
@@ -717,26 +681,64 @@ ufs2_inode :
717 inode->i_atime.tv_nsec = 0; 681 inode->i_atime.tv_nsec = 0;
718 inode->i_ctime.tv_nsec = 0; 682 inode->i_ctime.tv_nsec = 0;
719 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks); 683 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks);
720 inode->i_blksize = PAGE_SIZE; /*This is the optimal IO size(for stat)*/
721
722 inode->i_version++;
723 ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags); 684 ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags);
724 ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen); 685 ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen);
725 /* 686 /*
726 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); 687 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
727 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); 688 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
728 */ 689 */
729 ufsi->i_lastfrag= (inode->i_size + uspi->s_fsize- 1) >> uspi->s_fshift;
730 690
731 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { 691 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
732 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 692 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
733 ufsi->i_u1.u2_i_data[i] = 693 ufsi->i_u1.u2_i_data[i] =
734 ufs2_inode->ui_u2.ui_addr.ui_db[i]; 694 ufs2_inode->ui_u2.ui_addr.ui_db[i];
735 } 695 } else {
736 else {
737 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 696 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
738 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i]; 697 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i];
739 } 698 }
699}
700
701void ufs_read_inode(struct inode * inode)
702{
703 struct ufs_inode_info *ufsi = UFS_I(inode);
704 struct super_block * sb;
705 struct ufs_sb_private_info * uspi;
706 struct buffer_head * bh;
707
708 UFSD("ENTER, ino %lu\n", inode->i_ino);
709
710 sb = inode->i_sb;
711 uspi = UFS_SB(sb)->s_uspi;
712
713 if (inode->i_ino < UFS_ROOTINO ||
714 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
715 ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n",
716 inode->i_ino);
717 goto bad_inode;
718 }
719
720 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
721 if (!bh) {
722 ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n",
723 inode->i_ino);
724 goto bad_inode;
725 }
726 if ((UFS_SB(sb)->s_flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
727 struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data;
728
729 ufs2_read_inode(inode,
730 ufs2_inode + ufs_inotofsbo(inode->i_ino));
731 } else {
732 struct ufs_inode *ufs_inode = (struct ufs_inode *)bh->b_data;
733
734 ufs1_read_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino));
735 }
736
737 inode->i_blksize = PAGE_SIZE;/*This is the optimal IO size (for stat)*/
738 inode->i_version++;
739 ufsi->i_lastfrag =
740 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
741 ufsi->i_dir_start_lookup = 0;
740 ufsi->i_osync = 0; 742 ufsi->i_osync = 0;
741 743
742 ufs_set_inode_ops(inode); 744 ufs_set_inode_ops(inode);
@@ -745,6 +747,9 @@ ufs2_inode :
745 747
746 UFSD("EXIT\n"); 748 UFSD("EXIT\n");
747 return; 749 return;
750
751bad_inode:
752 make_bad_inode(inode);
748} 753}
749 754
750static int ufs_update_inode(struct inode * inode, int do_sync) 755static int ufs_update_inode(struct inode * inode, int do_sync)
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 3e807b828e22..c40f81ba9b13 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1454,7 +1454,7 @@ xfs_vm_invalidatepage(
1454 block_invalidatepage(page, offset); 1454 block_invalidatepage(page, offset);
1455} 1455}
1456 1456
1457struct address_space_operations xfs_address_space_operations = { 1457const struct address_space_operations xfs_address_space_operations = {
1458 .readpage = xfs_vm_readpage, 1458 .readpage = xfs_vm_readpage,
1459 .readpages = xfs_vm_readpages, 1459 .readpages = xfs_vm_readpages,
1460 .writepage = xfs_vm_writepage, 1460 .writepage = xfs_vm_writepage,
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 706d8c781b8a..2244e516b66a 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -40,7 +40,7 @@ typedef struct xfs_ioend {
40 struct work_struct io_work; /* xfsdatad work queue */ 40 struct work_struct io_work; /* xfsdatad work queue */
41} xfs_ioend_t; 41} xfs_ioend_t;
42 42
43extern struct address_space_operations xfs_address_space_operations; 43extern const struct address_space_operations xfs_address_space_operations;
44extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int); 44extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int);
45 45
46#endif /* __XFS_AOPS_H__ */ 46#endif /* __XFS_AOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 26fed0756f01..2af528dcfb04 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1520,7 +1520,7 @@ xfs_mapping_buftarg(
1520 struct backing_dev_info *bdi; 1520 struct backing_dev_info *bdi;
1521 struct inode *inode; 1521 struct inode *inode;
1522 struct address_space *mapping; 1522 struct address_space *mapping;
1523 static struct address_space_operations mapping_aops = { 1523 static const struct address_space_operations mapping_aops = {
1524 .sync_page = block_sync_page, 1524 .sync_page = block_sync_page,
1525 .migratepage = fail_migrate_page, 1525 .migratepage = fail_migrate_page,
1526 }; 1526 };
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 12810baeb5d4..d9180020de63 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -419,16 +419,15 @@ xfs_vn_link(
419 int error; 419 int error;
420 420
421 ip = old_dentry->d_inode; /* inode being linked to */ 421 ip = old_dentry->d_inode; /* inode being linked to */
422 if (S_ISDIR(ip->i_mode))
423 return -EPERM;
424
425 tdvp = vn_from_inode(dir); 422 tdvp = vn_from_inode(dir);
426 vp = vn_from_inode(ip); 423 vp = vn_from_inode(ip);
427 424
425 VN_HOLD(vp);
428 error = bhv_vop_link(tdvp, vp, dentry, NULL); 426 error = bhv_vop_link(tdvp, vp, dentry, NULL);
429 if (likely(!error)) { 427 if (unlikely(error)) {
428 VN_RELE(vp);
429 } else {
430 VMODIFY(tdvp); 430 VMODIFY(tdvp);
431 VN_HOLD(vp);
432 xfs_validate_fields(ip, &vattr); 431 xfs_validate_fields(ip, &vattr);
433 d_instantiate(dentry, ip); 432 d_instantiate(dentry, ip);
434 } 433 }
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index aa26ab906c88..028eb17ec2ed 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -140,9 +140,7 @@ BUFFER_FNS(PrivateStart, unwritten);
140#define current_pid() (current->pid) 140#define current_pid() (current->pid)
141#define current_fsuid(cred) (current->fsuid) 141#define current_fsuid(cred) (current->fsuid)
142#define current_fsgid(cred) (current->fsgid) 142#define current_fsgid(cred) (current->fsgid)
143#define current_set_flags(f) (current->flags |= (f))
144#define current_test_flags(f) (current->flags & (f)) 143#define current_test_flags(f) (current->flags & (f))
145#define current_clear_flags(f) (current->flags & ~(f))
146#define current_set_flags_nested(sp, f) \ 144#define current_set_flags_nested(sp, f) \
147 (*(sp) = current->flags, current->flags |= (f)) 145 (*(sp) = current->flags, current->flags |= (f))
148#define current_clear_flags_nested(sp, f) \ 146#define current_clear_flags_nested(sp, f) \
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 35c6a01963a7..c42b3221b20c 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -93,7 +93,7 @@ typedef enum {
93 */ 93 */
94static inline struct bhv_vnode *vn_from_inode(struct inode *inode) 94static inline struct bhv_vnode *vn_from_inode(struct inode *inode)
95{ 95{
96 return (bhv_vnode_t *)list_entry(inode, bhv_vnode_t, v_inode); 96 return container_of(inode, bhv_vnode_t, v_inode);
97} 97}
98static inline struct inode *vn_to_inode(struct bhv_vnode *vnode) 98static inline struct inode *vn_to_inode(struct bhv_vnode *vnode)
99{ 99{
diff --git a/fs/xfs/xfs_behavior.h b/fs/xfs/xfs_behavior.h
index 1d8ff103201c..6e6e56fb352d 100644
--- a/fs/xfs/xfs_behavior.h
+++ b/fs/xfs/xfs_behavior.h
@@ -78,15 +78,12 @@
78 * 78 *
79 */ 79 */
80 80
81struct bhv_head_lock;
82
83/* 81/*
84 * Behavior head. Head of the chain of behaviors. 82 * Behavior head. Head of the chain of behaviors.
85 * Contained within each virtualized object data structure. 83 * Contained within each virtualized object data structure.
86 */ 84 */
87typedef struct bhv_head { 85typedef struct bhv_head {
88 struct bhv_desc *bh_first; /* first behavior in chain */ 86 struct bhv_desc *bh_first; /* first behavior in chain */
89 struct bhv_head_lock *bh_lockp; /* pointer to lock info struct */
90} bhv_head_t; 87} bhv_head_t;
91 88
92/* 89/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 5fa0adb7e173..86c1bf0bba9e 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1961,9 +1961,9 @@ xfs_iunlink_remove(
1961 xfs_agino_t agino; 1961 xfs_agino_t agino;
1962 xfs_agino_t next_agino; 1962 xfs_agino_t next_agino;
1963 xfs_buf_t *last_ibp; 1963 xfs_buf_t *last_ibp;
1964 xfs_dinode_t *last_dip; 1964 xfs_dinode_t *last_dip = NULL;
1965 short bucket_index; 1965 short bucket_index;
1966 int offset, last_offset; 1966 int offset, last_offset = 0;
1967 int error; 1967 int error;
1968 int agi_ok; 1968 int agi_ok;
1969 1969
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index d8f5d4cbe8b7..e730328636c3 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1740,10 +1740,10 @@ xlog_write(xfs_mount_t * mp,
1740 xlog_in_core_t **commit_iclog, 1740 xlog_in_core_t **commit_iclog,
1741 uint flags) 1741 uint flags)
1742{ 1742{
1743 xlog_t *log = mp->m_log; 1743 xlog_t *log = mp->m_log;
1744 xlog_ticket_t *ticket = (xlog_ticket_t *)tic; 1744 xlog_ticket_t *ticket = (xlog_ticket_t *)tic;
1745 xlog_in_core_t *iclog = NULL; /* ptr to current in-core log */
1745 xlog_op_header_t *logop_head; /* ptr to log operation header */ 1746 xlog_op_header_t *logop_head; /* ptr to log operation header */
1746 xlog_in_core_t *iclog; /* ptr to current in-core log */
1747 __psint_t ptr; /* copy address into data region */ 1747 __psint_t ptr; /* copy address into data region */
1748 int len; /* # xlog_write() bytes 2 still copy */ 1748 int len; /* # xlog_write() bytes 2 still copy */
1749 int index; /* region index currently copying */ 1749 int index; /* region index currently copying */
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 55b4237c2153..3cb678e3a132 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -990,6 +990,8 @@ xlog_find_zeroed(
990 xfs_daddr_t num_scan_bblks; 990 xfs_daddr_t num_scan_bblks;
991 int error, log_bbnum = log->l_logBBsize; 991 int error, log_bbnum = log->l_logBBsize;
992 992
993 *blk_no = 0;
994
993 /* check totally zeroed log */ 995 /* check totally zeroed log */
994 bp = xlog_get_bp(log, 1); 996 bp = xlog_get_bp(log, 1);
995 if (!bp) 997 if (!bp)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 10dbf203c62f..4be5c0b2d296 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1721,15 +1721,14 @@ xfs_mount_log_sbunit(
1721 * is present to prevent thrashing). 1721 * is present to prevent thrashing).
1722 */ 1722 */
1723 1723
1724#ifdef CONFIG_HOTPLUG_CPU
1724/* 1725/*
1725 * hot-plug CPU notifier support. 1726 * hot-plug CPU notifier support.
1726 * 1727 *
1727 * We cannot use the hotcpu_register() function because it does 1728 * We need a notifier per filesystem as we need to be able to identify
1728 * not allow notifier instances. We need a notifier per filesystem 1729 * the filesystem to balance the counters out. This is achieved by
1729 * as we need to be able to identify the filesystem to balance 1730 * having a notifier block embedded in the xfs_mount_t and doing pointer
1730 * the counters out. This is achieved by having a notifier block 1731 * magic to get the mount pointer from the notifier block address.
1731 * embedded in the xfs_mount_t and doing pointer magic to get the
1732 * mount pointer from the notifier block address.
1733 */ 1732 */
1734STATIC int 1733STATIC int
1735xfs_icsb_cpu_notify( 1734xfs_icsb_cpu_notify(
@@ -1779,6 +1778,7 @@ xfs_icsb_cpu_notify(
1779 1778
1780 return NOTIFY_OK; 1779 return NOTIFY_OK;
1781} 1780}
1781#endif /* CONFIG_HOTPLUG_CPU */
1782 1782
1783int 1783int
1784xfs_icsb_init_counters( 1784xfs_icsb_init_counters(
@@ -1791,9 +1791,11 @@ xfs_icsb_init_counters(
1791 if (mp->m_sb_cnts == NULL) 1791 if (mp->m_sb_cnts == NULL)
1792 return -ENOMEM; 1792 return -ENOMEM;
1793 1793
1794#ifdef CONFIG_HOTPLUG_CPU
1794 mp->m_icsb_notifier.notifier_call = xfs_icsb_cpu_notify; 1795 mp->m_icsb_notifier.notifier_call = xfs_icsb_cpu_notify;
1795 mp->m_icsb_notifier.priority = 0; 1796 mp->m_icsb_notifier.priority = 0;
1796 register_cpu_notifier(&mp->m_icsb_notifier); 1797 register_hotcpu_notifier(&mp->m_icsb_notifier);
1798#endif /* CONFIG_HOTPLUG_CPU */
1797 1799
1798 for_each_online_cpu(i) { 1800 for_each_online_cpu(i) {
1799 cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i); 1801 cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
@@ -1812,7 +1814,7 @@ xfs_icsb_destroy_counters(
1812 xfs_mount_t *mp) 1814 xfs_mount_t *mp)
1813{ 1815{
1814 if (mp->m_sb_cnts) { 1816 if (mp->m_sb_cnts) {
1815 unregister_cpu_notifier(&mp->m_icsb_notifier); 1817 unregister_hotcpu_notifier(&mp->m_icsb_notifier);
1816 free_percpu(mp->m_sb_cnts); 1818 free_percpu(mp->m_sb_cnts);
1817 } 1819 }
1818} 1820}
@@ -2026,7 +2028,7 @@ xfs_icsb_balance_counter(
2026 xfs_sb_field_t field, 2028 xfs_sb_field_t field,
2027 int flags) 2029 int flags)
2028{ 2030{
2029 uint64_t count, resid = 0; 2031 uint64_t count, resid;
2030 int weight = num_online_cpus(); 2032 int weight = num_online_cpus();
2031 int s; 2033 int s;
2032 2034
@@ -2058,6 +2060,7 @@ xfs_icsb_balance_counter(
2058 break; 2060 break;
2059 default: 2061 default:
2060 BUG(); 2062 BUG();
2063 count = resid = 0; /* quiet, gcc */
2061 break; 2064 break;
2062 } 2065 }
2063 2066
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 0c1e42b037ef..5a0b678956e0 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1929,7 +1929,7 @@ xfs_growfs_rt(
1929 /* 1929 /*
1930 * Initial error checking. 1930 * Initial error checking.
1931 */ 1931 */
1932 if (mp->m_rtdev_targp || mp->m_rbmip == NULL || 1932 if (mp->m_rtdev_targp == NULL || mp->m_rbmip == NULL ||
1933 (nrblocks = in->newblocks) <= sbp->sb_rblocks || 1933 (nrblocks = in->newblocks) <= sbp->sb_rblocks ||
1934 (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize))) 1934 (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize)))
1935 return XFS_ERROR(EINVAL); 1935 return XFS_ERROR(EINVAL);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index cb65c3a603f5..9dc88b380608 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -338,8 +338,6 @@ typedef void (*xfs_trans_callback_t)(struct xfs_trans *, void *);
338typedef struct xfs_trans { 338typedef struct xfs_trans {
339 unsigned int t_magic; /* magic number */ 339 unsigned int t_magic; /* magic number */
340 xfs_log_callback_t t_logcb; /* log callback struct */ 340 xfs_log_callback_t t_logcb; /* log callback struct */
341 struct xfs_trans *t_forw; /* async list pointers */
342 struct xfs_trans *t_back; /* async list pointers */
343 unsigned int t_type; /* transaction type */ 341 unsigned int t_type; /* transaction type */
344 unsigned int t_log_res; /* amt of log space resvd */ 342 unsigned int t_log_res; /* amt of log space resvd */
345 unsigned int t_log_count; /* count for perm log res */ 343 unsigned int t_log_count; /* count for perm log res */
@@ -364,9 +362,11 @@ typedef struct xfs_trans {
364 long t_res_fdblocks_delta; /* on-disk only chg */ 362 long t_res_fdblocks_delta; /* on-disk only chg */
365 long t_frextents_delta;/* superblock freextents chg*/ 363 long t_frextents_delta;/* superblock freextents chg*/
366 long t_res_frextents_delta; /* on-disk only chg */ 364 long t_res_frextents_delta; /* on-disk only chg */
365#ifdef DEBUG
367 long t_ag_freeblks_delta; /* debugging counter */ 366 long t_ag_freeblks_delta; /* debugging counter */
368 long t_ag_flist_delta; /* debugging counter */ 367 long t_ag_flist_delta; /* debugging counter */
369 long t_ag_btree_delta; /* debugging counter */ 368 long t_ag_btree_delta; /* debugging counter */
369#endif
370 long t_dblocks_delta;/* superblock dblocks change */ 370 long t_dblocks_delta;/* superblock dblocks change */
371 long t_agcount_delta;/* superblock agcount change */ 371 long t_agcount_delta;/* superblock agcount change */
372 long t_imaxpct_delta;/* superblock imaxpct change */ 372 long t_imaxpct_delta;/* superblock imaxpct change */
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 00a6b7dc24a0..23cfa5837728 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -2603,8 +2603,7 @@ xfs_link(
2603 vn_trace_entry(src_vp, __FUNCTION__, (inst_t *)__return_address); 2603 vn_trace_entry(src_vp, __FUNCTION__, (inst_t *)__return_address);
2604 2604
2605 target_namelen = VNAMELEN(dentry); 2605 target_namelen = VNAMELEN(dentry);
2606 if (VN_ISDIR(src_vp)) 2606 ASSERT(!VN_ISDIR(src_vp));
2607 return XFS_ERROR(EPERM);
2608 2607
2609 sip = xfs_vtoi(src_vp); 2608 sip = xfs_vtoi(src_vp);
2610 tdp = XFS_BHVTOI(target_dir_bdp); 2609 tdp = XFS_BHVTOI(target_dir_bdp);
@@ -2699,9 +2698,8 @@ xfs_link(
2699 xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE); 2698 xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE);
2700 2699
2701 error = xfs_bumplink(tp, sip); 2700 error = xfs_bumplink(tp, sip);
2702 if (error) { 2701 if (error)
2703 goto abort_return; 2702 goto abort_return;
2704 }
2705 2703
2706 /* 2704 /*
2707 * If this is a synchronous mount, make sure that the 2705 * If this is a synchronous mount, make sure that the
@@ -2719,9 +2717,8 @@ xfs_link(
2719 } 2717 }
2720 2718
2721 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); 2719 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
2722 if (error) { 2720 if (error)
2723 goto std_return; 2721 goto std_return;
2724 }
2725 2722
2726 /* Fall through to std_return with error = 0. */ 2723 /* Fall through to std_return with error = 0. */
2727std_return: 2724std_return:
@@ -2742,6 +2739,8 @@ std_return:
2742 xfs_trans_cancel(tp, cancel_flags); 2739 xfs_trans_cancel(tp, cancel_flags);
2743 goto std_return; 2740 goto std_return;
2744} 2741}
2742
2743
2745/* 2744/*
2746 * xfs_mkdir 2745 * xfs_mkdir
2747 * 2746 *
diff --git a/include/asm-alpha/core_t2.h b/include/asm-alpha/core_t2.h
index dba70c62a16c..457c34b6eb09 100644
--- a/include/asm-alpha/core_t2.h
+++ b/include/asm-alpha/core_t2.h
@@ -435,7 +435,7 @@ static inline void t2_outl(u32 b, unsigned long addr)
435 set_hae(msb); \ 435 set_hae(msb); \
436} 436}
437 437
438static spinlock_t t2_hae_lock = SPIN_LOCK_UNLOCKED; 438static DEFINE_SPINLOCK(t2_hae_lock);
439 439
440__EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr) 440__EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr)
441{ 441{
diff --git a/include/asm-alpha/hw_irq.h b/include/asm-alpha/hw_irq.h
index ca9d43b63502..a37db0f95092 100644
--- a/include/asm-alpha/hw_irq.h
+++ b/include/asm-alpha/hw_irq.h
@@ -2,8 +2,6 @@
2#define _ALPHA_HW_IRQ_H 2#define _ALPHA_HW_IRQ_H
3 3
4 4
5static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
6
7extern volatile unsigned long irq_err_count; 5extern volatile unsigned long irq_err_count;
8 6
9#ifdef CONFIG_ALPHA_GENERIC 7#ifdef CONFIG_ALPHA_GENERIC
diff --git a/include/asm-arm/arch-at91rm9200/memory.h b/include/asm-arm/arch-at91rm9200/memory.h
index 3c327c404373..f985069e6d01 100644
--- a/include/asm-arm/arch-at91rm9200/memory.h
+++ b/include/asm-arm/arch-at91rm9200/memory.h
@@ -33,9 +33,7 @@
33 * bus_to_virt: Used to convert an address for DMA operations 33 * bus_to_virt: Used to convert an address for DMA operations
34 * to an address that the kernel can use. 34 * to an address that the kernel can use.
35 */ 35 */
36#define __virt_to_bus__is_a_macro
37#define __virt_to_bus(x) __virt_to_phys(x) 36#define __virt_to_bus(x) __virt_to_phys(x)
38#define __bus_to_virt__is_a_macro
39#define __bus_to_virt(x) __phys_to_virt(x) 37#define __bus_to_virt(x) __phys_to_virt(x)
40 38
41#endif 39#endif
diff --git a/include/asm-arm/arch-h720x/memory.h b/include/asm-arm/arch-h720x/memory.h
index 4a1bfd78a0fe..53e923dba76e 100644
--- a/include/asm-arm/arch-h720x/memory.h
+++ b/include/asm-arm/arch-h720x/memory.h
@@ -23,9 +23,7 @@
23 * There is something to do here later !, Mar 2000, Jungjun Kim 23 * There is something to do here later !, Mar 2000, Jungjun Kim
24 */ 24 */
25 25
26#define __virt_to_bus__is_a_macro
27#define __virt_to_bus(x) __virt_to_phys(x) 26#define __virt_to_bus(x) __virt_to_phys(x)
28#define __bus_to_virt__is_a_macro
29#define __bus_to_virt(x) __phys_to_virt(x) 27#define __bus_to_virt(x) __phys_to_virt(x)
30 28
31#endif 29#endif
diff --git a/include/asm-arm/arch-imx/memory.h b/include/asm-arm/arch-imx/memory.h
index d09ae32cd2f4..5ad90127915f 100644
--- a/include/asm-arm/arch-imx/memory.h
+++ b/include/asm-arm/arch-imx/memory.h
@@ -30,9 +30,7 @@
30 * bus_to_virt: Used to convert an address for DMA operations 30 * bus_to_virt: Used to convert an address for DMA operations
31 * to an address that the kernel can use. 31 * to an address that the kernel can use.
32 */ 32 */
33#define __virt_to_bus__is_a_macro 33#define __virt_to_bus(x) (x - PAGE_OFFSET + PHYS_OFFSET)
34#define __virt_to_bus(x) (x - PAGE_OFFSET + PHYS_OFFSET) 34#define __bus_to_virt(x) (x - PHYS_OFFSET + PAGE_OFFSET)
35#define __bus_to_virt__is_a_macro
36#define __bus_to_virt(x) (x - PHYS_OFFSET + PAGE_OFFSET)
37 35
38#endif 36#endif
diff --git a/include/asm-arm/arch-ixp23xx/ixp23xx.h b/include/asm-arm/arch-ixp23xx/ixp23xx.h
index d0a72201ee96..3927b1d61b17 100644
--- a/include/asm-arm/arch-ixp23xx/ixp23xx.h
+++ b/include/asm-arm/arch-ixp23xx/ixp23xx.h
@@ -295,15 +295,4 @@
295#define IXP23XX_PCI_CPP_ADDR_BITS IXP23XX_PCI_CSR(0x0160) 295#define IXP23XX_PCI_CPP_ADDR_BITS IXP23XX_PCI_CSR(0x0160)
296 296
297 297
298#ifndef __ASSEMBLY__
299/*
300 * Is system memory on the XSI or CPP bus?
301 */
302static inline unsigned ixp23xx_cpp_boot(void)
303{
304 return (*IXP23XX_EXP_CFG0 & IXP23XX_EXP_CFG0_XSI_NOT_PRES);
305}
306#endif
307
308
309#endif 298#endif
diff --git a/include/asm-arm/arch-ixp23xx/platform.h b/include/asm-arm/arch-ixp23xx/platform.h
index 19a73b39c864..56e16d66645a 100644
--- a/include/asm-arm/arch-ixp23xx/platform.h
+++ b/include/asm-arm/arch-ixp23xx/platform.h
@@ -43,5 +43,15 @@ extern struct sys_timer ixp23xx_timer;
43 43
44#define IXP23XX_UART_XTAL 14745600 44#define IXP23XX_UART_XTAL 14745600
45 45
46#ifndef __ASSEMBLY__
47/*
48 * Is system memory on the XSI or CPP bus?
49 */
50static inline unsigned ixp23xx_cpp_boot(void)
51{
52 return (*IXP23XX_EXP_CFG0 & IXP23XX_EXP_CFG0_XSI_NOT_PRES);
53}
54#endif
55
46 56
47#endif 57#endif
diff --git a/include/asm-arm/arch-ixp23xx/uncompress.h b/include/asm-arm/arch-ixp23xx/uncompress.h
index 013575e6a9a1..16c1110f2304 100644
--- a/include/asm-arm/arch-ixp23xx/uncompress.h
+++ b/include/asm-arm/arch-ixp23xx/uncompress.h
@@ -11,7 +11,7 @@
11#ifndef __ASM_ARCH_UNCOMPRESS_H 11#ifndef __ASM_ARCH_UNCOMPRESS_H
12#define __ASM_ARCH_UNCOMPRESS_H 12#define __ASM_ARCH_UNCOMPRESS_H
13 13
14#include <asm/hardware.h> 14#include <asm/arch/ixp23xx.h>
15#include <linux/serial_reg.h> 15#include <linux/serial_reg.h>
16 16
17#define UART_BASE ((volatile u32 *)IXP23XX_UART1_PHYS) 17#define UART_BASE ((volatile u32 *)IXP23XX_UART1_PHYS)
diff --git a/include/asm-arm/arch-s3c2410/regs-dsc.h b/include/asm-arm/arch-s3c2410/regs-dsc.h
index 84aca61cbaa3..a0a124875164 100644
--- a/include/asm-arm/arch-s3c2410/regs-dsc.h
+++ b/include/asm-arm/arch-s3c2410/regs-dsc.h
@@ -7,25 +7,23 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * S3C2440 Signal Drive Strength Control 10 * S3C2440/S3C2412 Signal Drive Strength Control
11 *
12 * Changelog:
13 * 11-Aug-2004 BJD Created file
14 * 25-Aug-2004 BJD Added the _SELECT_* defs for using with functions
15*/ 11*/
16 12
17 13
18#ifndef __ASM_ARCH_REGS_DSC_H 14#ifndef __ASM_ARCH_REGS_DSC_H
19#define __ASM_ARCH_REGS_DSC_H "2440-dsc" 15#define __ASM_ARCH_REGS_DSC_H "2440-dsc"
20 16
21#ifdef CONFIG_CPU_S3C2440 17#if defined(CONFIG_CPU_S3C2412)
18#define S3C2412_DSC0 S3C2410_GPIOREG(0xdc)
19#define S3C2412_DSC1 S3C2410_GPIOREG(0xe0)
20#endif
21
22#if defined(CONFIG_CPU_S3C2440)
22 23
23#define S3C2440_DSC0 S3C2410_GPIOREG(0xc4) 24#define S3C2440_DSC0 S3C2410_GPIOREG(0xc4)
24#define S3C2440_DSC1 S3C2410_GPIOREG(0xc8) 25#define S3C2440_DSC1 S3C2410_GPIOREG(0xc8)
25 26
26#define S3C2412_DSC0 S3C2410_GPIOREG(0xdc)
27#define S3C2412_DSC1 S3C2410_GPIOREG(0xe0)
28
29#define S3C2440_SELECT_DSC0 (0) 27#define S3C2440_SELECT_DSC0 (0)
30#define S3C2440_SELECT_DSC1 (1<<31) 28#define S3C2440_SELECT_DSC1 (1<<31)
31 29
diff --git a/include/asm-arm/arch-s3c2410/regs-nand.h b/include/asm-arm/arch-s3c2410/regs-nand.h
index 7cff235e667a..c1470c695c33 100644
--- a/include/asm-arm/arch-s3c2410/regs-nand.h
+++ b/include/asm-arm/arch-s3c2410/regs-nand.h
@@ -39,10 +39,19 @@
39#define S3C2440_NFESTAT1 S3C2410_NFREG(0x28) 39#define S3C2440_NFESTAT1 S3C2410_NFREG(0x28)
40#define S3C2440_NFMECC0 S3C2410_NFREG(0x2C) 40#define S3C2440_NFMECC0 S3C2410_NFREG(0x2C)
41#define S3C2440_NFMECC1 S3C2410_NFREG(0x30) 41#define S3C2440_NFMECC1 S3C2410_NFREG(0x30)
42#define S3C2440_NFSECC S3C2410_NFREG(0x34) 42#define S3C2440_NFSECC S3C24E10_NFREG(0x34)
43#define S3C2440_NFSBLK S3C2410_NFREG(0x38) 43#define S3C2440_NFSBLK S3C2410_NFREG(0x38)
44#define S3C2440_NFEBLK S3C2410_NFREG(0x3C) 44#define S3C2440_NFEBLK S3C2410_NFREG(0x3C)
45 45
46#define S3C2412_NFSBLK S3C2410_NFREG(0x20)
47#define S3C2412_NFEBLK S3C2410_NFREG(0x24)
48#define S3C2412_NFSTAT S3C2410_NFREG(0x28)
49#define S3C2412_NFMECC_ERR0 S3C2410_NFREG(0x2C)
50#define S3C2412_NFMECC_ERR1 S3C2410_NFREG(0x30)
51#define S3C2412_NFMECC0 S3C2410_NFREG(0x34)
52#define S3C2412_NFMECC1 S3C2410_NFREG(0x38)
53#define S3C2412_NFSECC S3C2410_NFREG(0x3C)
54
46#define S3C2410_NFCONF_EN (1<<15) 55#define S3C2410_NFCONF_EN (1<<15)
47#define S3C2410_NFCONF_512BYTE (1<<14) 56#define S3C2410_NFCONF_512BYTE (1<<14)
48#define S3C2410_NFCONF_4STEP (1<<13) 57#define S3C2410_NFCONF_4STEP (1<<13)
@@ -77,5 +86,42 @@
77#define S3C2440_NFSTAT_RnB_CHANGE (1<<2) 86#define S3C2440_NFSTAT_RnB_CHANGE (1<<2)
78#define S3C2440_NFSTAT_ILLEGAL_ACCESS (1<<3) 87#define S3C2440_NFSTAT_ILLEGAL_ACCESS (1<<3)
79 88
89#define S3C2412_NFCONF_NANDBOOT (1<<31)
90#define S3C2412_NFCONF_ECCCLKCON (1<<30)
91#define S3C2412_NFCONF_ECC_MLC (1<<24)
92#define S3C2412_NFCONF_TACLS_MASK (7<<12) /* 1 extra bit of Tacls */
93
94#define S3C2412_NFCONT_ECC4_DIRWR (1<<18)
95#define S3C2412_NFCONT_LOCKTIGHT (1<<17)
96#define S3C2412_NFCONT_SOFTLOCK (1<<16)
97#define S3C2412_NFCONT_ECC4_ENCINT (1<<13)
98#define S3C2412_NFCONT_ECC4_DECINT (1<<12)
99#define S3C2412_NFCONT_MAIN_ECC_LOCK (1<<7)
100#define S3C2412_NFCONT_INIT_MAIN_ECC (1<<5)
101#define S3C2412_NFCONT_nFCE1 (1<<2)
102#define S3C2412_NFCONT_nFCE0 (1<<1)
103
104#define S3C2412_NFSTAT_ECC_ENCDONE (1<<7)
105#define S3C2412_NFSTAT_ECC_DECDONE (1<<6)
106#define S3C2412_NFSTAT_ILLEGAL_ACCESS (1<<5)
107#define S3C2412_NFSTAT_RnB_CHANGE (1<<4)
108#define S3C2412_NFSTAT_nFCE1 (1<<3)
109#define S3C2412_NFSTAT_nFCE0 (1<<2)
110#define S3C2412_NFSTAT_Res1 (1<<1)
111#define S3C2412_NFSTAT_READY (1<<0)
112
113#define S3C2412_NFECCERR_SERRDATA(x) (((x) >> 21) & 0xf)
114#define S3C2412_NFECCERR_SERRBIT(x) (((x) >> 18) & 0x7)
115#define S3C2412_NFECCERR_MERRDATA(x) (((x) >> 7) & 0x3ff)
116#define S3C2412_NFECCERR_MERRBIT(x) (((x) >> 4) & 0x7)
117#define S3C2412_NFECCERR_SPARE_ERR(x) (((x) >> 2) & 0x3)
118#define S3C2412_NFECCERR_MAIN_ERR(x) (((x) >> 2) & 0x3)
119#define S3C2412_NFECCERR_NONE (0)
120#define S3C2412_NFECCERR_1BIT (1)
121#define S3C2412_NFECCERR_MULTIBIT (2)
122#define S3C2412_NFECCERR_ECCAREA (3)
123
124
125
80#endif /* __ASM_ARM_REGS_NAND */ 126#endif /* __ASM_ARM_REGS_NAND */
81 127
diff --git a/include/asm-arm/bugs.h b/include/asm-arm/bugs.h
index 4c80ec519d45..ca54eb0f12d7 100644
--- a/include/asm-arm/bugs.h
+++ b/include/asm-arm/bugs.h
@@ -10,8 +10,12 @@
10#ifndef __ASM_BUGS_H 10#ifndef __ASM_BUGS_H
11#define __ASM_BUGS_H 11#define __ASM_BUGS_H
12 12
13#ifdef CONFIG_MMU
13extern void check_writebuffer_bugs(void); 14extern void check_writebuffer_bugs(void);
14 15
15#define check_bugs() check_writebuffer_bugs() 16#define check_bugs() check_writebuffer_bugs()
17#else
18#define check_bugs() do { } while (0)
19#endif
16 20
17#endif 21#endif
diff --git a/include/asm-arm/domain.h b/include/asm-arm/domain.h
index f8ea2de4848e..4c2885abbe6c 100644
--- a/include/asm-arm/domain.h
+++ b/include/asm-arm/domain.h
@@ -50,6 +50,8 @@
50#define domain_val(dom,type) ((type) << (2*(dom))) 50#define domain_val(dom,type) ((type) << (2*(dom)))
51 51
52#ifndef __ASSEMBLY__ 52#ifndef __ASSEMBLY__
53
54#ifdef CONFIG_MMU
53#define set_domain(x) \ 55#define set_domain(x) \
54 do { \ 56 do { \
55 __asm__ __volatile__( \ 57 __asm__ __volatile__( \
@@ -66,5 +68,10 @@
66 set_domain(thread->cpu_domain); \ 68 set_domain(thread->cpu_domain); \
67 } while (0) 69 } while (0)
68 70
71#else
72#define set_domain(x) do { } while (0)
73#define modify_domain(dom,type) do { } while (0)
74#endif
75
69#endif 76#endif
70#endif /* !__ASSEMBLY__ */ 77#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-arm/fpstate.h b/include/asm-arm/fpstate.h
index 132c3c5628b2..6af4e6bd1290 100644
--- a/include/asm-arm/fpstate.h
+++ b/include/asm-arm/fpstate.h
@@ -72,6 +72,14 @@ union fp_state {
72 72
73#define FP_SIZE (sizeof(union fp_state) / sizeof(int)) 73#define FP_SIZE (sizeof(union fp_state) / sizeof(int))
74 74
75struct crunch_state {
76 unsigned int mvdx[16][2];
77 unsigned int mvax[4][3];
78 unsigned int dspsc[2];
79};
80
81#define CRUNCH_SIZE sizeof(struct crunch_state)
82
75#endif 83#endif
76 84
77#endif 85#endif
diff --git a/include/asm-arm/mach/map.h b/include/asm-arm/mach/map.h
index e8ea67c97c73..cef5364ed5fe 100644
--- a/include/asm-arm/mach/map.h
+++ b/include/asm-arm/mach/map.h
@@ -16,8 +16,6 @@ struct map_desc {
16 unsigned int type; 16 unsigned int type;
17}; 17};
18 18
19struct meminfo;
20
21#define MT_DEVICE 0 19#define MT_DEVICE 0
22#define MT_CACHECLEAN 1 20#define MT_CACHECLEAN 1
23#define MT_MINICLEAN 2 21#define MT_MINICLEAN 2
@@ -28,7 +26,8 @@ struct meminfo;
28#define MT_IXP2000_DEVICE 7 26#define MT_IXP2000_DEVICE 7
29#define MT_NONSHARED_DEVICE 8 27#define MT_NONSHARED_DEVICE 8
30 28
31extern void create_memmap_holes(struct meminfo *); 29#ifdef CONFIG_MMU
32extern void memtable_init(struct meminfo *);
33extern void iotable_init(struct map_desc *, int); 30extern void iotable_init(struct map_desc *, int);
34extern void setup_io_desc(void); 31#else
32#define iotable_init(map,num) do { } while (0)
33#endif
diff --git a/include/asm-arm/mach/pci.h b/include/asm-arm/mach/pci.h
index 25d540ed0079..923e0ca66200 100644
--- a/include/asm-arm/mach/pci.h
+++ b/include/asm-arm/mach/pci.h
@@ -28,7 +28,7 @@ struct hw_pci {
28struct pci_sys_data { 28struct pci_sys_data {
29 struct list_head node; 29 struct list_head node;
30 int busnr; /* primary bus number */ 30 int busnr; /* primary bus number */
31 unsigned long mem_offset; /* bus->cpu memory mapping offset */ 31 u64 mem_offset; /* bus->cpu memory mapping offset */
32 unsigned long io_offset; /* bus->cpu IO mapping offset */ 32 unsigned long io_offset; /* bus->cpu IO mapping offset */
33 struct pci_bus *bus; /* PCI bus */ 33 struct pci_bus *bus; /* PCI bus */
34 struct resource *resource[3]; /* Primary PCI bus resources */ 34 struct resource *resource[3]; /* Primary PCI bus resources */
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h
index 731e321a57d1..94f973b704f1 100644
--- a/include/asm-arm/memory.h
+++ b/include/asm-arm/memory.h
@@ -2,6 +2,7 @@
2 * linux/include/asm-arm/memory.h 2 * linux/include/asm-arm/memory.h
3 * 3 *
4 * Copyright (C) 2000-2002 Russell King 4 * Copyright (C) 2000-2002 Russell King
5 * modification for nommu, Hyok S. Choi, 2004
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License version 2 as
@@ -26,6 +27,8 @@
26#include <asm/arch/memory.h> 27#include <asm/arch/memory.h>
27#include <asm/sizes.h> 28#include <asm/sizes.h>
28 29
30#ifdef CONFIG_MMU
31
29#ifndef TASK_SIZE 32#ifndef TASK_SIZE
30/* 33/*
31 * TASK_SIZE - the maximum size of a user space task. 34 * TASK_SIZE - the maximum size of a user space task.
@@ -48,6 +51,60 @@
48#endif 51#endif
49 52
50/* 53/*
54 * The module space lives between the addresses given by TASK_SIZE
55 * and PAGE_OFFSET - it must be within 32MB of the kernel text.
56 */
57#define MODULE_END (PAGE_OFFSET)
58#define MODULE_START (MODULE_END - 16*1048576)
59
60#if TASK_SIZE > MODULE_START
61#error Top of user space clashes with start of module space
62#endif
63
64/*
65 * The XIP kernel gets mapped at the bottom of the module vm area.
66 * Since we use sections to map it, this macro replaces the physical address
67 * with its virtual address while keeping offset from the base section.
68 */
69#define XIP_VIRT_ADDR(physaddr) (MODULE_START + ((physaddr) & 0x000fffff))
70
71#else /* CONFIG_MMU */
72
73/*
74 * The limitation of user task size can grow up to the end of free ram region.
75 * It is difficult to define and perhaps will never meet the original meaning
76 * of this define that was meant to.
77 * Fortunately, there is no reference for this in noMMU mode, for now.
78 */
79#ifndef TASK_SIZE
80#define TASK_SIZE (CONFIG_DRAM_SIZE)
81#endif
82
83#ifndef TASK_UNMAPPED_BASE
84#define TASK_UNMAPPED_BASE UL(0x00000000)
85#endif
86
87#ifndef PHYS_OFFSET
88#define PHYS_OFFSET (CONFIG_DRAM_BASE)
89#endif
90
91#ifndef END_MEM
92#define END_MEM (CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE)
93#endif
94
95#ifndef PAGE_OFFSET
96#define PAGE_OFFSET (PHYS_OFFSET)
97#endif
98
99/*
100 * The module can be at any place in ram in nommu mode.
101 */
102#define MODULE_END (END_MEM)
103#define MODULE_START (PHYS_OFFSET)
104
105#endif /* !CONFIG_MMU */
106
107/*
51 * Size of DMA-consistent memory region. Must be multiple of 2M, 108 * Size of DMA-consistent memory region. Must be multiple of 2M,
52 * between 2MB and 14MB inclusive. 109 * between 2MB and 14MB inclusive.
53 */ 110 */
@@ -71,24 +128,6 @@
71#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) 128#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT)
72#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) 129#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
73 130
74/*
75 * The module space lives between the addresses given by TASK_SIZE
76 * and PAGE_OFFSET - it must be within 32MB of the kernel text.
77 */
78#define MODULE_END (PAGE_OFFSET)
79#define MODULE_START (MODULE_END - 16*1048576)
80
81#if TASK_SIZE > MODULE_START
82#error Top of user space clashes with start of module space
83#endif
84
85/*
86 * The XIP kernel gets mapped at the bottom of the module vm area.
87 * Since we use sections to map it, this macro replaces the physical address
88 * with its virtual address while keeping offset from the base section.
89 */
90#define XIP_VIRT_ADDR(physaddr) (MODULE_START + ((physaddr) & 0x000fffff))
91
92#ifndef __ASSEMBLY__ 131#ifndef __ASSEMBLY__
93 132
94/* 133/*
diff --git a/include/asm-arm/mmu.h b/include/asm-arm/mmu.h
index a457cb71984f..23dde52e0945 100644
--- a/include/asm-arm/mmu.h
+++ b/include/asm-arm/mmu.h
@@ -1,6 +1,8 @@
1#ifndef __ARM_MMU_H 1#ifndef __ARM_MMU_H
2#define __ARM_MMU_H 2#define __ARM_MMU_H
3 3
4#ifdef CONFIG_MMU
5
4typedef struct { 6typedef struct {
5#if __LINUX_ARM_ARCH__ >= 6 7#if __LINUX_ARM_ARCH__ >= 6
6 unsigned int id; 8 unsigned int id;
@@ -13,4 +15,18 @@ typedef struct {
13#define ASID(mm) (0) 15#define ASID(mm) (0)
14#endif 16#endif
15 17
18#else
19
20/*
21 * From nommu.h:
22 * Copyright (C) 2002, David McCullough <davidm@snapgear.com>
23 * modified for 2.6 by Hyok S. Choi <hyok.choi@samsung.com>
24 */
25typedef struct {
26 struct vm_list_struct *vmlist;
27 unsigned long end_brk;
28} mm_context_t;
29
30#endif
31
16#endif 32#endif
diff --git a/include/asm-arm/mmu_context.h b/include/asm-arm/mmu_context.h
index 81c59facea3b..9fadb01e030d 100644
--- a/include/asm-arm/mmu_context.h
+++ b/include/asm-arm/mmu_context.h
@@ -82,6 +82,7 @@ static inline void
82switch_mm(struct mm_struct *prev, struct mm_struct *next, 82switch_mm(struct mm_struct *prev, struct mm_struct *next,
83 struct task_struct *tsk) 83 struct task_struct *tsk)
84{ 84{
85#ifdef CONFIG_MMU
85 unsigned int cpu = smp_processor_id(); 86 unsigned int cpu = smp_processor_id();
86 87
87 if (prev != next) { 88 if (prev != next) {
@@ -91,6 +92,7 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
91 if (cache_is_vivt()) 92 if (cache_is_vivt())
92 cpu_clear(cpu, prev->cpu_vm_mask); 93 cpu_clear(cpu, prev->cpu_vm_mask);
93 } 94 }
95#endif
94} 96}
95 97
96#define deactivate_mm(tsk,mm) do { } while (0) 98#define deactivate_mm(tsk,mm) do { } while (0)
diff --git a/include/asm-arm/page-nommu.h b/include/asm-arm/page-nommu.h
new file mode 100644
index 000000000000..a1bcad060480
--- /dev/null
+++ b/include/asm-arm/page-nommu.h
@@ -0,0 +1,51 @@
1/*
2 * linux/include/asm-arm/page-nommu.h
3 *
4 * Copyright (C) 2004 Hyok S. Choi
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#ifndef _ASMARM_PAGE_NOMMU_H
11#define _ASMARM_PAGE_NOMMU_H
12
13#if !defined(CONFIG_SMALL_TASKS) && PAGE_SHIFT < 13
14#define KTHREAD_SIZE (8192)
15#else
16#define KTHREAD_SIZE PAGE_SIZE
17#endif
18
19#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
20#define free_user_page(page, addr) free_page(addr)
21
22#define clear_page(page) memset((page), 0, PAGE_SIZE)
23#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
24
25#define clear_user_page(page, vaddr, pg) clear_page(page)
26#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
27
28/*
29 * These are used to make use of C type-checking..
30 */
31typedef unsigned long pte_t;
32typedef unsigned long pmd_t;
33typedef unsigned long pgd_t[2];
34typedef unsigned long pgprot_t;
35
36#define pte_val(x) (x)
37#define pmd_val(x) (x)
38#define pgd_val(x) ((x)[0])
39#define pgprot_val(x) (x)
40
41#define __pte(x) (x)
42#define __pmd(x) (x)
43#define __pgprot(x) (x)
44
45/* to align the pointer to the (next) page boundary */
46#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
47
48extern unsigned long memory_start;
49extern unsigned long memory_end;
50
51#endif
diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h
index 66cfeb5290ea..63d12f0244c5 100644
--- a/include/asm-arm/page.h
+++ b/include/asm-arm/page.h
@@ -23,6 +23,12 @@
23 23
24#ifndef __ASSEMBLY__ 24#ifndef __ASSEMBLY__
25 25
26#ifndef CONFIG_MMU
27
28#include "page-nommu.h"
29
30#else
31
26#include <asm/glue.h> 32#include <asm/glue.h>
27 33
28/* 34/*
@@ -171,6 +177,8 @@ typedef unsigned long pgprot_t;
171/* the upper-most page table pointer */ 177/* the upper-most page table pointer */
172extern pmd_t *top_pmd; 178extern pmd_t *top_pmd;
173 179
180#endif /* CONFIG_MMU */
181
174#include <asm/memory.h> 182#include <asm/memory.h>
175 183
176#endif /* !__ASSEMBLY__ */ 184#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-arm/pgalloc.h b/include/asm-arm/pgalloc.h
index c4ac2e67768d..4d4394552911 100644
--- a/include/asm-arm/pgalloc.h
+++ b/include/asm-arm/pgalloc.h
@@ -16,6 +16,10 @@
16#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
17#include <asm/tlbflush.h> 17#include <asm/tlbflush.h>
18 18
19#define check_pgt_cache() do { } while (0)
20
21#ifdef CONFIG_MMU
22
19#define _PAGE_USER_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_USER)) 23#define _PAGE_USER_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_USER))
20#define _PAGE_KERNEL_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_KERNEL)) 24#define _PAGE_KERNEL_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_KERNEL))
21 25
@@ -32,8 +36,6 @@ extern void free_pgd_slow(pgd_t *pgd);
32#define pgd_alloc(mm) get_pgd_slow(mm) 36#define pgd_alloc(mm) get_pgd_slow(mm)
33#define pgd_free(pgd) free_pgd_slow(pgd) 37#define pgd_free(pgd) free_pgd_slow(pgd)
34 38
35#define check_pgt_cache() do { } while (0)
36
37/* 39/*
38 * Allocate one PTE table. 40 * Allocate one PTE table.
39 * 41 *
@@ -126,4 +128,6 @@ pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep)
126 __pmd_populate(pmdp, page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE); 128 __pmd_populate(pmdp, page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE);
127} 129}
128 130
131#endif /* CONFIG_MMU */
132
129#endif 133#endif
diff --git a/include/asm-arm/pgtable-nommu.h b/include/asm-arm/pgtable-nommu.h
new file mode 100644
index 000000000000..b13322dccf41
--- /dev/null
+++ b/include/asm-arm/pgtable-nommu.h
@@ -0,0 +1,123 @@
1/*
2 * linux/include/asm-arm/pgtable-nommu.h
3 *
4 * Copyright (C) 1995-2002 Russell King
5 * Copyright (C) 2004 Hyok S. Choi
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#ifndef _ASMARM_PGTABLE_NOMMU_H
12#define _ASMARM_PGTABLE_NOMMU_H
13
14#ifndef __ASSEMBLY__
15
16#include <linux/config.h>
17#include <linux/slab.h>
18#include <asm/processor.h>
19#include <asm/page.h>
20#include <asm/io.h>
21
22/*
23 * Trivial page table functions.
24 */
25#define pgd_present(pgd) (1)
26#define pgd_none(pgd) (0)
27#define pgd_bad(pgd) (0)
28#define pgd_clear(pgdp)
29#define kern_addr_valid(addr) (1)
30#define pmd_offset(a, b) ((void *)0)
31/* FIXME */
32/*
33 * PMD_SHIFT determines the size of the area a second-level page table can map
34 * PGDIR_SHIFT determines what a third-level page table entry can map
35 */
36#define PGDIR_SHIFT 21
37
38#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
39#define PGDIR_MASK (~(PGDIR_SIZE-1))
40/* FIXME */
41
42#define PAGE_NONE __pgprot(0)
43#define PAGE_SHARED __pgprot(0)
44#define PAGE_COPY __pgprot(0)
45#define PAGE_READONLY __pgprot(0)
46#define PAGE_KERNEL __pgprot(0)
47
48//extern void paging_init(struct meminfo *, struct machine_desc *);
49#define swapper_pg_dir ((pgd_t *) 0)
50
51#define __swp_type(x) (0)
52#define __swp_offset(x) (0)
53#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
54#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
55#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
56
57
58typedef pte_t *pte_addr_t;
59
60static inline int pte_file(pte_t pte) { return 0; }
61
62/*
63 * ZERO_PAGE is a global shared page that is always zero: used
64 * for zero-mapped memory areas etc..
65 */
66#define ZERO_PAGE(vaddr) (virt_to_page(0))
67
68/*
69 * Mark the prot value as uncacheable and unbufferable.
70 */
71#define pgprot_noncached(prot) __pgprot(0)
72#define pgprot_writecombine(prot) __pgprot(0)
73
74
75/*
76 * These would be in other places but having them here reduces the diffs.
77 */
78extern unsigned int kobjsize(const void *objp);
79extern int is_in_rom(unsigned long);
80
81/*
82 * No page table caches to initialise.
83 */
84#define pgtable_cache_init() do { } while (0)
85#define io_remap_page_range remap_page_range
86#define io_remap_pfn_range remap_pfn_range
87
88#define MK_IOSPACE_PFN(space, pfn) (pfn)
89#define GET_IOSPACE(pfn) 0
90#define GET_PFN(pfn) (pfn)
91
92
93/*
94 * All 32bit addresses are effectively valid for vmalloc...
95 * Sort of meaningless for non-VM targets.
96 */
97#define VMALLOC_START 0
98#define VMALLOC_END 0xffffffff
99
100#define FIRST_USER_ADDRESS (0)
101
102#else
103
104/*
105 * dummy tlb and user structures.
106 */
107#define v3_tlb_fns (0)
108#define v4_tlb_fns (0)
109#define v4wb_tlb_fns (0)
110#define v4wbi_tlb_fns (0)
111#define v6_tlb_fns (0)
112
113#define v3_user_fns (0)
114#define v4_user_fns (0)
115#define v4_mc_user_fns (0)
116#define v4wb_user_fns (0)
117#define v4wt_user_fns (0)
118#define v6_user_fns (0)
119#define xscale_mc_user_fns (0)
120
121#endif /*__ASSEMBLY__*/
122
123#endif /* _ASMARM_PGTABLE_H */
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index e85c08d78dda..8d3919c6458c 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -11,9 +11,15 @@
11#define _ASMARM_PGTABLE_H 11#define _ASMARM_PGTABLE_H
12 12
13#include <asm-generic/4level-fixup.h> 13#include <asm-generic/4level-fixup.h>
14#include <asm/proc-fns.h>
15
16#ifndef CONFIG_MMU
17
18#include "pgtable-nommu.h"
19
20#else
14 21
15#include <asm/memory.h> 22#include <asm/memory.h>
16#include <asm/proc-fns.h>
17#include <asm/arch/vmalloc.h> 23#include <asm/arch/vmalloc.h>
18 24
19/* 25/*
@@ -378,4 +384,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
378 384
379#endif /* !__ASSEMBLY__ */ 385#endif /* !__ASSEMBLY__ */
380 386
387#endif /* CONFIG_MMU */
388
381#endif /* _ASMARM_PGTABLE_H */ 389#endif /* _ASMARM_PGTABLE_H */
diff --git a/include/asm-arm/proc-fns.h b/include/asm-arm/proc-fns.h
index e9310895e79d..1bde92cdaebd 100644
--- a/include/asm-arm/proc-fns.h
+++ b/include/asm-arm/proc-fns.h
@@ -165,6 +165,8 @@
165 165
166#include <asm/memory.h> 166#include <asm/memory.h>
167 167
168#ifdef CONFIG_MMU
169
168#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm) 170#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm)
169 171
170#define cpu_get_pgd() \ 172#define cpu_get_pgd() \
@@ -176,6 +178,8 @@
176 (pgd_t *)phys_to_virt(pg); \ 178 (pgd_t *)phys_to_virt(pg); \
177 }) 179 })
178 180
181#endif
182
179#endif /* __ASSEMBLY__ */ 183#endif /* __ASSEMBLY__ */
180#endif /* __KERNEL__ */ 184#endif /* __KERNEL__ */
181#endif /* __ASM_PROCFNS_H */ 185#endif /* __ASM_PROCFNS_H */
diff --git a/include/asm-arm/ptrace.h b/include/asm-arm/ptrace.h
index 2bebe3dc0a30..5a8ef787dbf8 100644
--- a/include/asm-arm/ptrace.h
+++ b/include/asm-arm/ptrace.h
@@ -25,6 +25,11 @@
25 25
26#define PTRACE_SET_SYSCALL 23 26#define PTRACE_SET_SYSCALL 23
27 27
28/* PTRACE_SYSCALL is 24 */
29
30#define PTRACE_GETCRUNCHREGS 25
31#define PTRACE_SETCRUNCHREGS 26
32
28/* 33/*
29 * PSR bits 34 * PSR bits
30 */ 35 */
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index cfbccb63c67b..c46b5c84275f 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -59,6 +59,7 @@ struct thread_info {
59 struct cpu_context_save cpu_context; /* cpu context */ 59 struct cpu_context_save cpu_context; /* cpu context */
60 __u8 used_cp[16]; /* thread used copro */ 60 __u8 used_cp[16]; /* thread used copro */
61 unsigned long tp_value; 61 unsigned long tp_value;
62 struct crunch_state crunchstate;
62 union fp_state fpstate __attribute__((aligned(8))); 63 union fp_state fpstate __attribute__((aligned(8)));
63 union vfp_state vfpstate; 64 union vfp_state vfpstate;
64 struct restart_block restart_block; 65 struct restart_block restart_block;
@@ -101,6 +102,11 @@ extern void free_thread_info(struct thread_info *);
101#define thread_saved_fp(tsk) \ 102#define thread_saved_fp(tsk) \
102 ((unsigned long)(task_thread_info(tsk)->cpu_context.fp)) 103 ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
103 104
105extern void crunch_task_disable(struct thread_info *);
106extern void crunch_task_copy(struct thread_info *, void *);
107extern void crunch_task_restore(struct thread_info *, void *);
108extern void crunch_task_release(struct thread_info *);
109
104extern void iwmmxt_task_disable(struct thread_info *); 110extern void iwmmxt_task_disable(struct thread_info *);
105extern void iwmmxt_task_copy(struct thread_info *, void *); 111extern void iwmmxt_task_copy(struct thread_info *, void *);
106extern void iwmmxt_task_restore(struct thread_info *, void *); 112extern void iwmmxt_task_restore(struct thread_info *, void *);
diff --git a/include/asm-arm/uaccess.h b/include/asm-arm/uaccess.h
index 064f0f5e8e2b..87aba57a66c4 100644
--- a/include/asm-arm/uaccess.h
+++ b/include/asm-arm/uaccess.h
@@ -41,15 +41,24 @@ struct exception_table_entry
41extern int fixup_exception(struct pt_regs *regs); 41extern int fixup_exception(struct pt_regs *regs);
42 42
43/* 43/*
44 * These two are intentionally not defined anywhere - if the kernel
45 * code generates any references to them, that's a bug.
46 */
47extern int __get_user_bad(void);
48extern int __put_user_bad(void);
49
50/*
44 * Note that this is actually 0x1,0000,0000 51 * Note that this is actually 0x1,0000,0000
45 */ 52 */
46#define KERNEL_DS 0x00000000 53#define KERNEL_DS 0x00000000
47#define USER_DS TASK_SIZE
48
49#define get_ds() (KERNEL_DS) 54#define get_ds() (KERNEL_DS)
55
56#ifdef CONFIG_MMU
57
58#define USER_DS TASK_SIZE
50#define get_fs() (current_thread_info()->addr_limit) 59#define get_fs() (current_thread_info()->addr_limit)
51 60
52static inline void set_fs (mm_segment_t fs) 61static inline void set_fs(mm_segment_t fs)
53{ 62{
54 current_thread_info()->addr_limit = fs; 63 current_thread_info()->addr_limit = fs;
55 modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER); 64 modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
@@ -75,8 +84,6 @@ static inline void set_fs (mm_segment_t fs)
75 : "cc"); \ 84 : "cc"); \
76 flag; }) 85 flag; })
77 86
78#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
79
80/* 87/*
81 * Single-value transfer routines. They automatically use the right 88 * Single-value transfer routines. They automatically use the right
82 * size if we just have the right pointer type. Note that the functions 89 * size if we just have the right pointer type. Note that the functions
@@ -87,20 +94,10 @@ static inline void set_fs (mm_segment_t fs)
87 * fixup code, but there are a few places where it intrudes on the 94 * fixup code, but there are a few places where it intrudes on the
88 * main code path. When we only write to user space, there is no 95 * main code path. When we only write to user space, there is no
89 * problem. 96 * problem.
90 *
91 * The "__xxx" versions of the user access functions do not verify the
92 * address space - it must have been done previously with a separate
93 * "access_ok()" call.
94 *
95 * The "xxx_error" versions set the third argument to EFAULT if an
96 * error occurs, and leave it unchanged on success. Note that these
97 * versions are void (ie, don't return a value as such).
98 */ 97 */
99
100extern int __get_user_1(void *); 98extern int __get_user_1(void *);
101extern int __get_user_2(void *); 99extern int __get_user_2(void *);
102extern int __get_user_4(void *); 100extern int __get_user_4(void *);
103extern int __get_user_bad(void);
104 101
105#define __get_user_x(__r2,__p,__e,__s,__i...) \ 102#define __get_user_x(__r2,__p,__e,__s,__i...) \
106 __asm__ __volatile__ ( \ 103 __asm__ __volatile__ ( \
@@ -131,6 +128,74 @@ extern int __get_user_bad(void);
131 __e; \ 128 __e; \
132 }) 129 })
133 130
131extern int __put_user_1(void *, unsigned int);
132extern int __put_user_2(void *, unsigned int);
133extern int __put_user_4(void *, unsigned int);
134extern int __put_user_8(void *, unsigned long long);
135
136#define __put_user_x(__r2,__p,__e,__s) \
137 __asm__ __volatile__ ( \
138 __asmeq("%0", "r0") __asmeq("%2", "r2") \
139 "bl __put_user_" #__s \
140 : "=&r" (__e) \
141 : "0" (__p), "r" (__r2) \
142 : "ip", "lr", "cc")
143
144#define put_user(x,p) \
145 ({ \
146 const register typeof(*(p)) __r2 asm("r2") = (x); \
147 const register typeof(*(p)) __user *__p asm("r0") = (p);\
148 register int __e asm("r0"); \
149 switch (sizeof(*(__p))) { \
150 case 1: \
151 __put_user_x(__r2, __p, __e, 1); \
152 break; \
153 case 2: \
154 __put_user_x(__r2, __p, __e, 2); \
155 break; \
156 case 4: \
157 __put_user_x(__r2, __p, __e, 4); \
158 break; \
159 case 8: \
160 __put_user_x(__r2, __p, __e, 8); \
161 break; \
162 default: __e = __put_user_bad(); break; \
163 } \
164 __e; \
165 })
166
167#else /* CONFIG_MMU */
168
169/*
170 * uClinux has only one addr space, so has simplified address limits.
171 */
172#define USER_DS KERNEL_DS
173
174#define segment_eq(a,b) (1)
175#define __addr_ok(addr) (1)
176#define __range_ok(addr,size) (0)
177#define get_fs() (KERNEL_DS)
178
179static inline void set_fs(mm_segment_t fs)
180{
181}
182
183#define get_user(x,p) __get_user(x,p)
184#define put_user(x,p) __put_user(x,p)
185
186#endif /* CONFIG_MMU */
187
188#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
189
190/*
191 * The "__xxx" versions of the user access functions do not verify the
192 * address space - it must have been done previously with a separate
193 * "access_ok()" call.
194 *
195 * The "xxx_error" versions set the third argument to EFAULT if an
196 * error occurs, and leave it unchanged on success. Note that these
197 * versions are void (ie, don't return a value as such).
198 */
134#define __get_user(x,ptr) \ 199#define __get_user(x,ptr) \
135({ \ 200({ \
136 long __gu_err = 0; \ 201 long __gu_err = 0; \
@@ -212,43 +277,6 @@ do { \
212 : "r" (addr), "i" (-EFAULT) \ 277 : "r" (addr), "i" (-EFAULT) \
213 : "cc") 278 : "cc")
214 279
215extern int __put_user_1(void *, unsigned int);
216extern int __put_user_2(void *, unsigned int);
217extern int __put_user_4(void *, unsigned int);
218extern int __put_user_8(void *, unsigned long long);
219extern int __put_user_bad(void);
220
221#define __put_user_x(__r2,__p,__e,__s) \
222 __asm__ __volatile__ ( \
223 __asmeq("%0", "r0") __asmeq("%2", "r2") \
224 "bl __put_user_" #__s \
225 : "=&r" (__e) \
226 : "0" (__p), "r" (__r2) \
227 : "ip", "lr", "cc")
228
229#define put_user(x,p) \
230 ({ \
231 const register typeof(*(p)) __r2 asm("r2") = (x); \
232 const register typeof(*(p)) __user *__p asm("r0") = (p);\
233 register int __e asm("r0"); \
234 switch (sizeof(*(__p))) { \
235 case 1: \
236 __put_user_x(__r2, __p, __e, 1); \
237 break; \
238 case 2: \
239 __put_user_x(__r2, __p, __e, 2); \
240 break; \
241 case 4: \
242 __put_user_x(__r2, __p, __e, 4); \
243 break; \
244 case 8: \
245 __put_user_x(__r2, __p, __e, 8); \
246 break; \
247 default: __e = __put_user_bad(); break; \
248 } \
249 __e; \
250 })
251
252#define __put_user(x,ptr) \ 280#define __put_user(x,ptr) \
253({ \ 281({ \
254 long __pu_err = 0; \ 282 long __pu_err = 0; \
@@ -353,66 +381,54 @@ do { \
353 : "r" (x), "i" (-EFAULT) \ 381 : "r" (x), "i" (-EFAULT) \
354 : "cc") 382 : "cc")
355 383
356extern unsigned long __arch_copy_from_user(void *to, const void __user *from, unsigned long n); 384
357extern unsigned long __arch_copy_to_user(void __user *to, const void *from, unsigned long n); 385#ifdef CONFIG_MMU
358extern unsigned long __arch_clear_user(void __user *addr, unsigned long n); 386extern unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n);
359extern unsigned long __arch_strncpy_from_user(char *to, const char __user *from, unsigned long count); 387extern unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n);
360extern unsigned long __arch_strnlen_user(const char __user *s, long n); 388extern unsigned long __clear_user(void __user *addr, unsigned long n);
389#else
390#define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
391#define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
392#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0)
393#endif
394
395extern unsigned long __strncpy_from_user(char *to, const char __user *from, unsigned long count);
396extern unsigned long __strnlen_user(const char __user *s, long n);
361 397
362static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) 398static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
363{ 399{
364 if (access_ok(VERIFY_READ, from, n)) 400 if (access_ok(VERIFY_READ, from, n))
365 n = __arch_copy_from_user(to, from, n); 401 n = __copy_from_user(to, from, n);
366 else /* security hole - plug it */ 402 else /* security hole - plug it */
367 memzero(to, n); 403 memzero(to, n);
368 return n; 404 return n;
369} 405}
370 406
371static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
372{
373 return __arch_copy_from_user(to, from, n);
374}
375
376static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) 407static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
377{ 408{
378 if (access_ok(VERIFY_WRITE, to, n)) 409 if (access_ok(VERIFY_WRITE, to, n))
379 n = __arch_copy_to_user(to, from, n); 410 n = __copy_to_user(to, from, n);
380 return n; 411 return n;
381} 412}
382 413
383static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
384{
385 return __arch_copy_to_user(to, from, n);
386}
387
388#define __copy_to_user_inatomic __copy_to_user 414#define __copy_to_user_inatomic __copy_to_user
389#define __copy_from_user_inatomic __copy_from_user 415#define __copy_from_user_inatomic __copy_from_user
390 416
391static inline unsigned long clear_user (void __user *to, unsigned long n) 417static inline unsigned long clear_user(void __user *to, unsigned long n)
392{ 418{
393 if (access_ok(VERIFY_WRITE, to, n)) 419 if (access_ok(VERIFY_WRITE, to, n))
394 n = __arch_clear_user(to, n); 420 n = __clear_user(to, n);
395 return n; 421 return n;
396} 422}
397 423
398static inline unsigned long __clear_user (void __user *to, unsigned long n) 424static inline long strncpy_from_user(char *dst, const char __user *src, long count)
399{
400 return __arch_clear_user(to, n);
401}
402
403static inline long strncpy_from_user (char *dst, const char __user *src, long count)
404{ 425{
405 long res = -EFAULT; 426 long res = -EFAULT;
406 if (access_ok(VERIFY_READ, src, 1)) 427 if (access_ok(VERIFY_READ, src, 1))
407 res = __arch_strncpy_from_user(dst, src, count); 428 res = __strncpy_from_user(dst, src, count);
408 return res; 429 return res;
409} 430}
410 431
411static inline long __strncpy_from_user (char *dst, const char __user *src, long count)
412{
413 return __arch_strncpy_from_user(dst, src, count);
414}
415
416#define strlen_user(s) strnlen_user(s, ~0UL >> 1) 432#define strlen_user(s) strnlen_user(s, ~0UL >> 1)
417 433
418static inline long strnlen_user(const char __user *s, long n) 434static inline long strnlen_user(const char __user *s, long n)
@@ -420,7 +436,7 @@ static inline long strnlen_user(const char __user *s, long n)
420 unsigned long res = 0; 436 unsigned long res = 0;
421 437
422 if (__addr_ok(s)) 438 if (__addr_ok(s))
423 res = __arch_strnlen_user(s, n); 439 res = __strnlen_user(s, n);
424 440
425 return res; 441 return res;
426} 442}
diff --git a/include/asm-arm/ucontext.h b/include/asm-arm/ucontext.h
index 9e6f7ca9f5ae..bf65e9f4525d 100644
--- a/include/asm-arm/ucontext.h
+++ b/include/asm-arm/ucontext.h
@@ -35,6 +35,17 @@ struct ucontext {
35 * bytes, to prevent unpredictable padding in the signal frame. 35 * bytes, to prevent unpredictable padding in the signal frame.
36 */ 36 */
37 37
38#ifdef CONFIG_CRUNCH
39#define CRUNCH_MAGIC 0x5065cf03
40#define CRUNCH_STORAGE_SIZE (CRUNCH_SIZE + 8)
41
42struct crunch_sigframe {
43 unsigned long magic;
44 unsigned long size;
45 struct crunch_state storage;
46} __attribute__((__aligned__(8)));
47#endif
48
38#ifdef CONFIG_IWMMXT 49#ifdef CONFIG_IWMMXT
39/* iwmmxt_area is 0x98 bytes long, preceeded by 8 bytes of signature */ 50/* iwmmxt_area is 0x98 bytes long, preceeded by 8 bytes of signature */
40#define IWMMXT_MAGIC 0x12ef842a 51#define IWMMXT_MAGIC 0x12ef842a
@@ -74,6 +85,9 @@ struct vfp_sigframe
74 * one of these. 85 * one of these.
75 */ 86 */
76struct aux_sigframe { 87struct aux_sigframe {
88#ifdef CONFIG_CRUNCH
89 struct crunch_sigframe crunch;
90#endif
77#ifdef CONFIG_IWMMXT 91#ifdef CONFIG_IWMMXT
78 struct iwmmxt_sigframe iwmmxt; 92 struct iwmmxt_sigframe iwmmxt;
79#endif 93#endif
diff --git a/include/asm-cris/hw_irq.h b/include/asm-cris/hw_irq.h
index 341536a234e9..298066020af2 100644
--- a/include/asm-cris/hw_irq.h
+++ b/include/asm-cris/hw_irq.h
@@ -1,7 +1,5 @@
1#ifndef _ASM_HW_IRQ_H 1#ifndef _ASM_HW_IRQ_H
2#define _ASM_HW_IRQ_H 2#define _ASM_HW_IRQ_H
3 3
4static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
5
6#endif 4#endif
7 5
diff --git a/include/asm-cris/irq.h b/include/asm-cris/irq.h
index 4b338792218b..998cce9f3200 100644
--- a/include/asm-cris/irq.h
+++ b/include/asm-cris/irq.h
@@ -1,11 +1,6 @@
1#ifndef _ASM_IRQ_H 1#ifndef _ASM_IRQ_H
2#define _ASM_IRQ_H 2#define _ASM_IRQ_H
3 3
4/*
5 * IRQ line status macro IRQ_PER_CPU is used
6 */
7#define ARCH_HAS_IRQ_PER_CPU
8
9#include <asm/arch/irq.h> 4#include <asm/arch/irq.h>
10 5
11static inline int irq_canonicalize(int irq) 6static inline int irq_canonicalize(int irq)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 845cb67ad8ea..8ceab7bcd8b4 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -51,4 +51,10 @@
51 __ret; \ 51 __ret; \
52}) 52})
53 53
54#ifdef CONFIG_SMP
55# define WARN_ON_SMP(x) WARN_ON(x)
56#else
57# define WARN_ON_SMP(x) do { } while (0)
58#endif
59
54#endif 60#endif
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 9d11550b4818..db5a3732f106 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -58,6 +58,20 @@
58 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \ 58 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
59 } \ 59 } \
60 \ 60 \
61 /* Kernel symbol table: Normal unused symbols */ \
62 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
63 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
64 *(__ksymtab_unused) \
65 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
66 } \
67 \
68 /* Kernel symbol table: GPL-only unused symbols */ \
69 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
70 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
71 *(__ksymtab_unused_gpl) \
72 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
73 } \
74 \
61 /* Kernel symbol table: GPL-future-only symbols */ \ 75 /* Kernel symbol table: GPL-future-only symbols */ \
62 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \ 76 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
63 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \ 77 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
@@ -79,6 +93,20 @@
79 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \ 93 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
80 } \ 94 } \
81 \ 95 \
96 /* Kernel symbol table: Normal unused symbols */ \
97 __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \
98 VMLINUX_SYMBOL(__start___kcrctab_unused) = .; \
99 *(__kcrctab_unused) \
100 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .; \
101 } \
102 \
103 /* Kernel symbol table: GPL-only unused symbols */ \
104 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
105 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
106 *(__kcrctab_unused_gpl) \
107 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
108 } \
109 \
82 /* Kernel symbol table: GPL-future-only symbols */ \ 110 /* Kernel symbol table: GPL-future-only symbols */ \
83 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \ 111 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
84 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \ 112 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
diff --git a/include/asm-i386/cpu.h b/include/asm-i386/cpu.h
index e7252c216ca8..b1bc7b1b64b0 100644
--- a/include/asm-i386/cpu.h
+++ b/include/asm-i386/cpu.h
@@ -7,8 +7,6 @@
7#include <linux/nodemask.h> 7#include <linux/nodemask.h>
8#include <linux/percpu.h> 8#include <linux/percpu.h>
9 9
10#include <asm/node.h>
11
12struct i386_cpu { 10struct i386_cpu {
13 struct cpu cpu; 11 struct cpu cpu;
14}; 12};
diff --git a/include/asm-i386/elf.h b/include/asm-i386/elf.h
index 4153d80e4d2b..1eac92cb5b16 100644
--- a/include/asm-i386/elf.h
+++ b/include/asm-i386/elf.h
@@ -10,6 +10,7 @@
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/system.h> /* for savesegment */ 11#include <asm/system.h> /* for savesegment */
12#include <asm/auxvec.h> 12#include <asm/auxvec.h>
13#include <asm/desc.h>
13 14
14#include <linux/utsname.h> 15#include <linux/utsname.h>
15 16
@@ -129,15 +130,41 @@ extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct
129#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) 130#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
130#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs) 131#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
131 132
132#define VSYSCALL_BASE (__fix_to_virt(FIX_VSYSCALL)) 133#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
133#define VSYSCALL_EHDR ((const struct elfhdr *) VSYSCALL_BASE) 134#define VDSO_BASE ((unsigned long)current->mm->context.vdso)
134#define VSYSCALL_ENTRY ((unsigned long) &__kernel_vsyscall) 135
136#ifdef CONFIG_COMPAT_VDSO
137# define VDSO_COMPAT_BASE VDSO_HIGH_BASE
138# define VDSO_PRELINK VDSO_HIGH_BASE
139#else
140# define VDSO_COMPAT_BASE VDSO_BASE
141# define VDSO_PRELINK 0
142#endif
143
144#define VDSO_COMPAT_SYM(x) \
145 (VDSO_COMPAT_BASE + (unsigned long)(x) - VDSO_PRELINK)
146
147#define VDSO_SYM(x) \
148 (VDSO_BASE + (unsigned long)(x) - VDSO_PRELINK)
149
150#define VDSO_HIGH_EHDR ((const struct elfhdr *) VDSO_HIGH_BASE)
151#define VDSO_EHDR ((const struct elfhdr *) VDSO_COMPAT_BASE)
152
135extern void __kernel_vsyscall; 153extern void __kernel_vsyscall;
136 154
155#define VDSO_ENTRY VDSO_SYM(&__kernel_vsyscall)
156
157#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
158struct linux_binprm;
159extern int arch_setup_additional_pages(struct linux_binprm *bprm,
160 int executable_stack);
161
162extern unsigned int vdso_enabled;
163
137#define ARCH_DLINFO \ 164#define ARCH_DLINFO \
138do { \ 165do if (vdso_enabled) { \
139 NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY); \ 166 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
140 NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL_BASE); \ 167 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_COMPAT_BASE); \
141} while (0) 168} while (0)
142 169
143/* 170/*
@@ -148,15 +175,15 @@ do { \
148 * Dumping its extra ELF program headers includes all the other information 175 * Dumping its extra ELF program headers includes all the other information
149 * a debugger needs to easily find how the vsyscall DSO was being used. 176 * a debugger needs to easily find how the vsyscall DSO was being used.
150 */ 177 */
151#define ELF_CORE_EXTRA_PHDRS (VSYSCALL_EHDR->e_phnum) 178#define ELF_CORE_EXTRA_PHDRS (VDSO_HIGH_EHDR->e_phnum)
152#define ELF_CORE_WRITE_EXTRA_PHDRS \ 179#define ELF_CORE_WRITE_EXTRA_PHDRS \
153do { \ 180do { \
154 const struct elf_phdr *const vsyscall_phdrs = \ 181 const struct elf_phdr *const vsyscall_phdrs = \
155 (const struct elf_phdr *) (VSYSCALL_BASE \ 182 (const struct elf_phdr *) (VDSO_HIGH_BASE \
156 + VSYSCALL_EHDR->e_phoff); \ 183 + VDSO_HIGH_EHDR->e_phoff); \
157 int i; \ 184 int i; \
158 Elf32_Off ofs = 0; \ 185 Elf32_Off ofs = 0; \
159 for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) { \ 186 for (i = 0; i < VDSO_HIGH_EHDR->e_phnum; ++i) { \
160 struct elf_phdr phdr = vsyscall_phdrs[i]; \ 187 struct elf_phdr phdr = vsyscall_phdrs[i]; \
161 if (phdr.p_type == PT_LOAD) { \ 188 if (phdr.p_type == PT_LOAD) { \
162 BUG_ON(ofs != 0); \ 189 BUG_ON(ofs != 0); \
@@ -174,10 +201,10 @@ do { \
174#define ELF_CORE_WRITE_EXTRA_DATA \ 201#define ELF_CORE_WRITE_EXTRA_DATA \
175do { \ 202do { \
176 const struct elf_phdr *const vsyscall_phdrs = \ 203 const struct elf_phdr *const vsyscall_phdrs = \
177 (const struct elf_phdr *) (VSYSCALL_BASE \ 204 (const struct elf_phdr *) (VDSO_HIGH_BASE \
178 + VSYSCALL_EHDR->e_phoff); \ 205 + VDSO_HIGH_EHDR->e_phoff); \
179 int i; \ 206 int i; \
180 for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) { \ 207 for (i = 0; i < VDSO_HIGH_EHDR->e_phnum; ++i) { \
181 if (vsyscall_phdrs[i].p_type == PT_LOAD) \ 208 if (vsyscall_phdrs[i].p_type == PT_LOAD) \
182 DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr, \ 209 DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr, \
183 PAGE_ALIGN(vsyscall_phdrs[i].p_memsz)); \ 210 PAGE_ALIGN(vsyscall_phdrs[i].p_memsz)); \
diff --git a/include/asm-i386/fixmap.h b/include/asm-i386/fixmap.h
index f7e068f4d2f9..a48cc3f7ccc6 100644
--- a/include/asm-i386/fixmap.h
+++ b/include/asm-i386/fixmap.h
@@ -51,7 +51,7 @@
51 */ 51 */
52enum fixed_addresses { 52enum fixed_addresses {
53 FIX_HOLE, 53 FIX_HOLE,
54 FIX_VSYSCALL, 54 FIX_VDSO,
55#ifdef CONFIG_X86_LOCAL_APIC 55#ifdef CONFIG_X86_LOCAL_APIC
56 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 56 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
57#endif 57#endif
@@ -115,14 +115,6 @@ extern void __set_fixmap (enum fixed_addresses idx,
115#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) 115#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
116#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) 116#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
117 117
118/*
119 * This is the range that is readable by user mode, and things
120 * acting like user mode such as get_user_pages.
121 */
122#define FIXADDR_USER_START (__fix_to_virt(FIX_VSYSCALL))
123#define FIXADDR_USER_END (FIXADDR_USER_START + PAGE_SIZE)
124
125
126extern void __this_fixmap_does_not_exist(void); 118extern void __this_fixmap_does_not_exist(void);
127 119
128/* 120/*
diff --git a/include/asm-i386/hw_irq.h b/include/asm-i386/hw_irq.h
index a4c0a5a9ffd8..87e5a351d881 100644
--- a/include/asm-i386/hw_irq.h
+++ b/include/asm-i386/hw_irq.h
@@ -69,14 +69,4 @@ extern atomic_t irq_mis_count;
69 69
70#define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) 70#define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs))
71 71
72#if defined(CONFIG_X86_IO_APIC)
73static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
74{
75 if (IO_APIC_IRQ(i))
76 send_IPI_self(IO_APIC_VECTOR(i));
77}
78#else
79static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
80#endif
81
82#endif /* _ASM_HW_IRQ_H */ 72#endif /* _ASM_HW_IRQ_H */
diff --git a/include/asm-i386/mach-visws/setup_arch.h b/include/asm-i386/mach-visws/setup_arch.h
index b92d6d9a4d3c..33f700ef6831 100644
--- a/include/asm-i386/mach-visws/setup_arch.h
+++ b/include/asm-i386/mach-visws/setup_arch.h
@@ -1,5 +1,8 @@
1/* Hook to call BIOS initialisation function */ 1/* Hook to call BIOS initialisation function */
2 2
3extern unsigned long sgivwfb_mem_phys;
4extern unsigned long sgivwfb_mem_size;
5
3/* no action for visws */ 6/* no action for visws */
4 7
5#define ARCH_SETUP 8#define ARCH_SETUP
diff --git a/include/asm-i386/mmu.h b/include/asm-i386/mmu.h
index f431a0b86d4c..8358dd3df7aa 100644
--- a/include/asm-i386/mmu.h
+++ b/include/asm-i386/mmu.h
@@ -12,6 +12,7 @@ typedef struct {
12 int size; 12 int size;
13 struct semaphore sem; 13 struct semaphore sem;
14 void *ldt; 14 void *ldt;
15 void *vdso;
15} mm_context_t; 16} mm_context_t;
16 17
17#endif 18#endif
diff --git a/include/asm-i386/node.h b/include/asm-i386/node.h
deleted file mode 100644
index e13c6ffa72ae..000000000000
--- a/include/asm-i386/node.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef _ASM_I386_NODE_H_
2#define _ASM_I386_NODE_H_
3
4#include <linux/device.h>
5#include <linux/mmzone.h>
6#include <linux/node.h>
7#include <linux/topology.h>
8#include <linux/nodemask.h>
9
10struct i386_node {
11 struct node node;
12};
13extern struct i386_node node_devices[MAX_NUMNODES];
14
15static inline int arch_register_node(int num){
16 int p_node;
17 struct node *parent = NULL;
18
19 if (!node_online(num))
20 return 0;
21 p_node = parent_node(num);
22
23 if (p_node != num)
24 parent = &node_devices[p_node].node;
25
26 return register_node(&node_devices[num].node, num, parent);
27}
28
29#endif /* _ASM_I386_NODE_H_ */
diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
index e3a552fa5538..f5bf544c729a 100644
--- a/include/asm-i386/page.h
+++ b/include/asm-i386/page.h
@@ -96,6 +96,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
96 96
97#ifndef __ASSEMBLY__ 97#ifndef __ASSEMBLY__
98 98
99struct vm_area_struct;
100
99/* 101/*
100 * This much address space is reserved for vmalloc() and iomap() 102 * This much address space is reserved for vmalloc() and iomap()
101 * as well as fixmap mappings. 103 * as well as fixmap mappings.
@@ -139,6 +141,7 @@ extern int page_is_ram(unsigned long pagenr);
139#include <asm-generic/memory_model.h> 141#include <asm-generic/memory_model.h>
140#include <asm-generic/page.h> 142#include <asm-generic/page.h>
141 143
144#define __HAVE_ARCH_GATE_AREA 1
142#endif /* __KERNEL__ */ 145#endif /* __KERNEL__ */
143 146
144#endif /* _I386_PAGE_H */ 147#endif /* _I386_PAGE_H */
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index 55ea992da329..b32346d62e10 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -71,8 +71,12 @@ struct cpuinfo_x86 {
71 cpumask_t llc_shared_map; /* cpus sharing the last level cache */ 71 cpumask_t llc_shared_map; /* cpus sharing the last level cache */
72#endif 72#endif
73 unsigned char x86_max_cores; /* cpuid returned max cores value */ 73 unsigned char x86_max_cores; /* cpuid returned max cores value */
74 unsigned char booted_cores; /* number of cores as seen by OS */
75 unsigned char apicid; 74 unsigned char apicid;
75#ifdef CONFIG_SMP
76 unsigned char booted_cores; /* number of cores as seen by OS */
77 __u8 phys_proc_id; /* Physical processor id. */
78 __u8 cpu_core_id; /* Core id */
79#endif
76} __attribute__((__aligned__(SMP_CACHE_BYTES))); 80} __attribute__((__aligned__(SMP_CACHE_BYTES)));
77 81
78#define X86_VENDOR_INTEL 0 82#define X86_VENDOR_INTEL 0
@@ -104,8 +108,6 @@ extern struct cpuinfo_x86 cpu_data[];
104#define current_cpu_data boot_cpu_data 108#define current_cpu_data boot_cpu_data
105#endif 109#endif
106 110
107extern int phys_proc_id[NR_CPUS];
108extern int cpu_core_id[NR_CPUS];
109extern int cpu_llc_id[NR_CPUS]; 111extern int cpu_llc_id[NR_CPUS];
110extern char ignore_fpu_irq; 112extern char ignore_fpu_irq;
111 113
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
index fdbc7f422ea5..2833fa2c0dd0 100644
--- a/include/asm-i386/thread_info.h
+++ b/include/asm-i386/thread_info.h
@@ -37,6 +37,7 @@ struct thread_info {
37 0-0xBFFFFFFF for user-thead 37 0-0xBFFFFFFF for user-thead
38 0-0xFFFFFFFF for kernel-thread 38 0-0xFFFFFFFF for kernel-thread
39 */ 39 */
40 void *sysenter_return;
40 struct restart_block restart_block; 41 struct restart_block restart_block;
41 42
42 unsigned long previous_esp; /* ESP of the previous stack in case 43 unsigned long previous_esp; /* ESP of the previous stack in case
@@ -83,17 +84,15 @@ struct thread_info {
83#define init_stack (init_thread_union.stack) 84#define init_stack (init_thread_union.stack)
84 85
85 86
87/* how to get the current stack pointer from C */
88register unsigned long current_stack_pointer asm("esp") __attribute_used__;
89
86/* how to get the thread information struct from C */ 90/* how to get the thread information struct from C */
87static inline struct thread_info *current_thread_info(void) 91static inline struct thread_info *current_thread_info(void)
88{ 92{
89 struct thread_info *ti; 93 return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1));
90 __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1)));
91 return ti;
92} 94}
93 95
94/* how to get the current stack pointer from C */
95register unsigned long current_stack_pointer asm("esp") __attribute_used__;
96
97/* thread information allocation */ 96/* thread information allocation */
98#ifdef CONFIG_DEBUG_STACK_USAGE 97#ifdef CONFIG_DEBUG_STACK_USAGE
99#define alloc_thread_info(tsk) \ 98#define alloc_thread_info(tsk) \
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h
index b94e5eeef917..6adbd9b1ae88 100644
--- a/include/asm-i386/topology.h
+++ b/include/asm-i386/topology.h
@@ -28,10 +28,8 @@
28#define _ASM_I386_TOPOLOGY_H 28#define _ASM_I386_TOPOLOGY_H
29 29
30#ifdef CONFIG_X86_HT 30#ifdef CONFIG_X86_HT
31#define topology_physical_package_id(cpu) \ 31#define topology_physical_package_id(cpu) (cpu_data[cpu].phys_proc_id)
32 (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu]) 32#define topology_core_id(cpu) (cpu_data[cpu].cpu_core_id)
33#define topology_core_id(cpu) \
34 (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu])
35#define topology_core_siblings(cpu) (cpu_core_map[cpu]) 33#define topology_core_siblings(cpu) (cpu_core_map[cpu])
36#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) 34#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
37#endif 35#endif
@@ -114,4 +112,9 @@ extern unsigned long node_remap_size[];
114 112
115extern cpumask_t cpu_coregroup_map(int cpu); 113extern cpumask_t cpu_coregroup_map(int cpu);
116 114
115#ifdef CONFIG_SMP
116#define mc_capable() (boot_cpu_data.x86_max_cores > 1)
117#define smt_capable() (smp_num_siblings > 1)
118#endif
119
117#endif /* _ASM_I386_TOPOLOGY_H */ 120#endif /* _ASM_I386_TOPOLOGY_H */
diff --git a/include/asm-i386/unwind.h b/include/asm-i386/unwind.h
index d480f2e38215..69f0f1df6722 100644
--- a/include/asm-i386/unwind.h
+++ b/include/asm-i386/unwind.h
@@ -78,8 +78,8 @@ static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
78 return user_mode_vm(&info->regs); 78 return user_mode_vm(&info->regs);
79#else 79#else
80 return info->regs.eip < PAGE_OFFSET 80 return info->regs.eip < PAGE_OFFSET
81 || (info->regs.eip >= __fix_to_virt(FIX_VSYSCALL) 81 || (info->regs.eip >= __fix_to_virt(FIX_VDSO)
82 && info->regs.eip < __fix_to_virt(FIX_VSYSCALL) + PAGE_SIZE) 82 && info->regs.eip < __fix_to_virt(FIX_VDSO) + PAGE_SIZE)
83 || info->regs.esp < PAGE_OFFSET; 83 || info->regs.esp < PAGE_OFFSET;
84#endif 84#endif
85} 85}
diff --git a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h
index ea8b8c407ab4..27f9df6b9145 100644
--- a/include/asm-ia64/hw_irq.h
+++ b/include/asm-ia64/hw_irq.h
@@ -97,8 +97,7 @@ extern int reserve_irq_vector (int vector);
97extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect); 97extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect);
98extern void register_percpu_irq (ia64_vector vec, struct irqaction *action); 98extern void register_percpu_irq (ia64_vector vec, struct irqaction *action);
99 99
100static inline void 100static inline void ia64_resend_irq(unsigned int vector)
101hw_resend_irq (struct hw_interrupt_type *h, unsigned int vector)
102{ 101{
103 platform_send_ipi(smp_processor_id(), vector, IA64_IPI_DM_INT, 0); 102 platform_send_ipi(smp_processor_id(), vector, IA64_IPI_DM_INT, 0);
104} 103}
diff --git a/include/asm-ia64/irq.h b/include/asm-ia64/irq.h
index dbe86c0bbce5..79479e2c6966 100644
--- a/include/asm-ia64/irq.h
+++ b/include/asm-ia64/irq.h
@@ -14,11 +14,6 @@
14#define NR_IRQS 256 14#define NR_IRQS 256
15#define NR_IRQ_VECTORS NR_IRQS 15#define NR_IRQ_VECTORS NR_IRQS
16 16
17/*
18 * IRQ line status macro IRQ_PER_CPU is used
19 */
20#define ARCH_HAS_IRQ_PER_CPU
21
22static __inline__ int 17static __inline__ int
23irq_canonicalize (int irq) 18irq_canonicalize (int irq)
24{ 19{
diff --git a/include/asm-ia64/nodedata.h b/include/asm-ia64/nodedata.h
index a140310bf84d..2fb337b0e9b7 100644
--- a/include/asm-ia64/nodedata.h
+++ b/include/asm-ia64/nodedata.h
@@ -46,6 +46,18 @@ struct ia64_node_data {
46 */ 46 */
47#define NODE_DATA(nid) (local_node_data->pg_data_ptrs[nid]) 47#define NODE_DATA(nid) (local_node_data->pg_data_ptrs[nid])
48 48
49/*
50 * LOCAL_DATA_ADDR - This is to calculate the address of other node's
51 * "local_node_data" at hot-plug phase. The local_node_data
52 * is pointed by per_cpu_page. Kernel usually use it for
53 * just executing cpu. However, when new node is hot-added,
54 * the addresses of local data for other nodes are necessary
55 * to update all of them.
56 */
57#define LOCAL_DATA_ADDR(pgdat) \
58 ((struct ia64_node_data *)((u64)(pgdat) + \
59 L1_CACHE_ALIGN(sizeof(struct pglist_data))))
60
49#endif /* CONFIG_NUMA */ 61#endif /* CONFIG_NUMA */
50 62
51#endif /* _ASM_IA64_NODEDATA_H */ 63#endif /* _ASM_IA64_NODEDATA_H */
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
index cd490b20d592..bd4452bda357 100644
--- a/include/asm-ia64/sn/sn_sal.h
+++ b/include/asm-ia64/sn/sn_sal.h
@@ -85,6 +85,7 @@
85#define SN_SAL_GET_PROM_FEATURE_SET 0x02000065 85#define SN_SAL_GET_PROM_FEATURE_SET 0x02000065
86#define SN_SAL_SET_OS_FEATURE_SET 0x02000066 86#define SN_SAL_SET_OS_FEATURE_SET 0x02000066
87#define SN_SAL_INJECT_ERROR 0x02000067 87#define SN_SAL_INJECT_ERROR 0x02000067
88#define SN_SAL_SET_CPU_NUMBER 0x02000068
88 89
89/* 90/*
90 * Service-specific constants 91 * Service-specific constants
@@ -1150,4 +1151,13 @@ sn_inject_error(u64 paddr, u64 *data, u64 *ecc)
1150 local_irq_restore(irq_flags); 1151 local_irq_restore(irq_flags);
1151 return ret_stuff.status; 1152 return ret_stuff.status;
1152} 1153}
1154
1155static inline int
1156ia64_sn_set_cpu_number(int cpu)
1157{
1158 struct ia64_sal_retval rv;
1159
1160 SAL_CALL_NOLOCK(rv, SN_SAL_SET_CPU_NUMBER, cpu, 0, 0, 0, 0, 0, 0);
1161 return rv.status;
1162}
1153#endif /* _ASM_IA64_SN_SN_SAL_H */ 1163#endif /* _ASM_IA64_SN_SN_SAL_H */
diff --git a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h
index 616b5ed2aa72..937c21257523 100644
--- a/include/asm-ia64/topology.h
+++ b/include/asm-ia64/topology.h
@@ -112,6 +112,7 @@ void build_cpu_to_node_map(void);
112#define topology_core_id(cpu) (cpu_data(cpu)->core_id) 112#define topology_core_id(cpu) (cpu_data(cpu)->core_id)
113#define topology_core_siblings(cpu) (cpu_core_map[cpu]) 113#define topology_core_siblings(cpu) (cpu_core_map[cpu])
114#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) 114#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
115#define smt_capable() (smp_num_siblings > 1)
115#endif 116#endif
116 117
117#include <asm-generic/topology.h> 118#include <asm-generic/topology.h>
diff --git a/include/asm-m32r/hw_irq.h b/include/asm-m32r/hw_irq.h
index 8d7e9d0e09e8..7138537cda03 100644
--- a/include/asm-m32r/hw_irq.h
+++ b/include/asm-m32r/hw_irq.h
@@ -1,9 +1,4 @@
1#ifndef _ASM_M32R_HW_IRQ_H 1#ifndef _ASM_M32R_HW_IRQ_H
2#define _ASM_M32R_HW_IRQ_H 2#define _ASM_M32R_HW_IRQ_H
3 3
4static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
5{
6 /* Nothing to do */
7}
8
9#endif /* _ASM_M32R_HW_IRQ_H */ 4#endif /* _ASM_M32R_HW_IRQ_H */
diff --git a/include/asm-m68knommu/bootstd.h b/include/asm-m68knommu/bootstd.h
index 3fdc79f06d50..bdc1a4ac4fe9 100644
--- a/include/asm-m68knommu/bootstd.h
+++ b/include/asm-m68knommu/bootstd.h
@@ -52,7 +52,7 @@ type name(void) \
52 __asm__ __volatile__ ("trap #2" \ 52 __asm__ __volatile__ ("trap #2" \
53 : "=g" (__res) \ 53 : "=g" (__res) \
54 : "0" (__res) \ 54 : "0" (__res) \
55 : "%d0"); \ 55 ); \
56 __bsc_return(type,__res); \ 56 __bsc_return(type,__res); \
57} 57}
58 58
@@ -64,7 +64,7 @@ type name(atype a) \
64 __asm__ __volatile__ ("trap #2" \ 64 __asm__ __volatile__ ("trap #2" \
65 : "=g" (__res) \ 65 : "=g" (__res) \
66 : "0" (__res), "d" (__a) \ 66 : "0" (__res), "d" (__a) \
67 : "%d0"); \ 67 ); \
68 __bsc_return(type,__res); \ 68 __bsc_return(type,__res); \
69} 69}
70 70
@@ -77,7 +77,7 @@ type name(atype a, btype b) \
77 __asm__ __volatile__ ("trap #2" \ 77 __asm__ __volatile__ ("trap #2" \
78 : "=g" (__res) \ 78 : "=g" (__res) \
79 : "0" (__res), "d" (__a), "d" (__b) \ 79 : "0" (__res), "d" (__a), "d" (__b) \
80 : "%d0"); \ 80 ); \
81 __bsc_return(type,__res); \ 81 __bsc_return(type,__res); \
82} 82}
83 83
@@ -92,7 +92,7 @@ type name(atype a, btype b, ctype c) \
92 : "=g" (__res) \ 92 : "=g" (__res) \
93 : "0" (__res), "d" (__a), "d" (__b), \ 93 : "0" (__res), "d" (__a), "d" (__b), \
94 "d" (__c) \ 94 "d" (__c) \
95 : "%d0"); \ 95 ); \
96 __bsc_return(type,__res); \ 96 __bsc_return(type,__res); \
97} 97}
98 98
@@ -108,7 +108,7 @@ type name(atype a, btype b, ctype c, dtype d) \
108 : "=g" (__res) \ 108 : "=g" (__res) \
109 : "0" (__res), "d" (__a), "d" (__b), \ 109 : "0" (__res), "d" (__a), "d" (__b), \
110 "d" (__c), "d" (__d) \ 110 "d" (__c), "d" (__d) \
111 : "%d0"); \ 111 ); \
112 __bsc_return(type,__res); \ 112 __bsc_return(type,__res); \
113} 113}
114 114
@@ -125,7 +125,7 @@ type name(atype a, btype b, ctype c, dtype d, etype e) \
125 : "=g" (__res) \ 125 : "=g" (__res) \
126 : "0" (__res), "d" (__a), "d" (__b), \ 126 : "0" (__res), "d" (__a), "d" (__b), \
127 "d" (__c), "d" (__d), "d" (__e) \ 127 "d" (__c), "d" (__d), "d" (__e) \
128 : "%d0"); \ 128 ); \
129 __bsc_return(type,__res); \ 129 __bsc_return(type,__res); \
130} 130}
131 131
diff --git a/include/asm-m68knommu/ptrace.h b/include/asm-m68knommu/ptrace.h
index 1e19c457de7d..47258e86e8c4 100644
--- a/include/asm-m68knommu/ptrace.h
+++ b/include/asm-m68knommu/ptrace.h
@@ -46,11 +46,9 @@ struct pt_regs {
46#else 46#else
47 unsigned short sr; 47 unsigned short sr;
48 unsigned long pc; 48 unsigned long pc;
49#ifndef NO_FORMAT_VEC
50 unsigned format : 4; /* frame format specifier */ 49 unsigned format : 4; /* frame format specifier */
51 unsigned vector : 12; /* vector offset */ 50 unsigned vector : 12; /* vector offset */
52#endif 51#endif
53#endif
54}; 52};
55 53
56/* 54/*
diff --git a/include/asm-mips/asmmacro.h b/include/asm-mips/asmmacro.h
index 2c42f6b00a49..92e62ef711ed 100644
--- a/include/asm-mips/asmmacro.h
+++ b/include/asm-mips/asmmacro.h
@@ -26,14 +26,14 @@
26 ori \reg, \reg, TCSTATUS_IXMT 26 ori \reg, \reg, TCSTATUS_IXMT
27 xori \reg, \reg, TCSTATUS_IXMT 27 xori \reg, \reg, TCSTATUS_IXMT
28 mtc0 \reg, CP0_TCSTATUS 28 mtc0 \reg, CP0_TCSTATUS
29 ehb 29 _ehb
30 .endm 30 .endm
31 31
32 .macro local_irq_disable reg=t0 32 .macro local_irq_disable reg=t0
33 mfc0 \reg, CP0_TCSTATUS 33 mfc0 \reg, CP0_TCSTATUS
34 ori \reg, \reg, TCSTATUS_IXMT 34 ori \reg, \reg, TCSTATUS_IXMT
35 mtc0 \reg, CP0_TCSTATUS 35 mtc0 \reg, CP0_TCSTATUS
36 ehb 36 _ehb
37 .endm 37 .endm
38#else 38#else
39 .macro local_irq_enable reg=t0 39 .macro local_irq_enable reg=t0
diff --git a/include/asm-mips/cpu-features.h b/include/asm-mips/cpu-features.h
index 881ce1f9803d..44285a9d5520 100644
--- a/include/asm-mips/cpu-features.h
+++ b/include/asm-mips/cpu-features.h
@@ -187,19 +187,15 @@
187# endif 187# endif
188#endif 188#endif
189 189
190#ifdef CONFIG_CPU_MIPSR2 190#if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
191# if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint) 191# define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT)
192# define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT) 192#elif !defined(cpu_has_vint)
193# else
194# define cpu_has_vint 0
195# endif
196# if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
197# define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
198# else
199# define cpu_has_veic 0
200# endif
201#else
202# define cpu_has_vint 0 193# define cpu_has_vint 0
194#endif
195
196#if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
197# define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
198#elif !defined(cpu_has_veic)
203# define cpu_has_veic 0 199# define cpu_has_veic 0
204#endif 200#endif
205 201
diff --git a/include/asm-mips/fixmap.h b/include/asm-mips/fixmap.h
index 1cadefbbc037..6959bdb59310 100644
--- a/include/asm-mips/fixmap.h
+++ b/include/asm-mips/fixmap.h
@@ -69,7 +69,11 @@ extern void __set_fixmap (enum fixed_addresses idx,
69 * the start of the fixmap, and leave one page empty 69 * the start of the fixmap, and leave one page empty
70 * at the top of mem.. 70 * at the top of mem..
71 */ 71 */
72#if defined(CONFIG_CPU_TX39XX) || defined(CONFIG_CPU_TX49XX)
73#define FIXADDR_TOP (0xff000000UL - 0x2000)
74#else
72#define FIXADDR_TOP (0xffffe000UL) 75#define FIXADDR_TOP (0xffffe000UL)
76#endif
73#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 77#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
74#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 78#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
75 79
diff --git a/include/asm-mips/hazards.h b/include/asm-mips/hazards.h
index 66943c451c1d..25f5e8a4177d 100644
--- a/include/asm-mips/hazards.h
+++ b/include/asm-mips/hazards.h
@@ -69,10 +69,10 @@
69 * Use a macro for ehb unless explicit support for MIPSR2 is enabled 69 * Use a macro for ehb unless explicit support for MIPSR2 is enabled
70 */ 70 */
71 71
72#define irq_enable_hazard 72#define irq_enable_hazard \
73 _ehb 73 _ehb
74 74
75#define irq_disable_hazard 75#define irq_disable_hazard \
76 _ehb 76 _ehb
77 77
78#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) 78#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000)
diff --git a/include/asm-mips/hw_irq.h b/include/asm-mips/hw_irq.h
index c854d017c0e5..458d9fdc76bf 100644
--- a/include/asm-mips/hw_irq.h
+++ b/include/asm-mips/hw_irq.h
@@ -19,9 +19,9 @@ extern void init_8259A(int aeoi);
19 19
20extern atomic_t irq_err_count; 20extern atomic_t irq_err_count;
21 21
22/* This may not be apropriate for all machines, we'll see ... */ 22/*
23static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) 23 * interrupt-retrigger: NOP for now. This may not be apropriate for all
24{ 24 * machines, we'll see ...
25} 25 */
26 26
27#endif /* __ASM_HW_IRQ_H */ 27#endif /* __ASM_HW_IRQ_H */
diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h
index d35c61776a02..896550bad322 100644
--- a/include/asm-mips/irq.h
+++ b/include/asm-mips/irq.h
@@ -76,4 +76,8 @@ extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
76 unsigned long hwmask); 76 unsigned long hwmask);
77#endif /* CONFIG_MIPS_MT_SMTC */ 77#endif /* CONFIG_MIPS_MT_SMTC */
78 78
79#ifdef CONFIG_SMP
80#define ARCH_HAS_IRQ_PER_CPU
81#endif
82
79#endif /* _ASM_IRQ_H */ 83#endif /* _ASM_IRQ_H */
diff --git a/include/asm-mips/mach-au1x00/au1xxx_psc.h b/include/asm-mips/mach-au1x00/au1xxx_psc.h
index d7cbacdd21fe..1bd4e27caf6b 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_psc.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_psc.h
@@ -512,7 +512,7 @@ typedef struct psc_smb {
512 512
513/* Transmit register control. 513/* Transmit register control.
514*/ 514*/
515#define PSC_SMBTXRX_RSR (1 << 30) 515#define PSC_SMBTXRX_RSR (1 << 28)
516#define PSC_SMBTXRX_STP (1 << 29) 516#define PSC_SMBTXRX_STP (1 << 29)
517#define PSC_SMBTXRX_DATAMASK (0xff) 517#define PSC_SMBTXRX_DATAMASK (0xff)
518 518
diff --git a/include/asm-mips/mach-mips/irq.h b/include/asm-mips/mach-mips/irq.h
index 083d9c512a04..e994b0c01227 100644
--- a/include/asm-mips/mach-mips/irq.h
+++ b/include/asm-mips/mach-mips/irq.h
@@ -4,10 +4,4 @@
4 4
5#define NR_IRQS 256 5#define NR_IRQS 256
6 6
7#ifdef CONFIG_SMP
8
9#define ARCH_HAS_IRQ_PER_CPU
10
11#endif
12
13#endif /* __ASM_MACH_MIPS_IRQ_H */ 7#endif /* __ASM_MACH_MIPS_IRQ_H */
diff --git a/include/asm-mips/mipsregs.h b/include/asm-mips/mipsregs.h
index 673977901ed3..9192d76c133d 100644
--- a/include/asm-mips/mipsregs.h
+++ b/include/asm-mips/mipsregs.h
@@ -1459,7 +1459,8 @@ static inline void __emt(unsigned int previous)
1459static inline void __ehb(void) 1459static inline void __ehb(void)
1460{ 1460{
1461 __asm__ __volatile__( 1461 __asm__ __volatile__(
1462 " ehb \n"); 1462 " .set mips32r2 \n"
1463 " ehb \n" " .set mips0 \n");
1463} 1464}
1464 1465
1465/* 1466/*
diff --git a/include/asm-mips/sn/ioc3.h b/include/asm-mips/sn/ioc3.h
index f7d530f306f2..099677774d71 100644
--- a/include/asm-mips/sn/ioc3.h
+++ b/include/asm-mips/sn/ioc3.h
@@ -5,6 +5,8 @@
5#ifndef _IOC3_H 5#ifndef _IOC3_H
6#define _IOC3_H 6#define _IOC3_H
7 7
8#include <linux/types.h>
9
8/* SUPERIO uart register map */ 10/* SUPERIO uart register map */
9typedef volatile struct ioc3_uartregs { 11typedef volatile struct ioc3_uartregs {
10 union { 12 union {
diff --git a/include/asm-mips/sn/klconfig.h b/include/asm-mips/sn/klconfig.h
index 52238e65af8e..b63cd0655b3d 100644
--- a/include/asm-mips/sn/klconfig.h
+++ b/include/asm-mips/sn/klconfig.h
@@ -602,7 +602,7 @@ typedef struct klcpu_s { /* CPU */
602 602
603typedef struct klhub_s { /* HUB */ 603typedef struct klhub_s { /* HUB */
604 klinfo_t hub_info; 604 klinfo_t hub_info;
605 uint hub_flags; /* PCFG_HUB_xxx flags */ 605 unsigned int hub_flags; /* PCFG_HUB_xxx flags */
606 klport_t hub_port; /* hub is connected to this */ 606 klport_t hub_port; /* hub is connected to this */
607 nic_t hub_box_nic; /* nic of containing box */ 607 nic_t hub_box_nic; /* nic of containing box */
608 klconf_off_t hub_mfg_nic; /* MFG NIC string */ 608 klconf_off_t hub_mfg_nic; /* MFG NIC string */
@@ -611,7 +611,7 @@ typedef struct klhub_s { /* HUB */
611 611
612typedef struct klhub_uart_s { /* HUB */ 612typedef struct klhub_uart_s { /* HUB */
613 klinfo_t hubuart_info; 613 klinfo_t hubuart_info;
614 uint hubuart_flags; /* PCFG_HUB_xxx flags */ 614 unsigned int hubuart_flags; /* PCFG_HUB_xxx flags */
615 nic_t hubuart_box_nic; /* nic of containing box */ 615 nic_t hubuart_box_nic; /* nic of containing box */
616} klhub_uart_t ; 616} klhub_uart_t ;
617 617
@@ -710,7 +710,7 @@ typedef struct klvmed_s { /* VME DEVICE - VME BOARD */
710/* XXX - Don't we need the number of ports here?!? */ 710/* XXX - Don't we need the number of ports here?!? */
711typedef struct klrou_s { /* ROUTER */ 711typedef struct klrou_s { /* ROUTER */
712 klinfo_t rou_info ; 712 klinfo_t rou_info ;
713 uint rou_flags ; /* PCFG_ROUTER_xxx flags */ 713 unsigned int rou_flags ; /* PCFG_ROUTER_xxx flags */
714 nic_t rou_box_nic ; /* nic of the containing module */ 714 nic_t rou_box_nic ; /* nic of the containing module */
715 klport_t rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */ 715 klport_t rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
716 klconf_off_t rou_mfg_nic ; /* MFG NIC string */ 716 klconf_off_t rou_mfg_nic ; /* MFG NIC string */
@@ -733,8 +733,8 @@ typedef struct klgfx_s { /* GRAPHICS Device */
733 klinfo_t gfx_info; 733 klinfo_t gfx_info;
734 klconf_off_t old_gndevs; /* for compatibility with older proms */ 734 klconf_off_t old_gndevs; /* for compatibility with older proms */
735 klconf_off_t old_gdoff0; /* for compatibility with older proms */ 735 klconf_off_t old_gdoff0; /* for compatibility with older proms */
736 uint cookie; /* for compatibility with older proms */ 736 unsigned int cookie; /* for compatibility with older proms */
737 uint moduleslot; 737 unsigned int moduleslot;
738 struct klgfx_s *gfx_next_pipe; 738 struct klgfx_s *gfx_next_pipe;
739 graphics_t gfx_specific; 739 graphics_t gfx_specific;
740 klconf_off_t pad0; /* for compatibility with older proms */ 740 klconf_off_t pad0; /* for compatibility with older proms */
diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h
index 513aa5133830..158a4cd12e46 100644
--- a/include/asm-mips/stackframe.h
+++ b/include/asm-mips/stackframe.h
@@ -304,7 +304,7 @@
304 mfc0 v0, CP0_TCSTATUS 304 mfc0 v0, CP0_TCSTATUS
305 ori v0, TCSTATUS_IXMT 305 ori v0, TCSTATUS_IXMT
306 mtc0 v0, CP0_TCSTATUS 306 mtc0 v0, CP0_TCSTATUS
307 ehb 307 _ehb
308 DMT 5 # dmt a1 308 DMT 5 # dmt a1
309 jal mips_ihb 309 jal mips_ihb
310#endif /* CONFIG_MIPS_MT_SMTC */ 310#endif /* CONFIG_MIPS_MT_SMTC */
@@ -325,14 +325,14 @@
325 * restore TCStatus.IXMT. 325 * restore TCStatus.IXMT.
326 */ 326 */
327 LONG_L v1, PT_TCSTATUS(sp) 327 LONG_L v1, PT_TCSTATUS(sp)
328 ehb 328 _ehb
329 mfc0 v0, CP0_TCSTATUS 329 mfc0 v0, CP0_TCSTATUS
330 andi v1, TCSTATUS_IXMT 330 andi v1, TCSTATUS_IXMT
331 /* We know that TCStatua.IXMT should be set from above */ 331 /* We know that TCStatua.IXMT should be set from above */
332 xori v0, v0, TCSTATUS_IXMT 332 xori v0, v0, TCSTATUS_IXMT
333 or v0, v0, v1 333 or v0, v0, v1
334 mtc0 v0, CP0_TCSTATUS 334 mtc0 v0, CP0_TCSTATUS
335 ehb 335 _ehb
336 andi a1, a1, VPECONTROL_TE 336 andi a1, a1, VPECONTROL_TE
337 beqz a1, 1f 337 beqz a1, 1f
338 emt 338 emt
@@ -411,7 +411,7 @@
411 /* Clear TKSU, leave IXMT */ 411 /* Clear TKSU, leave IXMT */
412 xori t0, 0x00001800 412 xori t0, 0x00001800
413 mtc0 t0, CP0_TCSTATUS 413 mtc0 t0, CP0_TCSTATUS
414 ehb 414 _ehb
415 /* We need to leave the global IE bit set, but clear EXL...*/ 415 /* We need to leave the global IE bit set, but clear EXL...*/
416 mfc0 t0, CP0_STATUS 416 mfc0 t0, CP0_STATUS
417 ori t0, ST0_EXL | ST0_ERL 417 ori t0, ST0_EXL | ST0_ERL
@@ -438,7 +438,7 @@
438 * and enable interrupts only for the 438 * and enable interrupts only for the
439 * current TC, using the TCStatus register. 439 * current TC, using the TCStatus register.
440 */ 440 */
441 ehb 441 _ehb
442 mfc0 t0,CP0_TCSTATUS 442 mfc0 t0,CP0_TCSTATUS
443 /* Fortunately CU 0 is in the same place in both registers */ 443 /* Fortunately CU 0 is in the same place in both registers */
444 /* Set TCU0, TKSU (for later inversion) and IXMT */ 444 /* Set TCU0, TKSU (for later inversion) and IXMT */
@@ -447,7 +447,7 @@
447 /* Clear TKSU *and* IXMT */ 447 /* Clear TKSU *and* IXMT */
448 xori t0, 0x00001c00 448 xori t0, 0x00001c00
449 mtc0 t0, CP0_TCSTATUS 449 mtc0 t0, CP0_TCSTATUS
450 ehb 450 _ehb
451 /* We need to leave the global IE bit set, but clear EXL...*/ 451 /* We need to leave the global IE bit set, but clear EXL...*/
452 mfc0 t0, CP0_STATUS 452 mfc0 t0, CP0_STATUS
453 ori t0, ST0_EXL 453 ori t0, ST0_EXL
@@ -479,7 +479,7 @@
479 andi v1, v0, TCSTATUS_IXMT 479 andi v1, v0, TCSTATUS_IXMT
480 ori v0, TCSTATUS_IXMT 480 ori v0, TCSTATUS_IXMT
481 mtc0 v0, CP0_TCSTATUS 481 mtc0 v0, CP0_TCSTATUS
482 ehb 482 _ehb
483 DMT 2 # dmt v0 483 DMT 2 # dmt v0
484 /* 484 /*
485 * We don't know a priori if ra is "live" 485 * We don't know a priori if ra is "live"
@@ -495,7 +495,7 @@
495 xori t0, 0x1e 495 xori t0, 0x1e
496 mtc0 t0, CP0_STATUS 496 mtc0 t0, CP0_STATUS
497#ifdef CONFIG_MIPS_MT_SMTC 497#ifdef CONFIG_MIPS_MT_SMTC
498 ehb 498 _ehb
499 andi v0, v0, VPECONTROL_TE 499 andi v0, v0, VPECONTROL_TE
500 beqz v0, 2f 500 beqz v0, 2f
501 nop /* delay slot */ 501 nop /* delay slot */
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 8bb0bb9b2e68..809f9f55bacb 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -326,16 +326,17 @@
326#define __NR_unshare (__NR_Linux + 303) 326#define __NR_unshare (__NR_Linux + 303)
327#define __NR_splice (__NR_Linux + 304) 327#define __NR_splice (__NR_Linux + 304)
328#define __NR_sync_file_range (__NR_Linux + 305) 328#define __NR_sync_file_range (__NR_Linux + 305)
329#define __NR_tee (__NR_Linux + 306)
329 330
330/* 331/*
331 * Offset of the last Linux o32 flavoured syscall 332 * Offset of the last Linux o32 flavoured syscall
332 */ 333 */
333#define __NR_Linux_syscalls 305 334#define __NR_Linux_syscalls 306
334 335
335#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 336#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
336 337
337#define __NR_O32_Linux 4000 338#define __NR_O32_Linux 4000
338#define __NR_O32_Linux_syscalls 305 339#define __NR_O32_Linux_syscalls 306
339 340
340#if _MIPS_SIM == _MIPS_SIM_ABI64 341#if _MIPS_SIM == _MIPS_SIM_ABI64
341 342
@@ -608,16 +609,17 @@
608#define __NR_unshare (__NR_Linux + 262) 609#define __NR_unshare (__NR_Linux + 262)
609#define __NR_splice (__NR_Linux + 263) 610#define __NR_splice (__NR_Linux + 263)
610#define __NR_sync_file_range (__NR_Linux + 264) 611#define __NR_sync_file_range (__NR_Linux + 264)
612#define __NR_tee (__NR_Linux + 265)
611 613
612/* 614/*
613 * Offset of the last Linux 64-bit flavoured syscall 615 * Offset of the last Linux 64-bit flavoured syscall
614 */ 616 */
615#define __NR_Linux_syscalls 264 617#define __NR_Linux_syscalls 265
616 618
617#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 619#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
618 620
619#define __NR_64_Linux 5000 621#define __NR_64_Linux 5000
620#define __NR_64_Linux_syscalls 264 622#define __NR_64_Linux_syscalls 265
621 623
622#if _MIPS_SIM == _MIPS_SIM_NABI32 624#if _MIPS_SIM == _MIPS_SIM_NABI32
623 625
@@ -894,16 +896,17 @@
894#define __NR_unshare (__NR_Linux + 266) 896#define __NR_unshare (__NR_Linux + 266)
895#define __NR_splice (__NR_Linux + 267) 897#define __NR_splice (__NR_Linux + 267)
896#define __NR_sync_file_range (__NR_Linux + 268) 898#define __NR_sync_file_range (__NR_Linux + 268)
899#define __NR_tee (__NR_Linux + 269)
897 900
898/* 901/*
899 * Offset of the last N32 flavoured syscall 902 * Offset of the last N32 flavoured syscall
900 */ 903 */
901#define __NR_Linux_syscalls 268 904#define __NR_Linux_syscalls 269
902 905
903#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 906#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
904 907
905#define __NR_N32_Linux 6000 908#define __NR_N32_Linux 6000
906#define __NR_N32_Linux_syscalls 268 909#define __NR_N32_Linux_syscalls 269
907 910
908#ifdef __KERNEL__ 911#ifdef __KERNEL__
909 912
diff --git a/include/asm-parisc/assembly.h b/include/asm-parisc/assembly.h
index 3ce3440d1b0c..1a7bfe699e0c 100644
--- a/include/asm-parisc/assembly.h
+++ b/include/asm-parisc/assembly.h
@@ -48,6 +48,7 @@
48#define CALLEE_SAVE_FRAME_SIZE (CALLEE_REG_FRAME_SIZE + CALLEE_FLOAT_FRAME_SIZE) 48#define CALLEE_SAVE_FRAME_SIZE (CALLEE_REG_FRAME_SIZE + CALLEE_FLOAT_FRAME_SIZE)
49 49
50#ifdef CONFIG_PA20 50#ifdef CONFIG_PA20
51#define LDCW ldcw,co
51#define BL b,l 52#define BL b,l
52# ifdef CONFIG_64BIT 53# ifdef CONFIG_64BIT
53# define LEVEL 2.0w 54# define LEVEL 2.0w
@@ -55,6 +56,7 @@
55# define LEVEL 2.0 56# define LEVEL 2.0
56# endif 57# endif
57#else 58#else
59#define LDCW ldcw
58#define BL bl 60#define BL bl
59#define LEVEL 1.1 61#define LEVEL 1.1
60#endif 62#endif
diff --git a/include/asm-parisc/compat.h b/include/asm-parisc/compat.h
index 289624d8b2d4..71b4eeea205a 100644
--- a/include/asm-parisc/compat.h
+++ b/include/asm-parisc/compat.h
@@ -5,6 +5,7 @@
5 */ 5 */
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/personality.h>
8 9
9#define COMPAT_USER_HZ 100 10#define COMPAT_USER_HZ 100
10 11
@@ -149,4 +150,14 @@ static __inline__ void __user *compat_alloc_user_space(long len)
149 return (void __user *)regs->gr[30]; 150 return (void __user *)regs->gr[30];
150} 151}
151 152
153static inline int __is_compat_task(struct task_struct *t)
154{
155 return personality(t->personality) == PER_LINUX32;
156}
157
158static inline int is_compat_task(void)
159{
160 return __is_compat_task(current);
161}
162
152#endif /* _ASM_PARISC_COMPAT_H */ 163#endif /* _ASM_PARISC_COMPAT_H */
diff --git a/include/asm-parisc/hw_irq.h b/include/asm-parisc/hw_irq.h
index 151426e27521..6707f7df3921 100644
--- a/include/asm-parisc/hw_irq.h
+++ b/include/asm-parisc/hw_irq.h
@@ -3,15 +3,6 @@
3 3
4/* 4/*
5 * linux/include/asm/hw_irq.h 5 * linux/include/asm/hw_irq.h
6 *
7 * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
8 *
9 * moved some of the old arch/i386/kernel/irq.h to here. VY
10 *
11 * IRQ/IPI changes taken from work by Thomas Radke
12 * <tomsoft@informatik.tu-chemnitz.de>
13 */ 6 */
14 7
15extern void hw_resend_irq(struct hw_interrupt_type *, unsigned int);
16
17#endif 8#endif
diff --git a/include/asm-parisc/irq.h b/include/asm-parisc/irq.h
index 377ba90c7d02..5cae260615a2 100644
--- a/include/asm-parisc/irq.h
+++ b/include/asm-parisc/irq.h
@@ -26,11 +26,6 @@
26 26
27#define NR_IRQS (CPU_IRQ_MAX + 1) 27#define NR_IRQS (CPU_IRQ_MAX + 1)
28 28
29/*
30 * IRQ line status macro IRQ_PER_CPU is used
31 */
32#define ARCH_HAS_IRQ_PER_CPU
33
34static __inline__ int irq_canonicalize(int irq) 29static __inline__ int irq_canonicalize(int irq)
35{ 30{
36 return (irq == 2) ? 9 : irq; 31 return (irq == 2) ? 9 : irq;
diff --git a/include/asm-parisc/pdc.h b/include/asm-parisc/pdc.h
index 08364f957e7a..c9b2e35326ee 100644
--- a/include/asm-parisc/pdc.h
+++ b/include/asm-parisc/pdc.h
@@ -278,12 +278,11 @@ typedef struct {
278/* constants for OS (NVM...) */ 278/* constants for OS (NVM...) */
279#define OS_ID_NONE 0 /* Undefined OS ID */ 279#define OS_ID_NONE 0 /* Undefined OS ID */
280#define OS_ID_HPUX 1 /* HP-UX OS */ 280#define OS_ID_HPUX 1 /* HP-UX OS */
281#define OS_ID_LINUX OS_ID_HPUX /* just use the same value as hpux */
282#define OS_ID_MPEXL 2 /* MPE XL OS */ 281#define OS_ID_MPEXL 2 /* MPE XL OS */
283#define OS_ID_OSF 3 /* OSF OS */ 282#define OS_ID_OSF 3 /* OSF OS */
284#define OS_ID_HPRT 4 /* HP-RT OS */ 283#define OS_ID_HPRT 4 /* HP-RT OS */
285#define OS_ID_NOVEL 5 /* NOVELL OS */ 284#define OS_ID_NOVEL 5 /* NOVELL OS */
286#define OS_ID_NT 6 /* NT OS */ 285#define OS_ID_LINUX 6 /* Linux */
287 286
288 287
289/* constants for PDC_CHASSIS */ 288/* constants for PDC_CHASSIS */
@@ -352,8 +351,8 @@ struct pdc_cache_cf { /* for PDC_CACHE (I/D-caches) */
352 cc_wt : 1, /* 0 = WT-Dcache, 1 = WB-Dcache */ 351 cc_wt : 1, /* 0 = WT-Dcache, 1 = WB-Dcache */
353 cc_sh : 2, /* 0 = separate I/D-cache, else shared I/D-cache */ 352 cc_sh : 2, /* 0 = separate I/D-cache, else shared I/D-cache */
354 cc_cst : 3, /* 0 = incoherent D-cache, 1=coherent D-cache */ 353 cc_cst : 3, /* 0 = incoherent D-cache, 1=coherent D-cache */
355 cc_pad1 : 5, /* reserved */ 354 cc_pad1 : 10, /* reserved */
356 cc_assoc: 8; /* associativity of I/D-cache */ 355 cc_hv : 3; /* hversion dependent */
357}; 356};
358 357
359struct pdc_tlb_cf { /* for PDC_CACHE (I/D-TLB's) */ 358struct pdc_tlb_cf { /* for PDC_CACHE (I/D-TLB's) */
@@ -719,6 +718,7 @@ void setup_pdc(void); /* in inventory.c */
719int pdc_add_valid(unsigned long address); 718int pdc_add_valid(unsigned long address);
720int pdc_chassis_info(struct pdc_chassis_info *chassis_info, void *led_info, unsigned long len); 719int pdc_chassis_info(struct pdc_chassis_info *chassis_info, void *led_info, unsigned long len);
721int pdc_chassis_disp(unsigned long disp); 720int pdc_chassis_disp(unsigned long disp);
721int pdc_chassis_warn(unsigned long *warn);
722int pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info); 722int pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info);
723int pdc_iodc_read(unsigned long *actcnt, unsigned long hpa, unsigned int index, 723int pdc_iodc_read(unsigned long *actcnt, unsigned long hpa, unsigned int index,
724 void *iodc_data, unsigned int iodc_data_size); 724 void *iodc_data, unsigned int iodc_data_size);
@@ -732,6 +732,7 @@ int pdc_model_cpuid(unsigned long *cpu_id);
732int pdc_model_versions(unsigned long *versions, int id); 732int pdc_model_versions(unsigned long *versions, int id);
733int pdc_model_capabilities(unsigned long *capabilities); 733int pdc_model_capabilities(unsigned long *capabilities);
734int pdc_cache_info(struct pdc_cache_info *cache); 734int pdc_cache_info(struct pdc_cache_info *cache);
735int pdc_spaceid_bits(unsigned long *space_bits);
735#ifndef CONFIG_PA20 736#ifndef CONFIG_PA20
736int pdc_btlb_info(struct pdc_btlb_info *btlb); 737int pdc_btlb_info(struct pdc_btlb_info *btlb);
737int pdc_mem_map_hpa(struct pdc_memory_map *r_addr, struct pdc_module_path *mod_path); 738int pdc_mem_map_hpa(struct pdc_memory_map *r_addr, struct pdc_module_path *mod_path);
@@ -775,6 +776,18 @@ int pdc_sti_call(unsigned long func, unsigned long flags,
775 776
776extern void pdc_init(void); 777extern void pdc_init(void);
777 778
779static inline char * os_id_to_string(u16 os_id) {
780 switch(os_id) {
781 case OS_ID_NONE: return "No OS";
782 case OS_ID_HPUX: return "HP-UX";
783 case OS_ID_MPEXL: return "MPE-iX";
784 case OS_ID_OSF: return "OSF";
785 case OS_ID_HPRT: return "HP-RT";
786 case OS_ID_NOVEL: return "Novell Netware";
787 case OS_ID_LINUX: return "Linux";
788 default: return "Unknown";
789 }
790}
778#endif /* __ASSEMBLY__ */ 791#endif /* __ASSEMBLY__ */
779 792
780#endif /* _PARISC_PDC_H */ 793#endif /* _PARISC_PDC_H */
diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
index b6bcc672ba80..5066c54dae0a 100644
--- a/include/asm-parisc/pgtable.h
+++ b/include/asm-parisc/pgtable.h
@@ -506,13 +506,13 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
506 506
507/* TLB page size encoding - see table 3-1 in parisc20.pdf */ 507/* TLB page size encoding - see table 3-1 in parisc20.pdf */
508#define _PAGE_SIZE_ENCODING_4K 0 508#define _PAGE_SIZE_ENCODING_4K 0
509#define _PAGE_SIZE_ENCODING_16K 1 509#define _PAGE_SIZE_ENCODING_16K 1
510#define _PAGE_SIZE_ENCODING_64K 2 510#define _PAGE_SIZE_ENCODING_64K 2
511#define _PAGE_SIZE_ENCODING_256K 3 511#define _PAGE_SIZE_ENCODING_256K 3
512#define _PAGE_SIZE_ENCODING_1M 4 512#define _PAGE_SIZE_ENCODING_1M 4
513#define _PAGE_SIZE_ENCODING_4M 5 513#define _PAGE_SIZE_ENCODING_4M 5
514#define _PAGE_SIZE_ENCODING_16M 6 514#define _PAGE_SIZE_ENCODING_16M 6
515#define _PAGE_SIZE_ENCODING_64M 7 515#define _PAGE_SIZE_ENCODING_64M 7
516 516
517#if defined(CONFIG_PARISC_PAGE_SIZE_4KB) 517#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
518# define _PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_4K 518# define _PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_4K
diff --git a/include/asm-parisc/processor.h b/include/asm-parisc/processor.h
index ca49dc91f4fc..b73626f040da 100644
--- a/include/asm-parisc/processor.h
+++ b/include/asm-parisc/processor.h
@@ -26,14 +26,12 @@
26 * Default implementation of macro that returns current 26 * Default implementation of macro that returns current
27 * instruction pointer ("program counter"). 27 * instruction pointer ("program counter").
28 */ 28 */
29 29#ifdef CONFIG_PA20
30/* We cannot use MFIA as it was added for PA2.0 - prumpf 30#define current_ia(x) __asm__("mfia %0" : "=r"(x))
31 31#else /* mfia added in pa2.0 */
32 At one point there were no "0f/0b" type local symbols in gas for 32#define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x))
33 PA-RISC. This is no longer true, but this still seems like the 33#endif
34 nicest way to implement this. */ 34#define current_text_addr() ({ void *pc; current_ia(pc); pc; })
35
36#define current_text_addr() ({ void *pc; __asm__("\n\tblr 0,%0\n\tnop":"=r" (pc)); pc; })
37 35
38#define TASK_SIZE (current->thread.task_size) 36#define TASK_SIZE (current->thread.task_size)
39#define TASK_UNMAPPED_BASE (current->thread.map_base) 37#define TASK_UNMAPPED_BASE (current->thread.map_base)
diff --git a/include/asm-parisc/system.h b/include/asm-parisc/system.h
index 863876134b2c..5fe2d2329ab5 100644
--- a/include/asm-parisc/system.h
+++ b/include/asm-parisc/system.h
@@ -155,13 +155,14 @@ static inline void set_eiem(unsigned long val)
155 type and dynamically select the 16-byte aligned int from the array 155 type and dynamically select the 16-byte aligned int from the array
156 for the semaphore. */ 156 for the semaphore. */
157 157
158#define __PA_LDCW_ALIGNMENT 16 158#define __PA_LDCW_ALIGNMENT 16
159#define __ldcw_align(a) ({ \ 159#define __ldcw_align(a) ({ \
160 unsigned long __ret = (unsigned long) &(a)->lock[0]; \ 160 unsigned long __ret = (unsigned long) &(a)->lock[0]; \
161 __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1); \ 161 __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) \
162 (volatile unsigned int *) __ret; \ 162 & ~(__PA_LDCW_ALIGNMENT - 1); \
163 (volatile unsigned int *) __ret; \
163}) 164})
164#define LDCW "ldcw" 165#define __LDCW "ldcw"
165 166
166#else /*CONFIG_PA20*/ 167#else /*CONFIG_PA20*/
167/* From: "Jim Hull" <jim.hull of hp.com> 168/* From: "Jim Hull" <jim.hull of hp.com>
@@ -171,17 +172,18 @@ static inline void set_eiem(unsigned long val)
171 they only require "natural" alignment (4-byte for ldcw, 8-byte for 172 they only require "natural" alignment (4-byte for ldcw, 8-byte for
172 ldcd). */ 173 ldcd). */
173 174
174#define __PA_LDCW_ALIGNMENT 4 175#define __PA_LDCW_ALIGNMENT 4
175#define __ldcw_align(a) ((volatile unsigned int *)a) 176#define __ldcw_align(a) ((volatile unsigned int *)a)
176#define LDCW "ldcw,co" 177#define __LDCW "ldcw,co"
177 178
178#endif /*!CONFIG_PA20*/ 179#endif /*!CONFIG_PA20*/
179 180
180/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */ 181/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
181#define __ldcw(a) ({ \ 182#define __ldcw(a) ({ \
182 unsigned __ret; \ 183 unsigned __ret; \
183 __asm__ __volatile__(LDCW " 0(%1),%0" : "=r" (__ret) : "r" (a)); \ 184 __asm__ __volatile__(__LDCW " 0(%1),%0" \
184 __ret; \ 185 : "=r" (__ret) : "r" (a)); \
186 __ret; \
185}) 187})
186 188
187#ifdef CONFIG_SMP 189#ifdef CONFIG_SMP
diff --git a/include/asm-parisc/uaccess.h b/include/asm-parisc/uaccess.h
index f6c417c8c484..d973e8b3466c 100644
--- a/include/asm-parisc/uaccess.h
+++ b/include/asm-parisc/uaccess.h
@@ -172,7 +172,11 @@ struct exception_data {
172/* 172/*
173 * The "__put_user/kernel_asm()" macros tell gcc they read from memory 173 * The "__put_user/kernel_asm()" macros tell gcc they read from memory
174 * instead of writing. This is because they do not write to any memory 174 * instead of writing. This is because they do not write to any memory
175 * gcc knows about, so there are no aliasing issues. 175 * gcc knows about, so there are no aliasing issues. These macros must
176 * also be aware that "fixup_put_user_skip_[12]" are executed in the
177 * context of the fault, and any registers used there must be listed
178 * as clobbers. In this case only "r1" is used by the current routines.
179 * r8/r9 are already listed as err/val.
176 */ 180 */
177 181
178#ifdef __LP64__ 182#ifdef __LP64__
@@ -183,7 +187,8 @@ struct exception_data {
183 "\t.dword\t1b,fixup_put_user_skip_1\n" \ 187 "\t.dword\t1b,fixup_put_user_skip_1\n" \
184 "\t.previous" \ 188 "\t.previous" \
185 : "=r"(__pu_err) \ 189 : "=r"(__pu_err) \
186 : "r"(ptr), "r"(x), "0"(__pu_err)) 190 : "r"(ptr), "r"(x), "0"(__pu_err) \
191 : "r1")
187 192
188#define __put_user_asm(stx,x,ptr) \ 193#define __put_user_asm(stx,x,ptr) \
189 __asm__ __volatile__ ( \ 194 __asm__ __volatile__ ( \
diff --git a/include/asm-parisc/unistd.h b/include/asm-parisc/unistd.h
index 12b867238a47..27bcfad1c3e3 100644
--- a/include/asm-parisc/unistd.h
+++ b/include/asm-parisc/unistd.h
@@ -797,11 +797,6 @@
797 797
798#define SYS_ify(syscall_name) __NR_##syscall_name 798#define SYS_ify(syscall_name) __NR_##syscall_name
799 799
800/* Assume all syscalls are done from PIC code just to be
801 * safe. The worst case scenario is that you lose a register
802 * and save/restore r19 across the syscall. */
803#define PIC
804
805#ifndef ASM_LINE_SEP 800#ifndef ASM_LINE_SEP
806# define ASM_LINE_SEP ; 801# define ASM_LINE_SEP ;
807#endif 802#endif
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index fab41c280aa1..1ba3c9983614 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -117,38 +117,30 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
117#define CPU_FTR_PPC_LE ASM_CONST(0x0000000000200000) 117#define CPU_FTR_PPC_LE ASM_CONST(0x0000000000200000)
118#define CPU_FTR_REAL_LE ASM_CONST(0x0000000000400000) 118#define CPU_FTR_REAL_LE ASM_CONST(0x0000000000400000)
119 119
120/*
121 * Add the 64-bit processor unique features in the top half of the word;
122 * on 32-bit, make the names available but defined to be 0.
123 */
120#ifdef __powerpc64__ 124#ifdef __powerpc64__
121/* Add the 64b processor unique features in the top half of the word */ 125#define LONG_ASM_CONST(x) ASM_CONST(x)
122#define CPU_FTR_SLB ASM_CONST(0x0000000100000000)
123#define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000)
124#define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000)
125#define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000)
126#define CPU_FTR_IABR ASM_CONST(0x0000002000000000)
127#define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000)
128#define CPU_FTR_CTRL ASM_CONST(0x0000008000000000)
129#define CPU_FTR_SMT ASM_CONST(0x0000010000000000)
130#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000)
131#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0000040000000000)
132#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0000100000000000)
133#define CPU_FTR_PAUSE_ZERO ASM_CONST(0x0000200000000000)
134#define CPU_FTR_PURR ASM_CONST(0x0000400000000000)
135#else 126#else
136/* ensure on 32b processors the flags are available for compiling but 127#define LONG_ASM_CONST(x) 0
137 * don't do anything */
138#define CPU_FTR_SLB ASM_CONST(0x0)
139#define CPU_FTR_16M_PAGE ASM_CONST(0x0)
140#define CPU_FTR_TLBIEL ASM_CONST(0x0)
141#define CPU_FTR_NOEXECUTE ASM_CONST(0x0)
142#define CPU_FTR_IABR ASM_CONST(0x0)
143#define CPU_FTR_MMCRA ASM_CONST(0x0)
144#define CPU_FTR_CTRL ASM_CONST(0x0)
145#define CPU_FTR_SMT ASM_CONST(0x0)
146#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0)
147#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0)
148#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0)
149#define CPU_FTR_PURR ASM_CONST(0x0)
150#endif 128#endif
151 129
130#define CPU_FTR_SLB LONG_ASM_CONST(0x0000000100000000)
131#define CPU_FTR_16M_PAGE LONG_ASM_CONST(0x0000000200000000)
132#define CPU_FTR_TLBIEL LONG_ASM_CONST(0x0000000400000000)
133#define CPU_FTR_NOEXECUTE LONG_ASM_CONST(0x0000000800000000)
134#define CPU_FTR_IABR LONG_ASM_CONST(0x0000002000000000)
135#define CPU_FTR_MMCRA LONG_ASM_CONST(0x0000004000000000)
136#define CPU_FTR_CTRL LONG_ASM_CONST(0x0000008000000000)
137#define CPU_FTR_SMT LONG_ASM_CONST(0x0000010000000000)
138#define CPU_FTR_COHERENT_ICACHE LONG_ASM_CONST(0x0000020000000000)
139#define CPU_FTR_LOCKLESS_TLBIE LONG_ASM_CONST(0x0000040000000000)
140#define CPU_FTR_CI_LARGE_PAGE LONG_ASM_CONST(0x0000100000000000)
141#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000)
142#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000)
143
152#ifndef __ASSEMBLY__ 144#ifndef __ASSEMBLY__
153 145
154#define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \ 146#define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h
index ce0f7db63c16..d40359204aba 100644
--- a/include/asm-powerpc/hw_irq.h
+++ b/include/asm-powerpc/hw_irq.h
@@ -86,27 +86,27 @@ static inline void local_irq_save_ptr(unsigned long *flags)
86#define mask_irq(irq) \ 86#define mask_irq(irq) \
87 ({ \ 87 ({ \
88 irq_desc_t *desc = get_irq_desc(irq); \ 88 irq_desc_t *desc = get_irq_desc(irq); \
89 if (desc->handler && desc->handler->disable) \ 89 if (desc->chip && desc->chip->disable) \
90 desc->handler->disable(irq); \ 90 desc->chip->disable(irq); \
91 }) 91 })
92#define unmask_irq(irq) \ 92#define unmask_irq(irq) \
93 ({ \ 93 ({ \
94 irq_desc_t *desc = get_irq_desc(irq); \ 94 irq_desc_t *desc = get_irq_desc(irq); \
95 if (desc->handler && desc->handler->enable) \ 95 if (desc->chip && desc->chip->enable) \
96 desc->handler->enable(irq); \ 96 desc->chip->enable(irq); \
97 }) 97 })
98#define ack_irq(irq) \ 98#define ack_irq(irq) \
99 ({ \ 99 ({ \
100 irq_desc_t *desc = get_irq_desc(irq); \ 100 irq_desc_t *desc = get_irq_desc(irq); \
101 if (desc->handler && desc->handler->ack) \ 101 if (desc->chip && desc->chip->ack) \
102 desc->handler->ack(irq); \ 102 desc->chip->ack(irq); \
103 }) 103 })
104 104
105/* Should we handle this via lost interrupts and IPIs or should we don't care like 105/*
106 * we do now ? --BenH. 106 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
107 * or should we not care like we do now ? --BenH.
107 */ 108 */
108struct hw_interrupt_type; 109struct hw_interrupt_type;
109static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
110 110
111#endif /* __KERNEL__ */ 111#endif /* __KERNEL__ */
112#endif /* _ASM_POWERPC_HW_IRQ_H */ 112#endif /* _ASM_POWERPC_HW_IRQ_H */
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index a10feec29d4d..eb5f33e1977a 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -30,11 +30,6 @@
30#define IRQ_POLARITY_POSITIVE 0x2 /* high level or low->high edge */ 30#define IRQ_POLARITY_POSITIVE 0x2 /* high level or low->high edge */
31#define IRQ_POLARITY_NEGATIVE 0x0 /* low level or high->low edge */ 31#define IRQ_POLARITY_NEGATIVE 0x0 /* low level or high->low edge */
32 32
33/*
34 * IRQ line status macro IRQ_PER_CPU is used
35 */
36#define ARCH_HAS_IRQ_PER_CPU
37
38#define get_irq_desc(irq) (&irq_desc[(irq)]) 33#define get_irq_desc(irq) (&irq_desc[(irq)])
39 34
40/* Define a way to iterate across irqs. */ 35/* Define a way to iterate across irqs. */
diff --git a/include/asm-powerpc/iseries/it_lp_queue.h b/include/asm-powerpc/iseries/it_lp_queue.h
index b7c6fc12cce2..284c5a7db3ac 100644
--- a/include/asm-powerpc/iseries/it_lp_queue.h
+++ b/include/asm-powerpc/iseries/it_lp_queue.h
@@ -29,20 +29,20 @@
29 29
30struct HvLpEvent; 30struct HvLpEvent;
31 31
32#define ITMaxLpQueues 8 32#define IT_LP_MAX_QUEUES 8
33 33
34#define NotUsed 0 // Queue will not be used by PLIC 34#define IT_LP_NOT_USED 0 /* Queue will not be used by PLIC */
35#define DedicatedIo 1 // Queue dedicated to IO processor specified 35#define IT_LP_DEDICATED_IO 1 /* Queue dedicated to IO processor specified */
36#define DedicatedLp 2 // Queue dedicated to LP specified 36#define IT_LP_DEDICATED_LP 2 /* Queue dedicated to LP specified */
37#define Shared 3 // Queue shared for both IO and LP 37#define IT_LP_SHARED 3 /* Queue shared for both IO and LP */
38 38
39#define LpEventStackSize 4096 39#define IT_LP_EVENT_STACK_SIZE 4096
40#define LpEventMaxSize 256 40#define IT_LP_EVENT_MAX_SIZE 256
41#define LpEventAlign 64 41#define IT_LP_EVENT_ALIGN 64
42 42
43struct hvlpevent_queue { 43struct hvlpevent_queue {
44/* 44/*
45 * The xSlicCurEventPtr is the pointer to the next event stack entry 45 * The hq_current_event is the pointer to the next event stack entry
46 * that will become valid. The OS must peek at this entry to determine 46 * that will become valid. The OS must peek at this entry to determine
47 * if it is valid. PLIC will set the valid indicator as the very last 47 * if it is valid. PLIC will set the valid indicator as the very last
48 * store into that entry. 48 * store into that entry.
@@ -52,23 +52,23 @@ struct hvlpevent_queue {
52 * location again. 52 * location again.
53 * 53 *
54 * If the event stack fills and there are overflow events, then PLIC 54 * If the event stack fills and there are overflow events, then PLIC
55 * will set the xPlicOverflowIntPending flag in which case the OS will 55 * will set the hq_overflow_pending flag in which case the OS will
56 * have to fetch the additional LP events once they have drained the 56 * have to fetch the additional LP events once they have drained the
57 * event stack. 57 * event stack.
58 * 58 *
59 * The first 16-bytes are known by both the OS and PLIC. The remainder 59 * The first 16-bytes are known by both the OS and PLIC. The remainder
60 * of the cache line is for use by the OS. 60 * of the cache line is for use by the OS.
61 */ 61 */
62 u8 xPlicOverflowIntPending;// 0x00 Overflow events are pending 62 u8 hq_overflow_pending; /* 0x00 Overflow events are pending */
63 u8 xPlicStatus; // 0x01 DedicatedIo or DedicatedLp or NotUsed 63 u8 hq_status; /* 0x01 DedicatedIo or DedicatedLp or NotUsed */
64 u16 xSlicLogicalProcIndex; // 0x02 Logical Proc Index for correlation 64 u16 hq_proc_index; /* 0x02 Logical Proc Index for correlation */
65 u8 xPlicRsvd[12]; // 0x04 65 u8 hq_reserved1[12]; /* 0x04 */
66 char *xSlicCurEventPtr; // 0x10 66 char *hq_current_event; /* 0x10 */
67 char *xSlicLastValidEventPtr; // 0x18 67 char *hq_last_event; /* 0x18 */
68 char *xSlicEventStackPtr; // 0x20 68 char *hq_event_stack; /* 0x20 */
69 u8 xIndex; // 0x28 unique sequential index. 69 u8 hq_index; /* 0x28 unique sequential index. */
70 u8 xSlicRsvd[3]; // 0x29-2b 70 u8 hq_reserved2[3]; /* 0x29-2b */
71 spinlock_t lock; 71 spinlock_t hq_lock;
72}; 72};
73 73
74extern struct hvlpevent_queue hvlpevent_queue; 74extern struct hvlpevent_queue hvlpevent_queue;
diff --git a/include/asm-powerpc/kdump.h b/include/asm-powerpc/kdump.h
index 5a5c3b5ab1e0..dc1574c945f8 100644
--- a/include/asm-powerpc/kdump.h
+++ b/include/asm-powerpc/kdump.h
@@ -15,6 +15,8 @@
15#define KDUMP_TRAMPOLINE_START 0x0100 15#define KDUMP_TRAMPOLINE_START 0x0100
16#define KDUMP_TRAMPOLINE_END 0x3000 16#define KDUMP_TRAMPOLINE_END 0x3000
17 17
18#define KDUMP_MIN_TCE_ENTRIES 2048
19
18#else /* !CONFIG_CRASH_DUMP */ 20#else /* !CONFIG_CRASH_DUMP */
19 21
20#define PHYSICAL_START 0x0 22#define PHYSICAL_START 0x0
diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h
index efe8872ec583..8f7fd5cfec34 100644
--- a/include/asm-powerpc/kexec.h
+++ b/include/asm-powerpc/kexec.h
@@ -112,9 +112,13 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
112#ifdef __powerpc64__ 112#ifdef __powerpc64__
113extern void kexec_smp_wait(void); /* get and clear naca physid, wait for 113extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
114 master to copy new code to 0 */ 114 master to copy new code to 0 */
115extern void __init kexec_setup(void);
116extern int crashing_cpu; 115extern int crashing_cpu;
117extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)); 116extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
117extern cpumask_t cpus_in_sr;
118static inline int kexec_sr_activated(int cpu)
119{
120 return cpu_isset(cpu,cpus_in_sr);
121}
118#endif /* __powerpc64 __ */ 122#endif /* __powerpc64 __ */
119 123
120struct kimage; 124struct kimage;
@@ -124,10 +128,13 @@ extern int default_machine_kexec_prepare(struct kimage *image);
124extern void default_machine_crash_shutdown(struct pt_regs *regs); 128extern void default_machine_crash_shutdown(struct pt_regs *regs);
125 129
126extern void machine_kexec_simple(struct kimage *image); 130extern void machine_kexec_simple(struct kimage *image);
131extern void crash_kexec_secondary(struct pt_regs *regs);
127extern int overlaps_crashkernel(unsigned long start, unsigned long size); 132extern int overlaps_crashkernel(unsigned long start, unsigned long size);
128extern void reserve_crashkernel(void); 133extern void reserve_crashkernel(void);
129 134
130#else /* !CONFIG_KEXEC */ 135#else /* !CONFIG_KEXEC */
136static inline int kexec_sr_activated(int cpu) { return 0; }
137static inline void crash_kexec_secondary(struct pt_regs *regs) { }
131 138
132static inline int overlaps_crashkernel(unsigned long start, unsigned long size) 139static inline int overlaps_crashkernel(unsigned long start, unsigned long size)
133{ 140{
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index 73db1f71329d..eba133d149a7 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -81,6 +81,8 @@ struct machdep_calls {
81 void (*tce_free)(struct iommu_table *tbl, 81 void (*tce_free)(struct iommu_table *tbl,
82 long index, 82 long index,
83 long npages); 83 long npages);
84 unsigned long (*tce_get)(struct iommu_table *tbl,
85 long index);
84 void (*tce_flush)(struct iommu_table *tbl); 86 void (*tce_flush)(struct iommu_table *tbl);
85 void (*iommu_dev_setup)(struct pci_dev *dev); 87 void (*iommu_dev_setup)(struct pci_dev *dev);
86 void (*iommu_bus_setup)(struct pci_bus *bus); 88 void (*iommu_bus_setup)(struct pci_bus *bus);
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h
index 3a5ebe229af5..c3fc7a28e3cd 100644
--- a/include/asm-powerpc/mmu.h
+++ b/include/asm-powerpc/mmu.h
@@ -238,7 +238,6 @@ extern int hash_huge_page(struct mm_struct *mm, unsigned long access,
238 unsigned long ea, unsigned long vsid, int local, 238 unsigned long ea, unsigned long vsid, int local,
239 unsigned long trap); 239 unsigned long trap);
240 240
241extern void htab_finish_init(void);
242extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend, 241extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
243 unsigned long pstart, unsigned long mode, 242 unsigned long pstart, unsigned long mode,
244 int psize); 243 int psize);
diff --git a/include/asm-powerpc/mmu_context.h b/include/asm-powerpc/mmu_context.h
index 8c6b1a6d944f..083ac917bd29 100644
--- a/include/asm-powerpc/mmu_context.h
+++ b/include/asm-powerpc/mmu_context.h
@@ -25,8 +25,13 @@ static inline void enter_lazy_tlb(struct mm_struct *mm,
25{ 25{
26} 26}
27 27
28/*
29 * The proto-VSID space has 2^35 - 1 segments available for user mappings.
30 * Each segment contains 2^28 bytes. Each context maps 2^44 bytes,
31 * so we can support 2^19-1 contexts (19 == 35 + 28 - 44).
32 */
28#define NO_CONTEXT 0 33#define NO_CONTEXT 0
29#define MAX_CONTEXT (0x100000-1) 34#define MAX_CONTEXT ((1UL << 19) - 1)
30 35
31extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm); 36extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
32extern void destroy_context(struct mm_struct *mm); 37extern void destroy_context(struct mm_struct *mm);
diff --git a/include/asm-powerpc/mpc86xx.h b/include/asm-powerpc/mpc86xx.h
index d0a6718d188b..f260382739fa 100644
--- a/include/asm-powerpc/mpc86xx.h
+++ b/include/asm-powerpc/mpc86xx.h
@@ -15,15 +15,10 @@
15#ifndef __ASM_POWERPC_MPC86xx_H__ 15#ifndef __ASM_POWERPC_MPC86xx_H__
16#define __ASM_POWERPC_MPC86xx_H__ 16#define __ASM_POWERPC_MPC86xx_H__
17 17
18#include <linux/config.h>
19#include <asm/mmu.h> 18#include <asm/mmu.h>
20 19
21#ifdef CONFIG_PPC_86xx 20#ifdef CONFIG_PPC_86xx
22 21
23#ifdef CONFIG_MPC8641_HPCN
24#include <platforms/86xx/mpc8641_hpcn.h>
25#endif
26
27#define _IO_BASE isa_io_base 22#define _IO_BASE isa_io_base
28#define _ISA_MEM_BASE isa_mem_base 23#define _ISA_MEM_BASE isa_mem_base
29#ifdef CONFIG_PCI 24#ifdef CONFIG_PCI
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h
index 5d2c9e6c4be2..46afd29b904e 100644
--- a/include/asm-powerpc/pci.h
+++ b/include/asm-powerpc/pci.h
@@ -242,7 +242,7 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,
242#define HAVE_ARCH_PCI_RESOURCE_TO_USER 242#define HAVE_ARCH_PCI_RESOURCE_TO_USER
243extern void pci_resource_to_user(const struct pci_dev *dev, int bar, 243extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
244 const struct resource *rsrc, 244 const struct resource *rsrc,
245 u64 *start, u64 *end); 245 resource_size_t *start, resource_size_t *end);
246#endif /* CONFIG_PPC_MULTIPLATFORM || CONFIG_PPC32 */ 246#endif /* CONFIG_PPC_MULTIPLATFORM || CONFIG_PPC32 */
247 247
248#endif /* __KERNEL__ */ 248#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h
index 02e213e3d69f..a33c6acffa61 100644
--- a/include/asm-powerpc/rtas.h
+++ b/include/asm-powerpc/rtas.h
@@ -181,6 +181,9 @@ extern int rtas_set_rtc_time(struct rtc_time *rtc_time);
181extern unsigned int rtas_busy_delay_time(int status); 181extern unsigned int rtas_busy_delay_time(int status);
182extern unsigned int rtas_busy_delay(int status); 182extern unsigned int rtas_busy_delay(int status);
183 183
184extern int early_init_dt_scan_rtas(unsigned long node,
185 const char *uname, int depth, void *data);
186
184extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal); 187extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
185 188
186/* Error types logged. */ 189/* Error types logged. */
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index 4463148c659f..dcde4410348d 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -18,8 +18,9 @@
18#include <linux/percpu.h> 18#include <linux/percpu.h>
19 19
20#include <asm/processor.h> 20#include <asm/processor.h>
21#ifdef CONFIG_PPC64 21#ifdef CONFIG_PPC_ISERIES
22#include <asm/paca.h> 22#include <asm/paca.h>
23#include <asm/firmware.h>
23#include <asm/iseries/hv_call.h> 24#include <asm/iseries/hv_call.h>
24#endif 25#endif
25 26
@@ -177,7 +178,8 @@ static inline void set_dec(int val)
177#ifdef CONFIG_PPC_ISERIES 178#ifdef CONFIG_PPC_ISERIES
178 int cur_dec; 179 int cur_dec;
179 180
180 if (get_lppaca()->shared_proc) { 181 if (firmware_has_feature(FW_FEATURE_ISERIES) &&
182 get_lppaca()->shared_proc) {
181 get_lppaca()->virtual_decr = val; 183 get_lppaca()->virtual_decr = val;
182 cur_dec = get_dec(); 184 cur_dec = get_dec();
183 if (cur_dec > val) 185 if (cur_dec > val)
diff --git a/include/asm-powerpc/todc.h b/include/asm-powerpc/todc.h
new file mode 100644
index 000000000000..60a8c39b8c11
--- /dev/null
+++ b/include/asm-powerpc/todc.h
@@ -0,0 +1,487 @@
1/*
2 * Definitions for the M48Txx and mc146818 series of Time of day/Real Time
3 * Clock chips.
4 *
5 * Author: Mark A. Greer <mgreer@mvista.com>
6 *
7 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12
13/*
14 * Support for the M48T37/M48T59/.../mc146818 Real Time Clock chips.
15 * Purpose is to make one generic file that handles all of these chips instead
16 * of every platform implementing the same code over & over again.
17 */
18
19#ifndef __PPC_KERNEL_TODC_H
20#define __PPC_KERNEL_TODC_H
21
22typedef struct {
23 uint rtc_type; /* your particular chip */
24
25 /*
26 * Following are the addresses of the AS0, AS1, and DATA registers
27 * of these chips. Note that these are board-specific.
28 */
29 unsigned int nvram_as0;
30 unsigned int nvram_as1;
31 unsigned int nvram_data;
32
33 /*
34 * Define bits to stop external set of regs from changing so
35 * the chip can be read/written reliably.
36 */
37 unsigned char enable_read;
38 unsigned char enable_write;
39
40 /*
41 * Following is the number of AS0 address bits. This is normally
42 * 8 but some bad hardware routes address lines incorrectly.
43 */
44 int as0_bits;
45
46 int nvram_size; /* Size of NVRAM on chip */
47 int sw_flags; /* Software control flags */
48
49 /* Following are the register offsets for the particular chip */
50 int year;
51 int month;
52 int day_of_month;
53 int day_of_week;
54 int hours;
55 int minutes;
56 int seconds;
57 int control_b;
58 int control_a;
59 int watchdog;
60 int interrupts;
61 int alarm_date;
62 int alarm_hour;
63 int alarm_minutes;
64 int alarm_seconds;
65 int century;
66 int flags;
67
68 /*
69 * Some RTC chips have their NVRAM buried behind a addr/data pair of
70 * regs on the first level/clock registers. The following fields
71 * are the addresses for those addr/data regs.
72 */
73 int nvram_addr_reg;
74 int nvram_data_reg;
75} todc_info_t;
76
77/*
78 * Define the types of TODC/RTC variants that are supported in
79 * arch/ppc/kernel/todc_time.c
80 * Make a new one of these for any chip somehow differs from what's already
81 * defined. That way, if you ever need to put in code to touch those
82 * bits/registers in todc_time.c, you can put it inside an
83 * 'if (todc_info->rtc_type == TODC_TYPE_XXX)' so you won't break
84 * anyone else.
85 */
86#define TODC_TYPE_MK48T35 1
87#define TODC_TYPE_MK48T37 2
88#define TODC_TYPE_MK48T59 3
89#define TODC_TYPE_DS1693 4 /* Dallas DS1693 RTC */
90#define TODC_TYPE_DS1743 5 /* Dallas DS1743 RTC */
91#define TODC_TYPE_DS1746 6 /* Dallas DS1746 RTC */
92#define TODC_TYPE_DS1747 7 /* Dallas DS1747 RTC */
93#define TODC_TYPE_DS1501 8 /* Dallas DS1501 RTC */
94#define TODC_TYPE_DS1643 9 /* Dallas DS1643 RTC */
95#define TODC_TYPE_PC97307 10 /* PC97307 internal RTC */
96#define TODC_TYPE_DS1557 11 /* Dallas DS1557 RTC */
97#define TODC_TYPE_DS17285 12 /* Dallas DS17285 RTC */
98#define TODC_TYPE_DS1553 13 /* Dallas DS1553 RTC */
99#define TODC_TYPE_MC146818 100 /* Leave room for m48txx's */
100
101/*
102 * Bit to clear/set to enable reads/writes to the chip
103 */
104#define TODC_MK48TXX_CNTL_A_R 0x40
105#define TODC_MK48TXX_CNTL_A_W 0x80
106#define TODC_MK48TXX_DAY_CB 0x80
107
108#define TODC_DS1501_CNTL_B_TE 0x80
109
110/*
111 * Define flag bits used by todc routines.
112 */
113#define TODC_FLAG_2_LEVEL_NVRAM 0x00000001
114
115/*
116 * Define the values for the various RTC's that should to into the todc_info
117 * table.
118 * Note: The XXX_NVRAM_SIZE, XXX_NVRAM_ADDR_REG, and XXX_NVRAM_DATA_REG only
119 * matter if XXX_SW_FLAGS has TODC_FLAG_2_LEVEL_NVRAM set.
120 */
121#define TODC_TYPE_MK48T35_NVRAM_SIZE 0x7ff8
122#define TODC_TYPE_MK48T35_SW_FLAGS 0
123#define TODC_TYPE_MK48T35_YEAR 0x7fff
124#define TODC_TYPE_MK48T35_MONTH 0x7ffe
125#define TODC_TYPE_MK48T35_DOM 0x7ffd /* Day of Month */
126#define TODC_TYPE_MK48T35_DOW 0x7ffc /* Day of Week */
127#define TODC_TYPE_MK48T35_HOURS 0x7ffb
128#define TODC_TYPE_MK48T35_MINUTES 0x7ffa
129#define TODC_TYPE_MK48T35_SECONDS 0x7ff9
130#define TODC_TYPE_MK48T35_CNTL_B 0x7ff9
131#define TODC_TYPE_MK48T35_CNTL_A 0x7ff8
132#define TODC_TYPE_MK48T35_WATCHDOG 0x0000
133#define TODC_TYPE_MK48T35_INTERRUPTS 0x0000
134#define TODC_TYPE_MK48T35_ALARM_DATE 0x0000
135#define TODC_TYPE_MK48T35_ALARM_HOUR 0x0000
136#define TODC_TYPE_MK48T35_ALARM_MINUTES 0x0000
137#define TODC_TYPE_MK48T35_ALARM_SECONDS 0x0000
138#define TODC_TYPE_MK48T35_CENTURY 0x0000
139#define TODC_TYPE_MK48T35_FLAGS 0x0000
140#define TODC_TYPE_MK48T35_NVRAM_ADDR_REG 0
141#define TODC_TYPE_MK48T35_NVRAM_DATA_REG 0
142
143#define TODC_TYPE_MK48T37_NVRAM_SIZE 0x7ff0
144#define TODC_TYPE_MK48T37_SW_FLAGS 0
145#define TODC_TYPE_MK48T37_YEAR 0x7fff
146#define TODC_TYPE_MK48T37_MONTH 0x7ffe
147#define TODC_TYPE_MK48T37_DOM 0x7ffd /* Day of Month */
148#define TODC_TYPE_MK48T37_DOW 0x7ffc /* Day of Week */
149#define TODC_TYPE_MK48T37_HOURS 0x7ffb
150#define TODC_TYPE_MK48T37_MINUTES 0x7ffa
151#define TODC_TYPE_MK48T37_SECONDS 0x7ff9
152#define TODC_TYPE_MK48T37_CNTL_B 0x7ff9
153#define TODC_TYPE_MK48T37_CNTL_A 0x7ff8
154#define TODC_TYPE_MK48T37_WATCHDOG 0x7ff7
155#define TODC_TYPE_MK48T37_INTERRUPTS 0x7ff6
156#define TODC_TYPE_MK48T37_ALARM_DATE 0x7ff5
157#define TODC_TYPE_MK48T37_ALARM_HOUR 0x7ff4
158#define TODC_TYPE_MK48T37_ALARM_MINUTES 0x7ff3
159#define TODC_TYPE_MK48T37_ALARM_SECONDS 0x7ff2
160#define TODC_TYPE_MK48T37_CENTURY 0x7ff1
161#define TODC_TYPE_MK48T37_FLAGS 0x7ff0
162#define TODC_TYPE_MK48T37_NVRAM_ADDR_REG 0
163#define TODC_TYPE_MK48T37_NVRAM_DATA_REG 0
164
165#define TODC_TYPE_MK48T59_NVRAM_SIZE 0x1ff0
166#define TODC_TYPE_MK48T59_SW_FLAGS 0
167#define TODC_TYPE_MK48T59_YEAR 0x1fff
168#define TODC_TYPE_MK48T59_MONTH 0x1ffe
169#define TODC_TYPE_MK48T59_DOM 0x1ffd /* Day of Month */
170#define TODC_TYPE_MK48T59_DOW 0x1ffc /* Day of Week */
171#define TODC_TYPE_MK48T59_HOURS 0x1ffb
172#define TODC_TYPE_MK48T59_MINUTES 0x1ffa
173#define TODC_TYPE_MK48T59_SECONDS 0x1ff9
174#define TODC_TYPE_MK48T59_CNTL_B 0x1ff9
175#define TODC_TYPE_MK48T59_CNTL_A 0x1ff8
176#define TODC_TYPE_MK48T59_WATCHDOG 0x1fff
177#define TODC_TYPE_MK48T59_INTERRUPTS 0x1fff
178#define TODC_TYPE_MK48T59_ALARM_DATE 0x1fff
179#define TODC_TYPE_MK48T59_ALARM_HOUR 0x1fff
180#define TODC_TYPE_MK48T59_ALARM_MINUTES 0x1fff
181#define TODC_TYPE_MK48T59_ALARM_SECONDS 0x1fff
182#define TODC_TYPE_MK48T59_CENTURY 0x1fff
183#define TODC_TYPE_MK48T59_FLAGS 0x1fff
184#define TODC_TYPE_MK48T59_NVRAM_ADDR_REG 0
185#define TODC_TYPE_MK48T59_NVRAM_DATA_REG 0
186
187#define TODC_TYPE_DS1501_NVRAM_SIZE 0x100
188#define TODC_TYPE_DS1501_SW_FLAGS TODC_FLAG_2_LEVEL_NVRAM
189#define TODC_TYPE_DS1501_YEAR (TODC_TYPE_DS1501_NVRAM_SIZE + 0x06)
190#define TODC_TYPE_DS1501_MONTH (TODC_TYPE_DS1501_NVRAM_SIZE + 0x05)
191#define TODC_TYPE_DS1501_DOM (TODC_TYPE_DS1501_NVRAM_SIZE + 0x04)
192#define TODC_TYPE_DS1501_DOW (TODC_TYPE_DS1501_NVRAM_SIZE + 0x03)
193#define TODC_TYPE_DS1501_HOURS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x02)
194#define TODC_TYPE_DS1501_MINUTES (TODC_TYPE_DS1501_NVRAM_SIZE + 0x01)
195#define TODC_TYPE_DS1501_SECONDS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x00)
196#define TODC_TYPE_DS1501_CNTL_B (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0f)
197#define TODC_TYPE_DS1501_CNTL_A (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0f)
198#define TODC_TYPE_DS1501_WATCHDOG (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
199#define TODC_TYPE_DS1501_INTERRUPTS (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
200#define TODC_TYPE_DS1501_ALARM_DATE (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0b)
201#define TODC_TYPE_DS1501_ALARM_HOUR (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0a)
202#define TODC_TYPE_DS1501_ALARM_MINUTES (TODC_TYPE_DS1501_NVRAM_SIZE + 0x09)
203#define TODC_TYPE_DS1501_ALARM_SECONDS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x08)
204#define TODC_TYPE_DS1501_CENTURY (TODC_TYPE_DS1501_NVRAM_SIZE + 0x07)
205#define TODC_TYPE_DS1501_FLAGS (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
206#define TODC_TYPE_DS1501_NVRAM_ADDR_REG 0x10
207#define TODC_TYPE_DS1501_NVRAM_DATA_REG 0x13
208
209#define TODC_TYPE_DS1553_NVRAM_SIZE 0x1ff0
210#define TODC_TYPE_DS1553_SW_FLAGS 0
211#define TODC_TYPE_DS1553_YEAR 0x1fff
212#define TODC_TYPE_DS1553_MONTH 0x1ffe
213#define TODC_TYPE_DS1553_DOM 0x1ffd /* Day of Month */
214#define TODC_TYPE_DS1553_DOW 0x1ffc /* Day of Week */
215#define TODC_TYPE_DS1553_HOURS 0x1ffb
216#define TODC_TYPE_DS1553_MINUTES 0x1ffa
217#define TODC_TYPE_DS1553_SECONDS 0x1ff9
218#define TODC_TYPE_DS1553_CNTL_B 0x1ff9
219#define TODC_TYPE_DS1553_CNTL_A 0x1ff8 /* control_a R/W regs */
220#define TODC_TYPE_DS1553_WATCHDOG 0x1ff7
221#define TODC_TYPE_DS1553_INTERRUPTS 0x1ff6
222#define TODC_TYPE_DS1553_ALARM_DATE 0x1ff5
223#define TODC_TYPE_DS1553_ALARM_HOUR 0x1ff4
224#define TODC_TYPE_DS1553_ALARM_MINUTES 0x1ff3
225#define TODC_TYPE_DS1553_ALARM_SECONDS 0x1ff2
226#define TODC_TYPE_DS1553_CENTURY 0x1ff8
227#define TODC_TYPE_DS1553_FLAGS 0x1ff0
228#define TODC_TYPE_DS1553_NVRAM_ADDR_REG 0
229#define TODC_TYPE_DS1553_NVRAM_DATA_REG 0
230
231#define TODC_TYPE_DS1557_NVRAM_SIZE 0x7fff0
232#define TODC_TYPE_DS1557_SW_FLAGS 0
233#define TODC_TYPE_DS1557_YEAR 0x7ffff
234#define TODC_TYPE_DS1557_MONTH 0x7fffe
235#define TODC_TYPE_DS1557_DOM 0x7fffd /* Day of Month */
236#define TODC_TYPE_DS1557_DOW 0x7fffc /* Day of Week */
237#define TODC_TYPE_DS1557_HOURS 0x7fffb
238#define TODC_TYPE_DS1557_MINUTES 0x7fffa
239#define TODC_TYPE_DS1557_SECONDS 0x7fff9
240#define TODC_TYPE_DS1557_CNTL_B 0x7fff9
241#define TODC_TYPE_DS1557_CNTL_A 0x7fff8 /* control_a R/W regs */
242#define TODC_TYPE_DS1557_WATCHDOG 0x7fff7
243#define TODC_TYPE_DS1557_INTERRUPTS 0x7fff6
244#define TODC_TYPE_DS1557_ALARM_DATE 0x7fff5
245#define TODC_TYPE_DS1557_ALARM_HOUR 0x7fff4
246#define TODC_TYPE_DS1557_ALARM_MINUTES 0x7fff3
247#define TODC_TYPE_DS1557_ALARM_SECONDS 0x7fff2
248#define TODC_TYPE_DS1557_CENTURY 0x7fff8
249#define TODC_TYPE_DS1557_FLAGS 0x7fff0
250#define TODC_TYPE_DS1557_NVRAM_ADDR_REG 0
251#define TODC_TYPE_DS1557_NVRAM_DATA_REG 0
252
253#define TODC_TYPE_DS1643_NVRAM_SIZE 0x1ff8
254#define TODC_TYPE_DS1643_SW_FLAGS 0
255#define TODC_TYPE_DS1643_YEAR 0x1fff
256#define TODC_TYPE_DS1643_MONTH 0x1ffe
257#define TODC_TYPE_DS1643_DOM 0x1ffd /* Day of Month */
258#define TODC_TYPE_DS1643_DOW 0x1ffc /* Day of Week */
259#define TODC_TYPE_DS1643_HOURS 0x1ffb
260#define TODC_TYPE_DS1643_MINUTES 0x1ffa
261#define TODC_TYPE_DS1643_SECONDS 0x1ff9
262#define TODC_TYPE_DS1643_CNTL_B 0x1ff9
263#define TODC_TYPE_DS1643_CNTL_A 0x1ff8 /* control_a R/W regs */
264#define TODC_TYPE_DS1643_WATCHDOG 0x1fff
265#define TODC_TYPE_DS1643_INTERRUPTS 0x1fff
266#define TODC_TYPE_DS1643_ALARM_DATE 0x1fff
267#define TODC_TYPE_DS1643_ALARM_HOUR 0x1fff
268#define TODC_TYPE_DS1643_ALARM_MINUTES 0x1fff
269#define TODC_TYPE_DS1643_ALARM_SECONDS 0x1fff
270#define TODC_TYPE_DS1643_CENTURY 0x1ff8
271#define TODC_TYPE_DS1643_FLAGS 0x1fff
272#define TODC_TYPE_DS1643_NVRAM_ADDR_REG 0
273#define TODC_TYPE_DS1643_NVRAM_DATA_REG 0
274
275#define TODC_TYPE_DS1693_NVRAM_SIZE 0 /* Not handled yet */
276#define TODC_TYPE_DS1693_SW_FLAGS 0
277#define TODC_TYPE_DS1693_YEAR 0x09
278#define TODC_TYPE_DS1693_MONTH 0x08
279#define TODC_TYPE_DS1693_DOM 0x07 /* Day of Month */
280#define TODC_TYPE_DS1693_DOW 0x06 /* Day of Week */
281#define TODC_TYPE_DS1693_HOURS 0x04
282#define TODC_TYPE_DS1693_MINUTES 0x02
283#define TODC_TYPE_DS1693_SECONDS 0x00
284#define TODC_TYPE_DS1693_CNTL_B 0x0b
285#define TODC_TYPE_DS1693_CNTL_A 0x0a
286#define TODC_TYPE_DS1693_WATCHDOG 0xff
287#define TODC_TYPE_DS1693_INTERRUPTS 0xff
288#define TODC_TYPE_DS1693_ALARM_DATE 0x49
289#define TODC_TYPE_DS1693_ALARM_HOUR 0x05
290#define TODC_TYPE_DS1693_ALARM_MINUTES 0x03
291#define TODC_TYPE_DS1693_ALARM_SECONDS 0x01
292#define TODC_TYPE_DS1693_CENTURY 0x48
293#define TODC_TYPE_DS1693_FLAGS 0xff
294#define TODC_TYPE_DS1693_NVRAM_ADDR_REG 0
295#define TODC_TYPE_DS1693_NVRAM_DATA_REG 0
296
297#define TODC_TYPE_DS1743_NVRAM_SIZE 0x1ff8
298#define TODC_TYPE_DS1743_SW_FLAGS 0
299#define TODC_TYPE_DS1743_YEAR 0x1fff
300#define TODC_TYPE_DS1743_MONTH 0x1ffe
301#define TODC_TYPE_DS1743_DOM 0x1ffd /* Day of Month */
302#define TODC_TYPE_DS1743_DOW 0x1ffc /* Day of Week */
303#define TODC_TYPE_DS1743_HOURS 0x1ffb
304#define TODC_TYPE_DS1743_MINUTES 0x1ffa
305#define TODC_TYPE_DS1743_SECONDS 0x1ff9
306#define TODC_TYPE_DS1743_CNTL_B 0x1ff9
307#define TODC_TYPE_DS1743_CNTL_A 0x1ff8 /* control_a R/W regs */
308#define TODC_TYPE_DS1743_WATCHDOG 0x1fff
309#define TODC_TYPE_DS1743_INTERRUPTS 0x1fff
310#define TODC_TYPE_DS1743_ALARM_DATE 0x1fff
311#define TODC_TYPE_DS1743_ALARM_HOUR 0x1fff
312#define TODC_TYPE_DS1743_ALARM_MINUTES 0x1fff
313#define TODC_TYPE_DS1743_ALARM_SECONDS 0x1fff
314#define TODC_TYPE_DS1743_CENTURY 0x1ff8
315#define TODC_TYPE_DS1743_FLAGS 0x1fff
316#define TODC_TYPE_DS1743_NVRAM_ADDR_REG 0
317#define TODC_TYPE_DS1743_NVRAM_DATA_REG 0
318
319#define TODC_TYPE_DS1746_NVRAM_SIZE 0x1fff8
320#define TODC_TYPE_DS1746_SW_FLAGS 0
321#define TODC_TYPE_DS1746_YEAR 0x1ffff
322#define TODC_TYPE_DS1746_MONTH 0x1fffe
323#define TODC_TYPE_DS1746_DOM 0x1fffd /* Day of Month */
324#define TODC_TYPE_DS1746_DOW 0x1fffc /* Day of Week */
325#define TODC_TYPE_DS1746_HOURS 0x1fffb
326#define TODC_TYPE_DS1746_MINUTES 0x1fffa
327#define TODC_TYPE_DS1746_SECONDS 0x1fff9
328#define TODC_TYPE_DS1746_CNTL_B 0x1fff9
329#define TODC_TYPE_DS1746_CNTL_A 0x1fff8 /* control_a R/W regs */
330#define TODC_TYPE_DS1746_WATCHDOG 0x00000
331#define TODC_TYPE_DS1746_INTERRUPTS 0x00000
332#define TODC_TYPE_DS1746_ALARM_DATE 0x00000
333#define TODC_TYPE_DS1746_ALARM_HOUR 0x00000
334#define TODC_TYPE_DS1746_ALARM_MINUTES 0x00000
335#define TODC_TYPE_DS1746_ALARM_SECONDS 0x00000
336#define TODC_TYPE_DS1746_CENTURY 0x00000
337#define TODC_TYPE_DS1746_FLAGS 0x00000
338#define TODC_TYPE_DS1746_NVRAM_ADDR_REG 0
339#define TODC_TYPE_DS1746_NVRAM_DATA_REG 0
340
341#define TODC_TYPE_DS1747_NVRAM_SIZE 0x7fff8
342#define TODC_TYPE_DS1747_SW_FLAGS 0
343#define TODC_TYPE_DS1747_YEAR 0x7ffff
344#define TODC_TYPE_DS1747_MONTH 0x7fffe
345#define TODC_TYPE_DS1747_DOM 0x7fffd /* Day of Month */
346#define TODC_TYPE_DS1747_DOW 0x7fffc /* Day of Week */
347#define TODC_TYPE_DS1747_HOURS 0x7fffb
348#define TODC_TYPE_DS1747_MINUTES 0x7fffa
349#define TODC_TYPE_DS1747_SECONDS 0x7fff9
350#define TODC_TYPE_DS1747_CNTL_B 0x7fff9
351#define TODC_TYPE_DS1747_CNTL_A 0x7fff8 /* control_a R/W regs */
352#define TODC_TYPE_DS1747_WATCHDOG 0x00000
353#define TODC_TYPE_DS1747_INTERRUPTS 0x00000
354#define TODC_TYPE_DS1747_ALARM_DATE 0x00000
355#define TODC_TYPE_DS1747_ALARM_HOUR 0x00000
356#define TODC_TYPE_DS1747_ALARM_MINUTES 0x00000
357#define TODC_TYPE_DS1747_ALARM_SECONDS 0x00000
358#define TODC_TYPE_DS1747_CENTURY 0x00000
359#define TODC_TYPE_DS1747_FLAGS 0x00000
360#define TODC_TYPE_DS1747_NVRAM_ADDR_REG 0
361#define TODC_TYPE_DS1747_NVRAM_DATA_REG 0
362
363#define TODC_TYPE_DS17285_NVRAM_SIZE (0x1000-0x80) /* 4Kx8 NVRAM (minus RTC regs) */
364#define TODC_TYPE_DS17285_SW_FLAGS TODC_FLAG_2_LEVEL_NVRAM
365#define TODC_TYPE_DS17285_SECONDS (TODC_TYPE_DS17285_NVRAM_SIZE + 0x00)
366#define TODC_TYPE_DS17285_ALARM_SECONDS (TODC_TYPE_DS17285_NVRAM_SIZE + 0x01)
367#define TODC_TYPE_DS17285_MINUTES (TODC_TYPE_DS17285_NVRAM_SIZE + 0x02)
368#define TODC_TYPE_DS17285_ALARM_MINUTES (TODC_TYPE_DS17285_NVRAM_SIZE + 0x03)
369#define TODC_TYPE_DS17285_HOURS (TODC_TYPE_DS17285_NVRAM_SIZE + 0x04)
370#define TODC_TYPE_DS17285_ALARM_HOUR (TODC_TYPE_DS17285_NVRAM_SIZE + 0x05)
371#define TODC_TYPE_DS17285_DOW (TODC_TYPE_DS17285_NVRAM_SIZE + 0x06)
372#define TODC_TYPE_DS17285_DOM (TODC_TYPE_DS17285_NVRAM_SIZE + 0x07)
373#define TODC_TYPE_DS17285_MONTH (TODC_TYPE_DS17285_NVRAM_SIZE + 0x08)
374#define TODC_TYPE_DS17285_YEAR (TODC_TYPE_DS17285_NVRAM_SIZE + 0x09)
375#define TODC_TYPE_DS17285_CNTL_A (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0A)
376#define TODC_TYPE_DS17285_CNTL_B (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0B)
377#define TODC_TYPE_DS17285_CNTL_C (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0C)
378#define TODC_TYPE_DS17285_CNTL_D (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0D)
379#define TODC_TYPE_DS17285_WATCHDOG 0
380#define TODC_TYPE_DS17285_INTERRUPTS 0
381#define TODC_TYPE_DS17285_ALARM_DATE 0
382#define TODC_TYPE_DS17285_CENTURY 0
383#define TODC_TYPE_DS17285_FLAGS 0
384#define TODC_TYPE_DS17285_NVRAM_ADDR_REG 0x50
385#define TODC_TYPE_DS17285_NVRAM_DATA_REG 0x53
386
387#define TODC_TYPE_MC146818_NVRAM_SIZE 0 /* XXXX */
388#define TODC_TYPE_MC146818_SW_FLAGS 0
389#define TODC_TYPE_MC146818_YEAR 0x09
390#define TODC_TYPE_MC146818_MONTH 0x08
391#define TODC_TYPE_MC146818_DOM 0x07 /* Day of Month */
392#define TODC_TYPE_MC146818_DOW 0x06 /* Day of Week */
393#define TODC_TYPE_MC146818_HOURS 0x04
394#define TODC_TYPE_MC146818_MINUTES 0x02
395#define TODC_TYPE_MC146818_SECONDS 0x00
396#define TODC_TYPE_MC146818_CNTL_B 0x0a
397#define TODC_TYPE_MC146818_CNTL_A 0x0b /* control_a R/W regs */
398#define TODC_TYPE_MC146818_WATCHDOG 0
399#define TODC_TYPE_MC146818_INTERRUPTS 0x0c
400#define TODC_TYPE_MC146818_ALARM_DATE 0xff
401#define TODC_TYPE_MC146818_ALARM_HOUR 0x05
402#define TODC_TYPE_MC146818_ALARM_MINUTES 0x03
403#define TODC_TYPE_MC146818_ALARM_SECONDS 0x01
404#define TODC_TYPE_MC146818_CENTURY 0xff
405#define TODC_TYPE_MC146818_FLAGS 0xff
406#define TODC_TYPE_MC146818_NVRAM_ADDR_REG 0
407#define TODC_TYPE_MC146818_NVRAM_DATA_REG 0
408
409#define TODC_TYPE_PC97307_NVRAM_SIZE 0 /* No NVRAM? */
410#define TODC_TYPE_PC97307_SW_FLAGS 0
411#define TODC_TYPE_PC97307_YEAR 0x09
412#define TODC_TYPE_PC97307_MONTH 0x08
413#define TODC_TYPE_PC97307_DOM 0x07 /* Day of Month */
414#define TODC_TYPE_PC97307_DOW 0x06 /* Day of Week */
415#define TODC_TYPE_PC97307_HOURS 0x04
416#define TODC_TYPE_PC97307_MINUTES 0x02
417#define TODC_TYPE_PC97307_SECONDS 0x00
418#define TODC_TYPE_PC97307_CNTL_B 0x0a
419#define TODC_TYPE_PC97307_CNTL_A 0x0b /* control_a R/W regs */
420#define TODC_TYPE_PC97307_WATCHDOG 0x0c
421#define TODC_TYPE_PC97307_INTERRUPTS 0x0d
422#define TODC_TYPE_PC97307_ALARM_DATE 0xff
423#define TODC_TYPE_PC97307_ALARM_HOUR 0x05
424#define TODC_TYPE_PC97307_ALARM_MINUTES 0x03
425#define TODC_TYPE_PC97307_ALARM_SECONDS 0x01
426#define TODC_TYPE_PC97307_CENTURY 0xff
427#define TODC_TYPE_PC97307_FLAGS 0xff
428#define TODC_TYPE_PC97307_NVRAM_ADDR_REG 0
429#define TODC_TYPE_PC97307_NVRAM_DATA_REG 0
430
431/*
432 * Define macros to allocate and init the todc_info_t table that will
433 * be used by the todc_time.c routines.
434 */
435#define TODC_ALLOC() \
436 static todc_info_t todc_info_alloc; \
437 todc_info_t *todc_info = &todc_info_alloc;
438
439#define TODC_INIT(clock_type, as0, as1, data, bits) { \
440 todc_info->rtc_type = clock_type; \
441 \
442 todc_info->nvram_as0 = (unsigned int)(as0); \
443 todc_info->nvram_as1 = (unsigned int)(as1); \
444 todc_info->nvram_data = (unsigned int)(data); \
445 \
446 todc_info->as0_bits = (bits); \
447 \
448 todc_info->nvram_size = clock_type ##_NVRAM_SIZE; \
449 todc_info->sw_flags = clock_type ##_SW_FLAGS; \
450 \
451 todc_info->year = clock_type ##_YEAR; \
452 todc_info->month = clock_type ##_MONTH; \
453 todc_info->day_of_month = clock_type ##_DOM; \
454 todc_info->day_of_week = clock_type ##_DOW; \
455 todc_info->hours = clock_type ##_HOURS; \
456 todc_info->minutes = clock_type ##_MINUTES; \
457 todc_info->seconds = clock_type ##_SECONDS; \
458 todc_info->control_b = clock_type ##_CNTL_B; \
459 todc_info->control_a = clock_type ##_CNTL_A; \
460 todc_info->watchdog = clock_type ##_WATCHDOG; \
461 todc_info->interrupts = clock_type ##_INTERRUPTS; \
462 todc_info->alarm_date = clock_type ##_ALARM_DATE; \
463 todc_info->alarm_hour = clock_type ##_ALARM_HOUR; \
464 todc_info->alarm_minutes = clock_type ##_ALARM_MINUTES; \
465 todc_info->alarm_seconds = clock_type ##_ALARM_SECONDS; \
466 todc_info->century = clock_type ##_CENTURY; \
467 todc_info->flags = clock_type ##_FLAGS; \
468 \
469 todc_info->nvram_addr_reg = clock_type ##_NVRAM_ADDR_REG; \
470 todc_info->nvram_data_reg = clock_type ##_NVRAM_DATA_REG; \
471}
472
473extern todc_info_t *todc_info;
474
475unsigned char todc_direct_read_val(int addr);
476void todc_direct_write_val(int addr, unsigned char val);
477unsigned char todc_m48txx_read_val(int addr);
478void todc_m48txx_write_val(int addr, unsigned char val);
479unsigned char todc_mc146818_read_val(int addr);
480void todc_mc146818_write_val(int addr, unsigned char val);
481
482long todc_time_init(void);
483void todc_get_rtc_time(struct rtc_time *);
484int todc_set_rtc_time(struct rtc_time *);
485void todc_calibrate_decr(void);
486
487#endif /* __PPC_KERNEL_TODC_H */
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index 92f3e5507d22..bbc3844b086f 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -93,5 +93,10 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
93 93
94#endif /* CONFIG_NUMA */ 94#endif /* CONFIG_NUMA */
95 95
96#ifdef CONFIG_SMP
97#include <asm/cputable.h>
98#define smt_capable() (cpu_has_feature(CPU_FTR_SMT))
99#endif
100
96#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
97#endif /* _ASM_POWERPC_TOPOLOGY_H */ 102#endif /* _ASM_POWERPC_TOPOLOGY_H */
diff --git a/include/asm-powerpc/tsi108.h b/include/asm-powerpc/tsi108.h
new file mode 100644
index 000000000000..c4c278d72f71
--- /dev/null
+++ b/include/asm-powerpc/tsi108.h
@@ -0,0 +1,109 @@
1/*
2 * include/asm-ppc/tsi108.h
3 *
4 * common routine and memory layout for Tundra TSI108(Grendel) host bridge
5 * memory controller.
6 *
7 * Author: Jacob Pan (jacob.pan@freescale.com)
8 * Alex Bounine (alexandreb@tundra.com)
9 * 2004 (c) Freescale Semiconductor Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
13 */
14#ifndef __PPC_KERNEL_TSI108_H
15#define __PPC_KERNEL_TSI108_H
16
17#include <asm/pci-bridge.h>
18
19/* Size of entire register space */
20#define TSI108_REG_SIZE (0x10000)
21
22/* Sizes of register spaces for individual blocks */
23#define TSI108_HLP_SIZE 0x1000
24#define TSI108_PCI_SIZE 0x1000
25#define TSI108_CLK_SIZE 0x1000
26#define TSI108_PB_SIZE 0x1000
27#define TSI108_SD_SIZE 0x1000
28#define TSI108_DMA_SIZE 0x1000
29#define TSI108_ETH_SIZE 0x1000
30#define TSI108_I2C_SIZE 0x400
31#define TSI108_MPIC_SIZE 0x400
32#define TSI108_UART0_SIZE 0x200
33#define TSI108_GPIO_SIZE 0x200
34#define TSI108_UART1_SIZE 0x200
35
36/* Offsets within Tsi108(A) CSR space for individual blocks */
37#define TSI108_HLP_OFFSET 0x0000
38#define TSI108_PCI_OFFSET 0x1000
39#define TSI108_CLK_OFFSET 0x2000
40#define TSI108_PB_OFFSET 0x3000
41#define TSI108_SD_OFFSET 0x4000
42#define TSI108_DMA_OFFSET 0x5000
43#define TSI108_ETH_OFFSET 0x6000
44#define TSI108_I2C_OFFSET 0x7000
45#define TSI108_MPIC_OFFSET 0x7400
46#define TSI108_UART0_OFFSET 0x7800
47#define TSI108_GPIO_OFFSET 0x7A00
48#define TSI108_UART1_OFFSET 0x7C00
49
50/* Tsi108 registers used by common code components */
51#define TSI108_PCI_CSR (0x004)
52#define TSI108_PCI_IRP_CFG_CTL (0x180)
53#define TSI108_PCI_IRP_STAT (0x184)
54#define TSI108_PCI_IRP_ENABLE (0x188)
55#define TSI108_PCI_IRP_INTAD (0x18C)
56
57#define TSI108_PCI_IRP_STAT_P_INT (0x00400000)
58#define TSI108_PCI_IRP_ENABLE_P_INT (0x00400000)
59
60#define TSI108_CG_PWRUP_STATUS (0x234)
61
62#define TSI108_PB_ISR (0x00C)
63#define TSI108_PB_ERRCS (0x404)
64#define TSI108_PB_AERR (0x408)
65
66#define TSI108_PB_ERRCS_ES (1 << 1)
67#define TSI108_PB_ISR_PBS_RD_ERR (1 << 8)
68
69#define TSI108_PCI_CFG_BASE_PHYS (0xfb000000)
70#define TSI108_PCI_CFG_SIZE (0x01000000)
71/* Global variables */
72
73extern u32 tsi108_pci_cfg_base;
74/* Exported functions */
75
76extern int tsi108_bridge_init(struct pci_controller *hose, uint phys_csr_base);
77extern unsigned long tsi108_get_mem_size(void);
78extern unsigned long tsi108_get_cpu_clk(void);
79extern unsigned long tsi108_get_sdc_clk(void);
80extern int tsi108_direct_write_config(struct pci_bus *bus, unsigned int devfn,
81 int offset, int len, u32 val);
82extern int tsi108_direct_read_config(struct pci_bus *bus, unsigned int devfn,
83 int offset, int len, u32 * val);
84extern void tsi108_clear_pci_error(u32 pci_cfg_base);
85
86extern phys_addr_t get_csrbase(void);
87
88typedef struct {
89 u32 regs; /* hw registers base address */
90 u32 phyregs; /* phy registers base address */
91 u16 phy; /* phy address */
92 u16 irq_num; /* irq number */
93 u8 mac_addr[6]; /* phy mac address */
94} hw_info;
95
96extern u32 get_vir_csrbase(void);
97extern u32 tsi108_csr_vir_base;
98
99extern inline u32 tsi108_read_reg(u32 reg_offset)
100{
101 return in_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset));
102}
103
104extern inline void tsi108_write_reg(u32 reg_offset, u32 val)
105{
106 out_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset), val);
107}
108
109#endif /* __PPC_KERNEL_TSI108_H */
diff --git a/include/asm-powerpc/udbg.h b/include/asm-powerpc/udbg.h
index 19a1517ac43b..55e57844fa78 100644
--- a/include/asm-powerpc/udbg.h
+++ b/include/asm-powerpc/udbg.h
@@ -42,7 +42,8 @@ extern void __init udbg_init_debug_lpar(void);
42extern void __init udbg_init_pmac_realmode(void); 42extern void __init udbg_init_pmac_realmode(void);
43extern void __init udbg_init_maple_realmode(void); 43extern void __init udbg_init_maple_realmode(void);
44extern void __init udbg_init_iseries(void); 44extern void __init udbg_init_iseries(void);
45extern void __init udbg_init_rtas(void); 45extern void __init udbg_init_rtas_panel(void);
46extern void __init udbg_init_rtas_console(void);
46 47
47#endif /* __KERNEL__ */ 48#endif /* __KERNEL__ */
48#endif /* _ASM_POWERPC_UDBG_H */ 49#endif /* _ASM_POWERPC_UDBG_H */
diff --git a/include/asm-ppc/ocp.h b/include/asm-ppc/ocp.h
index 3be5d760ffcd..16dbc7d17450 100644
--- a/include/asm-ppc/ocp.h
+++ b/include/asm-ppc/ocp.h
@@ -26,7 +26,6 @@
26 26
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/devfs_fs_kernel.h>
30#include <linux/device.h> 29#include <linux/device.h>
31 30
32#include <asm/mmu.h> 31#include <asm/mmu.h>
diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h
index 61434edbad7b..11ffaaa5da16 100644
--- a/include/asm-ppc/pci.h
+++ b/include/asm-ppc/pci.h
@@ -133,7 +133,7 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,
133#define HAVE_ARCH_PCI_RESOURCE_TO_USER 133#define HAVE_ARCH_PCI_RESOURCE_TO_USER
134extern void pci_resource_to_user(const struct pci_dev *dev, int bar, 134extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
135 const struct resource *rsrc, 135 const struct resource *rsrc,
136 u64 *start, u64 *end); 136 resource_size_t *start, resource_size_t *end);
137 137
138 138
139#endif /* __KERNEL__ */ 139#endif /* __KERNEL__ */
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h
index 4d2b126ba159..0ddcdba79e4a 100644
--- a/include/asm-s390/bitops.h
+++ b/include/asm-s390/bitops.h
@@ -12,6 +12,9 @@
12 * Copyright (C) 1992, Linus Torvalds 12 * Copyright (C) 1992, Linus Torvalds
13 * 13 *
14 */ 14 */
15
16#ifdef __KERNEL__
17
15#include <linux/compiler.h> 18#include <linux/compiler.h>
16 19
17/* 20/*
@@ -50,19 +53,6 @@
50 * with operation of the form "set_bit(bitnr, flags)". 53 * with operation of the form "set_bit(bitnr, flags)".
51 */ 54 */
52 55
53/* set ALIGN_CS to 1 if the SMP safe bit operations should
54 * align the address to 4 byte boundary. It seems to work
55 * without the alignment.
56 */
57#ifdef __KERNEL__
58#define ALIGN_CS 0
59#else
60#define ALIGN_CS 1
61#ifndef CONFIG_SMP
62#error "bitops won't work without CONFIG_SMP"
63#endif
64#endif
65
66/* bitmap tables from arch/S390/kernel/bitmap.S */ 56/* bitmap tables from arch/S390/kernel/bitmap.S */
67extern const char _oi_bitmap[]; 57extern const char _oi_bitmap[];
68extern const char _ni_bitmap[]; 58extern const char _ni_bitmap[];
@@ -121,10 +111,6 @@ static inline void set_bit_cs(unsigned long nr, volatile unsigned long *ptr)
121 unsigned long addr, old, new, mask; 111 unsigned long addr, old, new, mask;
122 112
123 addr = (unsigned long) ptr; 113 addr = (unsigned long) ptr;
124#if ALIGN_CS == 1
125 nr += (addr & __BITOPS_ALIGN) << 3; /* add alignment to bit number */
126 addr ^= addr & __BITOPS_ALIGN; /* align address to 8 */
127#endif
128 /* calculate address for CS */ 114 /* calculate address for CS */
129 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3; 115 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3;
130 /* make OR mask */ 116 /* make OR mask */
@@ -141,10 +127,6 @@ static inline void clear_bit_cs(unsigned long nr, volatile unsigned long *ptr)
141 unsigned long addr, old, new, mask; 127 unsigned long addr, old, new, mask;
142 128
143 addr = (unsigned long) ptr; 129 addr = (unsigned long) ptr;
144#if ALIGN_CS == 1
145 nr += (addr & __BITOPS_ALIGN) << 3; /* add alignment to bit number */
146 addr ^= addr & __BITOPS_ALIGN; /* align address to 8 */
147#endif
148 /* calculate address for CS */ 130 /* calculate address for CS */
149 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3; 131 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3;
150 /* make AND mask */ 132 /* make AND mask */
@@ -161,10 +143,6 @@ static inline void change_bit_cs(unsigned long nr, volatile unsigned long *ptr)
161 unsigned long addr, old, new, mask; 143 unsigned long addr, old, new, mask;
162 144
163 addr = (unsigned long) ptr; 145 addr = (unsigned long) ptr;
164#if ALIGN_CS == 1
165 nr += (addr & __BITOPS_ALIGN) << 3; /* add alignment to bit number */
166 addr ^= addr & __BITOPS_ALIGN; /* align address to 8 */
167#endif
168 /* calculate address for CS */ 146 /* calculate address for CS */
169 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3; 147 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3;
170 /* make XOR mask */ 148 /* make XOR mask */
@@ -182,10 +160,6 @@ test_and_set_bit_cs(unsigned long nr, volatile unsigned long *ptr)
182 unsigned long addr, old, new, mask; 160 unsigned long addr, old, new, mask;
183 161
184 addr = (unsigned long) ptr; 162 addr = (unsigned long) ptr;
185#if ALIGN_CS == 1
186 nr += (addr & __BITOPS_ALIGN) << 3; /* add alignment to bit number */
187 addr ^= addr & __BITOPS_ALIGN; /* align address to 8 */
188#endif
189 /* calculate address for CS */ 163 /* calculate address for CS */
190 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3; 164 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3;
191 /* make OR/test mask */ 165 /* make OR/test mask */
@@ -205,10 +179,6 @@ test_and_clear_bit_cs(unsigned long nr, volatile unsigned long *ptr)
205 unsigned long addr, old, new, mask; 179 unsigned long addr, old, new, mask;
206 180
207 addr = (unsigned long) ptr; 181 addr = (unsigned long) ptr;
208#if ALIGN_CS == 1
209 nr += (addr & __BITOPS_ALIGN) << 3; /* add alignment to bit number */
210 addr ^= addr & __BITOPS_ALIGN; /* align address to 8 */
211#endif
212 /* calculate address for CS */ 182 /* calculate address for CS */
213 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3; 183 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3;
214 /* make AND/test mask */ 184 /* make AND/test mask */
@@ -228,10 +198,6 @@ test_and_change_bit_cs(unsigned long nr, volatile unsigned long *ptr)
228 unsigned long addr, old, new, mask; 198 unsigned long addr, old, new, mask;
229 199
230 addr = (unsigned long) ptr; 200 addr = (unsigned long) ptr;
231#if ALIGN_CS == 1
232 nr += (addr & __BITOPS_ALIGN) << 3; /* add alignment to bit number */
233 addr ^= addr & __BITOPS_ALIGN; /* align address to 8 */
234#endif
235 /* calculate address for CS */ 201 /* calculate address for CS */
236 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3; 202 addr += (nr ^ (nr & (__BITOPS_WORDSIZE - 1))) >> 3;
237 /* make XOR/test mask */ 203 /* make XOR/test mask */
@@ -834,8 +800,6 @@ static inline int sched_find_first_bit(unsigned long *b)
834 800
835#include <asm-generic/bitops/hweight.h> 801#include <asm-generic/bitops/hweight.h>
836 802
837#ifdef __KERNEL__
838
839/* 803/*
840 * ATTENTION: intel byte ordering convention for ext2 and minix !! 804 * ATTENTION: intel byte ordering convention for ext2 and minix !!
841 * bit 0 is the LSB of addr; bit 31 is the MSB of addr; 805 * bit 0 is the LSB of addr; bit 31 is the MSB of addr;
diff --git a/include/asm-s390/cio.h b/include/asm-s390/cio.h
index 089cf567c317..2b1619306351 100644
--- a/include/asm-s390/cio.h
+++ b/include/asm-s390/cio.h
@@ -276,6 +276,8 @@ extern void wait_cons_dev(void);
276 276
277extern void clear_all_subchannels(void); 277extern void clear_all_subchannels(void);
278 278
279extern void css_schedule_reprobe(void);
280
279#endif 281#endif
280 282
281#endif 283#endif
diff --git a/include/asm-s390/cmb.h b/include/asm-s390/cmb.h
index 2d09950a9c11..241756f80df3 100644
--- a/include/asm-s390/cmb.h
+++ b/include/asm-s390/cmb.h
@@ -44,10 +44,6 @@ struct cmbdata {
44#define BIODASDCMFENABLE _IO(DASD_IOCTL_LETTER,32) 44#define BIODASDCMFENABLE _IO(DASD_IOCTL_LETTER,32)
45/* enable channel measurement */ 45/* enable channel measurement */
46#define BIODASDCMFDISABLE _IO(DASD_IOCTL_LETTER,33) 46#define BIODASDCMFDISABLE _IO(DASD_IOCTL_LETTER,33)
47/* reset channel measurement block */
48#define BIODASDRESETCMB _IO(DASD_IOCTL_LETTER,34)
49/* read channel measurement data */
50#define BIODASDREADCMB _IOWR(DASD_IOCTL_LETTER,32,__u64)
51/* read channel measurement data */ 47/* read channel measurement data */
52#define BIODASDREADALLCMB _IOWR(DASD_IOCTL_LETTER,33,struct cmbdata) 48#define BIODASDREADALLCMB _IOWR(DASD_IOCTL_LETTER,33,struct cmbdata)
53 49
diff --git a/include/asm-s390/dasd.h b/include/asm-s390/dasd.h
index 1630c26e8f45..c042f9578081 100644
--- a/include/asm-s390/dasd.h
+++ b/include/asm-s390/dasd.h
@@ -68,10 +68,12 @@ typedef struct dasd_information2_t {
68 * 0x00: default features 68 * 0x00: default features
69 * 0x01: readonly (ro) 69 * 0x01: readonly (ro)
70 * 0x02: use diag discipline (diag) 70 * 0x02: use diag discipline (diag)
71 * 0x04: set the device initially online (internal use only)
71 */ 72 */
72#define DASD_FEATURE_DEFAULT 0 73#define DASD_FEATURE_DEFAULT 0x00
73#define DASD_FEATURE_READONLY 1 74#define DASD_FEATURE_READONLY 0x01
74#define DASD_FEATURE_USEDIAG 2 75#define DASD_FEATURE_USEDIAG 0x02
76#define DASD_FEATURE_INITIAL_ONLINE 0x04
75 77
76#define DASD_PARTN_BITS 2 78#define DASD_PARTN_BITS 2
77 79
diff --git a/include/asm-s390/thread_info.h b/include/asm-s390/thread_info.h
index 8e0c7ed73d03..0a518915bf90 100644
--- a/include/asm-s390/thread_info.h
+++ b/include/asm-s390/thread_info.h
@@ -63,6 +63,7 @@ struct thread_info {
63 .exec_domain = &default_exec_domain, \ 63 .exec_domain = &default_exec_domain, \
64 .flags = 0, \ 64 .flags = 0, \
65 .cpu = 0, \ 65 .cpu = 0, \
66 .preempt_count = 1, \
66 .restart_block = { \ 67 .restart_block = { \
67 .fn = do_no_restart_syscall, \ 68 .fn = do_no_restart_syscall, \
68 }, \ 69 }, \
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index e21443d3ea1d..aa7a243862e1 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -394,11 +394,9 @@
394 394
395#ifdef __KERNEL__ 395#ifdef __KERNEL__
396 396
397/* user-visible error numbers are in the range -1 - -122: see <asm-s390/errno.h> */
398
399#define __syscall_return(type, res) \ 397#define __syscall_return(type, res) \
400do { \ 398do { \
401 if ((unsigned long)(res) >= (unsigned long)(-125)) { \ 399 if ((unsigned long)(res) >= (unsigned long)(-4095)) {\
402 errno = -(res); \ 400 errno = -(res); \
403 res = -1; \ 401 res = -1; \
404 } \ 402 } \
diff --git a/include/asm-sh/hw_irq.h b/include/asm-sh/hw_irq.h
index 1d934fb2c581..fed26616967a 100644
--- a/include/asm-sh/hw_irq.h
+++ b/include/asm-sh/hw_irq.h
@@ -1,9 +1,4 @@
1#ifndef __ASM_SH_HW_IRQ_H 1#ifndef __ASM_SH_HW_IRQ_H
2#define __ASM_SH_HW_IRQ_H 2#define __ASM_SH_HW_IRQ_H
3 3
4static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
5{
6 /* Nothing to do */
7}
8
9#endif /* __ASM_SH_HW_IRQ_H */ 4#endif /* __ASM_SH_HW_IRQ_H */
diff --git a/include/asm-sh64/hw_irq.h b/include/asm-sh64/hw_irq.h
index ae718d1f2d6c..ebb39089b0ac 100644
--- a/include/asm-sh64/hw_irq.h
+++ b/include/asm-sh64/hw_irq.h
@@ -11,6 +11,5 @@
11 * Copyright (C) 2000, 2001 Paolo Alberelli 11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * 12 *
13 */ 13 */
14static __inline__ void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) { /* Nothing to do */ }
15 14
16#endif /* __ASM_SH64_HW_IRQ_H */ 15#endif /* __ASM_SH64_HW_IRQ_H */
diff --git a/include/asm-sparc64/topology.h b/include/asm-sparc64/topology.h
index 0e234e201bd6..98a6c613589d 100644
--- a/include/asm-sparc64/topology.h
+++ b/include/asm-sparc64/topology.h
@@ -1,6 +1,9 @@
1#ifndef _ASM_SPARC64_TOPOLOGY_H 1#ifndef _ASM_SPARC64_TOPOLOGY_H
2#define _ASM_SPARC64_TOPOLOGY_H 2#define _ASM_SPARC64_TOPOLOGY_H
3 3
4#include <asm/spitfire.h>
5#define smt_capable() (tlb_type == hypervisor)
6
4#include <asm-generic/topology.h> 7#include <asm-generic/topology.h>
5 8
6#endif /* _ASM_SPARC64_TOPOLOGY_H */ 9#endif /* _ASM_SPARC64_TOPOLOGY_H */
diff --git a/include/asm-um/hw_irq.h b/include/asm-um/hw_irq.h
index 4ee38c0b6a64..1cf84cf5f21a 100644
--- a/include/asm-um/hw_irq.h
+++ b/include/asm-um/hw_irq.h
@@ -4,7 +4,4 @@
4#include "asm/irq.h" 4#include "asm/irq.h"
5#include "asm/archparam.h" 5#include "asm/archparam.h"
6 6
7static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
8{}
9
10#endif 7#endif
diff --git a/include/asm-v850/hw_irq.h b/include/asm-v850/hw_irq.h
index a8aab4342712..043e94bb6bd8 100644
--- a/include/asm-v850/hw_irq.h
+++ b/include/asm-v850/hw_irq.h
@@ -1,8 +1,4 @@
1#ifndef __V850_HW_IRQ_H__ 1#ifndef __V850_HW_IRQ_H__
2#define __V850_HW_IRQ_H__ 2#define __V850_HW_IRQ_H__
3 3
4static inline void hw_resend_irq (struct hw_interrupt_type *h, unsigned int i)
5{
6}
7
8#endif /* __V850_HW_IRQ_H__ */ 4#endif /* __V850_HW_IRQ_H__ */
diff --git a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h
index 1b2ac55d3204..48a4a5364e85 100644
--- a/include/asm-x86_64/hw_irq.h
+++ b/include/asm-x86_64/hw_irq.h
@@ -124,18 +124,9 @@ asmlinkage void IRQ_NAME(nr); \
124__asm__( \ 124__asm__( \
125"\n.p2align\n" \ 125"\n.p2align\n" \
126"IRQ" #nr "_interrupt:\n\t" \ 126"IRQ" #nr "_interrupt:\n\t" \
127 "push $" #nr "-256 ; " \ 127 "push $~(" #nr ") ; " \
128 "jmp common_interrupt"); 128 "jmp common_interrupt");
129 129
130#if defined(CONFIG_X86_IO_APIC)
131static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {
132 if (IO_APIC_IRQ(i))
133 send_IPI_self(IO_APIC_VECTOR(i));
134}
135#else
136static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
137#endif
138
139#define platform_legacy_irq(irq) ((irq) < 16) 130#define platform_legacy_irq(irq) ((irq) < 16)
140 131
141#endif 132#endif
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
index c4e46e7fa7ba..6e7a2e976b04 100644
--- a/include/asm-x86_64/topology.h
+++ b/include/asm-x86_64/topology.h
@@ -59,6 +59,8 @@ extern int __node_distance(int, int);
59#define topology_core_id(cpu) (cpu_data[cpu].cpu_core_id) 59#define topology_core_id(cpu) (cpu_data[cpu].cpu_core_id)
60#define topology_core_siblings(cpu) (cpu_core_map[cpu]) 60#define topology_core_siblings(cpu) (cpu_core_map[cpu])
61#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) 61#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
62#define mc_capable() (boot_cpu_data.x86_max_cores > 1)
63#define smt_capable() (smp_num_siblings > 1)
62#endif 64#endif
63 65
64#include <asm-generic/topology.h> 66#include <asm-generic/topology.h>
diff --git a/include/asm-xtensa/hw_irq.h b/include/asm-xtensa/hw_irq.h
index ccf436249eaa..3ddbea759b2b 100644
--- a/include/asm-xtensa/hw_irq.h
+++ b/include/asm-xtensa/hw_irq.h
@@ -11,8 +11,4 @@
11#ifndef _XTENSA_HW_IRQ_H 11#ifndef _XTENSA_HW_IRQ_H
12#define _XTENSA_HW_IRQ_H 12#define _XTENSA_HW_IRQ_H
13 13
14static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
15{
16}
17
18#endif 14#endif
diff --git a/include/linux/ac97_codec.h b/include/linux/ac97_codec.h
index c35833824e11..2ed2fd855133 100644
--- a/include/linux/ac97_codec.h
+++ b/include/linux/ac97_codec.h
@@ -259,7 +259,7 @@ struct ac97_codec {
259 int type; 259 int type;
260 u32 model; 260 u32 model;
261 261
262 int modem:1; 262 unsigned int modem:1;
263 263
264 struct ac97_ops *codec_ops; 264 struct ac97_ops *codec_ops;
265 265
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 90d6df1551ed..88b5dfd8ee12 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -528,12 +528,18 @@ static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
528 528
529#ifdef CONFIG_ACPI_NUMA 529#ifdef CONFIG_ACPI_NUMA
530int acpi_get_pxm(acpi_handle handle); 530int acpi_get_pxm(acpi_handle handle);
531int acpi_get_node(acpi_handle *handle);
531#else 532#else
532static inline int acpi_get_pxm(acpi_handle handle) 533static inline int acpi_get_pxm(acpi_handle handle)
533{ 534{
534 return 0; 535 return 0;
535} 536}
537static inline int acpi_get_node(acpi_handle *handle)
538{
539 return 0;
540}
536#endif 541#endif
542extern int acpi_paddr_to_node(u64 start_addr, u64 size);
537 543
538extern int pnpacpi_disabled; 544extern int pnpacpi_disabled;
539 545
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index fb7e9b7ccbe3..737e407d0cd1 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -149,7 +149,6 @@ void create_empty_buffers(struct page *, unsigned long,
149 unsigned long b_state); 149 unsigned long b_state);
150void end_buffer_read_sync(struct buffer_head *bh, int uptodate); 150void end_buffer_read_sync(struct buffer_head *bh, int uptodate);
151void end_buffer_write_sync(struct buffer_head *bh, int uptodate); 151void end_buffer_write_sync(struct buffer_head *bh, int uptodate);
152void end_buffer_async_write(struct buffer_head *bh, int uptodate);
153 152
154/* Things to do with buffers at mapping->private_list */ 153/* Things to do with buffers at mapping->private_list */
155void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode); 154void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode);
@@ -214,6 +213,7 @@ int nobh_truncate_page(struct address_space *, loff_t);
214int nobh_writepage(struct page *page, get_block_t *get_block, 213int nobh_writepage(struct page *page, get_block_t *get_block,
215 struct writeback_control *wbc); 214 struct writeback_control *wbc);
216 215
216void buffer_init(void);
217 217
218/* 218/*
219 * inline definitions 219 * inline definitions
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index 7b5c5df5cb69..be512cc98791 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -27,8 +27,8 @@ extern struct inode_operations coda_dir_inode_operations;
27extern struct inode_operations coda_file_inode_operations; 27extern struct inode_operations coda_file_inode_operations;
28extern struct inode_operations coda_ioctl_inode_operations; 28extern struct inode_operations coda_ioctl_inode_operations;
29 29
30extern struct address_space_operations coda_file_aops; 30extern const struct address_space_operations coda_file_aops;
31extern struct address_space_operations coda_symlink_aops; 31extern const struct address_space_operations coda_symlink_aops;
32 32
33extern const struct file_operations coda_dir_operations; 33extern const struct file_operations coda_dir_operations;
34extern const struct file_operations coda_file_operations; 34extern const struct file_operations coda_file_operations;
diff --git a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
index 917d62e41480..269d000bb2a3 100644
--- a/include/linux/compat_ioctl.h
+++ b/include/linux/compat_ioctl.h
@@ -567,11 +567,6 @@ COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
567COMPATIBLE_IOCTL(AUTOFS_IOC_ASKREGHOST) 567COMPATIBLE_IOCTL(AUTOFS_IOC_ASKREGHOST)
568COMPATIBLE_IOCTL(AUTOFS_IOC_TOGGLEREGHOST) 568COMPATIBLE_IOCTL(AUTOFS_IOC_TOGGLEREGHOST)
569COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT) 569COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
570/* DEVFS */
571COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
572COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
573COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
574COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
575/* Raw devices */ 570/* Raw devices */
576COMPATIBLE_IOCTL(RAW_SETBIND) 571COMPATIBLE_IOCTL(RAW_SETBIND)
577COMPATIBLE_IOCTL(RAW_GETBIND) 572COMPATIBLE_IOCTL(RAW_GETBIND)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 08d50c53aab4..a3caf6866bae 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -31,17 +31,23 @@ struct cpu {
31 struct sys_device sysdev; 31 struct sys_device sysdev;
32}; 32};
33 33
34extern int register_cpu(struct cpu *, int, struct node *); 34extern int register_cpu(struct cpu *cpu, int num);
35extern struct sys_device *get_cpu_sysdev(unsigned cpu); 35extern struct sys_device *get_cpu_sysdev(unsigned cpu);
36#ifdef CONFIG_HOTPLUG_CPU 36#ifdef CONFIG_HOTPLUG_CPU
37extern void unregister_cpu(struct cpu *, struct node *); 37extern void unregister_cpu(struct cpu *cpu);
38#endif 38#endif
39struct notifier_block; 39struct notifier_block;
40 40
41#ifdef CONFIG_SMP 41#ifdef CONFIG_SMP
42/* Need to know about CPUs going up/down? */ 42/* Need to know about CPUs going up/down? */
43extern int register_cpu_notifier(struct notifier_block *nb); 43extern int register_cpu_notifier(struct notifier_block *nb);
44#ifdef CONFIG_HOTPLUG_CPU
44extern void unregister_cpu_notifier(struct notifier_block *nb); 45extern void unregister_cpu_notifier(struct notifier_block *nb);
46#else
47static inline void unregister_cpu_notifier(struct notifier_block *nb)
48{
49}
50#endif
45extern int current_in_cpu_hotplug(void); 51extern int current_in_cpu_hotplug(void);
46 52
47int cpu_up(unsigned int cpu); 53int cpu_up(unsigned int cpu);
@@ -73,6 +79,8 @@ extern int lock_cpu_hotplug_interruptible(void);
73 { .notifier_call = fn, .priority = pri }; \ 79 { .notifier_call = fn, .priority = pri }; \
74 register_cpu_notifier(&fn##_nb); \ 80 register_cpu_notifier(&fn##_nb); \
75} 81}
82#define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
83#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
76int cpu_down(unsigned int cpu); 84int cpu_down(unsigned int cpu);
77#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 85#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
78#else 86#else
@@ -80,6 +88,8 @@ int cpu_down(unsigned int cpu);
80#define unlock_cpu_hotplug() do { } while (0) 88#define unlock_cpu_hotplug() do { } while (0)
81#define lock_cpu_hotplug_interruptible() 0 89#define lock_cpu_hotplug_interruptible() 0
82#define hotcpu_notifier(fn, pri) 90#define hotcpu_notifier(fn, pri)
91#define register_hotcpu_notifier(nb)
92#define unregister_hotcpu_notifier(nb)
83 93
84/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */ 94/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
85static inline int cpu_is_offline(int cpu) { return 0; } 95static inline int cpu_is_offline(int cpu) { return 0; }
diff --git a/include/linux/devfs_fs.h b/include/linux/devfs_fs.h
deleted file mode 100644
index de236f431877..000000000000
--- a/include/linux/devfs_fs.h
+++ /dev/null
@@ -1,41 +0,0 @@
1#ifndef _LINUX_DEVFS_FS_H
2#define _LINUX_DEVFS_FS_H
3
4#include <linux/ioctl.h>
5
6#define DEVFSD_PROTOCOL_REVISION_KERNEL 5
7
8#define DEVFSD_IOCTL_BASE 'd'
9
10/* These are the various ioctls */
11#define DEVFSDIOC_GET_PROTO_REV _IOR(DEVFSD_IOCTL_BASE, 0, int)
12#define DEVFSDIOC_SET_EVENT_MASK _IOW(DEVFSD_IOCTL_BASE, 2, int)
13#define DEVFSDIOC_RELEASE_EVENT_QUEUE _IOW(DEVFSD_IOCTL_BASE, 3, int)
14#define DEVFSDIOC_SET_DEBUG_MASK _IOW(DEVFSD_IOCTL_BASE, 4, int)
15
16#define DEVFSD_NOTIFY_REGISTERED 0
17#define DEVFSD_NOTIFY_UNREGISTERED 1
18#define DEVFSD_NOTIFY_ASYNC_OPEN 2
19#define DEVFSD_NOTIFY_CLOSE 3
20#define DEVFSD_NOTIFY_LOOKUP 4
21#define DEVFSD_NOTIFY_CHANGE 5
22#define DEVFSD_NOTIFY_CREATE 6
23#define DEVFSD_NOTIFY_DELETE 7
24
25#define DEVFS_PATHLEN 1024 /* Never change this otherwise the
26 binary interface will change */
27
28struct devfsd_notify_struct { /* Use native C types to ensure same types in kernel and user space */
29 unsigned int type; /* DEVFSD_NOTIFY_* value */
30 unsigned int mode; /* Mode of the inode or device entry */
31 unsigned int major; /* Major number of device entry */
32 unsigned int minor; /* Minor number of device entry */
33 unsigned int uid; /* Uid of process, inode or device entry */
34 unsigned int gid; /* Gid of process, inode or device entry */
35 unsigned int overrun_count; /* Number of lost events */
36 unsigned int namelen; /* Number of characters not including '\0' */
37 /* The device name MUST come last */
38 char devname[DEVFS_PATHLEN]; /* This will be '\0' terminated */
39};
40
41#endif /* _LINUX_DEVFS_FS_H */
diff --git a/include/linux/devfs_fs_kernel.h b/include/linux/devfs_fs_kernel.h
deleted file mode 100644
index 0d74a6f22abc..000000000000
--- a/include/linux/devfs_fs_kernel.h
+++ /dev/null
@@ -1,57 +0,0 @@
1#ifndef _LINUX_DEVFS_FS_KERNEL_H
2#define _LINUX_DEVFS_FS_KERNEL_H
3
4#include <linux/fs.h>
5#include <linux/spinlock.h>
6#include <linux/types.h>
7
8#include <asm/semaphore.h>
9
10#define DEVFS_SUPER_MAGIC 0x1373
11
12#ifdef CONFIG_DEVFS_FS
13extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
14 __attribute__ ((format(printf, 3, 4)));
15extern int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
16 __attribute__ ((format(printf, 3, 4)));
17extern int devfs_mk_symlink(const char *name, const char *link);
18extern int devfs_mk_dir(const char *fmt, ...)
19 __attribute__ ((format(printf, 1, 2)));
20extern void devfs_remove(const char *fmt, ...)
21 __attribute__ ((format(printf, 1, 2)));
22extern int devfs_register_tape(const char *name);
23extern void devfs_unregister_tape(int num);
24extern void mount_devfs_fs(void);
25#else /* CONFIG_DEVFS_FS */
26static inline int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
27{
28 return 0;
29}
30static inline int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
31{
32 return 0;
33}
34static inline int devfs_mk_symlink(const char *name, const char *link)
35{
36 return 0;
37}
38static inline int devfs_mk_dir(const char *fmt, ...)
39{
40 return 0;
41}
42static inline void devfs_remove(const char *fmt, ...)
43{
44}
45static inline int devfs_register_tape(const char *name)
46{
47 return -1;
48}
49static inline void devfs_unregister_tape(int num)
50{
51}
52static inline void mount_devfs_fs(void)
53{
54 return;
55}
56#endif /* CONFIG_DEVFS_FS */
57#endif /* _LINUX_DEVFS_FS_KERNEL_H */
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 78b236ca04f8..272010a6078a 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -20,7 +20,7 @@
20 */ 20 */
21#ifndef DMAENGINE_H 21#ifndef DMAENGINE_H
22#define DMAENGINE_H 22#define DMAENGINE_H
23#include <linux/config.h> 23
24#ifdef CONFIG_DMA_ENGINE 24#ifdef CONFIG_DMA_ENGINE
25 25
26#include <linux/device.h> 26#include <linux/device.h>
diff --git a/include/linux/efs_fs.h b/include/linux/efs_fs.h
index fbfa6b52e2fb..278ef4495819 100644
--- a/include/linux/efs_fs.h
+++ b/include/linux/efs_fs.h
@@ -38,7 +38,7 @@ struct statfs;
38 38
39extern struct inode_operations efs_dir_inode_operations; 39extern struct inode_operations efs_dir_inode_operations;
40extern const struct file_operations efs_dir_operations; 40extern const struct file_operations efs_dir_operations;
41extern struct address_space_operations efs_symlink_aops; 41extern const struct address_space_operations efs_symlink_aops;
42 42
43extern void efs_read_inode(struct inode *); 43extern void efs_read_inode(struct inode *);
44extern efs_block_t efs_map_block(struct inode *, efs_block_t); 44extern efs_block_t efs_map_block(struct inode *, efs_block_t);
diff --git a/include/linux/elf-em.h b/include/linux/elf-em.h
index 114a96d25652..6a5796c81c90 100644
--- a/include/linux/elf-em.h
+++ b/include/linux/elf-em.h
@@ -11,7 +11,12 @@
11#define EM_486 6 /* Perhaps disused */ 11#define EM_486 6 /* Perhaps disused */
12#define EM_860 7 12#define EM_860 7
13#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */ 13#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
14 /* Next two are historical and binaries and
15 modules of these types will be rejected by
16 Linux. */
17#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
14#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */ 18#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
19
15#define EM_PARISC 15 /* HPPA */ 20#define EM_PARISC 15 /* HPPA */
16#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ 21#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
17#define EM_PPC 20 /* PowerPC */ 22#define EM_PPC 20 /* PowerPC */
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 07a08e92bc73..b45928f5c63f 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -380,7 +380,6 @@ struct fb_cursor {
380#include <linux/tty.h> 380#include <linux/tty.h>
381#include <linux/device.h> 381#include <linux/device.h>
382#include <linux/workqueue.h> 382#include <linux/workqueue.h>
383#include <linux/devfs_fs_kernel.h>
384#include <linux/notifier.h> 383#include <linux/notifier.h>
385#include <linux/list.h> 384#include <linux/list.h>
386#include <asm/io.h> 385#include <asm/io.h>
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2d8b348c1192..e04a5cfe874f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -392,7 +392,7 @@ struct address_space {
392 unsigned int truncate_count; /* Cover race condition with truncate */ 392 unsigned int truncate_count; /* Cover race condition with truncate */
393 unsigned long nrpages; /* number of total pages */ 393 unsigned long nrpages; /* number of total pages */
394 pgoff_t writeback_index;/* writeback starts here */ 394 pgoff_t writeback_index;/* writeback starts here */
395 struct address_space_operations *a_ops; /* methods */ 395 const struct address_space_operations *a_ops; /* methods */
396 unsigned long flags; /* error bits/gfp mask */ 396 unsigned long flags; /* error bits/gfp mask */
397 struct backing_dev_info *backing_dev_info; /* device readahead, etc */ 397 struct backing_dev_info *backing_dev_info; /* device readahead, etc */
398 spinlock_t private_lock; /* for use by the address_space */ 398 spinlock_t private_lock; /* for use by the address_space */
@@ -1405,7 +1405,7 @@ extern void bd_forget(struct inode *inode);
1405extern void bdput(struct block_device *); 1405extern void bdput(struct block_device *);
1406extern struct block_device *open_by_devnum(dev_t, unsigned); 1406extern struct block_device *open_by_devnum(dev_t, unsigned);
1407extern const struct file_operations def_blk_fops; 1407extern const struct file_operations def_blk_fops;
1408extern struct address_space_operations def_blk_aops; 1408extern const struct address_space_operations def_blk_aops;
1409extern const struct file_operations def_chr_fops; 1409extern const struct file_operations def_chr_fops;
1410extern const struct file_operations bad_sock_fops; 1410extern const struct file_operations bad_sock_fops;
1411extern const struct file_operations def_fifo_fops; 1411extern const struct file_operations def_fifo_fops;
diff --git a/include/linux/futex.h b/include/linux/futex.h
index 966a5b3da439..34c3a215f2cd 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -12,6 +12,9 @@
12#define FUTEX_REQUEUE 3 12#define FUTEX_REQUEUE 3
13#define FUTEX_CMP_REQUEUE 4 13#define FUTEX_CMP_REQUEUE 4
14#define FUTEX_WAKE_OP 5 14#define FUTEX_WAKE_OP 5
15#define FUTEX_LOCK_PI 6
16#define FUTEX_UNLOCK_PI 7
17#define FUTEX_TRYLOCK_PI 8
15 18
16/* 19/*
17 * Support for robust futexes: the kernel cleans up held futexes at 20 * Support for robust futexes: the kernel cleans up held futexes at
@@ -90,18 +93,21 @@ struct robust_list_head {
90 */ 93 */
91#define ROBUST_LIST_LIMIT 2048 94#define ROBUST_LIST_LIMIT 2048
92 95
93long do_futex(unsigned long uaddr, int op, int val, 96long do_futex(u32 __user *uaddr, int op, u32 val, unsigned long timeout,
94 unsigned long timeout, unsigned long uaddr2, int val2, 97 u32 __user *uaddr2, u32 val2, u32 val3);
95 int val3);
96 98
97extern int handle_futex_death(u32 __user *uaddr, struct task_struct *curr); 99extern int handle_futex_death(u32 __user *uaddr, struct task_struct *curr);
98 100
99#ifdef CONFIG_FUTEX 101#ifdef CONFIG_FUTEX
100extern void exit_robust_list(struct task_struct *curr); 102extern void exit_robust_list(struct task_struct *curr);
103extern void exit_pi_state_list(struct task_struct *curr);
101#else 104#else
102static inline void exit_robust_list(struct task_struct *curr) 105static inline void exit_robust_list(struct task_struct *curr)
103{ 106{
104} 107}
108static inline void exit_pi_state_list(struct task_struct *curr)
109{
110}
105#endif 111#endif
106 112
107#define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */ 113#define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 3498a0c68184..e4af57e87c17 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -112,8 +112,6 @@ struct gendisk {
112 sector_t capacity; 112 sector_t capacity;
113 113
114 int flags; 114 int flags;
115 char devfs_name[64]; /* devfs crap */
116 int number; /* more of the same */
117 struct device *driverfs_dev; 115 struct device *driverfs_dev;
118 struct kobject kobj; 116 struct kobject kobj;
119 struct kobject *holder_dir; 117 struct kobject *holder_dir;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ef7bef207f48..285316c836b5 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -552,7 +552,6 @@ typedef struct ide_drive_s {
552 struct hd_driveid *id; /* drive model identification info */ 552 struct hd_driveid *id; /* drive model identification info */
553 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 553 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
554 struct ide_settings_s *settings;/* /proc/ide/ drive settings */ 554 struct ide_settings_s *settings;/* /proc/ide/ drive settings */
555 char devfs_name[64]; /* devfs crap */
556 555
557 struct hwif_s *hwif; /* actually (ide_hwif_t *) */ 556 struct hwif_s *hwif; /* actually (ide_hwif_t *) */
558 557
@@ -793,6 +792,7 @@ typedef struct hwif_s {
793 unsigned auto_poll : 1; /* supports nop auto-poll */ 792 unsigned auto_poll : 1; /* supports nop auto-poll */
794 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 793 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
795 unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */ 794 unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */
795 unsigned err_stops_fifo : 1; /* 1=data FIFO is cleared by an error */
796 796
797 struct device gendev; 797 struct device gendev;
798 struct completion gendev_rel_comp; /* To deal with device release() */ 798 struct completion gendev_rel_comp; /* To deal with device release() */
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index e127ef7e8da8..3a256957fb56 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -87,6 +87,7 @@ extern struct group_info init_groups;
87 .lock_depth = -1, \ 87 .lock_depth = -1, \
88 .prio = MAX_PRIO-20, \ 88 .prio = MAX_PRIO-20, \
89 .static_prio = MAX_PRIO-20, \ 89 .static_prio = MAX_PRIO-20, \
90 .normal_prio = MAX_PRIO-20, \
90 .policy = SCHED_NORMAL, \ 91 .policy = SCHED_NORMAL, \
91 .cpus_allowed = CPU_MASK_ALL, \ 92 .cpus_allowed = CPU_MASK_ALL, \
92 .mm = NULL, \ 93 .mm = NULL, \
@@ -122,6 +123,8 @@ extern struct group_info init_groups;
122 .journal_info = NULL, \ 123 .journal_info = NULL, \
123 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ 124 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
124 .fs_excl = ATOMIC_INIT(0), \ 125 .fs_excl = ATOMIC_INIT(0), \
126 .pi_lock = SPIN_LOCK_UNLOCKED, \
127 INIT_RT_MUTEXES(tsk) \
125} 128}
126 129
127 130
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 70741e170114..db2a63a11633 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -36,6 +36,20 @@ extern void free_irq(unsigned int, void *);
36extern void disable_irq_nosync(unsigned int irq); 36extern void disable_irq_nosync(unsigned int irq);
37extern void disable_irq(unsigned int irq); 37extern void disable_irq(unsigned int irq);
38extern void enable_irq(unsigned int irq); 38extern void enable_irq(unsigned int irq);
39
40/* IRQ wakeup (PM) control: */
41extern int set_irq_wake(unsigned int irq, unsigned int on);
42
43static inline int enable_irq_wake(unsigned int irq)
44{
45 return set_irq_wake(irq, 1);
46}
47
48static inline int disable_irq_wake(unsigned int irq)
49{
50 return set_irq_wake(irq, 0);
51}
52
39#endif 53#endif
40 54
41#ifndef __ARCH_SET_SOFTIRQ_PENDING 55#ifndef __ARCH_SET_SOFTIRQ_PENDING
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index cd6bd001ba4e..87a9fc039b47 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -9,13 +9,15 @@
9#define _LINUX_IOPORT_H 9#define _LINUX_IOPORT_H
10 10
11#include <linux/compiler.h> 11#include <linux/compiler.h>
12#include <linux/types.h>
12/* 13/*
13 * Resources are tree-like, allowing 14 * Resources are tree-like, allowing
14 * nesting etc.. 15 * nesting etc..
15 */ 16 */
16struct resource { 17struct resource {
18 resource_size_t start;
19 resource_size_t end;
17 const char *name; 20 const char *name;
18 unsigned long start, end;
19 unsigned long flags; 21 unsigned long flags;
20 struct resource *parent, *sibling, *child; 22 struct resource *parent, *sibling, *child;
21}; 23};
@@ -96,31 +98,37 @@ extern struct resource * ____request_resource(struct resource *root, struct reso
96extern int release_resource(struct resource *new); 98extern int release_resource(struct resource *new);
97extern __deprecated_for_modules int insert_resource(struct resource *parent, struct resource *new); 99extern __deprecated_for_modules int insert_resource(struct resource *parent, struct resource *new);
98extern int allocate_resource(struct resource *root, struct resource *new, 100extern int allocate_resource(struct resource *root, struct resource *new,
99 unsigned long size, 101 resource_size_t size, resource_size_t min,
100 unsigned long min, unsigned long max, 102 resource_size_t max, resource_size_t align,
101 unsigned long align,
102 void (*alignf)(void *, struct resource *, 103 void (*alignf)(void *, struct resource *,
103 unsigned long, unsigned long), 104 resource_size_t, resource_size_t),
104 void *alignf_data); 105 void *alignf_data);
105int adjust_resource(struct resource *res, unsigned long start, 106int adjust_resource(struct resource *res, resource_size_t start,
106 unsigned long size); 107 resource_size_t size);
108
109/* get registered SYSTEM_RAM resources in specified area */
110extern int find_next_system_ram(struct resource *res);
107 111
108/* Convenience shorthand with allocation */ 112/* Convenience shorthand with allocation */
109#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name)) 113#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
110#define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name)) 114#define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name))
111#define rename_region(region, newname) do { (region)->name = (newname); } while (0) 115#define rename_region(region, newname) do { (region)->name = (newname); } while (0)
112 116
113extern struct resource * __request_region(struct resource *, unsigned long start, unsigned long n, const char *name); 117extern struct resource * __request_region(struct resource *,
118 resource_size_t start,
119 resource_size_t n, const char *name);
114 120
115/* Compatibility cruft */ 121/* Compatibility cruft */
116#define release_region(start,n) __release_region(&ioport_resource, (start), (n)) 122#define release_region(start,n) __release_region(&ioport_resource, (start), (n))
117#define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) 123#define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n))
118#define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) 124#define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n))
119 125
120extern int __check_region(struct resource *, unsigned long, unsigned long); 126extern int __check_region(struct resource *, resource_size_t, resource_size_t);
121extern void __release_region(struct resource *, unsigned long, unsigned long); 127extern void __release_region(struct resource *, resource_size_t,
128 resource_size_t);
122 129
123static inline int __deprecated check_region(unsigned long s, unsigned long n) 130static inline int __deprecated check_region(resource_size_t s,
131 resource_size_t n)
124{ 132{
125 return __check_region(&ioport_resource, s, n); 133 return __check_region(&ioport_resource, s, n);
126} 134}
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index 5653b2f23b6a..d09fbeabf1dc 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -210,11 +210,7 @@ struct kernel_ipmi_msg
210#include <linux/list.h> 210#include <linux/list.h>
211#include <linux/module.h> 211#include <linux/module.h>
212#include <linux/device.h> 212#include <linux/device.h>
213
214#ifdef CONFIG_PROC_FS
215#include <linux/proc_fs.h> 213#include <linux/proc_fs.h>
216extern struct proc_dir_entry *proc_ipmi_root;
217#endif /* CONFIG_PROC_FS */
218 214
219/* Opaque type for a IPMI message user. One of these is needed to 215/* Opaque type for a IPMI message user. One of these is needed to
220 send and receive messages. */ 216 send and receive messages. */
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 676e00dfb21a..0832149cdb18 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1,5 +1,5 @@
1#ifndef __irq_h 1#ifndef _LINUX_IRQ_H
2#define __irq_h 2#define _LINUX_IRQ_H
3 3
4/* 4/*
5 * Please do not include this file in generic code. There is currently 5 * Please do not include this file in generic code. There is currently
@@ -11,7 +11,7 @@
11 11
12#include <linux/smp.h> 12#include <linux/smp.h>
13 13
14#if !defined(CONFIG_S390) 14#ifndef CONFIG_S390
15 15
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <linux/cache.h> 17#include <linux/cache.h>
@@ -33,75 +33,160 @@
33#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ 33#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */
34#define IRQ_LEVEL 64 /* IRQ level triggered */ 34#define IRQ_LEVEL 64 /* IRQ level triggered */
35#define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */ 35#define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */
36#if defined(ARCH_HAS_IRQ_PER_CPU) 36#ifdef CONFIG_IRQ_PER_CPU
37# define IRQ_PER_CPU 256 /* IRQ is per CPU */ 37# define IRQ_PER_CPU 256 /* IRQ is per CPU */
38# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) 38# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
39#else 39#else
40# define CHECK_IRQ_PER_CPU(var) 0 40# define CHECK_IRQ_PER_CPU(var) 0
41#endif 41#endif
42 42
43#define IRQ_NOPROBE 512 /* IRQ is not valid for probing */
44#define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */
45#define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */
46#define IRQ_DELAYED_DISABLE \
47 4096 /* IRQ disable (masking) happens delayed. */
48
43/* 49/*
44 * Interrupt controller descriptor. This is all we need 50 * IRQ types, see also include/linux/interrupt.h
45 * to describe about the low-level hardware.
46 */ 51 */
47struct hw_interrupt_type { 52#define IRQ_TYPE_NONE 0x0000 /* Default, unspecified type */
48 const char * typename; 53#define IRQ_TYPE_EDGE_RISING 0x0001 /* Edge rising type */
49 unsigned int (*startup)(unsigned int irq); 54#define IRQ_TYPE_EDGE_FALLING 0x0002 /* Edge falling type */
50 void (*shutdown)(unsigned int irq); 55#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
51 void (*enable)(unsigned int irq); 56#define IRQ_TYPE_LEVEL_HIGH 0x0004 /* Level high type */
52 void (*disable)(unsigned int irq); 57#define IRQ_TYPE_LEVEL_LOW 0x0008 /* Level low type */
53 void (*ack)(unsigned int irq); 58#define IRQ_TYPE_SENSE_MASK 0x000f /* Mask of the above */
54 void (*end)(unsigned int irq); 59#define IRQ_TYPE_SIMPLE 0x0010 /* Simple type */
55 void (*set_affinity)(unsigned int irq, cpumask_t dest); 60#define IRQ_TYPE_PERCPU 0x0020 /* Per CPU type */
61#define IRQ_TYPE_PROBE 0x0040 /* Probing in progress */
62
63struct proc_dir_entry;
64
65/**
66 * struct irq_chip - hardware interrupt chip descriptor
67 *
68 * @name: name for /proc/interrupts
69 * @startup: start up the interrupt (defaults to ->enable if NULL)
70 * @shutdown: shut down the interrupt (defaults to ->disable if NULL)
71 * @enable: enable the interrupt (defaults to chip->unmask if NULL)
72 * @disable: disable the interrupt (defaults to chip->mask if NULL)
73 * @ack: start of a new interrupt
74 * @mask: mask an interrupt source
75 * @mask_ack: ack and mask an interrupt source
76 * @unmask: unmask an interrupt source
77 * @eoi: end of interrupt - chip level
78 * @end: end of interrupt - flow level
79 * @set_affinity: set the CPU affinity on SMP machines
80 * @retrigger: resend an IRQ to the CPU
81 * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
82 * @set_wake: enable/disable power-management wake-on of an IRQ
83 *
84 * @release: release function solely used by UML
85 * @typename: obsoleted by name, kept as migration helper
86 */
87struct irq_chip {
88 const char *name;
89 unsigned int (*startup)(unsigned int irq);
90 void (*shutdown)(unsigned int irq);
91 void (*enable)(unsigned int irq);
92 void (*disable)(unsigned int irq);
93
94 void (*ack)(unsigned int irq);
95 void (*mask)(unsigned int irq);
96 void (*mask_ack)(unsigned int irq);
97 void (*unmask)(unsigned int irq);
98 void (*eoi)(unsigned int irq);
99
100 void (*end)(unsigned int irq);
101 void (*set_affinity)(unsigned int irq, cpumask_t dest);
102 int (*retrigger)(unsigned int irq);
103 int (*set_type)(unsigned int irq, unsigned int flow_type);
104 int (*set_wake)(unsigned int irq, unsigned int on);
105
56 /* Currently used only by UML, might disappear one day.*/ 106 /* Currently used only by UML, might disappear one day.*/
57#ifdef CONFIG_IRQ_RELEASE_METHOD 107#ifdef CONFIG_IRQ_RELEASE_METHOD
58 void (*release)(unsigned int irq, void *dev_id); 108 void (*release)(unsigned int irq, void *dev_id);
59#endif 109#endif
110 /*
111 * For compatibility, ->typename is copied into ->name.
112 * Will disappear.
113 */
114 const char *typename;
60}; 115};
61 116
62typedef struct hw_interrupt_type hw_irq_controller; 117/**
63 118 * struct irq_desc - interrupt descriptor
64/* 119 *
65 * This is the "IRQ descriptor", which contains various information 120 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
66 * about the irq, including what kind of hardware handling it has, 121 * @chip: low level interrupt hardware access
67 * whether it is disabled etc etc. 122 * @handler_data: per-IRQ data for the irq_chip methods
123 * @chip_data: platform-specific per-chip private data for the chip
124 * methods, to allow shared chip implementations
125 * @action: the irq action chain
126 * @status: status information
127 * @depth: disable-depth, for nested irq_disable() calls
128 * @irq_count: stats field to detect stalled irqs
129 * @irqs_unhandled: stats field for spurious unhandled interrupts
130 * @lock: locking for SMP
131 * @affinity: IRQ affinity on SMP
132 * @cpu: cpu index useful for balancing
133 * @pending_mask: pending rebalanced interrupts
134 * @move_irq: need to re-target IRQ destination
135 * @dir: /proc/irq/ procfs entry
136 * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP
68 * 137 *
69 * Pad this out to 32 bytes for cache and indexing reasons. 138 * Pad this out to 32 bytes for cache and indexing reasons.
70 */ 139 */
71typedef struct irq_desc { 140struct irq_desc {
72 hw_irq_controller *handler; 141 void fastcall (*handle_irq)(unsigned int irq,
73 void *handler_data; 142 struct irq_desc *desc,
74 struct irqaction *action; /* IRQ action list */ 143 struct pt_regs *regs);
75 unsigned int status; /* IRQ status */ 144 struct irq_chip *chip;
76 unsigned int depth; /* nested irq disables */ 145 void *handler_data;
77 unsigned int irq_count; /* For detecting broken interrupts */ 146 void *chip_data;
78 unsigned int irqs_unhandled; 147 struct irqaction *action; /* IRQ action list */
79 spinlock_t lock; 148 unsigned int status; /* IRQ status */
80#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) 149
81 unsigned int move_irq; /* Flag need to re-target intr dest*/ 150 unsigned int depth; /* nested irq disables */
151 unsigned int irq_count; /* For detecting broken IRQs */
152 unsigned int irqs_unhandled;
153 spinlock_t lock;
154#ifdef CONFIG_SMP
155 cpumask_t affinity;
156 unsigned int cpu;
157#endif
158#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
159 cpumask_t pending_mask;
160 unsigned int move_irq; /* need to re-target IRQ dest */
82#endif 161#endif
83} ____cacheline_aligned irq_desc_t; 162#ifdef CONFIG_PROC_FS
163 struct proc_dir_entry *dir;
164#endif
165} ____cacheline_aligned;
84 166
85extern irq_desc_t irq_desc [NR_IRQS]; 167extern struct irq_desc irq_desc[NR_IRQS];
86 168
87/* Return a pointer to the irq descriptor for IRQ. */ 169/*
88static inline irq_desc_t * 170 * Migration helpers for obsolete names, they will go away:
89irq_descp (int irq) 171 */
90{ 172#define hw_interrupt_type irq_chip
91 return irq_desc + irq; 173typedef struct irq_chip hw_irq_controller;
92} 174#define no_irq_type no_irq_chip
175typedef struct irq_desc irq_desc_t;
93 176
94#include <asm/hw_irq.h> /* the arch dependent stuff */ 177/*
178 * Pick up the arch-dependent methods:
179 */
180#include <asm/hw_irq.h>
95 181
96extern int setup_irq(unsigned int irq, struct irqaction * new); 182extern int setup_irq(unsigned int irq, struct irqaction *new);
97 183
98#ifdef CONFIG_GENERIC_HARDIRQS 184#ifdef CONFIG_GENERIC_HARDIRQS
99extern cpumask_t irq_affinity[NR_IRQS];
100 185
101#ifdef CONFIG_SMP 186#ifdef CONFIG_SMP
102static inline void set_native_irq_info(int irq, cpumask_t mask) 187static inline void set_native_irq_info(int irq, cpumask_t mask)
103{ 188{
104 irq_affinity[irq] = mask; 189 irq_desc[irq].affinity = mask;
105} 190}
106#else 191#else
107static inline void set_native_irq_info(int irq, cpumask_t mask) 192static inline void set_native_irq_info(int irq, cpumask_t mask)
@@ -111,8 +196,7 @@ static inline void set_native_irq_info(int irq, cpumask_t mask)
111 196
112#ifdef CONFIG_SMP 197#ifdef CONFIG_SMP
113 198
114#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) 199#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
115extern cpumask_t pending_irq_cpumask[NR_IRQS];
116 200
117void set_pending_irq(unsigned int irq, cpumask_t mask); 201void set_pending_irq(unsigned int irq, cpumask_t mask);
118void move_native_irq(int irq); 202void move_native_irq(int irq);
@@ -133,7 +217,7 @@ static inline void set_irq_info(int irq, cpumask_t mask)
133{ 217{
134} 218}
135 219
136#else // CONFIG_PCI_MSI 220#else /* CONFIG_PCI_MSI */
137 221
138static inline void move_irq(int irq) 222static inline void move_irq(int irq)
139{ 223{
@@ -144,26 +228,36 @@ static inline void set_irq_info(int irq, cpumask_t mask)
144{ 228{
145 set_native_irq_info(irq, mask); 229 set_native_irq_info(irq, mask);
146} 230}
147#endif // CONFIG_PCI_MSI
148 231
149#else // CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE 232#endif /* CONFIG_PCI_MSI */
233
234#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
235
236static inline void move_irq(int irq)
237{
238}
239
240static inline void move_native_irq(int irq)
241{
242}
243
244static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
245{
246}
150 247
151#define move_irq(x)
152#define move_native_irq(x)
153#define set_pending_irq(x,y)
154static inline void set_irq_info(int irq, cpumask_t mask) 248static inline void set_irq_info(int irq, cpumask_t mask)
155{ 249{
156 set_native_irq_info(irq, mask); 250 set_native_irq_info(irq, mask);
157} 251}
158 252
159#endif // CONFIG_GENERIC_PENDING_IRQ 253#endif /* CONFIG_GENERIC_PENDING_IRQ */
160 254
161#else // CONFIG_SMP 255#else /* CONFIG_SMP */
162 256
163#define move_irq(x) 257#define move_irq(x)
164#define move_native_irq(x) 258#define move_native_irq(x)
165 259
166#endif // CONFIG_SMP 260#endif /* CONFIG_SMP */
167 261
168#ifdef CONFIG_IRQBALANCE 262#ifdef CONFIG_IRQBALANCE
169extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); 263extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
@@ -173,32 +267,138 @@ static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
173} 267}
174#endif 268#endif
175 269
270#ifdef CONFIG_AUTO_IRQ_AFFINITY
271extern int select_smp_affinity(unsigned int irq);
272#else
273static inline int select_smp_affinity(unsigned int irq)
274{
275 return 1;
276}
277#endif
278
176extern int no_irq_affinity; 279extern int no_irq_affinity;
177extern int noirqdebug_setup(char *str);
178 280
179extern fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, 281/* Handle irq action chains: */
180 struct irqaction *action); 282extern int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
283 struct irqaction *action);
284
285/*
286 * Built-in IRQ handlers for various IRQ types,
287 * callable via desc->chip->handle_irq()
288 */
289extern void fastcall
290handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs);
291extern void fastcall
292handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc,
293 struct pt_regs *regs);
294extern void fastcall
295handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs);
296extern void fastcall
297handle_simple_irq(unsigned int irq, struct irq_desc *desc,
298 struct pt_regs *regs);
299extern void fastcall
300handle_percpu_irq(unsigned int irq, struct irq_desc *desc,
301 struct pt_regs *regs);
302extern void fastcall
303handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs);
304
305/*
306 * Get a descriptive string for the highlevel handler, for
307 * /proc/interrupts output:
308 */
309extern const char *
310handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *,
311 struct pt_regs *));
312
313/*
314 * Monolithic do_IRQ implementation.
315 * (is an explicit fastcall, because i386 4KSTACKS calls it from assembly)
316 */
181extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); 317extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
182extern void note_interrupt(unsigned int irq, irq_desc_t *desc,
183 int action_ret, struct pt_regs *regs);
184extern int can_request_irq(unsigned int irq, unsigned long irqflags);
185 318
319/*
320 * Architectures call this to let the generic IRQ layer
321 * handle an interrupt. If the descriptor is attached to an
322 * irqchip-style controller then we call the ->handle_irq() handler,
323 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
324 */
325static inline void generic_handle_irq(unsigned int irq, struct pt_regs *regs)
326{
327 struct irq_desc *desc = irq_desc + irq;
328
329 if (likely(desc->handle_irq))
330 desc->handle_irq(irq, desc, regs);
331 else
332 __do_IRQ(irq, regs);
333}
334
335/* Handling of unhandled and spurious interrupts: */
336extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
337 int action_ret, struct pt_regs *regs);
338
339/* Resending of interrupts :*/
340void check_irq_resend(struct irq_desc *desc, unsigned int irq);
341
342/* Initialize /proc/irq/ */
186extern void init_irq_proc(void); 343extern void init_irq_proc(void);
187 344
188#ifdef CONFIG_AUTO_IRQ_AFFINITY 345/* Enable/disable irq debugging output: */
189extern int select_smp_affinity(unsigned int irq); 346extern int noirqdebug_setup(char *str);
190#else 347
191static inline int 348/* Checks whether the interrupt can be requested by request_irq(): */
192select_smp_affinity(unsigned int irq) 349extern int can_request_irq(unsigned int irq, unsigned long irqflags);
350
351/* Dummy irq-chip implementation: */
352extern struct irq_chip no_irq_chip;
353
354extern void
355set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
356 void fastcall (*handle)(unsigned int,
357 struct irq_desc *,
358 struct pt_regs *));
359extern void
360__set_irq_handler(unsigned int irq,
361 void fastcall (*handle)(unsigned int, struct irq_desc *,
362 struct pt_regs *),
363 int is_chained);
364
365/*
366 * Set a highlevel flow handler for a given IRQ:
367 */
368static inline void
369set_irq_handler(unsigned int irq,
370 void fastcall (*handle)(unsigned int, struct irq_desc *,
371 struct pt_regs *))
193{ 372{
194 return 1; 373 __set_irq_handler(irq, handle, 0);
195} 374}
196#endif
197 375
198#endif 376/*
377 * Set a highlevel chained flow handler for a given IRQ.
378 * (a chained handler is automatically enabled and set to
379 * IRQ_NOREQUEST and IRQ_NOPROBE)
380 */
381static inline void
382set_irq_chained_handler(unsigned int irq,
383 void fastcall (*handle)(unsigned int, struct irq_desc *,
384 struct pt_regs *))
385{
386 __set_irq_handler(irq, handle, 1);
387}
199 388
200extern hw_irq_controller no_irq_type; /* needed in every arch ? */ 389/* Set/get chip/data for an IRQ: */
201 390
202#endif 391extern int set_irq_chip(unsigned int irq, struct irq_chip *chip);
392extern int set_irq_data(unsigned int irq, void *data);
393extern int set_irq_chip_data(unsigned int irq, void *data);
394extern int set_irq_type(unsigned int irq, unsigned int type);
395
396#define get_irq_chip(irq) (irq_desc[irq].chip)
397#define get_irq_chip_data(irq) (irq_desc[irq].chip_data)
398#define get_irq_data(irq) (irq_desc[irq].handler_data)
399
400#endif /* CONFIG_GENERIC_HARDIRQS */
401
402#endif /* !CONFIG_S390 */
203 403
204#endif /* __irq_h */ 404#endif /* _LINUX_IRQ_H */
diff --git a/include/linux/isdn/tpam.h b/include/linux/isdn/tpam.h
deleted file mode 100644
index d18dd0dc570d..000000000000
--- a/include/linux/isdn/tpam.h
+++ /dev/null
@@ -1,55 +0,0 @@
1/* $Id: tpam.h,v 1.1.2.1 2001/06/08 08:23:46 kai Exp $
2 *
3 * Turbo PAM ISDN driver for Linux. (Kernel Driver)
4 *
5 * Copyright 2001 Stelian Pop <stelian.pop@fr.alcove.com>, Alcôve
6 *
7 * For all support questions please contact: <support@auvertech.fr>
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 as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#ifndef _TPAM_H_
26#define _TPAM_H_
27
28#include <linux/types.h>
29
30/* IOCTL commands */
31#define TPAM_CMD_DSPLOAD 0x0001
32#define TPAM_CMD_DSPSAVE 0x0002
33#define TPAM_CMD_DSPRUN 0x0003
34#define TPAM_CMD_LOOPMODEON 0x0004
35#define TPAM_CMD_LOOPMODEOFF 0x0005
36
37/* addresses of debug information zones on board */
38#define TPAM_TRAPAUDIT_REGISTER 0x005493e4
39#define TPAM_NCOAUDIT_REGISTER 0x00500000
40#define TPAM_MSGAUDIT_REGISTER 0x008E30F0
41
42/* length of debug information zones on board */
43#define TPAM_TRAPAUDIT_LENGTH 10000
44#define TPAM_NCOAUDIT_LENGTH 300000
45#define TPAM_NCOAUDIT_COUNT 30
46#define TPAM_MSGAUDIT_LENGTH 60000
47
48/* IOCTL load/save parameter */
49typedef struct tpam_dsp_ioctl {
50 __u32 address; /* address to load/save data */
51 __u32 data_len; /* size of data to be loaded/saved */
52 __u8 data[0]; /* data */
53} tpam_dsp_ioctl;
54
55#endif /* _TPAM_H_ */
diff --git a/include/linux/jffs2.h b/include/linux/jffs2.h
index c6f70660b371..c9c760700bc3 100644
--- a/include/linux/jffs2.h
+++ b/include/linux/jffs2.h
@@ -186,6 +186,7 @@ struct jffs2_raw_xref
186 jint32_t hdr_crc; 186 jint32_t hdr_crc;
187 jint32_t ino; /* inode number */ 187 jint32_t ino; /* inode number */
188 jint32_t xid; /* XATTR identifier number */ 188 jint32_t xid; /* XATTR identifier number */
189 jint32_t xseqno; /* xref sequencial number */
189 jint32_t node_crc; 190 jint32_t node_crc;
190} __attribute__((packed)); 191} __attribute__((packed));
191 192
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index 4eb851ece080..efe0ee4cc80b 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -155,10 +155,8 @@ static inline void con_schedule_flip(struct tty_struct *t)
155{ 155{
156 unsigned long flags; 156 unsigned long flags;
157 spin_lock_irqsave(&t->buf.lock, flags); 157 spin_lock_irqsave(&t->buf.lock, flags);
158 if (t->buf.tail != NULL) { 158 if (t->buf.tail != NULL)
159 t->buf.tail->active = 0;
160 t->buf.tail->commit = t->buf.tail->used; 159 t->buf.tail->commit = t->buf.tail->used;
161 }
162 spin_unlock_irqrestore(&t->buf.lock, flags); 160 spin_unlock_irqrestore(&t->buf.lock, flags);
163 schedule_work(&t->buf.work); 161 schedule_work(&t->buf.work);
164} 162}
diff --git a/include/linux/key.h b/include/linux/key.h
index e693e729bc92..169f05e4863e 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -177,7 +177,8 @@ struct key {
177/* 177/*
178 * kernel managed key type definition 178 * kernel managed key type definition
179 */ 179 */
180typedef int (*request_key_actor_t)(struct key *key, struct key *authkey, const char *op); 180typedef int (*request_key_actor_t)(struct key *key, struct key *authkey,
181 const char *op, void *aux);
181 182
182struct key_type { 183struct key_type {
183 /* name of the type */ 184 /* name of the type */
@@ -285,6 +286,11 @@ extern struct key *request_key(struct key_type *type,
285 const char *description, 286 const char *description,
286 const char *callout_info); 287 const char *callout_info);
287 288
289extern struct key *request_key_with_auxdata(struct key_type *type,
290 const char *description,
291 const char *callout_info,
292 void *aux);
293
288extern int key_validate(struct key *key); 294extern int key_validate(struct key *key);
289 295
290extern key_ref_t key_create_or_update(key_ref_t keyring, 296extern key_ref_t key_create_or_update(key_ref_t keyring,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 20b1cf527c60..f4284bf89758 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -30,6 +30,7 @@
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <asm/scatterlist.h>
33#include <asm/io.h> 34#include <asm/io.h>
34#include <linux/ata.h> 35#include <linux/ata.h>
35#include <linux/workqueue.h> 36#include <linux/workqueue.h>
@@ -887,6 +888,9 @@ static inline unsigned int ata_tag_internal(unsigned int tag)
887 return tag == ATA_MAX_QUEUE - 1; 888 return tag == ATA_MAX_QUEUE - 1;
888} 889}
889 890
891/*
892 * device helpers
893 */
890static inline unsigned int ata_class_enabled(unsigned int class) 894static inline unsigned int ata_class_enabled(unsigned int class)
891{ 895{
892 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; 896 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI;
@@ -917,6 +921,17 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
917 return ata_class_absent(dev->class); 921 return ata_class_absent(dev->class);
918} 922}
919 923
924/*
925 * port helpers
926 */
927static inline int ata_port_max_devices(const struct ata_port *ap)
928{
929 if (ap->flags & ATA_FLAG_SLAVE_POSS)
930 return 2;
931 return 1;
932}
933
934
920static inline u8 ata_chk_status(struct ata_port *ap) 935static inline u8 ata_chk_status(struct ata_port *ap)
921{ 936{
922 return ap->ops->check_status(ap); 937 return ap->ops->check_status(ap);
diff --git a/include/linux/list.h b/include/linux/list.h
index 37ca31b21bb7..6b74adf5297f 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -4,18 +4,11 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7#include <linux/poison.h>
7#include <linux/prefetch.h> 8#include <linux/prefetch.h>
8#include <asm/system.h> 9#include <asm/system.h>
9 10
10/* 11/*
11 * These are non-NULL pointers that will result in page faults
12 * under normal circumstances, used to verify that nobody uses
13 * non-initialized list entries.
14 */
15#define LIST_POISON1 ((void *) 0x00100100)
16#define LIST_POISON2 ((void *) 0x00200200)
17
18/*
19 * Simple doubly linked list implementation. 12 * Simple doubly linked list implementation.
20 * 13 *
21 * Some of the internal functions ("__xxx") are useful when 14 * Some of the internal functions ("__xxx") are useful when
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 911206386171..218501cfaeb9 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -63,6 +63,76 @@ extern int online_pages(unsigned long, unsigned long);
63/* reasonably generic interface to expand the physical pages in a zone */ 63/* reasonably generic interface to expand the physical pages in a zone */
64extern int __add_pages(struct zone *zone, unsigned long start_pfn, 64extern int __add_pages(struct zone *zone, unsigned long start_pfn,
65 unsigned long nr_pages); 65 unsigned long nr_pages);
66
67#ifdef CONFIG_NUMA
68extern int memory_add_physaddr_to_nid(u64 start);
69#else
70static inline int memory_add_physaddr_to_nid(u64 start)
71{
72 return 0;
73}
74#endif
75
76#ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION
77/*
78 * For supporting node-hotadd, we have to allocate a new pgdat.
79 *
80 * If an arch has generic style NODE_DATA(),
81 * node_data[nid] = kzalloc() works well. But it depends on the architecture.
82 *
83 * In general, generic_alloc_nodedata() is used.
84 * Now, arch_free_nodedata() is just defined for error path of node_hot_add.
85 *
86 */
87extern pg_data_t *arch_alloc_nodedata(int nid);
88extern void arch_free_nodedata(pg_data_t *pgdat);
89extern void arch_refresh_nodedata(int nid, pg_data_t *pgdat);
90
91#else /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */
92
93#define arch_alloc_nodedata(nid) generic_alloc_nodedata(nid)
94#define arch_free_nodedata(pgdat) generic_free_nodedata(pgdat)
95
96#ifdef CONFIG_NUMA
97/*
98 * If ARCH_HAS_NODEDATA_EXTENSION=n, this func is used to allocate pgdat.
99 * XXX: kmalloc_node() can't work well to get new node's memory at this time.
100 * Because, pgdat for the new node is not allocated/initialized yet itself.
101 * To use new node's memory, more consideration will be necessary.
102 */
103#define generic_alloc_nodedata(nid) \
104({ \
105 kzalloc(sizeof(pg_data_t), GFP_KERNEL); \
106})
107/*
108 * This definition is just for error path in node hotadd.
109 * For node hotremove, we have to replace this.
110 */
111#define generic_free_nodedata(pgdat) kfree(pgdat)
112
113extern pg_data_t *node_data[];
114static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
115{
116 node_data[nid] = pgdat;
117}
118
119#else /* !CONFIG_NUMA */
120
121/* never called */
122static inline pg_data_t *generic_alloc_nodedata(int nid)
123{
124 BUG();
125 return NULL;
126}
127static inline void generic_free_nodedata(pg_data_t *pgdat)
128{
129}
130static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
131{
132}
133#endif /* CONFIG_NUMA */
134#endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */
135
66#else /* ! CONFIG_MEMORY_HOTPLUG */ 136#else /* ! CONFIG_MEMORY_HOTPLUG */
67/* 137/*
68 * Stub functions for when hotplug is off 138 * Stub functions for when hotplug is off
@@ -99,7 +169,8 @@ static inline int __remove_pages(struct zone *zone, unsigned long start_pfn,
99 return -ENOSYS; 169 return -ENOSYS;
100} 170}
101 171
102extern int add_memory(u64 start, u64 size); 172extern int add_memory(int nid, u64 start, u64 size);
173extern int arch_add_memory(int nid, u64 start, u64 size);
103extern int remove_memory(u64 start, u64 size); 174extern int remove_memory(u64 start, u64 size);
104 175
105#endif /* __LINUX_MEMORY_HOTPLUG_H */ 176#endif /* __LINUX_MEMORY_HOTPLUG_H */
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 5b584dafb5a6..b03cfb91e228 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -40,7 +40,6 @@ struct miscdevice {
40 struct list_head list; 40 struct list_head list;
41 struct device *dev; 41 struct device *dev;
42 struct class_device *class; 42 struct class_device *class;
43 char devfs_name[64];
44}; 43};
45 44
46extern int misc_register(struct miscdevice * misc); 45extern int misc_register(struct miscdevice * misc);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index a929ea197e48..c41a1299b8cf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1030,13 +1030,20 @@ static inline void vm_stat_account(struct mm_struct *mm,
1030} 1030}
1031#endif /* CONFIG_PROC_FS */ 1031#endif /* CONFIG_PROC_FS */
1032 1032
1033static inline void
1034debug_check_no_locks_freed(const void *from, unsigned long len)
1035{
1036 mutex_debug_check_no_locks_freed(from, len);
1037 rt_mutex_debug_check_no_locks_freed(from, len);
1038}
1039
1033#ifndef CONFIG_DEBUG_PAGEALLOC 1040#ifndef CONFIG_DEBUG_PAGEALLOC
1034static inline void 1041static inline void
1035kernel_map_pages(struct page *page, int numpages, int enable) 1042kernel_map_pages(struct page *page, int numpages, int enable)
1036{ 1043{
1037 if (!PageHighMem(page) && !enable) 1044 if (!PageHighMem(page) && !enable)
1038 mutex_debug_check_no_locks_freed(page_address(page), 1045 debug_check_no_locks_freed(page_address(page),
1039 numpages * PAGE_SIZE); 1046 numpages * PAGE_SIZE);
1040} 1047}
1041#endif 1048#endif
1042 1049
@@ -1065,5 +1072,7 @@ void drop_slab(void);
1065extern int randomize_va_space; 1072extern int randomize_va_space;
1066#endif 1073#endif
1067 1074
1075const char *arch_vma_name(struct vm_area_struct *vma);
1076
1068#endif /* __KERNEL__ */ 1077#endif /* __KERNEL__ */
1069#endif /* _LINUX_MM_H */ 1078#endif /* _LINUX_MM_H */
diff --git a/include/linux/module.h b/include/linux/module.h
index 9ebbb74b7b72..9e9dc7c24d95 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -203,6 +203,15 @@ void *__symbol_get_gpl(const char *symbol);
203#define EXPORT_SYMBOL_GPL_FUTURE(sym) \ 203#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
204 __EXPORT_SYMBOL(sym, "_gpl_future") 204 __EXPORT_SYMBOL(sym, "_gpl_future")
205 205
206
207#ifdef CONFIG_UNUSED_SYMBOLS
208#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
209#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
210#else
211#define EXPORT_UNUSED_SYMBOL(sym)
212#define EXPORT_UNUSED_SYMBOL_GPL(sym)
213#endif
214
206#endif 215#endif
207 216
208struct module_ref 217struct module_ref
@@ -261,6 +270,15 @@ struct module
261 unsigned int num_gpl_syms; 270 unsigned int num_gpl_syms;
262 const unsigned long *gpl_crcs; 271 const unsigned long *gpl_crcs;
263 272
273 /* unused exported symbols. */
274 const struct kernel_symbol *unused_syms;
275 unsigned int num_unused_syms;
276 const unsigned long *unused_crcs;
277 /* GPL-only, unused exported symbols. */
278 const struct kernel_symbol *unused_gpl_syms;
279 unsigned int num_unused_gpl_syms;
280 const unsigned long *unused_gpl_crcs;
281
264 /* symbols that will be GPL-only in the near future. */ 282 /* symbols that will be GPL-only in the near future. */
265 const struct kernel_symbol *gpl_future_syms; 283 const struct kernel_symbol *gpl_future_syms;
266 unsigned int num_gpl_future_syms; 284 unsigned int num_gpl_future_syms;
@@ -456,6 +474,8 @@ void module_remove_driver(struct device_driver *);
456#define EXPORT_SYMBOL(sym) 474#define EXPORT_SYMBOL(sym)
457#define EXPORT_SYMBOL_GPL(sym) 475#define EXPORT_SYMBOL_GPL(sym)
458#define EXPORT_SYMBOL_GPL_FUTURE(sym) 476#define EXPORT_SYMBOL_GPL_FUTURE(sym)
477#define EXPORT_UNUSED_SYMBOL(sym)
478#define EXPORT_UNUSED_SYMBOL_GPL(sym)
459 479
460/* Given an address, look for it in the exception tables. */ 480/* Given an address, look for it in the exception tables. */
461static inline const struct exception_table_entry * 481static inline const struct exception_table_entry *
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 0a1740b2532e..d90b1bb37563 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -335,7 +335,7 @@ extern struct inode_operations nfs_file_inode_operations;
335extern struct inode_operations nfs3_file_inode_operations; 335extern struct inode_operations nfs3_file_inode_operations;
336#endif /* CONFIG_NFS_V3 */ 336#endif /* CONFIG_NFS_V3 */
337extern const struct file_operations nfs_file_operations; 337extern const struct file_operations nfs_file_operations;
338extern struct address_space_operations nfs_file_aops; 338extern const struct address_space_operations nfs_file_aops;
339 339
340static inline struct rpc_cred *nfs_file_cred(struct file *file) 340static inline struct rpc_cred *nfs_file_cred(struct file *file)
341{ 341{
diff --git a/include/linux/node.h b/include/linux/node.h
index 254dc3de650b..81dcec84cd8f 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -26,8 +26,25 @@ struct node {
26 struct sys_device sysdev; 26 struct sys_device sysdev;
27}; 27};
28 28
29extern struct node node_devices[];
30
29extern int register_node(struct node *, int, struct node *); 31extern int register_node(struct node *, int, struct node *);
30extern void unregister_node(struct node *node); 32extern void unregister_node(struct node *node);
33extern int register_one_node(int nid);
34extern void unregister_one_node(int nid);
35#ifdef CONFIG_NUMA
36extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
37extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
38#else
39static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
40{
41 return 0;
42}
43static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
44{
45 return 0;
46}
47#endif
31 48
32#define to_node(sys_device) container_of(sys_device, struct node, sysdev) 49#define to_node(sys_device) container_of(sys_device, struct node, sysdev)
33 50
diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h
new file mode 100644
index 000000000000..135742cfada5
--- /dev/null
+++ b/include/linux/nsc_gpio.h
@@ -0,0 +1,42 @@
1/**
2 nsc_gpio.c
3
4 National Semiconductor GPIO common access methods.
5
6 struct nsc_gpio_ops abstracts the low-level access
7 operations for the GPIO units on 2 NSC chip families; the GEODE
8 integrated CPU, and the PC-8736[03456] integrated PC-peripheral
9 chips.
10
11 The GPIO units on these chips have the same pin architecture, but
12 the access methods differ. Thus, scx200_gpio and pc8736x_gpio
13 implement their own versions of these routines; and use the common
14 file-operations routines implemented in nsc_gpio module.
15
16 Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com>
17
18 NB: this work was tested on the Geode SC-1100 and PC-87366 chips.
19 NSC sold the GEODE line to AMD, and the PC-8736x line to Winbond.
20*/
21
22struct nsc_gpio_ops {
23 struct module* owner;
24 u32 (*gpio_config) (unsigned iminor, u32 mask, u32 bits);
25 void (*gpio_dump) (struct nsc_gpio_ops *amp, unsigned iminor);
26 int (*gpio_get) (unsigned iminor);
27 void (*gpio_set) (unsigned iminor, int state);
28 void (*gpio_set_high)(unsigned iminor);
29 void (*gpio_set_low) (unsigned iminor);
30 void (*gpio_change) (unsigned iminor);
31 int (*gpio_current) (unsigned iminor);
32 struct device* dev; /* for dev_dbg() support, set in init */
33};
34
35extern ssize_t nsc_gpio_write(struct file *file, const char __user *data,
36 size_t len, loff_t *ppos);
37
38extern ssize_t nsc_gpio_read(struct file *file, char __user *buf,
39 size_t len, loff_t *ppos);
40
41extern void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index);
42
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 62a8c22f5f60..983fca251b25 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -404,8 +404,8 @@ int pcibios_enable_device(struct pci_dev *, int mask);
404char *pcibios_setup (char *str); 404char *pcibios_setup (char *str);
405 405
406/* Used only when drivers/pci/setup.c is used */ 406/* Used only when drivers/pci/setup.c is used */
407void pcibios_align_resource(void *, struct resource *, 407void pcibios_align_resource(void *, struct resource *, resource_size_t,
408 unsigned long, unsigned long); 408 resource_size_t);
409void pcibios_update_irq(struct pci_dev *, int irq); 409void pcibios_update_irq(struct pci_dev *, int irq);
410 410
411/* Generic PCI functions used internally */ 411/* Generic PCI functions used internally */
@@ -532,10 +532,10 @@ void pci_release_region(struct pci_dev *, int);
532 532
533/* drivers/pci/bus.c */ 533/* drivers/pci/bus.c */
534int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, 534int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
535 unsigned long size, unsigned long align, 535 resource_size_t size, resource_size_t align,
536 unsigned long min, unsigned int type_mask, 536 resource_size_t min, unsigned int type_mask,
537 void (*alignf)(void *, struct resource *, 537 void (*alignf)(void *, struct resource *,
538 unsigned long, unsigned long), 538 resource_size_t, resource_size_t),
539 void *alignf_data); 539 void *alignf_data);
540void pci_enable_bridges(struct pci_bus *bus); 540void pci_enable_bridges(struct pci_bus *bus);
541 541
@@ -730,7 +730,8 @@ static inline char *pci_name(struct pci_dev *pdev)
730 */ 730 */
731#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER 731#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER
732static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, 732static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
733 const struct resource *rsrc, u64 *start, u64 *end) 733 const struct resource *rsrc, resource_size_t *start,
734 resource_size_t *end)
734{ 735{
735 *start = rsrc->start; 736 *start = rsrc->start;
736 *end = rsrc->end; 737 *end = rsrc->end;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c2fd2d19938b..9ae6b1a75366 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1202,6 +1202,7 @@
1202#define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF 1202#define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF
1203#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2 0x03F6 1203#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2 0x03F6
1204#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3 0x03F7 1204#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3 0x03F7
1205#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE 0x0448
1205#define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450 1206#define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450
1206#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451 1207#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451
1207#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452 1208#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452
@@ -2170,7 +2171,6 @@
2170#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 2171#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815
2171#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e 2172#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e
2172#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 2173#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850
2173#define PCI_DEVICE_ID_INTEL_GD31244 0x3200
2174#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 2174#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2175#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 2175#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2176#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 2176#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
diff --git a/include/linux/plist.h b/include/linux/plist.h
new file mode 100644
index 000000000000..b95818a037ad
--- /dev/null
+++ b/include/linux/plist.h
@@ -0,0 +1,248 @@
1/*
2 * Descending-priority-sorted double-linked list
3 *
4 * (C) 2002-2003 Intel Corp
5 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>.
6 *
7 * 2001-2005 (c) MontaVista Software, Inc.
8 * Daniel Walker <dwalker@mvista.com>
9 *
10 * (C) 2005 Thomas Gleixner <tglx@linutronix.de>
11 *
12 * Simplifications of the original code by
13 * Oleg Nesterov <oleg@tv-sign.ru>
14 *
15 * Licensed under the FSF's GNU Public License v2 or later.
16 *
17 * Based on simple lists (include/linux/list.h).
18 *
19 * This is a priority-sorted list of nodes; each node has a
20 * priority from INT_MIN (highest) to INT_MAX (lowest).
21 *
22 * Addition is O(K), removal is O(1), change of priority of a node is
23 * O(K) and K is the number of RT priority levels used in the system.
24 * (1 <= K <= 99)
25 *
26 * This list is really a list of lists:
27 *
28 * - The tier 1 list is the prio_list, different priority nodes.
29 *
30 * - The tier 2 list is the node_list, serialized nodes.
31 *
32 * Simple ASCII art explanation:
33 *
34 * |HEAD |
35 * | |
36 * |prio_list.prev|<------------------------------------|
37 * |prio_list.next|<->|pl|<->|pl|<--------------->|pl|<-|
38 * |10 | |10| |21| |21| |21| |40| (prio)
39 * | | | | | | | | | | | |
40 * | | | | | | | | | | | |
41 * |node_list.next|<->|nl|<->|nl|<->|nl|<->|nl|<->|nl|<-|
42 * |node_list.prev|<------------------------------------|
43 *
44 * The nodes on the prio_list list are sorted by priority to simplify
45 * the insertion of new nodes. There are no nodes with duplicate
46 * priorites on the list.
47 *
48 * The nodes on the node_list is ordered by priority and can contain
49 * entries which have the same priority. Those entries are ordered
50 * FIFO
51 *
52 * Addition means: look for the prio_list node in the prio_list
53 * for the priority of the node and insert it before the node_list
54 * entry of the next prio_list node. If it is the first node of
55 * that priority, add it to the prio_list in the right position and
56 * insert it into the serialized node_list list
57 *
58 * Removal means remove it from the node_list and remove it from
59 * the prio_list if the node_list list_head is non empty. In case
60 * of removal from the prio_list it must be checked whether other
61 * entries of the same priority are on the list or not. If there
62 * is another entry of the same priority then this entry has to
63 * replace the removed entry on the prio_list. If the entry which
64 * is removed is the only entry of this priority then a simple
65 * remove from both list is sufficient.
66 *
67 * INT_MIN is the highest priority, 0 is the medium highest, INT_MAX
68 * is lowest priority.
69 *
70 * No locking is done, up to the caller.
71 *
72 */
73#ifndef _LINUX_PLIST_H_
74#define _LINUX_PLIST_H_
75
76#include <linux/kernel.h>
77#include <linux/list.h>
78#include <linux/spinlock_types.h>
79
80struct plist_head {
81 struct list_head prio_list;
82 struct list_head node_list;
83#ifdef CONFIG_DEBUG_PI_LIST
84 spinlock_t *lock;
85#endif
86};
87
88struct plist_node {
89 int prio;
90 struct plist_head plist;
91};
92
93#ifdef CONFIG_DEBUG_PI_LIST
94# define PLIST_HEAD_LOCK_INIT(_lock) .lock = _lock
95#else
96# define PLIST_HEAD_LOCK_INIT(_lock)
97#endif
98
99/**
100 * #PLIST_HEAD_INIT - static struct plist_head initializer
101 *
102 * @head: struct plist_head variable name
103 */
104#define PLIST_HEAD_INIT(head, _lock) \
105{ \
106 .prio_list = LIST_HEAD_INIT((head).prio_list), \
107 .node_list = LIST_HEAD_INIT((head).node_list), \
108 PLIST_HEAD_LOCK_INIT(&(_lock)) \
109}
110
111/**
112 * #PLIST_NODE_INIT - static struct plist_node initializer
113 *
114 * @node: struct plist_node variable name
115 * @__prio: initial node priority
116 */
117#define PLIST_NODE_INIT(node, __prio) \
118{ \
119 .prio = (__prio), \
120 .plist = PLIST_HEAD_INIT((node).plist, NULL), \
121}
122
123/**
124 * plist_head_init - dynamic struct plist_head initializer
125 *
126 * @head: &struct plist_head pointer
127 */
128static inline void
129plist_head_init(struct plist_head *head, spinlock_t *lock)
130{
131 INIT_LIST_HEAD(&head->prio_list);
132 INIT_LIST_HEAD(&head->node_list);
133#ifdef CONFIG_DEBUG_PI_LIST
134 head->lock = lock;
135#endif
136}
137
138/**
139 * plist_node_init - Dynamic struct plist_node initializer
140 *
141 * @node: &struct plist_node pointer
142 * @prio: initial node priority
143 */
144static inline void plist_node_init(struct plist_node *node, int prio)
145{
146 node->prio = prio;
147 plist_head_init(&node->plist, NULL);
148}
149
150extern void plist_add(struct plist_node *node, struct plist_head *head);
151extern void plist_del(struct plist_node *node, struct plist_head *head);
152
153/**
154 * plist_for_each - iterate over the plist
155 *
156 * @pos1: the type * to use as a loop counter.
157 * @head: the head for your list.
158 */
159#define plist_for_each(pos, head) \
160 list_for_each_entry(pos, &(head)->node_list, plist.node_list)
161
162/**
163 * plist_for_each_entry_safe - iterate over a plist of given type safe
164 * against removal of list entry
165 *
166 * @pos1: the type * to use as a loop counter.
167 * @n1: another type * to use as temporary storage
168 * @head: the head for your list.
169 */
170#define plist_for_each_safe(pos, n, head) \
171 list_for_each_entry_safe(pos, n, &(head)->node_list, plist.node_list)
172
173/**
174 * plist_for_each_entry - iterate over list of given type
175 *
176 * @pos: the type * to use as a loop counter.
177 * @head: the head for your list.
178 * @member: the name of the list_struct within the struct.
179 */
180#define plist_for_each_entry(pos, head, mem) \
181 list_for_each_entry(pos, &(head)->node_list, mem.plist.node_list)
182
183/**
184 * plist_for_each_entry_safe - iterate over list of given type safe against
185 * removal of list entry
186 *
187 * @pos: the type * to use as a loop counter.
188 * @n: another type * to use as temporary storage
189 * @head: the head for your list.
190 * @m: the name of the list_struct within the struct.
191 */
192#define plist_for_each_entry_safe(pos, n, head, m) \
193 list_for_each_entry_safe(pos, n, &(head)->node_list, m.plist.node_list)
194
195/**
196 * plist_head_empty - return !0 if a plist_head is empty
197 *
198 * @head: &struct plist_head pointer
199 */
200static inline int plist_head_empty(const struct plist_head *head)
201{
202 return list_empty(&head->node_list);
203}
204
205/**
206 * plist_node_empty - return !0 if plist_node is not on a list
207 *
208 * @node: &struct plist_node pointer
209 */
210static inline int plist_node_empty(const struct plist_node *node)
211{
212 return plist_head_empty(&node->plist);
213}
214
215/* All functions below assume the plist_head is not empty. */
216
217/**
218 * plist_first_entry - get the struct for the first entry
219 *
220 * @ptr: the &struct plist_head pointer.
221 * @type: the type of the struct this is embedded in.
222 * @member: the name of the list_struct within the struct.
223 */
224#ifdef CONFIG_DEBUG_PI_LIST
225# define plist_first_entry(head, type, member) \
226({ \
227 WARN_ON(plist_head_empty(head)); \
228 container_of(plist_first(head), type, member); \
229})
230#else
231# define plist_first_entry(head, type, member) \
232 container_of(plist_first(head), type, member)
233#endif
234
235/**
236 * plist_first - return the first node (and thus, highest priority)
237 *
238 * @head: the &struct plist_head pointer
239 *
240 * Assumes the plist is _not_ empty.
241 */
242static inline struct plist_node* plist_first(const struct plist_head *head)
243{
244 return list_entry(head->node_list.next,
245 struct plist_node, plist.node_list);
246}
247
248#endif
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 93b0959eb40f..ab8a8dd8d64c 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -389,7 +389,8 @@ int pnp_start_dev(struct pnp_dev *dev);
389int pnp_stop_dev(struct pnp_dev *dev); 389int pnp_stop_dev(struct pnp_dev *dev);
390int pnp_activate_dev(struct pnp_dev *dev); 390int pnp_activate_dev(struct pnp_dev *dev);
391int pnp_disable_dev(struct pnp_dev *dev); 391int pnp_disable_dev(struct pnp_dev *dev);
392void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size); 392void pnp_resource_change(struct resource *resource, resource_size_t start,
393 resource_size_t size);
393 394
394/* protocol helpers */ 395/* protocol helpers */
395int pnp_is_active(struct pnp_dev * dev); 396int pnp_is_active(struct pnp_dev * dev);
@@ -434,7 +435,9 @@ static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
434static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } 435static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
435static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } 436static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
436static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } 437static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
437static inline void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) { } 438static inline void pnp_resource_change(struct resource *resource,
439 resource_size_t start,
440 resource_size_t size) { }
438 441
439/* protocol helpers */ 442/* protocol helpers */
440static inline int pnp_is_active(struct pnp_dev * dev) { return 0; } 443static inline int pnp_is_active(struct pnp_dev * dev) { return 0; }
diff --git a/include/linux/poison.h b/include/linux/poison.h
new file mode 100644
index 000000000000..a5347c02432e
--- /dev/null
+++ b/include/linux/poison.h
@@ -0,0 +1,58 @@
1#ifndef _LINUX_POISON_H
2#define _LINUX_POISON_H
3
4/********** include/linux/list.h **********/
5/*
6 * These are non-NULL pointers that will result in page faults
7 * under normal circumstances, used to verify that nobody uses
8 * non-initialized list entries.
9 */
10#define LIST_POISON1 ((void *) 0x00100100)
11#define LIST_POISON2 ((void *) 0x00200200)
12
13/********** mm/slab.c **********/
14/*
15 * Magic nums for obj red zoning.
16 * Placed in the first word before and the first word after an obj.
17 */
18#define RED_INACTIVE 0x5A2CF071UL /* when obj is inactive */
19#define RED_ACTIVE 0x170FC2A5UL /* when obj is active */
20
21/* ...and for poisoning */
22#define POISON_INUSE 0x5a /* for use-uninitialised poisoning */
23#define POISON_FREE 0x6b /* for use-after-free poisoning */
24#define POISON_END 0xa5 /* end-byte of poisoning */
25
26/********** arch/$ARCH/mm/init.c **********/
27#define POISON_FREE_INITMEM 0xcc
28
29/********** arch/x86_64/mm/init.c **********/
30#define POISON_FREE_INITDATA 0xba
31
32/********** arch/ia64/hp/common/sba_iommu.c **********/
33/*
34 * arch/ia64/hp/common/sba_iommu.c uses a 16-byte poison string with a
35 * value of "SBAIOMMU POISON\0" for spill-over poisoning.
36 */
37
38/********** fs/jbd/journal.c **********/
39#define JBD_POISON_FREE 0x5b
40
41/********** drivers/base/dmapool.c **********/
42#define POOL_POISON_FREED 0xa7 /* !inuse */
43#define POOL_POISON_ALLOCATED 0xa9 /* !initted */
44
45/********** drivers/atm/ **********/
46#define ATM_POISON_FREE 0x12
47
48/********** kernel/mutexes **********/
49#define MUTEX_DEBUG_INIT 0x11
50#define MUTEX_DEBUG_FREE 0x22
51
52/********** security/ **********/
53#define KEY_DESTROY 0xbd
54
55/********** sound/oss/ **********/
56#define OSS_POISON_FREE 0xAB
57
58#endif
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 6312758393b6..48dfe00070c7 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -258,6 +258,7 @@ extern void rcu_init(void);
258extern void rcu_check_callbacks(int cpu, int user); 258extern void rcu_check_callbacks(int cpu, int user);
259extern void rcu_restart_cpu(int cpu); 259extern void rcu_restart_cpu(int cpu);
260extern long rcu_batches_completed(void); 260extern long rcu_batches_completed(void);
261extern long rcu_batches_completed_bh(void);
261 262
262/* Exported interfaces */ 263/* Exported interfaces */
263extern void FASTCALL(call_rcu(struct rcu_head *head, 264extern void FASTCALL(call_rcu(struct rcu_head *head,
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 5676c4210e2c..daa2d83cefe8 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1973,7 +1973,7 @@ void reiserfs_unmap_buffer(struct buffer_head *);
1973/* file.c */ 1973/* file.c */
1974extern struct inode_operations reiserfs_file_inode_operations; 1974extern struct inode_operations reiserfs_file_inode_operations;
1975extern const struct file_operations reiserfs_file_operations; 1975extern const struct file_operations reiserfs_file_operations;
1976extern struct address_space_operations reiserfs_address_space_operations; 1976extern const struct address_space_operations reiserfs_address_space_operations;
1977 1977
1978/* fix_nodes.c */ 1978/* fix_nodes.c */
1979 1979
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
new file mode 100644
index 000000000000..fa4a3b82ba70
--- /dev/null
+++ b/include/linux/rtmutex.h
@@ -0,0 +1,117 @@
1/*
2 * RT Mutexes: blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner:
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 *
9 * This file contains the public data structure and API definitions.
10 */
11
12#ifndef __LINUX_RT_MUTEX_H
13#define __LINUX_RT_MUTEX_H
14
15#include <linux/linkage.h>
16#include <linux/plist.h>
17#include <linux/spinlock_types.h>
18
19/*
20 * The rt_mutex structure
21 *
22 * @wait_lock: spinlock to protect the structure
23 * @wait_list: pilist head to enqueue waiters in priority order
24 * @owner: the mutex owner
25 */
26struct rt_mutex {
27 spinlock_t wait_lock;
28 struct plist_head wait_list;
29 struct task_struct *owner;
30#ifdef CONFIG_DEBUG_RT_MUTEXES
31 int save_state;
32 struct list_head held_list_entry;
33 unsigned long acquire_ip;
34 const char *name, *file;
35 int line;
36 void *magic;
37#endif
38};
39
40struct rt_mutex_waiter;
41struct hrtimer_sleeper;
42
43#ifdef CONFIG_DEBUG_RT_MUTEXES
44 extern int rt_mutex_debug_check_no_locks_freed(const void *from,
45 unsigned long len);
46 extern void rt_mutex_debug_check_no_locks_held(struct task_struct *task);
47#else
48 static inline int rt_mutex_debug_check_no_locks_freed(const void *from,
49 unsigned long len)
50 {
51 return 0;
52 }
53# define rt_mutex_debug_check_no_locks_held(task) do { } while (0)
54#endif
55
56#ifdef CONFIG_DEBUG_RT_MUTEXES
57# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \
58 , .name = #mutexname, .file = __FILE__, .line = __LINE__
59# define rt_mutex_init(mutex) __rt_mutex_init(mutex, __FUNCTION__)
60 extern void rt_mutex_debug_task_free(struct task_struct *tsk);
61#else
62# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname)
63# define rt_mutex_init(mutex) __rt_mutex_init(mutex, NULL)
64# define rt_mutex_debug_task_free(t) do { } while (0)
65#endif
66
67#define __RT_MUTEX_INITIALIZER(mutexname) \
68 { .wait_lock = SPIN_LOCK_UNLOCKED \
69 , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \
70 , .owner = NULL \
71 __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
72
73#define DEFINE_RT_MUTEX(mutexname) \
74 struct rt_mutex mutexname = __RT_MUTEX_INITIALIZER(mutexname)
75
76/***
77 * rt_mutex_is_locked - is the mutex locked
78 * @lock: the mutex to be queried
79 *
80 * Returns 1 if the mutex is locked, 0 if unlocked.
81 */
82static inline int rt_mutex_is_locked(struct rt_mutex *lock)
83{
84 return lock->owner != NULL;
85}
86
87extern void __rt_mutex_init(struct rt_mutex *lock, const char *name);
88extern void rt_mutex_destroy(struct rt_mutex *lock);
89
90extern void rt_mutex_lock(struct rt_mutex *lock);
91extern int rt_mutex_lock_interruptible(struct rt_mutex *lock,
92 int detect_deadlock);
93extern int rt_mutex_timed_lock(struct rt_mutex *lock,
94 struct hrtimer_sleeper *timeout,
95 int detect_deadlock);
96
97extern int rt_mutex_trylock(struct rt_mutex *lock);
98
99extern void rt_mutex_unlock(struct rt_mutex *lock);
100
101#ifdef CONFIG_DEBUG_RT_MUTEXES
102# define INIT_RT_MUTEX_DEBUG(tsk) \
103 .held_list_head = LIST_HEAD_INIT(tsk.held_list_head), \
104 .held_list_lock = SPIN_LOCK_UNLOCKED
105#else
106# define INIT_RT_MUTEX_DEBUG(tsk)
107#endif
108
109#ifdef CONFIG_RT_MUTEXES
110# define INIT_RT_MUTEXES(tsk) \
111 .pi_waiters = PLIST_HEAD_INIT(tsk.pi_waiters, tsk.pi_lock), \
112 INIT_RT_MUTEX_DEBUG(tsk)
113#else
114# define INIT_RT_MUTEXES(tsk)
115#endif
116
117#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 122a25c1b997..821f0481ebe1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -73,6 +73,7 @@ struct sched_param {
73#include <linux/seccomp.h> 73#include <linux/seccomp.h>
74#include <linux/rcupdate.h> 74#include <linux/rcupdate.h>
75#include <linux/futex.h> 75#include <linux/futex.h>
76#include <linux/rtmutex.h>
76 77
77#include <linux/time.h> 78#include <linux/time.h>
78#include <linux/param.h> 79#include <linux/param.h>
@@ -83,6 +84,7 @@ struct sched_param {
83#include <asm/processor.h> 84#include <asm/processor.h>
84 85
85struct exec_domain; 86struct exec_domain;
87struct futex_pi_state;
86 88
87/* 89/*
88 * List of flags we want to share for kernel threads, 90 * List of flags we want to share for kernel threads,
@@ -123,6 +125,7 @@ extern unsigned long nr_running(void);
123extern unsigned long nr_uninterruptible(void); 125extern unsigned long nr_uninterruptible(void);
124extern unsigned long nr_active(void); 126extern unsigned long nr_active(void);
125extern unsigned long nr_iowait(void); 127extern unsigned long nr_iowait(void);
128extern unsigned long weighted_cpuload(const int cpu);
126 129
127 130
128/* 131/*
@@ -494,8 +497,11 @@ struct signal_struct {
494 497
495#define MAX_PRIO (MAX_RT_PRIO + 40) 498#define MAX_PRIO (MAX_RT_PRIO + 40)
496 499
497#define rt_task(p) (unlikely((p)->prio < MAX_RT_PRIO)) 500#define rt_prio(prio) unlikely((prio) < MAX_RT_PRIO)
501#define rt_task(p) rt_prio((p)->prio)
498#define batch_task(p) (unlikely((p)->policy == SCHED_BATCH)) 502#define batch_task(p) (unlikely((p)->policy == SCHED_BATCH))
503#define has_rt_policy(p) \
504 unlikely((p)->policy != SCHED_NORMAL && (p)->policy != SCHED_BATCH)
499 505
500/* 506/*
501 * Some day this will be a full-fledged user tracking system.. 507 * Some day this will be a full-fledged user tracking system..
@@ -558,9 +564,9 @@ enum idle_type
558/* 564/*
559 * sched-domains (multiprocessor balancing) declarations: 565 * sched-domains (multiprocessor balancing) declarations:
560 */ 566 */
561#ifdef CONFIG_SMP
562#define SCHED_LOAD_SCALE 128UL /* increase resolution of load */ 567#define SCHED_LOAD_SCALE 128UL /* increase resolution of load */
563 568
569#ifdef CONFIG_SMP
564#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ 570#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */
565#define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */ 571#define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */
566#define SD_BALANCE_EXEC 4 /* Balance on exec */ 572#define SD_BALANCE_EXEC 4 /* Balance on exec */
@@ -569,6 +575,11 @@ enum idle_type
569#define SD_WAKE_AFFINE 32 /* Wake task to waking CPU */ 575#define SD_WAKE_AFFINE 32 /* Wake task to waking CPU */
570#define SD_WAKE_BALANCE 64 /* Perform balancing at task wakeup */ 576#define SD_WAKE_BALANCE 64 /* Perform balancing at task wakeup */
571#define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */ 577#define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */
578#define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */
579
580#define BALANCE_FOR_POWER ((sched_mc_power_savings || sched_smt_power_savings) \
581 ? SD_POWERSAVINGS_BALANCE : 0)
582
572 583
573struct sched_group { 584struct sched_group {
574 struct sched_group *next; /* Must be a circular list */ 585 struct sched_group *next; /* Must be a circular list */
@@ -638,7 +649,7 @@ struct sched_domain {
638#endif 649#endif
639}; 650};
640 651
641extern void partition_sched_domains(cpumask_t *partition1, 652extern int partition_sched_domains(cpumask_t *partition1,
642 cpumask_t *partition2); 653 cpumask_t *partition2);
643 654
644/* 655/*
@@ -713,10 +724,13 @@ struct task_struct {
713 724
714 int lock_depth; /* BKL lock depth */ 725 int lock_depth; /* BKL lock depth */
715 726
716#if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) 727#ifdef CONFIG_SMP
728#ifdef __ARCH_WANT_UNLOCKED_CTXSW
717 int oncpu; 729 int oncpu;
718#endif 730#endif
719 int prio, static_prio; 731#endif
732 int load_weight; /* for niceness load balancing purposes */
733 int prio, static_prio, normal_prio;
720 struct list_head run_list; 734 struct list_head run_list;
721 prio_array_t *array; 735 prio_array_t *array;
722 736
@@ -843,6 +857,20 @@ struct task_struct {
843/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */ 857/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
844 spinlock_t alloc_lock; 858 spinlock_t alloc_lock;
845 859
860 /* Protection of the PI data structures: */
861 spinlock_t pi_lock;
862
863#ifdef CONFIG_RT_MUTEXES
864 /* PI waiters blocked on a rt_mutex held by this task */
865 struct plist_head pi_waiters;
866 /* Deadlock detection and priority inheritance handling */
867 struct rt_mutex_waiter *pi_blocked_on;
868# ifdef CONFIG_DEBUG_RT_MUTEXES
869 spinlock_t held_list_lock;
870 struct list_head held_list_head;
871# endif
872#endif
873
846#ifdef CONFIG_DEBUG_MUTEXES 874#ifdef CONFIG_DEBUG_MUTEXES
847 /* mutex deadlock detection */ 875 /* mutex deadlock detection */
848 struct mutex_waiter *blocked_on; 876 struct mutex_waiter *blocked_on;
@@ -888,6 +916,8 @@ struct task_struct {
888#ifdef CONFIG_COMPAT 916#ifdef CONFIG_COMPAT
889 struct compat_robust_list_head __user *compat_robust_list; 917 struct compat_robust_list_head __user *compat_robust_list;
890#endif 918#endif
919 struct list_head pi_state_list;
920 struct futex_pi_state *pi_state_cache;
891 921
892 atomic_t fs_excl; /* holding fs exclusive resources */ 922 atomic_t fs_excl; /* holding fs exclusive resources */
893 struct rcu_head rcu; 923 struct rcu_head rcu;
@@ -955,6 +985,7 @@ static inline void put_task_struct(struct task_struct *t)
955#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */ 985#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */
956#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */ 986#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */
957#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */ 987#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
988#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
958 989
959/* 990/*
960 * Only the _current_ task can read/write to tsk->flags, but other 991 * Only the _current_ task can read/write to tsk->flags, but other
@@ -1009,6 +1040,19 @@ static inline void idle_task_exit(void) {}
1009#endif 1040#endif
1010 1041
1011extern void sched_idle_next(void); 1042extern void sched_idle_next(void);
1043
1044#ifdef CONFIG_RT_MUTEXES
1045extern int rt_mutex_getprio(task_t *p);
1046extern void rt_mutex_setprio(task_t *p, int prio);
1047extern void rt_mutex_adjust_pi(task_t *p);
1048#else
1049static inline int rt_mutex_getprio(task_t *p)
1050{
1051 return p->normal_prio;
1052}
1053# define rt_mutex_adjust_pi(p) do { } while (0)
1054#endif
1055
1012extern void set_user_nice(task_t *p, long nice); 1056extern void set_user_nice(task_t *p, long nice);
1013extern int task_prio(const task_t *p); 1057extern int task_prio(const task_t *p);
1014extern int task_nice(const task_t *p); 1058extern int task_nice(const task_t *p);
@@ -1408,6 +1452,11 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm)
1408extern long sched_setaffinity(pid_t pid, cpumask_t new_mask); 1452extern long sched_setaffinity(pid_t pid, cpumask_t new_mask);
1409extern long sched_getaffinity(pid_t pid, cpumask_t *mask); 1453extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
1410 1454
1455#include <linux/sysdev.h>
1456extern int sched_mc_power_savings, sched_smt_power_savings;
1457extern struct sysdev_attribute attr_sched_mc_power_savings, attr_sched_smt_power_savings;
1458extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
1459
1411extern void normalize_rt_tasks(void); 1460extern void normalize_rt_tasks(void);
1412 1461
1413#ifdef CONFIG_PM 1462#ifdef CONFIG_PM
diff --git a/include/linux/scx200.h b/include/linux/scx200.h
index a22f9e173ad2..693c0557e70b 100644
--- a/include/linux/scx200.h
+++ b/include/linux/scx200.h
@@ -49,10 +49,3 @@ extern unsigned scx200_cb_base;
49#define SCx200_REV 0x3d /* Revision Register */ 49#define SCx200_REV 0x3d /* Revision Register */
50#define SCx200_CBA 0x3e /* Configuration Base Address Register */ 50#define SCx200_CBA 0x3e /* Configuration Base Address Register */
51#define SCx200_CBA_SCRATCH 0x64 /* Configuration Base Address Scratchpad */ 51#define SCx200_CBA_SCRATCH 0x64 /* Configuration Base Address Scratchpad */
52
53/*
54 Local variables:
55 compile-command: "make -C ../.. bzImage modules"
56 c-basic-offset: 8
57 End:
58*/
diff --git a/include/linux/scx200_gpio.h b/include/linux/scx200_gpio.h
index 30cdd648ba79..90dd069cc145 100644
--- a/include/linux/scx200_gpio.h
+++ b/include/linux/scx200_gpio.h
@@ -1,6 +1,6 @@
1#include <linux/spinlock.h> 1#include <linux/spinlock.h>
2 2
3u32 scx200_gpio_configure(int index, u32 set, u32 clear); 3u32 scx200_gpio_configure(unsigned index, u32 set, u32 clear);
4 4
5extern unsigned scx200_gpio_base; 5extern unsigned scx200_gpio_base;
6extern long scx200_gpio_shadow[2]; 6extern long scx200_gpio_shadow[2];
@@ -17,7 +17,7 @@ extern long scx200_gpio_shadow[2];
17 17
18/* returns the value of the GPIO pin */ 18/* returns the value of the GPIO pin */
19 19
20static inline int scx200_gpio_get(int index) { 20static inline int scx200_gpio_get(unsigned index) {
21 __SCx200_GPIO_BANK; 21 __SCx200_GPIO_BANK;
22 __SCx200_GPIO_IOADDR + 0x04; 22 __SCx200_GPIO_IOADDR + 0x04;
23 __SCx200_GPIO_INDEX; 23 __SCx200_GPIO_INDEX;
@@ -29,7 +29,7 @@ static inline int scx200_gpio_get(int index) {
29 driven if the GPIO is configured as an output, it might not be the 29 driven if the GPIO is configured as an output, it might not be the
30 state of the GPIO right now if the GPIO is configured as an input) */ 30 state of the GPIO right now if the GPIO is configured as an input) */
31 31
32static inline int scx200_gpio_current(int index) { 32static inline int scx200_gpio_current(unsigned index) {
33 __SCx200_GPIO_BANK; 33 __SCx200_GPIO_BANK;
34 __SCx200_GPIO_INDEX; 34 __SCx200_GPIO_INDEX;
35 35
@@ -38,7 +38,7 @@ static inline int scx200_gpio_current(int index) {
38 38
39/* drive the GPIO signal high */ 39/* drive the GPIO signal high */
40 40
41static inline void scx200_gpio_set_high(int index) { 41static inline void scx200_gpio_set_high(unsigned index) {
42 __SCx200_GPIO_BANK; 42 __SCx200_GPIO_BANK;
43 __SCx200_GPIO_IOADDR; 43 __SCx200_GPIO_IOADDR;
44 __SCx200_GPIO_SHADOW; 44 __SCx200_GPIO_SHADOW;
@@ -49,7 +49,7 @@ static inline void scx200_gpio_set_high(int index) {
49 49
50/* drive the GPIO signal low */ 50/* drive the GPIO signal low */
51 51
52static inline void scx200_gpio_set_low(int index) { 52static inline void scx200_gpio_set_low(unsigned index) {
53 __SCx200_GPIO_BANK; 53 __SCx200_GPIO_BANK;
54 __SCx200_GPIO_IOADDR; 54 __SCx200_GPIO_IOADDR;
55 __SCx200_GPIO_SHADOW; 55 __SCx200_GPIO_SHADOW;
@@ -60,7 +60,7 @@ static inline void scx200_gpio_set_low(int index) {
60 60
61/* drive the GPIO signal to state */ 61/* drive the GPIO signal to state */
62 62
63static inline void scx200_gpio_set(int index, int state) { 63static inline void scx200_gpio_set(unsigned index, int state) {
64 __SCx200_GPIO_BANK; 64 __SCx200_GPIO_BANK;
65 __SCx200_GPIO_IOADDR; 65 __SCx200_GPIO_IOADDR;
66 __SCx200_GPIO_SHADOW; 66 __SCx200_GPIO_SHADOW;
@@ -73,7 +73,7 @@ static inline void scx200_gpio_set(int index, int state) {
73} 73}
74 74
75/* toggle the GPIO signal */ 75/* toggle the GPIO signal */
76static inline void scx200_gpio_change(int index) { 76static inline void scx200_gpio_change(unsigned index) {
77 __SCx200_GPIO_BANK; 77 __SCx200_GPIO_BANK;
78 __SCx200_GPIO_IOADDR; 78 __SCx200_GPIO_IOADDR;
79 __SCx200_GPIO_SHADOW; 79 __SCx200_GPIO_SHADOW;
@@ -87,10 +87,3 @@ static inline void scx200_gpio_change(int index) {
87#undef __SCx200_GPIO_SHADOW 87#undef __SCx200_GPIO_SHADOW
88#undef __SCx200_GPIO_INDEX 88#undef __SCx200_GPIO_INDEX
89#undef __SCx200_GPIO_OUT 89#undef __SCx200_GPIO_OUT
90
91/*
92 Local variables:
93 compile-command: "make -C ../.. bzImage modules"
94 c-basic-offset: 8
95 End:
96*/
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 951c4e858274..fc1104a2cfa9 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -336,7 +336,6 @@ struct uart_driver {
336 struct module *owner; 336 struct module *owner;
337 const char *driver_name; 337 const char *driver_name;
338 const char *dev_name; 338 const char *dev_name;
339 const char *devfs_name;
340 int major; 339 int major;
341 int minor; 340 int minor;
342 int nr; 341 int nr;
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index e928c0dcc297..c8bb68099eb9 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -642,10 +642,14 @@ struct spi_board_info {
642 u16 bus_num; 642 u16 bus_num;
643 u16 chip_select; 643 u16 chip_select;
644 644
645 /* mode becomes spi_device.mode, and is essential for chips
646 * where the default of SPI_CS_HIGH = 0 is wrong.
647 */
648 u8 mode;
649
645 /* ... may need additional spi_device chip config data here. 650 /* ... may need additional spi_device chip config data here.
646 * avoid stuff protocol drivers can set; but include stuff 651 * avoid stuff protocol drivers can set; but include stuff
647 * needed to behave without being bound to a driver: 652 * needed to behave without being bound to a driver:
648 * - chipselect polarity
649 * - quirks like clock rate mattering when not selected 653 * - quirks like clock rate mattering when not selected
650 */ 654 */
651}; 655};
diff --git a/include/linux/swap.h b/include/linux/swap.h
index dc3f3aa0c83e..c41e2d6d1acc 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -199,6 +199,8 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
199} 199}
200#endif 200#endif
201 201
202extern int kswapd_run(int nid);
203
202#ifdef CONFIG_MMU 204#ifdef CONFIG_MMU
203/* linux/mm/shmem.c */ 205/* linux/mm/shmem.c */
204extern int shmem_unuse(swp_entry_t entry, struct page *page); 206extern int shmem_unuse(swp_entry_t entry, struct page *page);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 33785b79d548..008f04c56737 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -174,9 +174,9 @@ asmlinkage long sys_waitid(int which, pid_t pid,
174 int options, struct rusage __user *ru); 174 int options, struct rusage __user *ru);
175asmlinkage long sys_waitpid(pid_t pid, int __user *stat_addr, int options); 175asmlinkage long sys_waitpid(pid_t pid, int __user *stat_addr, int options);
176asmlinkage long sys_set_tid_address(int __user *tidptr); 176asmlinkage long sys_set_tid_address(int __user *tidptr);
177asmlinkage long sys_futex(u32 __user *uaddr, int op, int val, 177asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val,
178 struct timespec __user *utime, u32 __user *uaddr2, 178 struct timespec __user *utime, u32 __user *uaddr2,
179 int val3); 179 u32 val3);
180 180
181asmlinkage long sys_init_module(void __user *umod, unsigned long len, 181asmlinkage long sys_init_module(void __user *umod, unsigned long len,
182 const char __user *uargs); 182 const char __user *uargs);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 349ef908a222..46e4d8f2771f 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -149,6 +149,7 @@ enum
149 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */ 149 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */
150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */ 150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */
151 KERN_COMPAT_LOG=73, /* int: print compat layer messages */ 151 KERN_COMPAT_LOG=73, /* int: print compat layer messages */
152 KERN_MAX_LOCK_DEPTH=74,
152}; 153};
153 154
154 155
@@ -189,6 +190,7 @@ enum
189 VM_ZONE_RECLAIM_MODE=31, /* reclaim local zone memory before going off node */ 190 VM_ZONE_RECLAIM_MODE=31, /* reclaim local zone memory before going off node */
190 VM_ZONE_RECLAIM_INTERVAL=32, /* time period to wait after reclaim failure */ 191 VM_ZONE_RECLAIM_INTERVAL=32, /* time period to wait after reclaim failure */
191 VM_PANIC_ON_OOM=33, /* panic at out-of-memory */ 192 VM_PANIC_ON_OOM=33, /* panic at out-of-memory */
193 VM_VDSO_ENABLED=34, /* map VDSO into new processes? */
192}; 194};
193 195
194 196
diff --git a/include/linux/topology.h b/include/linux/topology.h
index a305ae2e44b6..ec1eca85290a 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -134,7 +134,8 @@
134 .flags = SD_LOAD_BALANCE \ 134 .flags = SD_LOAD_BALANCE \
135 | SD_BALANCE_NEWIDLE \ 135 | SD_BALANCE_NEWIDLE \
136 | SD_BALANCE_EXEC \ 136 | SD_BALANCE_EXEC \
137 | SD_WAKE_AFFINE, \ 137 | SD_WAKE_AFFINE \
138 | BALANCE_FOR_POWER, \
138 .last_balance = jiffies, \ 139 .last_balance = jiffies, \
139 .balance_interval = 1, \ 140 .balance_interval = 1, \
140 .nr_balance_failed = 0, \ 141 .nr_balance_failed = 0, \
diff --git a/include/linux/tty.h b/include/linux/tty.h
index cb35ca50a0a6..b3b807e4b050 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -57,7 +57,6 @@ struct tty_buffer {
57 unsigned char *flag_buf_ptr; 57 unsigned char *flag_buf_ptr;
58 int used; 58 int used;
59 int size; 59 int size;
60 int active;
61 int commit; 60 int commit;
62 int read; 61 int read;
63 /* Data points here */ 62 /* Data points here */
@@ -259,7 +258,6 @@ struct tty_struct {
259#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ 258#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */
260#define TTY_PUSH 6 /* n_tty private */ 259#define TTY_PUSH 6 /* n_tty private */
261#define TTY_CLOSING 7 /* ->close() in progress */ 260#define TTY_CLOSING 7 /* ->close() in progress */
262#define TTY_DONT_FLIP 8 /* Defer buffer flip */
263#define TTY_LDISC 9 /* Line discipline attached */ 261#define TTY_LDISC 9 /* Line discipline attached */
264#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */ 262#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */
265#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */ 263#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index b368b296d035..58c961c9e170 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -157,7 +157,6 @@ struct tty_driver {
157 struct cdev cdev; 157 struct cdev cdev;
158 struct module *owner; 158 struct module *owner;
159 const char *driver_name; 159 const char *driver_name;
160 const char *devfs_name;
161 const char *name; 160 const char *name;
162 int name_base; /* offset of printed name */ 161 int name_base; /* offset of printed name */
163 int major; /* major device number */ 162 int major; /* major device number */
@@ -242,8 +241,15 @@ void tty_set_operations(struct tty_driver *driver, struct tty_operations *op);
242 * is also a promise, if the above case is true, not to signal 241 * is also a promise, if the above case is true, not to signal
243 * overruns, either.) 242 * overruns, either.)
244 * 243 *
245 * TTY_DRIVER_NO_DEVFS --- if set, do not create devfs entries. This 244 * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need
246 * is only used by tty_register_driver(). 245 * to be registered with a call to tty_register_driver() when the
246 * device is found in the system and unregistered with a call to
247 * tty_unregister_device() so the devices will be show up
248 * properly in sysfs. If not set, driver->num entries will be
249 * created by the tty core in sysfs when tty_register_driver() is
250 * called. This is to be used by drivers that have tty devices
251 * that can appear and disappear while the main tty driver is
252 * registered with the tty core.
247 * 253 *
248 * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead 254 * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead
249 * use dynamic memory keyed through the devpts filesystem. This 255 * use dynamic memory keyed through the devpts filesystem. This
@@ -252,7 +258,7 @@ void tty_set_operations(struct tty_driver *driver, struct tty_operations *op);
252#define TTY_DRIVER_INSTALLED 0x0001 258#define TTY_DRIVER_INSTALLED 0x0001
253#define TTY_DRIVER_RESET_TERMIOS 0x0002 259#define TTY_DRIVER_RESET_TERMIOS 0x0002
254#define TTY_DRIVER_REAL_RAW 0x0004 260#define TTY_DRIVER_REAL_RAW 0x0004
255#define TTY_DRIVER_NO_DEVFS 0x0008 261#define TTY_DRIVER_DYNAMIC_DEV 0x0008
256#define TTY_DRIVER_DEVPTS_MEM 0x0010 262#define TTY_DRIVER_DEVPTS_MEM 0x0010
257 263
258/* tty driver types */ 264/* tty driver types */
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 31548303ee37..eb677cf56106 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -12,7 +12,7 @@ static inline int tty_insert_flip_char(struct tty_struct *tty,
12 unsigned char ch, char flag) 12 unsigned char ch, char flag)
13{ 13{
14 struct tty_buffer *tb = tty->buf.tail; 14 struct tty_buffer *tb = tty->buf.tail;
15 if (tb && tb->active && tb->used < tb->size) { 15 if (tb && tb->used < tb->size) {
16 tb->flag_buf_ptr[tb->used] = flag; 16 tb->flag_buf_ptr[tb->used] = flag;
17 tb->char_buf_ptr[tb->used++] = ch; 17 tb->char_buf_ptr[tb->used++] = ch;
18 return 1; 18 return 1;
diff --git a/include/linux/types.h b/include/linux/types.h
index a5e46e783ffa..3f235660a3cd 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -177,8 +177,15 @@ typedef __u64 __bitwise __be64;
177 177
178#ifdef __KERNEL__ 178#ifdef __KERNEL__
179typedef unsigned __bitwise__ gfp_t; 179typedef unsigned __bitwise__ gfp_t;
180
181#ifdef CONFIG_RESOURCES_64BIT
182typedef u64 resource_size_t;
183#else
184typedef u32 resource_size_t;
180#endif 185#endif
181 186
187#endif /* __KERNEL__ */
188
182struct ustat { 189struct ustat {
183 __kernel_daddr_t f_tfree; 190 __kernel_daddr_t f_tfree;
184 __kernel_ino_t f_tinode; 191 __kernel_ino_t f_tinode;
diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h
index 914f911325be..e39b7cc43390 100644
--- a/include/linux/ufs_fs.h
+++ b/include/linux/ufs_fs.h
@@ -966,7 +966,7 @@ extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
966extern struct inode_operations ufs_file_inode_operations; 966extern struct inode_operations ufs_file_inode_operations;
967extern const struct file_operations ufs_file_operations; 967extern const struct file_operations ufs_file_operations;
968 968
969extern struct address_space_operations ufs_aops; 969extern const struct address_space_operations ufs_aops;
970 970
971/* ialloc.c */ 971/* ialloc.c */
972extern void ufs_free_inode (struct inode *inode); 972extern void ufs_free_inode (struct inode *inode);
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 1192ed8f4fe8..011bcfeb9f09 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -28,6 +28,9 @@ struct watchdog_info {
28#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int) 28#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int)
29#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) 29#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int)
30#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) 30#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int)
31#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int)
32#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int)
33#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int)
31 34
32#define WDIOF_UNKNOWN -1 /* Unknown flag error */ 35#define WDIOF_UNKNOWN -1 /* Unknown flag error */
33#define WDIOS_UNKNOWN -1 /* Unknown status error */ 36#define WDIOS_UNKNOWN -1 /* Unknown status error */
@@ -38,9 +41,10 @@ struct watchdog_info {
38#define WDIOF_EXTERN2 0x0008 /* External relay 2 */ 41#define WDIOF_EXTERN2 0x0008 /* External relay 2 */
39#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ 42#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */
40#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ 43#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */
41#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ 44#define WDIOF_POWEROVER 0x0040 /* Power over voltage */
42#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ 45#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */
43#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ 46#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */
47#define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */
44#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ 48#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */
45 49
46#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ 50#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h
index 074c4008ad52..d91d88f93c8b 100644
--- a/include/media/cx2341x.h
+++ b/include/media/cx2341x.h
@@ -89,9 +89,9 @@ int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params,
89 struct v4l2_queryctrl *qctrl); 89 struct v4l2_queryctrl *qctrl);
90const char **cx2341x_ctrl_get_menu(u32 id); 90const char **cx2341x_ctrl_get_menu(u32 id);
91int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, 91int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params,
92 struct v4l2_ext_controls *ctrls, int cmd); 92 struct v4l2_ext_controls *ctrls, unsigned int cmd);
93void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p); 93void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p);
94void cx2341x_log_status(struct cx2341x_mpeg_params *p, int cardid); 94void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix);
95 95
96/* Firmware names */ 96/* Firmware names */
97#define CX2341X_FIRM_ENC_FILENAME "v4l-cx2341x-enc.fw" 97#define CX2341X_FIRM_ENC_FILENAME "v4l-cx2341x-enc.fw"
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index a1b473190e65..62dae1a8c441 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -314,7 +314,6 @@ void *priv;
314 /* for videodev.c intenal usage -- please don't touch */ 314 /* for videodev.c intenal usage -- please don't touch */
315 int users; /* video_exclusive_{open|close} ... */ 315 int users; /* video_exclusive_{open|close} ... */
316 struct mutex lock; /* ... helper function uses these */ 316 struct mutex lock; /* ... helper function uses these */
317 char devfs_name[64]; /* devfs */
318 struct class_device class_dev; /* sysfs */ 317 struct class_device class_dev; /* sysfs */
319}; 318};
320 319
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 446afc3ea27f..758f8bf133c7 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -265,6 +265,7 @@
265 265
266/* specific - Analog Devices */ 266/* specific - Analog Devices */
267#define AC97_AD_TEST 0x5a /* test register */ 267#define AC97_AD_TEST 0x5a /* test register */
268#define AC97_AD_TEST2 0x5c /* undocumented test register 2 */
268#define AC97_AD_CODEC_CFG 0x70 /* codec configuration */ 269#define AC97_AD_CODEC_CFG 0x70 /* codec configuration */
269#define AC97_AD_JACK_SPDIF 0x72 /* Jack Sense & S/PDIF */ 270#define AC97_AD_JACK_SPDIF 0x72 /* Jack Sense & S/PDIF */
270#define AC97_AD_SERIAL_CFG 0x74 /* Serial Configuration */ 271#define AC97_AD_SERIAL_CFG 0x74 /* Serial Configuration */
diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h
index 3bf5911fe827..3d9888492026 100644
--- a/include/sound/ak4xxx-adda.h
+++ b/include/sound/ak4xxx-adda.h
@@ -32,8 +32,8 @@ struct snd_akm4xxx;
32struct snd_ak4xxx_ops { 32struct snd_ak4xxx_ops {
33 void (*lock)(struct snd_akm4xxx *ak, int chip); 33 void (*lock)(struct snd_akm4xxx *ak, int chip);
34 void (*unlock)(struct snd_akm4xxx *ak, int chip); 34 void (*unlock)(struct snd_akm4xxx *ak, int chip);
35 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val); 35 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
36 // unsigned char (*read)(struct snd_akm4xxx *ak, int chip, unsigned char reg); 36 unsigned char val);
37 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate); 37 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
38}; 38};
39 39
@@ -41,29 +41,40 @@ struct snd_ak4xxx_ops {
41 41
42struct snd_akm4xxx { 42struct snd_akm4xxx {
43 struct snd_card *card; 43 struct snd_card *card;
44 unsigned int num_adcs; /* AK4524 or AK4528 ADCs */ 44 unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
45 unsigned int num_dacs; /* AK4524 or AK4528 DACs */ 45 unsigned int num_dacs; /* AK4524 or AK4528 DACs */
46 unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */ 46 unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
47 unsigned char ipga_gain[AK4XXX_MAX_CHIPS][2]; /* saved register image for IPGA (AK4528) */ 47 unsigned char ipga_gain[AK4XXX_MAX_CHIPS][2]; /* saved register image
48 * for IPGA (AK4528)
49 */
48 unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */ 50 unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
49 void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */ 51 void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
50 /* template should fill the following fields */ 52 /* template should fill the following fields */
51 unsigned int idx_offset; /* control index offset */ 53 unsigned int idx_offset; /* control index offset */
52 enum { 54 enum {
53 SND_AK4524, SND_AK4528, SND_AK4529, 55 SND_AK4524, SND_AK4528, SND_AK4529,
54 SND_AK4355, SND_AK4358, SND_AK4381 56 SND_AK4355, SND_AK4358, SND_AK4381
55 } type; 57 } type;
58 unsigned int *num_stereo; /* array of combined counts
59 * for the mixer
60 */
61 char **channel_names; /* array of mixer channel names */
56 struct snd_ak4xxx_ops ops; 62 struct snd_ak4xxx_ops ops;
57}; 63};
58 64
59void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val); 65void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
66 unsigned char val);
60void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state); 67void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state);
61void snd_akm4xxx_init(struct snd_akm4xxx *ak); 68void snd_akm4xxx_init(struct snd_akm4xxx *ak);
62int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak); 69int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
63 70
64#define snd_akm4xxx_get(ak,chip,reg) (ak)->images[(chip) * 16 + (reg)] 71#define snd_akm4xxx_get(ak,chip,reg) \
65#define snd_akm4xxx_set(ak,chip,reg,val) ((ak)->images[(chip) * 16 + (reg)] = (val)) 72 (ak)->images[(chip) * 16 + (reg)]
66#define snd_akm4xxx_get_ipga(ak,chip,reg) (ak)->ipga_gain[chip][(reg)-4] 73#define snd_akm4xxx_set(ak,chip,reg,val) \
67#define snd_akm4xxx_set_ipga(ak,chip,reg,val) ((ak)->ipga_gain[chip][(reg)-4] = (val)) 74 ((ak)->images[(chip) * 16 + (reg)] = (val))
75#define snd_akm4xxx_get_ipga(ak,chip,reg) \
76 (ak)->ipga_gain[chip][(reg)-4]
77#define snd_akm4xxx_set_ipga(ak,chip,reg,val) \
78 ((ak)->ipga_gain[chip][(reg)-4] = (val))
68 79
69#endif /* __SOUND_AK4XXX_ADDA_H */ 80#endif /* __SOUND_AK4XXX_ADDA_H */
diff --git a/include/sound/initval.h b/include/sound/initval.h
index d29e3d31d149..d45170b9e0b7 100644
--- a/include/sound/initval.h
+++ b/include/sound/initval.h
@@ -62,7 +62,8 @@ static int snd_legacy_find_free_irq(int *irq_table)
62{ 62{
63 while (*irq_table != -1) { 63 while (*irq_table != -1) {
64 if (!request_irq(*irq_table, snd_legacy_empty_irq_handler, 64 if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
65 SA_INTERRUPT, "ALSA Test IRQ", (void *) irq_table)) { 65 SA_INTERRUPT | SA_PROBEIRQ, "ALSA Test IRQ",
66 (void *) irq_table)) {
66 free_irq(*irq_table, (void *) irq_table); 67 free_irq(*irq_table, (void *) irq_table);
67 return *irq_table; 68 return *irq_table;
68 } 69 }
diff --git a/init/Kconfig b/init/Kconfig
index df55b3665601..f70f2fd273c2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -339,9 +339,14 @@ config BASE_FULL
339 kernel data structures. This saves memory on small machines, 339 kernel data structures. This saves memory on small machines,
340 but may reduce performance. 340 but may reduce performance.
341 341
342config RT_MUTEXES
343 boolean
344 select PLIST
345
342config FUTEX 346config FUTEX
343 bool "Enable futex support" if EMBEDDED 347 bool "Enable futex support" if EMBEDDED
344 default y 348 default y
349 select RT_MUTEXES
345 help 350 help
346 Disabling this option will cause the kernel to be built without 351 Disabling this option will cause the kernel to be built without
347 support for "fast userspace mutexes". The resulting kernel may not 352 support for "fast userspace mutexes". The resulting kernel may not
diff --git a/init/Makefile b/init/Makefile
index a2300078f2b7..633a268d270d 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -6,7 +6,6 @@ obj-y := main.o version.o mounts.o initramfs.o
6obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o 6obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
7 7
8mounts-y := do_mounts.o 8mounts-y := do_mounts.o
9mounts-$(CONFIG_DEVFS_FS) += do_mounts_devfs.o
10mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o 9mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
11mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o 10mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
12mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o 11mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 21b3b8f33a72..94aeec7aa917 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -325,7 +325,7 @@ static int __init mount_nfs_root(void)
325{ 325{
326 void *data = nfs_root_data(); 326 void *data = nfs_root_data();
327 327
328 create_dev("/dev/root", ROOT_DEV, NULL); 328 create_dev("/dev/root", ROOT_DEV);
329 if (data && 329 if (data &&
330 do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0) 330 do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0)
331 return 1; 331 return 1;
@@ -386,7 +386,7 @@ void __init mount_root(void)
386 change_floppy("root floppy"); 386 change_floppy("root floppy");
387 } 387 }
388#endif 388#endif
389 create_dev("/dev/root", ROOT_DEV, root_device_name); 389 create_dev("/dev/root", ROOT_DEV);
390 mount_block_root("/dev/root", root_mountflags); 390 mount_block_root("/dev/root", root_mountflags);
391} 391}
392 392
@@ -397,8 +397,6 @@ void __init prepare_namespace(void)
397{ 397{
398 int is_floppy; 398 int is_floppy;
399 399
400 mount_devfs();
401
402 if (root_delay) { 400 if (root_delay) {
403 printk(KERN_INFO "Waiting %dsec before mounting root device...\n", 401 printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
404 root_delay); 402 root_delay);
@@ -428,10 +426,8 @@ void __init prepare_namespace(void)
428 426
429 mount_root(); 427 mount_root();
430out: 428out:
431 umount_devfs("/dev");
432 sys_mount(".", "/", NULL, MS_MOVE, NULL); 429 sys_mount(".", "/", NULL, MS_MOVE, NULL);
433 sys_chroot("."); 430 sys_chroot(".");
434 security_sb_post_mountroot(); 431 security_sb_post_mountroot();
435 mount_devfs_fs ();
436} 432}
437 433
diff --git a/init/do_mounts.h b/init/do_mounts.h
index e0a7ac9649e1..e7f2e7fa066e 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -1,6 +1,5 @@
1#include <linux/config.h> 1#include <linux/config.h>
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/devfs_fs_kernel.h>
4#include <linux/init.h> 3#include <linux/init.h>
5#include <linux/syscalls.h> 4#include <linux/syscalls.h>
6#include <linux/unistd.h> 5#include <linux/unistd.h>
@@ -15,25 +14,12 @@ void mount_root(void);
15extern int root_mountflags; 14extern int root_mountflags;
16extern char *root_device_name; 15extern char *root_device_name;
17 16
18#ifdef CONFIG_DEVFS_FS 17static inline int create_dev(char *name, dev_t dev)
19
20void mount_devfs(void);
21void umount_devfs(char *path);
22int create_dev(char *name, dev_t dev, char *devfs_name);
23
24#else
25
26static inline void mount_devfs(void) {}
27static inline void umount_devfs(const char *path) {}
28
29static inline int create_dev(char *name, dev_t dev, char *devfs_name)
30{ 18{
31 sys_unlink(name); 19 sys_unlink(name);
32 return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); 20 return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
33} 21}
34 22
35#endif
36
37#if BITS_PER_LONG == 32 23#if BITS_PER_LONG == 32
38static inline u32 bstat(char *name) 24static inline u32 bstat(char *name)
39{ 25{
diff --git a/init/do_mounts_devfs.c b/init/do_mounts_devfs.c
deleted file mode 100644
index cc526474690a..000000000000
--- a/init/do_mounts_devfs.c
+++ /dev/null
@@ -1,137 +0,0 @@
1
2#include <linux/kernel.h>
3#include <linux/dirent.h>
4#include <linux/string.h>
5
6#include "do_mounts.h"
7
8void __init mount_devfs(void)
9{
10 sys_mount("devfs", "/dev", "devfs", 0, NULL);
11}
12
13void __init umount_devfs(char *path)
14{
15 sys_umount(path, 0);
16}
17
18/*
19 * If the dir will fit in *buf, return its length. If it won't fit, return
20 * zero. Return -ve on error.
21 */
22static int __init do_read_dir(int fd, void *buf, int len)
23{
24 long bytes, n;
25 char *p = buf;
26 sys_lseek(fd, 0, 0);
27
28 for (bytes = 0; bytes < len; bytes += n) {
29 n = sys_getdents64(fd, (struct linux_dirent64 *)(p + bytes),
30 len - bytes);
31 if (n < 0)
32 return n;
33 if (n == 0)
34 return bytes;
35 }
36 return 0;
37}
38
39/*
40 * Try to read all of a directory. Returns the contents at *p, which
41 * is kmalloced memory. Returns the number of bytes read at *len. Returns
42 * NULL on error.
43 */
44static void * __init read_dir(char *path, int *len)
45{
46 int size;
47 int fd = sys_open(path, 0, 0);
48
49 *len = 0;
50 if (fd < 0)
51 return NULL;
52
53 for (size = 1 << 9; size <= (PAGE_SIZE << MAX_ORDER); size <<= 1) {
54 void *p = kmalloc(size, GFP_KERNEL);
55 int n;
56 if (!p)
57 break;
58 n = do_read_dir(fd, p, size);
59 if (n > 0) {
60 sys_close(fd);
61 *len = n;
62 return p;
63 }
64 kfree(p);
65 if (n == -EINVAL)
66 continue; /* Try a larger buffer */
67 if (n < 0)
68 break;
69 }
70 sys_close(fd);
71 return NULL;
72}
73
74/*
75 * recursively scan <path>, looking for a device node of type <dev>
76 */
77static int __init find_in_devfs(char *path, unsigned dev)
78{
79 char *end = path + strlen(path);
80 int rest = path + 64 - end;
81 int size;
82 char *p = read_dir(path, &size);
83 char *s;
84
85 if (!p)
86 return -1;
87 for (s = p; s < p + size; s += ((struct linux_dirent64 *)s)->d_reclen) {
88 struct linux_dirent64 *d = (struct linux_dirent64 *)s;
89 if (strlen(d->d_name) + 2 > rest)
90 continue;
91 switch (d->d_type) {
92 case DT_BLK:
93 sprintf(end, "/%s", d->d_name);
94 if (bstat(path) != dev)
95 break;
96 kfree(p);
97 return 0;
98 case DT_DIR:
99 if (strcmp(d->d_name, ".") == 0)
100 break;
101 if (strcmp(d->d_name, "..") == 0)
102 break;
103 sprintf(end, "/%s", d->d_name);
104 if (find_in_devfs(path, dev) < 0)
105 break;
106 kfree(p);
107 return 0;
108 }
109 }
110 kfree(p);
111 return -1;
112}
113
114/*
115 * create a device node called <name> which points to
116 * <devfs_name> if possible, otherwise find a device node
117 * which matches <dev> and make <name> a symlink pointing to it.
118 */
119int __init create_dev(char *name, dev_t dev, char *devfs_name)
120{
121 char path[64];
122
123 sys_unlink(name);
124 if (devfs_name && devfs_name[0]) {
125 if (strncmp(devfs_name, "/dev/", 5) == 0)
126 devfs_name += 5;
127 sprintf(path, "/dev/%s", devfs_name);
128 if (sys_access(path, 0) == 0)
129 return sys_symlink(devfs_name, name);
130 }
131 if (!dev)
132 return -1;
133 strcpy(path, "/dev");
134 if (find_in_devfs(path, new_encode_dev(dev)) < 0)
135 return -1;
136 return sys_symlink(path + 5, name);
137}
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 405f9031af87..a06f037fa000 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -44,7 +44,7 @@ static void __init handle_initrd(void)
44 int pid; 44 int pid;
45 45
46 real_root_dev = new_encode_dev(ROOT_DEV); 46 real_root_dev = new_encode_dev(ROOT_DEV);
47 create_dev("/dev/root.old", Root_RAM0, NULL); 47 create_dev("/dev/root.old", Root_RAM0);
48 /* mount initrd on rootfs' /root */ 48 /* mount initrd on rootfs' /root */
49 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY); 49 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
50 sys_mkdir("/old", 0700); 50 sys_mkdir("/old", 0700);
@@ -54,7 +54,6 @@ static void __init handle_initrd(void)
54 sys_chdir("/root"); 54 sys_chdir("/root");
55 sys_mount(".", "/", NULL, MS_MOVE, NULL); 55 sys_mount(".", "/", NULL, MS_MOVE, NULL);
56 sys_chroot("."); 56 sys_chroot(".");
57 mount_devfs_fs ();
58 57
59 current->flags |= PF_NOFREEZE; 58 current->flags |= PF_NOFREEZE;
60 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); 59 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
@@ -71,7 +70,6 @@ static void __init handle_initrd(void)
71 sys_chroot("."); 70 sys_chroot(".");
72 sys_close(old_fd); 71 sys_close(old_fd);
73 sys_close(root_fd); 72 sys_close(root_fd);
74 umount_devfs("/old/dev");
75 73
76 if (new_decode_dev(real_root_dev) == Root_RAM0) { 74 if (new_decode_dev(real_root_dev) == Root_RAM0) {
77 sys_chdir("/old"); 75 sys_chdir("/old");
@@ -107,7 +105,7 @@ static void __init handle_initrd(void)
107int __init initrd_load(void) 105int __init initrd_load(void)
108{ 106{
109 if (mount_initrd) { 107 if (mount_initrd) {
110 create_dev("/dev/ram", Root_RAM0, NULL); 108 create_dev("/dev/ram", Root_RAM0);
111 /* 109 /*
112 * Load the initrd data into /dev/ram0. Execute it as initrd 110 * Load the initrd data into /dev/ram0. Execute it as initrd
113 * unless /dev/ram0 is supposed to be our actual root device, 111 * unless /dev/ram0 is supposed to be our actual root device,
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index f6f36806f84a..2429e1bf8c60 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -125,19 +125,18 @@ static void __init md_setup_drive(void)
125 int err = 0; 125 int err = 0;
126 char *devname; 126 char *devname;
127 mdu_disk_info_t dinfo; 127 mdu_disk_info_t dinfo;
128 char name[16], devfs_name[16]; 128 char name[16];
129 129
130 minor = md_setup_args[ent].minor; 130 minor = md_setup_args[ent].minor;
131 partitioned = md_setup_args[ent].partitioned; 131 partitioned = md_setup_args[ent].partitioned;
132 devname = md_setup_args[ent].device_names; 132 devname = md_setup_args[ent].device_names;
133 133
134 sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor); 134 sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
135 sprintf(devfs_name, "/dev/md/%s%d", partitioned?"d":"", minor);
136 if (partitioned) 135 if (partitioned)
137 dev = MKDEV(mdp_major, minor << MdpMinorShift); 136 dev = MKDEV(mdp_major, minor << MdpMinorShift);
138 else 137 else
139 dev = MKDEV(MD_MAJOR, minor); 138 dev = MKDEV(MD_MAJOR, minor);
140 create_dev(name, dev, devfs_name); 139 create_dev(name, dev);
141 for (i = 0; i < MD_SB_DISKS && devname != 0; i++) { 140 for (i = 0; i < MD_SB_DISKS && devname != 0; i++) {
142 char *p; 141 char *p;
143 char comp_name[64]; 142 char comp_name[64];
@@ -272,7 +271,7 @@ __setup("md=", md_setup);
272 271
273void __init md_run_setup(void) 272void __init md_run_setup(void)
274{ 273{
275 create_dev("/dev/md0", MKDEV(MD_MAJOR, 0), "md/0"); 274 create_dev("/dev/md0", MKDEV(MD_MAJOR, 0));
276 if (raid_noautodetect) 275 if (raid_noautodetect)
277 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n"); 276 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n");
278 else { 277 else {
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index c2683fcd792d..ed652f40f075 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -262,8 +262,8 @@ int __init rd_load_disk(int n)
262{ 262{
263 if (rd_prompt) 263 if (rd_prompt)
264 change_floppy("root floppy disk to be loaded into RAM disk"); 264 change_floppy("root floppy disk to be loaded into RAM disk");
265 create_dev("/dev/root", ROOT_DEV, root_device_name); 265 create_dev("/dev/root", ROOT_DEV);
266 create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL); 266 create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n));
267 return rd_load_image("/dev/root"); 267 return rd_load_image("/dev/root");
268} 268}
269 269
diff --git a/init/main.c b/init/main.c
index 80af1a52485f..bce0eb7f4f8f 100644
--- a/init/main.c
+++ b/init/main.c
@@ -15,7 +15,6 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/devfs_fs_kernel.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
20#include <linux/syscalls.h> 19#include <linux/syscalls.h>
21#include <linux/string.h> 20#include <linux/string.h>
@@ -48,6 +47,7 @@
48#include <linux/mempolicy.h> 47#include <linux/mempolicy.h>
49#include <linux/key.h> 48#include <linux/key.h>
50#include <linux/unwind.h> 49#include <linux/unwind.h>
50#include <linux/buffer_head.h>
51 51
52#include <asm/io.h> 52#include <asm/io.h>
53#include <asm/bugs.h> 53#include <asm/bugs.h>
@@ -80,7 +80,6 @@ extern void mca_init(void);
80extern void sbus_init(void); 80extern void sbus_init(void);
81extern void sysctl_init(void); 81extern void sysctl_init(void);
82extern void signals_init(void); 82extern void signals_init(void);
83extern void buffer_init(void);
84extern void pidhash_init(void); 83extern void pidhash_init(void);
85extern void pidmap_init(void); 84extern void pidmap_init(void);
86extern void prio_tree_init(void); 85extern void prio_tree_init(void);
diff --git a/kernel/Makefile b/kernel/Makefile
index 752bd7d383af..82fb182f6f61 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -16,6 +16,9 @@ obj-$(CONFIG_FUTEX) += futex.o
16ifeq ($(CONFIG_COMPAT),y) 16ifeq ($(CONFIG_COMPAT),y)
17obj-$(CONFIG_FUTEX) += futex_compat.o 17obj-$(CONFIG_FUTEX) += futex_compat.o
18endif 18endif
19obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
20obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
21obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
19obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o 22obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
20obj-$(CONFIG_SMP) += cpu.o spinlock.o 23obj-$(CONFIG_SMP) += cpu.o spinlock.o
21obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o 24obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
diff --git a/kernel/acct.c b/kernel/acct.c
index 368c4f03fe0e..126ca43d5d2b 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -521,6 +521,7 @@ static void do_acct_process(struct file *file)
521 521
522/** 522/**
523 * acct_init_pacct - initialize a new pacct_struct 523 * acct_init_pacct - initialize a new pacct_struct
524 * @pacct: per-process accounting info struct to initialize
524 */ 525 */
525void acct_init_pacct(struct pacct_struct *pacct) 526void acct_init_pacct(struct pacct_struct *pacct)
526{ 527{
@@ -576,7 +577,7 @@ void acct_collect(long exitcode, int group_dead)
576 * 577 *
577 * handles process accounting for an exiting task 578 * handles process accounting for an exiting task
578 */ 579 */
579void acct_process() 580void acct_process(void)
580{ 581{
581 struct file *file = NULL; 582 struct file *file = NULL;
582 583
diff --git a/kernel/audit.c b/kernel/audit.c
index 7dfac7031bd7..82443fb433ef 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -818,7 +818,7 @@ err:
818 */ 818 */
819unsigned int audit_serial(void) 819unsigned int audit_serial(void)
820{ 820{
821 static spinlock_t serial_lock = SPIN_LOCK_UNLOCKED; 821 static DEFINE_SPINLOCK(serial_lock);
822 static unsigned int serial = 0; 822 static unsigned int serial = 0;
823 823
824 unsigned long flags; 824 unsigned long flags;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 9ebd96fda295..dc5e3f01efe7 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -658,8 +658,7 @@ static void audit_log_task_context(struct audit_buffer *ab)
658 return; 658 return;
659 659
660error_path: 660error_path:
661 if (ctx) 661 kfree(ctx);
662 kfree(ctx);
663 audit_panic("error in audit_log_task_context"); 662 audit_panic("error in audit_log_task_context");
664 return; 663 return;
665} 664}
@@ -1367,7 +1366,7 @@ int __audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr)
1367 * @mqdes: MQ descriptor 1366 * @mqdes: MQ descriptor
1368 * @msg_len: Message length 1367 * @msg_len: Message length
1369 * @msg_prio: Message priority 1368 * @msg_prio: Message priority
1370 * @abs_timeout: Message timeout in absolute time 1369 * @u_abs_timeout: Message timeout in absolute time
1371 * 1370 *
1372 * Returns 0 for success or NULL context or < 0 on error. 1371 * Returns 0 for success or NULL context or < 0 on error.
1373 */ 1372 */
@@ -1409,8 +1408,8 @@ int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio,
1409 * __audit_mq_timedreceive - record audit data for a POSIX MQ timed receive 1408 * __audit_mq_timedreceive - record audit data for a POSIX MQ timed receive
1410 * @mqdes: MQ descriptor 1409 * @mqdes: MQ descriptor
1411 * @msg_len: Message length 1410 * @msg_len: Message length
1412 * @msg_prio: Message priority 1411 * @u_msg_prio: Message priority
1413 * @abs_timeout: Message timeout in absolute time 1412 * @u_abs_timeout: Message timeout in absolute time
1414 * 1413 *
1415 * Returns 0 for success or NULL context or < 0 on error. 1414 * Returns 0 for success or NULL context or < 0 on error.
1416 */ 1415 */
@@ -1558,7 +1557,6 @@ int __audit_ipc_obj(struct kern_ipc_perm *ipcp)
1558 * @uid: msgq user id 1557 * @uid: msgq user id
1559 * @gid: msgq group id 1558 * @gid: msgq group id
1560 * @mode: msgq mode (permissions) 1559 * @mode: msgq mode (permissions)
1561 * @ipcp: in-kernel IPC permissions
1562 * 1560 *
1563 * Returns 0 for success or NULL context or < 0 on error. 1561 * Returns 0 for success or NULL context or < 0 on error.
1564 */ 1562 */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 03dcd981846a..70fbf2e83766 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -18,7 +18,7 @@
18/* This protects CPUs going up and down... */ 18/* This protects CPUs going up and down... */
19static DEFINE_MUTEX(cpucontrol); 19static DEFINE_MUTEX(cpucontrol);
20 20
21static BLOCKING_NOTIFIER_HEAD(cpu_chain); 21static __cpuinitdata BLOCKING_NOTIFIER_HEAD(cpu_chain);
22 22
23#ifdef CONFIG_HOTPLUG_CPU 23#ifdef CONFIG_HOTPLUG_CPU
24static struct task_struct *lock_cpu_hotplug_owner; 24static struct task_struct *lock_cpu_hotplug_owner;
@@ -69,10 +69,13 @@ EXPORT_SYMBOL_GPL(lock_cpu_hotplug_interruptible);
69#endif /* CONFIG_HOTPLUG_CPU */ 69#endif /* CONFIG_HOTPLUG_CPU */
70 70
71/* Need to know about CPUs going up/down? */ 71/* Need to know about CPUs going up/down? */
72int register_cpu_notifier(struct notifier_block *nb) 72int __cpuinit register_cpu_notifier(struct notifier_block *nb)
73{ 73{
74 return blocking_notifier_chain_register(&cpu_chain, nb); 74 return blocking_notifier_chain_register(&cpu_chain, nb);
75} 75}
76
77#ifdef CONFIG_HOTPLUG_CPU
78
76EXPORT_SYMBOL(register_cpu_notifier); 79EXPORT_SYMBOL(register_cpu_notifier);
77 80
78void unregister_cpu_notifier(struct notifier_block *nb) 81void unregister_cpu_notifier(struct notifier_block *nb)
@@ -81,7 +84,6 @@ void unregister_cpu_notifier(struct notifier_block *nb)
81} 84}
82EXPORT_SYMBOL(unregister_cpu_notifier); 85EXPORT_SYMBOL(unregister_cpu_notifier);
83 86
84#ifdef CONFIG_HOTPLUG_CPU
85static inline void check_for_tasks(int cpu) 87static inline void check_for_tasks(int cpu)
86{ 88{
87 struct task_struct *p; 89 struct task_struct *p;
diff --git a/kernel/exit.c b/kernel/exit.c
index 304ef637be6c..ab06b9f88f64 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -926,9 +926,18 @@ fastcall NORET_TYPE void do_exit(long code)
926 tsk->mempolicy = NULL; 926 tsk->mempolicy = NULL;
927#endif 927#endif
928 /* 928 /*
929 * This must happen late, after the PID is not
930 * hashed anymore:
931 */
932 if (unlikely(!list_empty(&tsk->pi_state_list)))
933 exit_pi_state_list(tsk);
934 if (unlikely(current->pi_state_cache))
935 kfree(current->pi_state_cache);
936 /*
929 * If DEBUG_MUTEXES is on, make sure we are holding no locks: 937 * If DEBUG_MUTEXES is on, make sure we are holding no locks:
930 */ 938 */
931 mutex_debug_check_no_locks_held(tsk); 939 mutex_debug_check_no_locks_held(tsk);
940 rt_mutex_debug_check_no_locks_held(tsk);
932 941
933 if (tsk->io_context) 942 if (tsk->io_context)
934 exit_io_context(); 943 exit_io_context();
diff --git a/kernel/fork.c b/kernel/fork.c
index 9b4e54ef0225..628198a4f28a 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -104,6 +104,7 @@ static kmem_cache_t *mm_cachep;
104void free_task(struct task_struct *tsk) 104void free_task(struct task_struct *tsk)
105{ 105{
106 free_thread_info(tsk->thread_info); 106 free_thread_info(tsk->thread_info);
107 rt_mutex_debug_task_free(tsk);
107 free_task_struct(tsk); 108 free_task_struct(tsk);
108} 109}
109EXPORT_SYMBOL(free_task); 110EXPORT_SYMBOL(free_task);
@@ -913,6 +914,19 @@ asmlinkage long sys_set_tid_address(int __user *tidptr)
913 return current->pid; 914 return current->pid;
914} 915}
915 916
917static inline void rt_mutex_init_task(struct task_struct *p)
918{
919#ifdef CONFIG_RT_MUTEXES
920 spin_lock_init(&p->pi_lock);
921 plist_head_init(&p->pi_waiters, &p->pi_lock);
922 p->pi_blocked_on = NULL;
923# ifdef CONFIG_DEBUG_RT_MUTEXES
924 spin_lock_init(&p->held_list_lock);
925 INIT_LIST_HEAD(&p->held_list_head);
926# endif
927#endif
928}
929
916/* 930/*
917 * This creates a new process as a copy of the old one, 931 * This creates a new process as a copy of the old one,
918 * but does not actually start it yet. 932 * but does not actually start it yet.
@@ -1034,6 +1048,8 @@ static task_t *copy_process(unsigned long clone_flags,
1034 mpol_fix_fork_child_flag(p); 1048 mpol_fix_fork_child_flag(p);
1035#endif 1049#endif
1036 1050
1051 rt_mutex_init_task(p);
1052
1037#ifdef CONFIG_DEBUG_MUTEXES 1053#ifdef CONFIG_DEBUG_MUTEXES
1038 p->blocked_on = NULL; /* not blocked yet */ 1054 p->blocked_on = NULL; /* not blocked yet */
1039#endif 1055#endif
@@ -1076,6 +1092,9 @@ static task_t *copy_process(unsigned long clone_flags,
1076#ifdef CONFIG_COMPAT 1092#ifdef CONFIG_COMPAT
1077 p->compat_robust_list = NULL; 1093 p->compat_robust_list = NULL;
1078#endif 1094#endif
1095 INIT_LIST_HEAD(&p->pi_state_list);
1096 p->pi_state_cache = NULL;
1097
1079 /* 1098 /*
1080 * sigaltstack should be cleared when sharing the same VM 1099 * sigaltstack should be cleared when sharing the same VM
1081 */ 1100 */
diff --git a/kernel/futex.c b/kernel/futex.c
index e1a380c77a5a..6c91f938005d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -12,6 +12,10 @@
12 * (C) Copyright 2006 Red Hat Inc, All Rights Reserved 12 * (C) Copyright 2006 Red Hat Inc, All Rights Reserved
13 * Thanks to Thomas Gleixner for suggestions, analysis and fixes. 13 * Thanks to Thomas Gleixner for suggestions, analysis and fixes.
14 * 14 *
15 * PI-futex support started by Ingo Molnar and Thomas Gleixner
16 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
17 * Copyright (C) 2006 Timesys Corp., Thomas Gleixner <tglx@timesys.com>
18 *
15 * Thanks to Ben LaHaise for yelling "hashed waitqueues" loudly 19 * Thanks to Ben LaHaise for yelling "hashed waitqueues" loudly
16 * enough at me, Linus for the original (flawed) idea, Matthew 20 * enough at me, Linus for the original (flawed) idea, Matthew
17 * Kirkwood for proof-of-concept implementation. 21 * Kirkwood for proof-of-concept implementation.
@@ -46,6 +50,8 @@
46#include <linux/signal.h> 50#include <linux/signal.h>
47#include <asm/futex.h> 51#include <asm/futex.h>
48 52
53#include "rtmutex_common.h"
54
49#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8) 55#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8)
50 56
51/* 57/*
@@ -63,7 +69,7 @@ union futex_key {
63 int offset; 69 int offset;
64 } shared; 70 } shared;
65 struct { 71 struct {
66 unsigned long uaddr; 72 unsigned long address;
67 struct mm_struct *mm; 73 struct mm_struct *mm;
68 int offset; 74 int offset;
69 } private; 75 } private;
@@ -75,6 +81,27 @@ union futex_key {
75}; 81};
76 82
77/* 83/*
84 * Priority Inheritance state:
85 */
86struct futex_pi_state {
87 /*
88 * list of 'owned' pi_state instances - these have to be
89 * cleaned up in do_exit() if the task exits prematurely:
90 */
91 struct list_head list;
92
93 /*
94 * The PI object:
95 */
96 struct rt_mutex pi_mutex;
97
98 struct task_struct *owner;
99 atomic_t refcount;
100
101 union futex_key key;
102};
103
104/*
78 * We use this hashed waitqueue instead of a normal wait_queue_t, so 105 * We use this hashed waitqueue instead of a normal wait_queue_t, so
79 * we can wake only the relevant ones (hashed queues may be shared). 106 * we can wake only the relevant ones (hashed queues may be shared).
80 * 107 *
@@ -87,15 +114,19 @@ struct futex_q {
87 struct list_head list; 114 struct list_head list;
88 wait_queue_head_t waiters; 115 wait_queue_head_t waiters;
89 116
90 /* Which hash list lock to use. */ 117 /* Which hash list lock to use: */
91 spinlock_t *lock_ptr; 118 spinlock_t *lock_ptr;
92 119
93 /* Key which the futex is hashed on. */ 120 /* Key which the futex is hashed on: */
94 union futex_key key; 121 union futex_key key;
95 122
96 /* For fd, sigio sent using these. */ 123 /* For fd, sigio sent using these: */
97 int fd; 124 int fd;
98 struct file *filp; 125 struct file *filp;
126
127 /* Optional priority inheritance state: */
128 struct futex_pi_state *pi_state;
129 struct task_struct *task;
99}; 130};
100 131
101/* 132/*
@@ -144,8 +175,9 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2)
144 * 175 *
145 * Should be called with &current->mm->mmap_sem but NOT any spinlocks. 176 * Should be called with &current->mm->mmap_sem but NOT any spinlocks.
146 */ 177 */
147static int get_futex_key(unsigned long uaddr, union futex_key *key) 178static int get_futex_key(u32 __user *uaddr, union futex_key *key)
148{ 179{
180 unsigned long address = (unsigned long)uaddr;
149 struct mm_struct *mm = current->mm; 181 struct mm_struct *mm = current->mm;
150 struct vm_area_struct *vma; 182 struct vm_area_struct *vma;
151 struct page *page; 183 struct page *page;
@@ -154,16 +186,16 @@ static int get_futex_key(unsigned long uaddr, union futex_key *key)
154 /* 186 /*
155 * The futex address must be "naturally" aligned. 187 * The futex address must be "naturally" aligned.
156 */ 188 */
157 key->both.offset = uaddr % PAGE_SIZE; 189 key->both.offset = address % PAGE_SIZE;
158 if (unlikely((key->both.offset % sizeof(u32)) != 0)) 190 if (unlikely((key->both.offset % sizeof(u32)) != 0))
159 return -EINVAL; 191 return -EINVAL;
160 uaddr -= key->both.offset; 192 address -= key->both.offset;
161 193
162 /* 194 /*
163 * The futex is hashed differently depending on whether 195 * The futex is hashed differently depending on whether
164 * it's in a shared or private mapping. So check vma first. 196 * it's in a shared or private mapping. So check vma first.
165 */ 197 */
166 vma = find_extend_vma(mm, uaddr); 198 vma = find_extend_vma(mm, address);
167 if (unlikely(!vma)) 199 if (unlikely(!vma))
168 return -EFAULT; 200 return -EFAULT;
169 201
@@ -184,7 +216,7 @@ static int get_futex_key(unsigned long uaddr, union futex_key *key)
184 */ 216 */
185 if (likely(!(vma->vm_flags & VM_MAYSHARE))) { 217 if (likely(!(vma->vm_flags & VM_MAYSHARE))) {
186 key->private.mm = mm; 218 key->private.mm = mm;
187 key->private.uaddr = uaddr; 219 key->private.address = address;
188 return 0; 220 return 0;
189 } 221 }
190 222
@@ -194,7 +226,7 @@ static int get_futex_key(unsigned long uaddr, union futex_key *key)
194 key->shared.inode = vma->vm_file->f_dentry->d_inode; 226 key->shared.inode = vma->vm_file->f_dentry->d_inode;
195 key->both.offset++; /* Bit 0 of offset indicates inode-based key. */ 227 key->both.offset++; /* Bit 0 of offset indicates inode-based key. */
196 if (likely(!(vma->vm_flags & VM_NONLINEAR))) { 228 if (likely(!(vma->vm_flags & VM_NONLINEAR))) {
197 key->shared.pgoff = (((uaddr - vma->vm_start) >> PAGE_SHIFT) 229 key->shared.pgoff = (((address - vma->vm_start) >> PAGE_SHIFT)
198 + vma->vm_pgoff); 230 + vma->vm_pgoff);
199 return 0; 231 return 0;
200 } 232 }
@@ -205,7 +237,7 @@ static int get_futex_key(unsigned long uaddr, union futex_key *key)
205 * from swap. But that's a lot of code to duplicate here 237 * from swap. But that's a lot of code to duplicate here
206 * for a rare case, so we simply fetch the page. 238 * for a rare case, so we simply fetch the page.
207 */ 239 */
208 err = get_user_pages(current, mm, uaddr, 1, 0, 0, &page, NULL); 240 err = get_user_pages(current, mm, address, 1, 0, 0, &page, NULL);
209 if (err >= 0) { 241 if (err >= 0) {
210 key->shared.pgoff = 242 key->shared.pgoff =
211 page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); 243 page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
@@ -246,18 +278,244 @@ static void drop_key_refs(union futex_key *key)
246 } 278 }
247} 279}
248 280
249static inline int get_futex_value_locked(int *dest, int __user *from) 281static inline int get_futex_value_locked(u32 *dest, u32 __user *from)
250{ 282{
251 int ret; 283 int ret;
252 284
253 inc_preempt_count(); 285 inc_preempt_count();
254 ret = __copy_from_user_inatomic(dest, from, sizeof(int)); 286 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
255 dec_preempt_count(); 287 dec_preempt_count();
256 288
257 return ret ? -EFAULT : 0; 289 return ret ? -EFAULT : 0;
258} 290}
259 291
260/* 292/*
293 * Fault handling. Called with current->mm->mmap_sem held.
294 */
295static int futex_handle_fault(unsigned long address, int attempt)
296{
297 struct vm_area_struct * vma;
298 struct mm_struct *mm = current->mm;
299
300 if (attempt >= 2 || !(vma = find_vma(mm, address)) ||
301 vma->vm_start > address || !(vma->vm_flags & VM_WRITE))
302 return -EFAULT;
303
304 switch (handle_mm_fault(mm, vma, address, 1)) {
305 case VM_FAULT_MINOR:
306 current->min_flt++;
307 break;
308 case VM_FAULT_MAJOR:
309 current->maj_flt++;
310 break;
311 default:
312 return -EFAULT;
313 }
314 return 0;
315}
316
317/*
318 * PI code:
319 */
320static int refill_pi_state_cache(void)
321{
322 struct futex_pi_state *pi_state;
323
324 if (likely(current->pi_state_cache))
325 return 0;
326
327 pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL);
328
329 if (!pi_state)
330 return -ENOMEM;
331
332 memset(pi_state, 0, sizeof(*pi_state));
333 INIT_LIST_HEAD(&pi_state->list);
334 /* pi_mutex gets initialized later */
335 pi_state->owner = NULL;
336 atomic_set(&pi_state->refcount, 1);
337
338 current->pi_state_cache = pi_state;
339
340 return 0;
341}
342
343static struct futex_pi_state * alloc_pi_state(void)
344{
345 struct futex_pi_state *pi_state = current->pi_state_cache;
346
347 WARN_ON(!pi_state);
348 current->pi_state_cache = NULL;
349
350 return pi_state;
351}
352
353static void free_pi_state(struct futex_pi_state *pi_state)
354{
355 if (!atomic_dec_and_test(&pi_state->refcount))
356 return;
357
358 /*
359 * If pi_state->owner is NULL, the owner is most probably dying
360 * and has cleaned up the pi_state already
361 */
362 if (pi_state->owner) {
363 spin_lock_irq(&pi_state->owner->pi_lock);
364 list_del_init(&pi_state->list);
365 spin_unlock_irq(&pi_state->owner->pi_lock);
366
367 rt_mutex_proxy_unlock(&pi_state->pi_mutex, pi_state->owner);
368 }
369
370 if (current->pi_state_cache)
371 kfree(pi_state);
372 else {
373 /*
374 * pi_state->list is already empty.
375 * clear pi_state->owner.
376 * refcount is at 0 - put it back to 1.
377 */
378 pi_state->owner = NULL;
379 atomic_set(&pi_state->refcount, 1);
380 current->pi_state_cache = pi_state;
381 }
382}
383
384/*
385 * Look up the task based on what TID userspace gave us.
386 * We dont trust it.
387 */
388static struct task_struct * futex_find_get_task(pid_t pid)
389{
390 struct task_struct *p;
391
392 read_lock(&tasklist_lock);
393 p = find_task_by_pid(pid);
394 if (!p)
395 goto out_unlock;
396 if ((current->euid != p->euid) && (current->euid != p->uid)) {
397 p = NULL;
398 goto out_unlock;
399 }
400 if (p->state == EXIT_ZOMBIE || p->exit_state == EXIT_ZOMBIE) {
401 p = NULL;
402 goto out_unlock;
403 }
404 get_task_struct(p);
405out_unlock:
406 read_unlock(&tasklist_lock);
407
408 return p;
409}
410
411/*
412 * This task is holding PI mutexes at exit time => bad.
413 * Kernel cleans up PI-state, but userspace is likely hosed.
414 * (Robust-futex cleanup is separate and might save the day for userspace.)
415 */
416void exit_pi_state_list(struct task_struct *curr)
417{
418 struct futex_hash_bucket *hb;
419 struct list_head *next, *head = &curr->pi_state_list;
420 struct futex_pi_state *pi_state;
421 union futex_key key;
422
423 /*
424 * We are a ZOMBIE and nobody can enqueue itself on
425 * pi_state_list anymore, but we have to be careful
426 * versus waiters unqueueing themselfs
427 */
428 spin_lock_irq(&curr->pi_lock);
429 while (!list_empty(head)) {
430
431 next = head->next;
432 pi_state = list_entry(next, struct futex_pi_state, list);
433 key = pi_state->key;
434 spin_unlock_irq(&curr->pi_lock);
435
436 hb = hash_futex(&key);
437 spin_lock(&hb->lock);
438
439 spin_lock_irq(&curr->pi_lock);
440 if (head->next != next) {
441 spin_unlock(&hb->lock);
442 continue;
443 }
444
445 list_del_init(&pi_state->list);
446
447 WARN_ON(pi_state->owner != curr);
448
449 pi_state->owner = NULL;
450 spin_unlock_irq(&curr->pi_lock);
451
452 rt_mutex_unlock(&pi_state->pi_mutex);
453
454 spin_unlock(&hb->lock);
455
456 spin_lock_irq(&curr->pi_lock);
457 }
458 spin_unlock_irq(&curr->pi_lock);
459}
460
461static int
462lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, struct futex_q *me)
463{
464 struct futex_pi_state *pi_state = NULL;
465 struct futex_q *this, *next;
466 struct list_head *head;
467 struct task_struct *p;
468 pid_t pid;
469
470 head = &hb->chain;
471
472 list_for_each_entry_safe(this, next, head, list) {
473 if (match_futex (&this->key, &me->key)) {
474 /*
475 * Another waiter already exists - bump up
476 * the refcount and return its pi_state:
477 */
478 pi_state = this->pi_state;
479 atomic_inc(&pi_state->refcount);
480 me->pi_state = pi_state;
481
482 return 0;
483 }
484 }
485
486 /*
487 * We are the first waiter - try to look up the real owner and
488 * attach the new pi_state to it:
489 */
490 pid = uval & FUTEX_TID_MASK;
491 p = futex_find_get_task(pid);
492 if (!p)
493 return -ESRCH;
494
495 pi_state = alloc_pi_state();
496
497 /*
498 * Initialize the pi_mutex in locked state and make 'p'
499 * the owner of it:
500 */
501 rt_mutex_init_proxy_locked(&pi_state->pi_mutex, p);
502
503 /* Store the key for possible exit cleanups: */
504 pi_state->key = me->key;
505
506 spin_lock_irq(&p->pi_lock);
507 list_add(&pi_state->list, &p->pi_state_list);
508 pi_state->owner = p;
509 spin_unlock_irq(&p->pi_lock);
510
511 put_task_struct(p);
512
513 me->pi_state = pi_state;
514
515 return 0;
516}
517
518/*
261 * The hash bucket lock must be held when this is called. 519 * The hash bucket lock must be held when this is called.
262 * Afterwards, the futex_q must not be accessed. 520 * Afterwards, the futex_q must not be accessed.
263 */ 521 */
@@ -284,16 +542,80 @@ static void wake_futex(struct futex_q *q)
284 q->lock_ptr = NULL; 542 q->lock_ptr = NULL;
285} 543}
286 544
545static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
546{
547 struct task_struct *new_owner;
548 struct futex_pi_state *pi_state = this->pi_state;
549 u32 curval, newval;
550
551 if (!pi_state)
552 return -EINVAL;
553
554 new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
555
556 /*
557 * This happens when we have stolen the lock and the original
558 * pending owner did not enqueue itself back on the rt_mutex.
559 * Thats not a tragedy. We know that way, that a lock waiter
560 * is on the fly. We make the futex_q waiter the pending owner.
561 */
562 if (!new_owner)
563 new_owner = this->task;
564
565 /*
566 * We pass it to the next owner. (The WAITERS bit is always
567 * kept enabled while there is PI state around. We must also
568 * preserve the owner died bit.)
569 */
570 newval = (uval & FUTEX_OWNER_DIED) | FUTEX_WAITERS | new_owner->pid;
571
572 inc_preempt_count();
573 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
574 dec_preempt_count();
575
576 if (curval == -EFAULT)
577 return -EFAULT;
578 if (curval != uval)
579 return -EINVAL;
580
581 list_del_init(&pi_state->owner->pi_state_list);
582 list_add(&pi_state->list, &new_owner->pi_state_list);
583 pi_state->owner = new_owner;
584 rt_mutex_unlock(&pi_state->pi_mutex);
585
586 return 0;
587}
588
589static int unlock_futex_pi(u32 __user *uaddr, u32 uval)
590{
591 u32 oldval;
592
593 /*
594 * There is no waiter, so we unlock the futex. The owner died
595 * bit has not to be preserved here. We are the owner:
596 */
597 inc_preempt_count();
598 oldval = futex_atomic_cmpxchg_inatomic(uaddr, uval, 0);
599 dec_preempt_count();
600
601 if (oldval == -EFAULT)
602 return oldval;
603 if (oldval != uval)
604 return -EAGAIN;
605
606 return 0;
607}
608
287/* 609/*
288 * Wake up all waiters hashed on the physical page that is mapped 610 * Wake up all waiters hashed on the physical page that is mapped
289 * to this virtual address: 611 * to this virtual address:
290 */ 612 */
291static int futex_wake(unsigned long uaddr, int nr_wake) 613static int futex_wake(u32 __user *uaddr, int nr_wake)
292{ 614{
293 union futex_key key; 615 struct futex_hash_bucket *hb;
294 struct futex_hash_bucket *bh;
295 struct list_head *head;
296 struct futex_q *this, *next; 616 struct futex_q *this, *next;
617 struct list_head *head;
618 union futex_key key;
297 int ret; 619 int ret;
298 620
299 down_read(&current->mm->mmap_sem); 621 down_read(&current->mm->mmap_sem);
@@ -302,19 +624,21 @@ static int futex_wake(unsigned long uaddr, int nr_wake)
302 if (unlikely(ret != 0)) 624 if (unlikely(ret != 0))
303 goto out; 625 goto out;
304 626
305 bh = hash_futex(&key); 627 hb = hash_futex(&key);
306 spin_lock(&bh->lock); 628 spin_lock(&hb->lock);
307 head = &bh->chain; 629 head = &hb->chain;
308 630
309 list_for_each_entry_safe(this, next, head, list) { 631 list_for_each_entry_safe(this, next, head, list) {
310 if (match_futex (&this->key, &key)) { 632 if (match_futex (&this->key, &key)) {
633 if (this->pi_state)
634 return -EINVAL;
311 wake_futex(this); 635 wake_futex(this);
312 if (++ret >= nr_wake) 636 if (++ret >= nr_wake)
313 break; 637 break;
314 } 638 }
315 } 639 }
316 640
317 spin_unlock(&bh->lock); 641 spin_unlock(&hb->lock);
318out: 642out:
319 up_read(&current->mm->mmap_sem); 643 up_read(&current->mm->mmap_sem);
320 return ret; 644 return ret;
@@ -324,10 +648,12 @@ out:
324 * Wake up all waiters hashed on the physical page that is mapped 648 * Wake up all waiters hashed on the physical page that is mapped
325 * to this virtual address: 649 * to this virtual address:
326 */ 650 */
327static int futex_wake_op(unsigned long uaddr1, unsigned long uaddr2, int nr_wake, int nr_wake2, int op) 651static int
652futex_wake_op(u32 __user *uaddr1, u32 __user *uaddr2,
653 int nr_wake, int nr_wake2, int op)
328{ 654{
329 union futex_key key1, key2; 655 union futex_key key1, key2;
330 struct futex_hash_bucket *bh1, *bh2; 656 struct futex_hash_bucket *hb1, *hb2;
331 struct list_head *head; 657 struct list_head *head;
332 struct futex_q *this, *next; 658 struct futex_q *this, *next;
333 int ret, op_ret, attempt = 0; 659 int ret, op_ret, attempt = 0;
@@ -342,27 +668,29 @@ retryfull:
342 if (unlikely(ret != 0)) 668 if (unlikely(ret != 0))
343 goto out; 669 goto out;
344 670
345 bh1 = hash_futex(&key1); 671 hb1 = hash_futex(&key1);
346 bh2 = hash_futex(&key2); 672 hb2 = hash_futex(&key2);
347 673
348retry: 674retry:
349 if (bh1 < bh2) 675 if (hb1 < hb2)
350 spin_lock(&bh1->lock); 676 spin_lock(&hb1->lock);
351 spin_lock(&bh2->lock); 677 spin_lock(&hb2->lock);
352 if (bh1 > bh2) 678 if (hb1 > hb2)
353 spin_lock(&bh1->lock); 679 spin_lock(&hb1->lock);
354 680
355 op_ret = futex_atomic_op_inuser(op, (int __user *)uaddr2); 681 op_ret = futex_atomic_op_inuser(op, uaddr2);
356 if (unlikely(op_ret < 0)) { 682 if (unlikely(op_ret < 0)) {
357 int dummy; 683 u32 dummy;
358 684
359 spin_unlock(&bh1->lock); 685 spin_unlock(&hb1->lock);
360 if (bh1 != bh2) 686 if (hb1 != hb2)
361 spin_unlock(&bh2->lock); 687 spin_unlock(&hb2->lock);
362 688
363#ifndef CONFIG_MMU 689#ifndef CONFIG_MMU
364 /* we don't get EFAULT from MMU faults if we don't have an MMU, 690 /*
365 * but we might get them from range checking */ 691 * we don't get EFAULT from MMU faults if we don't have an MMU,
692 * but we might get them from range checking
693 */
366 ret = op_ret; 694 ret = op_ret;
367 goto out; 695 goto out;
368#endif 696#endif
@@ -372,47 +700,34 @@ retry:
372 goto out; 700 goto out;
373 } 701 }
374 702
375 /* futex_atomic_op_inuser needs to both read and write 703 /*
704 * futex_atomic_op_inuser needs to both read and write
376 * *(int __user *)uaddr2, but we can't modify it 705 * *(int __user *)uaddr2, but we can't modify it
377 * non-atomically. Therefore, if get_user below is not 706 * non-atomically. Therefore, if get_user below is not
378 * enough, we need to handle the fault ourselves, while 707 * enough, we need to handle the fault ourselves, while
379 * still holding the mmap_sem. */ 708 * still holding the mmap_sem.
709 */
380 if (attempt++) { 710 if (attempt++) {
381 struct vm_area_struct * vma; 711 if (futex_handle_fault((unsigned long)uaddr2,
382 struct mm_struct *mm = current->mm; 712 attempt))
383
384 ret = -EFAULT;
385 if (attempt >= 2 ||
386 !(vma = find_vma(mm, uaddr2)) ||
387 vma->vm_start > uaddr2 ||
388 !(vma->vm_flags & VM_WRITE))
389 goto out;
390
391 switch (handle_mm_fault(mm, vma, uaddr2, 1)) {
392 case VM_FAULT_MINOR:
393 current->min_flt++;
394 break;
395 case VM_FAULT_MAJOR:
396 current->maj_flt++;
397 break;
398 default:
399 goto out; 713 goto out;
400 }
401 goto retry; 714 goto retry;
402 } 715 }
403 716
404 /* If we would have faulted, release mmap_sem, 717 /*
405 * fault it in and start all over again. */ 718 * If we would have faulted, release mmap_sem,
719 * fault it in and start all over again.
720 */
406 up_read(&current->mm->mmap_sem); 721 up_read(&current->mm->mmap_sem);
407 722
408 ret = get_user(dummy, (int __user *)uaddr2); 723 ret = get_user(dummy, uaddr2);
409 if (ret) 724 if (ret)
410 return ret; 725 return ret;
411 726
412 goto retryfull; 727 goto retryfull;
413 } 728 }
414 729
415 head = &bh1->chain; 730 head = &hb1->chain;
416 731
417 list_for_each_entry_safe(this, next, head, list) { 732 list_for_each_entry_safe(this, next, head, list) {
418 if (match_futex (&this->key, &key1)) { 733 if (match_futex (&this->key, &key1)) {
@@ -423,7 +738,7 @@ retry:
423 } 738 }
424 739
425 if (op_ret > 0) { 740 if (op_ret > 0) {
426 head = &bh2->chain; 741 head = &hb2->chain;
427 742
428 op_ret = 0; 743 op_ret = 0;
429 list_for_each_entry_safe(this, next, head, list) { 744 list_for_each_entry_safe(this, next, head, list) {
@@ -436,9 +751,9 @@ retry:
436 ret += op_ret; 751 ret += op_ret;
437 } 752 }
438 753
439 spin_unlock(&bh1->lock); 754 spin_unlock(&hb1->lock);
440 if (bh1 != bh2) 755 if (hb1 != hb2)
441 spin_unlock(&bh2->lock); 756 spin_unlock(&hb2->lock);
442out: 757out:
443 up_read(&current->mm->mmap_sem); 758 up_read(&current->mm->mmap_sem);
444 return ret; 759 return ret;
@@ -448,11 +763,11 @@ out:
448 * Requeue all waiters hashed on one physical page to another 763 * Requeue all waiters hashed on one physical page to another
449 * physical page. 764 * physical page.
450 */ 765 */
451static int futex_requeue(unsigned long uaddr1, unsigned long uaddr2, 766static int futex_requeue(u32 __user *uaddr1, u32 __user *uaddr2,
452 int nr_wake, int nr_requeue, int *valp) 767 int nr_wake, int nr_requeue, u32 *cmpval)
453{ 768{
454 union futex_key key1, key2; 769 union futex_key key1, key2;
455 struct futex_hash_bucket *bh1, *bh2; 770 struct futex_hash_bucket *hb1, *hb2;
456 struct list_head *head1; 771 struct list_head *head1;
457 struct futex_q *this, *next; 772 struct futex_q *this, *next;
458 int ret, drop_count = 0; 773 int ret, drop_count = 0;
@@ -467,68 +782,72 @@ static int futex_requeue(unsigned long uaddr1, unsigned long uaddr2,
467 if (unlikely(ret != 0)) 782 if (unlikely(ret != 0))
468 goto out; 783 goto out;
469 784
470 bh1 = hash_futex(&key1); 785 hb1 = hash_futex(&key1);
471 bh2 = hash_futex(&key2); 786 hb2 = hash_futex(&key2);
472 787
473 if (bh1 < bh2) 788 if (hb1 < hb2)
474 spin_lock(&bh1->lock); 789 spin_lock(&hb1->lock);
475 spin_lock(&bh2->lock); 790 spin_lock(&hb2->lock);
476 if (bh1 > bh2) 791 if (hb1 > hb2)
477 spin_lock(&bh1->lock); 792 spin_lock(&hb1->lock);
478 793
479 if (likely(valp != NULL)) { 794 if (likely(cmpval != NULL)) {
480 int curval; 795 u32 curval;
481 796
482 ret = get_futex_value_locked(&curval, (int __user *)uaddr1); 797 ret = get_futex_value_locked(&curval, uaddr1);
483 798
484 if (unlikely(ret)) { 799 if (unlikely(ret)) {
485 spin_unlock(&bh1->lock); 800 spin_unlock(&hb1->lock);
486 if (bh1 != bh2) 801 if (hb1 != hb2)
487 spin_unlock(&bh2->lock); 802 spin_unlock(&hb2->lock);
488 803
489 /* If we would have faulted, release mmap_sem, fault 804 /*
805 * If we would have faulted, release mmap_sem, fault
490 * it in and start all over again. 806 * it in and start all over again.
491 */ 807 */
492 up_read(&current->mm->mmap_sem); 808 up_read(&current->mm->mmap_sem);
493 809
494 ret = get_user(curval, (int __user *)uaddr1); 810 ret = get_user(curval, uaddr1);
495 811
496 if (!ret) 812 if (!ret)
497 goto retry; 813 goto retry;
498 814
499 return ret; 815 return ret;
500 } 816 }
501 if (curval != *valp) { 817 if (curval != *cmpval) {
502 ret = -EAGAIN; 818 ret = -EAGAIN;
503 goto out_unlock; 819 goto out_unlock;
504 } 820 }
505 } 821 }
506 822
507 head1 = &bh1->chain; 823 head1 = &hb1->chain;
508 list_for_each_entry_safe(this, next, head1, list) { 824 list_for_each_entry_safe(this, next, head1, list) {
509 if (!match_futex (&this->key, &key1)) 825 if (!match_futex (&this->key, &key1))
510 continue; 826 continue;
511 if (++ret <= nr_wake) { 827 if (++ret <= nr_wake) {
512 wake_futex(this); 828 wake_futex(this);
513 } else { 829 } else {
514 list_move_tail(&this->list, &bh2->chain); 830 /*
515 this->lock_ptr = &bh2->lock; 831 * If key1 and key2 hash to the same bucket, no need to
832 * requeue.
833 */
834 if (likely(head1 != &hb2->chain)) {
835 list_move_tail(&this->list, &hb2->chain);
836 this->lock_ptr = &hb2->lock;
837 }
516 this->key = key2; 838 this->key = key2;
517 get_key_refs(&key2); 839 get_key_refs(&key2);
518 drop_count++; 840 drop_count++;
519 841
520 if (ret - nr_wake >= nr_requeue) 842 if (ret - nr_wake >= nr_requeue)
521 break; 843 break;
522 /* Make sure to stop if key1 == key2 */
523 if (head1 == &bh2->chain && head1 != &next->list)
524 head1 = &this->list;
525 } 844 }
526 } 845 }
527 846
528out_unlock: 847out_unlock:
529 spin_unlock(&bh1->lock); 848 spin_unlock(&hb1->lock);
530 if (bh1 != bh2) 849 if (hb1 != hb2)
531 spin_unlock(&bh2->lock); 850 spin_unlock(&hb2->lock);
532 851
533 /* drop_key_refs() must be called outside the spinlocks. */ 852 /* drop_key_refs() must be called outside the spinlocks. */
534 while (--drop_count >= 0) 853 while (--drop_count >= 0)
@@ -543,7 +862,7 @@ out:
543static inline struct futex_hash_bucket * 862static inline struct futex_hash_bucket *
544queue_lock(struct futex_q *q, int fd, struct file *filp) 863queue_lock(struct futex_q *q, int fd, struct file *filp)
545{ 864{
546 struct futex_hash_bucket *bh; 865 struct futex_hash_bucket *hb;
547 866
548 q->fd = fd; 867 q->fd = fd;
549 q->filp = filp; 868 q->filp = filp;
@@ -551,23 +870,24 @@ queue_lock(struct futex_q *q, int fd, struct file *filp)
551 init_waitqueue_head(&q->waiters); 870 init_waitqueue_head(&q->waiters);
552 871
553 get_key_refs(&q->key); 872 get_key_refs(&q->key);
554 bh = hash_futex(&q->key); 873 hb = hash_futex(&q->key);
555 q->lock_ptr = &bh->lock; 874 q->lock_ptr = &hb->lock;
556 875
557 spin_lock(&bh->lock); 876 spin_lock(&hb->lock);
558 return bh; 877 return hb;
559} 878}
560 879
561static inline void __queue_me(struct futex_q *q, struct futex_hash_bucket *bh) 880static inline void __queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
562{ 881{
563 list_add_tail(&q->list, &bh->chain); 882 list_add_tail(&q->list, &hb->chain);
564 spin_unlock(&bh->lock); 883 q->task = current;
884 spin_unlock(&hb->lock);
565} 885}
566 886
567static inline void 887static inline void
568queue_unlock(struct futex_q *q, struct futex_hash_bucket *bh) 888queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb)
569{ 889{
570 spin_unlock(&bh->lock); 890 spin_unlock(&hb->lock);
571 drop_key_refs(&q->key); 891 drop_key_refs(&q->key);
572} 892}
573 893
@@ -579,16 +899,17 @@ queue_unlock(struct futex_q *q, struct futex_hash_bucket *bh)
579/* The key must be already stored in q->key. */ 899/* The key must be already stored in q->key. */
580static void queue_me(struct futex_q *q, int fd, struct file *filp) 900static void queue_me(struct futex_q *q, int fd, struct file *filp)
581{ 901{
582 struct futex_hash_bucket *bh; 902 struct futex_hash_bucket *hb;
583 bh = queue_lock(q, fd, filp); 903
584 __queue_me(q, bh); 904 hb = queue_lock(q, fd, filp);
905 __queue_me(q, hb);
585} 906}
586 907
587/* Return 1 if we were still queued (ie. 0 means we were woken) */ 908/* Return 1 if we were still queued (ie. 0 means we were woken) */
588static int unqueue_me(struct futex_q *q) 909static int unqueue_me(struct futex_q *q)
589{ 910{
590 int ret = 0;
591 spinlock_t *lock_ptr; 911 spinlock_t *lock_ptr;
912 int ret = 0;
592 913
593 /* In the common case we don't take the spinlock, which is nice. */ 914 /* In the common case we don't take the spinlock, which is nice. */
594 retry: 915 retry:
@@ -614,6 +935,9 @@ static int unqueue_me(struct futex_q *q)
614 } 935 }
615 WARN_ON(list_empty(&q->list)); 936 WARN_ON(list_empty(&q->list));
616 list_del(&q->list); 937 list_del(&q->list);
938
939 BUG_ON(q->pi_state);
940
617 spin_unlock(lock_ptr); 941 spin_unlock(lock_ptr);
618 ret = 1; 942 ret = 1;
619 } 943 }
@@ -622,21 +946,42 @@ static int unqueue_me(struct futex_q *q)
622 return ret; 946 return ret;
623} 947}
624 948
625static int futex_wait(unsigned long uaddr, int val, unsigned long time) 949/*
950 * PI futexes can not be requeued and must remove themself from the
951 * hash bucket. The hash bucket lock is held on entry and dropped here.
952 */
953static void unqueue_me_pi(struct futex_q *q, struct futex_hash_bucket *hb)
626{ 954{
627 DECLARE_WAITQUEUE(wait, current); 955 WARN_ON(list_empty(&q->list));
628 int ret, curval; 956 list_del(&q->list);
957
958 BUG_ON(!q->pi_state);
959 free_pi_state(q->pi_state);
960 q->pi_state = NULL;
961
962 spin_unlock(&hb->lock);
963
964 drop_key_refs(&q->key);
965}
966
967static int futex_wait(u32 __user *uaddr, u32 val, unsigned long time)
968{
969 struct task_struct *curr = current;
970 DECLARE_WAITQUEUE(wait, curr);
971 struct futex_hash_bucket *hb;
629 struct futex_q q; 972 struct futex_q q;
630 struct futex_hash_bucket *bh; 973 u32 uval;
974 int ret;
631 975
976 q.pi_state = NULL;
632 retry: 977 retry:
633 down_read(&current->mm->mmap_sem); 978 down_read(&curr->mm->mmap_sem);
634 979
635 ret = get_futex_key(uaddr, &q.key); 980 ret = get_futex_key(uaddr, &q.key);
636 if (unlikely(ret != 0)) 981 if (unlikely(ret != 0))
637 goto out_release_sem; 982 goto out_release_sem;
638 983
639 bh = queue_lock(&q, -1, NULL); 984 hb = queue_lock(&q, -1, NULL);
640 985
641 /* 986 /*
642 * Access the page AFTER the futex is queued. 987 * Access the page AFTER the futex is queued.
@@ -658,37 +1003,35 @@ static int futex_wait(unsigned long uaddr, int val, unsigned long time)
658 * We hold the mmap semaphore, so the mapping cannot have changed 1003 * We hold the mmap semaphore, so the mapping cannot have changed
659 * since we looked it up in get_futex_key. 1004 * since we looked it up in get_futex_key.
660 */ 1005 */
661 1006 ret = get_futex_value_locked(&uval, uaddr);
662 ret = get_futex_value_locked(&curval, (int __user *)uaddr);
663 1007
664 if (unlikely(ret)) { 1008 if (unlikely(ret)) {
665 queue_unlock(&q, bh); 1009 queue_unlock(&q, hb);
666 1010
667 /* If we would have faulted, release mmap_sem, fault it in and 1011 /*
1012 * If we would have faulted, release mmap_sem, fault it in and
668 * start all over again. 1013 * start all over again.
669 */ 1014 */
670 up_read(&current->mm->mmap_sem); 1015 up_read(&curr->mm->mmap_sem);
671 1016
672 ret = get_user(curval, (int __user *)uaddr); 1017 ret = get_user(uval, uaddr);
673 1018
674 if (!ret) 1019 if (!ret)
675 goto retry; 1020 goto retry;
676 return ret; 1021 return ret;
677 } 1022 }
678 if (curval != val) { 1023 ret = -EWOULDBLOCK;
679 ret = -EWOULDBLOCK; 1024 if (uval != val)
680 queue_unlock(&q, bh); 1025 goto out_unlock_release_sem;
681 goto out_release_sem;
682 }
683 1026
684 /* Only actually queue if *uaddr contained val. */ 1027 /* Only actually queue if *uaddr contained val. */
685 __queue_me(&q, bh); 1028 __queue_me(&q, hb);
686 1029
687 /* 1030 /*
688 * Now the futex is queued and we have checked the data, we 1031 * Now the futex is queued and we have checked the data, we
689 * don't want to hold mmap_sem while we sleep. 1032 * don't want to hold mmap_sem while we sleep.
690 */ 1033 */
691 up_read(&current->mm->mmap_sem); 1034 up_read(&curr->mm->mmap_sem);
692 1035
693 /* 1036 /*
694 * There might have been scheduling since the queue_me(), as we 1037 * There might have been scheduling since the queue_me(), as we
@@ -720,12 +1063,421 @@ static int futex_wait(unsigned long uaddr, int val, unsigned long time)
720 return 0; 1063 return 0;
721 if (time == 0) 1064 if (time == 0)
722 return -ETIMEDOUT; 1065 return -ETIMEDOUT;
723 /* We expect signal_pending(current), but another thread may 1066 /*
724 * have handled it for us already. */ 1067 * We expect signal_pending(current), but another thread may
1068 * have handled it for us already.
1069 */
725 return -EINTR; 1070 return -EINTR;
726 1071
1072 out_unlock_release_sem:
1073 queue_unlock(&q, hb);
1074
727 out_release_sem: 1075 out_release_sem:
1076 up_read(&curr->mm->mmap_sem);
1077 return ret;
1078}
1079
1080/*
1081 * Userspace tried a 0 -> TID atomic transition of the futex value
1082 * and failed. The kernel side here does the whole locking operation:
1083 * if there are waiters then it will block, it does PI, etc. (Due to
1084 * races the kernel might see a 0 value of the futex too.)
1085 */
1086static int do_futex_lock_pi(u32 __user *uaddr, int detect, int trylock,
1087 struct hrtimer_sleeper *to)
1088{
1089 struct task_struct *curr = current;
1090 struct futex_hash_bucket *hb;
1091 u32 uval, newval, curval;
1092 struct futex_q q;
1093 int ret, attempt = 0;
1094
1095 if (refill_pi_state_cache())
1096 return -ENOMEM;
1097
1098 q.pi_state = NULL;
1099 retry:
1100 down_read(&curr->mm->mmap_sem);
1101
1102 ret = get_futex_key(uaddr, &q.key);
1103 if (unlikely(ret != 0))
1104 goto out_release_sem;
1105
1106 hb = queue_lock(&q, -1, NULL);
1107
1108 retry_locked:
1109 /*
1110 * To avoid races, we attempt to take the lock here again
1111 * (by doing a 0 -> TID atomic cmpxchg), while holding all
1112 * the locks. It will most likely not succeed.
1113 */
1114 newval = current->pid;
1115
1116 inc_preempt_count();
1117 curval = futex_atomic_cmpxchg_inatomic(uaddr, 0, newval);
1118 dec_preempt_count();
1119
1120 if (unlikely(curval == -EFAULT))
1121 goto uaddr_faulted;
1122
1123 /* We own the lock already */
1124 if (unlikely((curval & FUTEX_TID_MASK) == current->pid)) {
1125 if (!detect && 0)
1126 force_sig(SIGKILL, current);
1127 ret = -EDEADLK;
1128 goto out_unlock_release_sem;
1129 }
1130
1131 /*
1132 * Surprise - we got the lock. Just return
1133 * to userspace:
1134 */
1135 if (unlikely(!curval))
1136 goto out_unlock_release_sem;
1137
1138 uval = curval;
1139 newval = uval | FUTEX_WAITERS;
1140
1141 inc_preempt_count();
1142 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
1143 dec_preempt_count();
1144
1145 if (unlikely(curval == -EFAULT))
1146 goto uaddr_faulted;
1147 if (unlikely(curval != uval))
1148 goto retry_locked;
1149
1150 /*
1151 * We dont have the lock. Look up the PI state (or create it if
1152 * we are the first waiter):
1153 */
1154 ret = lookup_pi_state(uval, hb, &q);
1155
1156 if (unlikely(ret)) {
1157 /*
1158 * There were no waiters and the owner task lookup
1159 * failed. When the OWNER_DIED bit is set, then we
1160 * know that this is a robust futex and we actually
1161 * take the lock. This is safe as we are protected by
1162 * the hash bucket lock. We also set the waiters bit
1163 * unconditionally here, to simplify glibc handling of
1164 * multiple tasks racing to acquire the lock and
1165 * cleanup the problems which were left by the dead
1166 * owner.
1167 */
1168 if (curval & FUTEX_OWNER_DIED) {
1169 uval = newval;
1170 newval = current->pid |
1171 FUTEX_OWNER_DIED | FUTEX_WAITERS;
1172
1173 inc_preempt_count();
1174 curval = futex_atomic_cmpxchg_inatomic(uaddr,
1175 uval, newval);
1176 dec_preempt_count();
1177
1178 if (unlikely(curval == -EFAULT))
1179 goto uaddr_faulted;
1180 if (unlikely(curval != uval))
1181 goto retry_locked;
1182 ret = 0;
1183 }
1184 goto out_unlock_release_sem;
1185 }
1186
1187 /*
1188 * Only actually queue now that the atomic ops are done:
1189 */
1190 __queue_me(&q, hb);
1191
1192 /*
1193 * Now the futex is queued and we have checked the data, we
1194 * don't want to hold mmap_sem while we sleep.
1195 */
1196 up_read(&curr->mm->mmap_sem);
1197
1198 WARN_ON(!q.pi_state);
1199 /*
1200 * Block on the PI mutex:
1201 */
1202 if (!trylock)
1203 ret = rt_mutex_timed_lock(&q.pi_state->pi_mutex, to, 1);
1204 else {
1205 ret = rt_mutex_trylock(&q.pi_state->pi_mutex);
1206 /* Fixup the trylock return value: */
1207 ret = ret ? 0 : -EWOULDBLOCK;
1208 }
1209
1210 down_read(&curr->mm->mmap_sem);
1211 hb = queue_lock(&q, -1, NULL);
1212
1213 /*
1214 * Got the lock. We might not be the anticipated owner if we
1215 * did a lock-steal - fix up the PI-state in that case.
1216 */
1217 if (!ret && q.pi_state->owner != curr) {
1218 u32 newtid = current->pid | FUTEX_WAITERS;
1219
1220 /* Owner died? */
1221 if (q.pi_state->owner != NULL) {
1222 spin_lock_irq(&q.pi_state->owner->pi_lock);
1223 list_del_init(&q.pi_state->list);
1224 spin_unlock_irq(&q.pi_state->owner->pi_lock);
1225 } else
1226 newtid |= FUTEX_OWNER_DIED;
1227
1228 q.pi_state->owner = current;
1229
1230 spin_lock_irq(&current->pi_lock);
1231 list_add(&q.pi_state->list, &current->pi_state_list);
1232 spin_unlock_irq(&current->pi_lock);
1233
1234 /* Unqueue and drop the lock */
1235 unqueue_me_pi(&q, hb);
1236 up_read(&curr->mm->mmap_sem);
1237 /*
1238 * We own it, so we have to replace the pending owner
1239 * TID. This must be atomic as we have preserve the
1240 * owner died bit here.
1241 */
1242 ret = get_user(uval, uaddr);
1243 while (!ret) {
1244 newval = (uval & FUTEX_OWNER_DIED) | newtid;
1245 curval = futex_atomic_cmpxchg_inatomic(uaddr,
1246 uval, newval);
1247 if (curval == -EFAULT)
1248 ret = -EFAULT;
1249 if (curval == uval)
1250 break;
1251 uval = curval;
1252 }
1253 } else {
1254 /*
1255 * Catch the rare case, where the lock was released
1256 * when we were on the way back before we locked
1257 * the hash bucket.
1258 */
1259 if (ret && q.pi_state->owner == curr) {
1260 if (rt_mutex_trylock(&q.pi_state->pi_mutex))
1261 ret = 0;
1262 }
1263 /* Unqueue and drop the lock */
1264 unqueue_me_pi(&q, hb);
1265 up_read(&curr->mm->mmap_sem);
1266 }
1267
1268 if (!detect && ret == -EDEADLK && 0)
1269 force_sig(SIGKILL, current);
1270
1271 return ret;
1272
1273 out_unlock_release_sem:
1274 queue_unlock(&q, hb);
1275
1276 out_release_sem:
1277 up_read(&curr->mm->mmap_sem);
1278 return ret;
1279
1280 uaddr_faulted:
1281 /*
1282 * We have to r/w *(int __user *)uaddr, but we can't modify it
1283 * non-atomically. Therefore, if get_user below is not
1284 * enough, we need to handle the fault ourselves, while
1285 * still holding the mmap_sem.
1286 */
1287 if (attempt++) {
1288 if (futex_handle_fault((unsigned long)uaddr, attempt))
1289 goto out_unlock_release_sem;
1290
1291 goto retry_locked;
1292 }
1293
1294 queue_unlock(&q, hb);
1295 up_read(&curr->mm->mmap_sem);
1296
1297 ret = get_user(uval, uaddr);
1298 if (!ret && (uval != -EFAULT))
1299 goto retry;
1300
1301 return ret;
1302}
1303
1304/*
1305 * Restart handler
1306 */
1307static long futex_lock_pi_restart(struct restart_block *restart)
1308{
1309 struct hrtimer_sleeper timeout, *to = NULL;
1310 int ret;
1311
1312 restart->fn = do_no_restart_syscall;
1313
1314 if (restart->arg2 || restart->arg3) {
1315 to = &timeout;
1316 hrtimer_init(&to->timer, CLOCK_REALTIME, HRTIMER_ABS);
1317 hrtimer_init_sleeper(to, current);
1318 to->timer.expires.tv64 = ((u64)restart->arg1 << 32) |
1319 (u64) restart->arg0;
1320 }
1321
1322 pr_debug("lock_pi restart: %p, %d (%d)\n",
1323 (u32 __user *)restart->arg0, current->pid);
1324
1325 ret = do_futex_lock_pi((u32 __user *)restart->arg0, restart->arg1,
1326 0, to);
1327
1328 if (ret != -EINTR)
1329 return ret;
1330
1331 restart->fn = futex_lock_pi_restart;
1332
1333 /* The other values are filled in */
1334 return -ERESTART_RESTARTBLOCK;
1335}
1336
1337/*
1338 * Called from the syscall entry below.
1339 */
1340static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1341 long nsec, int trylock)
1342{
1343 struct hrtimer_sleeper timeout, *to = NULL;
1344 struct restart_block *restart;
1345 int ret;
1346
1347 if (sec != MAX_SCHEDULE_TIMEOUT) {
1348 to = &timeout;
1349 hrtimer_init(&to->timer, CLOCK_REALTIME, HRTIMER_ABS);
1350 hrtimer_init_sleeper(to, current);
1351 to->timer.expires = ktime_set(sec, nsec);
1352 }
1353
1354 ret = do_futex_lock_pi(uaddr, detect, trylock, to);
1355
1356 if (ret != -EINTR)
1357 return ret;
1358
1359 pr_debug("lock_pi interrupted: %p, %d (%d)\n", uaddr, current->pid);
1360
1361 restart = &current_thread_info()->restart_block;
1362 restart->fn = futex_lock_pi_restart;
1363 restart->arg0 = (unsigned long) uaddr;
1364 restart->arg1 = detect;
1365 if (to) {
1366 restart->arg2 = to->timer.expires.tv64 & 0xFFFFFFFF;
1367 restart->arg3 = to->timer.expires.tv64 >> 32;
1368 } else
1369 restart->arg2 = restart->arg3 = 0;
1370
1371 return -ERESTART_RESTARTBLOCK;
1372}
1373
1374/*
1375 * Userspace attempted a TID -> 0 atomic transition, and failed.
1376 * This is the in-kernel slowpath: we look up the PI state (if any),
1377 * and do the rt-mutex unlock.
1378 */
1379static int futex_unlock_pi(u32 __user *uaddr)
1380{
1381 struct futex_hash_bucket *hb;
1382 struct futex_q *this, *next;
1383 u32 uval;
1384 struct list_head *head;
1385 union futex_key key;
1386 int ret, attempt = 0;
1387
1388retry:
1389 if (get_user(uval, uaddr))
1390 return -EFAULT;
1391 /*
1392 * We release only a lock we actually own:
1393 */
1394 if ((uval & FUTEX_TID_MASK) != current->pid)
1395 return -EPERM;
1396 /*
1397 * First take all the futex related locks:
1398 */
1399 down_read(&current->mm->mmap_sem);
1400
1401 ret = get_futex_key(uaddr, &key);
1402 if (unlikely(ret != 0))
1403 goto out;
1404
1405 hb = hash_futex(&key);
1406 spin_lock(&hb->lock);
1407
1408retry_locked:
1409 /*
1410 * To avoid races, try to do the TID -> 0 atomic transition
1411 * again. If it succeeds then we can return without waking
1412 * anyone else up:
1413 */
1414 inc_preempt_count();
1415 uval = futex_atomic_cmpxchg_inatomic(uaddr, current->pid, 0);
1416 dec_preempt_count();
1417
1418 if (unlikely(uval == -EFAULT))
1419 goto pi_faulted;
1420 /*
1421 * Rare case: we managed to release the lock atomically,
1422 * no need to wake anyone else up:
1423 */
1424 if (unlikely(uval == current->pid))
1425 goto out_unlock;
1426
1427 /*
1428 * Ok, other tasks may need to be woken up - check waiters
1429 * and do the wakeup if necessary:
1430 */
1431 head = &hb->chain;
1432
1433 list_for_each_entry_safe(this, next, head, list) {
1434 if (!match_futex (&this->key, &key))
1435 continue;
1436 ret = wake_futex_pi(uaddr, uval, this);
1437 /*
1438 * The atomic access to the futex value
1439 * generated a pagefault, so retry the
1440 * user-access and the wakeup:
1441 */
1442 if (ret == -EFAULT)
1443 goto pi_faulted;
1444 goto out_unlock;
1445 }
1446 /*
1447 * No waiters - kernel unlocks the futex:
1448 */
1449 ret = unlock_futex_pi(uaddr, uval);
1450 if (ret == -EFAULT)
1451 goto pi_faulted;
1452
1453out_unlock:
1454 spin_unlock(&hb->lock);
1455out:
728 up_read(&current->mm->mmap_sem); 1456 up_read(&current->mm->mmap_sem);
1457
1458 return ret;
1459
1460pi_faulted:
1461 /*
1462 * We have to r/w *(int __user *)uaddr, but we can't modify it
1463 * non-atomically. Therefore, if get_user below is not
1464 * enough, we need to handle the fault ourselves, while
1465 * still holding the mmap_sem.
1466 */
1467 if (attempt++) {
1468 if (futex_handle_fault((unsigned long)uaddr, attempt))
1469 goto out_unlock;
1470
1471 goto retry_locked;
1472 }
1473
1474 spin_unlock(&hb->lock);
1475 up_read(&current->mm->mmap_sem);
1476
1477 ret = get_user(uval, uaddr);
1478 if (!ret && (uval != -EFAULT))
1479 goto retry;
1480
729 return ret; 1481 return ret;
730} 1482}
731 1483
@@ -735,6 +1487,7 @@ static int futex_close(struct inode *inode, struct file *filp)
735 1487
736 unqueue_me(q); 1488 unqueue_me(q);
737 kfree(q); 1489 kfree(q);
1490
738 return 0; 1491 return 0;
739} 1492}
740 1493
@@ -766,7 +1519,7 @@ static struct file_operations futex_fops = {
766 * Signal allows caller to avoid the race which would occur if they 1519 * Signal allows caller to avoid the race which would occur if they
767 * set the sigio stuff up afterwards. 1520 * set the sigio stuff up afterwards.
768 */ 1521 */
769static int futex_fd(unsigned long uaddr, int signal) 1522static int futex_fd(u32 __user *uaddr, int signal)
770{ 1523{
771 struct futex_q *q; 1524 struct futex_q *q;
772 struct file *filp; 1525 struct file *filp;
@@ -803,6 +1556,7 @@ static int futex_fd(unsigned long uaddr, int signal)
803 err = -ENOMEM; 1556 err = -ENOMEM;
804 goto error; 1557 goto error;
805 } 1558 }
1559 q->pi_state = NULL;
806 1560
807 down_read(&current->mm->mmap_sem); 1561 down_read(&current->mm->mmap_sem);
808 err = get_futex_key(uaddr, &q->key); 1562 err = get_futex_key(uaddr, &q->key);
@@ -840,7 +1594,7 @@ error:
840 * Implementation: user-space maintains a per-thread list of locks it 1594 * Implementation: user-space maintains a per-thread list of locks it
841 * is holding. Upon do_exit(), the kernel carefully walks this list, 1595 * is holding. Upon do_exit(), the kernel carefully walks this list,
842 * and marks all locks that are owned by this thread with the 1596 * and marks all locks that are owned by this thread with the
843 * FUTEX_OWNER_DEAD bit, and wakes up a waiter (if any). The list is 1597 * FUTEX_OWNER_DIED bit, and wakes up a waiter (if any). The list is
844 * always manipulated with the lock held, so the list is private and 1598 * always manipulated with the lock held, so the list is private and
845 * per-thread. Userspace also maintains a per-thread 'list_op_pending' 1599 * per-thread. Userspace also maintains a per-thread 'list_op_pending'
846 * field, to allow the kernel to clean up if the thread dies after 1600 * field, to allow the kernel to clean up if the thread dies after
@@ -915,7 +1669,7 @@ err_unlock:
915 */ 1669 */
916int handle_futex_death(u32 __user *uaddr, struct task_struct *curr) 1670int handle_futex_death(u32 __user *uaddr, struct task_struct *curr)
917{ 1671{
918 u32 uval; 1672 u32 uval, nval;
919 1673
920retry: 1674retry:
921 if (get_user(uval, uaddr)) 1675 if (get_user(uval, uaddr))
@@ -932,12 +1686,16 @@ retry:
932 * thread-death.) The rest of the cleanup is done in 1686 * thread-death.) The rest of the cleanup is done in
933 * userspace. 1687 * userspace.
934 */ 1688 */
935 if (futex_atomic_cmpxchg_inatomic(uaddr, uval, 1689 nval = futex_atomic_cmpxchg_inatomic(uaddr, uval,
936 uval | FUTEX_OWNER_DIED) != uval) 1690 uval | FUTEX_OWNER_DIED);
1691 if (nval == -EFAULT)
1692 return -1;
1693
1694 if (nval != uval)
937 goto retry; 1695 goto retry;
938 1696
939 if (uval & FUTEX_WAITERS) 1697 if (uval & FUTEX_WAITERS)
940 futex_wake((unsigned long)uaddr, 1); 1698 futex_wake(uaddr, 1);
941 } 1699 }
942 return 0; 1700 return 0;
943} 1701}
@@ -978,7 +1736,7 @@ void exit_robust_list(struct task_struct *curr)
978 while (entry != &head->list) { 1736 while (entry != &head->list) {
979 /* 1737 /*
980 * A pending lock might already be on the list, so 1738 * A pending lock might already be on the list, so
981 * dont process it twice: 1739 * don't process it twice:
982 */ 1740 */
983 if (entry != pending) 1741 if (entry != pending)
984 if (handle_futex_death((void *)entry + futex_offset, 1742 if (handle_futex_death((void *)entry + futex_offset,
@@ -999,8 +1757,8 @@ void exit_robust_list(struct task_struct *curr)
999 } 1757 }
1000} 1758}
1001 1759
1002long do_futex(unsigned long uaddr, int op, int val, unsigned long timeout, 1760long do_futex(u32 __user *uaddr, int op, u32 val, unsigned long timeout,
1003 unsigned long uaddr2, int val2, int val3) 1761 u32 __user *uaddr2, u32 val2, u32 val3)
1004{ 1762{
1005 int ret; 1763 int ret;
1006 1764
@@ -1024,6 +1782,15 @@ long do_futex(unsigned long uaddr, int op, int val, unsigned long timeout,
1024 case FUTEX_WAKE_OP: 1782 case FUTEX_WAKE_OP:
1025 ret = futex_wake_op(uaddr, uaddr2, val, val2, val3); 1783 ret = futex_wake_op(uaddr, uaddr2, val, val2, val3);
1026 break; 1784 break;
1785 case FUTEX_LOCK_PI:
1786 ret = futex_lock_pi(uaddr, val, timeout, val2, 0);
1787 break;
1788 case FUTEX_UNLOCK_PI:
1789 ret = futex_unlock_pi(uaddr);
1790 break;
1791 case FUTEX_TRYLOCK_PI:
1792 ret = futex_lock_pi(uaddr, 0, timeout, val2, 1);
1793 break;
1027 default: 1794 default:
1028 ret = -ENOSYS; 1795 ret = -ENOSYS;
1029 } 1796 }
@@ -1031,29 +1798,33 @@ long do_futex(unsigned long uaddr, int op, int val, unsigned long timeout,
1031} 1798}
1032 1799
1033 1800
1034asmlinkage long sys_futex(u32 __user *uaddr, int op, int val, 1801asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val,
1035 struct timespec __user *utime, u32 __user *uaddr2, 1802 struct timespec __user *utime, u32 __user *uaddr2,
1036 int val3) 1803 u32 val3)
1037{ 1804{
1038 struct timespec t; 1805 struct timespec t;
1039 unsigned long timeout = MAX_SCHEDULE_TIMEOUT; 1806 unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
1040 int val2 = 0; 1807 u32 val2 = 0;
1041 1808
1042 if (utime && (op == FUTEX_WAIT)) { 1809 if (utime && (op == FUTEX_WAIT || op == FUTEX_LOCK_PI)) {
1043 if (copy_from_user(&t, utime, sizeof(t)) != 0) 1810 if (copy_from_user(&t, utime, sizeof(t)) != 0)
1044 return -EFAULT; 1811 return -EFAULT;
1045 if (!timespec_valid(&t)) 1812 if (!timespec_valid(&t))
1046 return -EINVAL; 1813 return -EINVAL;
1047 timeout = timespec_to_jiffies(&t) + 1; 1814 if (op == FUTEX_WAIT)
1815 timeout = timespec_to_jiffies(&t) + 1;
1816 else {
1817 timeout = t.tv_sec;
1818 val2 = t.tv_nsec;
1819 }
1048 } 1820 }
1049 /* 1821 /*
1050 * requeue parameter in 'utime' if op == FUTEX_REQUEUE. 1822 * requeue parameter in 'utime' if op == FUTEX_REQUEUE.
1051 */ 1823 */
1052 if (op >= FUTEX_REQUEUE) 1824 if (op == FUTEX_REQUEUE || op == FUTEX_CMP_REQUEUE)
1053 val2 = (int) (unsigned long) utime; 1825 val2 = (u32) (unsigned long) utime;
1054 1826
1055 return do_futex((unsigned long)uaddr, op, val, timeout, 1827 return do_futex(uaddr, op, val, timeout, uaddr2, val2, val3);
1056 (unsigned long)uaddr2, val2, val3);
1057} 1828}
1058 1829
1059static int futexfs_get_sb(struct file_system_type *fs_type, 1830static int futexfs_get_sb(struct file_system_type *fs_type,
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index 1ab6a0ea3d14..d1d92b441fb7 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -129,16 +129,20 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
129 unsigned long timeout = MAX_SCHEDULE_TIMEOUT; 129 unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
130 int val2 = 0; 130 int val2 = 0;
131 131
132 if (utime && (op == FUTEX_WAIT)) { 132 if (utime && (op == FUTEX_WAIT || op == FUTEX_LOCK_PI)) {
133 if (get_compat_timespec(&t, utime)) 133 if (get_compat_timespec(&t, utime))
134 return -EFAULT; 134 return -EFAULT;
135 if (!timespec_valid(&t)) 135 if (!timespec_valid(&t))
136 return -EINVAL; 136 return -EINVAL;
137 timeout = timespec_to_jiffies(&t) + 1; 137 if (op == FUTEX_WAIT)
138 timeout = timespec_to_jiffies(&t) + 1;
139 else {
140 timeout = t.tv_sec;
141 val2 = t.tv_nsec;
142 }
138 } 143 }
139 if (op >= FUTEX_REQUEUE) 144 if (op == FUTEX_REQUEUE || op == FUTEX_CMP_REQUEUE)
140 val2 = (int) (unsigned long) utime; 145 val2 = (int) (unsigned long) utime;
141 146
142 return do_futex((unsigned long)uaddr, op, val, timeout, 147 return do_futex(uaddr, op, val, timeout, uaddr2, val2, val3);
143 (unsigned long)uaddr2, val2, val3);
144} 148}
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 55601b3ce60e..8d3dc29ef41a 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -833,7 +833,7 @@ static void migrate_hrtimers(int cpu)
833} 833}
834#endif /* CONFIG_HOTPLUG_CPU */ 834#endif /* CONFIG_HOTPLUG_CPU */
835 835
836static int hrtimer_cpu_notify(struct notifier_block *self, 836static int __devinit hrtimer_cpu_notify(struct notifier_block *self,
837 unsigned long action, void *hcpu) 837 unsigned long action, void *hcpu)
838{ 838{
839 long cpu = (long)hcpu; 839 long cpu = (long)hcpu;
@@ -857,7 +857,7 @@ static int hrtimer_cpu_notify(struct notifier_block *self,
857 return NOTIFY_OK; 857 return NOTIFY_OK;
858} 858}
859 859
860static struct notifier_block hrtimers_nb = { 860static struct notifier_block __devinitdata hrtimers_nb = {
861 .notifier_call = hrtimer_cpu_notify, 861 .notifier_call = hrtimer_cpu_notify,
862}; 862};
863 863
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile
index 9f77f50d8143..1dab0ac3f797 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -1,5 +1,5 @@
1 1
2obj-y := handle.o manage.o spurious.o 2obj-y := handle.o manage.o spurious.o resend.o chip.o
3obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o 3obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
4obj-$(CONFIG_PROC_FS) += proc.o 4obj-$(CONFIG_PROC_FS) += proc.o
5obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o 5obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o
diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c
index 3467097ca61a..533068cfb607 100644
--- a/kernel/irq/autoprobe.c
+++ b/kernel/irq/autoprobe.c
@@ -11,12 +11,14 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/delay.h> 12#include <linux/delay.h>
13 13
14#include "internals.h"
15
14/* 16/*
15 * Autodetection depends on the fact that any interrupt that 17 * Autodetection depends on the fact that any interrupt that
16 * comes in on to an unassigned handler will get stuck with 18 * comes in on to an unassigned handler will get stuck with
17 * "IRQ_WAITING" cleared and the interrupt disabled. 19 * "IRQ_WAITING" cleared and the interrupt disabled.
18 */ 20 */
19static DECLARE_MUTEX(probe_sem); 21static DEFINE_MUTEX(probing_active);
20 22
21/** 23/**
22 * probe_irq_on - begin an interrupt autodetect 24 * probe_irq_on - begin an interrupt autodetect
@@ -27,11 +29,11 @@ static DECLARE_MUTEX(probe_sem);
27 */ 29 */
28unsigned long probe_irq_on(void) 30unsigned long probe_irq_on(void)
29{ 31{
30 unsigned long val; 32 struct irq_desc *desc;
31 irq_desc_t *desc; 33 unsigned long mask;
32 unsigned int i; 34 unsigned int i;
33 35
34 down(&probe_sem); 36 mutex_lock(&probing_active);
35 /* 37 /*
36 * something may have generated an irq long ago and we want to 38 * something may have generated an irq long ago and we want to
37 * flush such a longstanding irq before considering it as spurious. 39 * flush such a longstanding irq before considering it as spurious.
@@ -40,8 +42,21 @@ unsigned long probe_irq_on(void)
40 desc = irq_desc + i; 42 desc = irq_desc + i;
41 43
42 spin_lock_irq(&desc->lock); 44 spin_lock_irq(&desc->lock);
43 if (!irq_desc[i].action) 45 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
44 irq_desc[i].handler->startup(i); 46 /*
47 * An old-style architecture might still have
48 * the handle_bad_irq handler there:
49 */
50 compat_irq_chip_set_default_handler(desc);
51
52 /*
53 * Some chips need to know about probing in
54 * progress:
55 */
56 if (desc->chip->set_type)
57 desc->chip->set_type(i, IRQ_TYPE_PROBE);
58 desc->chip->startup(i);
59 }
45 spin_unlock_irq(&desc->lock); 60 spin_unlock_irq(&desc->lock);
46 } 61 }
47 62
@@ -57,9 +72,9 @@ unsigned long probe_irq_on(void)
57 desc = irq_desc + i; 72 desc = irq_desc + i;
58 73
59 spin_lock_irq(&desc->lock); 74 spin_lock_irq(&desc->lock);
60 if (!desc->action) { 75 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
61 desc->status |= IRQ_AUTODETECT | IRQ_WAITING; 76 desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
62 if (desc->handler->startup(i)) 77 if (desc->chip->startup(i))
63 desc->status |= IRQ_PENDING; 78 desc->status |= IRQ_PENDING;
64 } 79 }
65 spin_unlock_irq(&desc->lock); 80 spin_unlock_irq(&desc->lock);
@@ -73,11 +88,11 @@ unsigned long probe_irq_on(void)
73 /* 88 /*
74 * Now filter out any obviously spurious interrupts 89 * Now filter out any obviously spurious interrupts
75 */ 90 */
76 val = 0; 91 mask = 0;
77 for (i = 0; i < NR_IRQS; i++) { 92 for (i = 0; i < NR_IRQS; i++) {
78 irq_desc_t *desc = irq_desc + i;
79 unsigned int status; 93 unsigned int status;
80 94
95 desc = irq_desc + i;
81 spin_lock_irq(&desc->lock); 96 spin_lock_irq(&desc->lock);
82 status = desc->status; 97 status = desc->status;
83 98
@@ -85,17 +100,16 @@ unsigned long probe_irq_on(void)
85 /* It triggered already - consider it spurious. */ 100 /* It triggered already - consider it spurious. */
86 if (!(status & IRQ_WAITING)) { 101 if (!(status & IRQ_WAITING)) {
87 desc->status = status & ~IRQ_AUTODETECT; 102 desc->status = status & ~IRQ_AUTODETECT;
88 desc->handler->shutdown(i); 103 desc->chip->shutdown(i);
89 } else 104 } else
90 if (i < 32) 105 if (i < 32)
91 val |= 1 << i; 106 mask |= 1 << i;
92 } 107 }
93 spin_unlock_irq(&desc->lock); 108 spin_unlock_irq(&desc->lock);
94 } 109 }
95 110
96 return val; 111 return mask;
97} 112}
98
99EXPORT_SYMBOL(probe_irq_on); 113EXPORT_SYMBOL(probe_irq_on);
100 114
101/** 115/**
@@ -117,7 +131,7 @@ unsigned int probe_irq_mask(unsigned long val)
117 131
118 mask = 0; 132 mask = 0;
119 for (i = 0; i < NR_IRQS; i++) { 133 for (i = 0; i < NR_IRQS; i++) {
120 irq_desc_t *desc = irq_desc + i; 134 struct irq_desc *desc = irq_desc + i;
121 unsigned int status; 135 unsigned int status;
122 136
123 spin_lock_irq(&desc->lock); 137 spin_lock_irq(&desc->lock);
@@ -128,11 +142,11 @@ unsigned int probe_irq_mask(unsigned long val)
128 mask |= 1 << i; 142 mask |= 1 << i;
129 143
130 desc->status = status & ~IRQ_AUTODETECT; 144 desc->status = status & ~IRQ_AUTODETECT;
131 desc->handler->shutdown(i); 145 desc->chip->shutdown(i);
132 } 146 }
133 spin_unlock_irq(&desc->lock); 147 spin_unlock_irq(&desc->lock);
134 } 148 }
135 up(&probe_sem); 149 mutex_unlock(&probing_active);
136 150
137 return mask & val; 151 return mask & val;
138} 152}
@@ -160,7 +174,7 @@ int probe_irq_off(unsigned long val)
160 int i, irq_found = 0, nr_irqs = 0; 174 int i, irq_found = 0, nr_irqs = 0;
161 175
162 for (i = 0; i < NR_IRQS; i++) { 176 for (i = 0; i < NR_IRQS; i++) {
163 irq_desc_t *desc = irq_desc + i; 177 struct irq_desc *desc = irq_desc + i;
164 unsigned int status; 178 unsigned int status;
165 179
166 spin_lock_irq(&desc->lock); 180 spin_lock_irq(&desc->lock);
@@ -173,16 +187,16 @@ int probe_irq_off(unsigned long val)
173 nr_irqs++; 187 nr_irqs++;
174 } 188 }
175 desc->status = status & ~IRQ_AUTODETECT; 189 desc->status = status & ~IRQ_AUTODETECT;
176 desc->handler->shutdown(i); 190 desc->chip->shutdown(i);
177 } 191 }
178 spin_unlock_irq(&desc->lock); 192 spin_unlock_irq(&desc->lock);
179 } 193 }
180 up(&probe_sem); 194 mutex_unlock(&probing_active);
181 195
182 if (nr_irqs > 1) 196 if (nr_irqs > 1)
183 irq_found = -irq_found; 197 irq_found = -irq_found;
198
184 return irq_found; 199 return irq_found;
185} 200}
186
187EXPORT_SYMBOL(probe_irq_off); 201EXPORT_SYMBOL(probe_irq_off);
188 202
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
new file mode 100644
index 000000000000..4a0952d9458b
--- /dev/null
+++ b/kernel/irq/chip.c
@@ -0,0 +1,525 @@
1/*
2 * linux/kernel/irq/chip.c
3 *
4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
6 *
7 * This file contains the core interrupt handling code, for irq-chip
8 * based architectures.
9 *
10 * Detailed information is available in Documentation/DocBook/genericirq
11 */
12
13#include <linux/irq.h>
14#include <linux/module.h>
15#include <linux/interrupt.h>
16#include <linux/kernel_stat.h>
17
18#include "internals.h"
19
20/**
21 * set_irq_chip - set the irq chip for an irq
22 * @irq: irq number
23 * @chip: pointer to irq chip description structure
24 */
25int set_irq_chip(unsigned int irq, struct irq_chip *chip)
26{
27 struct irq_desc *desc;
28 unsigned long flags;
29
30 if (irq >= NR_IRQS) {
31 printk(KERN_ERR "Trying to install chip for IRQ%d\n", irq);
32 WARN_ON(1);
33 return -EINVAL;
34 }
35
36 if (!chip)
37 chip = &no_irq_chip;
38
39 desc = irq_desc + irq;
40 spin_lock_irqsave(&desc->lock, flags);
41 irq_chip_set_defaults(chip);
42 desc->chip = chip;
43 /*
44 * For compatibility only:
45 */
46 desc->chip = chip;
47 spin_unlock_irqrestore(&desc->lock, flags);
48
49 return 0;
50}
51EXPORT_SYMBOL(set_irq_chip);
52
53/**
54 * set_irq_type - set the irq type for an irq
55 * @irq: irq number
56 * @type: interrupt type - see include/linux/interrupt.h
57 */
58int set_irq_type(unsigned int irq, unsigned int type)
59{
60 struct irq_desc *desc;
61 unsigned long flags;
62 int ret = -ENXIO;
63
64 if (irq >= NR_IRQS) {
65 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
66 return -ENODEV;
67 }
68
69 desc = irq_desc + irq;
70 if (desc->chip->set_type) {
71 spin_lock_irqsave(&desc->lock, flags);
72 ret = desc->chip->set_type(irq, type);
73 spin_unlock_irqrestore(&desc->lock, flags);
74 }
75 return ret;
76}
77EXPORT_SYMBOL(set_irq_type);
78
79/**
80 * set_irq_data - set irq type data for an irq
81 * @irq: Interrupt number
82 * @data: Pointer to interrupt specific data
83 *
84 * Set the hardware irq controller data for an irq
85 */
86int set_irq_data(unsigned int irq, void *data)
87{
88 struct irq_desc *desc;
89 unsigned long flags;
90
91 if (irq >= NR_IRQS) {
92 printk(KERN_ERR
93 "Trying to install controller data for IRQ%d\n", irq);
94 return -EINVAL;
95 }
96
97 desc = irq_desc + irq;
98 spin_lock_irqsave(&desc->lock, flags);
99 desc->handler_data = data;
100 spin_unlock_irqrestore(&desc->lock, flags);
101 return 0;
102}
103EXPORT_SYMBOL(set_irq_data);
104
105/**
106 * set_irq_chip_data - set irq chip data for an irq
107 * @irq: Interrupt number
108 * @data: Pointer to chip specific data
109 *
110 * Set the hardware irq chip data for an irq
111 */
112int set_irq_chip_data(unsigned int irq, void *data)
113{
114 struct irq_desc *desc = irq_desc + irq;
115 unsigned long flags;
116
117 if (irq >= NR_IRQS || !desc->chip) {
118 printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
119 return -EINVAL;
120 }
121
122 spin_lock_irqsave(&desc->lock, flags);
123 desc->chip_data = data;
124 spin_unlock_irqrestore(&desc->lock, flags);
125
126 return 0;
127}
128EXPORT_SYMBOL(set_irq_chip_data);
129
130/*
131 * default enable function
132 */
133static void default_enable(unsigned int irq)
134{
135 struct irq_desc *desc = irq_desc + irq;
136
137 desc->chip->unmask(irq);
138 desc->status &= ~IRQ_MASKED;
139}
140
141/*
142 * default disable function
143 */
144static void default_disable(unsigned int irq)
145{
146 struct irq_desc *desc = irq_desc + irq;
147
148 if (!(desc->status & IRQ_DELAYED_DISABLE))
149 irq_desc[irq].chip->mask(irq);
150}
151
152/*
153 * default startup function
154 */
155static unsigned int default_startup(unsigned int irq)
156{
157 irq_desc[irq].chip->enable(irq);
158
159 return 0;
160}
161
162/*
163 * Fixup enable/disable function pointers
164 */
165void irq_chip_set_defaults(struct irq_chip *chip)
166{
167 if (!chip->enable)
168 chip->enable = default_enable;
169 if (!chip->disable)
170 chip->disable = default_disable;
171 if (!chip->startup)
172 chip->startup = default_startup;
173 if (!chip->shutdown)
174 chip->shutdown = chip->disable;
175 if (!chip->name)
176 chip->name = chip->typename;
177}
178
179static inline void mask_ack_irq(struct irq_desc *desc, int irq)
180{
181 if (desc->chip->mask_ack)
182 desc->chip->mask_ack(irq);
183 else {
184 desc->chip->mask(irq);
185 desc->chip->ack(irq);
186 }
187}
188
189/**
190 * handle_simple_irq - Simple and software-decoded IRQs.
191 * @irq: the interrupt number
192 * @desc: the interrupt description structure for this irq
193 * @regs: pointer to a register structure
194 *
195 * Simple interrupts are either sent from a demultiplexing interrupt
196 * handler or come from hardware, where no interrupt hardware control
197 * is necessary.
198 *
199 * Note: The caller is expected to handle the ack, clear, mask and
200 * unmask issues if necessary.
201 */
202void fastcall
203handle_simple_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
204{
205 struct irqaction *action;
206 irqreturn_t action_ret;
207 const unsigned int cpu = smp_processor_id();
208
209 spin_lock(&desc->lock);
210
211 if (unlikely(desc->status & IRQ_INPROGRESS))
212 goto out_unlock;
213 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
214 kstat_cpu(cpu).irqs[irq]++;
215
216 action = desc->action;
217 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
218 goto out_unlock;
219
220 desc->status |= IRQ_INPROGRESS;
221 spin_unlock(&desc->lock);
222
223 action_ret = handle_IRQ_event(irq, regs, action);
224 if (!noirqdebug)
225 note_interrupt(irq, desc, action_ret, regs);
226
227 spin_lock(&desc->lock);
228 desc->status &= ~IRQ_INPROGRESS;
229out_unlock:
230 spin_unlock(&desc->lock);
231}
232
233/**
234 * handle_level_irq - Level type irq handler
235 * @irq: the interrupt number
236 * @desc: the interrupt description structure for this irq
237 * @regs: pointer to a register structure
238 *
239 * Level type interrupts are active as long as the hardware line has
240 * the active level. This may require to mask the interrupt and unmask
241 * it after the associated handler has acknowledged the device, so the
242 * interrupt line is back to inactive.
243 */
244void fastcall
245handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
246{
247 unsigned int cpu = smp_processor_id();
248 struct irqaction *action;
249 irqreturn_t action_ret;
250
251 spin_lock(&desc->lock);
252 mask_ack_irq(desc, irq);
253
254 if (unlikely(desc->status & IRQ_INPROGRESS))
255 goto out;
256 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
257 kstat_cpu(cpu).irqs[irq]++;
258
259 /*
260 * If its disabled or no action available
261 * keep it masked and get out of here
262 */
263 action = desc->action;
264 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
265 goto out;
266
267 desc->status |= IRQ_INPROGRESS;
268 spin_unlock(&desc->lock);
269
270 action_ret = handle_IRQ_event(irq, regs, action);
271 if (!noirqdebug)
272 note_interrupt(irq, desc, action_ret, regs);
273
274 spin_lock(&desc->lock);
275 desc->status &= ~IRQ_INPROGRESS;
276out:
277 if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
278 desc->chip->unmask(irq);
279 spin_unlock(&desc->lock);
280}
281
282/**
283 * handle_fasteoi_irq - irq handler for transparent controllers
284 * @irq: the interrupt number
285 * @desc: the interrupt description structure for this irq
286 * @regs: pointer to a register structure
287 *
288 * Only a single callback will be issued to the chip: an ->eoi()
289 * call when the interrupt has been serviced. This enables support
290 * for modern forms of interrupt handlers, which handle the flow
291 * details in hardware, transparently.
292 */
293void fastcall
294handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc,
295 struct pt_regs *regs)
296{
297 unsigned int cpu = smp_processor_id();
298 struct irqaction *action;
299 irqreturn_t action_ret;
300
301 spin_lock(&desc->lock);
302
303 if (unlikely(desc->status & IRQ_INPROGRESS))
304 goto out;
305
306 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
307 kstat_cpu(cpu).irqs[irq]++;
308
309 /*
310 * If its disabled or no action available
311 * keep it masked and get out of here
312 */
313 action = desc->action;
314 if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
315 desc->status |= IRQ_PENDING;
316 goto out;
317 }
318
319 desc->status |= IRQ_INPROGRESS;
320 desc->status &= ~IRQ_PENDING;
321 spin_unlock(&desc->lock);
322
323 action_ret = handle_IRQ_event(irq, regs, action);
324 if (!noirqdebug)
325 note_interrupt(irq, desc, action_ret, regs);
326
327 spin_lock(&desc->lock);
328 desc->status &= ~IRQ_INPROGRESS;
329out:
330 desc->chip->eoi(irq);
331
332 spin_unlock(&desc->lock);
333}
334
335/**
336 * handle_edge_irq - edge type IRQ handler
337 * @irq: the interrupt number
338 * @desc: the interrupt description structure for this irq
339 * @regs: pointer to a register structure
340 *
341 * Interrupt occures on the falling and/or rising edge of a hardware
342 * signal. The occurence is latched into the irq controller hardware
343 * and must be acked in order to be reenabled. After the ack another
344 * interrupt can happen on the same source even before the first one
345 * is handled by the assosiacted event handler. If this happens it
346 * might be necessary to disable (mask) the interrupt depending on the
347 * controller hardware. This requires to reenable the interrupt inside
348 * of the loop which handles the interrupts which have arrived while
349 * the handler was running. If all pending interrupts are handled, the
350 * loop is left.
351 */
352void fastcall
353handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
354{
355 const unsigned int cpu = smp_processor_id();
356
357 spin_lock(&desc->lock);
358
359 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
360
361 /*
362 * If we're currently running this IRQ, or its disabled,
363 * we shouldn't process the IRQ. Mark it pending, handle
364 * the necessary masking and go out
365 */
366 if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
367 !desc->action)) {
368 desc->status |= (IRQ_PENDING | IRQ_MASKED);
369 mask_ack_irq(desc, irq);
370 goto out_unlock;
371 }
372
373 kstat_cpu(cpu).irqs[irq]++;
374
375 /* Start handling the irq */
376 desc->chip->ack(irq);
377
378 /* Mark the IRQ currently in progress.*/
379 desc->status |= IRQ_INPROGRESS;
380
381 do {
382 struct irqaction *action = desc->action;
383 irqreturn_t action_ret;
384
385 if (unlikely(!action)) {
386 desc->chip->mask(irq);
387 goto out_unlock;
388 }
389
390 /*
391 * When another irq arrived while we were handling
392 * one, we could have masked the irq.
393 * Renable it, if it was not disabled in meantime.
394 */
395 if (unlikely((desc->status &
396 (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
397 (IRQ_PENDING | IRQ_MASKED))) {
398 desc->chip->unmask(irq);
399 desc->status &= ~IRQ_MASKED;
400 }
401
402 desc->status &= ~IRQ_PENDING;
403 spin_unlock(&desc->lock);
404 action_ret = handle_IRQ_event(irq, regs, action);
405 if (!noirqdebug)
406 note_interrupt(irq, desc, action_ret, regs);
407 spin_lock(&desc->lock);
408
409 } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
410
411 desc->status &= ~IRQ_INPROGRESS;
412out_unlock:
413 spin_unlock(&desc->lock);
414}
415
416#ifdef CONFIG_SMP
417/**
418 * handle_percpu_IRQ - Per CPU local irq handler
419 * @irq: the interrupt number
420 * @desc: the interrupt description structure for this irq
421 * @regs: pointer to a register structure
422 *
423 * Per CPU interrupts on SMP machines without locking requirements
424 */
425void fastcall
426handle_percpu_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
427{
428 irqreturn_t action_ret;
429
430 kstat_this_cpu.irqs[irq]++;
431
432 if (desc->chip->ack)
433 desc->chip->ack(irq);
434
435 action_ret = handle_IRQ_event(irq, regs, desc->action);
436 if (!noirqdebug)
437 note_interrupt(irq, desc, action_ret, regs);
438
439 if (desc->chip->eoi)
440 desc->chip->eoi(irq);
441}
442
443#endif /* CONFIG_SMP */
444
445void
446__set_irq_handler(unsigned int irq,
447 void fastcall (*handle)(unsigned int, irq_desc_t *,
448 struct pt_regs *),
449 int is_chained)
450{
451 struct irq_desc *desc;
452 unsigned long flags;
453
454 if (irq >= NR_IRQS) {
455 printk(KERN_ERR
456 "Trying to install type control for IRQ%d\n", irq);
457 return;
458 }
459
460 desc = irq_desc + irq;
461
462 if (!handle)
463 handle = handle_bad_irq;
464
465 if (is_chained && desc->chip == &no_irq_chip)
466 printk(KERN_WARNING "Trying to install "
467 "chained interrupt type for IRQ%d\n", irq);
468
469 spin_lock_irqsave(&desc->lock, flags);
470
471 /* Uninstall? */
472 if (handle == handle_bad_irq) {
473 if (desc->chip != &no_irq_chip) {
474 desc->chip->mask(irq);
475 desc->chip->ack(irq);
476 }
477 desc->status |= IRQ_DISABLED;
478 desc->depth = 1;
479 }
480 desc->handle_irq = handle;
481
482 if (handle != handle_bad_irq && is_chained) {
483 desc->status &= ~IRQ_DISABLED;
484 desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
485 desc->depth = 0;
486 desc->chip->unmask(irq);
487 }
488 spin_unlock_irqrestore(&desc->lock, flags);
489}
490
491void
492set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
493 void fastcall (*handle)(unsigned int,
494 struct irq_desc *,
495 struct pt_regs *))
496{
497 set_irq_chip(irq, chip);
498 __set_irq_handler(irq, handle, 0);
499}
500
501/*
502 * Get a descriptive string for the highlevel handler, for
503 * /proc/interrupts output:
504 */
505const char *
506handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *,
507 struct pt_regs *))
508{
509 if (handle == handle_level_irq)
510 return "level ";
511 if (handle == handle_fasteoi_irq)
512 return "fasteoi";
513 if (handle == handle_edge_irq)
514 return "edge ";
515 if (handle == handle_simple_irq)
516 return "simple ";
517#ifdef CONFIG_SMP
518 if (handle == handle_percpu_irq)
519 return "percpu ";
520#endif
521 if (handle == handle_bad_irq)
522 return "bad ";
523
524 return NULL;
525}
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 0f6530117105..5a360dd4331b 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -1,9 +1,13 @@
1/* 1/*
2 * linux/kernel/irq/handle.c 2 * linux/kernel/irq/handle.c
3 * 3 *
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar 4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
5 * 6 *
6 * This file contains the core interrupt handling code. 7 * This file contains the core interrupt handling code.
8 *
9 * Detailed information is available in Documentation/DocBook/genericirq
10 *
7 */ 11 */
8 12
9#include <linux/irq.h> 13#include <linux/irq.h>
@@ -14,11 +18,22 @@
14 18
15#include "internals.h" 19#include "internals.h"
16 20
21/**
22 * handle_bad_irq - handle spurious and unhandled irqs
23 */
24void fastcall
25handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
26{
27 print_irq_desc(irq, desc);
28 kstat_this_cpu.irqs[irq]++;
29 ack_bad_irq(irq);
30}
31
17/* 32/*
18 * Linux has a controller-independent interrupt architecture. 33 * Linux has a controller-independent interrupt architecture.
19 * Every controller has a 'controller-template', that is used 34 * Every controller has a 'controller-template', that is used
20 * by the main code to do the right thing. Each driver-visible 35 * by the main code to do the right thing. Each driver-visible
21 * interrupt source is transparently wired to the apropriate 36 * interrupt source is transparently wired to the appropriate
22 * controller. Thus drivers need not be aware of the 37 * controller. Thus drivers need not be aware of the
23 * interrupt-controller. 38 * interrupt-controller.
24 * 39 *
@@ -28,41 +43,52 @@
28 * 43 *
29 * Controller mappings for all interrupt sources: 44 * Controller mappings for all interrupt sources:
30 */ 45 */
31irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { 46struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = {
32 [0 ... NR_IRQS-1] = { 47 [0 ... NR_IRQS-1] = {
33 .status = IRQ_DISABLED, 48 .status = IRQ_DISABLED,
34 .handler = &no_irq_type, 49 .chip = &no_irq_chip,
35 .lock = SPIN_LOCK_UNLOCKED 50 .handle_irq = handle_bad_irq,
51 .depth = 1,
52 .lock = SPIN_LOCK_UNLOCKED,
53#ifdef CONFIG_SMP
54 .affinity = CPU_MASK_ALL
55#endif
36 } 56 }
37}; 57};
38 58
39/* 59/*
40 * Generic 'no controller' code 60 * What should we do if we get a hw irq event on an illegal vector?
61 * Each architecture has to answer this themself.
41 */ 62 */
42static void end_none(unsigned int irq) { } 63static void ack_bad(unsigned int irq)
43static void enable_none(unsigned int irq) { }
44static void disable_none(unsigned int irq) { }
45static void shutdown_none(unsigned int irq) { }
46static unsigned int startup_none(unsigned int irq) { return 0; }
47
48static void ack_none(unsigned int irq)
49{ 64{
50 /* 65 print_irq_desc(irq, irq_desc + irq);
51 * 'what should we do if we get a hw irq event on an illegal vector'.
52 * each architecture has to answer this themself.
53 */
54 ack_bad_irq(irq); 66 ack_bad_irq(irq);
55} 67}
56 68
57struct hw_interrupt_type no_irq_type = { 69/*
58 .typename = "none", 70 * NOP functions
59 .startup = startup_none, 71 */
60 .shutdown = shutdown_none, 72static void noop(unsigned int irq)
61 .enable = enable_none, 73{
62 .disable = disable_none, 74}
63 .ack = ack_none, 75
64 .end = end_none, 76static unsigned int noop_ret(unsigned int irq)
65 .set_affinity = NULL 77{
78 return 0;
79}
80
81/*
82 * Generic no controller implementation
83 */
84struct irq_chip no_irq_chip = {
85 .name = "none",
86 .startup = noop_ret,
87 .shutdown = noop,
88 .enable = noop,
89 .disable = noop,
90 .ack = ack_bad,
91 .end = noop,
66}; 92};
67 93
68/* 94/*
@@ -73,11 +99,16 @@ irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
73 return IRQ_NONE; 99 return IRQ_NONE;
74} 100}
75 101
76/* 102/**
77 * Have got an event to handle: 103 * handle_IRQ_event - irq action chain handler
104 * @irq: the interrupt number
105 * @regs: pointer to a register structure
106 * @action: the interrupt action chain for this irq
107 *
108 * Handles the action chain of an irq event
78 */ 109 */
79fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, 110irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
80 struct irqaction *action) 111 struct irqaction *action)
81{ 112{
82 irqreturn_t ret, retval = IRQ_NONE; 113 irqreturn_t ret, retval = IRQ_NONE;
83 unsigned int status = 0; 114 unsigned int status = 0;
@@ -100,15 +131,22 @@ fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
100 return retval; 131 return retval;
101} 132}
102 133
103/* 134/**
104 * do_IRQ handles all normal device IRQ's (the special 135 * __do_IRQ - original all in one highlevel IRQ handler
136 * @irq: the interrupt number
137 * @regs: pointer to a register structure
138 *
139 * __do_IRQ handles all normal device IRQ's (the special
105 * SMP cross-CPU interrupts have their own specific 140 * SMP cross-CPU interrupts have their own specific
106 * handlers). 141 * handlers).
142 *
143 * This is the original x86 implementation which is used for every
144 * interrupt type.
107 */ 145 */
108fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs) 146fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs)
109{ 147{
110 irq_desc_t *desc = irq_desc + irq; 148 struct irq_desc *desc = irq_desc + irq;
111 struct irqaction * action; 149 struct irqaction *action;
112 unsigned int status; 150 unsigned int status;
113 151
114 kstat_this_cpu.irqs[irq]++; 152 kstat_this_cpu.irqs[irq]++;
@@ -118,16 +156,16 @@ fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs)
118 /* 156 /*
119 * No locking required for CPU-local interrupts: 157 * No locking required for CPU-local interrupts:
120 */ 158 */
121 if (desc->handler->ack) 159 if (desc->chip->ack)
122 desc->handler->ack(irq); 160 desc->chip->ack(irq);
123 action_ret = handle_IRQ_event(irq, regs, desc->action); 161 action_ret = handle_IRQ_event(irq, regs, desc->action);
124 desc->handler->end(irq); 162 desc->chip->end(irq);
125 return 1; 163 return 1;
126 } 164 }
127 165
128 spin_lock(&desc->lock); 166 spin_lock(&desc->lock);
129 if (desc->handler->ack) 167 if (desc->chip->ack)
130 desc->handler->ack(irq); 168 desc->chip->ack(irq);
131 /* 169 /*
132 * REPLAY is when Linux resends an IRQ that was dropped earlier 170 * REPLAY is when Linux resends an IRQ that was dropped earlier
133 * WAITING is used by probe to mark irqs that are being tested 171 * WAITING is used by probe to mark irqs that are being tested
@@ -187,7 +225,7 @@ out:
187 * The ->end() handler has to deal with interrupts which got 225 * The ->end() handler has to deal with interrupts which got
188 * disabled while the handler was running. 226 * disabled while the handler was running.
189 */ 227 */
190 desc->handler->end(irq); 228 desc->chip->end(irq);
191 spin_unlock(&desc->lock); 229 spin_unlock(&desc->lock);
192 230
193 return 1; 231 return 1;
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 46feba630266..08a849a22447 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -4,6 +4,12 @@
4 4
5extern int noirqdebug; 5extern int noirqdebug;
6 6
7/* Set default functions for irq_chip structures: */
8extern void irq_chip_set_defaults(struct irq_chip *chip);
9
10/* Set default handler: */
11extern void compat_irq_chip_set_default_handler(struct irq_desc *desc);
12
7#ifdef CONFIG_PROC_FS 13#ifdef CONFIG_PROC_FS
8extern void register_irq_proc(unsigned int irq); 14extern void register_irq_proc(unsigned int irq);
9extern void register_handler_proc(unsigned int irq, struct irqaction *action); 15extern void register_handler_proc(unsigned int irq, struct irqaction *action);
@@ -16,3 +22,43 @@ static inline void unregister_handler_proc(unsigned int irq,
16 struct irqaction *action) { } 22 struct irqaction *action) { }
17#endif 23#endif
18 24
25/*
26 * Debugging printout:
27 */
28
29#include <linux/kallsyms.h>
30
31#define P(f) if (desc->status & f) printk("%14s set\n", #f)
32
33static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
34{
35 printk("irq %d, desc: %p, depth: %d, count: %d, unhandled: %d\n",
36 irq, desc, desc->depth, desc->irq_count, desc->irqs_unhandled);
37 printk("->handle_irq(): %p, ", desc->handle_irq);
38 print_symbol("%s\n", (unsigned long)desc->handle_irq);
39 printk("->chip(): %p, ", desc->chip);
40 print_symbol("%s\n", (unsigned long)desc->chip);
41 printk("->action(): %p\n", desc->action);
42 if (desc->action) {
43 printk("->action->handler(): %p, ", desc->action->handler);
44 print_symbol("%s\n", (unsigned long)desc->action->handler);
45 }
46
47 P(IRQ_INPROGRESS);
48 P(IRQ_DISABLED);
49 P(IRQ_PENDING);
50 P(IRQ_REPLAY);
51 P(IRQ_AUTODETECT);
52 P(IRQ_WAITING);
53 P(IRQ_LEVEL);
54 P(IRQ_MASKED);
55#ifdef CONFIG_IRQ_PER_CPU
56 P(IRQ_PER_CPU);
57#endif
58 P(IRQ_NOPROBE);
59 P(IRQ_NOREQUEST);
60 P(IRQ_NOAUTOEN);
61}
62
63#undef P
64
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 1279e3499534..9eb1d518ee1c 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * linux/kernel/irq/manage.c 2 * linux/kernel/irq/manage.c
3 * 3 *
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar 4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006 Thomas Gleixner
5 * 6 *
6 * This file contains driver APIs to the irq subsystem. 7 * This file contains driver APIs to the irq subsystem.
7 */ 8 */
@@ -16,12 +17,6 @@
16 17
17#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
18 19
19cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
20
21#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
22cpumask_t __cacheline_aligned pending_irq_cpumask[NR_IRQS];
23#endif
24
25/** 20/**
26 * synchronize_irq - wait for pending IRQ handlers (on other CPUs) 21 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
27 * @irq: interrupt number to wait for 22 * @irq: interrupt number to wait for
@@ -42,7 +37,6 @@ void synchronize_irq(unsigned int irq)
42 while (desc->status & IRQ_INPROGRESS) 37 while (desc->status & IRQ_INPROGRESS)
43 cpu_relax(); 38 cpu_relax();
44} 39}
45
46EXPORT_SYMBOL(synchronize_irq); 40EXPORT_SYMBOL(synchronize_irq);
47 41
48#endif 42#endif
@@ -60,7 +54,7 @@ EXPORT_SYMBOL(synchronize_irq);
60 */ 54 */
61void disable_irq_nosync(unsigned int irq) 55void disable_irq_nosync(unsigned int irq)
62{ 56{
63 irq_desc_t *desc = irq_desc + irq; 57 struct irq_desc *desc = irq_desc + irq;
64 unsigned long flags; 58 unsigned long flags;
65 59
66 if (irq >= NR_IRQS) 60 if (irq >= NR_IRQS)
@@ -69,11 +63,10 @@ void disable_irq_nosync(unsigned int irq)
69 spin_lock_irqsave(&desc->lock, flags); 63 spin_lock_irqsave(&desc->lock, flags);
70 if (!desc->depth++) { 64 if (!desc->depth++) {
71 desc->status |= IRQ_DISABLED; 65 desc->status |= IRQ_DISABLED;
72 desc->handler->disable(irq); 66 desc->chip->disable(irq);
73 } 67 }
74 spin_unlock_irqrestore(&desc->lock, flags); 68 spin_unlock_irqrestore(&desc->lock, flags);
75} 69}
76
77EXPORT_SYMBOL(disable_irq_nosync); 70EXPORT_SYMBOL(disable_irq_nosync);
78 71
79/** 72/**
@@ -90,7 +83,7 @@ EXPORT_SYMBOL(disable_irq_nosync);
90 */ 83 */
91void disable_irq(unsigned int irq) 84void disable_irq(unsigned int irq)
92{ 85{
93 irq_desc_t *desc = irq_desc + irq; 86 struct irq_desc *desc = irq_desc + irq;
94 87
95 if (irq >= NR_IRQS) 88 if (irq >= NR_IRQS)
96 return; 89 return;
@@ -99,7 +92,6 @@ void disable_irq(unsigned int irq)
99 if (desc->action) 92 if (desc->action)
100 synchronize_irq(irq); 93 synchronize_irq(irq);
101} 94}
102
103EXPORT_SYMBOL(disable_irq); 95EXPORT_SYMBOL(disable_irq);
104 96
105/** 97/**
@@ -114,7 +106,7 @@ EXPORT_SYMBOL(disable_irq);
114 */ 106 */
115void enable_irq(unsigned int irq) 107void enable_irq(unsigned int irq)
116{ 108{
117 irq_desc_t *desc = irq_desc + irq; 109 struct irq_desc *desc = irq_desc + irq;
118 unsigned long flags; 110 unsigned long flags;
119 111
120 if (irq >= NR_IRQS) 112 if (irq >= NR_IRQS)
@@ -123,17 +115,15 @@ void enable_irq(unsigned int irq)
123 spin_lock_irqsave(&desc->lock, flags); 115 spin_lock_irqsave(&desc->lock, flags);
124 switch (desc->depth) { 116 switch (desc->depth) {
125 case 0: 117 case 0:
118 printk(KERN_WARNING "Unablanced enable_irq(%d)\n", irq);
126 WARN_ON(1); 119 WARN_ON(1);
127 break; 120 break;
128 case 1: { 121 case 1: {
129 unsigned int status = desc->status & ~IRQ_DISABLED; 122 unsigned int status = desc->status & ~IRQ_DISABLED;
130 123
131 desc->status = status; 124 /* Prevent probing on this irq: */
132 if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { 125 desc->status = status | IRQ_NOPROBE;
133 desc->status = status | IRQ_REPLAY; 126 check_irq_resend(desc, irq);
134 hw_resend_irq(desc->handler,irq);
135 }
136 desc->handler->enable(irq);
137 /* fall-through */ 127 /* fall-through */
138 } 128 }
139 default: 129 default:
@@ -141,9 +131,29 @@ void enable_irq(unsigned int irq)
141 } 131 }
142 spin_unlock_irqrestore(&desc->lock, flags); 132 spin_unlock_irqrestore(&desc->lock, flags);
143} 133}
144
145EXPORT_SYMBOL(enable_irq); 134EXPORT_SYMBOL(enable_irq);
146 135
136/**
137 * set_irq_wake - control irq power management wakeup
138 * @irq: interrupt to control
139 * @on: enable/disable power management wakeup
140 *
141 * Enable/disable power management wakeup mode
142 */
143int set_irq_wake(unsigned int irq, unsigned int on)
144{
145 struct irq_desc *desc = irq_desc + irq;
146 unsigned long flags;
147 int ret = -ENXIO;
148
149 spin_lock_irqsave(&desc->lock, flags);
150 if (desc->chip->set_wake)
151 ret = desc->chip->set_wake(irq, on);
152 spin_unlock_irqrestore(&desc->lock, flags);
153 return ret;
154}
155EXPORT_SYMBOL(set_irq_wake);
156
147/* 157/*
148 * Internal function that tells the architecture code whether a 158 * Internal function that tells the architecture code whether a
149 * particular irq has been exclusively allocated or is available 159 * particular irq has been exclusively allocated or is available
@@ -153,7 +163,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
153{ 163{
154 struct irqaction *action; 164 struct irqaction *action;
155 165
156 if (irq >= NR_IRQS) 166 if (irq >= NR_IRQS || irq_desc[irq].status & IRQ_NOREQUEST)
157 return 0; 167 return 0;
158 168
159 action = irq_desc[irq].action; 169 action = irq_desc[irq].action;
@@ -164,11 +174,22 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
164 return !action; 174 return !action;
165} 175}
166 176
177void compat_irq_chip_set_default_handler(struct irq_desc *desc)
178{
179 /*
180 * If the architecture still has not overriden
181 * the flow handler then zap the default. This
182 * should catch incorrect flow-type setting.
183 */
184 if (desc->handle_irq == &handle_bad_irq)
185 desc->handle_irq = NULL;
186}
187
167/* 188/*
168 * Internal function to register an irqaction - typically used to 189 * Internal function to register an irqaction - typically used to
169 * allocate special interrupts that are part of the architecture. 190 * allocate special interrupts that are part of the architecture.
170 */ 191 */
171int setup_irq(unsigned int irq, struct irqaction * new) 192int setup_irq(unsigned int irq, struct irqaction *new)
172{ 193{
173 struct irq_desc *desc = irq_desc + irq; 194 struct irq_desc *desc = irq_desc + irq;
174 struct irqaction *old, **p; 195 struct irqaction *old, **p;
@@ -178,7 +199,7 @@ int setup_irq(unsigned int irq, struct irqaction * new)
178 if (irq >= NR_IRQS) 199 if (irq >= NR_IRQS)
179 return -EINVAL; 200 return -EINVAL;
180 201
181 if (desc->handler == &no_irq_type) 202 if (desc->chip == &no_irq_chip)
182 return -ENOSYS; 203 return -ENOSYS;
183 /* 204 /*
184 * Some drivers like serial.c use request_irq() heavily, 205 * Some drivers like serial.c use request_irq() heavily,
@@ -200,14 +221,21 @@ int setup_irq(unsigned int irq, struct irqaction * new)
200 /* 221 /*
201 * The following block of code has to be executed atomically 222 * The following block of code has to be executed atomically
202 */ 223 */
203 spin_lock_irqsave(&desc->lock,flags); 224 spin_lock_irqsave(&desc->lock, flags);
204 p = &desc->action; 225 p = &desc->action;
205 if ((old = *p) != NULL) { 226 old = *p;
206 /* Can't share interrupts unless both agree to */ 227 if (old) {
207 if (!(old->flags & new->flags & SA_SHIRQ)) 228 /*
229 * Can't share interrupts unless both agree to and are
230 * the same type (level, edge, polarity). So both flag
231 * fields must have SA_SHIRQ set and the bits which
232 * set the trigger type must match.
233 */
234 if (!((old->flags & new->flags) & SA_SHIRQ) ||
235 ((old->flags ^ new->flags) & SA_TRIGGER_MASK))
208 goto mismatch; 236 goto mismatch;
209 237
210#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) 238#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
211 /* All handlers must agree on per-cpuness */ 239 /* All handlers must agree on per-cpuness */
212 if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU)) 240 if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
213 goto mismatch; 241 goto mismatch;
@@ -222,20 +250,44 @@ int setup_irq(unsigned int irq, struct irqaction * new)
222 } 250 }
223 251
224 *p = new; 252 *p = new;
225#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) 253#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
226 if (new->flags & SA_PERCPU_IRQ) 254 if (new->flags & SA_PERCPU_IRQ)
227 desc->status |= IRQ_PER_CPU; 255 desc->status |= IRQ_PER_CPU;
228#endif 256#endif
229 if (!shared) { 257 if (!shared) {
230 desc->depth = 0; 258 irq_chip_set_defaults(desc->chip);
231 desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | 259
232 IRQ_WAITING | IRQ_INPROGRESS); 260 /* Setup the type (level, edge polarity) if configured: */
233 if (desc->handler->startup) 261 if (new->flags & SA_TRIGGER_MASK) {
234 desc->handler->startup(irq); 262 if (desc->chip && desc->chip->set_type)
235 else 263 desc->chip->set_type(irq,
236 desc->handler->enable(irq); 264 new->flags & SA_TRIGGER_MASK);
265 else
266 /*
267 * SA_TRIGGER_* but the PIC does not support
268 * multiple flow-types?
269 */
270 printk(KERN_WARNING "setup_irq(%d) SA_TRIGGER"
271 "set. No set_type function available\n",
272 irq);
273 } else
274 compat_irq_chip_set_default_handler(desc);
275
276 desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING |
277 IRQ_INPROGRESS);
278
279 if (!(desc->status & IRQ_NOAUTOEN)) {
280 desc->depth = 0;
281 desc->status &= ~IRQ_DISABLED;
282 if (desc->chip->startup)
283 desc->chip->startup(irq);
284 else
285 desc->chip->enable(irq);
286 } else
287 /* Undo nested disables: */
288 desc->depth = 1;
237 } 289 }
238 spin_unlock_irqrestore(&desc->lock,flags); 290 spin_unlock_irqrestore(&desc->lock, flags);
239 291
240 new->irq = irq; 292 new->irq = irq;
241 register_irq_proc(irq); 293 register_irq_proc(irq);
@@ -278,10 +330,10 @@ void free_irq(unsigned int irq, void *dev_id)
278 return; 330 return;
279 331
280 desc = irq_desc + irq; 332 desc = irq_desc + irq;
281 spin_lock_irqsave(&desc->lock,flags); 333 spin_lock_irqsave(&desc->lock, flags);
282 p = &desc->action; 334 p = &desc->action;
283 for (;;) { 335 for (;;) {
284 struct irqaction * action = *p; 336 struct irqaction *action = *p;
285 337
286 if (action) { 338 if (action) {
287 struct irqaction **pp = p; 339 struct irqaction **pp = p;
@@ -295,18 +347,18 @@ void free_irq(unsigned int irq, void *dev_id)
295 347
296 /* Currently used only by UML, might disappear one day.*/ 348 /* Currently used only by UML, might disappear one day.*/
297#ifdef CONFIG_IRQ_RELEASE_METHOD 349#ifdef CONFIG_IRQ_RELEASE_METHOD
298 if (desc->handler->release) 350 if (desc->chip->release)
299 desc->handler->release(irq, dev_id); 351 desc->chip->release(irq, dev_id);
300#endif 352#endif
301 353
302 if (!desc->action) { 354 if (!desc->action) {
303 desc->status |= IRQ_DISABLED; 355 desc->status |= IRQ_DISABLED;
304 if (desc->handler->shutdown) 356 if (desc->chip->shutdown)
305 desc->handler->shutdown(irq); 357 desc->chip->shutdown(irq);
306 else 358 else
307 desc->handler->disable(irq); 359 desc->chip->disable(irq);
308 } 360 }
309 spin_unlock_irqrestore(&desc->lock,flags); 361 spin_unlock_irqrestore(&desc->lock, flags);
310 unregister_handler_proc(irq, action); 362 unregister_handler_proc(irq, action);
311 363
312 /* Make sure it's not being used on another CPU */ 364 /* Make sure it's not being used on another CPU */
@@ -314,12 +366,11 @@ void free_irq(unsigned int irq, void *dev_id)
314 kfree(action); 366 kfree(action);
315 return; 367 return;
316 } 368 }
317 printk(KERN_ERR "Trying to free free IRQ%d\n",irq); 369 printk(KERN_ERR "Trying to free free IRQ%d\n", irq);
318 spin_unlock_irqrestore(&desc->lock,flags); 370 spin_unlock_irqrestore(&desc->lock, flags);
319 return; 371 return;
320 } 372 }
321} 373}
322
323EXPORT_SYMBOL(free_irq); 374EXPORT_SYMBOL(free_irq);
324 375
325/** 376/**
@@ -353,9 +404,9 @@ EXPORT_SYMBOL(free_irq);
353 */ 404 */
354int request_irq(unsigned int irq, 405int request_irq(unsigned int irq,
355 irqreturn_t (*handler)(int, void *, struct pt_regs *), 406 irqreturn_t (*handler)(int, void *, struct pt_regs *),
356 unsigned long irqflags, const char * devname, void *dev_id) 407 unsigned long irqflags, const char *devname, void *dev_id)
357{ 408{
358 struct irqaction * action; 409 struct irqaction *action;
359 int retval; 410 int retval;
360 411
361 /* 412 /*
@@ -368,6 +419,8 @@ int request_irq(unsigned int irq,
368 return -EINVAL; 419 return -EINVAL;
369 if (irq >= NR_IRQS) 420 if (irq >= NR_IRQS)
370 return -EINVAL; 421 return -EINVAL;
422 if (irq_desc[irq].status & IRQ_NOREQUEST)
423 return -EINVAL;
371 if (!handler) 424 if (!handler)
372 return -EINVAL; 425 return -EINVAL;
373 426
@@ -390,6 +443,5 @@ int request_irq(unsigned int irq,
390 443
391 return retval; 444 return retval;
392} 445}
393
394EXPORT_SYMBOL(request_irq); 446EXPORT_SYMBOL(request_irq);
395 447
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index a12d00eb5e7c..a57ebe9fa6f6 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -3,19 +3,19 @@
3 3
4void set_pending_irq(unsigned int irq, cpumask_t mask) 4void set_pending_irq(unsigned int irq, cpumask_t mask)
5{ 5{
6 irq_desc_t *desc = irq_desc + irq; 6 struct irq_desc *desc = irq_desc + irq;
7 unsigned long flags; 7 unsigned long flags;
8 8
9 spin_lock_irqsave(&desc->lock, flags); 9 spin_lock_irqsave(&desc->lock, flags);
10 desc->move_irq = 1; 10 desc->move_irq = 1;
11 pending_irq_cpumask[irq] = mask; 11 irq_desc[irq].pending_mask = mask;
12 spin_unlock_irqrestore(&desc->lock, flags); 12 spin_unlock_irqrestore(&desc->lock, flags);
13} 13}
14 14
15void move_native_irq(int irq) 15void move_native_irq(int irq)
16{ 16{
17 struct irq_desc *desc = irq_desc + irq;
17 cpumask_t tmp; 18 cpumask_t tmp;
18 irq_desc_t *desc = irq_descp(irq);
19 19
20 if (likely(!desc->move_irq)) 20 if (likely(!desc->move_irq))
21 return; 21 return;
@@ -30,15 +30,15 @@ void move_native_irq(int irq)
30 30
31 desc->move_irq = 0; 31 desc->move_irq = 0;
32 32
33 if (unlikely(cpus_empty(pending_irq_cpumask[irq]))) 33 if (unlikely(cpus_empty(irq_desc[irq].pending_mask)))
34 return; 34 return;
35 35
36 if (!desc->handler->set_affinity) 36 if (!desc->chip->set_affinity)
37 return; 37 return;
38 38
39 assert_spin_locked(&desc->lock); 39 assert_spin_locked(&desc->lock);
40 40
41 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map); 41 cpus_and(tmp, irq_desc[irq].pending_mask, cpu_online_map);
42 42
43 /* 43 /*
44 * If there was a valid mask to work with, please 44 * If there was a valid mask to work with, please
@@ -51,12 +51,12 @@ void move_native_irq(int irq)
51 */ 51 */
52 if (likely(!cpus_empty(tmp))) { 52 if (likely(!cpus_empty(tmp))) {
53 if (likely(!(desc->status & IRQ_DISABLED))) 53 if (likely(!(desc->status & IRQ_DISABLED)))
54 desc->handler->disable(irq); 54 desc->chip->disable(irq);
55 55
56 desc->handler->set_affinity(irq,tmp); 56 desc->chip->set_affinity(irq,tmp);
57 57
58 if (likely(!(desc->status & IRQ_DISABLED))) 58 if (likely(!(desc->status & IRQ_DISABLED)))
59 desc->handler->enable(irq); 59 desc->chip->enable(irq);
60 } 60 }
61 cpus_clear(pending_irq_cpumask[irq]); 61 cpus_clear(irq_desc[irq].pending_mask);
62} 62}
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index afacd6f585fa..607c7809ad01 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -12,15 +12,10 @@
12 12
13#include "internals.h" 13#include "internals.h"
14 14
15static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS]; 15static struct proc_dir_entry *root_irq_dir;
16 16
17#ifdef CONFIG_SMP 17#ifdef CONFIG_SMP
18 18
19/*
20 * The /proc/irq/<irq>/smp_affinity values:
21 */
22static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
23
24#ifdef CONFIG_GENERIC_PENDING_IRQ 19#ifdef CONFIG_GENERIC_PENDING_IRQ
25void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) 20void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
26{ 21{
@@ -36,15 +31,15 @@ void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
36void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) 31void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
37{ 32{
38 set_balance_irq_affinity(irq, mask_val); 33 set_balance_irq_affinity(irq, mask_val);
39 irq_affinity[irq] = mask_val; 34 irq_desc[irq].affinity = mask_val;
40 irq_desc[irq].handler->set_affinity(irq, mask_val); 35 irq_desc[irq].chip->set_affinity(irq, mask_val);
41} 36}
42#endif 37#endif
43 38
44static int irq_affinity_read_proc(char *page, char **start, off_t off, 39static int irq_affinity_read_proc(char *page, char **start, off_t off,
45 int count, int *eof, void *data) 40 int count, int *eof, void *data)
46{ 41{
47 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); 42 int len = cpumask_scnprintf(page, count, irq_desc[(long)data].affinity);
48 43
49 if (count - len < 2) 44 if (count - len < 2)
50 return -EINVAL; 45 return -EINVAL;
@@ -59,7 +54,7 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
59 unsigned int irq = (int)(long)data, full_count = count, err; 54 unsigned int irq = (int)(long)data, full_count = count, err;
60 cpumask_t new_value, tmp; 55 cpumask_t new_value, tmp;
61 56
62 if (!irq_desc[irq].handler->set_affinity || no_irq_affinity) 57 if (!irq_desc[irq].chip->set_affinity || no_irq_affinity)
63 return -EIO; 58 return -EIO;
64 59
65 err = cpumask_parse(buffer, count, new_value); 60 err = cpumask_parse(buffer, count, new_value);
@@ -102,7 +97,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
102{ 97{
103 char name [MAX_NAMELEN]; 98 char name [MAX_NAMELEN];
104 99
105 if (!irq_dir[irq] || action->dir || !action->name || 100 if (!irq_desc[irq].dir || action->dir || !action->name ||
106 !name_unique(irq, action)) 101 !name_unique(irq, action))
107 return; 102 return;
108 103
@@ -110,7 +105,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
110 snprintf(name, MAX_NAMELEN, "%s", action->name); 105 snprintf(name, MAX_NAMELEN, "%s", action->name);
111 106
112 /* create /proc/irq/1234/handler/ */ 107 /* create /proc/irq/1234/handler/ */
113 action->dir = proc_mkdir(name, irq_dir[irq]); 108 action->dir = proc_mkdir(name, irq_desc[irq].dir);
114} 109}
115 110
116#undef MAX_NAMELEN 111#undef MAX_NAMELEN
@@ -122,22 +117,22 @@ void register_irq_proc(unsigned int irq)
122 char name [MAX_NAMELEN]; 117 char name [MAX_NAMELEN];
123 118
124 if (!root_irq_dir || 119 if (!root_irq_dir ||
125 (irq_desc[irq].handler == &no_irq_type) || 120 (irq_desc[irq].chip == &no_irq_chip) ||
126 irq_dir[irq]) 121 irq_desc[irq].dir)
127 return; 122 return;
128 123
129 memset(name, 0, MAX_NAMELEN); 124 memset(name, 0, MAX_NAMELEN);
130 sprintf(name, "%d", irq); 125 sprintf(name, "%d", irq);
131 126
132 /* create /proc/irq/1234 */ 127 /* create /proc/irq/1234 */
133 irq_dir[irq] = proc_mkdir(name, root_irq_dir); 128 irq_desc[irq].dir = proc_mkdir(name, root_irq_dir);
134 129
135#ifdef CONFIG_SMP 130#ifdef CONFIG_SMP
136 { 131 {
137 struct proc_dir_entry *entry; 132 struct proc_dir_entry *entry;
138 133
139 /* create /proc/irq/<irq>/smp_affinity */ 134 /* create /proc/irq/<irq>/smp_affinity */
140 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]); 135 entry = create_proc_entry("smp_affinity", 0600, irq_desc[irq].dir);
141 136
142 if (entry) { 137 if (entry) {
143 entry->nlink = 1; 138 entry->nlink = 1;
@@ -145,7 +140,6 @@ void register_irq_proc(unsigned int irq)
145 entry->read_proc = irq_affinity_read_proc; 140 entry->read_proc = irq_affinity_read_proc;
146 entry->write_proc = irq_affinity_write_proc; 141 entry->write_proc = irq_affinity_write_proc;
147 } 142 }
148 smp_affinity_entry[irq] = entry;
149 } 143 }
150#endif 144#endif
151} 145}
@@ -155,7 +149,7 @@ void register_irq_proc(unsigned int irq)
155void unregister_handler_proc(unsigned int irq, struct irqaction *action) 149void unregister_handler_proc(unsigned int irq, struct irqaction *action)
156{ 150{
157 if (action->dir) 151 if (action->dir)
158 remove_proc_entry(action->dir->name, irq_dir[irq]); 152 remove_proc_entry(action->dir->name, irq_desc[irq].dir);
159} 153}
160 154
161void init_irq_proc(void) 155void init_irq_proc(void)
diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c
new file mode 100644
index 000000000000..872f91ba2ce8
--- /dev/null
+++ b/kernel/irq/resend.c
@@ -0,0 +1,78 @@
1/*
2 * linux/kernel/irq/resend.c
3 *
4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner
6 *
7 * This file contains the IRQ-resend code
8 *
9 * If the interrupt is waiting to be processed, we try to re-run it.
10 * We can't directly run it from here since the caller might be in an
11 * interrupt-protected region. Not all irq controller chips can
12 * retrigger interrupts at the hardware level, so in those cases
13 * we allow the resending of IRQs via a tasklet.
14 */
15
16#include <linux/irq.h>
17#include <linux/module.h>
18#include <linux/random.h>
19#include <linux/interrupt.h>
20
21#include "internals.h"
22
23#ifdef CONFIG_HARDIRQS_SW_RESEND
24
25/* Bitmap to handle software resend of interrupts: */
26static DECLARE_BITMAP(irqs_resend, NR_IRQS);
27
28/*
29 * Run software resends of IRQ's
30 */
31static void resend_irqs(unsigned long arg)
32{
33 struct irq_desc *desc;
34 int irq;
35
36 while (!bitmap_empty(irqs_resend, NR_IRQS)) {
37 irq = find_first_bit(irqs_resend, NR_IRQS);
38 clear_bit(irq, irqs_resend);
39 desc = irq_desc + irq;
40 local_irq_disable();
41 desc->handle_irq(irq, desc, NULL);
42 local_irq_enable();
43 }
44}
45
46/* Tasklet to handle resend: */
47static DECLARE_TASKLET(resend_tasklet, resend_irqs, 0);
48
49#endif
50
51/*
52 * IRQ resend
53 *
54 * Is called with interrupts disabled and desc->lock held.
55 */
56void check_irq_resend(struct irq_desc *desc, unsigned int irq)
57{
58 unsigned int status = desc->status;
59
60 /*
61 * Make sure the interrupt is enabled, before resending it:
62 */
63 desc->chip->enable(irq);
64
65 if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
66 desc->status &= ~IRQ_PENDING;
67 desc->status = status | IRQ_REPLAY;
68
69 if (!desc->chip || !desc->chip->retrigger ||
70 !desc->chip->retrigger(irq)) {
71#ifdef CONFIG_HARDIRQS_SW_RESEND
72 /* Set it pending and activate the softirq: */
73 set_bit(irq, irqs_resend);
74 tasklet_schedule(&resend_tasklet);
75#endif
76 }
77 }
78}
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index b2fb3c18d06b..b483deed311c 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -16,22 +16,20 @@ static int irqfixup __read_mostly;
16/* 16/*
17 * Recovery handler for misrouted interrupts. 17 * Recovery handler for misrouted interrupts.
18 */ 18 */
19
20static int misrouted_irq(int irq, struct pt_regs *regs) 19static int misrouted_irq(int irq, struct pt_regs *regs)
21{ 20{
22 int i; 21 int i;
23 irq_desc_t *desc;
24 int ok = 0; 22 int ok = 0;
25 int work = 0; /* Did we do work for a real IRQ */ 23 int work = 0; /* Did we do work for a real IRQ */
26 24
27 for(i = 1; i < NR_IRQS; i++) { 25 for (i = 1; i < NR_IRQS; i++) {
26 struct irq_desc *desc = irq_desc + i;
28 struct irqaction *action; 27 struct irqaction *action;
29 28
30 if (i == irq) /* Already tried */ 29 if (i == irq) /* Already tried */
31 continue; 30 continue;
32 desc = &irq_desc[i]; 31
33 spin_lock(&desc->lock); 32 spin_lock(&desc->lock);
34 action = desc->action;
35 /* Already running on another processor */ 33 /* Already running on another processor */
36 if (desc->status & IRQ_INPROGRESS) { 34 if (desc->status & IRQ_INPROGRESS) {
37 /* 35 /*
@@ -45,7 +43,9 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
45 } 43 }
46 /* Honour the normal IRQ locking */ 44 /* Honour the normal IRQ locking */
47 desc->status |= IRQ_INPROGRESS; 45 desc->status |= IRQ_INPROGRESS;
46 action = desc->action;
48 spin_unlock(&desc->lock); 47 spin_unlock(&desc->lock);
48
49 while (action) { 49 while (action) {
50 /* Only shared IRQ handlers are safe to call */ 50 /* Only shared IRQ handlers are safe to call */
51 if (action->flags & SA_SHIRQ) { 51 if (action->flags & SA_SHIRQ) {
@@ -62,9 +62,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
62 62
63 /* 63 /*
64 * While we were looking for a fixup someone queued a real 64 * While we were looking for a fixup someone queued a real
65 * IRQ clashing with our walk 65 * IRQ clashing with our walk:
66 */ 66 */
67
68 while ((desc->status & IRQ_PENDING) && action) { 67 while ((desc->status & IRQ_PENDING) && action) {
69 /* 68 /*
70 * Perform real IRQ processing for the IRQ we deferred 69 * Perform real IRQ processing for the IRQ we deferred
@@ -80,8 +79,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
80 * If we did actual work for the real IRQ line we must let the 79 * If we did actual work for the real IRQ line we must let the
81 * IRQ controller clean up too 80 * IRQ controller clean up too
82 */ 81 */
83 if(work) 82 if (work && desc->chip && desc->chip->end)
84 desc->handler->end(i); 83 desc->chip->end(i);
85 spin_unlock(&desc->lock); 84 spin_unlock(&desc->lock);
86 } 85 }
87 /* So the caller can adjust the irq error counts */ 86 /* So the caller can adjust the irq error counts */
@@ -100,7 +99,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
100 */ 99 */
101 100
102static void 101static void
103__report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) 102__report_bad_irq(unsigned int irq, struct irq_desc *desc,
103 irqreturn_t action_ret)
104{ 104{
105 struct irqaction *action; 105 struct irqaction *action;
106 106
@@ -113,6 +113,7 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
113 } 113 }
114 dump_stack(); 114 dump_stack();
115 printk(KERN_ERR "handlers:\n"); 115 printk(KERN_ERR "handlers:\n");
116
116 action = desc->action; 117 action = desc->action;
117 while (action) { 118 while (action) {
118 printk(KERN_ERR "[<%p>]", action->handler); 119 printk(KERN_ERR "[<%p>]", action->handler);
@@ -123,7 +124,8 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
123 } 124 }
124} 125}
125 126
126static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) 127static void
128report_bad_irq(unsigned int irq, struct irq_desc *desc, irqreturn_t action_ret)
127{ 129{
128 static int count = 100; 130 static int count = 100;
129 131
@@ -133,8 +135,8 @@ static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t actio
133 } 135 }
134} 136}
135 137
136void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret, 138void note_interrupt(unsigned int irq, struct irq_desc *desc,
137 struct pt_regs *regs) 139 irqreturn_t action_ret, struct pt_regs *regs)
138{ 140{
139 if (unlikely(action_ret != IRQ_HANDLED)) { 141 if (unlikely(action_ret != IRQ_HANDLED)) {
140 desc->irqs_unhandled++; 142 desc->irqs_unhandled++;
@@ -166,7 +168,8 @@ void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret,
166 */ 168 */
167 printk(KERN_EMERG "Disabling IRQ #%d\n", irq); 169 printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
168 desc->status |= IRQ_DISABLED; 170 desc->status |= IRQ_DISABLED;
169 desc->handler->disable(irq); 171 desc->depth = 1;
172 desc->chip->disable(irq);
170 } 173 }
171 desc->irqs_unhandled = 0; 174 desc->irqs_unhandled = 0;
172} 175}
@@ -177,6 +180,7 @@ int __init noirqdebug_setup(char *str)
177{ 180{
178 noirqdebug = 1; 181 noirqdebug = 1;
179 printk(KERN_INFO "IRQ lockup detection disabled\n"); 182 printk(KERN_INFO "IRQ lockup detection disabled\n");
183
180 return 1; 184 return 1;
181} 185}
182 186
@@ -187,6 +191,7 @@ static int __init irqfixup_setup(char *str)
187 irqfixup = 1; 191 irqfixup = 1;
188 printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n"); 192 printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n");
189 printk(KERN_WARNING "This may impact system performance.\n"); 193 printk(KERN_WARNING "This may impact system performance.\n");
194
190 return 1; 195 return 1;
191} 196}
192 197
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 58f0f382597c..50087ecf337e 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1042,7 +1042,6 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
1042 1042
1043void crash_kexec(struct pt_regs *regs) 1043void crash_kexec(struct pt_regs *regs)
1044{ 1044{
1045 struct kimage *image;
1046 int locked; 1045 int locked;
1047 1046
1048 1047
@@ -1056,12 +1055,11 @@ void crash_kexec(struct pt_regs *regs)
1056 */ 1055 */
1057 locked = xchg(&kexec_lock, 1); 1056 locked = xchg(&kexec_lock, 1);
1058 if (!locked) { 1057 if (!locked) {
1059 image = xchg(&kexec_crash_image, NULL); 1058 if (kexec_crash_image) {
1060 if (image) {
1061 struct pt_regs fixed_regs; 1059 struct pt_regs fixed_regs;
1062 crash_setup_regs(&fixed_regs, regs); 1060 crash_setup_regs(&fixed_regs, regs);
1063 machine_crash_shutdown(&fixed_regs); 1061 machine_crash_shutdown(&fixed_regs);
1064 machine_kexec(image); 1062 machine_kexec(kexec_crash_image);
1065 } 1063 }
1066 xchg(&kexec_lock, 0); 1064 xchg(&kexec_lock, 0);
1067 } 1065 }
diff --git a/kernel/module.c b/kernel/module.c
index 10e5b872adf6..99c022ac3d21 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1,4 +1,4 @@
1/* Rewritten by Rusty Russell, on the backs of many others... 1/*
2 Copyright (C) 2002 Richard Henderson 2 Copyright (C) 2002 Richard Henderson
3 Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM. 3 Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.
4 4
@@ -122,9 +122,17 @@ extern const struct kernel_symbol __start___ksymtab_gpl[];
122extern const struct kernel_symbol __stop___ksymtab_gpl[]; 122extern const struct kernel_symbol __stop___ksymtab_gpl[];
123extern const struct kernel_symbol __start___ksymtab_gpl_future[]; 123extern const struct kernel_symbol __start___ksymtab_gpl_future[];
124extern const struct kernel_symbol __stop___ksymtab_gpl_future[]; 124extern const struct kernel_symbol __stop___ksymtab_gpl_future[];
125extern const struct kernel_symbol __start___ksymtab_unused[];
126extern const struct kernel_symbol __stop___ksymtab_unused[];
127extern const struct kernel_symbol __start___ksymtab_unused_gpl[];
128extern const struct kernel_symbol __stop___ksymtab_unused_gpl[];
129extern const struct kernel_symbol __start___ksymtab_gpl_future[];
130extern const struct kernel_symbol __stop___ksymtab_gpl_future[];
125extern const unsigned long __start___kcrctab[]; 131extern const unsigned long __start___kcrctab[];
126extern const unsigned long __start___kcrctab_gpl[]; 132extern const unsigned long __start___kcrctab_gpl[];
127extern const unsigned long __start___kcrctab_gpl_future[]; 133extern const unsigned long __start___kcrctab_gpl_future[];
134extern const unsigned long __start___kcrctab_unused[];
135extern const unsigned long __start___kcrctab_unused_gpl[];
128 136
129#ifndef CONFIG_MODVERSIONS 137#ifndef CONFIG_MODVERSIONS
130#define symversion(base, idx) NULL 138#define symversion(base, idx) NULL
@@ -144,6 +152,17 @@ static const struct kernel_symbol *lookup_symbol(const char *name,
144 return NULL; 152 return NULL;
145} 153}
146 154
155static void printk_unused_warning(const char *name)
156{
157 printk(KERN_WARNING "Symbol %s is marked as UNUSED, "
158 "however this module is using it.\n", name);
159 printk(KERN_WARNING "This symbol will go away in the future.\n");
160 printk(KERN_WARNING "Please evalute if this is the right api to use, "
161 "and if it really is, submit a report the linux kernel "
162 "mailinglist together with submitting your code for "
163 "inclusion.\n");
164}
165
147/* Find a symbol, return value, crc and module which owns it */ 166/* Find a symbol, return value, crc and module which owns it */
148static unsigned long __find_symbol(const char *name, 167static unsigned long __find_symbol(const char *name,
149 struct module **owner, 168 struct module **owner,
@@ -186,6 +205,25 @@ static unsigned long __find_symbol(const char *name,
186 return ks->value; 205 return ks->value;
187 } 206 }
188 207
208 ks = lookup_symbol(name, __start___ksymtab_unused,
209 __stop___ksymtab_unused);
210 if (ks) {
211 printk_unused_warning(name);
212 *crc = symversion(__start___kcrctab_unused,
213 (ks - __start___ksymtab_unused));
214 return ks->value;
215 }
216
217 if (gplok)
218 ks = lookup_symbol(name, __start___ksymtab_unused_gpl,
219 __stop___ksymtab_unused_gpl);
220 if (ks) {
221 printk_unused_warning(name);
222 *crc = symversion(__start___kcrctab_unused_gpl,
223 (ks - __start___ksymtab_unused_gpl));
224 return ks->value;
225 }
226
189 /* Now try modules. */ 227 /* Now try modules. */
190 list_for_each_entry(mod, &modules, list) { 228 list_for_each_entry(mod, &modules, list) {
191 *owner = mod; 229 *owner = mod;
@@ -204,6 +242,23 @@ static unsigned long __find_symbol(const char *name,
204 return ks->value; 242 return ks->value;
205 } 243 }
206 } 244 }
245 ks = lookup_symbol(name, mod->unused_syms, mod->unused_syms + mod->num_unused_syms);
246 if (ks) {
247 printk_unused_warning(name);
248 *crc = symversion(mod->unused_crcs, (ks - mod->unused_syms));
249 return ks->value;
250 }
251
252 if (gplok) {
253 ks = lookup_symbol(name, mod->unused_gpl_syms,
254 mod->unused_gpl_syms + mod->num_unused_gpl_syms);
255 if (ks) {
256 printk_unused_warning(name);
257 *crc = symversion(mod->unused_gpl_crcs,
258 (ks - mod->unused_gpl_syms));
259 return ks->value;
260 }
261 }
207 ks = lookup_symbol(name, mod->gpl_future_syms, 262 ks = lookup_symbol(name, mod->gpl_future_syms,
208 (mod->gpl_future_syms + 263 (mod->gpl_future_syms +
209 mod->num_gpl_future_syms)); 264 mod->num_gpl_future_syms));
@@ -1403,10 +1458,27 @@ static struct module *load_module(void __user *umod,
1403 Elf_Ehdr *hdr; 1458 Elf_Ehdr *hdr;
1404 Elf_Shdr *sechdrs; 1459 Elf_Shdr *sechdrs;
1405 char *secstrings, *args, *modmagic, *strtab = NULL; 1460 char *secstrings, *args, *modmagic, *strtab = NULL;
1406 unsigned int i, symindex = 0, strindex = 0, setupindex, exindex, 1461 unsigned int i;
1407 exportindex, modindex, obsparmindex, infoindex, gplindex, 1462 unsigned int symindex = 0;
1408 crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex, 1463 unsigned int strindex = 0;
1409 gplfuturecrcindex, unwindex = 0; 1464 unsigned int setupindex;
1465 unsigned int exindex;
1466 unsigned int exportindex;
1467 unsigned int modindex;
1468 unsigned int obsparmindex;
1469 unsigned int infoindex;
1470 unsigned int gplindex;
1471 unsigned int crcindex;
1472 unsigned int gplcrcindex;
1473 unsigned int versindex;
1474 unsigned int pcpuindex;
1475 unsigned int gplfutureindex;
1476 unsigned int gplfuturecrcindex;
1477 unsigned int unwindex = 0;
1478 unsigned int unusedindex;
1479 unsigned int unusedcrcindex;
1480 unsigned int unusedgplindex;
1481 unsigned int unusedgplcrcindex;
1410 struct module *mod; 1482 struct module *mod;
1411 long err = 0; 1483 long err = 0;
1412 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1484 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -1487,9 +1559,13 @@ static struct module *load_module(void __user *umod,
1487 exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab"); 1559 exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab");
1488 gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl"); 1560 gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl");
1489 gplfutureindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl_future"); 1561 gplfutureindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl_future");
1562 unusedindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_unused");
1563 unusedgplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_unused_gpl");
1490 crcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab"); 1564 crcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab");
1491 gplcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl"); 1565 gplcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl");
1492 gplfuturecrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl_future"); 1566 gplfuturecrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl_future");
1567 unusedcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_unused");
1568 unusedgplcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_unused_gpl");
1493 setupindex = find_sec(hdr, sechdrs, secstrings, "__param"); 1569 setupindex = find_sec(hdr, sechdrs, secstrings, "__param");
1494 exindex = find_sec(hdr, sechdrs, secstrings, "__ex_table"); 1570 exindex = find_sec(hdr, sechdrs, secstrings, "__ex_table");
1495 obsparmindex = find_sec(hdr, sechdrs, secstrings, "__obsparm"); 1571 obsparmindex = find_sec(hdr, sechdrs, secstrings, "__obsparm");
@@ -1638,14 +1714,27 @@ static struct module *load_module(void __user *umod,
1638 mod->gpl_crcs = (void *)sechdrs[gplcrcindex].sh_addr; 1714 mod->gpl_crcs = (void *)sechdrs[gplcrcindex].sh_addr;
1639 mod->num_gpl_future_syms = sechdrs[gplfutureindex].sh_size / 1715 mod->num_gpl_future_syms = sechdrs[gplfutureindex].sh_size /
1640 sizeof(*mod->gpl_future_syms); 1716 sizeof(*mod->gpl_future_syms);
1717 mod->num_unused_syms = sechdrs[unusedindex].sh_size /
1718 sizeof(*mod->unused_syms);
1719 mod->num_unused_gpl_syms = sechdrs[unusedgplindex].sh_size /
1720 sizeof(*mod->unused_gpl_syms);
1641 mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr; 1721 mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr;
1642 if (gplfuturecrcindex) 1722 if (gplfuturecrcindex)
1643 mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr; 1723 mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr;
1644 1724
1725 mod->unused_syms = (void *)sechdrs[unusedindex].sh_addr;
1726 if (unusedcrcindex)
1727 mod->unused_crcs = (void *)sechdrs[unusedcrcindex].sh_addr;
1728 mod->unused_gpl_syms = (void *)sechdrs[unusedgplindex].sh_addr;
1729 if (unusedgplcrcindex)
1730 mod->unused_crcs = (void *)sechdrs[unusedgplcrcindex].sh_addr;
1731
1645#ifdef CONFIG_MODVERSIONS 1732#ifdef CONFIG_MODVERSIONS
1646 if ((mod->num_syms && !crcindex) || 1733 if ((mod->num_syms && !crcindex) ||
1647 (mod->num_gpl_syms && !gplcrcindex) || 1734 (mod->num_gpl_syms && !gplcrcindex) ||
1648 (mod->num_gpl_future_syms && !gplfuturecrcindex)) { 1735 (mod->num_gpl_future_syms && !gplfuturecrcindex) ||
1736 (mod->num_unused_syms && !unusedcrcindex) ||
1737 (mod->num_unused_gpl_syms && !unusedgplcrcindex)) {
1649 printk(KERN_WARNING "%s: No versions for exported symbols." 1738 printk(KERN_WARNING "%s: No versions for exported symbols."
1650 " Tainting kernel.\n", mod->name); 1739 " Tainting kernel.\n", mod->name);
1651 add_taint(TAINT_FORCED_MODULE); 1740 add_taint(TAINT_FORCED_MODULE);
diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
index 036b6285b15c..e38e4bac97ca 100644
--- a/kernel/mutex-debug.c
+++ b/kernel/mutex-debug.c
@@ -16,6 +16,7 @@
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/poison.h>
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20#include <linux/kallsyms.h> 21#include <linux/kallsyms.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
@@ -381,7 +382,7 @@ void debug_mutex_set_owner(struct mutex *lock,
381 382
382void debug_mutex_init_waiter(struct mutex_waiter *waiter) 383void debug_mutex_init_waiter(struct mutex_waiter *waiter)
383{ 384{
384 memset(waiter, 0x11, sizeof(*waiter)); 385 memset(waiter, MUTEX_DEBUG_INIT, sizeof(*waiter));
385 waiter->magic = waiter; 386 waiter->magic = waiter;
386 INIT_LIST_HEAD(&waiter->list); 387 INIT_LIST_HEAD(&waiter->list);
387} 388}
@@ -397,7 +398,7 @@ void debug_mutex_wake_waiter(struct mutex *lock, struct mutex_waiter *waiter)
397void debug_mutex_free_waiter(struct mutex_waiter *waiter) 398void debug_mutex_free_waiter(struct mutex_waiter *waiter)
398{ 399{
399 DEBUG_WARN_ON(!list_empty(&waiter->list)); 400 DEBUG_WARN_ON(!list_empty(&waiter->list));
400 memset(waiter, 0x22, sizeof(*waiter)); 401 memset(waiter, MUTEX_DEBUG_FREE, sizeof(*waiter));
401} 402}
402 403
403void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter, 404void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index fc311a4673a2..857b4fa09124 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -38,13 +38,22 @@ config PM_DEBUG
38 38
39config PM_TRACE 39config PM_TRACE
40 bool "Suspend/resume event tracing" 40 bool "Suspend/resume event tracing"
41 depends on PM && PM_DEBUG && X86_32 41 depends on PM && PM_DEBUG && X86_32 && EXPERIMENTAL
42 default y 42 default n
43 ---help--- 43 ---help---
44 This enables some cheesy code to save the last PM event point in the 44 This enables some cheesy code to save the last PM event point in the
45 RTC across reboots, so that you can debug a machine that just hangs 45 RTC across reboots, so that you can debug a machine that just hangs
46 during suspend (or more commonly, during resume). 46 during suspend (or more commonly, during resume).
47 47
48 To use this debugging feature you should attempt to suspend the machine,
49 then reboot it, then run
50
51 dmesg -s 1000000 | grep 'hash matches'
52
53 CAUTION: this option will cause your machine's real-time clock to be
54 set to an invalid time after a resume.
55
56
48config SOFTWARE_SUSPEND 57config SOFTWARE_SUSPEND
49 bool "Software Suspend" 58 bool "Software Suspend"
50 depends on PM && SWAP && (X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP) 59 depends on PM && SWAP && (X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP)
diff --git a/kernel/profile.c b/kernel/profile.c
index 68afe121e507..5a730fdb1a2c 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -299,7 +299,7 @@ out:
299} 299}
300 300
301#ifdef CONFIG_HOTPLUG_CPU 301#ifdef CONFIG_HOTPLUG_CPU
302static int profile_cpu_callback(struct notifier_block *info, 302static int __devinit profile_cpu_callback(struct notifier_block *info,
303 unsigned long action, void *__cpu) 303 unsigned long action, void *__cpu)
304{ 304{
305 int node, cpu = (unsigned long)__cpu; 305 int node, cpu = (unsigned long)__cpu;
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 20e9710fc21c..f464f5ae3f11 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -182,6 +182,15 @@ long rcu_batches_completed(void)
182 return rcu_ctrlblk.completed; 182 return rcu_ctrlblk.completed;
183} 183}
184 184
185/*
186 * Return the number of RCU batches processed thus far. Useful
187 * for debug and statistics.
188 */
189long rcu_batches_completed_bh(void)
190{
191 return rcu_bh_ctrlblk.completed;
192}
193
185static void rcu_barrier_callback(struct rcu_head *notused) 194static void rcu_barrier_callback(struct rcu_head *notused)
186{ 195{
187 if (atomic_dec_and_test(&rcu_barrier_cpu_count)) 196 if (atomic_dec_and_test(&rcu_barrier_cpu_count))
@@ -539,7 +548,7 @@ static void __devinit rcu_online_cpu(int cpu)
539 tasklet_init(&per_cpu(rcu_tasklet, cpu), rcu_process_callbacks, 0UL); 548 tasklet_init(&per_cpu(rcu_tasklet, cpu), rcu_process_callbacks, 0UL);
540} 549}
541 550
542static int rcu_cpu_notify(struct notifier_block *self, 551static int __devinit rcu_cpu_notify(struct notifier_block *self,
543 unsigned long action, void *hcpu) 552 unsigned long action, void *hcpu)
544{ 553{
545 long cpu = (long)hcpu; 554 long cpu = (long)hcpu;
@@ -556,7 +565,7 @@ static int rcu_cpu_notify(struct notifier_block *self,
556 return NOTIFY_OK; 565 return NOTIFY_OK;
557} 566}
558 567
559static struct notifier_block rcu_nb = { 568static struct notifier_block __devinitdata rcu_nb = {
560 .notifier_call = rcu_cpu_notify, 569 .notifier_call = rcu_cpu_notify,
561}; 570};
562 571
@@ -619,6 +628,7 @@ module_param(qlowmark, int, 0);
619module_param(rsinterval, int, 0); 628module_param(rsinterval, int, 0);
620#endif 629#endif
621EXPORT_SYMBOL_GPL(rcu_batches_completed); 630EXPORT_SYMBOL_GPL(rcu_batches_completed);
631EXPORT_SYMBOL_GPL(rcu_batches_completed_bh);
622EXPORT_SYMBOL_GPL(call_rcu); 632EXPORT_SYMBOL_GPL(call_rcu);
623EXPORT_SYMBOL_GPL(call_rcu_bh); 633EXPORT_SYMBOL_GPL(call_rcu_bh);
624EXPORT_SYMBOL_GPL(synchronize_rcu); 634EXPORT_SYMBOL_GPL(synchronize_rcu);
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 8154e7589d12..4d1c3d247127 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Read-Copy Update /proc-based torture test facility 2 * Read-Copy Update module-based torture test facility
3 * 3 *
4 * 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
5 * 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
@@ -53,6 +53,7 @@ static int stat_interval; /* Interval between stats, in seconds. */
53static int verbose; /* Print more debug info. */ 53static int verbose; /* Print more debug info. */
54static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */ 54static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */
55static int shuffle_interval = 5; /* Interval between shuffles (in sec)*/ 55static int shuffle_interval = 5; /* Interval between shuffles (in sec)*/
56static char *torture_type = "rcu"; /* What to torture. */
56 57
57module_param(nreaders, int, 0); 58module_param(nreaders, int, 0);
58MODULE_PARM_DESC(nreaders, "Number of RCU reader threads"); 59MODULE_PARM_DESC(nreaders, "Number of RCU reader threads");
@@ -64,13 +65,16 @@ module_param(test_no_idle_hz, bool, 0);
64MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs"); 65MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
65module_param(shuffle_interval, int, 0); 66module_param(shuffle_interval, int, 0);
66MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles"); 67MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
67#define TORTURE_FLAG "rcutorture: " 68module_param(torture_type, charp, 0);
69MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh)");
70
71#define TORTURE_FLAG "-torture:"
68#define PRINTK_STRING(s) \ 72#define PRINTK_STRING(s) \
69 do { printk(KERN_ALERT TORTURE_FLAG s "\n"); } while (0) 73 do { printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
70#define VERBOSE_PRINTK_STRING(s) \ 74#define VERBOSE_PRINTK_STRING(s) \
71 do { if (verbose) printk(KERN_ALERT TORTURE_FLAG s "\n"); } while (0) 75 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
72#define VERBOSE_PRINTK_ERRSTRING(s) \ 76#define VERBOSE_PRINTK_ERRSTRING(s) \
73 do { if (verbose) printk(KERN_ALERT TORTURE_FLAG "!!! " s "\n"); } while (0) 77 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
74 78
75static char printk_buf[4096]; 79static char printk_buf[4096];
76 80
@@ -139,28 +143,6 @@ rcu_torture_free(struct rcu_torture *p)
139 spin_unlock_bh(&rcu_torture_lock); 143 spin_unlock_bh(&rcu_torture_lock);
140} 144}
141 145
142static void
143rcu_torture_cb(struct rcu_head *p)
144{
145 int i;
146 struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu);
147
148 if (fullstop) {
149 /* Test is ending, just drop callbacks on the floor. */
150 /* The next initialization will pick up the pieces. */
151 return;
152 }
153 i = rp->rtort_pipe_count;
154 if (i > RCU_TORTURE_PIPE_LEN)
155 i = RCU_TORTURE_PIPE_LEN;
156 atomic_inc(&rcu_torture_wcount[i]);
157 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
158 rp->rtort_mbtest = 0;
159 rcu_torture_free(rp);
160 } else
161 call_rcu(p, rcu_torture_cb);
162}
163
164struct rcu_random_state { 146struct rcu_random_state {
165 unsigned long rrs_state; 147 unsigned long rrs_state;
166 unsigned long rrs_count; 148 unsigned long rrs_count;
@@ -191,6 +173,119 @@ rcu_random(struct rcu_random_state *rrsp)
191} 173}
192 174
193/* 175/*
176 * Operations vector for selecting different types of tests.
177 */
178
179struct rcu_torture_ops {
180 void (*init)(void);
181 void (*cleanup)(void);
182 int (*readlock)(void);
183 void (*readunlock)(int idx);
184 int (*completed)(void);
185 void (*deferredfree)(struct rcu_torture *p);
186 int (*stats)(char *page);
187 char *name;
188};
189static struct rcu_torture_ops *cur_ops = NULL;
190
191/*
192 * Definitions for rcu torture testing.
193 */
194
195static int rcu_torture_read_lock(void)
196{
197 rcu_read_lock();
198 return 0;
199}
200
201static void rcu_torture_read_unlock(int idx)
202{
203 rcu_read_unlock();
204}
205
206static int rcu_torture_completed(void)
207{
208 return rcu_batches_completed();
209}
210
211static void
212rcu_torture_cb(struct rcu_head *p)
213{
214 int i;
215 struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu);
216
217 if (fullstop) {
218 /* Test is ending, just drop callbacks on the floor. */
219 /* The next initialization will pick up the pieces. */
220 return;
221 }
222 i = rp->rtort_pipe_count;
223 if (i > RCU_TORTURE_PIPE_LEN)
224 i = RCU_TORTURE_PIPE_LEN;
225 atomic_inc(&rcu_torture_wcount[i]);
226 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
227 rp->rtort_mbtest = 0;
228 rcu_torture_free(rp);
229 } else
230 cur_ops->deferredfree(rp);
231}
232
233static void rcu_torture_deferred_free(struct rcu_torture *p)
234{
235 call_rcu(&p->rtort_rcu, rcu_torture_cb);
236}
237
238static struct rcu_torture_ops rcu_ops = {
239 .init = NULL,
240 .cleanup = NULL,
241 .readlock = rcu_torture_read_lock,
242 .readunlock = rcu_torture_read_unlock,
243 .completed = rcu_torture_completed,
244 .deferredfree = rcu_torture_deferred_free,
245 .stats = NULL,
246 .name = "rcu"
247};
248
249/*
250 * Definitions for rcu_bh torture testing.
251 */
252
253static int rcu_bh_torture_read_lock(void)
254{
255 rcu_read_lock_bh();
256 return 0;
257}
258
259static void rcu_bh_torture_read_unlock(int idx)
260{
261 rcu_read_unlock_bh();
262}
263
264static int rcu_bh_torture_completed(void)
265{
266 return rcu_batches_completed_bh();
267}
268
269static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
270{
271 call_rcu_bh(&p->rtort_rcu, rcu_torture_cb);
272}
273
274static struct rcu_torture_ops rcu_bh_ops = {
275 .init = NULL,
276 .cleanup = NULL,
277 .readlock = rcu_bh_torture_read_lock,
278 .readunlock = rcu_bh_torture_read_unlock,
279 .completed = rcu_bh_torture_completed,
280 .deferredfree = rcu_bh_torture_deferred_free,
281 .stats = NULL,
282 .name = "rcu_bh"
283};
284
285static struct rcu_torture_ops *torture_ops[] =
286 { &rcu_ops, &rcu_bh_ops, NULL };
287
288/*
194 * RCU torture writer kthread. Repeatedly substitutes a new structure 289 * RCU torture writer kthread. Repeatedly substitutes a new structure
195 * for that pointed to by rcu_torture_current, freeing the old structure 290 * for that pointed to by rcu_torture_current, freeing the old structure
196 * after a series of grace periods (the "pipeline"). 291 * after a series of grace periods (the "pipeline").
@@ -209,8 +304,6 @@ rcu_torture_writer(void *arg)
209 304
210 do { 305 do {
211 schedule_timeout_uninterruptible(1); 306 schedule_timeout_uninterruptible(1);
212 if (rcu_batches_completed() == oldbatch)
213 continue;
214 if ((rp = rcu_torture_alloc()) == NULL) 307 if ((rp = rcu_torture_alloc()) == NULL)
215 continue; 308 continue;
216 rp->rtort_pipe_count = 0; 309 rp->rtort_pipe_count = 0;
@@ -225,10 +318,10 @@ rcu_torture_writer(void *arg)
225 i = RCU_TORTURE_PIPE_LEN; 318 i = RCU_TORTURE_PIPE_LEN;
226 atomic_inc(&rcu_torture_wcount[i]); 319 atomic_inc(&rcu_torture_wcount[i]);
227 old_rp->rtort_pipe_count++; 320 old_rp->rtort_pipe_count++;
228 call_rcu(&old_rp->rtort_rcu, rcu_torture_cb); 321 cur_ops->deferredfree(old_rp);
229 } 322 }
230 rcu_torture_current_version++; 323 rcu_torture_current_version++;
231 oldbatch = rcu_batches_completed(); 324 oldbatch = cur_ops->completed();
232 } while (!kthread_should_stop() && !fullstop); 325 } while (!kthread_should_stop() && !fullstop);
233 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping"); 326 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping");
234 while (!kthread_should_stop()) 327 while (!kthread_should_stop())
@@ -246,6 +339,7 @@ static int
246rcu_torture_reader(void *arg) 339rcu_torture_reader(void *arg)
247{ 340{
248 int completed; 341 int completed;
342 int idx;
249 DEFINE_RCU_RANDOM(rand); 343 DEFINE_RCU_RANDOM(rand);
250 struct rcu_torture *p; 344 struct rcu_torture *p;
251 int pipe_count; 345 int pipe_count;
@@ -254,12 +348,12 @@ rcu_torture_reader(void *arg)
254 set_user_nice(current, 19); 348 set_user_nice(current, 19);
255 349
256 do { 350 do {
257 rcu_read_lock(); 351 idx = cur_ops->readlock();
258 completed = rcu_batches_completed(); 352 completed = cur_ops->completed();
259 p = rcu_dereference(rcu_torture_current); 353 p = rcu_dereference(rcu_torture_current);
260 if (p == NULL) { 354 if (p == NULL) {
261 /* Wait for rcu_torture_writer to get underway */ 355 /* Wait for rcu_torture_writer to get underway */
262 rcu_read_unlock(); 356 cur_ops->readunlock(idx);
263 schedule_timeout_interruptible(HZ); 357 schedule_timeout_interruptible(HZ);
264 continue; 358 continue;
265 } 359 }
@@ -273,14 +367,14 @@ rcu_torture_reader(void *arg)
273 pipe_count = RCU_TORTURE_PIPE_LEN; 367 pipe_count = RCU_TORTURE_PIPE_LEN;
274 } 368 }
275 ++__get_cpu_var(rcu_torture_count)[pipe_count]; 369 ++__get_cpu_var(rcu_torture_count)[pipe_count];
276 completed = rcu_batches_completed() - completed; 370 completed = cur_ops->completed() - completed;
277 if (completed > RCU_TORTURE_PIPE_LEN) { 371 if (completed > RCU_TORTURE_PIPE_LEN) {
278 /* Should not happen, but... */ 372 /* Should not happen, but... */
279 completed = RCU_TORTURE_PIPE_LEN; 373 completed = RCU_TORTURE_PIPE_LEN;
280 } 374 }
281 ++__get_cpu_var(rcu_torture_batch)[completed]; 375 ++__get_cpu_var(rcu_torture_batch)[completed];
282 preempt_enable(); 376 preempt_enable();
283 rcu_read_unlock(); 377 cur_ops->readunlock(idx);
284 schedule(); 378 schedule();
285 } while (!kthread_should_stop() && !fullstop); 379 } while (!kthread_should_stop() && !fullstop);
286 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping"); 380 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping");
@@ -311,7 +405,7 @@ rcu_torture_printk(char *page)
311 if (pipesummary[i] != 0) 405 if (pipesummary[i] != 0)
312 break; 406 break;
313 } 407 }
314 cnt += sprintf(&page[cnt], "rcutorture: "); 408 cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG);
315 cnt += sprintf(&page[cnt], 409 cnt += sprintf(&page[cnt],
316 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d " 410 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d "
317 "rtmbe: %d", 411 "rtmbe: %d",
@@ -324,7 +418,7 @@ rcu_torture_printk(char *page)
324 atomic_read(&n_rcu_torture_mberror)); 418 atomic_read(&n_rcu_torture_mberror));
325 if (atomic_read(&n_rcu_torture_mberror) != 0) 419 if (atomic_read(&n_rcu_torture_mberror) != 0)
326 cnt += sprintf(&page[cnt], " !!!"); 420 cnt += sprintf(&page[cnt], " !!!");
327 cnt += sprintf(&page[cnt], "\nrcutorture: "); 421 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
328 if (i > 1) { 422 if (i > 1) {
329 cnt += sprintf(&page[cnt], "!!! "); 423 cnt += sprintf(&page[cnt], "!!! ");
330 atomic_inc(&n_rcu_torture_error); 424 atomic_inc(&n_rcu_torture_error);
@@ -332,17 +426,19 @@ rcu_torture_printk(char *page)
332 cnt += sprintf(&page[cnt], "Reader Pipe: "); 426 cnt += sprintf(&page[cnt], "Reader Pipe: ");
333 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) 427 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
334 cnt += sprintf(&page[cnt], " %ld", pipesummary[i]); 428 cnt += sprintf(&page[cnt], " %ld", pipesummary[i]);
335 cnt += sprintf(&page[cnt], "\nrcutorture: "); 429 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
336 cnt += sprintf(&page[cnt], "Reader Batch: "); 430 cnt += sprintf(&page[cnt], "Reader Batch: ");
337 for (i = 0; i < RCU_TORTURE_PIPE_LEN; i++) 431 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
338 cnt += sprintf(&page[cnt], " %ld", batchsummary[i]); 432 cnt += sprintf(&page[cnt], " %ld", batchsummary[i]);
339 cnt += sprintf(&page[cnt], "\nrcutorture: "); 433 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
340 cnt += sprintf(&page[cnt], "Free-Block Circulation: "); 434 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
341 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { 435 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
342 cnt += sprintf(&page[cnt], " %d", 436 cnt += sprintf(&page[cnt], " %d",
343 atomic_read(&rcu_torture_wcount[i])); 437 atomic_read(&rcu_torture_wcount[i]));
344 } 438 }
345 cnt += sprintf(&page[cnt], "\n"); 439 cnt += sprintf(&page[cnt], "\n");
440 if (cur_ops->stats != NULL)
441 cnt += cur_ops->stats(&page[cnt]);
346 return cnt; 442 return cnt;
347} 443}
348 444
@@ -444,11 +540,11 @@ rcu_torture_shuffle(void *arg)
444static inline void 540static inline void
445rcu_torture_print_module_parms(char *tag) 541rcu_torture_print_module_parms(char *tag)
446{ 542{
447 printk(KERN_ALERT TORTURE_FLAG "--- %s: nreaders=%d " 543 printk(KERN_ALERT "%s" TORTURE_FLAG "--- %s: nreaders=%d "
448 "stat_interval=%d verbose=%d test_no_idle_hz=%d " 544 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
449 "shuffle_interval = %d\n", 545 "shuffle_interval = %d\n",
450 tag, nrealreaders, stat_interval, verbose, test_no_idle_hz, 546 torture_type, tag, nrealreaders, stat_interval, verbose,
451 shuffle_interval); 547 test_no_idle_hz, shuffle_interval);
452} 548}
453 549
454static void 550static void
@@ -493,6 +589,9 @@ rcu_torture_cleanup(void)
493 rcu_barrier(); 589 rcu_barrier();
494 590
495 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 591 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
592
593 if (cur_ops->cleanup != NULL)
594 cur_ops->cleanup();
496 if (atomic_read(&n_rcu_torture_error)) 595 if (atomic_read(&n_rcu_torture_error))
497 rcu_torture_print_module_parms("End of test: FAILURE"); 596 rcu_torture_print_module_parms("End of test: FAILURE");
498 else 597 else
@@ -508,6 +607,20 @@ rcu_torture_init(void)
508 607
509 /* Process args and tell the world that the torturer is on the job. */ 608 /* Process args and tell the world that the torturer is on the job. */
510 609
610 for (i = 0; cur_ops = torture_ops[i], cur_ops != NULL; i++) {
611 cur_ops = torture_ops[i];
612 if (strcmp(torture_type, cur_ops->name) == 0) {
613 break;
614 }
615 }
616 if (cur_ops == NULL) {
617 printk(KERN_ALERT "rcutorture: invalid torture type: \"%s\"\n",
618 torture_type);
619 return (-EINVAL);
620 }
621 if (cur_ops->init != NULL)
622 cur_ops->init(); /* no "goto unwind" prior to this point!!! */
623
511 if (nreaders >= 0) 624 if (nreaders >= 0)
512 nrealreaders = nreaders; 625 nrealreaders = nreaders;
513 else 626 else
diff --git a/kernel/resource.c b/kernel/resource.c
index e3080fcc66a3..bf1130d81b7f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -23,20 +23,18 @@
23 23
24struct resource ioport_resource = { 24struct resource ioport_resource = {
25 .name = "PCI IO", 25 .name = "PCI IO",
26 .start = 0x0000, 26 .start = 0,
27 .end = IO_SPACE_LIMIT, 27 .end = IO_SPACE_LIMIT,
28 .flags = IORESOURCE_IO, 28 .flags = IORESOURCE_IO,
29}; 29};
30
31EXPORT_SYMBOL(ioport_resource); 30EXPORT_SYMBOL(ioport_resource);
32 31
33struct resource iomem_resource = { 32struct resource iomem_resource = {
34 .name = "PCI mem", 33 .name = "PCI mem",
35 .start = 0UL, 34 .start = 0,
36 .end = ~0UL, 35 .end = -1,
37 .flags = IORESOURCE_MEM, 36 .flags = IORESOURCE_MEM,
38}; 37};
39
40EXPORT_SYMBOL(iomem_resource); 38EXPORT_SYMBOL(iomem_resource);
41 39
42static DEFINE_RWLOCK(resource_lock); 40static DEFINE_RWLOCK(resource_lock);
@@ -83,10 +81,10 @@ static int r_show(struct seq_file *m, void *v)
83 for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) 81 for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
84 if (p->parent == root) 82 if (p->parent == root)
85 break; 83 break;
86 seq_printf(m, "%*s%0*lx-%0*lx : %s\n", 84 seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
87 depth * 2, "", 85 depth * 2, "",
88 width, r->start, 86 width, (unsigned long long) r->start,
89 width, r->end, 87 width, (unsigned long long) r->end,
90 r->name ? r->name : "<BAD>"); 88 r->name ? r->name : "<BAD>");
91 return 0; 89 return 0;
92} 90}
@@ -151,8 +149,8 @@ __initcall(ioresources_init);
151/* Return the conflict entry if you can't request it */ 149/* Return the conflict entry if you can't request it */
152static struct resource * __request_resource(struct resource *root, struct resource *new) 150static struct resource * __request_resource(struct resource *root, struct resource *new)
153{ 151{
154 unsigned long start = new->start; 152 resource_size_t start = new->start;
155 unsigned long end = new->end; 153 resource_size_t end = new->end;
156 struct resource *tmp, **p; 154 struct resource *tmp, **p;
157 155
158 if (end < start) 156 if (end < start)
@@ -232,15 +230,52 @@ int release_resource(struct resource *old)
232 230
233EXPORT_SYMBOL(release_resource); 231EXPORT_SYMBOL(release_resource);
234 232
233#ifdef CONFIG_MEMORY_HOTPLUG
234/*
235 * Finds the lowest memory reosurce exists within [res->start.res->end)
236 * the caller must specify res->start, res->end, res->flags.
237 * If found, returns 0, res is overwritten, if not found, returns -1.
238 */
239int find_next_system_ram(struct resource *res)
240{
241 resource_size_t start, end;
242 struct resource *p;
243
244 BUG_ON(!res);
245
246 start = res->start;
247 end = res->end;
248
249 read_lock(&resource_lock);
250 for (p = iomem_resource.child; p ; p = p->sibling) {
251 /* system ram is just marked as IORESOURCE_MEM */
252 if (p->flags != res->flags)
253 continue;
254 if (p->start > end) {
255 p = NULL;
256 break;
257 }
258 if (p->start >= start)
259 break;
260 }
261 read_unlock(&resource_lock);
262 if (!p)
263 return -1;
264 /* copy data */
265 res->start = p->start;
266 res->end = p->end;
267 return 0;
268}
269#endif
270
235/* 271/*
236 * Find empty slot in the resource tree given range and alignment. 272 * Find empty slot in the resource tree given range and alignment.
237 */ 273 */
238static int find_resource(struct resource *root, struct resource *new, 274static int find_resource(struct resource *root, struct resource *new,
239 unsigned long size, 275 resource_size_t size, resource_size_t min,
240 unsigned long min, unsigned long max, 276 resource_size_t max, resource_size_t align,
241 unsigned long align,
242 void (*alignf)(void *, struct resource *, 277 void (*alignf)(void *, struct resource *,
243 unsigned long, unsigned long), 278 resource_size_t, resource_size_t),
244 void *alignf_data) 279 void *alignf_data)
245{ 280{
246 struct resource *this = root->child; 281 struct resource *this = root->child;
@@ -282,11 +317,10 @@ static int find_resource(struct resource *root, struct resource *new,
282 * Allocate empty slot in the resource tree given range and alignment. 317 * Allocate empty slot in the resource tree given range and alignment.
283 */ 318 */
284int allocate_resource(struct resource *root, struct resource *new, 319int allocate_resource(struct resource *root, struct resource *new,
285 unsigned long size, 320 resource_size_t size, resource_size_t min,
286 unsigned long min, unsigned long max, 321 resource_size_t max, resource_size_t align,
287 unsigned long align,
288 void (*alignf)(void *, struct resource *, 322 void (*alignf)(void *, struct resource *,
289 unsigned long, unsigned long), 323 resource_size_t, resource_size_t),
290 void *alignf_data) 324 void *alignf_data)
291{ 325{
292 int err; 326 int err;
@@ -378,10 +412,10 @@ EXPORT_SYMBOL(insert_resource);
378 * arguments. Returns -EBUSY if it can't fit. Existing children of 412 * arguments. Returns -EBUSY if it can't fit. Existing children of
379 * the resource are assumed to be immutable. 413 * the resource are assumed to be immutable.
380 */ 414 */
381int adjust_resource(struct resource *res, unsigned long start, unsigned long size) 415int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size)
382{ 416{
383 struct resource *tmp, *parent = res->parent; 417 struct resource *tmp, *parent = res->parent;
384 unsigned long end = start + size - 1; 418 resource_size_t end = start + size - 1;
385 int result = -EBUSY; 419 int result = -EBUSY;
386 420
387 write_lock(&resource_lock); 421 write_lock(&resource_lock);
@@ -428,7 +462,9 @@ EXPORT_SYMBOL(adjust_resource);
428 * 462 *
429 * Release-region releases a matching busy region. 463 * Release-region releases a matching busy region.
430 */ 464 */
431struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name) 465struct resource * __request_region(struct resource *parent,
466 resource_size_t start, resource_size_t n,
467 const char *name)
432{ 468{
433 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); 469 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
434 470
@@ -464,7 +500,8 @@ struct resource * __request_region(struct resource *parent, unsigned long start,
464 500
465EXPORT_SYMBOL(__request_region); 501EXPORT_SYMBOL(__request_region);
466 502
467int __check_region(struct resource *parent, unsigned long start, unsigned long n) 503int __check_region(struct resource *parent, resource_size_t start,
504 resource_size_t n)
468{ 505{
469 struct resource * res; 506 struct resource * res;
470 507
@@ -479,10 +516,11 @@ int __check_region(struct resource *parent, unsigned long start, unsigned long n
479 516
480EXPORT_SYMBOL(__check_region); 517EXPORT_SYMBOL(__check_region);
481 518
482void __release_region(struct resource *parent, unsigned long start, unsigned long n) 519void __release_region(struct resource *parent, resource_size_t start,
520 resource_size_t n)
483{ 521{
484 struct resource **p; 522 struct resource **p;
485 unsigned long end; 523 resource_size_t end;
486 524
487 p = &parent->child; 525 p = &parent->child;
488 end = start + n - 1; 526 end = start + n - 1;
@@ -511,7 +549,9 @@ void __release_region(struct resource *parent, unsigned long start, unsigned lon
511 549
512 write_unlock(&resource_lock); 550 write_unlock(&resource_lock);
513 551
514 printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end); 552 printk(KERN_WARNING "Trying to free nonexistent resource "
553 "<%016llx-%016llx>\n", (unsigned long long)start,
554 (unsigned long long)end);
515} 555}
516 556
517EXPORT_SYMBOL(__release_region); 557EXPORT_SYMBOL(__release_region);
diff --git a/kernel/rtmutex-debug.c b/kernel/rtmutex-debug.c
new file mode 100644
index 000000000000..4aa8a2c9f453
--- /dev/null
+++ b/kernel/rtmutex-debug.c
@@ -0,0 +1,513 @@
1/*
2 * RT-Mutexes: blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner:
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2006 Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 *
9 * This code is based on the rt.c implementation in the preempt-rt tree.
10 * Portions of said code are
11 *
12 * Copyright (C) 2004 LynuxWorks, Inc., Igor Manyilov, Bill Huey
13 * Copyright (C) 2006 Esben Nielsen
14 * Copyright (C) 2006 Kihon Technologies Inc.,
15 * Steven Rostedt <rostedt@goodmis.org>
16 *
17 * See rt.c in preempt-rt for proper credits and further information
18 */
19#include <linux/config.h>
20#include <linux/sched.h>
21#include <linux/delay.h>
22#include <linux/module.h>
23#include <linux/spinlock.h>
24#include <linux/kallsyms.h>
25#include <linux/syscalls.h>
26#include <linux/interrupt.h>
27#include <linux/plist.h>
28#include <linux/fs.h>
29
30#include "rtmutex_common.h"
31
32#ifdef CONFIG_DEBUG_RT_MUTEXES
33# include "rtmutex-debug.h"
34#else
35# include "rtmutex.h"
36#endif
37
38# define TRACE_WARN_ON(x) WARN_ON(x)
39# define TRACE_BUG_ON(x) BUG_ON(x)
40
41# define TRACE_OFF() \
42do { \
43 if (rt_trace_on) { \
44 rt_trace_on = 0; \
45 console_verbose(); \
46 if (spin_is_locked(&current->pi_lock)) \
47 spin_unlock(&current->pi_lock); \
48 if (spin_is_locked(&current->held_list_lock)) \
49 spin_unlock(&current->held_list_lock); \
50 } \
51} while (0)
52
53# define TRACE_OFF_NOLOCK() \
54do { \
55 if (rt_trace_on) { \
56 rt_trace_on = 0; \
57 console_verbose(); \
58 } \
59} while (0)
60
61# define TRACE_BUG_LOCKED() \
62do { \
63 TRACE_OFF(); \
64 BUG(); \
65} while (0)
66
67# define TRACE_WARN_ON_LOCKED(c) \
68do { \
69 if (unlikely(c)) { \
70 TRACE_OFF(); \
71 WARN_ON(1); \
72 } \
73} while (0)
74
75# define TRACE_BUG_ON_LOCKED(c) \
76do { \
77 if (unlikely(c)) \
78 TRACE_BUG_LOCKED(); \
79} while (0)
80
81#ifdef CONFIG_SMP
82# define SMP_TRACE_BUG_ON_LOCKED(c) TRACE_BUG_ON_LOCKED(c)
83#else
84# define SMP_TRACE_BUG_ON_LOCKED(c) do { } while (0)
85#endif
86
87/*
88 * deadlock detection flag. We turn it off when we detect
89 * the first problem because we dont want to recurse back
90 * into the tracing code when doing error printk or
91 * executing a BUG():
92 */
93int rt_trace_on = 1;
94
95void deadlock_trace_off(void)
96{
97 rt_trace_on = 0;
98}
99
100static void printk_task(task_t *p)
101{
102 if (p)
103 printk("%16s:%5d [%p, %3d]", p->comm, p->pid, p, p->prio);
104 else
105 printk("<none>");
106}
107
108static void printk_task_short(task_t *p)
109{
110 if (p)
111 printk("%s/%d [%p, %3d]", p->comm, p->pid, p, p->prio);
112 else
113 printk("<none>");
114}
115
116static void printk_lock(struct rt_mutex *lock, int print_owner)
117{
118 if (lock->name)
119 printk(" [%p] {%s}\n",
120 lock, lock->name);
121 else
122 printk(" [%p] {%s:%d}\n",
123 lock, lock->file, lock->line);
124
125 if (print_owner && rt_mutex_owner(lock)) {
126 printk(".. ->owner: %p\n", lock->owner);
127 printk(".. held by: ");
128 printk_task(rt_mutex_owner(lock));
129 printk("\n");
130 }
131 if (rt_mutex_owner(lock)) {
132 printk("... acquired at: ");
133 print_symbol("%s\n", lock->acquire_ip);
134 }
135}
136
137static void printk_waiter(struct rt_mutex_waiter *w)
138{
139 printk("-------------------------\n");
140 printk("| waiter struct %p:\n", w);
141 printk("| w->list_entry: [DP:%p/%p|SP:%p/%p|PRI:%d]\n",
142 w->list_entry.plist.prio_list.prev, w->list_entry.plist.prio_list.next,
143 w->list_entry.plist.node_list.prev, w->list_entry.plist.node_list.next,
144 w->list_entry.prio);
145 printk("| w->pi_list_entry: [DP:%p/%p|SP:%p/%p|PRI:%d]\n",
146 w->pi_list_entry.plist.prio_list.prev, w->pi_list_entry.plist.prio_list.next,
147 w->pi_list_entry.plist.node_list.prev, w->pi_list_entry.plist.node_list.next,
148 w->pi_list_entry.prio);
149 printk("\n| lock:\n");
150 printk_lock(w->lock, 1);
151 printk("| w->ti->task:\n");
152 printk_task(w->task);
153 printk("| blocked at: ");
154 print_symbol("%s\n", w->ip);
155 printk("-------------------------\n");
156}
157
158static void show_task_locks(task_t *p)
159{
160 switch (p->state) {
161 case TASK_RUNNING: printk("R"); break;
162 case TASK_INTERRUPTIBLE: printk("S"); break;
163 case TASK_UNINTERRUPTIBLE: printk("D"); break;
164 case TASK_STOPPED: printk("T"); break;
165 case EXIT_ZOMBIE: printk("Z"); break;
166 case EXIT_DEAD: printk("X"); break;
167 default: printk("?"); break;
168 }
169 printk_task(p);
170 if (p->pi_blocked_on) {
171 struct rt_mutex *lock = p->pi_blocked_on->lock;
172
173 printk(" blocked on:");
174 printk_lock(lock, 1);
175 } else
176 printk(" (not blocked)\n");
177}
178
179void rt_mutex_show_held_locks(task_t *task, int verbose)
180{
181 struct list_head *curr, *cursor = NULL;
182 struct rt_mutex *lock;
183 task_t *t;
184 unsigned long flags;
185 int count = 0;
186
187 if (!rt_trace_on)
188 return;
189
190 if (verbose) {
191 printk("------------------------------\n");
192 printk("| showing all locks held by: | (");
193 printk_task_short(task);
194 printk("):\n");
195 printk("------------------------------\n");
196 }
197
198next:
199 spin_lock_irqsave(&task->held_list_lock, flags);
200 list_for_each(curr, &task->held_list_head) {
201 if (cursor && curr != cursor)
202 continue;
203 lock = list_entry(curr, struct rt_mutex, held_list_entry);
204 t = rt_mutex_owner(lock);
205 WARN_ON(t != task);
206 count++;
207 cursor = curr->next;
208 spin_unlock_irqrestore(&task->held_list_lock, flags);
209
210 printk("\n#%03d: ", count);
211 printk_lock(lock, 0);
212 goto next;
213 }
214 spin_unlock_irqrestore(&task->held_list_lock, flags);
215
216 printk("\n");
217}
218
219void rt_mutex_show_all_locks(void)
220{
221 task_t *g, *p;
222 int count = 10;
223 int unlock = 1;
224
225 printk("\n");
226 printk("----------------------\n");
227 printk("| showing all tasks: |\n");
228 printk("----------------------\n");
229
230 /*
231 * Here we try to get the tasklist_lock as hard as possible,
232 * if not successful after 2 seconds we ignore it (but keep
233 * trying). This is to enable a debug printout even if a
234 * tasklist_lock-holding task deadlocks or crashes.
235 */
236retry:
237 if (!read_trylock(&tasklist_lock)) {
238 if (count == 10)
239 printk("hm, tasklist_lock locked, retrying... ");
240 if (count) {
241 count--;
242 printk(" #%d", 10-count);
243 mdelay(200);
244 goto retry;
245 }
246 printk(" ignoring it.\n");
247 unlock = 0;
248 }
249 if (count != 10)
250 printk(" locked it.\n");
251
252 do_each_thread(g, p) {
253 show_task_locks(p);
254 if (!unlock)
255 if (read_trylock(&tasklist_lock))
256 unlock = 1;
257 } while_each_thread(g, p);
258
259 printk("\n");
260
261 printk("-----------------------------------------\n");
262 printk("| showing all locks held in the system: |\n");
263 printk("-----------------------------------------\n");
264
265 do_each_thread(g, p) {
266 rt_mutex_show_held_locks(p, 0);
267 if (!unlock)
268 if (read_trylock(&tasklist_lock))
269 unlock = 1;
270 } while_each_thread(g, p);
271
272
273 printk("=============================================\n\n");
274
275 if (unlock)
276 read_unlock(&tasklist_lock);
277}
278
279void rt_mutex_debug_check_no_locks_held(task_t *task)
280{
281 struct rt_mutex_waiter *w;
282 struct list_head *curr;
283 struct rt_mutex *lock;
284
285 if (!rt_trace_on)
286 return;
287 if (!rt_prio(task->normal_prio) && rt_prio(task->prio)) {
288 printk("BUG: PI priority boost leaked!\n");
289 printk_task(task);
290 printk("\n");
291 }
292 if (list_empty(&task->held_list_head))
293 return;
294
295 spin_lock(&task->pi_lock);
296 plist_for_each_entry(w, &task->pi_waiters, pi_list_entry) {
297 TRACE_OFF();
298
299 printk("hm, PI interest held at exit time? Task:\n");
300 printk_task(task);
301 printk_waiter(w);
302 return;
303 }
304 spin_unlock(&task->pi_lock);
305
306 list_for_each(curr, &task->held_list_head) {
307 lock = list_entry(curr, struct rt_mutex, held_list_entry);
308
309 printk("BUG: %s/%d, lock held at task exit time!\n",
310 task->comm, task->pid);
311 printk_lock(lock, 1);
312 if (rt_mutex_owner(lock) != task)
313 printk("exiting task is not even the owner??\n");
314 }
315}
316
317int rt_mutex_debug_check_no_locks_freed(const void *from, unsigned long len)
318{
319 const void *to = from + len;
320 struct list_head *curr;
321 struct rt_mutex *lock;
322 unsigned long flags;
323 void *lock_addr;
324
325 if (!rt_trace_on)
326 return 0;
327
328 spin_lock_irqsave(&current->held_list_lock, flags);
329 list_for_each(curr, &current->held_list_head) {
330 lock = list_entry(curr, struct rt_mutex, held_list_entry);
331 lock_addr = lock;
332 if (lock_addr < from || lock_addr >= to)
333 continue;
334 TRACE_OFF();
335
336 printk("BUG: %s/%d, active lock [%p(%p-%p)] freed!\n",
337 current->comm, current->pid, lock, from, to);
338 dump_stack();
339 printk_lock(lock, 1);
340 if (rt_mutex_owner(lock) != current)
341 printk("freeing task is not even the owner??\n");
342 return 1;
343 }
344 spin_unlock_irqrestore(&current->held_list_lock, flags);
345
346 return 0;
347}
348
349void rt_mutex_debug_task_free(struct task_struct *task)
350{
351 WARN_ON(!plist_head_empty(&task->pi_waiters));
352 WARN_ON(task->pi_blocked_on);
353}
354
355/*
356 * We fill out the fields in the waiter to store the information about
357 * the deadlock. We print when we return. act_waiter can be NULL in
358 * case of a remove waiter operation.
359 */
360void debug_rt_mutex_deadlock(int detect, struct rt_mutex_waiter *act_waiter,
361 struct rt_mutex *lock)
362{
363 struct task_struct *task;
364
365 if (!rt_trace_on || detect || !act_waiter)
366 return;
367
368 task = rt_mutex_owner(act_waiter->lock);
369 if (task && task != current) {
370 act_waiter->deadlock_task_pid = task->pid;
371 act_waiter->deadlock_lock = lock;
372 }
373}
374
375void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
376{
377 struct task_struct *task;
378
379 if (!waiter->deadlock_lock || !rt_trace_on)
380 return;
381
382 task = find_task_by_pid(waiter->deadlock_task_pid);
383 if (!task)
384 return;
385
386 TRACE_OFF_NOLOCK();
387
388 printk("\n============================================\n");
389 printk( "[ BUG: circular locking deadlock detected! ]\n");
390 printk( "--------------------------------------------\n");
391 printk("%s/%d is deadlocking current task %s/%d\n\n",
392 task->comm, task->pid, current->comm, current->pid);
393
394 printk("\n1) %s/%d is trying to acquire this lock:\n",
395 current->comm, current->pid);
396 printk_lock(waiter->lock, 1);
397
398 printk("... trying at: ");
399 print_symbol("%s\n", waiter->ip);
400
401 printk("\n2) %s/%d is blocked on this lock:\n", task->comm, task->pid);
402 printk_lock(waiter->deadlock_lock, 1);
403
404 rt_mutex_show_held_locks(current, 1);
405 rt_mutex_show_held_locks(task, 1);
406
407 printk("\n%s/%d's [blocked] stackdump:\n\n", task->comm, task->pid);
408 show_stack(task, NULL);
409 printk("\n%s/%d's [current] stackdump:\n\n",
410 current->comm, current->pid);
411 dump_stack();
412 rt_mutex_show_all_locks();
413 printk("[ turning off deadlock detection."
414 "Please report this trace. ]\n\n");
415 local_irq_disable();
416}
417
418void debug_rt_mutex_lock(struct rt_mutex *lock __IP_DECL__)
419{
420 unsigned long flags;
421
422 if (rt_trace_on) {
423 TRACE_WARN_ON_LOCKED(!list_empty(&lock->held_list_entry));
424
425 spin_lock_irqsave(&current->held_list_lock, flags);
426 list_add_tail(&lock->held_list_entry, &current->held_list_head);
427 spin_unlock_irqrestore(&current->held_list_lock, flags);
428
429 lock->acquire_ip = ip;
430 }
431}
432
433void debug_rt_mutex_unlock(struct rt_mutex *lock)
434{
435 unsigned long flags;
436
437 if (rt_trace_on) {
438 TRACE_WARN_ON_LOCKED(rt_mutex_owner(lock) != current);
439 TRACE_WARN_ON_LOCKED(list_empty(&lock->held_list_entry));
440
441 spin_lock_irqsave(&current->held_list_lock, flags);
442 list_del_init(&lock->held_list_entry);
443 spin_unlock_irqrestore(&current->held_list_lock, flags);
444 }
445}
446
447void debug_rt_mutex_proxy_lock(struct rt_mutex *lock,
448 struct task_struct *powner __IP_DECL__)
449{
450 unsigned long flags;
451
452 if (rt_trace_on) {
453 TRACE_WARN_ON_LOCKED(!list_empty(&lock->held_list_entry));
454
455 spin_lock_irqsave(&powner->held_list_lock, flags);
456 list_add_tail(&lock->held_list_entry, &powner->held_list_head);
457 spin_unlock_irqrestore(&powner->held_list_lock, flags);
458
459 lock->acquire_ip = ip;
460 }
461}
462
463void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock)
464{
465 unsigned long flags;
466
467 if (rt_trace_on) {
468 struct task_struct *owner = rt_mutex_owner(lock);
469
470 TRACE_WARN_ON_LOCKED(!owner);
471 TRACE_WARN_ON_LOCKED(list_empty(&lock->held_list_entry));
472
473 spin_lock_irqsave(&owner->held_list_lock, flags);
474 list_del_init(&lock->held_list_entry);
475 spin_unlock_irqrestore(&owner->held_list_lock, flags);
476 }
477}
478
479void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter)
480{
481 memset(waiter, 0x11, sizeof(*waiter));
482 plist_node_init(&waiter->list_entry, MAX_PRIO);
483 plist_node_init(&waiter->pi_list_entry, MAX_PRIO);
484}
485
486void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter)
487{
488 TRACE_WARN_ON(!plist_node_empty(&waiter->list_entry));
489 TRACE_WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
490 TRACE_WARN_ON(waiter->task);
491 memset(waiter, 0x22, sizeof(*waiter));
492}
493
494void debug_rt_mutex_init(struct rt_mutex *lock, const char *name)
495{
496 void *addr = lock;
497
498 if (rt_trace_on) {
499 rt_mutex_debug_check_no_locks_freed(addr,
500 sizeof(struct rt_mutex));
501 INIT_LIST_HEAD(&lock->held_list_entry);
502 lock->name = name;
503 }
504}
505
506void rt_mutex_deadlock_account_lock(struct rt_mutex *lock, task_t *task)
507{
508}
509
510void rt_mutex_deadlock_account_unlock(struct task_struct *task)
511{
512}
513
diff --git a/kernel/rtmutex-debug.h b/kernel/rtmutex-debug.h
new file mode 100644
index 000000000000..7612fbc62d70
--- /dev/null
+++ b/kernel/rtmutex-debug.h
@@ -0,0 +1,37 @@
1/*
2 * RT-Mutexes: blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner:
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 *
9 * This file contains macros used solely by rtmutex.c. Debug version.
10 */
11
12#define __IP_DECL__ , unsigned long ip
13#define __IP__ , ip
14#define __RET_IP__ , (unsigned long)__builtin_return_address(0)
15
16extern void
17rt_mutex_deadlock_account_lock(struct rt_mutex *lock, struct task_struct *task);
18extern void rt_mutex_deadlock_account_unlock(struct task_struct *task);
19extern void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter);
20extern void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter);
21extern void debug_rt_mutex_init(struct rt_mutex *lock, const char *name);
22extern void debug_rt_mutex_lock(struct rt_mutex *lock __IP_DECL__);
23extern void debug_rt_mutex_unlock(struct rt_mutex *lock);
24extern void debug_rt_mutex_proxy_lock(struct rt_mutex *lock,
25 struct task_struct *powner __IP_DECL__);
26extern void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock);
27extern void debug_rt_mutex_deadlock(int detect, struct rt_mutex_waiter *waiter,
28 struct rt_mutex *lock);
29extern void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter);
30# define debug_rt_mutex_reset_waiter(w) \
31 do { (w)->deadlock_lock = NULL; } while (0)
32
33static inline int debug_rt_mutex_detect_deadlock(struct rt_mutex_waiter *waiter,
34 int detect)
35{
36 return (waiter != NULL);
37}
diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
new file mode 100644
index 000000000000..e82c2f848249
--- /dev/null
+++ b/kernel/rtmutex-tester.c
@@ -0,0 +1,440 @@
1/*
2 * RT-Mutex-tester: scriptable tester for rt mutexes
3 *
4 * started by Thomas Gleixner:
5 *
6 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
7 *
8 */
9#include <linux/config.h>
10#include <linux/kthread.h>
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/smp_lock.h>
14#include <linux/spinlock.h>
15#include <linux/sysdev.h>
16#include <linux/timer.h>
17
18#include "rtmutex.h"
19
20#define MAX_RT_TEST_THREADS 8
21#define MAX_RT_TEST_MUTEXES 8
22
23static spinlock_t rttest_lock;
24static atomic_t rttest_event;
25
26struct test_thread_data {
27 int opcode;
28 int opdata;
29 int mutexes[MAX_RT_TEST_MUTEXES];
30 int bkl;
31 int event;
32 struct sys_device sysdev;
33};
34
35static struct test_thread_data thread_data[MAX_RT_TEST_THREADS];
36static task_t *threads[MAX_RT_TEST_THREADS];
37static struct rt_mutex mutexes[MAX_RT_TEST_MUTEXES];
38
39enum test_opcodes {
40 RTTEST_NOP = 0,
41 RTTEST_SCHEDOT, /* 1 Sched other, data = nice */
42 RTTEST_SCHEDRT, /* 2 Sched fifo, data = prio */
43 RTTEST_LOCK, /* 3 Lock uninterruptible, data = lockindex */
44 RTTEST_LOCKNOWAIT, /* 4 Lock uninterruptible no wait in wakeup, data = lockindex */
45 RTTEST_LOCKINT, /* 5 Lock interruptible, data = lockindex */
46 RTTEST_LOCKINTNOWAIT, /* 6 Lock interruptible no wait in wakeup, data = lockindex */
47 RTTEST_LOCKCONT, /* 7 Continue locking after the wakeup delay */
48 RTTEST_UNLOCK, /* 8 Unlock, data = lockindex */
49 RTTEST_LOCKBKL, /* 9 Lock BKL */
50 RTTEST_UNLOCKBKL, /* 10 Unlock BKL */
51 RTTEST_SIGNAL, /* 11 Signal other test thread, data = thread id */
52 RTTEST_RESETEVENT = 98, /* 98 Reset event counter */
53 RTTEST_RESET = 99, /* 99 Reset all pending operations */
54};
55
56static int handle_op(struct test_thread_data *td, int lockwakeup)
57{
58 int i, id, ret = -EINVAL;
59
60 switch(td->opcode) {
61
62 case RTTEST_NOP:
63 return 0;
64
65 case RTTEST_LOCKCONT:
66 td->mutexes[td->opdata] = 1;
67 td->event = atomic_add_return(1, &rttest_event);
68 return 0;
69
70 case RTTEST_RESET:
71 for (i = 0; i < MAX_RT_TEST_MUTEXES; i++) {
72 if (td->mutexes[i] == 4) {
73 rt_mutex_unlock(&mutexes[i]);
74 td->mutexes[i] = 0;
75 }
76 }
77
78 if (!lockwakeup && td->bkl == 4) {
79 unlock_kernel();
80 td->bkl = 0;
81 }
82 return 0;
83
84 case RTTEST_RESETEVENT:
85 atomic_set(&rttest_event, 0);
86 return 0;
87
88 default:
89 if (lockwakeup)
90 return ret;
91 }
92
93 switch(td->opcode) {
94
95 case RTTEST_LOCK:
96 case RTTEST_LOCKNOWAIT:
97 id = td->opdata;
98 if (id < 0 || id >= MAX_RT_TEST_MUTEXES)
99 return ret;
100
101 td->mutexes[id] = 1;
102 td->event = atomic_add_return(1, &rttest_event);
103 rt_mutex_lock(&mutexes[id]);
104 td->event = atomic_add_return(1, &rttest_event);
105 td->mutexes[id] = 4;
106 return 0;
107
108 case RTTEST_LOCKINT:
109 case RTTEST_LOCKINTNOWAIT:
110 id = td->opdata;
111 if (id < 0 || id >= MAX_RT_TEST_MUTEXES)
112 return ret;
113
114 td->mutexes[id] = 1;
115 td->event = atomic_add_return(1, &rttest_event);
116 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
117 td->event = atomic_add_return(1, &rttest_event);
118 td->mutexes[id] = ret ? 0 : 4;
119 return ret ? -EINTR : 0;
120
121 case RTTEST_UNLOCK:
122 id = td->opdata;
123 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
124 return ret;
125
126 td->event = atomic_add_return(1, &rttest_event);
127 rt_mutex_unlock(&mutexes[id]);
128 td->event = atomic_add_return(1, &rttest_event);
129 td->mutexes[id] = 0;
130 return 0;
131
132 case RTTEST_LOCKBKL:
133 if (td->bkl)
134 return 0;
135 td->bkl = 1;
136 lock_kernel();
137 td->bkl = 4;
138 return 0;
139
140 case RTTEST_UNLOCKBKL:
141 if (td->bkl != 4)
142 break;
143 unlock_kernel();
144 td->bkl = 0;
145 return 0;
146
147 default:
148 break;
149 }
150 return ret;
151}
152
153/*
154 * Schedule replacement for rtsem_down(). Only called for threads with
155 * PF_MUTEX_TESTER set.
156 *
157 * This allows us to have finegrained control over the event flow.
158 *
159 */
160void schedule_rt_mutex_test(struct rt_mutex *mutex)
161{
162 int tid, op, dat;
163 struct test_thread_data *td;
164
165 /* We have to lookup the task */
166 for (tid = 0; tid < MAX_RT_TEST_THREADS; tid++) {
167 if (threads[tid] == current)
168 break;
169 }
170
171 BUG_ON(tid == MAX_RT_TEST_THREADS);
172
173 td = &thread_data[tid];
174
175 op = td->opcode;
176 dat = td->opdata;
177
178 switch (op) {
179 case RTTEST_LOCK:
180 case RTTEST_LOCKINT:
181 case RTTEST_LOCKNOWAIT:
182 case RTTEST_LOCKINTNOWAIT:
183 if (mutex != &mutexes[dat])
184 break;
185
186 if (td->mutexes[dat] != 1)
187 break;
188
189 td->mutexes[dat] = 2;
190 td->event = atomic_add_return(1, &rttest_event);
191 break;
192
193 case RTTEST_LOCKBKL:
194 default:
195 break;
196 }
197
198 schedule();
199
200
201 switch (op) {
202 case RTTEST_LOCK:
203 case RTTEST_LOCKINT:
204 if (mutex != &mutexes[dat])
205 return;
206
207 if (td->mutexes[dat] != 2)
208 return;
209
210 td->mutexes[dat] = 3;
211 td->event = atomic_add_return(1, &rttest_event);
212 break;
213
214 case RTTEST_LOCKNOWAIT:
215 case RTTEST_LOCKINTNOWAIT:
216 if (mutex != &mutexes[dat])
217 return;
218
219 if (td->mutexes[dat] != 2)
220 return;
221
222 td->mutexes[dat] = 1;
223 td->event = atomic_add_return(1, &rttest_event);
224 return;
225
226 case RTTEST_LOCKBKL:
227 return;
228 default:
229 return;
230 }
231
232 td->opcode = 0;
233
234 for (;;) {
235 set_current_state(TASK_INTERRUPTIBLE);
236
237 if (td->opcode > 0) {
238 int ret;
239
240 set_current_state(TASK_RUNNING);
241 ret = handle_op(td, 1);
242 set_current_state(TASK_INTERRUPTIBLE);
243 if (td->opcode == RTTEST_LOCKCONT)
244 break;
245 td->opcode = ret;
246 }
247
248 /* Wait for the next command to be executed */
249 schedule();
250 }
251
252 /* Restore previous command and data */
253 td->opcode = op;
254 td->opdata = dat;
255}
256
257static int test_func(void *data)
258{
259 struct test_thread_data *td = data;
260 int ret;
261
262 current->flags |= PF_MUTEX_TESTER;
263 allow_signal(SIGHUP);
264
265 for(;;) {
266
267 set_current_state(TASK_INTERRUPTIBLE);
268
269 if (td->opcode > 0) {
270 set_current_state(TASK_RUNNING);
271 ret = handle_op(td, 0);
272 set_current_state(TASK_INTERRUPTIBLE);
273 td->opcode = ret;
274 }
275
276 /* Wait for the next command to be executed */
277 schedule();
278
279 if (signal_pending(current))
280 flush_signals(current);
281
282 if(kthread_should_stop())
283 break;
284 }
285 return 0;
286}
287
288/**
289 * sysfs_test_command - interface for test commands
290 * @dev: thread reference
291 * @buf: command for actual step
292 * @count: length of buffer
293 *
294 * command syntax:
295 *
296 * opcode:data
297 */
298static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf,
299 size_t count)
300{
301 struct sched_param schedpar;
302 struct test_thread_data *td;
303 char cmdbuf[32];
304 int op, dat, tid, ret;
305
306 td = container_of(dev, struct test_thread_data, sysdev);
307 tid = td->sysdev.id;
308
309 /* strings from sysfs write are not 0 terminated! */
310 if (count >= sizeof(cmdbuf))
311 return -EINVAL;
312
313 /* strip of \n: */
314 if (buf[count-1] == '\n')
315 count--;
316 if (count < 1)
317 return -EINVAL;
318
319 memcpy(cmdbuf, buf, count);
320 cmdbuf[count] = 0;
321
322 if (sscanf(cmdbuf, "%d:%d", &op, &dat) != 2)
323 return -EINVAL;
324
325 switch (op) {
326 case RTTEST_SCHEDOT:
327 schedpar.sched_priority = 0;
328 ret = sched_setscheduler(threads[tid], SCHED_NORMAL, &schedpar);
329 if (ret)
330 return ret;
331 set_user_nice(current, 0);
332 break;
333
334 case RTTEST_SCHEDRT:
335 schedpar.sched_priority = dat;
336 ret = sched_setscheduler(threads[tid], SCHED_FIFO, &schedpar);
337 if (ret)
338 return ret;
339 break;
340
341 case RTTEST_SIGNAL:
342 send_sig(SIGHUP, threads[tid], 0);
343 break;
344
345 default:
346 if (td->opcode > 0)
347 return -EBUSY;
348 td->opdata = dat;
349 td->opcode = op;
350 wake_up_process(threads[tid]);
351 }
352
353 return count;
354}
355
356/**
357 * sysfs_test_status - sysfs interface for rt tester
358 * @dev: thread to query
359 * @buf: char buffer to be filled with thread status info
360 */
361static ssize_t sysfs_test_status(struct sys_device *dev, char *buf)
362{
363 struct test_thread_data *td;
364 char *curr = buf;
365 task_t *tsk;
366 int i;
367
368 td = container_of(dev, struct test_thread_data, sysdev);
369 tsk = threads[td->sysdev.id];
370
371 spin_lock(&rttest_lock);
372
373 curr += sprintf(curr,
374 "O: %4d, E:%8d, S: 0x%08lx, P: %4d, N: %4d, B: %p, K: %d, M:",
375 td->opcode, td->event, tsk->state,
376 (MAX_RT_PRIO - 1) - tsk->prio,
377 (MAX_RT_PRIO - 1) - tsk->normal_prio,
378 tsk->pi_blocked_on, td->bkl);
379
380 for (i = MAX_RT_TEST_MUTEXES - 1; i >=0 ; i--)
381 curr += sprintf(curr, "%d", td->mutexes[i]);
382
383 spin_unlock(&rttest_lock);
384
385 curr += sprintf(curr, ", T: %p, R: %p\n", tsk,
386 mutexes[td->sysdev.id].owner);
387
388 return curr - buf;
389}
390
391static SYSDEV_ATTR(status, 0600, sysfs_test_status, NULL);
392static SYSDEV_ATTR(command, 0600, NULL, sysfs_test_command);
393
394static struct sysdev_class rttest_sysclass = {
395 set_kset_name("rttest"),
396};
397
398static int init_test_thread(int id)
399{
400 thread_data[id].sysdev.cls = &rttest_sysclass;
401 thread_data[id].sysdev.id = id;
402
403 threads[id] = kthread_run(test_func, &thread_data[id], "rt-test-%d", id);
404 if (IS_ERR(threads[id]))
405 return PTR_ERR(threads[id]);
406
407 return sysdev_register(&thread_data[id].sysdev);
408}
409
410static int init_rttest(void)
411{
412 int ret, i;
413
414 spin_lock_init(&rttest_lock);
415
416 for (i = 0; i < MAX_RT_TEST_MUTEXES; i++)
417 rt_mutex_init(&mutexes[i]);
418
419 ret = sysdev_class_register(&rttest_sysclass);
420 if (ret)
421 return ret;
422
423 for (i = 0; i < MAX_RT_TEST_THREADS; i++) {
424 ret = init_test_thread(i);
425 if (ret)
426 break;
427 ret = sysdev_create_file(&thread_data[i].sysdev, &attr_status);
428 if (ret)
429 break;
430 ret = sysdev_create_file(&thread_data[i].sysdev, &attr_command);
431 if (ret)
432 break;
433 }
434
435 printk("Initializing RT-Tester: %s\n", ret ? "Failed" : "OK" );
436
437 return ret;
438}
439
440device_initcall(init_rttest);
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
new file mode 100644
index 000000000000..45d61016da57
--- /dev/null
+++ b/kernel/rtmutex.c
@@ -0,0 +1,990 @@
1/*
2 * RT-Mutexes: simple blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner.
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2005-2006 Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 * Copyright (C) 2005 Kihon Technologies Inc., Steven Rostedt
9 * Copyright (C) 2006 Esben Nielsen
10 */
11#include <linux/spinlock.h>
12#include <linux/module.h>
13#include <linux/sched.h>
14#include <linux/timer.h>
15
16#include "rtmutex_common.h"
17
18#ifdef CONFIG_DEBUG_RT_MUTEXES
19# include "rtmutex-debug.h"
20#else
21# include "rtmutex.h"
22#endif
23
24/*
25 * lock->owner state tracking:
26 *
27 * lock->owner holds the task_struct pointer of the owner. Bit 0 and 1
28 * are used to keep track of the "owner is pending" and "lock has
29 * waiters" state.
30 *
31 * owner bit1 bit0
32 * NULL 0 0 lock is free (fast acquire possible)
33 * NULL 0 1 invalid state
34 * NULL 1 0 Transitional State*
35 * NULL 1 1 invalid state
36 * taskpointer 0 0 lock is held (fast release possible)
37 * taskpointer 0 1 task is pending owner
38 * taskpointer 1 0 lock is held and has waiters
39 * taskpointer 1 1 task is pending owner and lock has more waiters
40 *
41 * Pending ownership is assigned to the top (highest priority)
42 * waiter of the lock, when the lock is released. The thread is woken
43 * up and can now take the lock. Until the lock is taken (bit 0
44 * cleared) a competing higher priority thread can steal the lock
45 * which puts the woken up thread back on the waiters list.
46 *
47 * The fast atomic compare exchange based acquire and release is only
48 * possible when bit 0 and 1 of lock->owner are 0.
49 *
50 * (*) There's a small time where the owner can be NULL and the
51 * "lock has waiters" bit is set. This can happen when grabbing the lock.
52 * To prevent a cmpxchg of the owner releasing the lock, we need to set this
53 * bit before looking at the lock, hence the reason this is a transitional
54 * state.
55 */
56
57static void
58rt_mutex_set_owner(struct rt_mutex *lock, struct task_struct *owner,
59 unsigned long mask)
60{
61 unsigned long val = (unsigned long)owner | mask;
62
63 if (rt_mutex_has_waiters(lock))
64 val |= RT_MUTEX_HAS_WAITERS;
65
66 lock->owner = (struct task_struct *)val;
67}
68
69static inline void clear_rt_mutex_waiters(struct rt_mutex *lock)
70{
71 lock->owner = (struct task_struct *)
72 ((unsigned long)lock->owner & ~RT_MUTEX_HAS_WAITERS);
73}
74
75static void fixup_rt_mutex_waiters(struct rt_mutex *lock)
76{
77 if (!rt_mutex_has_waiters(lock))
78 clear_rt_mutex_waiters(lock);
79}
80
81/*
82 * We can speed up the acquire/release, if the architecture
83 * supports cmpxchg and if there's no debugging state to be set up
84 */
85#if defined(__HAVE_ARCH_CMPXCHG) && !defined(CONFIG_DEBUG_RT_MUTEXES)
86# define rt_mutex_cmpxchg(l,c,n) (cmpxchg(&l->owner, c, n) == c)
87static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
88{
89 unsigned long owner, *p = (unsigned long *) &lock->owner;
90
91 do {
92 owner = *p;
93 } while (cmpxchg(p, owner, owner | RT_MUTEX_HAS_WAITERS) != owner);
94}
95#else
96# define rt_mutex_cmpxchg(l,c,n) (0)
97static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
98{
99 lock->owner = (struct task_struct *)
100 ((unsigned long)lock->owner | RT_MUTEX_HAS_WAITERS);
101}
102#endif
103
104/*
105 * Calculate task priority from the waiter list priority
106 *
107 * Return task->normal_prio when the waiter list is empty or when
108 * the waiter is not allowed to do priority boosting
109 */
110int rt_mutex_getprio(struct task_struct *task)
111{
112 if (likely(!task_has_pi_waiters(task)))
113 return task->normal_prio;
114
115 return min(task_top_pi_waiter(task)->pi_list_entry.prio,
116 task->normal_prio);
117}
118
119/*
120 * Adjust the priority of a task, after its pi_waiters got modified.
121 *
122 * This can be both boosting and unboosting. task->pi_lock must be held.
123 */
124static void __rt_mutex_adjust_prio(struct task_struct *task)
125{
126 int prio = rt_mutex_getprio(task);
127
128 if (task->prio != prio)
129 rt_mutex_setprio(task, prio);
130}
131
132/*
133 * Adjust task priority (undo boosting). Called from the exit path of
134 * rt_mutex_slowunlock() and rt_mutex_slowlock().
135 *
136 * (Note: We do this outside of the protection of lock->wait_lock to
137 * allow the lock to be taken while or before we readjust the priority
138 * of task. We do not use the spin_xx_mutex() variants here as we are
139 * outside of the debug path.)
140 */
141static void rt_mutex_adjust_prio(struct task_struct *task)
142{
143 unsigned long flags;
144
145 spin_lock_irqsave(&task->pi_lock, flags);
146 __rt_mutex_adjust_prio(task);
147 spin_unlock_irqrestore(&task->pi_lock, flags);
148}
149
150/*
151 * Max number of times we'll walk the boosting chain:
152 */
153int max_lock_depth = 1024;
154
155/*
156 * Adjust the priority chain. Also used for deadlock detection.
157 * Decreases task's usage by one - may thus free the task.
158 * Returns 0 or -EDEADLK.
159 */
160static int rt_mutex_adjust_prio_chain(task_t *task,
161 int deadlock_detect,
162 struct rt_mutex *orig_lock,
163 struct rt_mutex_waiter *orig_waiter,
164 struct task_struct *top_task
165 __IP_DECL__)
166{
167 struct rt_mutex *lock;
168 struct rt_mutex_waiter *waiter, *top_waiter = orig_waiter;
169 int detect_deadlock, ret = 0, depth = 0;
170 unsigned long flags;
171
172 detect_deadlock = debug_rt_mutex_detect_deadlock(orig_waiter,
173 deadlock_detect);
174
175 /*
176 * The (de)boosting is a step by step approach with a lot of
177 * pitfalls. We want this to be preemptible and we want hold a
178 * maximum of two locks per step. So we have to check
179 * carefully whether things change under us.
180 */
181 again:
182 if (++depth > max_lock_depth) {
183 static int prev_max;
184
185 /*
186 * Print this only once. If the admin changes the limit,
187 * print a new message when reaching the limit again.
188 */
189 if (prev_max != max_lock_depth) {
190 prev_max = max_lock_depth;
191 printk(KERN_WARNING "Maximum lock depth %d reached "
192 "task: %s (%d)\n", max_lock_depth,
193 top_task->comm, top_task->pid);
194 }
195 put_task_struct(task);
196
197 return deadlock_detect ? -EDEADLK : 0;
198 }
199 retry:
200 /*
201 * Task can not go away as we did a get_task() before !
202 */
203 spin_lock_irqsave(&task->pi_lock, flags);
204
205 waiter = task->pi_blocked_on;
206 /*
207 * Check whether the end of the boosting chain has been
208 * reached or the state of the chain has changed while we
209 * dropped the locks.
210 */
211 if (!waiter || !waiter->task)
212 goto out_unlock_pi;
213
214 if (top_waiter && (!task_has_pi_waiters(task) ||
215 top_waiter != task_top_pi_waiter(task)))
216 goto out_unlock_pi;
217
218 /*
219 * When deadlock detection is off then we check, if further
220 * priority adjustment is necessary.
221 */
222 if (!detect_deadlock && waiter->list_entry.prio == task->prio)
223 goto out_unlock_pi;
224
225 lock = waiter->lock;
226 if (!spin_trylock(&lock->wait_lock)) {
227 spin_unlock_irqrestore(&task->pi_lock, flags);
228 cpu_relax();
229 goto retry;
230 }
231
232 /* Deadlock detection */
233 if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
234 debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock);
235 spin_unlock(&lock->wait_lock);
236 ret = deadlock_detect ? -EDEADLK : 0;
237 goto out_unlock_pi;
238 }
239
240 top_waiter = rt_mutex_top_waiter(lock);
241
242 /* Requeue the waiter */
243 plist_del(&waiter->list_entry, &lock->wait_list);
244 waiter->list_entry.prio = task->prio;
245 plist_add(&waiter->list_entry, &lock->wait_list);
246
247 /* Release the task */
248 spin_unlock_irqrestore(&task->pi_lock, flags);
249 put_task_struct(task);
250
251 /* Grab the next task */
252 task = rt_mutex_owner(lock);
253 spin_lock_irqsave(&task->pi_lock, flags);
254
255 if (waiter == rt_mutex_top_waiter(lock)) {
256 /* Boost the owner */
257 plist_del(&top_waiter->pi_list_entry, &task->pi_waiters);
258 waiter->pi_list_entry.prio = waiter->list_entry.prio;
259 plist_add(&waiter->pi_list_entry, &task->pi_waiters);
260 __rt_mutex_adjust_prio(task);
261
262 } else if (top_waiter == waiter) {
263 /* Deboost the owner */
264 plist_del(&waiter->pi_list_entry, &task->pi_waiters);
265 waiter = rt_mutex_top_waiter(lock);
266 waiter->pi_list_entry.prio = waiter->list_entry.prio;
267 plist_add(&waiter->pi_list_entry, &task->pi_waiters);
268 __rt_mutex_adjust_prio(task);
269 }
270
271 get_task_struct(task);
272 spin_unlock_irqrestore(&task->pi_lock, flags);
273
274 top_waiter = rt_mutex_top_waiter(lock);
275 spin_unlock(&lock->wait_lock);
276
277 if (!detect_deadlock && waiter != top_waiter)
278 goto out_put_task;
279
280 goto again;
281
282 out_unlock_pi:
283 spin_unlock_irqrestore(&task->pi_lock, flags);
284 out_put_task:
285 put_task_struct(task);
286 return ret;
287}
288
289/*
290 * Optimization: check if we can steal the lock from the
291 * assigned pending owner [which might not have taken the
292 * lock yet]:
293 */
294static inline int try_to_steal_lock(struct rt_mutex *lock)
295{
296 struct task_struct *pendowner = rt_mutex_owner(lock);
297 struct rt_mutex_waiter *next;
298 unsigned long flags;
299
300 if (!rt_mutex_owner_pending(lock))
301 return 0;
302
303 if (pendowner == current)
304 return 1;
305
306 spin_lock_irqsave(&pendowner->pi_lock, flags);
307 if (current->prio >= pendowner->prio) {
308 spin_unlock_irqrestore(&pendowner->pi_lock, flags);
309 return 0;
310 }
311
312 /*
313 * Check if a waiter is enqueued on the pending owners
314 * pi_waiters list. Remove it and readjust pending owners
315 * priority.
316 */
317 if (likely(!rt_mutex_has_waiters(lock))) {
318 spin_unlock_irqrestore(&pendowner->pi_lock, flags);
319 return 1;
320 }
321
322 /* No chain handling, pending owner is not blocked on anything: */
323 next = rt_mutex_top_waiter(lock);
324 plist_del(&next->pi_list_entry, &pendowner->pi_waiters);
325 __rt_mutex_adjust_prio(pendowner);
326 spin_unlock_irqrestore(&pendowner->pi_lock, flags);
327
328 /*
329 * We are going to steal the lock and a waiter was
330 * enqueued on the pending owners pi_waiters queue. So
331 * we have to enqueue this waiter into
332 * current->pi_waiters list. This covers the case,
333 * where current is boosted because it holds another
334 * lock and gets unboosted because the booster is
335 * interrupted, so we would delay a waiter with higher
336 * priority as current->normal_prio.
337 *
338 * Note: in the rare case of a SCHED_OTHER task changing
339 * its priority and thus stealing the lock, next->task
340 * might be current:
341 */
342 if (likely(next->task != current)) {
343 spin_lock_irqsave(&current->pi_lock, flags);
344 plist_add(&next->pi_list_entry, &current->pi_waiters);
345 __rt_mutex_adjust_prio(current);
346 spin_unlock_irqrestore(&current->pi_lock, flags);
347 }
348 return 1;
349}
350
351/*
352 * Try to take an rt-mutex
353 *
354 * This fails
355 * - when the lock has a real owner
356 * - when a different pending owner exists and has higher priority than current
357 *
358 * Must be called with lock->wait_lock held.
359 */
360static int try_to_take_rt_mutex(struct rt_mutex *lock __IP_DECL__)
361{
362 /*
363 * We have to be careful here if the atomic speedups are
364 * enabled, such that, when
365 * - no other waiter is on the lock
366 * - the lock has been released since we did the cmpxchg
367 * the lock can be released or taken while we are doing the
368 * checks and marking the lock with RT_MUTEX_HAS_WAITERS.
369 *
370 * The atomic acquire/release aware variant of
371 * mark_rt_mutex_waiters uses a cmpxchg loop. After setting
372 * the WAITERS bit, the atomic release / acquire can not
373 * happen anymore and lock->wait_lock protects us from the
374 * non-atomic case.
375 *
376 * Note, that this might set lock->owner =
377 * RT_MUTEX_HAS_WAITERS in the case the lock is not contended
378 * any more. This is fixed up when we take the ownership.
379 * This is the transitional state explained at the top of this file.
380 */
381 mark_rt_mutex_waiters(lock);
382
383 if (rt_mutex_owner(lock) && !try_to_steal_lock(lock))
384 return 0;
385
386 /* We got the lock. */
387 debug_rt_mutex_lock(lock __IP__);
388
389 rt_mutex_set_owner(lock, current, 0);
390
391 rt_mutex_deadlock_account_lock(lock, current);
392
393 return 1;
394}
395
396/*
397 * Task blocks on lock.
398 *
399 * Prepare waiter and propagate pi chain
400 *
401 * This must be called with lock->wait_lock held.
402 */
403static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
404 struct rt_mutex_waiter *waiter,
405 int detect_deadlock
406 __IP_DECL__)
407{
408 struct rt_mutex_waiter *top_waiter = waiter;
409 task_t *owner = rt_mutex_owner(lock);
410 int boost = 0, res;
411 unsigned long flags;
412
413 spin_lock_irqsave(&current->pi_lock, flags);
414 __rt_mutex_adjust_prio(current);
415 waiter->task = current;
416 waiter->lock = lock;
417 plist_node_init(&waiter->list_entry, current->prio);
418 plist_node_init(&waiter->pi_list_entry, current->prio);
419
420 /* Get the top priority waiter on the lock */
421 if (rt_mutex_has_waiters(lock))
422 top_waiter = rt_mutex_top_waiter(lock);
423 plist_add(&waiter->list_entry, &lock->wait_list);
424
425 current->pi_blocked_on = waiter;
426
427 spin_unlock_irqrestore(&current->pi_lock, flags);
428
429 if (waiter == rt_mutex_top_waiter(lock)) {
430 spin_lock_irqsave(&owner->pi_lock, flags);
431 plist_del(&top_waiter->pi_list_entry, &owner->pi_waiters);
432 plist_add(&waiter->pi_list_entry, &owner->pi_waiters);
433
434 __rt_mutex_adjust_prio(owner);
435 if (owner->pi_blocked_on) {
436 boost = 1;
437 /* gets dropped in rt_mutex_adjust_prio_chain()! */
438 get_task_struct(owner);
439 }
440 spin_unlock_irqrestore(&owner->pi_lock, flags);
441 }
442 else if (debug_rt_mutex_detect_deadlock(waiter, detect_deadlock)) {
443 spin_lock_irqsave(&owner->pi_lock, flags);
444 if (owner->pi_blocked_on) {
445 boost = 1;
446 /* gets dropped in rt_mutex_adjust_prio_chain()! */
447 get_task_struct(owner);
448 }
449 spin_unlock_irqrestore(&owner->pi_lock, flags);
450 }
451 if (!boost)
452 return 0;
453
454 spin_unlock(&lock->wait_lock);
455
456 res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter,
457 current __IP__);
458
459 spin_lock(&lock->wait_lock);
460
461 return res;
462}
463
464/*
465 * Wake up the next waiter on the lock.
466 *
467 * Remove the top waiter from the current tasks waiter list and from
468 * the lock waiter list. Set it as pending owner. Then wake it up.
469 *
470 * Called with lock->wait_lock held.
471 */
472static void wakeup_next_waiter(struct rt_mutex *lock)
473{
474 struct rt_mutex_waiter *waiter;
475 struct task_struct *pendowner;
476 unsigned long flags;
477
478 spin_lock_irqsave(&current->pi_lock, flags);
479
480 waiter = rt_mutex_top_waiter(lock);
481 plist_del(&waiter->list_entry, &lock->wait_list);
482
483 /*
484 * Remove it from current->pi_waiters. We do not adjust a
485 * possible priority boost right now. We execute wakeup in the
486 * boosted mode and go back to normal after releasing
487 * lock->wait_lock.
488 */
489 plist_del(&waiter->pi_list_entry, &current->pi_waiters);
490 pendowner = waiter->task;
491 waiter->task = NULL;
492
493 rt_mutex_set_owner(lock, pendowner, RT_MUTEX_OWNER_PENDING);
494
495 spin_unlock_irqrestore(&current->pi_lock, flags);
496
497 /*
498 * Clear the pi_blocked_on variable and enqueue a possible
499 * waiter into the pi_waiters list of the pending owner. This
500 * prevents that in case the pending owner gets unboosted a
501 * waiter with higher priority than pending-owner->normal_prio
502 * is blocked on the unboosted (pending) owner.
503 */
504 spin_lock_irqsave(&pendowner->pi_lock, flags);
505
506 WARN_ON(!pendowner->pi_blocked_on);
507 WARN_ON(pendowner->pi_blocked_on != waiter);
508 WARN_ON(pendowner->pi_blocked_on->lock != lock);
509
510 pendowner->pi_blocked_on = NULL;
511
512 if (rt_mutex_has_waiters(lock)) {
513 struct rt_mutex_waiter *next;
514
515 next = rt_mutex_top_waiter(lock);
516 plist_add(&next->pi_list_entry, &pendowner->pi_waiters);
517 }
518 spin_unlock_irqrestore(&pendowner->pi_lock, flags);
519
520 wake_up_process(pendowner);
521}
522
523/*
524 * Remove a waiter from a lock
525 *
526 * Must be called with lock->wait_lock held
527 */
528static void remove_waiter(struct rt_mutex *lock,
529 struct rt_mutex_waiter *waiter __IP_DECL__)
530{
531 int first = (waiter == rt_mutex_top_waiter(lock));
532 int boost = 0;
533 task_t *owner = rt_mutex_owner(lock);
534 unsigned long flags;
535
536 spin_lock_irqsave(&current->pi_lock, flags);
537 plist_del(&waiter->list_entry, &lock->wait_list);
538 waiter->task = NULL;
539 current->pi_blocked_on = NULL;
540 spin_unlock_irqrestore(&current->pi_lock, flags);
541
542 if (first && owner != current) {
543
544 spin_lock_irqsave(&owner->pi_lock, flags);
545
546 plist_del(&waiter->pi_list_entry, &owner->pi_waiters);
547
548 if (rt_mutex_has_waiters(lock)) {
549 struct rt_mutex_waiter *next;
550
551 next = rt_mutex_top_waiter(lock);
552 plist_add(&next->pi_list_entry, &owner->pi_waiters);
553 }
554 __rt_mutex_adjust_prio(owner);
555
556 if (owner->pi_blocked_on) {
557 boost = 1;
558 /* gets dropped in rt_mutex_adjust_prio_chain()! */
559 get_task_struct(owner);
560 }
561 spin_unlock_irqrestore(&owner->pi_lock, flags);
562 }
563
564 WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
565
566 if (!boost)
567 return;
568
569 spin_unlock(&lock->wait_lock);
570
571 rt_mutex_adjust_prio_chain(owner, 0, lock, NULL, current __IP__);
572
573 spin_lock(&lock->wait_lock);
574}
575
576/*
577 * Recheck the pi chain, in case we got a priority setting
578 *
579 * Called from sched_setscheduler
580 */
581void rt_mutex_adjust_pi(struct task_struct *task)
582{
583 struct rt_mutex_waiter *waiter;
584 unsigned long flags;
585
586 spin_lock_irqsave(&task->pi_lock, flags);
587
588 waiter = task->pi_blocked_on;
589 if (!waiter || waiter->list_entry.prio == task->prio) {
590 spin_unlock_irqrestore(&task->pi_lock, flags);
591 return;
592 }
593
594 /* gets dropped in rt_mutex_adjust_prio_chain()! */
595 get_task_struct(task);
596 spin_unlock_irqrestore(&task->pi_lock, flags);
597
598 rt_mutex_adjust_prio_chain(task, 0, NULL, NULL, task __RET_IP__);
599}
600
601/*
602 * Slow path lock function:
603 */
604static int __sched
605rt_mutex_slowlock(struct rt_mutex *lock, int state,
606 struct hrtimer_sleeper *timeout,
607 int detect_deadlock __IP_DECL__)
608{
609 struct rt_mutex_waiter waiter;
610 int ret = 0;
611
612 debug_rt_mutex_init_waiter(&waiter);
613 waiter.task = NULL;
614
615 spin_lock(&lock->wait_lock);
616
617 /* Try to acquire the lock again: */
618 if (try_to_take_rt_mutex(lock __IP__)) {
619 spin_unlock(&lock->wait_lock);
620 return 0;
621 }
622
623 set_current_state(state);
624
625 /* Setup the timer, when timeout != NULL */
626 if (unlikely(timeout))
627 hrtimer_start(&timeout->timer, timeout->timer.expires,
628 HRTIMER_ABS);
629
630 for (;;) {
631 /* Try to acquire the lock: */
632 if (try_to_take_rt_mutex(lock __IP__))
633 break;
634
635 /*
636 * TASK_INTERRUPTIBLE checks for signals and
637 * timeout. Ignored otherwise.
638 */
639 if (unlikely(state == TASK_INTERRUPTIBLE)) {
640 /* Signal pending? */
641 if (signal_pending(current))
642 ret = -EINTR;
643 if (timeout && !timeout->task)
644 ret = -ETIMEDOUT;
645 if (ret)
646 break;
647 }
648
649 /*
650 * waiter.task is NULL the first time we come here and
651 * when we have been woken up by the previous owner
652 * but the lock got stolen by a higher prio task.
653 */
654 if (!waiter.task) {
655 ret = task_blocks_on_rt_mutex(lock, &waiter,
656 detect_deadlock __IP__);
657 /*
658 * If we got woken up by the owner then start loop
659 * all over without going into schedule to try
660 * to get the lock now:
661 */
662 if (unlikely(!waiter.task))
663 continue;
664
665 if (unlikely(ret))
666 break;
667 }
668
669 spin_unlock(&lock->wait_lock);
670
671 debug_rt_mutex_print_deadlock(&waiter);
672
673 if (waiter.task)
674 schedule_rt_mutex(lock);
675
676 spin_lock(&lock->wait_lock);
677 set_current_state(state);
678 }
679
680 set_current_state(TASK_RUNNING);
681
682 if (unlikely(waiter.task))
683 remove_waiter(lock, &waiter __IP__);
684
685 /*
686 * try_to_take_rt_mutex() sets the waiter bit
687 * unconditionally. We might have to fix that up.
688 */
689 fixup_rt_mutex_waiters(lock);
690
691 spin_unlock(&lock->wait_lock);
692
693 /* Remove pending timer: */
694 if (unlikely(timeout))
695 hrtimer_cancel(&timeout->timer);
696
697 /*
698 * Readjust priority, when we did not get the lock. We might
699 * have been the pending owner and boosted. Since we did not
700 * take the lock, the PI boost has to go.
701 */
702 if (unlikely(ret))
703 rt_mutex_adjust_prio(current);
704
705 debug_rt_mutex_free_waiter(&waiter);
706
707 return ret;
708}
709
710/*
711 * Slow path try-lock function:
712 */
713static inline int
714rt_mutex_slowtrylock(struct rt_mutex *lock __IP_DECL__)
715{
716 int ret = 0;
717
718 spin_lock(&lock->wait_lock);
719
720 if (likely(rt_mutex_owner(lock) != current)) {
721
722 ret = try_to_take_rt_mutex(lock __IP__);
723 /*
724 * try_to_take_rt_mutex() sets the lock waiters
725 * bit unconditionally. Clean this up.
726 */
727 fixup_rt_mutex_waiters(lock);
728 }
729
730 spin_unlock(&lock->wait_lock);
731
732 return ret;
733}
734
735/*
736 * Slow path to release a rt-mutex:
737 */
738static void __sched
739rt_mutex_slowunlock(struct rt_mutex *lock)
740{
741 spin_lock(&lock->wait_lock);
742
743 debug_rt_mutex_unlock(lock);
744
745 rt_mutex_deadlock_account_unlock(current);
746
747 if (!rt_mutex_has_waiters(lock)) {
748 lock->owner = NULL;
749 spin_unlock(&lock->wait_lock);
750 return;
751 }
752
753 wakeup_next_waiter(lock);
754
755 spin_unlock(&lock->wait_lock);
756
757 /* Undo pi boosting if necessary: */
758 rt_mutex_adjust_prio(current);
759}
760
761/*
762 * debug aware fast / slowpath lock,trylock,unlock
763 *
764 * The atomic acquire/release ops are compiled away, when either the
765 * architecture does not support cmpxchg or when debugging is enabled.
766 */
767static inline int
768rt_mutex_fastlock(struct rt_mutex *lock, int state,
769 int detect_deadlock,
770 int (*slowfn)(struct rt_mutex *lock, int state,
771 struct hrtimer_sleeper *timeout,
772 int detect_deadlock __IP_DECL__))
773{
774 if (!detect_deadlock && likely(rt_mutex_cmpxchg(lock, NULL, current))) {
775 rt_mutex_deadlock_account_lock(lock, current);
776 return 0;
777 } else
778 return slowfn(lock, state, NULL, detect_deadlock __RET_IP__);
779}
780
781static inline int
782rt_mutex_timed_fastlock(struct rt_mutex *lock, int state,
783 struct hrtimer_sleeper *timeout, int detect_deadlock,
784 int (*slowfn)(struct rt_mutex *lock, int state,
785 struct hrtimer_sleeper *timeout,
786 int detect_deadlock __IP_DECL__))
787{
788 if (!detect_deadlock && likely(rt_mutex_cmpxchg(lock, NULL, current))) {
789 rt_mutex_deadlock_account_lock(lock, current);
790 return 0;
791 } else
792 return slowfn(lock, state, timeout, detect_deadlock __RET_IP__);
793}
794
795static inline int
796rt_mutex_fasttrylock(struct rt_mutex *lock,
797 int (*slowfn)(struct rt_mutex *lock __IP_DECL__))
798{
799 if (likely(rt_mutex_cmpxchg(lock, NULL, current))) {
800 rt_mutex_deadlock_account_lock(lock, current);
801 return 1;
802 }
803 return slowfn(lock __RET_IP__);
804}
805
806static inline void
807rt_mutex_fastunlock(struct rt_mutex *lock,
808 void (*slowfn)(struct rt_mutex *lock))
809{
810 if (likely(rt_mutex_cmpxchg(lock, current, NULL)))
811 rt_mutex_deadlock_account_unlock(current);
812 else
813 slowfn(lock);
814}
815
816/**
817 * rt_mutex_lock - lock a rt_mutex
818 *
819 * @lock: the rt_mutex to be locked
820 */
821void __sched rt_mutex_lock(struct rt_mutex *lock)
822{
823 might_sleep();
824
825 rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, 0, rt_mutex_slowlock);
826}
827EXPORT_SYMBOL_GPL(rt_mutex_lock);
828
829/**
830 * rt_mutex_lock_interruptible - lock a rt_mutex interruptible
831 *
832 * @lock: the rt_mutex to be locked
833 * @detect_deadlock: deadlock detection on/off
834 *
835 * Returns:
836 * 0 on success
837 * -EINTR when interrupted by a signal
838 * -EDEADLK when the lock would deadlock (when deadlock detection is on)
839 */
840int __sched rt_mutex_lock_interruptible(struct rt_mutex *lock,
841 int detect_deadlock)
842{
843 might_sleep();
844
845 return rt_mutex_fastlock(lock, TASK_INTERRUPTIBLE,
846 detect_deadlock, rt_mutex_slowlock);
847}
848EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible);
849
850/**
851 * rt_mutex_lock_interruptible_ktime - lock a rt_mutex interruptible
852 * the timeout structure is provided
853 * by the caller
854 *
855 * @lock: the rt_mutex to be locked
856 * @timeout: timeout structure or NULL (no timeout)
857 * @detect_deadlock: deadlock detection on/off
858 *
859 * Returns:
860 * 0 on success
861 * -EINTR when interrupted by a signal
862 * -ETIMEOUT when the timeout expired
863 * -EDEADLK when the lock would deadlock (when deadlock detection is on)
864 */
865int
866rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout,
867 int detect_deadlock)
868{
869 might_sleep();
870
871 return rt_mutex_timed_fastlock(lock, TASK_INTERRUPTIBLE, timeout,
872 detect_deadlock, rt_mutex_slowlock);
873}
874EXPORT_SYMBOL_GPL(rt_mutex_timed_lock);
875
876/**
877 * rt_mutex_trylock - try to lock a rt_mutex
878 *
879 * @lock: the rt_mutex to be locked
880 *
881 * Returns 1 on success and 0 on contention
882 */
883int __sched rt_mutex_trylock(struct rt_mutex *lock)
884{
885 return rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);
886}
887EXPORT_SYMBOL_GPL(rt_mutex_trylock);
888
889/**
890 * rt_mutex_unlock - unlock a rt_mutex
891 *
892 * @lock: the rt_mutex to be unlocked
893 */
894void __sched rt_mutex_unlock(struct rt_mutex *lock)
895{
896 rt_mutex_fastunlock(lock, rt_mutex_slowunlock);
897}
898EXPORT_SYMBOL_GPL(rt_mutex_unlock);
899
900/***
901 * rt_mutex_destroy - mark a mutex unusable
902 * @lock: the mutex to be destroyed
903 *
904 * This function marks the mutex uninitialized, and any subsequent
905 * use of the mutex is forbidden. The mutex must not be locked when
906 * this function is called.
907 */
908void rt_mutex_destroy(struct rt_mutex *lock)
909{
910 WARN_ON(rt_mutex_is_locked(lock));
911#ifdef CONFIG_DEBUG_RT_MUTEXES
912 lock->magic = NULL;
913#endif
914}
915
916EXPORT_SYMBOL_GPL(rt_mutex_destroy);
917
918/**
919 * __rt_mutex_init - initialize the rt lock
920 *
921 * @lock: the rt lock to be initialized
922 *
923 * Initialize the rt lock to unlocked state.
924 *
925 * Initializing of a locked rt lock is not allowed
926 */
927void __rt_mutex_init(struct rt_mutex *lock, const char *name)
928{
929 lock->owner = NULL;
930 spin_lock_init(&lock->wait_lock);
931 plist_head_init(&lock->wait_list, &lock->wait_lock);
932
933 debug_rt_mutex_init(lock, name);
934}
935EXPORT_SYMBOL_GPL(__rt_mutex_init);
936
937/**
938 * rt_mutex_init_proxy_locked - initialize and lock a rt_mutex on behalf of a
939 * proxy owner
940 *
941 * @lock: the rt_mutex to be locked
942 * @proxy_owner:the task to set as owner
943 *
944 * No locking. Caller has to do serializing itself
945 * Special API call for PI-futex support
946 */
947void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
948 struct task_struct *proxy_owner)
949{
950 __rt_mutex_init(lock, NULL);
951 debug_rt_mutex_proxy_lock(lock, proxy_owner __RET_IP__);
952 rt_mutex_set_owner(lock, proxy_owner, 0);
953 rt_mutex_deadlock_account_lock(lock, proxy_owner);
954}
955
956/**
957 * rt_mutex_proxy_unlock - release a lock on behalf of owner
958 *
959 * @lock: the rt_mutex to be locked
960 *
961 * No locking. Caller has to do serializing itself
962 * Special API call for PI-futex support
963 */
964void rt_mutex_proxy_unlock(struct rt_mutex *lock,
965 struct task_struct *proxy_owner)
966{
967 debug_rt_mutex_proxy_unlock(lock);
968 rt_mutex_set_owner(lock, NULL, 0);
969 rt_mutex_deadlock_account_unlock(proxy_owner);
970}
971
972/**
973 * rt_mutex_next_owner - return the next owner of the lock
974 *
975 * @lock: the rt lock query
976 *
977 * Returns the next owner of the lock or NULL
978 *
979 * Caller has to serialize against other accessors to the lock
980 * itself.
981 *
982 * Special API call for PI-futex support
983 */
984struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock)
985{
986 if (!rt_mutex_has_waiters(lock))
987 return NULL;
988
989 return rt_mutex_top_waiter(lock)->task;
990}
diff --git a/kernel/rtmutex.h b/kernel/rtmutex.h
new file mode 100644
index 000000000000..1e0fca13ff72
--- /dev/null
+++ b/kernel/rtmutex.h
@@ -0,0 +1,29 @@
1/*
2 * RT-Mutexes: blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner:
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 *
9 * This file contains macros used solely by rtmutex.c.
10 * Non-debug version.
11 */
12
13#define __IP_DECL__
14#define __IP__
15#define __RET_IP__
16#define rt_mutex_deadlock_check(l) (0)
17#define rt_mutex_deadlock_account_lock(m, t) do { } while (0)
18#define rt_mutex_deadlock_account_unlock(l) do { } while (0)
19#define debug_rt_mutex_init_waiter(w) do { } while (0)
20#define debug_rt_mutex_free_waiter(w) do { } while (0)
21#define debug_rt_mutex_lock(l) do { } while (0)
22#define debug_rt_mutex_proxy_lock(l,p) do { } while (0)
23#define debug_rt_mutex_proxy_unlock(l) do { } while (0)
24#define debug_rt_mutex_unlock(l) do { } while (0)
25#define debug_rt_mutex_init(m, n) do { } while (0)
26#define debug_rt_mutex_deadlock(d, a ,l) do { } while (0)
27#define debug_rt_mutex_print_deadlock(w) do { } while (0)
28#define debug_rt_mutex_detect_deadlock(w,d) (d)
29#define debug_rt_mutex_reset_waiter(w) do { } while (0)
diff --git a/kernel/rtmutex_common.h b/kernel/rtmutex_common.h
new file mode 100644
index 000000000000..9c75856e791e
--- /dev/null
+++ b/kernel/rtmutex_common.h
@@ -0,0 +1,123 @@
1/*
2 * RT Mutexes: blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner:
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 *
9 * This file contains the private data structure and API definitions.
10 */
11
12#ifndef __KERNEL_RTMUTEX_COMMON_H
13#define __KERNEL_RTMUTEX_COMMON_H
14
15#include <linux/rtmutex.h>
16
17/*
18 * The rtmutex in kernel tester is independent of rtmutex debugging. We
19 * call schedule_rt_mutex_test() instead of schedule() for the tasks which
20 * belong to the tester. That way we can delay the wakeup path of those
21 * threads to provoke lock stealing and testing of complex boosting scenarios.
22 */
23#ifdef CONFIG_RT_MUTEX_TESTER
24
25extern void schedule_rt_mutex_test(struct rt_mutex *lock);
26
27#define schedule_rt_mutex(_lock) \
28 do { \
29 if (!(current->flags & PF_MUTEX_TESTER)) \
30 schedule(); \
31 else \
32 schedule_rt_mutex_test(_lock); \
33 } while (0)
34
35#else
36# define schedule_rt_mutex(_lock) schedule()
37#endif
38
39/*
40 * This is the control structure for tasks blocked on a rt_mutex,
41 * which is allocated on the kernel stack on of the blocked task.
42 *
43 * @list_entry: pi node to enqueue into the mutex waiters list
44 * @pi_list_entry: pi node to enqueue into the mutex owner waiters list
45 * @task: task reference to the blocked task
46 */
47struct rt_mutex_waiter {
48 struct plist_node list_entry;
49 struct plist_node pi_list_entry;
50 struct task_struct *task;
51 struct rt_mutex *lock;
52#ifdef CONFIG_DEBUG_RT_MUTEXES
53 unsigned long ip;
54 pid_t deadlock_task_pid;
55 struct rt_mutex *deadlock_lock;
56#endif
57};
58
59/*
60 * Various helpers to access the waiters-plist:
61 */
62static inline int rt_mutex_has_waiters(struct rt_mutex *lock)
63{
64 return !plist_head_empty(&lock->wait_list);
65}
66
67static inline struct rt_mutex_waiter *
68rt_mutex_top_waiter(struct rt_mutex *lock)
69{
70 struct rt_mutex_waiter *w;
71
72 w = plist_first_entry(&lock->wait_list, struct rt_mutex_waiter,
73 list_entry);
74 BUG_ON(w->lock != lock);
75
76 return w;
77}
78
79static inline int task_has_pi_waiters(struct task_struct *p)
80{
81 return !plist_head_empty(&p->pi_waiters);
82}
83
84static inline struct rt_mutex_waiter *
85task_top_pi_waiter(struct task_struct *p)
86{
87 return plist_first_entry(&p->pi_waiters, struct rt_mutex_waiter,
88 pi_list_entry);
89}
90
91/*
92 * lock->owner state tracking:
93 */
94#define RT_MUTEX_OWNER_PENDING 1UL
95#define RT_MUTEX_HAS_WAITERS 2UL
96#define RT_MUTEX_OWNER_MASKALL 3UL
97
98static inline struct task_struct *rt_mutex_owner(struct rt_mutex *lock)
99{
100 return (struct task_struct *)
101 ((unsigned long)lock->owner & ~RT_MUTEX_OWNER_MASKALL);
102}
103
104static inline struct task_struct *rt_mutex_real_owner(struct rt_mutex *lock)
105{
106 return (struct task_struct *)
107 ((unsigned long)lock->owner & ~RT_MUTEX_HAS_WAITERS);
108}
109
110static inline unsigned long rt_mutex_owner_pending(struct rt_mutex *lock)
111{
112 return (unsigned long)lock->owner & RT_MUTEX_OWNER_PENDING;
113}
114
115/*
116 * PI-futex support (proxy locking functions, etc.):
117 */
118extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock);
119extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
120 struct task_struct *proxy_owner);
121extern void rt_mutex_proxy_unlock(struct rt_mutex *lock,
122 struct task_struct *proxy_owner);
123#endif
diff --git a/kernel/sched.c b/kernel/sched.c
index a856040c200a..2629c1711fd6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -168,15 +168,21 @@
168 */ 168 */
169 169
170#define SCALE_PRIO(x, prio) \ 170#define SCALE_PRIO(x, prio) \
171 max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO/2), MIN_TIMESLICE) 171 max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO / 2), MIN_TIMESLICE)
172 172
173static unsigned int task_timeslice(task_t *p) 173static unsigned int static_prio_timeslice(int static_prio)
174{ 174{
175 if (p->static_prio < NICE_TO_PRIO(0)) 175 if (static_prio < NICE_TO_PRIO(0))
176 return SCALE_PRIO(DEF_TIMESLICE*4, p->static_prio); 176 return SCALE_PRIO(DEF_TIMESLICE * 4, static_prio);
177 else 177 else
178 return SCALE_PRIO(DEF_TIMESLICE, p->static_prio); 178 return SCALE_PRIO(DEF_TIMESLICE, static_prio);
179} 179}
180
181static inline unsigned int task_timeslice(task_t *p)
182{
183 return static_prio_timeslice(p->static_prio);
184}
185
180#define task_hot(p, now, sd) ((long long) ((now) - (p)->last_ran) \ 186#define task_hot(p, now, sd) ((long long) ((now) - (p)->last_ran) \
181 < (long long) (sd)->cache_hot_time) 187 < (long long) (sd)->cache_hot_time)
182 188
@@ -184,13 +190,11 @@ static unsigned int task_timeslice(task_t *p)
184 * These are the runqueue data structures: 190 * These are the runqueue data structures:
185 */ 191 */
186 192
187#define BITMAP_SIZE ((((MAX_PRIO+1+7)/8)+sizeof(long)-1)/sizeof(long))
188
189typedef struct runqueue runqueue_t; 193typedef struct runqueue runqueue_t;
190 194
191struct prio_array { 195struct prio_array {
192 unsigned int nr_active; 196 unsigned int nr_active;
193 unsigned long bitmap[BITMAP_SIZE]; 197 DECLARE_BITMAP(bitmap, MAX_PRIO+1); /* include 1 bit for delimiter */
194 struct list_head queue[MAX_PRIO]; 198 struct list_head queue[MAX_PRIO];
195}; 199};
196 200
@@ -209,6 +213,7 @@ struct runqueue {
209 * remote CPUs use both these fields when doing load calculation. 213 * remote CPUs use both these fields when doing load calculation.
210 */ 214 */
211 unsigned long nr_running; 215 unsigned long nr_running;
216 unsigned long raw_weighted_load;
212#ifdef CONFIG_SMP 217#ifdef CONFIG_SMP
213 unsigned long cpu_load[3]; 218 unsigned long cpu_load[3];
214#endif 219#endif
@@ -239,7 +244,6 @@ struct runqueue {
239 244
240 task_t *migration_thread; 245 task_t *migration_thread;
241 struct list_head migration_queue; 246 struct list_head migration_queue;
242 int cpu;
243#endif 247#endif
244 248
245#ifdef CONFIG_SCHEDSTATS 249#ifdef CONFIG_SCHEDSTATS
@@ -351,11 +355,30 @@ static inline void finish_lock_switch(runqueue_t *rq, task_t *prev)
351#endif /* __ARCH_WANT_UNLOCKED_CTXSW */ 355#endif /* __ARCH_WANT_UNLOCKED_CTXSW */
352 356
353/* 357/*
358 * __task_rq_lock - lock the runqueue a given task resides on.
359 * Must be called interrupts disabled.
360 */
361static inline runqueue_t *__task_rq_lock(task_t *p)
362 __acquires(rq->lock)
363{
364 struct runqueue *rq;
365
366repeat_lock_task:
367 rq = task_rq(p);
368 spin_lock(&rq->lock);
369 if (unlikely(rq != task_rq(p))) {
370 spin_unlock(&rq->lock);
371 goto repeat_lock_task;
372 }
373 return rq;
374}
375
376/*
354 * task_rq_lock - lock the runqueue a given task resides on and disable 377 * task_rq_lock - lock the runqueue a given task resides on and disable
355 * interrupts. Note the ordering: we can safely lookup the task_rq without 378 * interrupts. Note the ordering: we can safely lookup the task_rq without
356 * explicitly disabling preemption. 379 * explicitly disabling preemption.
357 */ 380 */
358static inline runqueue_t *task_rq_lock(task_t *p, unsigned long *flags) 381static runqueue_t *task_rq_lock(task_t *p, unsigned long *flags)
359 __acquires(rq->lock) 382 __acquires(rq->lock)
360{ 383{
361 struct runqueue *rq; 384 struct runqueue *rq;
@@ -371,6 +394,12 @@ repeat_lock_task:
371 return rq; 394 return rq;
372} 395}
373 396
397static inline void __task_rq_unlock(runqueue_t *rq)
398 __releases(rq->lock)
399{
400 spin_unlock(&rq->lock);
401}
402
374static inline void task_rq_unlock(runqueue_t *rq, unsigned long *flags) 403static inline void task_rq_unlock(runqueue_t *rq, unsigned long *flags)
375 __releases(rq->lock) 404 __releases(rq->lock)
376{ 405{
@@ -634,7 +663,7 @@ static inline void enqueue_task_head(struct task_struct *p, prio_array_t *array)
634} 663}
635 664
636/* 665/*
637 * effective_prio - return the priority that is based on the static 666 * __normal_prio - return the priority that is based on the static
638 * priority but is modified by bonuses/penalties. 667 * priority but is modified by bonuses/penalties.
639 * 668 *
640 * We scale the actual sleep average [0 .... MAX_SLEEP_AVG] 669 * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
@@ -647,13 +676,11 @@ static inline void enqueue_task_head(struct task_struct *p, prio_array_t *array)
647 * 676 *
648 * Both properties are important to certain workloads. 677 * Both properties are important to certain workloads.
649 */ 678 */
650static int effective_prio(task_t *p) 679
680static inline int __normal_prio(task_t *p)
651{ 681{
652 int bonus, prio; 682 int bonus, prio;
653 683
654 if (rt_task(p))
655 return p->prio;
656
657 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2; 684 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
658 685
659 prio = p->static_prio - bonus; 686 prio = p->static_prio - bonus;
@@ -665,6 +692,106 @@ static int effective_prio(task_t *p)
665} 692}
666 693
667/* 694/*
695 * To aid in avoiding the subversion of "niceness" due to uneven distribution
696 * of tasks with abnormal "nice" values across CPUs the contribution that
697 * each task makes to its run queue's load is weighted according to its
698 * scheduling class and "nice" value. For SCHED_NORMAL tasks this is just a
699 * scaled version of the new time slice allocation that they receive on time
700 * slice expiry etc.
701 */
702
703/*
704 * Assume: static_prio_timeslice(NICE_TO_PRIO(0)) == DEF_TIMESLICE
705 * If static_prio_timeslice() is ever changed to break this assumption then
706 * this code will need modification
707 */
708#define TIME_SLICE_NICE_ZERO DEF_TIMESLICE
709#define LOAD_WEIGHT(lp) \
710 (((lp) * SCHED_LOAD_SCALE) / TIME_SLICE_NICE_ZERO)
711#define PRIO_TO_LOAD_WEIGHT(prio) \
712 LOAD_WEIGHT(static_prio_timeslice(prio))
713#define RTPRIO_TO_LOAD_WEIGHT(rp) \
714 (PRIO_TO_LOAD_WEIGHT(MAX_RT_PRIO) + LOAD_WEIGHT(rp))
715
716static void set_load_weight(task_t *p)
717{
718 if (has_rt_policy(p)) {
719#ifdef CONFIG_SMP
720 if (p == task_rq(p)->migration_thread)
721 /*
722 * The migration thread does the actual balancing.
723 * Giving its load any weight will skew balancing
724 * adversely.
725 */
726 p->load_weight = 0;
727 else
728#endif
729 p->load_weight = RTPRIO_TO_LOAD_WEIGHT(p->rt_priority);
730 } else
731 p->load_weight = PRIO_TO_LOAD_WEIGHT(p->static_prio);
732}
733
734static inline void inc_raw_weighted_load(runqueue_t *rq, const task_t *p)
735{
736 rq->raw_weighted_load += p->load_weight;
737}
738
739static inline void dec_raw_weighted_load(runqueue_t *rq, const task_t *p)
740{
741 rq->raw_weighted_load -= p->load_weight;
742}
743
744static inline void inc_nr_running(task_t *p, runqueue_t *rq)
745{
746 rq->nr_running++;
747 inc_raw_weighted_load(rq, p);
748}
749
750static inline void dec_nr_running(task_t *p, runqueue_t *rq)
751{
752 rq->nr_running--;
753 dec_raw_weighted_load(rq, p);
754}
755
756/*
757 * Calculate the expected normal priority: i.e. priority
758 * without taking RT-inheritance into account. Might be
759 * boosted by interactivity modifiers. Changes upon fork,
760 * setprio syscalls, and whenever the interactivity
761 * estimator recalculates.
762 */
763static inline int normal_prio(task_t *p)
764{
765 int prio;
766
767 if (has_rt_policy(p))
768 prio = MAX_RT_PRIO-1 - p->rt_priority;
769 else
770 prio = __normal_prio(p);
771 return prio;
772}
773
774/*
775 * Calculate the current priority, i.e. the priority
776 * taken into account by the scheduler. This value might
777 * be boosted by RT tasks, or might be boosted by
778 * interactivity modifiers. Will be RT if the task got
779 * RT-boosted. If not then it returns p->normal_prio.
780 */
781static int effective_prio(task_t *p)
782{
783 p->normal_prio = normal_prio(p);
784 /*
785 * If we are RT tasks or we were boosted to RT priority,
786 * keep the priority unchanged. Otherwise, update priority
787 * to the normal priority:
788 */
789 if (!rt_prio(p->prio))
790 return p->normal_prio;
791 return p->prio;
792}
793
794/*
668 * __activate_task - move a task to the runqueue. 795 * __activate_task - move a task to the runqueue.
669 */ 796 */
670static void __activate_task(task_t *p, runqueue_t *rq) 797static void __activate_task(task_t *p, runqueue_t *rq)
@@ -674,7 +801,7 @@ static void __activate_task(task_t *p, runqueue_t *rq)
674 if (batch_task(p)) 801 if (batch_task(p))
675 target = rq->expired; 802 target = rq->expired;
676 enqueue_task(p, target); 803 enqueue_task(p, target);
677 rq->nr_running++; 804 inc_nr_running(p, rq);
678} 805}
679 806
680/* 807/*
@@ -683,39 +810,45 @@ static void __activate_task(task_t *p, runqueue_t *rq)
683static inline void __activate_idle_task(task_t *p, runqueue_t *rq) 810static inline void __activate_idle_task(task_t *p, runqueue_t *rq)
684{ 811{
685 enqueue_task_head(p, rq->active); 812 enqueue_task_head(p, rq->active);
686 rq->nr_running++; 813 inc_nr_running(p, rq);
687} 814}
688 815
816/*
817 * Recalculate p->normal_prio and p->prio after having slept,
818 * updating the sleep-average too:
819 */
689static int recalc_task_prio(task_t *p, unsigned long long now) 820static int recalc_task_prio(task_t *p, unsigned long long now)
690{ 821{
691 /* Caller must always ensure 'now >= p->timestamp' */ 822 /* Caller must always ensure 'now >= p->timestamp' */
692 unsigned long long __sleep_time = now - p->timestamp; 823 unsigned long sleep_time = now - p->timestamp;
693 unsigned long sleep_time;
694 824
695 if (batch_task(p)) 825 if (batch_task(p))
696 sleep_time = 0; 826 sleep_time = 0;
697 else {
698 if (__sleep_time > NS_MAX_SLEEP_AVG)
699 sleep_time = NS_MAX_SLEEP_AVG;
700 else
701 sleep_time = (unsigned long)__sleep_time;
702 }
703 827
704 if (likely(sleep_time > 0)) { 828 if (likely(sleep_time > 0)) {
705 /* 829 /*
706 * User tasks that sleep a long time are categorised as 830 * This ceiling is set to the lowest priority that would allow
707 * idle. They will only have their sleep_avg increased to a 831 * a task to be reinserted into the active array on timeslice
708 * level that makes them just interactive priority to stay 832 * completion.
709 * active yet prevent them suddenly becoming cpu hogs and
710 * starving other processes.
711 */ 833 */
712 if (p->mm && sleep_time > INTERACTIVE_SLEEP(p)) { 834 unsigned long ceiling = INTERACTIVE_SLEEP(p);
713 unsigned long ceiling;
714 835
715 ceiling = JIFFIES_TO_NS(MAX_SLEEP_AVG - 836 if (p->mm && sleep_time > ceiling && p->sleep_avg < ceiling) {
716 DEF_TIMESLICE); 837 /*
717 if (p->sleep_avg < ceiling) 838 * Prevents user tasks from achieving best priority
718 p->sleep_avg = ceiling; 839 * with one single large enough sleep.
840 */
841 p->sleep_avg = ceiling;
842 /*
843 * Using INTERACTIVE_SLEEP() as a ceiling places a
844 * nice(0) task 1ms sleep away from promotion, and
845 * gives it 700ms to round-robin with no chance of
846 * being demoted. This is more than generous, so
847 * mark this sleep as non-interactive to prevent the
848 * on-runqueue bonus logic from intervening should
849 * this task not receive cpu immediately.
850 */
851 p->sleep_type = SLEEP_NONINTERACTIVE;
719 } else { 852 } else {
720 /* 853 /*
721 * Tasks waking from uninterruptible sleep are 854 * Tasks waking from uninterruptible sleep are
@@ -723,12 +856,12 @@ static int recalc_task_prio(task_t *p, unsigned long long now)
723 * are likely to be waiting on I/O 856 * are likely to be waiting on I/O
724 */ 857 */
725 if (p->sleep_type == SLEEP_NONINTERACTIVE && p->mm) { 858 if (p->sleep_type == SLEEP_NONINTERACTIVE && p->mm) {
726 if (p->sleep_avg >= INTERACTIVE_SLEEP(p)) 859 if (p->sleep_avg >= ceiling)
727 sleep_time = 0; 860 sleep_time = 0;
728 else if (p->sleep_avg + sleep_time >= 861 else if (p->sleep_avg + sleep_time >=
729 INTERACTIVE_SLEEP(p)) { 862 ceiling) {
730 p->sleep_avg = INTERACTIVE_SLEEP(p); 863 p->sleep_avg = ceiling;
731 sleep_time = 0; 864 sleep_time = 0;
732 } 865 }
733 } 866 }
734 867
@@ -742,9 +875,9 @@ static int recalc_task_prio(task_t *p, unsigned long long now)
742 */ 875 */
743 p->sleep_avg += sleep_time; 876 p->sleep_avg += sleep_time;
744 877
745 if (p->sleep_avg > NS_MAX_SLEEP_AVG)
746 p->sleep_avg = NS_MAX_SLEEP_AVG;
747 } 878 }
879 if (p->sleep_avg > NS_MAX_SLEEP_AVG)
880 p->sleep_avg = NS_MAX_SLEEP_AVG;
748 } 881 }
749 882
750 return effective_prio(p); 883 return effective_prio(p);
@@ -805,7 +938,7 @@ static void activate_task(task_t *p, runqueue_t *rq, int local)
805 */ 938 */
806static void deactivate_task(struct task_struct *p, runqueue_t *rq) 939static void deactivate_task(struct task_struct *p, runqueue_t *rq)
807{ 940{
808 rq->nr_running--; 941 dec_nr_running(p, rq);
809 dequeue_task(p, p->array); 942 dequeue_task(p, p->array);
810 p->array = NULL; 943 p->array = NULL;
811} 944}
@@ -860,6 +993,12 @@ inline int task_curr(const task_t *p)
860 return cpu_curr(task_cpu(p)) == p; 993 return cpu_curr(task_cpu(p)) == p;
861} 994}
862 995
996/* Used instead of source_load when we know the type == 0 */
997unsigned long weighted_cpuload(const int cpu)
998{
999 return cpu_rq(cpu)->raw_weighted_load;
1000}
1001
863#ifdef CONFIG_SMP 1002#ifdef CONFIG_SMP
864typedef struct { 1003typedef struct {
865 struct list_head list; 1004 struct list_head list;
@@ -949,7 +1088,8 @@ void kick_process(task_t *p)
949} 1088}
950 1089
951/* 1090/*
952 * Return a low guess at the load of a migration-source cpu. 1091 * Return a low guess at the load of a migration-source cpu weighted
1092 * according to the scheduling class and "nice" value.
953 * 1093 *
954 * We want to under-estimate the load of migration sources, to 1094 * We want to under-estimate the load of migration sources, to
955 * balance conservatively. 1095 * balance conservatively.
@@ -957,24 +1097,36 @@ void kick_process(task_t *p)
957static inline unsigned long source_load(int cpu, int type) 1097static inline unsigned long source_load(int cpu, int type)
958{ 1098{
959 runqueue_t *rq = cpu_rq(cpu); 1099 runqueue_t *rq = cpu_rq(cpu);
960 unsigned long load_now = rq->nr_running * SCHED_LOAD_SCALE; 1100
961 if (type == 0) 1101 if (type == 0)
962 return load_now; 1102 return rq->raw_weighted_load;
963 1103
964 return min(rq->cpu_load[type-1], load_now); 1104 return min(rq->cpu_load[type-1], rq->raw_weighted_load);
965} 1105}
966 1106
967/* 1107/*
968 * Return a high guess at the load of a migration-target cpu 1108 * Return a high guess at the load of a migration-target cpu weighted
1109 * according to the scheduling class and "nice" value.
969 */ 1110 */
970static inline unsigned long target_load(int cpu, int type) 1111static inline unsigned long target_load(int cpu, int type)
971{ 1112{
972 runqueue_t *rq = cpu_rq(cpu); 1113 runqueue_t *rq = cpu_rq(cpu);
973 unsigned long load_now = rq->nr_running * SCHED_LOAD_SCALE; 1114
974 if (type == 0) 1115 if (type == 0)
975 return load_now; 1116 return rq->raw_weighted_load;
1117
1118 return max(rq->cpu_load[type-1], rq->raw_weighted_load);
1119}
1120
1121/*
1122 * Return the average load per task on the cpu's run queue
1123 */
1124static inline unsigned long cpu_avg_load_per_task(int cpu)
1125{
1126 runqueue_t *rq = cpu_rq(cpu);
1127 unsigned long n = rq->nr_running;
976 1128
977 return max(rq->cpu_load[type-1], load_now); 1129 return n ? rq->raw_weighted_load / n : SCHED_LOAD_SCALE;
978} 1130}
979 1131
980/* 1132/*
@@ -1047,7 +1199,7 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
1047 cpus_and(tmp, group->cpumask, p->cpus_allowed); 1199 cpus_and(tmp, group->cpumask, p->cpus_allowed);
1048 1200
1049 for_each_cpu_mask(i, tmp) { 1201 for_each_cpu_mask(i, tmp) {
1050 load = source_load(i, 0); 1202 load = weighted_cpuload(i);
1051 1203
1052 if (load < min_load || (load == min_load && i == this_cpu)) { 1204 if (load < min_load || (load == min_load && i == this_cpu)) {
1053 min_load = load; 1205 min_load = load;
@@ -1074,9 +1226,15 @@ static int sched_balance_self(int cpu, int flag)
1074 struct task_struct *t = current; 1226 struct task_struct *t = current;
1075 struct sched_domain *tmp, *sd = NULL; 1227 struct sched_domain *tmp, *sd = NULL;
1076 1228
1077 for_each_domain(cpu, tmp) 1229 for_each_domain(cpu, tmp) {
1230 /*
1231 * If power savings logic is enabled for a domain, stop there.
1232 */
1233 if (tmp->flags & SD_POWERSAVINGS_BALANCE)
1234 break;
1078 if (tmp->flags & flag) 1235 if (tmp->flags & flag)
1079 sd = tmp; 1236 sd = tmp;
1237 }
1080 1238
1081 while (sd) { 1239 while (sd) {
1082 cpumask_t span; 1240 cpumask_t span;
@@ -1226,17 +1384,19 @@ static int try_to_wake_up(task_t *p, unsigned int state, int sync)
1226 1384
1227 if (this_sd->flags & SD_WAKE_AFFINE) { 1385 if (this_sd->flags & SD_WAKE_AFFINE) {
1228 unsigned long tl = this_load; 1386 unsigned long tl = this_load;
1387 unsigned long tl_per_task = cpu_avg_load_per_task(this_cpu);
1388
1229 /* 1389 /*
1230 * If sync wakeup then subtract the (maximum possible) 1390 * If sync wakeup then subtract the (maximum possible)
1231 * effect of the currently running task from the load 1391 * effect of the currently running task from the load
1232 * of the current CPU: 1392 * of the current CPU:
1233 */ 1393 */
1234 if (sync) 1394 if (sync)
1235 tl -= SCHED_LOAD_SCALE; 1395 tl -= current->load_weight;
1236 1396
1237 if ((tl <= load && 1397 if ((tl <= load &&
1238 tl + target_load(cpu, idx) <= SCHED_LOAD_SCALE) || 1398 tl + target_load(cpu, idx) <= tl_per_task) ||
1239 100*(tl + SCHED_LOAD_SCALE) <= imbalance*load) { 1399 100*(tl + p->load_weight) <= imbalance*load) {
1240 /* 1400 /*
1241 * This domain has SD_WAKE_AFFINE and 1401 * This domain has SD_WAKE_AFFINE and
1242 * p is cache cold in this domain, and 1402 * p is cache cold in this domain, and
@@ -1353,6 +1513,12 @@ void fastcall sched_fork(task_t *p, int clone_flags)
1353 * event cannot wake it up and insert it on the runqueue either. 1513 * event cannot wake it up and insert it on the runqueue either.
1354 */ 1514 */
1355 p->state = TASK_RUNNING; 1515 p->state = TASK_RUNNING;
1516
1517 /*
1518 * Make sure we do not leak PI boosting priority to the child:
1519 */
1520 p->prio = current->normal_prio;
1521
1356 INIT_LIST_HEAD(&p->run_list); 1522 INIT_LIST_HEAD(&p->run_list);
1357 p->array = NULL; 1523 p->array = NULL;
1358#ifdef CONFIG_SCHEDSTATS 1524#ifdef CONFIG_SCHEDSTATS
@@ -1432,10 +1598,11 @@ void fastcall wake_up_new_task(task_t *p, unsigned long clone_flags)
1432 __activate_task(p, rq); 1598 __activate_task(p, rq);
1433 else { 1599 else {
1434 p->prio = current->prio; 1600 p->prio = current->prio;
1601 p->normal_prio = current->normal_prio;
1435 list_add_tail(&p->run_list, &current->run_list); 1602 list_add_tail(&p->run_list, &current->run_list);
1436 p->array = current->array; 1603 p->array = current->array;
1437 p->array->nr_active++; 1604 p->array->nr_active++;
1438 rq->nr_running++; 1605 inc_nr_running(p, rq);
1439 } 1606 }
1440 set_need_resched(); 1607 set_need_resched();
1441 } else 1608 } else
@@ -1653,7 +1820,8 @@ unsigned long nr_uninterruptible(void)
1653 1820
1654unsigned long long nr_context_switches(void) 1821unsigned long long nr_context_switches(void)
1655{ 1822{
1656 unsigned long long i, sum = 0; 1823 int i;
1824 unsigned long long sum = 0;
1657 1825
1658 for_each_possible_cpu(i) 1826 for_each_possible_cpu(i)
1659 sum += cpu_rq(i)->nr_switches; 1827 sum += cpu_rq(i)->nr_switches;
@@ -1691,9 +1859,6 @@ unsigned long nr_active(void)
1691/* 1859/*
1692 * double_rq_lock - safely lock two runqueues 1860 * double_rq_lock - safely lock two runqueues
1693 * 1861 *
1694 * We must take them in cpu order to match code in
1695 * dependent_sleeper and wake_dependent_sleeper.
1696 *
1697 * Note this does not disable interrupts like task_rq_lock, 1862 * Note this does not disable interrupts like task_rq_lock,
1698 * you need to do so manually before calling. 1863 * you need to do so manually before calling.
1699 */ 1864 */
@@ -1705,7 +1870,7 @@ static void double_rq_lock(runqueue_t *rq1, runqueue_t *rq2)
1705 spin_lock(&rq1->lock); 1870 spin_lock(&rq1->lock);
1706 __acquire(rq2->lock); /* Fake it out ;) */ 1871 __acquire(rq2->lock); /* Fake it out ;) */
1707 } else { 1872 } else {
1708 if (rq1->cpu < rq2->cpu) { 1873 if (rq1 < rq2) {
1709 spin_lock(&rq1->lock); 1874 spin_lock(&rq1->lock);
1710 spin_lock(&rq2->lock); 1875 spin_lock(&rq2->lock);
1711 } else { 1876 } else {
@@ -1741,7 +1906,7 @@ static void double_lock_balance(runqueue_t *this_rq, runqueue_t *busiest)
1741 __acquires(this_rq->lock) 1906 __acquires(this_rq->lock)
1742{ 1907{
1743 if (unlikely(!spin_trylock(&busiest->lock))) { 1908 if (unlikely(!spin_trylock(&busiest->lock))) {
1744 if (busiest->cpu < this_rq->cpu) { 1909 if (busiest < this_rq) {
1745 spin_unlock(&this_rq->lock); 1910 spin_unlock(&this_rq->lock);
1746 spin_lock(&busiest->lock); 1911 spin_lock(&busiest->lock);
1747 spin_lock(&this_rq->lock); 1912 spin_lock(&this_rq->lock);
@@ -1804,9 +1969,9 @@ void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t *p,
1804 runqueue_t *this_rq, prio_array_t *this_array, int this_cpu) 1969 runqueue_t *this_rq, prio_array_t *this_array, int this_cpu)
1805{ 1970{
1806 dequeue_task(p, src_array); 1971 dequeue_task(p, src_array);
1807 src_rq->nr_running--; 1972 dec_nr_running(p, src_rq);
1808 set_task_cpu(p, this_cpu); 1973 set_task_cpu(p, this_cpu);
1809 this_rq->nr_running++; 1974 inc_nr_running(p, this_rq);
1810 enqueue_task(p, this_array); 1975 enqueue_task(p, this_array);
1811 p->timestamp = (p->timestamp - src_rq->timestamp_last_tick) 1976 p->timestamp = (p->timestamp - src_rq->timestamp_last_tick)
1812 + this_rq->timestamp_last_tick; 1977 + this_rq->timestamp_last_tick;
@@ -1853,26 +2018,42 @@ int can_migrate_task(task_t *p, runqueue_t *rq, int this_cpu,
1853 return 1; 2018 return 1;
1854} 2019}
1855 2020
2021#define rq_best_prio(rq) min((rq)->curr->prio, (rq)->best_expired_prio)
1856/* 2022/*
1857 * move_tasks tries to move up to max_nr_move tasks from busiest to this_rq, 2023 * move_tasks tries to move up to max_nr_move tasks and max_load_move weighted
1858 * as part of a balancing operation within "domain". Returns the number of 2024 * load from busiest to this_rq, as part of a balancing operation within
1859 * tasks moved. 2025 * "domain". Returns the number of tasks moved.
1860 * 2026 *
1861 * Called with both runqueues locked. 2027 * Called with both runqueues locked.
1862 */ 2028 */
1863static int move_tasks(runqueue_t *this_rq, int this_cpu, runqueue_t *busiest, 2029static int move_tasks(runqueue_t *this_rq, int this_cpu, runqueue_t *busiest,
1864 unsigned long max_nr_move, struct sched_domain *sd, 2030 unsigned long max_nr_move, unsigned long max_load_move,
1865 enum idle_type idle, int *all_pinned) 2031 struct sched_domain *sd, enum idle_type idle,
2032 int *all_pinned)
1866{ 2033{
1867 prio_array_t *array, *dst_array; 2034 prio_array_t *array, *dst_array;
1868 struct list_head *head, *curr; 2035 struct list_head *head, *curr;
1869 int idx, pulled = 0, pinned = 0; 2036 int idx, pulled = 0, pinned = 0, this_best_prio, busiest_best_prio;
2037 int busiest_best_prio_seen;
2038 int skip_for_load; /* skip the task based on weighted load issues */
2039 long rem_load_move;
1870 task_t *tmp; 2040 task_t *tmp;
1871 2041
1872 if (max_nr_move == 0) 2042 if (max_nr_move == 0 || max_load_move == 0)
1873 goto out; 2043 goto out;
1874 2044
2045 rem_load_move = max_load_move;
1875 pinned = 1; 2046 pinned = 1;
2047 this_best_prio = rq_best_prio(this_rq);
2048 busiest_best_prio = rq_best_prio(busiest);
2049 /*
2050 * Enable handling of the case where there is more than one task
2051 * with the best priority. If the current running task is one
2052 * of those with prio==busiest_best_prio we know it won't be moved
2053 * and therefore it's safe to override the skip (based on load) of
2054 * any task we find with that prio.
2055 */
2056 busiest_best_prio_seen = busiest_best_prio == busiest->curr->prio;
1876 2057
1877 /* 2058 /*
1878 * We first consider expired tasks. Those will likely not be 2059 * We first consider expired tasks. Those will likely not be
@@ -1912,7 +2093,17 @@ skip_queue:
1912 2093
1913 curr = curr->prev; 2094 curr = curr->prev;
1914 2095
1915 if (!can_migrate_task(tmp, busiest, this_cpu, sd, idle, &pinned)) { 2096 /*
2097 * To help distribute high priority tasks accross CPUs we don't
2098 * skip a task if it will be the highest priority task (i.e. smallest
2099 * prio value) on its new queue regardless of its load weight
2100 */
2101 skip_for_load = tmp->load_weight > rem_load_move;
2102 if (skip_for_load && idx < this_best_prio)
2103 skip_for_load = !busiest_best_prio_seen && idx == busiest_best_prio;
2104 if (skip_for_load ||
2105 !can_migrate_task(tmp, busiest, this_cpu, sd, idle, &pinned)) {
2106 busiest_best_prio_seen |= idx == busiest_best_prio;
1916 if (curr != head) 2107 if (curr != head)
1917 goto skip_queue; 2108 goto skip_queue;
1918 idx++; 2109 idx++;
@@ -1926,9 +2117,15 @@ skip_queue:
1926 2117
1927 pull_task(busiest, array, tmp, this_rq, dst_array, this_cpu); 2118 pull_task(busiest, array, tmp, this_rq, dst_array, this_cpu);
1928 pulled++; 2119 pulled++;
2120 rem_load_move -= tmp->load_weight;
1929 2121
1930 /* We only want to steal up to the prescribed number of tasks. */ 2122 /*
1931 if (pulled < max_nr_move) { 2123 * We only want to steal up to the prescribed number of tasks
2124 * and the prescribed amount of weighted load.
2125 */
2126 if (pulled < max_nr_move && rem_load_move > 0) {
2127 if (idx < this_best_prio)
2128 this_best_prio = idx;
1932 if (curr != head) 2129 if (curr != head)
1933 goto skip_queue; 2130 goto skip_queue;
1934 idx++; 2131 idx++;
@@ -1949,7 +2146,7 @@ out:
1949 2146
1950/* 2147/*
1951 * find_busiest_group finds and returns the busiest CPU group within the 2148 * find_busiest_group finds and returns the busiest CPU group within the
1952 * domain. It calculates and returns the number of tasks which should be 2149 * domain. It calculates and returns the amount of weighted load which should be
1953 * moved to restore balance via the imbalance parameter. 2150 * moved to restore balance via the imbalance parameter.
1954 */ 2151 */
1955static struct sched_group * 2152static struct sched_group *
@@ -1959,9 +2156,19 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
1959 struct sched_group *busiest = NULL, *this = NULL, *group = sd->groups; 2156 struct sched_group *busiest = NULL, *this = NULL, *group = sd->groups;
1960 unsigned long max_load, avg_load, total_load, this_load, total_pwr; 2157 unsigned long max_load, avg_load, total_load, this_load, total_pwr;
1961 unsigned long max_pull; 2158 unsigned long max_pull;
2159 unsigned long busiest_load_per_task, busiest_nr_running;
2160 unsigned long this_load_per_task, this_nr_running;
1962 int load_idx; 2161 int load_idx;
2162#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
2163 int power_savings_balance = 1;
2164 unsigned long leader_nr_running = 0, min_load_per_task = 0;
2165 unsigned long min_nr_running = ULONG_MAX;
2166 struct sched_group *group_min = NULL, *group_leader = NULL;
2167#endif
1963 2168
1964 max_load = this_load = total_load = total_pwr = 0; 2169 max_load = this_load = total_load = total_pwr = 0;
2170 busiest_load_per_task = busiest_nr_running = 0;
2171 this_load_per_task = this_nr_running = 0;
1965 if (idle == NOT_IDLE) 2172 if (idle == NOT_IDLE)
1966 load_idx = sd->busy_idx; 2173 load_idx = sd->busy_idx;
1967 else if (idle == NEWLY_IDLE) 2174 else if (idle == NEWLY_IDLE)
@@ -1970,16 +2177,19 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
1970 load_idx = sd->idle_idx; 2177 load_idx = sd->idle_idx;
1971 2178
1972 do { 2179 do {
1973 unsigned long load; 2180 unsigned long load, group_capacity;
1974 int local_group; 2181 int local_group;
1975 int i; 2182 int i;
2183 unsigned long sum_nr_running, sum_weighted_load;
1976 2184
1977 local_group = cpu_isset(this_cpu, group->cpumask); 2185 local_group = cpu_isset(this_cpu, group->cpumask);
1978 2186
1979 /* Tally up the load of all CPUs in the group */ 2187 /* Tally up the load of all CPUs in the group */
1980 avg_load = 0; 2188 sum_weighted_load = sum_nr_running = avg_load = 0;
1981 2189
1982 for_each_cpu_mask(i, group->cpumask) { 2190 for_each_cpu_mask(i, group->cpumask) {
2191 runqueue_t *rq = cpu_rq(i);
2192
1983 if (*sd_idle && !idle_cpu(i)) 2193 if (*sd_idle && !idle_cpu(i))
1984 *sd_idle = 0; 2194 *sd_idle = 0;
1985 2195
@@ -1990,6 +2200,8 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
1990 load = source_load(i, load_idx); 2200 load = source_load(i, load_idx);
1991 2201
1992 avg_load += load; 2202 avg_load += load;
2203 sum_nr_running += rq->nr_running;
2204 sum_weighted_load += rq->raw_weighted_load;
1993 } 2205 }
1994 2206
1995 total_load += avg_load; 2207 total_load += avg_load;
@@ -1998,17 +2210,80 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
1998 /* Adjust by relative CPU power of the group */ 2210 /* Adjust by relative CPU power of the group */
1999 avg_load = (avg_load * SCHED_LOAD_SCALE) / group->cpu_power; 2211 avg_load = (avg_load * SCHED_LOAD_SCALE) / group->cpu_power;
2000 2212
2213 group_capacity = group->cpu_power / SCHED_LOAD_SCALE;
2214
2001 if (local_group) { 2215 if (local_group) {
2002 this_load = avg_load; 2216 this_load = avg_load;
2003 this = group; 2217 this = group;
2004 } else if (avg_load > max_load) { 2218 this_nr_running = sum_nr_running;
2219 this_load_per_task = sum_weighted_load;
2220 } else if (avg_load > max_load &&
2221 sum_nr_running > group_capacity) {
2005 max_load = avg_load; 2222 max_load = avg_load;
2006 busiest = group; 2223 busiest = group;
2224 busiest_nr_running = sum_nr_running;
2225 busiest_load_per_task = sum_weighted_load;
2007 } 2226 }
2227
2228#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
2229 /*
2230 * Busy processors will not participate in power savings
2231 * balance.
2232 */
2233 if (idle == NOT_IDLE || !(sd->flags & SD_POWERSAVINGS_BALANCE))
2234 goto group_next;
2235
2236 /*
2237 * If the local group is idle or completely loaded
2238 * no need to do power savings balance at this domain
2239 */
2240 if (local_group && (this_nr_running >= group_capacity ||
2241 !this_nr_running))
2242 power_savings_balance = 0;
2243
2244 /*
2245 * If a group is already running at full capacity or idle,
2246 * don't include that group in power savings calculations
2247 */
2248 if (!power_savings_balance || sum_nr_running >= group_capacity
2249 || !sum_nr_running)
2250 goto group_next;
2251
2252 /*
2253 * Calculate the group which has the least non-idle load.
2254 * This is the group from where we need to pick up the load
2255 * for saving power
2256 */
2257 if ((sum_nr_running < min_nr_running) ||
2258 (sum_nr_running == min_nr_running &&
2259 first_cpu(group->cpumask) <
2260 first_cpu(group_min->cpumask))) {
2261 group_min = group;
2262 min_nr_running = sum_nr_running;
2263 min_load_per_task = sum_weighted_load /
2264 sum_nr_running;
2265 }
2266
2267 /*
2268 * Calculate the group which is almost near its
2269 * capacity but still has some space to pick up some load
2270 * from other group and save more power
2271 */
2272 if (sum_nr_running <= group_capacity - 1)
2273 if (sum_nr_running > leader_nr_running ||
2274 (sum_nr_running == leader_nr_running &&
2275 first_cpu(group->cpumask) >
2276 first_cpu(group_leader->cpumask))) {
2277 group_leader = group;
2278 leader_nr_running = sum_nr_running;
2279 }
2280
2281group_next:
2282#endif
2008 group = group->next; 2283 group = group->next;
2009 } while (group != sd->groups); 2284 } while (group != sd->groups);
2010 2285
2011 if (!busiest || this_load >= max_load || max_load <= SCHED_LOAD_SCALE) 2286 if (!busiest || this_load >= max_load || busiest_nr_running == 0)
2012 goto out_balanced; 2287 goto out_balanced;
2013 2288
2014 avg_load = (SCHED_LOAD_SCALE * total_load) / total_pwr; 2289 avg_load = (SCHED_LOAD_SCALE * total_load) / total_pwr;
@@ -2017,6 +2292,7 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2017 100*max_load <= sd->imbalance_pct*this_load) 2292 100*max_load <= sd->imbalance_pct*this_load)
2018 goto out_balanced; 2293 goto out_balanced;
2019 2294
2295 busiest_load_per_task /= busiest_nr_running;
2020 /* 2296 /*
2021 * We're trying to get all the cpus to the average_load, so we don't 2297 * We're trying to get all the cpus to the average_load, so we don't
2022 * want to push ourselves above the average load, nor do we wish to 2298 * want to push ourselves above the average load, nor do we wish to
@@ -2028,21 +2304,50 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2028 * by pulling tasks to us. Be careful of negative numbers as they'll 2304 * by pulling tasks to us. Be careful of negative numbers as they'll
2029 * appear as very large values with unsigned longs. 2305 * appear as very large values with unsigned longs.
2030 */ 2306 */
2307 if (max_load <= busiest_load_per_task)
2308 goto out_balanced;
2309
2310 /*
2311 * In the presence of smp nice balancing, certain scenarios can have
2312 * max load less than avg load(as we skip the groups at or below
2313 * its cpu_power, while calculating max_load..)
2314 */
2315 if (max_load < avg_load) {
2316 *imbalance = 0;
2317 goto small_imbalance;
2318 }
2031 2319
2032 /* Don't want to pull so many tasks that a group would go idle */ 2320 /* Don't want to pull so many tasks that a group would go idle */
2033 max_pull = min(max_load - avg_load, max_load - SCHED_LOAD_SCALE); 2321 max_pull = min(max_load - avg_load, max_load - busiest_load_per_task);
2034 2322
2035 /* How much load to actually move to equalise the imbalance */ 2323 /* How much load to actually move to equalise the imbalance */
2036 *imbalance = min(max_pull * busiest->cpu_power, 2324 *imbalance = min(max_pull * busiest->cpu_power,
2037 (avg_load - this_load) * this->cpu_power) 2325 (avg_load - this_load) * this->cpu_power)
2038 / SCHED_LOAD_SCALE; 2326 / SCHED_LOAD_SCALE;
2039 2327
2040 if (*imbalance < SCHED_LOAD_SCALE) { 2328 /*
2041 unsigned long pwr_now = 0, pwr_move = 0; 2329 * if *imbalance is less than the average load per runnable task
2330 * there is no gaurantee that any tasks will be moved so we'll have
2331 * a think about bumping its value to force at least one task to be
2332 * moved
2333 */
2334 if (*imbalance < busiest_load_per_task) {
2335 unsigned long pwr_now, pwr_move;
2042 unsigned long tmp; 2336 unsigned long tmp;
2337 unsigned int imbn;
2338
2339small_imbalance:
2340 pwr_move = pwr_now = 0;
2341 imbn = 2;
2342 if (this_nr_running) {
2343 this_load_per_task /= this_nr_running;
2344 if (busiest_load_per_task > this_load_per_task)
2345 imbn = 1;
2346 } else
2347 this_load_per_task = SCHED_LOAD_SCALE;
2043 2348
2044 if (max_load - this_load >= SCHED_LOAD_SCALE*2) { 2349 if (max_load - this_load >= busiest_load_per_task * imbn) {
2045 *imbalance = 1; 2350 *imbalance = busiest_load_per_task;
2046 return busiest; 2351 return busiest;
2047 } 2352 }
2048 2353
@@ -2052,39 +2357,47 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2052 * moving them. 2357 * moving them.
2053 */ 2358 */
2054 2359
2055 pwr_now += busiest->cpu_power*min(SCHED_LOAD_SCALE, max_load); 2360 pwr_now += busiest->cpu_power *
2056 pwr_now += this->cpu_power*min(SCHED_LOAD_SCALE, this_load); 2361 min(busiest_load_per_task, max_load);
2362 pwr_now += this->cpu_power *
2363 min(this_load_per_task, this_load);
2057 pwr_now /= SCHED_LOAD_SCALE; 2364 pwr_now /= SCHED_LOAD_SCALE;
2058 2365
2059 /* Amount of load we'd subtract */ 2366 /* Amount of load we'd subtract */
2060 tmp = SCHED_LOAD_SCALE*SCHED_LOAD_SCALE/busiest->cpu_power; 2367 tmp = busiest_load_per_task*SCHED_LOAD_SCALE/busiest->cpu_power;
2061 if (max_load > tmp) 2368 if (max_load > tmp)
2062 pwr_move += busiest->cpu_power*min(SCHED_LOAD_SCALE, 2369 pwr_move += busiest->cpu_power *
2063 max_load - tmp); 2370 min(busiest_load_per_task, max_load - tmp);
2064 2371
2065 /* Amount of load we'd add */ 2372 /* Amount of load we'd add */
2066 if (max_load*busiest->cpu_power < 2373 if (max_load*busiest->cpu_power <
2067 SCHED_LOAD_SCALE*SCHED_LOAD_SCALE) 2374 busiest_load_per_task*SCHED_LOAD_SCALE)
2068 tmp = max_load*busiest->cpu_power/this->cpu_power; 2375 tmp = max_load*busiest->cpu_power/this->cpu_power;
2069 else 2376 else
2070 tmp = SCHED_LOAD_SCALE*SCHED_LOAD_SCALE/this->cpu_power; 2377 tmp = busiest_load_per_task*SCHED_LOAD_SCALE/this->cpu_power;
2071 pwr_move += this->cpu_power*min(SCHED_LOAD_SCALE, this_load + tmp); 2378 pwr_move += this->cpu_power*min(this_load_per_task, this_load + tmp);
2072 pwr_move /= SCHED_LOAD_SCALE; 2379 pwr_move /= SCHED_LOAD_SCALE;
2073 2380
2074 /* Move if we gain throughput */ 2381 /* Move if we gain throughput */
2075 if (pwr_move <= pwr_now) 2382 if (pwr_move <= pwr_now)
2076 goto out_balanced; 2383 goto out_balanced;
2077 2384
2078 *imbalance = 1; 2385 *imbalance = busiest_load_per_task;
2079 return busiest;
2080 } 2386 }
2081 2387
2082 /* Get rid of the scaling factor, rounding down as we divide */
2083 *imbalance = *imbalance / SCHED_LOAD_SCALE;
2084 return busiest; 2388 return busiest;
2085 2389
2086out_balanced: 2390out_balanced:
2391#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
2392 if (idle == NOT_IDLE || !(sd->flags & SD_POWERSAVINGS_BALANCE))
2393 goto ret;
2087 2394
2395 if (this == group_leader && group_leader != group_min) {
2396 *imbalance = min_load_per_task;
2397 return group_min;
2398 }
2399ret:
2400#endif
2088 *imbalance = 0; 2401 *imbalance = 0;
2089 return NULL; 2402 return NULL;
2090} 2403}
@@ -2093,18 +2406,21 @@ out_balanced:
2093 * find_busiest_queue - find the busiest runqueue among the cpus in group. 2406 * find_busiest_queue - find the busiest runqueue among the cpus in group.
2094 */ 2407 */
2095static runqueue_t *find_busiest_queue(struct sched_group *group, 2408static runqueue_t *find_busiest_queue(struct sched_group *group,
2096 enum idle_type idle) 2409 enum idle_type idle, unsigned long imbalance)
2097{ 2410{
2098 unsigned long load, max_load = 0; 2411 unsigned long max_load = 0;
2099 runqueue_t *busiest = NULL; 2412 runqueue_t *busiest = NULL, *rqi;
2100 int i; 2413 int i;
2101 2414
2102 for_each_cpu_mask(i, group->cpumask) { 2415 for_each_cpu_mask(i, group->cpumask) {
2103 load = source_load(i, 0); 2416 rqi = cpu_rq(i);
2417
2418 if (rqi->nr_running == 1 && rqi->raw_weighted_load > imbalance)
2419 continue;
2104 2420
2105 if (load > max_load) { 2421 if (rqi->raw_weighted_load > max_load) {
2106 max_load = load; 2422 max_load = rqi->raw_weighted_load;
2107 busiest = cpu_rq(i); 2423 busiest = rqi;
2108 } 2424 }
2109 } 2425 }
2110 2426
@@ -2117,6 +2433,7 @@ static runqueue_t *find_busiest_queue(struct sched_group *group,
2117 */ 2433 */
2118#define MAX_PINNED_INTERVAL 512 2434#define MAX_PINNED_INTERVAL 512
2119 2435
2436#define minus_1_or_zero(n) ((n) > 0 ? (n) - 1 : 0)
2120/* 2437/*
2121 * Check this_cpu to ensure it is balanced within domain. Attempt to move 2438 * Check this_cpu to ensure it is balanced within domain. Attempt to move
2122 * tasks if there is an imbalance. 2439 * tasks if there is an imbalance.
@@ -2133,7 +2450,8 @@ static int load_balance(int this_cpu, runqueue_t *this_rq,
2133 int active_balance = 0; 2450 int active_balance = 0;
2134 int sd_idle = 0; 2451 int sd_idle = 0;
2135 2452
2136 if (idle != NOT_IDLE && sd->flags & SD_SHARE_CPUPOWER) 2453 if (idle != NOT_IDLE && sd->flags & SD_SHARE_CPUPOWER &&
2454 !sched_smt_power_savings)
2137 sd_idle = 1; 2455 sd_idle = 1;
2138 2456
2139 schedstat_inc(sd, lb_cnt[idle]); 2457 schedstat_inc(sd, lb_cnt[idle]);
@@ -2144,7 +2462,7 @@ static int load_balance(int this_cpu, runqueue_t *this_rq,
2144 goto out_balanced; 2462 goto out_balanced;
2145 } 2463 }
2146 2464
2147 busiest = find_busiest_queue(group, idle); 2465 busiest = find_busiest_queue(group, idle, imbalance);
2148 if (!busiest) { 2466 if (!busiest) {
2149 schedstat_inc(sd, lb_nobusyq[idle]); 2467 schedstat_inc(sd, lb_nobusyq[idle]);
2150 goto out_balanced; 2468 goto out_balanced;
@@ -2164,6 +2482,7 @@ static int load_balance(int this_cpu, runqueue_t *this_rq,
2164 */ 2482 */
2165 double_rq_lock(this_rq, busiest); 2483 double_rq_lock(this_rq, busiest);
2166 nr_moved = move_tasks(this_rq, this_cpu, busiest, 2484 nr_moved = move_tasks(this_rq, this_cpu, busiest,
2485 minus_1_or_zero(busiest->nr_running),
2167 imbalance, sd, idle, &all_pinned); 2486 imbalance, sd, idle, &all_pinned);
2168 double_rq_unlock(this_rq, busiest); 2487 double_rq_unlock(this_rq, busiest);
2169 2488
@@ -2221,7 +2540,8 @@ static int load_balance(int this_cpu, runqueue_t *this_rq,
2221 sd->balance_interval *= 2; 2540 sd->balance_interval *= 2;
2222 } 2541 }
2223 2542
2224 if (!nr_moved && !sd_idle && sd->flags & SD_SHARE_CPUPOWER) 2543 if (!nr_moved && !sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
2544 !sched_smt_power_savings)
2225 return -1; 2545 return -1;
2226 return nr_moved; 2546 return nr_moved;
2227 2547
@@ -2236,7 +2556,7 @@ out_one_pinned:
2236 (sd->balance_interval < sd->max_interval)) 2556 (sd->balance_interval < sd->max_interval))
2237 sd->balance_interval *= 2; 2557 sd->balance_interval *= 2;
2238 2558
2239 if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER) 2559 if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER && !sched_smt_power_savings)
2240 return -1; 2560 return -1;
2241 return 0; 2561 return 0;
2242} 2562}
@@ -2257,7 +2577,7 @@ static int load_balance_newidle(int this_cpu, runqueue_t *this_rq,
2257 int nr_moved = 0; 2577 int nr_moved = 0;
2258 int sd_idle = 0; 2578 int sd_idle = 0;
2259 2579
2260 if (sd->flags & SD_SHARE_CPUPOWER) 2580 if (sd->flags & SD_SHARE_CPUPOWER && !sched_smt_power_savings)
2261 sd_idle = 1; 2581 sd_idle = 1;
2262 2582
2263 schedstat_inc(sd, lb_cnt[NEWLY_IDLE]); 2583 schedstat_inc(sd, lb_cnt[NEWLY_IDLE]);
@@ -2267,7 +2587,7 @@ static int load_balance_newidle(int this_cpu, runqueue_t *this_rq,
2267 goto out_balanced; 2587 goto out_balanced;
2268 } 2588 }
2269 2589
2270 busiest = find_busiest_queue(group, NEWLY_IDLE); 2590 busiest = find_busiest_queue(group, NEWLY_IDLE, imbalance);
2271 if (!busiest) { 2591 if (!busiest) {
2272 schedstat_inc(sd, lb_nobusyq[NEWLY_IDLE]); 2592 schedstat_inc(sd, lb_nobusyq[NEWLY_IDLE]);
2273 goto out_balanced; 2593 goto out_balanced;
@@ -2282,6 +2602,7 @@ static int load_balance_newidle(int this_cpu, runqueue_t *this_rq,
2282 /* Attempt to move tasks */ 2602 /* Attempt to move tasks */
2283 double_lock_balance(this_rq, busiest); 2603 double_lock_balance(this_rq, busiest);
2284 nr_moved = move_tasks(this_rq, this_cpu, busiest, 2604 nr_moved = move_tasks(this_rq, this_cpu, busiest,
2605 minus_1_or_zero(busiest->nr_running),
2285 imbalance, sd, NEWLY_IDLE, NULL); 2606 imbalance, sd, NEWLY_IDLE, NULL);
2286 spin_unlock(&busiest->lock); 2607 spin_unlock(&busiest->lock);
2287 } 2608 }
@@ -2297,7 +2618,7 @@ static int load_balance_newidle(int this_cpu, runqueue_t *this_rq,
2297 2618
2298out_balanced: 2619out_balanced:
2299 schedstat_inc(sd, lb_balanced[NEWLY_IDLE]); 2620 schedstat_inc(sd, lb_balanced[NEWLY_IDLE]);
2300 if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER) 2621 if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER && !sched_smt_power_savings)
2301 return -1; 2622 return -1;
2302 sd->nr_balance_failed = 0; 2623 sd->nr_balance_failed = 0;
2303 return 0; 2624 return 0;
@@ -2352,17 +2673,19 @@ static void active_load_balance(runqueue_t *busiest_rq, int busiest_cpu)
2352 double_lock_balance(busiest_rq, target_rq); 2673 double_lock_balance(busiest_rq, target_rq);
2353 2674
2354 /* Search for an sd spanning us and the target CPU. */ 2675 /* Search for an sd spanning us and the target CPU. */
2355 for_each_domain(target_cpu, sd) 2676 for_each_domain(target_cpu, sd) {
2356 if ((sd->flags & SD_LOAD_BALANCE) && 2677 if ((sd->flags & SD_LOAD_BALANCE) &&
2357 cpu_isset(busiest_cpu, sd->span)) 2678 cpu_isset(busiest_cpu, sd->span))
2358 break; 2679 break;
2680 }
2359 2681
2360 if (unlikely(sd == NULL)) 2682 if (unlikely(sd == NULL))
2361 goto out; 2683 goto out;
2362 2684
2363 schedstat_inc(sd, alb_cnt); 2685 schedstat_inc(sd, alb_cnt);
2364 2686
2365 if (move_tasks(target_rq, target_cpu, busiest_rq, 1, sd, SCHED_IDLE, NULL)) 2687 if (move_tasks(target_rq, target_cpu, busiest_rq, 1,
2688 RTPRIO_TO_LOAD_WEIGHT(100), sd, SCHED_IDLE, NULL))
2366 schedstat_inc(sd, alb_pushed); 2689 schedstat_inc(sd, alb_pushed);
2367 else 2690 else
2368 schedstat_inc(sd, alb_failed); 2691 schedstat_inc(sd, alb_failed);
@@ -2390,7 +2713,7 @@ static void rebalance_tick(int this_cpu, runqueue_t *this_rq,
2390 struct sched_domain *sd; 2713 struct sched_domain *sd;
2391 int i; 2714 int i;
2392 2715
2393 this_load = this_rq->nr_running * SCHED_LOAD_SCALE; 2716 this_load = this_rq->raw_weighted_load;
2394 /* Update our load */ 2717 /* Update our load */
2395 for (i = 0; i < 3; i++) { 2718 for (i = 0; i < 3; i++) {
2396 unsigned long new_load = this_load; 2719 unsigned long new_load = this_load;
@@ -2691,48 +3014,35 @@ static inline void wakeup_busy_runqueue(runqueue_t *rq)
2691 resched_task(rq->idle); 3014 resched_task(rq->idle);
2692} 3015}
2693 3016
2694static void wake_sleeping_dependent(int this_cpu, runqueue_t *this_rq) 3017/*
3018 * Called with interrupt disabled and this_rq's runqueue locked.
3019 */
3020static void wake_sleeping_dependent(int this_cpu)
2695{ 3021{
2696 struct sched_domain *tmp, *sd = NULL; 3022 struct sched_domain *tmp, *sd = NULL;
2697 cpumask_t sibling_map;
2698 int i; 3023 int i;
2699 3024
2700 for_each_domain(this_cpu, tmp) 3025 for_each_domain(this_cpu, tmp) {
2701 if (tmp->flags & SD_SHARE_CPUPOWER) 3026 if (tmp->flags & SD_SHARE_CPUPOWER) {
2702 sd = tmp; 3027 sd = tmp;
3028 break;
3029 }
3030 }
2703 3031
2704 if (!sd) 3032 if (!sd)
2705 return; 3033 return;
2706 3034
2707 /* 3035 for_each_cpu_mask(i, sd->span) {
2708 * Unlock the current runqueue because we have to lock in
2709 * CPU order to avoid deadlocks. Caller knows that we might
2710 * unlock. We keep IRQs disabled.
2711 */
2712 spin_unlock(&this_rq->lock);
2713
2714 sibling_map = sd->span;
2715
2716 for_each_cpu_mask(i, sibling_map)
2717 spin_lock(&cpu_rq(i)->lock);
2718 /*
2719 * We clear this CPU from the mask. This both simplifies the
2720 * inner loop and keps this_rq locked when we exit:
2721 */
2722 cpu_clear(this_cpu, sibling_map);
2723
2724 for_each_cpu_mask(i, sibling_map) {
2725 runqueue_t *smt_rq = cpu_rq(i); 3036 runqueue_t *smt_rq = cpu_rq(i);
2726 3037
3038 if (i == this_cpu)
3039 continue;
3040 if (unlikely(!spin_trylock(&smt_rq->lock)))
3041 continue;
3042
2727 wakeup_busy_runqueue(smt_rq); 3043 wakeup_busy_runqueue(smt_rq);
3044 spin_unlock(&smt_rq->lock);
2728 } 3045 }
2729
2730 for_each_cpu_mask(i, sibling_map)
2731 spin_unlock(&cpu_rq(i)->lock);
2732 /*
2733 * We exit with this_cpu's rq still held and IRQs
2734 * still disabled:
2735 */
2736} 3046}
2737 3047
2738/* 3048/*
@@ -2745,52 +3055,46 @@ static inline unsigned long smt_slice(task_t *p, struct sched_domain *sd)
2745 return p->time_slice * (100 - sd->per_cpu_gain) / 100; 3055 return p->time_slice * (100 - sd->per_cpu_gain) / 100;
2746} 3056}
2747 3057
2748static int dependent_sleeper(int this_cpu, runqueue_t *this_rq) 3058/*
3059 * To minimise lock contention and not have to drop this_rq's runlock we only
3060 * trylock the sibling runqueues and bypass those runqueues if we fail to
3061 * acquire their lock. As we only trylock the normal locking order does not
3062 * need to be obeyed.
3063 */
3064static int dependent_sleeper(int this_cpu, runqueue_t *this_rq, task_t *p)
2749{ 3065{
2750 struct sched_domain *tmp, *sd = NULL; 3066 struct sched_domain *tmp, *sd = NULL;
2751 cpumask_t sibling_map;
2752 prio_array_t *array;
2753 int ret = 0, i; 3067 int ret = 0, i;
2754 task_t *p;
2755 3068
2756 for_each_domain(this_cpu, tmp) 3069 /* kernel/rt threads do not participate in dependent sleeping */
2757 if (tmp->flags & SD_SHARE_CPUPOWER) 3070 if (!p->mm || rt_task(p))
3071 return 0;
3072
3073 for_each_domain(this_cpu, tmp) {
3074 if (tmp->flags & SD_SHARE_CPUPOWER) {
2758 sd = tmp; 3075 sd = tmp;
3076 break;
3077 }
3078 }
2759 3079
2760 if (!sd) 3080 if (!sd)
2761 return 0; 3081 return 0;
2762 3082
2763 /* 3083 for_each_cpu_mask(i, sd->span) {
2764 * The same locking rules and details apply as for 3084 runqueue_t *smt_rq;
2765 * wake_sleeping_dependent(): 3085 task_t *smt_curr;
2766 */
2767 spin_unlock(&this_rq->lock);
2768 sibling_map = sd->span;
2769 for_each_cpu_mask(i, sibling_map)
2770 spin_lock(&cpu_rq(i)->lock);
2771 cpu_clear(this_cpu, sibling_map);
2772 3086
2773 /* 3087 if (i == this_cpu)
2774 * Establish next task to be run - it might have gone away because 3088 continue;
2775 * we released the runqueue lock above:
2776 */
2777 if (!this_rq->nr_running)
2778 goto out_unlock;
2779 array = this_rq->active;
2780 if (!array->nr_active)
2781 array = this_rq->expired;
2782 BUG_ON(!array->nr_active);
2783 3089
2784 p = list_entry(array->queue[sched_find_first_bit(array->bitmap)].next, 3090 smt_rq = cpu_rq(i);
2785 task_t, run_list); 3091 if (unlikely(!spin_trylock(&smt_rq->lock)))
3092 continue;
2786 3093
2787 for_each_cpu_mask(i, sibling_map) { 3094 smt_curr = smt_rq->curr;
2788 runqueue_t *smt_rq = cpu_rq(i);
2789 task_t *smt_curr = smt_rq->curr;
2790 3095
2791 /* Kernel threads do not participate in dependent sleeping */ 3096 if (!smt_curr->mm)
2792 if (!p->mm || !smt_curr->mm || rt_task(p)) 3097 goto unlock;
2793 goto check_smt_task;
2794 3098
2795 /* 3099 /*
2796 * If a user task with lower static priority than the 3100 * If a user task with lower static priority than the
@@ -2808,49 +3112,24 @@ static int dependent_sleeper(int this_cpu, runqueue_t *this_rq)
2808 if ((jiffies % DEF_TIMESLICE) > 3112 if ((jiffies % DEF_TIMESLICE) >
2809 (sd->per_cpu_gain * DEF_TIMESLICE / 100)) 3113 (sd->per_cpu_gain * DEF_TIMESLICE / 100))
2810 ret = 1; 3114 ret = 1;
2811 } else 3115 } else {
2812 if (smt_curr->static_prio < p->static_prio && 3116 if (smt_curr->static_prio < p->static_prio &&
2813 !TASK_PREEMPTS_CURR(p, smt_rq) && 3117 !TASK_PREEMPTS_CURR(p, smt_rq) &&
2814 smt_slice(smt_curr, sd) > task_timeslice(p)) 3118 smt_slice(smt_curr, sd) > task_timeslice(p))
2815 ret = 1; 3119 ret = 1;
2816
2817check_smt_task:
2818 if ((!smt_curr->mm && smt_curr != smt_rq->idle) ||
2819 rt_task(smt_curr))
2820 continue;
2821 if (!p->mm) {
2822 wakeup_busy_runqueue(smt_rq);
2823 continue;
2824 }
2825
2826 /*
2827 * Reschedule a lower priority task on the SMT sibling for
2828 * it to be put to sleep, or wake it up if it has been put to
2829 * sleep for priority reasons to see if it should run now.
2830 */
2831 if (rt_task(p)) {
2832 if ((jiffies % DEF_TIMESLICE) >
2833 (sd->per_cpu_gain * DEF_TIMESLICE / 100))
2834 resched_task(smt_curr);
2835 } else {
2836 if (TASK_PREEMPTS_CURR(p, smt_rq) &&
2837 smt_slice(p, sd) > task_timeslice(smt_curr))
2838 resched_task(smt_curr);
2839 else
2840 wakeup_busy_runqueue(smt_rq);
2841 } 3120 }
3121unlock:
3122 spin_unlock(&smt_rq->lock);
2842 } 3123 }
2843out_unlock:
2844 for_each_cpu_mask(i, sibling_map)
2845 spin_unlock(&cpu_rq(i)->lock);
2846 return ret; 3124 return ret;
2847} 3125}
2848#else 3126#else
2849static inline void wake_sleeping_dependent(int this_cpu, runqueue_t *this_rq) 3127static inline void wake_sleeping_dependent(int this_cpu)
2850{ 3128{
2851} 3129}
2852 3130
2853static inline int dependent_sleeper(int this_cpu, runqueue_t *this_rq) 3131static inline int dependent_sleeper(int this_cpu, runqueue_t *this_rq,
3132 task_t *p)
2854{ 3133{
2855 return 0; 3134 return 0;
2856} 3135}
@@ -2972,32 +3251,13 @@ need_resched_nonpreemptible:
2972 3251
2973 cpu = smp_processor_id(); 3252 cpu = smp_processor_id();
2974 if (unlikely(!rq->nr_running)) { 3253 if (unlikely(!rq->nr_running)) {
2975go_idle:
2976 idle_balance(cpu, rq); 3254 idle_balance(cpu, rq);
2977 if (!rq->nr_running) { 3255 if (!rq->nr_running) {
2978 next = rq->idle; 3256 next = rq->idle;
2979 rq->expired_timestamp = 0; 3257 rq->expired_timestamp = 0;
2980 wake_sleeping_dependent(cpu, rq); 3258 wake_sleeping_dependent(cpu);
2981 /*
2982 * wake_sleeping_dependent() might have released
2983 * the runqueue, so break out if we got new
2984 * tasks meanwhile:
2985 */
2986 if (!rq->nr_running)
2987 goto switch_tasks;
2988 }
2989 } else {
2990 if (dependent_sleeper(cpu, rq)) {
2991 next = rq->idle;
2992 goto switch_tasks; 3259 goto switch_tasks;
2993 } 3260 }
2994 /*
2995 * dependent_sleeper() releases and reacquires the runqueue
2996 * lock, hence go into the idle loop if the rq went
2997 * empty meanwhile:
2998 */
2999 if (unlikely(!rq->nr_running))
3000 goto go_idle;
3001 } 3261 }
3002 3262
3003 array = rq->active; 3263 array = rq->active;
@@ -3035,6 +3295,8 @@ go_idle:
3035 } 3295 }
3036 } 3296 }
3037 next->sleep_type = SLEEP_NORMAL; 3297 next->sleep_type = SLEEP_NORMAL;
3298 if (dependent_sleeper(cpu, rq, next))
3299 next = rq->idle;
3038switch_tasks: 3300switch_tasks:
3039 if (next == rq->idle) 3301 if (next == rq->idle)
3040 schedstat_inc(rq, sched_goidle); 3302 schedstat_inc(rq, sched_goidle);
@@ -3478,12 +3740,65 @@ long fastcall __sched sleep_on_timeout(wait_queue_head_t *q, long timeout)
3478 3740
3479EXPORT_SYMBOL(sleep_on_timeout); 3741EXPORT_SYMBOL(sleep_on_timeout);
3480 3742
3743#ifdef CONFIG_RT_MUTEXES
3744
3745/*
3746 * rt_mutex_setprio - set the current priority of a task
3747 * @p: task
3748 * @prio: prio value (kernel-internal form)
3749 *
3750 * This function changes the 'effective' priority of a task. It does
3751 * not touch ->normal_prio like __setscheduler().
3752 *
3753 * Used by the rt_mutex code to implement priority inheritance logic.
3754 */
3755void rt_mutex_setprio(task_t *p, int prio)
3756{
3757 unsigned long flags;
3758 prio_array_t *array;
3759 runqueue_t *rq;
3760 int oldprio;
3761
3762 BUG_ON(prio < 0 || prio > MAX_PRIO);
3763
3764 rq = task_rq_lock(p, &flags);
3765
3766 oldprio = p->prio;
3767 array = p->array;
3768 if (array)
3769 dequeue_task(p, array);
3770 p->prio = prio;
3771
3772 if (array) {
3773 /*
3774 * If changing to an RT priority then queue it
3775 * in the active array!
3776 */
3777 if (rt_task(p))
3778 array = rq->active;
3779 enqueue_task(p, array);
3780 /*
3781 * Reschedule if we are currently running on this runqueue and
3782 * our priority decreased, or if we are not currently running on
3783 * this runqueue and our priority is higher than the current's
3784 */
3785 if (task_running(rq, p)) {
3786 if (p->prio > oldprio)
3787 resched_task(rq->curr);
3788 } else if (TASK_PREEMPTS_CURR(p, rq))
3789 resched_task(rq->curr);
3790 }
3791 task_rq_unlock(rq, &flags);
3792}
3793
3794#endif
3795
3481void set_user_nice(task_t *p, long nice) 3796void set_user_nice(task_t *p, long nice)
3482{ 3797{
3483 unsigned long flags; 3798 unsigned long flags;
3484 prio_array_t *array; 3799 prio_array_t *array;
3485 runqueue_t *rq; 3800 runqueue_t *rq;
3486 int old_prio, new_prio, delta; 3801 int old_prio, delta;
3487 3802
3488 if (TASK_NICE(p) == nice || nice < -20 || nice > 19) 3803 if (TASK_NICE(p) == nice || nice < -20 || nice > 19)
3489 return; 3804 return;
@@ -3498,22 +3813,25 @@ void set_user_nice(task_t *p, long nice)
3498 * it wont have any effect on scheduling until the task is 3813 * it wont have any effect on scheduling until the task is
3499 * not SCHED_NORMAL/SCHED_BATCH: 3814 * not SCHED_NORMAL/SCHED_BATCH:
3500 */ 3815 */
3501 if (rt_task(p)) { 3816 if (has_rt_policy(p)) {
3502 p->static_prio = NICE_TO_PRIO(nice); 3817 p->static_prio = NICE_TO_PRIO(nice);
3503 goto out_unlock; 3818 goto out_unlock;
3504 } 3819 }
3505 array = p->array; 3820 array = p->array;
3506 if (array) 3821 if (array) {
3507 dequeue_task(p, array); 3822 dequeue_task(p, array);
3823 dec_raw_weighted_load(rq, p);
3824 }
3508 3825
3509 old_prio = p->prio;
3510 new_prio = NICE_TO_PRIO(nice);
3511 delta = new_prio - old_prio;
3512 p->static_prio = NICE_TO_PRIO(nice); 3826 p->static_prio = NICE_TO_PRIO(nice);
3513 p->prio += delta; 3827 set_load_weight(p);
3828 old_prio = p->prio;
3829 p->prio = effective_prio(p);
3830 delta = p->prio - old_prio;
3514 3831
3515 if (array) { 3832 if (array) {
3516 enqueue_task(p, array); 3833 enqueue_task(p, array);
3834 inc_raw_weighted_load(rq, p);
3517 /* 3835 /*
3518 * If the task increased its priority or is running and 3836 * If the task increased its priority or is running and
3519 * lowered its priority, then reschedule its CPU: 3837 * lowered its priority, then reschedule its CPU:
@@ -3524,7 +3842,6 @@ void set_user_nice(task_t *p, long nice)
3524out_unlock: 3842out_unlock:
3525 task_rq_unlock(rq, &flags); 3843 task_rq_unlock(rq, &flags);
3526} 3844}
3527
3528EXPORT_SYMBOL(set_user_nice); 3845EXPORT_SYMBOL(set_user_nice);
3529 3846
3530/* 3847/*
@@ -3639,16 +3956,15 @@ static void __setscheduler(struct task_struct *p, int policy, int prio)
3639 BUG_ON(p->array); 3956 BUG_ON(p->array);
3640 p->policy = policy; 3957 p->policy = policy;
3641 p->rt_priority = prio; 3958 p->rt_priority = prio;
3642 if (policy != SCHED_NORMAL && policy != SCHED_BATCH) { 3959 p->normal_prio = normal_prio(p);
3643 p->prio = MAX_RT_PRIO-1 - p->rt_priority; 3960 /* we are holding p->pi_lock already */
3644 } else { 3961 p->prio = rt_mutex_getprio(p);
3645 p->prio = p->static_prio; 3962 /*
3646 /* 3963 * SCHED_BATCH tasks are treated as perpetual CPU hogs:
3647 * SCHED_BATCH tasks are treated as perpetual CPU hogs: 3964 */
3648 */ 3965 if (policy == SCHED_BATCH)
3649 if (policy == SCHED_BATCH) 3966 p->sleep_avg = 0;
3650 p->sleep_avg = 0; 3967 set_load_weight(p);
3651 }
3652} 3968}
3653 3969
3654/** 3970/**
@@ -3667,6 +3983,8 @@ int sched_setscheduler(struct task_struct *p, int policy,
3667 unsigned long flags; 3983 unsigned long flags;
3668 runqueue_t *rq; 3984 runqueue_t *rq;
3669 3985
3986 /* may grab non-irq protected spin_locks */
3987 BUG_ON(in_interrupt());
3670recheck: 3988recheck:
3671 /* double check policy once rq lock held */ 3989 /* double check policy once rq lock held */
3672 if (policy < 0) 3990 if (policy < 0)
@@ -3715,14 +4033,20 @@ recheck:
3715 if (retval) 4033 if (retval)
3716 return retval; 4034 return retval;
3717 /* 4035 /*
4036 * make sure no PI-waiters arrive (or leave) while we are
4037 * changing the priority of the task:
4038 */
4039 spin_lock_irqsave(&p->pi_lock, flags);
4040 /*
3718 * To be able to change p->policy safely, the apropriate 4041 * To be able to change p->policy safely, the apropriate
3719 * runqueue lock must be held. 4042 * runqueue lock must be held.
3720 */ 4043 */
3721 rq = task_rq_lock(p, &flags); 4044 rq = __task_rq_lock(p);
3722 /* recheck policy now with rq lock held */ 4045 /* recheck policy now with rq lock held */
3723 if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) { 4046 if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) {
3724 policy = oldpolicy = -1; 4047 policy = oldpolicy = -1;
3725 task_rq_unlock(rq, &flags); 4048 __task_rq_unlock(rq);
4049 spin_unlock_irqrestore(&p->pi_lock, flags);
3726 goto recheck; 4050 goto recheck;
3727 } 4051 }
3728 array = p->array; 4052 array = p->array;
@@ -3743,7 +4067,11 @@ recheck:
3743 } else if (TASK_PREEMPTS_CURR(p, rq)) 4067 } else if (TASK_PREEMPTS_CURR(p, rq))
3744 resched_task(rq->curr); 4068 resched_task(rq->curr);
3745 } 4069 }
3746 task_rq_unlock(rq, &flags); 4070 __task_rq_unlock(rq);
4071 spin_unlock_irqrestore(&p->pi_lock, flags);
4072
4073 rt_mutex_adjust_pi(p);
4074
3747 return 0; 4075 return 0;
3748} 4076}
3749EXPORT_SYMBOL_GPL(sched_setscheduler); 4077EXPORT_SYMBOL_GPL(sched_setscheduler);
@@ -3765,8 +4093,10 @@ do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
3765 read_unlock_irq(&tasklist_lock); 4093 read_unlock_irq(&tasklist_lock);
3766 return -ESRCH; 4094 return -ESRCH;
3767 } 4095 }
3768 retval = sched_setscheduler(p, policy, &lparam); 4096 get_task_struct(p);
3769 read_unlock_irq(&tasklist_lock); 4097 read_unlock_irq(&tasklist_lock);
4098 retval = sched_setscheduler(p, policy, &lparam);
4099 put_task_struct(p);
3770 return retval; 4100 return retval;
3771} 4101}
3772 4102
@@ -4378,7 +4708,7 @@ void __devinit init_idle(task_t *idle, int cpu)
4378 idle->timestamp = sched_clock(); 4708 idle->timestamp = sched_clock();
4379 idle->sleep_avg = 0; 4709 idle->sleep_avg = 0;
4380 idle->array = NULL; 4710 idle->array = NULL;
4381 idle->prio = MAX_PRIO; 4711 idle->prio = idle->normal_prio = MAX_PRIO;
4382 idle->state = TASK_RUNNING; 4712 idle->state = TASK_RUNNING;
4383 idle->cpus_allowed = cpumask_of_cpu(cpu); 4713 idle->cpus_allowed = cpumask_of_cpu(cpu);
4384 set_task_cpu(idle, cpu); 4714 set_task_cpu(idle, cpu);
@@ -4474,13 +4804,16 @@ EXPORT_SYMBOL_GPL(set_cpus_allowed);
4474 * 4804 *
4475 * So we race with normal scheduler movements, but that's OK, as long 4805 * So we race with normal scheduler movements, but that's OK, as long
4476 * as the task is no longer on this CPU. 4806 * as the task is no longer on this CPU.
4807 *
4808 * Returns non-zero if task was successfully migrated.
4477 */ 4809 */
4478static void __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu) 4810static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
4479{ 4811{
4480 runqueue_t *rq_dest, *rq_src; 4812 runqueue_t *rq_dest, *rq_src;
4813 int ret = 0;
4481 4814
4482 if (unlikely(cpu_is_offline(dest_cpu))) 4815 if (unlikely(cpu_is_offline(dest_cpu)))
4483 return; 4816 return ret;
4484 4817
4485 rq_src = cpu_rq(src_cpu); 4818 rq_src = cpu_rq(src_cpu);
4486 rq_dest = cpu_rq(dest_cpu); 4819 rq_dest = cpu_rq(dest_cpu);
@@ -4508,9 +4841,10 @@ static void __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
4508 if (TASK_PREEMPTS_CURR(p, rq_dest)) 4841 if (TASK_PREEMPTS_CURR(p, rq_dest))
4509 resched_task(rq_dest->curr); 4842 resched_task(rq_dest->curr);
4510 } 4843 }
4511 4844 ret = 1;
4512out: 4845out:
4513 double_rq_unlock(rq_src, rq_dest); 4846 double_rq_unlock(rq_src, rq_dest);
4847 return ret;
4514} 4848}
4515 4849
4516/* 4850/*
@@ -4580,9 +4914,12 @@ wait_to_die:
4580/* Figure out where task on dead CPU should go, use force if neccessary. */ 4914/* Figure out where task on dead CPU should go, use force if neccessary. */
4581static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk) 4915static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk)
4582{ 4916{
4917 runqueue_t *rq;
4918 unsigned long flags;
4583 int dest_cpu; 4919 int dest_cpu;
4584 cpumask_t mask; 4920 cpumask_t mask;
4585 4921
4922restart:
4586 /* On same node? */ 4923 /* On same node? */
4587 mask = node_to_cpumask(cpu_to_node(dead_cpu)); 4924 mask = node_to_cpumask(cpu_to_node(dead_cpu));
4588 cpus_and(mask, mask, tsk->cpus_allowed); 4925 cpus_and(mask, mask, tsk->cpus_allowed);
@@ -4594,8 +4931,10 @@ static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk)
4594 4931
4595 /* No more Mr. Nice Guy. */ 4932 /* No more Mr. Nice Guy. */
4596 if (dest_cpu == NR_CPUS) { 4933 if (dest_cpu == NR_CPUS) {
4934 rq = task_rq_lock(tsk, &flags);
4597 cpus_setall(tsk->cpus_allowed); 4935 cpus_setall(tsk->cpus_allowed);
4598 dest_cpu = any_online_cpu(tsk->cpus_allowed); 4936 dest_cpu = any_online_cpu(tsk->cpus_allowed);
4937 task_rq_unlock(rq, &flags);
4599 4938
4600 /* 4939 /*
4601 * Don't tell them about moving exiting tasks or 4940 * Don't tell them about moving exiting tasks or
@@ -4607,7 +4946,8 @@ static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk)
4607 "longer affine to cpu%d\n", 4946 "longer affine to cpu%d\n",
4608 tsk->pid, tsk->comm, dead_cpu); 4947 tsk->pid, tsk->comm, dead_cpu);
4609 } 4948 }
4610 __migrate_task(tsk, dead_cpu, dest_cpu); 4949 if (!__migrate_task(tsk, dead_cpu, dest_cpu))
4950 goto restart;
4611} 4951}
4612 4952
4613/* 4953/*
@@ -4734,8 +5074,9 @@ static void migrate_dead_tasks(unsigned int dead_cpu)
4734 * migration_call - callback that gets triggered when a CPU is added. 5074 * migration_call - callback that gets triggered when a CPU is added.
4735 * Here we can start up the necessary migration thread for the new CPU. 5075 * Here we can start up the necessary migration thread for the new CPU.
4736 */ 5076 */
4737static int migration_call(struct notifier_block *nfb, unsigned long action, 5077static int __cpuinit migration_call(struct notifier_block *nfb,
4738 void *hcpu) 5078 unsigned long action,
5079 void *hcpu)
4739{ 5080{
4740 int cpu = (long)hcpu; 5081 int cpu = (long)hcpu;
4741 struct task_struct *p; 5082 struct task_struct *p;
@@ -4805,7 +5146,7 @@ static int migration_call(struct notifier_block *nfb, unsigned long action,
4805/* Register at highest priority so that task migration (migrate_all_tasks) 5146/* Register at highest priority so that task migration (migrate_all_tasks)
4806 * happens before everything else. 5147 * happens before everything else.
4807 */ 5148 */
4808static struct notifier_block migration_notifier = { 5149static struct notifier_block __cpuinitdata migration_notifier = {
4809 .notifier_call = migration_call, 5150 .notifier_call = migration_call,
4810 .priority = 10 5151 .priority = 10
4811}; 5152};
@@ -5606,6 +5947,7 @@ static cpumask_t sched_domain_node_span(int node)
5606} 5947}
5607#endif 5948#endif
5608 5949
5950int sched_smt_power_savings = 0, sched_mc_power_savings = 0;
5609/* 5951/*
5610 * At the moment, CONFIG_SCHED_SMT is never defined, but leave it in so we 5952 * At the moment, CONFIG_SCHED_SMT is never defined, but leave it in so we
5611 * can switch it on easily if needed. 5953 * can switch it on easily if needed.
@@ -5621,7 +5963,7 @@ static int cpu_to_cpu_group(int cpu)
5621 5963
5622#ifdef CONFIG_SCHED_MC 5964#ifdef CONFIG_SCHED_MC
5623static DEFINE_PER_CPU(struct sched_domain, core_domains); 5965static DEFINE_PER_CPU(struct sched_domain, core_domains);
5624static struct sched_group sched_group_core[NR_CPUS]; 5966static struct sched_group *sched_group_core_bycpu[NR_CPUS];
5625#endif 5967#endif
5626 5968
5627#if defined(CONFIG_SCHED_MC) && defined(CONFIG_SCHED_SMT) 5969#if defined(CONFIG_SCHED_MC) && defined(CONFIG_SCHED_SMT)
@@ -5637,7 +5979,7 @@ static int cpu_to_core_group(int cpu)
5637#endif 5979#endif
5638 5980
5639static DEFINE_PER_CPU(struct sched_domain, phys_domains); 5981static DEFINE_PER_CPU(struct sched_domain, phys_domains);
5640static struct sched_group sched_group_phys[NR_CPUS]; 5982static struct sched_group *sched_group_phys_bycpu[NR_CPUS];
5641static int cpu_to_phys_group(int cpu) 5983static int cpu_to_phys_group(int cpu)
5642{ 5984{
5643#if defined(CONFIG_SCHED_MC) 5985#if defined(CONFIG_SCHED_MC)
@@ -5694,13 +6036,74 @@ next_sg:
5694} 6036}
5695#endif 6037#endif
5696 6038
6039/* Free memory allocated for various sched_group structures */
6040static void free_sched_groups(const cpumask_t *cpu_map)
6041{
6042 int cpu;
6043#ifdef CONFIG_NUMA
6044 int i;
6045
6046 for_each_cpu_mask(cpu, *cpu_map) {
6047 struct sched_group *sched_group_allnodes
6048 = sched_group_allnodes_bycpu[cpu];
6049 struct sched_group **sched_group_nodes
6050 = sched_group_nodes_bycpu[cpu];
6051
6052 if (sched_group_allnodes) {
6053 kfree(sched_group_allnodes);
6054 sched_group_allnodes_bycpu[cpu] = NULL;
6055 }
6056
6057 if (!sched_group_nodes)
6058 continue;
6059
6060 for (i = 0; i < MAX_NUMNODES; i++) {
6061 cpumask_t nodemask = node_to_cpumask(i);
6062 struct sched_group *oldsg, *sg = sched_group_nodes[i];
6063
6064 cpus_and(nodemask, nodemask, *cpu_map);
6065 if (cpus_empty(nodemask))
6066 continue;
6067
6068 if (sg == NULL)
6069 continue;
6070 sg = sg->next;
6071next_sg:
6072 oldsg = sg;
6073 sg = sg->next;
6074 kfree(oldsg);
6075 if (oldsg != sched_group_nodes[i])
6076 goto next_sg;
6077 }
6078 kfree(sched_group_nodes);
6079 sched_group_nodes_bycpu[cpu] = NULL;
6080 }
6081#endif
6082 for_each_cpu_mask(cpu, *cpu_map) {
6083 if (sched_group_phys_bycpu[cpu]) {
6084 kfree(sched_group_phys_bycpu[cpu]);
6085 sched_group_phys_bycpu[cpu] = NULL;
6086 }
6087#ifdef CONFIG_SCHED_MC
6088 if (sched_group_core_bycpu[cpu]) {
6089 kfree(sched_group_core_bycpu[cpu]);
6090 sched_group_core_bycpu[cpu] = NULL;
6091 }
6092#endif
6093 }
6094}
6095
5697/* 6096/*
5698 * Build sched domains for a given set of cpus and attach the sched domains 6097 * Build sched domains for a given set of cpus and attach the sched domains
5699 * to the individual cpus 6098 * to the individual cpus
5700 */ 6099 */
5701void build_sched_domains(const cpumask_t *cpu_map) 6100static int build_sched_domains(const cpumask_t *cpu_map)
5702{ 6101{
5703 int i; 6102 int i;
6103 struct sched_group *sched_group_phys = NULL;
6104#ifdef CONFIG_SCHED_MC
6105 struct sched_group *sched_group_core = NULL;
6106#endif
5704#ifdef CONFIG_NUMA 6107#ifdef CONFIG_NUMA
5705 struct sched_group **sched_group_nodes = NULL; 6108 struct sched_group **sched_group_nodes = NULL;
5706 struct sched_group *sched_group_allnodes = NULL; 6109 struct sched_group *sched_group_allnodes = NULL;
@@ -5708,11 +6111,11 @@ void build_sched_domains(const cpumask_t *cpu_map)
5708 /* 6111 /*
5709 * Allocate the per-node list of sched groups 6112 * Allocate the per-node list of sched groups
5710 */ 6113 */
5711 sched_group_nodes = kmalloc(sizeof(struct sched_group*)*MAX_NUMNODES, 6114 sched_group_nodes = kzalloc(sizeof(struct sched_group*)*MAX_NUMNODES,
5712 GFP_ATOMIC); 6115 GFP_KERNEL);
5713 if (!sched_group_nodes) { 6116 if (!sched_group_nodes) {
5714 printk(KERN_WARNING "Can not alloc sched group node list\n"); 6117 printk(KERN_WARNING "Can not alloc sched group node list\n");
5715 return; 6118 return -ENOMEM;
5716 } 6119 }
5717 sched_group_nodes_bycpu[first_cpu(*cpu_map)] = sched_group_nodes; 6120 sched_group_nodes_bycpu[first_cpu(*cpu_map)] = sched_group_nodes;
5718#endif 6121#endif
@@ -5738,7 +6141,7 @@ void build_sched_domains(const cpumask_t *cpu_map)
5738 if (!sched_group_allnodes) { 6141 if (!sched_group_allnodes) {
5739 printk(KERN_WARNING 6142 printk(KERN_WARNING
5740 "Can not alloc allnodes sched group\n"); 6143 "Can not alloc allnodes sched group\n");
5741 break; 6144 goto error;
5742 } 6145 }
5743 sched_group_allnodes_bycpu[i] 6146 sched_group_allnodes_bycpu[i]
5744 = sched_group_allnodes; 6147 = sched_group_allnodes;
@@ -5759,6 +6162,18 @@ void build_sched_domains(const cpumask_t *cpu_map)
5759 cpus_and(sd->span, sd->span, *cpu_map); 6162 cpus_and(sd->span, sd->span, *cpu_map);
5760#endif 6163#endif
5761 6164
6165 if (!sched_group_phys) {
6166 sched_group_phys
6167 = kmalloc(sizeof(struct sched_group) * NR_CPUS,
6168 GFP_KERNEL);
6169 if (!sched_group_phys) {
6170 printk (KERN_WARNING "Can not alloc phys sched"
6171 "group\n");
6172 goto error;
6173 }
6174 sched_group_phys_bycpu[i] = sched_group_phys;
6175 }
6176
5762 p = sd; 6177 p = sd;
5763 sd = &per_cpu(phys_domains, i); 6178 sd = &per_cpu(phys_domains, i);
5764 group = cpu_to_phys_group(i); 6179 group = cpu_to_phys_group(i);
@@ -5768,6 +6183,18 @@ void build_sched_domains(const cpumask_t *cpu_map)
5768 sd->groups = &sched_group_phys[group]; 6183 sd->groups = &sched_group_phys[group];
5769 6184
5770#ifdef CONFIG_SCHED_MC 6185#ifdef CONFIG_SCHED_MC
6186 if (!sched_group_core) {
6187 sched_group_core
6188 = kmalloc(sizeof(struct sched_group) * NR_CPUS,
6189 GFP_KERNEL);
6190 if (!sched_group_core) {
6191 printk (KERN_WARNING "Can not alloc core sched"
6192 "group\n");
6193 goto error;
6194 }
6195 sched_group_core_bycpu[i] = sched_group_core;
6196 }
6197
5771 p = sd; 6198 p = sd;
5772 sd = &per_cpu(core_domains, i); 6199 sd = &per_cpu(core_domains, i);
5773 group = cpu_to_core_group(i); 6200 group = cpu_to_core_group(i);
@@ -5851,24 +6278,21 @@ void build_sched_domains(const cpumask_t *cpu_map)
5851 domainspan = sched_domain_node_span(i); 6278 domainspan = sched_domain_node_span(i);
5852 cpus_and(domainspan, domainspan, *cpu_map); 6279 cpus_and(domainspan, domainspan, *cpu_map);
5853 6280
5854 sg = kmalloc(sizeof(struct sched_group), GFP_KERNEL); 6281 sg = kmalloc_node(sizeof(struct sched_group), GFP_KERNEL, i);
6282 if (!sg) {
6283 printk(KERN_WARNING "Can not alloc domain group for "
6284 "node %d\n", i);
6285 goto error;
6286 }
5855 sched_group_nodes[i] = sg; 6287 sched_group_nodes[i] = sg;
5856 for_each_cpu_mask(j, nodemask) { 6288 for_each_cpu_mask(j, nodemask) {
5857 struct sched_domain *sd; 6289 struct sched_domain *sd;
5858 sd = &per_cpu(node_domains, j); 6290 sd = &per_cpu(node_domains, j);
5859 sd->groups = sg; 6291 sd->groups = sg;
5860 if (sd->groups == NULL) {
5861 /* Turn off balancing if we have no groups */
5862 sd->flags = 0;
5863 }
5864 }
5865 if (!sg) {
5866 printk(KERN_WARNING
5867 "Can not alloc domain group for node %d\n", i);
5868 continue;
5869 } 6292 }
5870 sg->cpu_power = 0; 6293 sg->cpu_power = 0;
5871 sg->cpumask = nodemask; 6294 sg->cpumask = nodemask;
6295 sg->next = sg;
5872 cpus_or(covered, covered, nodemask); 6296 cpus_or(covered, covered, nodemask);
5873 prev = sg; 6297 prev = sg;
5874 6298
@@ -5887,54 +6311,90 @@ void build_sched_domains(const cpumask_t *cpu_map)
5887 if (cpus_empty(tmp)) 6311 if (cpus_empty(tmp))
5888 continue; 6312 continue;
5889 6313
5890 sg = kmalloc(sizeof(struct sched_group), GFP_KERNEL); 6314 sg = kmalloc_node(sizeof(struct sched_group),
6315 GFP_KERNEL, i);
5891 if (!sg) { 6316 if (!sg) {
5892 printk(KERN_WARNING 6317 printk(KERN_WARNING
5893 "Can not alloc domain group for node %d\n", j); 6318 "Can not alloc domain group for node %d\n", j);
5894 break; 6319 goto error;
5895 } 6320 }
5896 sg->cpu_power = 0; 6321 sg->cpu_power = 0;
5897 sg->cpumask = tmp; 6322 sg->cpumask = tmp;
6323 sg->next = prev->next;
5898 cpus_or(covered, covered, tmp); 6324 cpus_or(covered, covered, tmp);
5899 prev->next = sg; 6325 prev->next = sg;
5900 prev = sg; 6326 prev = sg;
5901 } 6327 }
5902 prev->next = sched_group_nodes[i];
5903 } 6328 }
5904#endif 6329#endif
5905 6330
5906 /* Calculate CPU power for physical packages and nodes */ 6331 /* Calculate CPU power for physical packages and nodes */
6332#ifdef CONFIG_SCHED_SMT
5907 for_each_cpu_mask(i, *cpu_map) { 6333 for_each_cpu_mask(i, *cpu_map) {
5908 int power;
5909 struct sched_domain *sd; 6334 struct sched_domain *sd;
5910#ifdef CONFIG_SCHED_SMT
5911 sd = &per_cpu(cpu_domains, i); 6335 sd = &per_cpu(cpu_domains, i);
5912 power = SCHED_LOAD_SCALE; 6336 sd->groups->cpu_power = SCHED_LOAD_SCALE;
5913 sd->groups->cpu_power = power; 6337 }
5914#endif 6338#endif
5915#ifdef CONFIG_SCHED_MC 6339#ifdef CONFIG_SCHED_MC
6340 for_each_cpu_mask(i, *cpu_map) {
6341 int power;
6342 struct sched_domain *sd;
5916 sd = &per_cpu(core_domains, i); 6343 sd = &per_cpu(core_domains, i);
5917 power = SCHED_LOAD_SCALE + (cpus_weight(sd->groups->cpumask)-1) 6344 if (sched_smt_power_savings)
6345 power = SCHED_LOAD_SCALE * cpus_weight(sd->groups->cpumask);
6346 else
6347 power = SCHED_LOAD_SCALE + (cpus_weight(sd->groups->cpumask)-1)
5918 * SCHED_LOAD_SCALE / 10; 6348 * SCHED_LOAD_SCALE / 10;
5919 sd->groups->cpu_power = power; 6349 sd->groups->cpu_power = power;
6350 }
6351#endif
5920 6352
6353 for_each_cpu_mask(i, *cpu_map) {
6354 struct sched_domain *sd;
6355#ifdef CONFIG_SCHED_MC
5921 sd = &per_cpu(phys_domains, i); 6356 sd = &per_cpu(phys_domains, i);
6357 if (i != first_cpu(sd->groups->cpumask))
6358 continue;
5922 6359
5923 /* 6360 sd->groups->cpu_power = 0;
5924 * This has to be < 2 * SCHED_LOAD_SCALE 6361 if (sched_mc_power_savings || sched_smt_power_savings) {
5925 * Lets keep it SCHED_LOAD_SCALE, so that 6362 int j;
5926 * while calculating NUMA group's cpu_power 6363
5927 * we can simply do 6364 for_each_cpu_mask(j, sd->groups->cpumask) {
5928 * numa_group->cpu_power += phys_group->cpu_power; 6365 struct sched_domain *sd1;
5929 * 6366 sd1 = &per_cpu(core_domains, j);
5930 * See "only add power once for each physical pkg" 6367 /*
5931 * comment below 6368 * for each core we will add once
5932 */ 6369 * to the group in physical domain
5933 sd->groups->cpu_power = SCHED_LOAD_SCALE; 6370 */
6371 if (j != first_cpu(sd1->groups->cpumask))
6372 continue;
6373
6374 if (sched_smt_power_savings)
6375 sd->groups->cpu_power += sd1->groups->cpu_power;
6376 else
6377 sd->groups->cpu_power += SCHED_LOAD_SCALE;
6378 }
6379 } else
6380 /*
6381 * This has to be < 2 * SCHED_LOAD_SCALE
6382 * Lets keep it SCHED_LOAD_SCALE, so that
6383 * while calculating NUMA group's cpu_power
6384 * we can simply do
6385 * numa_group->cpu_power += phys_group->cpu_power;
6386 *
6387 * See "only add power once for each physical pkg"
6388 * comment below
6389 */
6390 sd->groups->cpu_power = SCHED_LOAD_SCALE;
5934#else 6391#else
6392 int power;
5935 sd = &per_cpu(phys_domains, i); 6393 sd = &per_cpu(phys_domains, i);
5936 power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE * 6394 if (sched_smt_power_savings)
5937 (cpus_weight(sd->groups->cpumask)-1) / 10; 6395 power = SCHED_LOAD_SCALE * cpus_weight(sd->groups->cpumask);
6396 else
6397 power = SCHED_LOAD_SCALE;
5938 sd->groups->cpu_power = power; 6398 sd->groups->cpu_power = power;
5939#endif 6399#endif
5940 } 6400 }
@@ -5962,13 +6422,20 @@ void build_sched_domains(const cpumask_t *cpu_map)
5962 * Tune cache-hot values: 6422 * Tune cache-hot values:
5963 */ 6423 */
5964 calibrate_migration_costs(cpu_map); 6424 calibrate_migration_costs(cpu_map);
6425
6426 return 0;
6427
6428error:
6429 free_sched_groups(cpu_map);
6430 return -ENOMEM;
5965} 6431}
5966/* 6432/*
5967 * Set up scheduler domains and groups. Callers must hold the hotplug lock. 6433 * Set up scheduler domains and groups. Callers must hold the hotplug lock.
5968 */ 6434 */
5969static void arch_init_sched_domains(const cpumask_t *cpu_map) 6435static int arch_init_sched_domains(const cpumask_t *cpu_map)
5970{ 6436{
5971 cpumask_t cpu_default_map; 6437 cpumask_t cpu_default_map;
6438 int err;
5972 6439
5973 /* 6440 /*
5974 * Setup mask for cpus without special case scheduling requirements. 6441 * Setup mask for cpus without special case scheduling requirements.
@@ -5977,51 +6444,14 @@ static void arch_init_sched_domains(const cpumask_t *cpu_map)
5977 */ 6444 */
5978 cpus_andnot(cpu_default_map, *cpu_map, cpu_isolated_map); 6445 cpus_andnot(cpu_default_map, *cpu_map, cpu_isolated_map);
5979 6446
5980 build_sched_domains(&cpu_default_map); 6447 err = build_sched_domains(&cpu_default_map);
6448
6449 return err;
5981} 6450}
5982 6451
5983static void arch_destroy_sched_domains(const cpumask_t *cpu_map) 6452static void arch_destroy_sched_domains(const cpumask_t *cpu_map)
5984{ 6453{
5985#ifdef CONFIG_NUMA 6454 free_sched_groups(cpu_map);
5986 int i;
5987 int cpu;
5988
5989 for_each_cpu_mask(cpu, *cpu_map) {
5990 struct sched_group *sched_group_allnodes
5991 = sched_group_allnodes_bycpu[cpu];
5992 struct sched_group **sched_group_nodes
5993 = sched_group_nodes_bycpu[cpu];
5994
5995 if (sched_group_allnodes) {
5996 kfree(sched_group_allnodes);
5997 sched_group_allnodes_bycpu[cpu] = NULL;
5998 }
5999
6000 if (!sched_group_nodes)
6001 continue;
6002
6003 for (i = 0; i < MAX_NUMNODES; i++) {
6004 cpumask_t nodemask = node_to_cpumask(i);
6005 struct sched_group *oldsg, *sg = sched_group_nodes[i];
6006
6007 cpus_and(nodemask, nodemask, *cpu_map);
6008 if (cpus_empty(nodemask))
6009 continue;
6010
6011 if (sg == NULL)
6012 continue;
6013 sg = sg->next;
6014next_sg:
6015 oldsg = sg;
6016 sg = sg->next;
6017 kfree(oldsg);
6018 if (oldsg != sched_group_nodes[i])
6019 goto next_sg;
6020 }
6021 kfree(sched_group_nodes);
6022 sched_group_nodes_bycpu[cpu] = NULL;
6023 }
6024#endif
6025} 6455}
6026 6456
6027/* 6457/*
@@ -6046,9 +6476,10 @@ static void detach_destroy_domains(const cpumask_t *cpu_map)
6046 * correct sched domains 6476 * correct sched domains
6047 * Call with hotplug lock held 6477 * Call with hotplug lock held
6048 */ 6478 */
6049void partition_sched_domains(cpumask_t *partition1, cpumask_t *partition2) 6479int partition_sched_domains(cpumask_t *partition1, cpumask_t *partition2)
6050{ 6480{
6051 cpumask_t change_map; 6481 cpumask_t change_map;
6482 int err = 0;
6052 6483
6053 cpus_and(*partition1, *partition1, cpu_online_map); 6484 cpus_and(*partition1, *partition1, cpu_online_map);
6054 cpus_and(*partition2, *partition2, cpu_online_map); 6485 cpus_and(*partition2, *partition2, cpu_online_map);
@@ -6057,10 +6488,86 @@ void partition_sched_domains(cpumask_t *partition1, cpumask_t *partition2)
6057 /* Detach sched domains from all of the affected cpus */ 6488 /* Detach sched domains from all of the affected cpus */
6058 detach_destroy_domains(&change_map); 6489 detach_destroy_domains(&change_map);
6059 if (!cpus_empty(*partition1)) 6490 if (!cpus_empty(*partition1))
6060 build_sched_domains(partition1); 6491 err = build_sched_domains(partition1);
6061 if (!cpus_empty(*partition2)) 6492 if (!err && !cpus_empty(*partition2))
6062 build_sched_domains(partition2); 6493 err = build_sched_domains(partition2);
6494
6495 return err;
6496}
6497
6498#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
6499int arch_reinit_sched_domains(void)
6500{
6501 int err;
6502
6503 lock_cpu_hotplug();
6504 detach_destroy_domains(&cpu_online_map);
6505 err = arch_init_sched_domains(&cpu_online_map);
6506 unlock_cpu_hotplug();
6507
6508 return err;
6509}
6510
6511static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt)
6512{
6513 int ret;
6514
6515 if (buf[0] != '0' && buf[0] != '1')
6516 return -EINVAL;
6517
6518 if (smt)
6519 sched_smt_power_savings = (buf[0] == '1');
6520 else
6521 sched_mc_power_savings = (buf[0] == '1');
6522
6523 ret = arch_reinit_sched_domains();
6524
6525 return ret ? ret : count;
6526}
6527
6528int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls)
6529{
6530 int err = 0;
6531#ifdef CONFIG_SCHED_SMT
6532 if (smt_capable())
6533 err = sysfs_create_file(&cls->kset.kobj,
6534 &attr_sched_smt_power_savings.attr);
6535#endif
6536#ifdef CONFIG_SCHED_MC
6537 if (!err && mc_capable())
6538 err = sysfs_create_file(&cls->kset.kobj,
6539 &attr_sched_mc_power_savings.attr);
6540#endif
6541 return err;
6542}
6543#endif
6544
6545#ifdef CONFIG_SCHED_MC
6546static ssize_t sched_mc_power_savings_show(struct sys_device *dev, char *page)
6547{
6548 return sprintf(page, "%u\n", sched_mc_power_savings);
6549}
6550static ssize_t sched_mc_power_savings_store(struct sys_device *dev, const char *buf, size_t count)
6551{
6552 return sched_power_savings_store(buf, count, 0);
6553}
6554SYSDEV_ATTR(sched_mc_power_savings, 0644, sched_mc_power_savings_show,
6555 sched_mc_power_savings_store);
6556#endif
6557
6558#ifdef CONFIG_SCHED_SMT
6559static ssize_t sched_smt_power_savings_show(struct sys_device *dev, char *page)
6560{
6561 return sprintf(page, "%u\n", sched_smt_power_savings);
6562}
6563static ssize_t sched_smt_power_savings_store(struct sys_device *dev, const char *buf, size_t count)
6564{
6565 return sched_power_savings_store(buf, count, 1);
6063} 6566}
6567SYSDEV_ATTR(sched_smt_power_savings, 0644, sched_smt_power_savings_show,
6568 sched_smt_power_savings_store);
6569#endif
6570
6064 6571
6065#ifdef CONFIG_HOTPLUG_CPU 6572#ifdef CONFIG_HOTPLUG_CPU
6066/* 6573/*
@@ -6143,7 +6650,6 @@ void __init sched_init(void)
6143 rq->push_cpu = 0; 6650 rq->push_cpu = 0;
6144 rq->migration_thread = NULL; 6651 rq->migration_thread = NULL;
6145 INIT_LIST_HEAD(&rq->migration_queue); 6652 INIT_LIST_HEAD(&rq->migration_queue);
6146 rq->cpu = i;
6147#endif 6653#endif
6148 atomic_set(&rq->nr_iowait, 0); 6654 atomic_set(&rq->nr_iowait, 0);
6149 6655
@@ -6158,6 +6664,7 @@ void __init sched_init(void)
6158 } 6664 }
6159 } 6665 }
6160 6666
6667 set_load_weight(&init_task);
6161 /* 6668 /*
6162 * The boot idle thread does lazy MMU switching as well: 6669 * The boot idle thread does lazy MMU switching as well:
6163 */ 6670 */
@@ -6204,11 +6711,12 @@ void normalize_rt_tasks(void)
6204 runqueue_t *rq; 6711 runqueue_t *rq;
6205 6712
6206 read_lock_irq(&tasklist_lock); 6713 read_lock_irq(&tasklist_lock);
6207 for_each_process (p) { 6714 for_each_process(p) {
6208 if (!rt_task(p)) 6715 if (!rt_task(p))
6209 continue; 6716 continue;
6210 6717
6211 rq = task_rq_lock(p, &flags); 6718 spin_lock_irqsave(&p->pi_lock, flags);
6719 rq = __task_rq_lock(p);
6212 6720
6213 array = p->array; 6721 array = p->array;
6214 if (array) 6722 if (array)
@@ -6219,7 +6727,8 @@ void normalize_rt_tasks(void)
6219 resched_task(rq->curr); 6727 resched_task(rq->curr);
6220 } 6728 }
6221 6729
6222 task_rq_unlock(rq, &flags); 6730 __task_rq_unlock(rq);
6731 spin_unlock_irqrestore(&p->pi_lock, flags);
6223 } 6732 }
6224 read_unlock_irq(&tasklist_lock); 6733 read_unlock_irq(&tasklist_lock);
6225} 6734}
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 9e2f1c6e73d7..8f03e3b89b55 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -446,7 +446,7 @@ static void takeover_tasklets(unsigned int cpu)
446} 446}
447#endif /* CONFIG_HOTPLUG_CPU */ 447#endif /* CONFIG_HOTPLUG_CPU */
448 448
449static int cpu_callback(struct notifier_block *nfb, 449static int __devinit cpu_callback(struct notifier_block *nfb,
450 unsigned long action, 450 unsigned long action,
451 void *hcpu) 451 void *hcpu)
452{ 452{
@@ -486,7 +486,7 @@ static int cpu_callback(struct notifier_block *nfb,
486 return NOTIFY_OK; 486 return NOTIFY_OK;
487} 487}
488 488
489static struct notifier_block cpu_nfb = { 489static struct notifier_block __devinitdata cpu_nfb = {
490 .notifier_call = cpu_callback 490 .notifier_call = cpu_callback
491}; 491};
492 492
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index b5c3b94e01ce..6b76caa22981 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -104,7 +104,7 @@ static int watchdog(void * __bind_cpu)
104/* 104/*
105 * Create/destroy watchdog threads as CPUs come and go: 105 * Create/destroy watchdog threads as CPUs come and go:
106 */ 106 */
107static int 107static int __devinit
108cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 108cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
109{ 109{
110 int hotcpu = (unsigned long)hcpu; 110 int hotcpu = (unsigned long)hcpu;
@@ -142,7 +142,7 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
142 return NOTIFY_OK; 142 return NOTIFY_OK;
143} 143}
144 144
145static struct notifier_block cpu_nfb = { 145static struct notifier_block __devinitdata cpu_nfb = {
146 .notifier_call = cpu_callback 146 .notifier_call = cpu_callback
147}; 147};
148 148
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index f1a4eb1a655e..93a2c5398648 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -133,6 +133,10 @@ extern int acct_parm[];
133extern int no_unaligned_warning; 133extern int no_unaligned_warning;
134#endif 134#endif
135 135
136#ifdef CONFIG_RT_MUTEXES
137extern int max_lock_depth;
138#endif
139
136static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 140static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
137 ctl_table *, void **); 141 ctl_table *, void **);
138static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 142static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
@@ -688,6 +692,17 @@ static ctl_table kern_table[] = {
688 .proc_handler = &proc_dointvec, 692 .proc_handler = &proc_dointvec,
689 }, 693 },
690#endif 694#endif
695#ifdef CONFIG_RT_MUTEXES
696 {
697 .ctl_name = KERN_MAX_LOCK_DEPTH,
698 .procname = "max_lock_depth",
699 .data = &max_lock_depth,
700 .maxlen = sizeof(int),
701 .mode = 0644,
702 .proc_handler = &proc_dointvec,
703 },
704#endif
705
691 { .ctl_name = 0 } 706 { .ctl_name = 0 }
692}; 707};
693 708
@@ -928,6 +943,18 @@ static ctl_table vm_table[] = {
928 .strategy = &sysctl_jiffies, 943 .strategy = &sysctl_jiffies,
929 }, 944 },
930#endif 945#endif
946#ifdef CONFIG_X86_32
947 {
948 .ctl_name = VM_VDSO_ENABLED,
949 .procname = "vdso_enabled",
950 .data = &vdso_enabled,
951 .maxlen = sizeof(vdso_enabled),
952 .mode = 0644,
953 .proc_handler = &proc_dointvec,
954 .strategy = &sysctl_intvec,
955 .extra1 = &zero,
956 },
957#endif
931 { .ctl_name = 0 } 958 { .ctl_name = 0 }
932}; 959};
933 960
diff --git a/kernel/timer.c b/kernel/timer.c
index 5bb6b7976eec..5a8960253063 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1652,7 +1652,7 @@ static void __devinit migrate_timers(int cpu)
1652} 1652}
1653#endif /* CONFIG_HOTPLUG_CPU */ 1653#endif /* CONFIG_HOTPLUG_CPU */
1654 1654
1655static int timer_cpu_notify(struct notifier_block *self, 1655static int __devinit timer_cpu_notify(struct notifier_block *self,
1656 unsigned long action, void *hcpu) 1656 unsigned long action, void *hcpu)
1657{ 1657{
1658 long cpu = (long)hcpu; 1658 long cpu = (long)hcpu;
@@ -1672,7 +1672,7 @@ static int timer_cpu_notify(struct notifier_block *self,
1672 return NOTIFY_OK; 1672 return NOTIFY_OK;
1673} 1673}
1674 1674
1675static struct notifier_block timers_nb = { 1675static struct notifier_block __devinitdata timers_nb = {
1676 .notifier_call = timer_cpu_notify, 1676 .notifier_call = timer_cpu_notify,
1677}; 1677};
1678 1678
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 565cf7a1febd..59f0b42bd89e 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -559,7 +559,7 @@ static void take_over_work(struct workqueue_struct *wq, unsigned int cpu)
559} 559}
560 560
561/* We're holding the cpucontrol mutex here */ 561/* We're holding the cpucontrol mutex here */
562static int workqueue_cpu_callback(struct notifier_block *nfb, 562static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
563 unsigned long action, 563 unsigned long action,
564 void *hcpu) 564 void *hcpu)
565{ 565{
diff --git a/lib/Kconfig b/lib/Kconfig
index 3de93357f5ab..f6299342b882 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -86,4 +86,10 @@ config TEXTSEARCH_BM
86config TEXTSEARCH_FSM 86config TEXTSEARCH_FSM
87 tristate 87 tristate
88 88
89#
90# plist support is select#ed if needed
91#
92config PLIST
93 boolean
94
89endmenu 95endmenu
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 8bab0102ac73..e4fcbd12cf6e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -23,6 +23,22 @@ config MAGIC_SYSRQ
23 keys are documented in <file:Documentation/sysrq.txt>. Don't say Y 23 keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
24 unless you really know what this hack does. 24 unless you really know what this hack does.
25 25
26config UNUSED_SYMBOLS
27 bool "Enable unused/obsolete exported symbols"
28 default y if X86
29 help
30 Unused but exported symbols make the kernel needlessly bigger. For
31 that reason most of these unused exports will soon be removed. This
32 option is provided temporarily to provide a transition period in case
33 some external kernel module needs one of these symbols anyway. If you
34 encounter such a case in your module, consider if you are actually
35 using the right API. (rationale: since nobody in the kernel is using
36 this in a module, there is a pretty good chance it's actually the
37 wrong interface to use). If you really need the symbol, please send a
38 mail to the linux kernel mailing list mentioning the symbol and why
39 you really need it, and what the merge plan to the mainline kernel for
40 your module is.
41
26config DEBUG_KERNEL 42config DEBUG_KERNEL
27 bool "Kernel debugging" 43 bool "Kernel debugging"
28 help 44 help
@@ -107,6 +123,24 @@ config DEBUG_MUTEXES
107 This allows mutex semantics violations and mutex related deadlocks 123 This allows mutex semantics violations and mutex related deadlocks
108 (lockups) to be detected and reported automatically. 124 (lockups) to be detected and reported automatically.
109 125
126config DEBUG_RT_MUTEXES
127 bool "RT Mutex debugging, deadlock detection"
128 depends on DEBUG_KERNEL && RT_MUTEXES
129 help
130 This allows rt mutex semantics violations and rt mutex related
131 deadlocks (lockups) to be detected and reported automatically.
132
133config DEBUG_PI_LIST
134 bool
135 default y
136 depends on DEBUG_RT_MUTEXES
137
138config RT_MUTEX_TESTER
139 bool "Built-in scriptable tester for rt-mutexes"
140 depends on DEBUG_KERNEL && RT_MUTEXES
141 help
142 This option enables a rt-mutex tester.
143
110config DEBUG_SPINLOCK 144config DEBUG_SPINLOCK
111 bool "Spinlock debugging" 145 bool "Spinlock debugging"
112 depends on DEBUG_KERNEL 146 depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 79358ad1f113..10c13c9d7824 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -25,6 +25,7 @@ lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o
25lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o 25lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
26lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 26lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
27obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o 27obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
28obj-$(CONFIG_PLIST) += plist.o
28obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o 29obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
29 30
30ifneq ($(CONFIG_HAVE_DEC_LOCK),y) 31ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
diff --git a/lib/plist.c b/lib/plist.c
new file mode 100644
index 000000000000..3074a02272f3
--- /dev/null
+++ b/lib/plist.c
@@ -0,0 +1,118 @@
1/*
2 * lib/plist.c
3 *
4 * Descending-priority-sorted double-linked list
5 *
6 * (C) 2002-2003 Intel Corp
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>.
8 *
9 * 2001-2005 (c) MontaVista Software, Inc.
10 * Daniel Walker <dwalker@mvista.com>
11 *
12 * (C) 2005 Thomas Gleixner <tglx@linutronix.de>
13 *
14 * Simplifications of the original code by
15 * Oleg Nesterov <oleg@tv-sign.ru>
16 *
17 * Licensed under the FSF's GNU Public License v2 or later.
18 *
19 * Based on simple lists (include/linux/list.h).
20 *
21 * This file contains the add / del functions which are considered to
22 * be too large to inline. See include/linux/plist.h for further
23 * information.
24 */
25
26#include <linux/plist.h>
27#include <linux/spinlock.h>
28
29#ifdef CONFIG_DEBUG_PI_LIST
30
31static void plist_check_prev_next(struct list_head *t, struct list_head *p,
32 struct list_head *n)
33{
34 if (n->prev != p || p->next != n) {
35 printk("top: %p, n: %p, p: %p\n", t, t->next, t->prev);
36 printk("prev: %p, n: %p, p: %p\n", p, p->next, p->prev);
37 printk("next: %p, n: %p, p: %p\n", n, n->next, n->prev);
38 WARN_ON(1);
39 }
40}
41
42static void plist_check_list(struct list_head *top)
43{
44 struct list_head *prev = top, *next = top->next;
45
46 plist_check_prev_next(top, prev, next);
47 while (next != top) {
48 prev = next;
49 next = prev->next;
50 plist_check_prev_next(top, prev, next);
51 }
52}
53
54static void plist_check_head(struct plist_head *head)
55{
56 WARN_ON(!head->lock);
57 if (head->lock)
58 WARN_ON_SMP(!spin_is_locked(head->lock));
59 plist_check_list(&head->prio_list);
60 plist_check_list(&head->node_list);
61}
62
63#else
64# define plist_check_head(h) do { } while (0)
65#endif
66
67/**
68 * plist_add - add @node to @head
69 *
70 * @node: &struct plist_node pointer
71 * @head: &struct plist_head pointer
72 */
73void plist_add(struct plist_node *node, struct plist_head *head)
74{
75 struct plist_node *iter;
76
77 plist_check_head(head);
78 WARN_ON(!plist_node_empty(node));
79
80 list_for_each_entry(iter, &head->prio_list, plist.prio_list) {
81 if (node->prio < iter->prio)
82 goto lt_prio;
83 else if (node->prio == iter->prio) {
84 iter = list_entry(iter->plist.prio_list.next,
85 struct plist_node, plist.prio_list);
86 goto eq_prio;
87 }
88 }
89
90lt_prio:
91 list_add_tail(&node->plist.prio_list, &iter->plist.prio_list);
92eq_prio:
93 list_add_tail(&node->plist.node_list, &iter->plist.node_list);
94
95 plist_check_head(head);
96}
97
98/**
99 * plist_del - Remove a @node from plist.
100 *
101 * @node: &struct plist_node pointer - entry to be removed
102 * @head: &struct plist_head pointer - list head
103 */
104void plist_del(struct plist_node *node, struct plist_head *head)
105{
106 plist_check_head(head);
107
108 if (!list_empty(&node->plist.prio_list)) {
109 struct plist_node *next = plist_first(&node->plist);
110
111 list_move_tail(&next->plist.prio_list, &node->plist.prio_list);
112 list_del_init(&node->plist.prio_list);
113 }
114
115 list_del_init(&node->plist.node_list);
116
117 plist_check_head(head);
118}
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 797428afd111..bed7229378f2 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -489,7 +489,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
489 if (str < end) 489 if (str < end)
490 *str = '\0'; 490 *str = '\0';
491 else 491 else
492 *end = '\0'; 492 end[-1] = '\0';
493 } 493 }
494 /* the trailing null byte doesn't count towards the total */ 494 /* the trailing null byte doesn't count towards the total */
495 return str-buf; 495 return str-buf;
diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c
index 02a16eacb72d..d84560c076d8 100644
--- a/lib/zlib_inflate/inffast.c
+++ b/lib/zlib_inflate/inffast.c
@@ -63,10 +63,10 @@
63 bytes, which is the maximum length that can be coded. inflate_fast() 63 bytes, which is the maximum length that can be coded. inflate_fast()
64 requires strm->avail_out >= 258 for each loop to avoid checking for 64 requires strm->avail_out >= 258 for each loop to avoid checking for
65 output space. 65 output space.
66
67 - @start: inflate()'s starting value for strm->avail_out
66 */ 68 */
67void inflate_fast(strm, start) 69void inflate_fast(z_streamp strm, unsigned start)
68z_streamp strm;
69unsigned start; /* inflate()'s starting value for strm->avail_out */
70{ 70{
71 struct inflate_state *state; 71 struct inflate_state *state;
72 unsigned char *in; /* local strm->next_in */ 72 unsigned char *in; /* local strm->next_in */
diff --git a/lib/zlib_inflate/inftrees.c b/lib/zlib_inflate/inftrees.c
index da665fbb16aa..3fe6ce5b53e5 100644
--- a/lib/zlib_inflate/inftrees.c
+++ b/lib/zlib_inflate/inftrees.c
@@ -20,13 +20,8 @@
20 table index bits. It will differ if the request is greater than the 20 table index bits. It will differ if the request is greater than the
21 longest code or if it is less than the shortest code. 21 longest code or if it is less than the shortest code.
22 */ 22 */
23int zlib_inflate_table(type, lens, codes, table, bits, work) 23int zlib_inflate_table(codetype type, unsigned short *lens, unsigned codes,
24codetype type; 24 code **table, unsigned *bits, unsigned short *work)
25unsigned short *lens;
26unsigned codes;
27code **table;
28unsigned *bits;
29unsigned short *work;
30{ 25{
31 unsigned len; /* a code's length in bits */ 26 unsigned len; /* a code's length in bits */
32 unsigned sym; /* index of code symbols */ 27 unsigned sym; /* index of code symbols */
diff --git a/mm/Kconfig b/mm/Kconfig
index 66e65ab39426..8f5b45615f7b 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -115,7 +115,8 @@ config SPARSEMEM_EXTREME
115# eventually, we can have this option just 'select SPARSEMEM' 115# eventually, we can have this option just 'select SPARSEMEM'
116config MEMORY_HOTPLUG 116config MEMORY_HOTPLUG
117 bool "Allow for memory hot-add" 117 bool "Allow for memory hot-add"
118 depends on SPARSEMEM && HOTPLUG && !SOFTWARE_SUSPEND 118 depends on SPARSEMEM && HOTPLUG && !SOFTWARE_SUSPEND && ARCH_ENABLE_MEMORY_HOTPLUG
119 depends on (IA64 || X86 || PPC64)
119 120
120comment "Memory hotplug is currently incompatible with Software Suspend" 121comment "Memory hotplug is currently incompatible with Software Suspend"
121 depends on SPARSEMEM && HOTPLUG && SOFTWARE_SUSPEND 122 depends on SPARSEMEM && HOTPLUG && SOFTWARE_SUSPEND
@@ -145,3 +146,9 @@ config MIGRATION
145 while the virtual addresses are not changed. This is useful for 146 while the virtual addresses are not changed. This is useful for
146 example on NUMA systems to put pages nearer to the processors accessing 147 example on NUMA systems to put pages nearer to the processors accessing
147 the page. 148 the page.
149
150config RESOURCES_64BIT
151 bool "64 bit Memory and IO resources (EXPERIMENTAL)" if (!64BIT && EXPERIMENTAL)
152 default 64BIT
153 help
154 This option allows memory and IO resources to be 64 bit.
diff --git a/mm/filemap.c b/mm/filemap.c
index 9c7334bafda8..648f2c0c8e18 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2069,7 +2069,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2069{ 2069{
2070 struct file *file = iocb->ki_filp; 2070 struct file *file = iocb->ki_filp;
2071 struct address_space * mapping = file->f_mapping; 2071 struct address_space * mapping = file->f_mapping;
2072 struct address_space_operations *a_ops = mapping->a_ops; 2072 const struct address_space_operations *a_ops = mapping->a_ops;
2073 struct inode *inode = mapping->host; 2073 struct inode *inode = mapping->host;
2074 long status = 0; 2074 long status = 0;
2075 struct page *page; 2075 struct page *page;
@@ -2095,14 +2095,21 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2095 do { 2095 do {
2096 unsigned long index; 2096 unsigned long index;
2097 unsigned long offset; 2097 unsigned long offset;
2098 unsigned long maxlen;
2099 size_t copied; 2098 size_t copied;
2100 2099
2101 offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ 2100 offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */
2102 index = pos >> PAGE_CACHE_SHIFT; 2101 index = pos >> PAGE_CACHE_SHIFT;
2103 bytes = PAGE_CACHE_SIZE - offset; 2102 bytes = PAGE_CACHE_SIZE - offset;
2104 if (bytes > count) 2103
2105 bytes = count; 2104 /* Limit the size of the copy to the caller's write size */
2105 bytes = min(bytes, count);
2106
2107 /*
2108 * Limit the size of the copy to that of the current segment,
2109 * because fault_in_pages_readable() doesn't know how to walk
2110 * segments.
2111 */
2112 bytes = min(bytes, cur_iov->iov_len - iov_base);
2106 2113
2107 /* 2114 /*
2108 * Bring in the user page that we will copy from _first_. 2115 * Bring in the user page that we will copy from _first_.
@@ -2110,10 +2117,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2110 * same page as we're writing to, without it being marked 2117 * same page as we're writing to, without it being marked
2111 * up-to-date. 2118 * up-to-date.
2112 */ 2119 */
2113 maxlen = cur_iov->iov_len - iov_base; 2120 fault_in_pages_readable(buf, bytes);
2114 if (maxlen > bytes)
2115 maxlen = bytes;
2116 fault_in_pages_readable(buf, maxlen);
2117 2121
2118 page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); 2122 page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec);
2119 if (!page) { 2123 if (!page) {
@@ -2121,6 +2125,12 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2121 break; 2125 break;
2122 } 2126 }
2123 2127
2128 if (unlikely(bytes == 0)) {
2129 status = 0;
2130 copied = 0;
2131 goto zero_length_segment;
2132 }
2133
2124 status = a_ops->prepare_write(file, page, offset, offset+bytes); 2134 status = a_ops->prepare_write(file, page, offset, offset+bytes);
2125 if (unlikely(status)) { 2135 if (unlikely(status)) {
2126 loff_t isize = i_size_read(inode); 2136 loff_t isize = i_size_read(inode);
@@ -2150,7 +2160,8 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2150 page_cache_release(page); 2160 page_cache_release(page);
2151 continue; 2161 continue;
2152 } 2162 }
2153 if (likely(copied > 0)) { 2163zero_length_segment:
2164 if (likely(copied >= 0)) {
2154 if (!status) 2165 if (!status)
2155 status = copied; 2166 status = copied;
2156 2167
@@ -2215,7 +2226,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2215 unsigned long nr_segs, loff_t *ppos) 2226 unsigned long nr_segs, loff_t *ppos)
2216{ 2227{
2217 struct file *file = iocb->ki_filp; 2228 struct file *file = iocb->ki_filp;
2218 struct address_space * mapping = file->f_mapping; 2229 const struct address_space * mapping = file->f_mapping;
2219 size_t ocount; /* original count */ 2230 size_t ocount; /* original count */
2220 size_t count; /* after file limit checks */ 2231 size_t count; /* after file limit checks */
2221 struct inode *inode = mapping->host; 2232 struct inode *inode = mapping->host;
diff --git a/mm/filemap.h b/mm/filemap.h
index 536979fb4ba7..3f2a343c6015 100644
--- a/mm/filemap.h
+++ b/mm/filemap.h
@@ -88,7 +88,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes)
88 const struct iovec *iov = *iovp; 88 const struct iovec *iov = *iovp;
89 size_t base = *basep; 89 size_t base = *basep;
90 90
91 while (bytes) { 91 do {
92 int copy = min(bytes, iov->iov_len - base); 92 int copy = min(bytes, iov->iov_len - base);
93 93
94 bytes -= copy; 94 bytes -= copy;
@@ -97,7 +97,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes)
97 iov++; 97 iov++;
98 base = 0; 98 base = 0;
99 } 99 }
100 } 100 } while (bytes);
101 *iovp = iov; 101 *iovp = iov;
102 *basep = base; 102 *basep = base;
103} 103}
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index b960ac8e5918..b4fd0d7c9bfb 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -273,7 +273,7 @@ __xip_file_write(struct file *filp, const char __user *buf,
273 size_t count, loff_t pos, loff_t *ppos) 273 size_t count, loff_t pos, loff_t *ppos)
274{ 274{
275 struct address_space * mapping = filp->f_mapping; 275 struct address_space * mapping = filp->f_mapping;
276 struct address_space_operations *a_ops = mapping->a_ops; 276 const struct address_space_operations *a_ops = mapping->a_ops;
277 struct inode *inode = mapping->host; 277 struct inode *inode = mapping->host;
278 long status = 0; 278 long status = 0;
279 struct page *page; 279 struct page *page;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 841a077d5aeb..ea4038838b0a 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -21,6 +21,7 @@
21#include <linux/memory_hotplug.h> 21#include <linux/memory_hotplug.h>
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
24#include <linux/ioport.h>
24 25
25#include <asm/tlbflush.h> 26#include <asm/tlbflush.h>
26 27
@@ -126,6 +127,9 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
126 unsigned long i; 127 unsigned long i;
127 unsigned long flags; 128 unsigned long flags;
128 unsigned long onlined_pages = 0; 129 unsigned long onlined_pages = 0;
130 struct resource res;
131 u64 section_end;
132 unsigned long start_pfn;
129 struct zone *zone; 133 struct zone *zone;
130 int need_zonelists_rebuild = 0; 134 int need_zonelists_rebuild = 0;
131 135
@@ -148,10 +152,27 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
148 if (!populated_zone(zone)) 152 if (!populated_zone(zone))
149 need_zonelists_rebuild = 1; 153 need_zonelists_rebuild = 1;
150 154
151 for (i = 0; i < nr_pages; i++) { 155 res.start = (u64)pfn << PAGE_SHIFT;
152 struct page *page = pfn_to_page(pfn + i); 156 res.end = res.start + ((u64)nr_pages << PAGE_SHIFT) - 1;
153 online_page(page); 157 res.flags = IORESOURCE_MEM; /* we just need system ram */
154 onlined_pages++; 158 section_end = res.end;
159
160 while (find_next_system_ram(&res) >= 0) {
161 start_pfn = (unsigned long)(res.start >> PAGE_SHIFT);
162 nr_pages = (unsigned long)
163 ((res.end + 1 - res.start) >> PAGE_SHIFT);
164
165 if (PageReserved(pfn_to_page(start_pfn))) {
166 /* this region's page is not onlined now */
167 for (i = 0; i < nr_pages; i++) {
168 struct page *page = pfn_to_page(start_pfn + i);
169 online_page(page);
170 onlined_pages++;
171 }
172 }
173
174 res.start = res.end + 1;
175 res.end = section_end;
155 } 176 }
156 zone->present_pages += onlined_pages; 177 zone->present_pages += onlined_pages;
157 zone->zone_pgdat->node_present_pages += onlined_pages; 178 zone->zone_pgdat->node_present_pages += onlined_pages;
@@ -163,3 +184,100 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
163 vm_total_pages = nr_free_pagecache_pages(); 184 vm_total_pages = nr_free_pagecache_pages();
164 return 0; 185 return 0;
165} 186}
187
188static pg_data_t *hotadd_new_pgdat(int nid, u64 start)
189{
190 struct pglist_data *pgdat;
191 unsigned long zones_size[MAX_NR_ZONES] = {0};
192 unsigned long zholes_size[MAX_NR_ZONES] = {0};
193 unsigned long start_pfn = start >> PAGE_SHIFT;
194
195 pgdat = arch_alloc_nodedata(nid);
196 if (!pgdat)
197 return NULL;
198
199 arch_refresh_nodedata(nid, pgdat);
200
201 /* we can use NODE_DATA(nid) from here */
202
203 /* init node's zones as empty zones, we don't have any present pages.*/
204 free_area_init_node(nid, pgdat, zones_size, start_pfn, zholes_size);
205
206 return pgdat;
207}
208
209static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
210{
211 arch_refresh_nodedata(nid, NULL);
212 arch_free_nodedata(pgdat);
213 return;
214}
215
216/* add this memory to iomem resource */
217static void register_memory_resource(u64 start, u64 size)
218{
219 struct resource *res;
220
221 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
222 BUG_ON(!res);
223
224 res->name = "System RAM";
225 res->start = start;
226 res->end = start + size - 1;
227 res->flags = IORESOURCE_MEM;
228 if (request_resource(&iomem_resource, res) < 0) {
229 printk("System RAM resource %llx - %llx cannot be added\n",
230 (unsigned long long)res->start, (unsigned long long)res->end);
231 kfree(res);
232 }
233}
234
235
236
237int add_memory(int nid, u64 start, u64 size)
238{
239 pg_data_t *pgdat = NULL;
240 int new_pgdat = 0;
241 int ret;
242
243 if (!node_online(nid)) {
244 pgdat = hotadd_new_pgdat(nid, start);
245 if (!pgdat)
246 return -ENOMEM;
247 new_pgdat = 1;
248 ret = kswapd_run(nid);
249 if (ret)
250 goto error;
251 }
252
253 /* call arch's memory hotadd */
254 ret = arch_add_memory(nid, start, size);
255
256 if (ret < 0)
257 goto error;
258
259 /* we online node here. we can't roll back from here. */
260 node_set_online(nid);
261
262 if (new_pgdat) {
263 ret = register_one_node(nid);
264 /*
265 * If sysfs file of new node can't create, cpu on the node
266 * can't be hot-added. There is no rollback way now.
267 * So, check by BUG_ON() to catch it reluctantly..
268 */
269 BUG_ON(ret);
270 }
271
272 /* register this memory as resource */
273 register_memory_resource(start, size);
274
275 return ret;
276error:
277 /* rollback pgdat allocation and others */
278 if (new_pgdat)
279 rollback_node_hotadd(nid, pgdat);
280
281 return ret;
282}
283EXPORT_SYMBOL_GPL(add_memory);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 8ccf6f1b1473..4ec7026c7bab 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -516,14 +516,14 @@ static void set_ratelimit(void)
516 ratelimit_pages = (4096 * 1024) / PAGE_CACHE_SIZE; 516 ratelimit_pages = (4096 * 1024) / PAGE_CACHE_SIZE;
517} 517}
518 518
519static int 519static int __cpuinit
520ratelimit_handler(struct notifier_block *self, unsigned long u, void *v) 520ratelimit_handler(struct notifier_block *self, unsigned long u, void *v)
521{ 521{
522 set_ratelimit(); 522 set_ratelimit();
523 return 0; 523 return 0;
524} 524}
525 525
526static struct notifier_block ratelimit_nb = { 526static struct notifier_block __cpuinitdata ratelimit_nb = {
527 .notifier_call = ratelimit_handler, 527 .notifier_call = ratelimit_handler,
528 .next = NULL, 528 .next = NULL,
529}; 529};
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9f86191bb632..084a2de7e52a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -446,8 +446,8 @@ static void __free_pages_ok(struct page *page, unsigned int order)
446 446
447 arch_free_page(page, order); 447 arch_free_page(page, order);
448 if (!PageHighMem(page)) 448 if (!PageHighMem(page))
449 mutex_debug_check_no_locks_freed(page_address(page), 449 debug_check_no_locks_freed(page_address(page),
450 PAGE_SIZE<<order); 450 PAGE_SIZE<<order);
451 451
452 for (i = 0 ; i < (1 << order) ; ++i) 452 for (i = 0 ; i < (1 << order) ; ++i)
453 reserved += free_pages_check(page + i); 453 reserved += free_pages_check(page + i);
@@ -2009,7 +2009,7 @@ static inline void free_zone_pagesets(int cpu)
2009 } 2009 }
2010} 2010}
2011 2011
2012static int pageset_cpuup_callback(struct notifier_block *nfb, 2012static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb,
2013 unsigned long action, 2013 unsigned long action,
2014 void *hcpu) 2014 void *hcpu)
2015{ 2015{
@@ -2031,7 +2031,7 @@ static int pageset_cpuup_callback(struct notifier_block *nfb,
2031 return ret; 2031 return ret;
2032} 2032}
2033 2033
2034static struct notifier_block pageset_notifier = 2034static struct notifier_block __cpuinitdata pageset_notifier =
2035 { &pageset_cpuup_callback, NULL, 0 }; 2035 { &pageset_cpuup_callback, NULL, 0 };
2036 2036
2037void __init setup_per_cpu_pageset(void) 2037void __init setup_per_cpu_pageset(void)
diff --git a/mm/shmem.c b/mm/shmem.c
index 38bc3334f263..b14ff817d162 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -26,7 +26,6 @@
26#include <linux/config.h> 26#include <linux/config.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/devfs_fs_kernel.h>
30#include <linux/fs.h> 29#include <linux/fs.h>
31#include <linux/mm.h> 30#include <linux/mm.h>
32#include <linux/mman.h> 31#include <linux/mman.h>
@@ -174,7 +173,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages)
174} 173}
175 174
176static struct super_operations shmem_ops; 175static struct super_operations shmem_ops;
177static struct address_space_operations shmem_aops; 176static const struct address_space_operations shmem_aops;
178static struct file_operations shmem_file_operations; 177static struct file_operations shmem_file_operations;
179static struct inode_operations shmem_inode_operations; 178static struct inode_operations shmem_inode_operations;
180static struct inode_operations shmem_dir_inode_operations; 179static struct inode_operations shmem_dir_inode_operations;
@@ -2162,7 +2161,7 @@ static void destroy_inodecache(void)
2162 printk(KERN_INFO "shmem_inode_cache: not all structures were freed\n"); 2161 printk(KERN_INFO "shmem_inode_cache: not all structures were freed\n");
2163} 2162}
2164 2163
2165static struct address_space_operations shmem_aops = { 2164static const struct address_space_operations shmem_aops = {
2166 .writepage = shmem_writepage, 2165 .writepage = shmem_writepage,
2167 .set_page_dirty = __set_page_dirty_nobuffers, 2166 .set_page_dirty = __set_page_dirty_nobuffers,
2168#ifdef CONFIG_TMPFS 2167#ifdef CONFIG_TMPFS
@@ -2252,9 +2251,7 @@ static int __init init_tmpfs(void)
2252 printk(KERN_ERR "Could not register tmpfs\n"); 2251 printk(KERN_ERR "Could not register tmpfs\n");
2253 goto out2; 2252 goto out2;
2254 } 2253 }
2255#ifdef CONFIG_TMPFS 2254
2256 devfs_mk_dir("shm");
2257#endif
2258 shm_mnt = vfs_kern_mount(&tmpfs_fs_type, MS_NOUSER, 2255 shm_mnt = vfs_kern_mount(&tmpfs_fs_type, MS_NOUSER,
2259 tmpfs_fs_type.name, NULL); 2256 tmpfs_fs_type.name, NULL);
2260 if (IS_ERR(shm_mnt)) { 2257 if (IS_ERR(shm_mnt)) {
diff --git a/mm/slab.c b/mm/slab.c
index 98ac20bc0de9..233e39d14caf 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -89,6 +89,7 @@
89#include <linux/config.h> 89#include <linux/config.h>
90#include <linux/slab.h> 90#include <linux/slab.h>
91#include <linux/mm.h> 91#include <linux/mm.h>
92#include <linux/poison.h>
92#include <linux/swap.h> 93#include <linux/swap.h>
93#include <linux/cache.h> 94#include <linux/cache.h>
94#include <linux/interrupt.h> 95#include <linux/interrupt.h>
@@ -106,6 +107,7 @@
106#include <linux/nodemask.h> 107#include <linux/nodemask.h>
107#include <linux/mempolicy.h> 108#include <linux/mempolicy.h>
108#include <linux/mutex.h> 109#include <linux/mutex.h>
110#include <linux/rtmutex.h>
109 111
110#include <asm/uaccess.h> 112#include <asm/uaccess.h>
111#include <asm/cacheflush.h> 113#include <asm/cacheflush.h>
@@ -492,17 +494,6 @@ struct kmem_cache {
492#endif 494#endif
493 495
494#if DEBUG 496#if DEBUG
495/*
496 * Magic nums for obj red zoning.
497 * Placed in the first word before and the first word after an obj.
498 */
499#define RED_INACTIVE 0x5A2CF071UL /* when obj is inactive */
500#define RED_ACTIVE 0x170FC2A5UL /* when obj is active */
501
502/* ...and for poisoning */
503#define POISON_INUSE 0x5a /* for use-uninitialised poisoning */
504#define POISON_FREE 0x6b /* for use-after-free poisoning */
505#define POISON_END 0xa5 /* end-byte of poisoning */
506 497
507/* 498/*
508 * memory layout of objects: 499 * memory layout of objects:
@@ -1083,7 +1074,7 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
1083 1074
1084#endif 1075#endif
1085 1076
1086static int cpuup_callback(struct notifier_block *nfb, 1077static int __devinit cpuup_callback(struct notifier_block *nfb,
1087 unsigned long action, void *hcpu) 1078 unsigned long action, void *hcpu)
1088{ 1079{
1089 long cpu = (long)hcpu; 1080 long cpu = (long)hcpu;
@@ -1265,7 +1256,9 @@ bad:
1265 return NOTIFY_BAD; 1256 return NOTIFY_BAD;
1266} 1257}
1267 1258
1268static struct notifier_block cpucache_notifier = { &cpuup_callback, NULL, 0 }; 1259static struct notifier_block __cpuinitdata cpucache_notifier = {
1260 &cpuup_callback, NULL, 0
1261};
1269 1262
1270/* 1263/*
1271 * swap the static kmem_list3 with kmalloced memory 1264 * swap the static kmem_list3 with kmalloced memory
@@ -3405,7 +3398,7 @@ void kfree(const void *objp)
3405 local_irq_save(flags); 3398 local_irq_save(flags);
3406 kfree_debugcheck(objp); 3399 kfree_debugcheck(objp);
3407 c = virt_to_cache(objp); 3400 c = virt_to_cache(objp);
3408 mutex_debug_check_no_locks_freed(objp, obj_size(c)); 3401 debug_check_no_locks_freed(objp, obj_size(c));
3409 __cache_free(c, (void *)objp); 3402 __cache_free(c, (void *)objp);
3410 local_irq_restore(flags); 3403 local_irq_restore(flags);
3411} 3404}
diff --git a/mm/sparse.c b/mm/sparse.c
index e0a3fe48aa37..c7a2b3a0e46b 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -45,7 +45,7 @@ static struct mem_section *sparse_index_alloc(int nid)
45 45
46static int sparse_index_init(unsigned long section_nr, int nid) 46static int sparse_index_init(unsigned long section_nr, int nid)
47{ 47{
48 static spinlock_t index_init_lock = SPIN_LOCK_UNLOCKED; 48 static DEFINE_SPINLOCK(index_init_lock);
49 unsigned long root = SECTION_NR_TO_ROOT(section_nr); 49 unsigned long root = SECTION_NR_TO_ROOT(section_nr);
50 struct mem_section *section; 50 struct mem_section *section;
51 int ret = 0; 51 int ret = 0;
diff --git a/mm/swap_state.c b/mm/swap_state.c
index e0e1583f32c2..7535211bb495 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -24,7 +24,7 @@
24 * vmscan's shrink_list, to make sync_page look nicer, and to allow 24 * vmscan's shrink_list, to make sync_page look nicer, and to allow
25 * future use of radix_tree tags in the swap cache. 25 * future use of radix_tree tags in the swap cache.
26 */ 26 */
27static struct address_space_operations swap_aops = { 27static const struct address_space_operations swap_aops = {
28 .writepage = swap_writepage, 28 .writepage = swap_writepage,
29 .sync_page = block_sync_page, 29 .sync_page = block_sync_page,
30 .set_page_dirty = __set_page_dirty_nobuffers, 30 .set_page_dirty = __set_page_dirty_nobuffers,
diff --git a/mm/tiny-shmem.c b/mm/tiny-shmem.c
index f9d6a9cc91c4..5f2cbf0f153c 100644
--- a/mm/tiny-shmem.c
+++ b/mm/tiny-shmem.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/devfs_fs_kernel.h>
16#include <linux/vfs.h> 15#include <linux/vfs.h>
17#include <linux/mount.h> 16#include <linux/mount.h>
18#include <linux/file.h> 17#include <linux/file.h>
@@ -33,9 +32,6 @@ static int __init init_tmpfs(void)
33{ 32{
34 BUG_ON(register_filesystem(&tmpfs_fs_type) != 0); 33 BUG_ON(register_filesystem(&tmpfs_fs_type) != 0);
35 34
36#ifdef CONFIG_TMPFS
37 devfs_mk_dir("shm");
38#endif
39 shm_mnt = kern_mount(&tmpfs_fs_type); 35 shm_mnt = kern_mount(&tmpfs_fs_type);
40 BUG_ON(IS_ERR(shm_mnt)); 36 BUG_ON(IS_ERR(shm_mnt));
41 37
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 72babac71dea..eeacb0d695c3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -34,6 +34,7 @@
34#include <linux/notifier.h> 34#include <linux/notifier.h>
35#include <linux/rwsem.h> 35#include <linux/rwsem.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/kthread.h>
37 38
38#include <asm/tlbflush.h> 39#include <asm/tlbflush.h>
39#include <asm/div64.h> 40#include <asm/div64.h>
@@ -1223,7 +1224,6 @@ static int kswapd(void *p)
1223 }; 1224 };
1224 cpumask_t cpumask; 1225 cpumask_t cpumask;
1225 1226
1226 daemonize("kswapd%d", pgdat->node_id);
1227 cpumask = node_to_cpumask(pgdat->node_id); 1227 cpumask = node_to_cpumask(pgdat->node_id);
1228 if (!cpus_empty(cpumask)) 1228 if (!cpus_empty(cpumask))
1229 set_cpus_allowed(tsk, cpumask); 1229 set_cpus_allowed(tsk, cpumask);
@@ -1450,7 +1450,7 @@ out:
1450 not required for correctness. So if the last cpu in a node goes 1450 not required for correctness. So if the last cpu in a node goes
1451 away, we get changed to run anywhere: as the first one comes back, 1451 away, we get changed to run anywhere: as the first one comes back,
1452 restore their cpu bindings. */ 1452 restore their cpu bindings. */
1453static int cpu_callback(struct notifier_block *nfb, 1453static int __devinit cpu_callback(struct notifier_block *nfb,
1454 unsigned long action, void *hcpu) 1454 unsigned long action, void *hcpu)
1455{ 1455{
1456 pg_data_t *pgdat; 1456 pg_data_t *pgdat;
@@ -1468,20 +1468,35 @@ static int cpu_callback(struct notifier_block *nfb,
1468} 1468}
1469#endif /* CONFIG_HOTPLUG_CPU */ 1469#endif /* CONFIG_HOTPLUG_CPU */
1470 1470
1471/*
1472 * This kswapd start function will be called by init and node-hot-add.
1473 * On node-hot-add, kswapd will moved to proper cpus if cpus are hot-added.
1474 */
1475int kswapd_run(int nid)
1476{
1477 pg_data_t *pgdat = NODE_DATA(nid);
1478 int ret = 0;
1479
1480 if (pgdat->kswapd)
1481 return 0;
1482
1483 pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
1484 if (IS_ERR(pgdat->kswapd)) {
1485 /* failure at boot is fatal */
1486 BUG_ON(system_state == SYSTEM_BOOTING);
1487 printk("Failed to start kswapd on node %d\n",nid);
1488 ret = -1;
1489 }
1490 return ret;
1491}
1492
1471static int __init kswapd_init(void) 1493static int __init kswapd_init(void)
1472{ 1494{
1473 pg_data_t *pgdat; 1495 int nid;
1474 1496
1475 swap_setup(); 1497 swap_setup();
1476 for_each_online_pgdat(pgdat) { 1498 for_each_online_node(nid)
1477 pid_t pid; 1499 kswapd_run(nid);
1478
1479 pid = kernel_thread(kswapd, pgdat, CLONE_KERNEL);
1480 BUG_ON(pid < 0);
1481 read_lock(&tasklist_lock);
1482 pgdat->kswapd = find_task_by_pid(pid);
1483 read_unlock(&tasklist_lock);
1484 }
1485 hotcpu_notifier(cpu_callback, 0); 1500 hotcpu_notifier(cpu_callback, 0);
1486 return 0; 1501 return 0;
1487} 1502}
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 74368f79ee5d..b105a715fa93 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -480,12 +480,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
480 480
481 BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); 481 BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len);
482 482
483 if (test_bit(TTY_DONT_FLIP, &tty->flags)) { 483 tty_insert_flip_string(tty, skb->data, skb->len);
484 tty_buffer_request_room(tty, skb->len); 484 tty_flip_buffer_push(tty);
485 tty_insert_flip_string(tty, skb->data, skb->len);
486 tty_flip_buffer_push(tty);
487 } else
488 tty->ldisc.receive_buf(tty, skb->data, NULL, skb->len);
489 485
490 kfree_skb(skb); 486 kfree_skb(skb);
491} 487}
@@ -1025,13 +1021,12 @@ int rfcomm_init_ttys(void)
1025 1021
1026 rfcomm_tty_driver->owner = THIS_MODULE; 1022 rfcomm_tty_driver->owner = THIS_MODULE;
1027 rfcomm_tty_driver->driver_name = "rfcomm"; 1023 rfcomm_tty_driver->driver_name = "rfcomm";
1028 rfcomm_tty_driver->devfs_name = "bluetooth/rfcomm/";
1029 rfcomm_tty_driver->name = "rfcomm"; 1024 rfcomm_tty_driver->name = "rfcomm";
1030 rfcomm_tty_driver->major = RFCOMM_TTY_MAJOR; 1025 rfcomm_tty_driver->major = RFCOMM_TTY_MAJOR;
1031 rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR; 1026 rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR;
1032 rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1027 rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1033 rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1028 rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL;
1034 rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 1029 rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1035 rfcomm_tty_driver->init_termios = tty_std_termios; 1030 rfcomm_tty_driver->init_termios = tty_std_termios;
1036 rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1031 rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1037 tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); 1032 tty_set_operations(rfcomm_tty_driver, &rfcomm_ops);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8a777932786d..e728980160d2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -349,7 +349,7 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
349 (strict & RT6_SELECT_F_REACHABLE) && 349 (strict & RT6_SELECT_F_REACHABLE) &&
350 last && last != rt0) { 350 last && last != rt0) {
351 /* no entries matched; do round-robin */ 351 /* no entries matched; do round-robin */
352 static spinlock_t lock = SPIN_LOCK_UNLOCKED; 352 static DEFINE_SPINLOCK(lock);
353 spin_lock(&lock); 353 spin_lock(&lock);
354 *head = rt0->u.next; 354 *head = rt0->u.next;
355 rt0->u.next = last->u.next; 355 rt0->u.next = last->u.next;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 6f20b4206e08..b592c4bc3331 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -124,7 +124,6 @@ static int __init ircomm_tty_init(void)
124 driver->owner = THIS_MODULE; 124 driver->owner = THIS_MODULE;
125 driver->driver_name = "ircomm"; 125 driver->driver_name = "ircomm";
126 driver->name = "ircomm"; 126 driver->name = "ircomm";
127 driver->devfs_name = "ircomm";
128 driver->major = IRCOMM_TTY_MAJOR; 127 driver->major = IRCOMM_TTY_MAJOR;
129 driver->minor_start = IRCOMM_TTY_MINOR; 128 driver->minor_start = IRCOMM_TTY_MINOR;
130 driver->type = TTY_DRIVER_TYPE_SERIAL; 129 driver->type = TTY_DRIVER_TYPE_SERIAL;
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index e4fe1e80029c..ad6caba02a7b 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -244,7 +244,6 @@
244#include <linux/skbuff.h> 244#include <linux/skbuff.h>
245#include <linux/tty.h> 245#include <linux/tty.h>
246#include <linux/proc_fs.h> 246#include <linux/proc_fs.h>
247#include <linux/devfs_fs_kernel.h>
248#include <linux/netdevice.h> 247#include <linux/netdevice.h>
249#include <linux/miscdevice.h> 248#include <linux/miscdevice.h>
250#include <linux/poll.h> 249#include <linux/poll.h>
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index f43311221a72..2f312164d6d5 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -70,7 +70,7 @@
70# define RPCDBG_FACILITY RPCDBG_AUTH 70# define RPCDBG_FACILITY RPCDBG_AUTH
71#endif 71#endif
72 72
73spinlock_t krb5_seq_lock = SPIN_LOCK_UNLOCKED; 73DEFINE_SPINLOCK(krb5_seq_lock);
74 74
75u32 75u32
76gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text, 76gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 54128040a124..1bb75703f384 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -117,7 +117,7 @@ struct bclink {
117static struct bcbearer *bcbearer = NULL; 117static struct bcbearer *bcbearer = NULL;
118static struct bclink *bclink = NULL; 118static struct bclink *bclink = NULL;
119static struct link *bcl = NULL; 119static struct link *bcl = NULL;
120static spinlock_t bc_lock = SPIN_LOCK_UNLOCKED; 120static DEFINE_SPINLOCK(bc_lock);
121 121
122char tipc_bclink_name[] = "multicast-link"; 122char tipc_bclink_name[] = "multicast-link";
123 123
@@ -796,7 +796,7 @@ int tipc_bclink_init(void)
796 memset(bclink, 0, sizeof(struct bclink)); 796 memset(bclink, 0, sizeof(struct bclink));
797 INIT_LIST_HEAD(&bcl->waiting_ports); 797 INIT_LIST_HEAD(&bcl->waiting_ports);
798 bcl->next_out_no = 1; 798 bcl->next_out_no = 1;
799 bclink->node.lock = SPIN_LOCK_UNLOCKED; 799 spin_lock_init(&bclink->node.lock);
800 bcl->owner = &bclink->node; 800 bcl->owner = &bclink->node;
801 bcl->max_pkt = MAX_PKT_DEFAULT_MCAST; 801 bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
802 tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT); 802 tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 4fa24b5e8914..7ef17a449cfd 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -566,7 +566,7 @@ restart:
566 b_ptr->link_req = tipc_disc_init_link_req(b_ptr, &m_ptr->bcast_addr, 566 b_ptr->link_req = tipc_disc_init_link_req(b_ptr, &m_ptr->bcast_addr,
567 bcast_scope, 2); 567 bcast_scope, 2);
568 } 568 }
569 b_ptr->publ.lock = SPIN_LOCK_UNLOCKED; 569 spin_lock_init(&b_ptr->publ.lock);
570 write_unlock_bh(&tipc_net_lock); 570 write_unlock_bh(&tipc_net_lock);
571 info("Enabled bearer <%s>, discovery domain %s, priority %u\n", 571 info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
572 name, addr_string_fill(addr_string, bcast_scope), priority); 572 name, addr_string_fill(addr_string, bcast_scope), priority);
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 3ec502fac8c3..285e1bc2d880 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -63,7 +63,7 @@ struct manager {
63 63
64static struct manager mng = { 0}; 64static struct manager mng = { 0};
65 65
66static spinlock_t config_lock = SPIN_LOCK_UNLOCKED; 66static DEFINE_SPINLOCK(config_lock);
67 67
68static const void *req_tlv_area; /* request message TLV area */ 68static const void *req_tlv_area; /* request message TLV area */
69static int req_tlv_space; /* request message TLV area size */ 69static int req_tlv_space; /* request message TLV area size */
diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c
index 26ef95d5fe38..55130655e1ed 100644
--- a/net/tipc/dbg.c
+++ b/net/tipc/dbg.c
@@ -41,7 +41,7 @@
41#define MAX_STRING 512 41#define MAX_STRING 512
42 42
43static char print_string[MAX_STRING]; 43static char print_string[MAX_STRING];
44static spinlock_t print_lock = SPIN_LOCK_UNLOCKED; 44static DEFINE_SPINLOCK(print_lock);
45 45
46static struct print_buf cons_buf = { NULL, 0, NULL, NULL }; 46static struct print_buf cons_buf = { NULL, 0, NULL, NULL };
47struct print_buf *TIPC_CONS = &cons_buf; 47struct print_buf *TIPC_CONS = &cons_buf;
diff --git a/net/tipc/handler.c b/net/tipc/handler.c
index 966f70a1b608..ae6ddf00a1aa 100644
--- a/net/tipc/handler.c
+++ b/net/tipc/handler.c
@@ -44,7 +44,7 @@ struct queue_item {
44 44
45static kmem_cache_t *tipc_queue_item_cache; 45static kmem_cache_t *tipc_queue_item_cache;
46static struct list_head signal_queue_head; 46static struct list_head signal_queue_head;
47static spinlock_t qitem_lock = SPIN_LOCK_UNLOCKED; 47static DEFINE_SPINLOCK(qitem_lock);
48static int handler_enabled = 0; 48static int handler_enabled = 0;
49 49
50static void process_signal_queue(unsigned long dummy); 50static void process_signal_queue(unsigned long dummy);
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 38571306aba5..a6926ff07bcc 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -101,7 +101,7 @@ struct name_table {
101 101
102static struct name_table table = { NULL } ; 102static struct name_table table = { NULL } ;
103static atomic_t rsv_publ_ok = ATOMIC_INIT(0); 103static atomic_t rsv_publ_ok = ATOMIC_INIT(0);
104rwlock_t tipc_nametbl_lock = RW_LOCK_UNLOCKED; 104DEFINE_RWLOCK(tipc_nametbl_lock);
105 105
106 106
107static int hash(int x) 107static int hash(int x)
@@ -172,7 +172,7 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
172 } 172 }
173 173
174 memset(nseq, 0, sizeof(*nseq)); 174 memset(nseq, 0, sizeof(*nseq));
175 nseq->lock = SPIN_LOCK_UNLOCKED; 175 spin_lock_init(&nseq->lock);
176 nseq->type = type; 176 nseq->type = type;
177 nseq->sseqs = sseq; 177 nseq->sseqs = sseq;
178 dbg("tipc_nameseq_create(): nseq = %p, type %u, ssseqs %p, ff: %u\n", 178 dbg("tipc_nameseq_create(): nseq = %p, type %u, ssseqs %p, ff: %u\n",
diff --git a/net/tipc/net.c b/net/tipc/net.c
index f7c8223ddf7d..e5a359ab4930 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -115,7 +115,7 @@
115 * - A local spin_lock protecting the queue of subscriber events. 115 * - A local spin_lock protecting the queue of subscriber events.
116*/ 116*/
117 117
118rwlock_t tipc_net_lock = RW_LOCK_UNLOCKED; 118DEFINE_RWLOCK(tipc_net_lock);
119struct network tipc_net = { NULL }; 119struct network tipc_net = { NULL };
120 120
121struct node *tipc_net_select_remote_node(u32 addr, u32 ref) 121struct node *tipc_net_select_remote_node(u32 addr, u32 ref)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index ce9678efa98a..861322b935da 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -77,7 +77,7 @@ struct node *tipc_node_create(u32 addr)
77 77
78 memset(n_ptr, 0, sizeof(*n_ptr)); 78 memset(n_ptr, 0, sizeof(*n_ptr));
79 n_ptr->addr = addr; 79 n_ptr->addr = addr;
80 n_ptr->lock = SPIN_LOCK_UNLOCKED; 80 spin_lock_init(&n_ptr->lock);
81 INIT_LIST_HEAD(&n_ptr->nsub); 81 INIT_LIST_HEAD(&n_ptr->nsub);
82 n_ptr->owner = c_ptr; 82 n_ptr->owner = c_ptr;
83 tipc_cltr_attach_node(c_ptr, n_ptr); 83 tipc_cltr_attach_node(c_ptr, n_ptr);
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 47d97404e3ee..3251c8d8e53c 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -57,8 +57,8 @@
57static struct sk_buff *msg_queue_head = NULL; 57static struct sk_buff *msg_queue_head = NULL;
58static struct sk_buff *msg_queue_tail = NULL; 58static struct sk_buff *msg_queue_tail = NULL;
59 59
60spinlock_t tipc_port_list_lock = SPIN_LOCK_UNLOCKED; 60DEFINE_SPINLOCK(tipc_port_list_lock);
61static spinlock_t queue_lock = SPIN_LOCK_UNLOCKED; 61static DEFINE_SPINLOCK(queue_lock);
62 62
63static LIST_HEAD(ports); 63static LIST_HEAD(ports);
64static void port_handle_node_down(unsigned long ref); 64static void port_handle_node_down(unsigned long ref);
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index d2f0cce10e20..596d3c8ff750 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -63,7 +63,7 @@
63 63
64struct ref_table tipc_ref_table = { NULL }; 64struct ref_table tipc_ref_table = { NULL };
65 65
66static rwlock_t ref_table_lock = RW_LOCK_UNLOCKED; 66static DEFINE_RWLOCK(ref_table_lock);
67 67
68/** 68/**
69 * tipc_ref_table_init - create reference table for objects 69 * tipc_ref_table_init - create reference table for objects
@@ -87,7 +87,7 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
87 index_mask = sz - 1; 87 index_mask = sz - 1;
88 for (i = sz - 1; i >= 0; i--) { 88 for (i = sz - 1; i >= 0; i--) {
89 table[i].object = NULL; 89 table[i].object = NULL;
90 table[i].lock = SPIN_LOCK_UNLOCKED; 90 spin_lock_init(&table[i].lock);
91 table[i].data.next_plus_upper = (start & ~index_mask) + i - 1; 91 table[i].data.next_plus_upper = (start & ~index_mask) + i - 1;
92 } 92 }
93 tipc_ref_table.entries = table; 93 tipc_ref_table.entries = table;
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index fc171875660c..e19b4bcd67ec 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -457,7 +457,7 @@ int tipc_subscr_start(void)
457 int res = -1; 457 int res = -1;
458 458
459 memset(&topsrv, 0, sizeof (topsrv)); 459 memset(&topsrv, 0, sizeof (topsrv));
460 topsrv.lock = SPIN_LOCK_UNLOCKED; 460 spin_lock_init(&topsrv.lock);
461 INIT_LIST_HEAD(&topsrv.subscriber_list); 461 INIT_LIST_HEAD(&topsrv.subscriber_list);
462 462
463 spin_lock_bh(&topsrv.lock); 463 spin_lock_bh(&topsrv.lock);
diff --git a/net/tipc/user_reg.c b/net/tipc/user_reg.c
index 3f3f933976e9..1e3ae57c7228 100644
--- a/net/tipc/user_reg.c
+++ b/net/tipc/user_reg.c
@@ -67,7 +67,7 @@ struct tipc_user {
67 67
68static struct tipc_user *users = NULL; 68static struct tipc_user *users = NULL;
69static u32 next_free_user = MAX_USERID + 1; 69static u32 next_free_user = MAX_USERID + 1;
70static spinlock_t reg_lock = SPIN_LOCK_UNLOCKED; 70static DEFINE_SPINLOCK(reg_lock);
71 71
72/** 72/**
73 * reg_init - create TIPC user registry (but don't activate it) 73 * reg_init - create TIPC user registry (but don't activate it)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index ac5f275b0283..b0d067be7390 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -13,11 +13,6 @@ space := $(empty) $(empty)
13depfile = $(subst $(comma),_,$(@D)/.$(@F).d) 13depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
14 14
15### 15###
16# basetarget equals the filename of the target with no extension.
17# So 'foo/bar.o' becomes 'bar'
18basetarget = $(basename $(notdir $@))
19
20###
21# Escape single quote for use in echo statements 16# Escape single quote for use in echo statements
22escsq = $(subst $(squote),'\$(squote)',$1) 17escsq = $(subst $(squote),'\$(squote)',$1)
23 18
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 3cb445cc7432..02a7eea5fdbc 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -117,7 +117,7 @@ $(real-objs-m:.o=.lst): quiet_modtag := [M]
117$(obj-m) : quiet_modtag := [M] 117$(obj-m) : quiet_modtag := [M]
118 118
119# Default for not multi-part modules 119# Default for not multi-part modules
120modname = $(basetarget) 120modname = $(*F)
121 121
122$(multi-objs-m) : modname = $(modname-multi) 122$(multi-objs-m) : modname = $(modname-multi)
123$(multi-objs-m:.o=.i) : modname = $(modname-multi) 123$(multi-objs-m:.o=.i) : modname = $(modname-multi)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 18ecd4d5df7f..2b066d12af2c 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -80,10 +80,8 @@ obj-dirs += $(host-objdirs)
80##### 80#####
81# Handle options to gcc. Support building with separate output directory 81# Handle options to gcc. Support building with separate output directory
82 82
83_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ 83_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o)
84 $(HOSTCFLAGS_$(basetarget).o) 84_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o)
85_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
86 $(HOSTCXXFLAGS_$(basetarget).o)
87 85
88ifeq ($(KBUILD_SRC),) 86ifeq ($(KBUILD_SRC),)
89__hostc_flags = $(_hostc_flags) 87__hostc_flags = $(_hostc_flags)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index fc498fee68ed..2cb4935e85d1 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -82,12 +82,12 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
82# than one module. In that case KBUILD_MODNAME will be set to foo_bar, 82# than one module. In that case KBUILD_MODNAME will be set to foo_bar,
83# where foo and bar are the name of the modules. 83# where foo and bar are the name of the modules.
84name-fix = $(subst $(comma),_,$(subst -,_,$1)) 84name-fix = $(subst $(comma),_,$(subst -,_,$1))
85basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" 85basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))"
86modname_flags = $(if $(filter 1,$(words $(modname))),\ 86modname_flags = $(if $(filter 1,$(words $(modname))),\
87 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 87 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
88 88
89_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o) 89_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
90_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) 90_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
91_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) 91_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
92 92
93# If building the kernel in a separate objtree expand all occurrences 93# If building the kernel in a separate objtree expand all occurrences
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index e83613e0e827..576cce5e387f 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -72,7 +72,7 @@ $(modules:.ko=.mod.c): __modpost ;
72# Step 5), compile all *.mod.c files 72# Step 5), compile all *.mod.c files
73 73
74# modname is set to make c_flags define KBUILD_MODNAME 74# modname is set to make c_flags define KBUILD_MODNAME
75modname = $(basetarget) 75modname = $(*F)
76 76
77quiet_cmd_cc_o_c = CC $@ 77quiet_cmd_cc_o_c = CC $@
78 cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ 78 cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
diff --git a/scripts/rt-tester/check-all.sh b/scripts/rt-tester/check-all.sh
new file mode 100644
index 000000000000..43098afe7431
--- /dev/null
+++ b/scripts/rt-tester/check-all.sh
@@ -0,0 +1,22 @@
1
2
3function testit ()
4{
5 printf "%-30s: " $1
6 ./rt-tester.py $1 | grep Pass
7}
8
9testit t2-l1-2rt-sameprio.tst
10testit t2-l1-pi.tst
11testit t2-l1-signal.tst
12#testit t2-l2-2rt-deadlock.tst
13testit t3-l1-pi-1rt.tst
14testit t3-l1-pi-2rt.tst
15testit t3-l1-pi-3rt.tst
16testit t3-l1-pi-signal.tst
17testit t3-l1-pi-steal.tst
18testit t3-l2-pi.tst
19testit t4-l2-pi-deboost.tst
20testit t5-l4-pi-boost-deboost.tst
21testit t5-l4-pi-boost-deboost-setsched.tst
22
diff --git a/scripts/rt-tester/rt-tester.py b/scripts/rt-tester/rt-tester.py
new file mode 100644
index 000000000000..4c79660793cf
--- /dev/null
+++ b/scripts/rt-tester/rt-tester.py
@@ -0,0 +1,222 @@
1#!/usr/bin/env python
2#
3# rt-mutex tester
4#
5# (C) 2006 Thomas Gleixner <tglx@linutronix.de>
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#
11import os
12import sys
13import getopt
14import shutil
15import string
16
17# Globals
18quiet = 0
19test = 0
20comments = 0
21
22sysfsprefix = "/sys/devices/system/rttest/rttest"
23statusfile = "/status"
24commandfile = "/command"
25
26# Command opcodes
27cmd_opcodes = {
28 "schedother" : "1",
29 "schedfifo" : "2",
30 "lock" : "3",
31 "locknowait" : "4",
32 "lockint" : "5",
33 "lockintnowait" : "6",
34 "lockcont" : "7",
35 "unlock" : "8",
36 "lockbkl" : "9",
37 "unlockbkl" : "10",
38 "signal" : "11",
39 "resetevent" : "98",
40 "reset" : "99",
41 }
42
43test_opcodes = {
44 "prioeq" : ["P" , "eq" , None],
45 "priolt" : ["P" , "lt" , None],
46 "priogt" : ["P" , "gt" , None],
47 "nprioeq" : ["N" , "eq" , None],
48 "npriolt" : ["N" , "lt" , None],
49 "npriogt" : ["N" , "gt" , None],
50 "unlocked" : ["M" , "eq" , 0],
51 "trylock" : ["M" , "eq" , 1],
52 "blocked" : ["M" , "eq" , 2],
53 "blockedwake" : ["M" , "eq" , 3],
54 "locked" : ["M" , "eq" , 4],
55 "opcodeeq" : ["O" , "eq" , None],
56 "opcodelt" : ["O" , "lt" , None],
57 "opcodegt" : ["O" , "gt" , None],
58 "eventeq" : ["E" , "eq" , None],
59 "eventlt" : ["E" , "lt" , None],
60 "eventgt" : ["E" , "gt" , None],
61 }
62
63# Print usage information
64def usage():
65 print "rt-tester.py <-c -h -q -t> <testfile>"
66 print " -c display comments after first command"
67 print " -h help"
68 print " -q quiet mode"
69 print " -t test mode (syntax check)"
70 print " testfile: read test specification from testfile"
71 print " otherwise from stdin"
72 return
73
74# Print progress when not in quiet mode
75def progress(str):
76 if not quiet:
77 print str
78
79# Analyse a status value
80def analyse(val, top, arg):
81
82 intval = int(val)
83
84 if top[0] == "M":
85 intval = intval / (10 ** int(arg))
86 intval = intval % 10
87 argval = top[2]
88 elif top[0] == "O":
89 argval = int(cmd_opcodes.get(arg, arg))
90 else:
91 argval = int(arg)
92
93 # progress("%d %s %d" %(intval, top[1], argval))
94
95 if top[1] == "eq" and intval == argval:
96 return 1
97 if top[1] == "lt" and intval < argval:
98 return 1
99 if top[1] == "gt" and intval > argval:
100 return 1
101 return 0
102
103# Parse the commandline
104try:
105 (options, arguments) = getopt.getopt(sys.argv[1:],'chqt')
106except getopt.GetoptError, ex:
107 usage()
108 sys.exit(1)
109
110# Parse commandline options
111for option, value in options:
112 if option == "-c":
113 comments = 1
114 elif option == "-q":
115 quiet = 1
116 elif option == "-t":
117 test = 1
118 elif option == '-h':
119 usage()
120 sys.exit(0)
121
122# Select the input source
123if arguments:
124 try:
125 fd = open(arguments[0])
126 except Exception,ex:
127 sys.stderr.write("File not found %s\n" %(arguments[0]))
128 sys.exit(1)
129else:
130 fd = sys.stdin
131
132linenr = 0
133
134# Read the test patterns
135while 1:
136
137 linenr = linenr + 1
138 line = fd.readline()
139 if not len(line):
140 break
141
142 line = line.strip()
143 parts = line.split(":")
144
145 if not parts or len(parts) < 1:
146 continue
147
148 if len(parts[0]) == 0:
149 continue
150
151 if parts[0].startswith("#"):
152 if comments > 1:
153 progress(line)
154 continue
155
156 if comments == 1:
157 comments = 2
158
159 progress(line)
160
161 cmd = parts[0].strip().lower()
162 opc = parts[1].strip().lower()
163 tid = parts[2].strip()
164 dat = parts[3].strip()
165
166 try:
167 # Test or wait for a status value
168 if cmd == "t" or cmd == "w":
169 testop = test_opcodes[opc]
170
171 fname = "%s%s%s" %(sysfsprefix, tid, statusfile)
172 if test:
173 print fname
174 continue
175
176 while 1:
177 query = 1
178 fsta = open(fname, 'r')
179 status = fsta.readline().strip()
180 fsta.close()
181 stat = status.split(",")
182 for s in stat:
183 s = s.strip()
184 if s.startswith(testop[0]):
185 # Seperate status value
186 val = s[2:].strip()
187 query = analyse(val, testop, dat)
188 break
189 if query or cmd == "t":
190 break
191
192 progress(" " + status)
193
194 if not query:
195 sys.stderr.write("Test failed in line %d\n" %(linenr))
196 sys.exit(1)
197
198 # Issue a command to the tester
199 elif cmd == "c":
200 cmdnr = cmd_opcodes[opc]
201 # Build command string and sys filename
202 cmdstr = "%s:%s" %(cmdnr, dat)
203 fname = "%s%s%s" %(sysfsprefix, tid, commandfile)
204 if test:
205 print fname
206 continue
207 fcmd = open(fname, 'w')
208 fcmd.write(cmdstr)
209 fcmd.close()
210
211 except Exception,ex:
212 sys.stderr.write(str(ex))
213 sys.stderr.write("\nSyntax error in line %d\n" %(linenr))
214 if not test:
215 fd.close()
216 sys.exit(1)
217
218# Normal exit pass
219print "Pass"
220sys.exit(0)
221
222
diff --git a/scripts/rt-tester/t2-l1-2rt-sameprio.tst b/scripts/rt-tester/t2-l1-2rt-sameprio.tst
new file mode 100644
index 000000000000..8821f27cc8be
--- /dev/null
+++ b/scripts/rt-tester/t2-l1-2rt-sameprio.tst
@@ -0,0 +1,99 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 1 lock
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedfifo: 0: 80
60C: schedfifo: 1: 80
61
62# T0 lock L0
63C: locknowait: 0: 0
64C: locknowait: 1: 0
65W: locked: 0: 0
66W: blocked: 1: 0
67T: prioeq: 0: 80
68
69# T0 unlock L0
70C: unlock: 0: 0
71W: locked: 1: 0
72
73# Verify T0
74W: unlocked: 0: 0
75T: prioeq: 0: 80
76
77# Unlock
78C: unlock: 1: 0
79W: unlocked: 1: 0
80
81# T1,T0 lock L0
82C: locknowait: 1: 0
83C: locknowait: 0: 0
84W: locked: 1: 0
85W: blocked: 0: 0
86T: prioeq: 1: 80
87
88# T1 unlock L0
89C: unlock: 1: 0
90W: locked: 0: 0
91
92# Verify T1
93W: unlocked: 1: 0
94T: prioeq: 1: 80
95
96# Unlock and exit
97C: unlock: 0: 0
98W: unlocked: 0: 0
99
diff --git a/scripts/rt-tester/t2-l1-pi.tst b/scripts/rt-tester/t2-l1-pi.tst
new file mode 100644
index 000000000000..cde1f189a02b
--- /dev/null
+++ b/scripts/rt-tester/t2-l1-pi.tst
@@ -0,0 +1,82 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 1 lock with priority inversion
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedfifo: 1: 80
61
62# T0 lock L0
63C: locknowait: 0: 0
64W: locked: 0: 0
65
66# T1 lock L0
67C: locknowait: 1: 0
68W: blocked: 1: 0
69T: prioeq: 0: 80
70
71# T0 unlock L0
72C: unlock: 0: 0
73W: locked: 1: 0
74
75# Verify T1
76W: unlocked: 0: 0
77T: priolt: 0: 1
78
79# Unlock and exit
80C: unlock: 1: 0
81W: unlocked: 1: 0
82
diff --git a/scripts/rt-tester/t2-l1-signal.tst b/scripts/rt-tester/t2-l1-signal.tst
new file mode 100644
index 000000000000..3ab0bfc49950
--- /dev/null
+++ b/scripts/rt-tester/t2-l1-signal.tst
@@ -0,0 +1,77 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 1 lock with priority inversion
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedother: 1: 0
61
62# T0 lock L0
63C: locknowait: 0: 0
64W: locked: 0: 0
65
66# T1 lock L0
67C: lockintnowait: 1: 0
68W: blocked: 1: 0
69
70# Interrupt T1
71C: signal: 1: 0
72W: unlocked: 1: 0
73T: opcodeeq: 1: -4
74
75# Unlock and exit
76C: unlock: 0: 0
77W: unlocked: 0: 0
diff --git a/scripts/rt-tester/t2-l2-2rt-deadlock.tst b/scripts/rt-tester/t2-l2-2rt-deadlock.tst
new file mode 100644
index 000000000000..f4b5d5d6215f
--- /dev/null
+++ b/scripts/rt-tester/t2-l2-2rt-deadlock.tst
@@ -0,0 +1,89 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 2 lock
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedfifo: 0: 80
60C: schedfifo: 1: 80
61
62# T0 lock L0
63C: locknowait: 0: 0
64W: locked: 0: 0
65
66# T1 lock L1
67C: locknowait: 1: 1
68W: locked: 1: 1
69
70# T0 lock L1
71C: lockintnowait: 0: 1
72W: blocked: 0: 1
73
74# T1 lock L0
75C: lockintnowait: 1: 0
76W: blocked: 1: 0
77
78# Make deadlock go away
79C: signal: 1: 0
80W: unlocked: 1: 0
81C: signal: 0: 0
82W: unlocked: 0: 1
83
84# Unlock and exit
85C: unlock: 0: 0
86W: unlocked: 0: 0
87C: unlock: 1: 1
88W: unlocked: 1: 1
89
diff --git a/scripts/rt-tester/t3-l1-pi-1rt.tst b/scripts/rt-tester/t3-l1-pi-1rt.tst
new file mode 100644
index 000000000000..63440ca2cce9
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-1rt.tst
@@ -0,0 +1,92 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedother: 1: 0
61C: schedfifo: 2: 82
62
63# T0 lock L0
64C: locknowait: 0: 0
65W: locked: 0: 0
66
67# T1 lock L0
68C: locknowait: 1: 0
69W: blocked: 1: 0
70T: priolt: 0: 1
71
72# T2 lock L0
73C: locknowait: 2: 0
74W: blocked: 2: 0
75T: prioeq: 0: 82
76
77# T0 unlock L0
78C: unlock: 0: 0
79
80# Wait until T2 got the lock
81W: locked: 2: 0
82W: unlocked: 0: 0
83T: priolt: 0: 1
84
85# T2 unlock L0
86C: unlock: 2: 0
87
88W: unlocked: 2: 0
89W: locked: 1: 0
90
91C: unlock: 1: 0
92W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l1-pi-2rt.tst b/scripts/rt-tester/t3-l1-pi-2rt.tst
new file mode 100644
index 000000000000..e5816fe67df3
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-2rt.tst
@@ -0,0 +1,93 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedfifo: 1: 81
61C: schedfifo: 2: 82
62
63# T0 lock L0
64C: locknowait: 0: 0
65W: locked: 0: 0
66
67# T1 lock L0
68C: locknowait: 1: 0
69W: blocked: 1: 0
70T: prioeq: 0: 81
71
72# T2 lock L0
73C: locknowait: 2: 0
74W: blocked: 2: 0
75T: prioeq: 0: 82
76T: prioeq: 1: 81
77
78# T0 unlock L0
79C: unlock: 0: 0
80
81# Wait until T2 got the lock
82W: locked: 2: 0
83W: unlocked: 0: 0
84T: priolt: 0: 1
85
86# T2 unlock L0
87C: unlock: 2: 0
88
89W: unlocked: 2: 0
90W: locked: 1: 0
91
92C: unlock: 1: 0
93W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l1-pi-3rt.tst b/scripts/rt-tester/t3-l1-pi-3rt.tst
new file mode 100644
index 000000000000..718b82b5d3bb
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-3rt.tst
@@ -0,0 +1,92 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedfifo: 0: 80
60C: schedfifo: 1: 81
61C: schedfifo: 2: 82
62
63# T0 lock L0
64C: locknowait: 0: 0
65W: locked: 0: 0
66
67# T1 lock L0
68C: locknowait: 1: 0
69W: blocked: 1: 0
70T: prioeq: 0: 81
71
72# T2 lock L0
73C: locknowait: 2: 0
74W: blocked: 2: 0
75T: prioeq: 0: 82
76
77# T0 unlock L0
78C: unlock: 0: 0
79
80# Wait until T2 got the lock
81W: locked: 2: 0
82W: unlocked: 0: 0
83T: prioeq: 0: 80
84
85# T2 unlock L0
86C: unlock: 2: 0
87
88W: locked: 1: 0
89W: unlocked: 2: 0
90
91C: unlock: 1: 0
92W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l1-pi-signal.tst b/scripts/rt-tester/t3-l1-pi-signal.tst
new file mode 100644
index 000000000000..c6e213563498
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-signal.tst
@@ -0,0 +1,98 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52# Reset event counter
53C: resetevent: 0: 0
54W: opcodeeq: 0: 0
55
56# Set priorities
57C: schedother: 0: 0
58C: schedfifo: 1: 80
59C: schedfifo: 2: 81
60
61# T0 lock L0
62C: lock: 0: 0
63W: locked: 0: 0
64
65# T1 lock L0, no wait in the wakeup path
66C: locknowait: 1: 0
67W: blocked: 1: 0
68T: prioeq: 0: 80
69T: prioeq: 1: 80
70
71# T2 lock L0 interruptible, no wait in the wakeup path
72C: lockintnowait: 2: 0
73W: blocked: 2: 0
74T: prioeq: 0: 81
75T: prioeq: 1: 80
76
77# Interrupt T2
78C: signal: 2: 2
79W: unlocked: 2: 0
80T: prioeq: 1: 80
81T: prioeq: 0: 80
82
83T: locked: 0: 0
84T: blocked: 1: 0
85
86# T0 unlock L0
87C: unlock: 0: 0
88
89# Wait until T1 has locked L0 and exit
90W: locked: 1: 0
91W: unlocked: 0: 0
92T: priolt: 0: 1
93
94C: unlock: 1: 0
95W: unlocked: 1: 0
96
97
98
diff --git a/scripts/rt-tester/t3-l1-pi-steal.tst b/scripts/rt-tester/t3-l1-pi-steal.tst
new file mode 100644
index 000000000000..f53749d59d79
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-steal.tst
@@ -0,0 +1,96 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI steal pending ownership
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedfifo: 1: 80
61C: schedfifo: 2: 81
62
63# T0 lock L0
64C: lock: 0: 0
65W: locked: 0: 0
66
67# T1 lock L0
68C: lock: 1: 0
69W: blocked: 1: 0
70T: prioeq: 0: 80
71
72# T0 unlock L0
73C: unlock: 0: 0
74
75# Wait until T1 is in the wakeup loop
76W: blockedwake: 1: 0
77T: priolt: 0: 1
78
79# T2 lock L0
80C: lock: 2: 0
81# T1 leave wakeup loop
82C: lockcont: 1: 0
83
84# T2 must have the lock and T1 must be blocked
85W: locked: 2: 0
86W: blocked: 1: 0
87
88# T2 unlock L0
89C: unlock: 2: 0
90
91# Wait until T1 is in the wakeup loop and let it run
92W: blockedwake: 1: 0
93C: lockcont: 1: 0
94W: locked: 1: 0
95C: unlock: 1: 0
96W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l2-pi.tst b/scripts/rt-tester/t3-l2-pi.tst
new file mode 100644
index 000000000000..cdc3e4fd7bac
--- /dev/null
+++ b/scripts/rt-tester/t3-l2-pi.tst
@@ -0,0 +1,92 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 2 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedother: 1: 0
61C: schedfifo: 2: 82
62
63# T0 lock L0
64C: locknowait: 0: 0
65W: locked: 0: 0
66
67# T1 lock L0
68C: locknowait: 1: 0
69W: blocked: 1: 0
70T: priolt: 0: 1
71
72# T2 lock L0
73C: locknowait: 2: 0
74W: blocked: 2: 0
75T: prioeq: 0: 82
76
77# T0 unlock L0
78C: unlock: 0: 0
79
80# Wait until T2 got the lock
81W: locked: 2: 0
82W: unlocked: 0: 0
83T: priolt: 0: 1
84
85# T2 unlock L0
86C: unlock: 2: 0
87
88W: unlocked: 2: 0
89W: locked: 1: 0
90
91C: unlock: 1: 0
92W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t4-l2-pi-deboost.tst b/scripts/rt-tester/t4-l2-pi-deboost.tst
new file mode 100644
index 000000000000..baa14137f473
--- /dev/null
+++ b/scripts/rt-tester/t4-l2-pi-deboost.tst
@@ -0,0 +1,123 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 4 threads 2 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedother: 1: 0
61C: schedfifo: 2: 82
62C: schedfifo: 3: 83
63
64# T0 lock L0
65C: locknowait: 0: 0
66W: locked: 0: 0
67
68# T1 lock L1
69C: locknowait: 1: 1
70W: locked: 1: 1
71
72# T3 lock L0
73C: lockintnowait: 3: 0
74W: blocked: 3: 0
75T: prioeq: 0: 83
76
77# T0 lock L1
78C: lock: 0: 1
79W: blocked: 0: 1
80T: prioeq: 1: 83
81
82# T1 unlock L1
83C: unlock: 1: 1
84
85# Wait until T0 is in the wakeup code
86W: blockedwake: 0: 1
87
88# Verify that T1 is unboosted
89W: unlocked: 1: 1
90T: priolt: 1: 1
91
92# T2 lock L1 (T0 is boosted and pending owner !)
93C: locknowait: 2: 1
94W: blocked: 2: 1
95T: prioeq: 0: 83
96
97# Interrupt T3 and wait until T3 returned
98C: signal: 3: 0
99W: unlocked: 3: 0
100
101# Verify prio of T0 (still pending owner,
102# but T2 is enqueued due to the previous boost by T3
103T: prioeq: 0: 82
104
105# Let T0 continue
106C: lockcont: 0: 1
107W: locked: 0: 1
108
109# Unlock L1 and let T2 get L1
110C: unlock: 0: 1
111W: locked: 2: 1
112
113# Verify that T0 is unboosted
114W: unlocked: 0: 1
115T: priolt: 0: 1
116
117# Unlock everything and exit
118C: unlock: 2: 1
119W: unlocked: 2: 1
120
121C: unlock: 0: 0
122W: unlocked: 0: 0
123
diff --git a/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst b/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
new file mode 100644
index 000000000000..e6ec0c81b54d
--- /dev/null
+++ b/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
@@ -0,0 +1,183 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 5 threads 4 lock PI - modify priority of blocked threads
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedfifo: 1: 81
61C: schedfifo: 2: 82
62C: schedfifo: 3: 83
63C: schedfifo: 4: 84
64
65# T0 lock L0
66C: locknowait: 0: 0
67W: locked: 0: 0
68
69# T1 lock L1
70C: locknowait: 1: 1
71W: locked: 1: 1
72
73# T1 lock L0
74C: lockintnowait: 1: 0
75W: blocked: 1: 0
76T: prioeq: 0: 81
77
78# T2 lock L2
79C: locknowait: 2: 2
80W: locked: 2: 2
81
82# T2 lock L1
83C: lockintnowait: 2: 1
84W: blocked: 2: 1
85T: prioeq: 0: 82
86T: prioeq: 1: 82
87
88# T3 lock L3
89C: locknowait: 3: 3
90W: locked: 3: 3
91
92# T3 lock L2
93C: lockintnowait: 3: 2
94W: blocked: 3: 2
95T: prioeq: 0: 83
96T: prioeq: 1: 83
97T: prioeq: 2: 83
98
99# T4 lock L3
100C: lockintnowait: 4: 3
101W: blocked: 4: 3
102T: prioeq: 0: 84
103T: prioeq: 1: 84
104T: prioeq: 2: 84
105T: prioeq: 3: 84
106
107# Reduce prio of T4
108C: schedfifo: 4: 80
109T: prioeq: 0: 83
110T: prioeq: 1: 83
111T: prioeq: 2: 83
112T: prioeq: 3: 83
113T: prioeq: 4: 80
114
115# Increase prio of T4
116C: schedfifo: 4: 84
117T: prioeq: 0: 84
118T: prioeq: 1: 84
119T: prioeq: 2: 84
120T: prioeq: 3: 84
121T: prioeq: 4: 84
122
123# Reduce prio of T3
124C: schedfifo: 3: 80
125T: prioeq: 0: 84
126T: prioeq: 1: 84
127T: prioeq: 2: 84
128T: prioeq: 3: 84
129T: prioeq: 4: 84
130
131# Increase prio of T3
132C: schedfifo: 3: 85
133T: prioeq: 0: 85
134T: prioeq: 1: 85
135T: prioeq: 2: 85
136T: prioeq: 3: 85
137T: prioeq: 4: 84
138
139# Reduce prio of T3
140C: schedfifo: 3: 83
141T: prioeq: 0: 84
142T: prioeq: 1: 84
143T: prioeq: 2: 84
144T: prioeq: 3: 84
145T: prioeq: 4: 84
146
147# Signal T4
148C: signal: 4: 0
149W: unlocked: 4: 3
150T: prioeq: 0: 83
151T: prioeq: 1: 83
152T: prioeq: 2: 83
153T: prioeq: 3: 83
154
155# Signal T3
156C: signal: 3: 0
157W: unlocked: 3: 2
158T: prioeq: 0: 82
159T: prioeq: 1: 82
160T: prioeq: 2: 82
161
162# Signal T2
163C: signal: 2: 0
164W: unlocked: 2: 1
165T: prioeq: 0: 81
166T: prioeq: 1: 81
167
168# Signal T1
169C: signal: 1: 0
170W: unlocked: 1: 0
171T: priolt: 0: 1
172
173# Unlock and exit
174C: unlock: 3: 3
175C: unlock: 2: 2
176C: unlock: 1: 1
177C: unlock: 0: 0
178
179W: unlocked: 3: 3
180W: unlocked: 2: 2
181W: unlocked: 1: 1
182W: unlocked: 0: 0
183
diff --git a/scripts/rt-tester/t5-l4-pi-boost-deboost.tst b/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
new file mode 100644
index 000000000000..ca64f8bbf4bc
--- /dev/null
+++ b/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
@@ -0,0 +1,143 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 5 threads 4 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60C: schedfifo: 1: 81
61C: schedfifo: 2: 82
62C: schedfifo: 3: 83
63C: schedfifo: 4: 84
64
65# T0 lock L0
66C: locknowait: 0: 0
67W: locked: 0: 0
68
69# T1 lock L1
70C: locknowait: 1: 1
71W: locked: 1: 1
72
73# T1 lock L0
74C: lockintnowait: 1: 0
75W: blocked: 1: 0
76T: prioeq: 0: 81
77
78# T2 lock L2
79C: locknowait: 2: 2
80W: locked: 2: 2
81
82# T2 lock L1
83C: lockintnowait: 2: 1
84W: blocked: 2: 1
85T: prioeq: 0: 82
86T: prioeq: 1: 82
87
88# T3 lock L3
89C: locknowait: 3: 3
90W: locked: 3: 3
91
92# T3 lock L2
93C: lockintnowait: 3: 2
94W: blocked: 3: 2
95T: prioeq: 0: 83
96T: prioeq: 1: 83
97T: prioeq: 2: 83
98
99# T4 lock L3
100C: lockintnowait: 4: 3
101W: blocked: 4: 3
102T: prioeq: 0: 84
103T: prioeq: 1: 84
104T: prioeq: 2: 84
105T: prioeq: 3: 84
106
107# Signal T4
108C: signal: 4: 0
109W: unlocked: 4: 3
110T: prioeq: 0: 83
111T: prioeq: 1: 83
112T: prioeq: 2: 83
113T: prioeq: 3: 83
114
115# Signal T3
116C: signal: 3: 0
117W: unlocked: 3: 2
118T: prioeq: 0: 82
119T: prioeq: 1: 82
120T: prioeq: 2: 82
121
122# Signal T2
123C: signal: 2: 0
124W: unlocked: 2: 1
125T: prioeq: 0: 81
126T: prioeq: 1: 81
127
128# Signal T1
129C: signal: 1: 0
130W: unlocked: 1: 0
131T: priolt: 0: 1
132
133# Unlock and exit
134C: unlock: 3: 3
135C: unlock: 2: 2
136C: unlock: 1: 1
137C: unlock: 0: 0
138
139W: unlocked: 3: 3
140W: unlocked: 2: 2
141W: unlocked: 1: 1
142W: unlocked: 0: 0
143
diff --git a/security/keys/internal.h b/security/keys/internal.h
index 3c2877f0663e..1bb416f4bbce 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -99,6 +99,7 @@ extern int install_process_keyring(struct task_struct *tsk);
99extern struct key *request_key_and_link(struct key_type *type, 99extern struct key *request_key_and_link(struct key_type *type,
100 const char *description, 100 const char *description,
101 const char *callout_info, 101 const char *callout_info,
102 void *aux,
102 struct key *dest_keyring, 103 struct key *dest_keyring,
103 unsigned long flags); 104 unsigned long flags);
104 105
diff --git a/security/keys/key.c b/security/keys/key.c
index 43295ca37b5d..80de8c3e9cc3 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/poison.h>
14#include <linux/sched.h> 15#include <linux/sched.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/security.h> 17#include <linux/security.h>
@@ -988,7 +989,7 @@ void unregister_key_type(struct key_type *ktype)
988 if (key->type == ktype) { 989 if (key->type == ktype) {
989 if (ktype->destroy) 990 if (ktype->destroy)
990 ktype->destroy(key); 991 ktype->destroy(key);
991 memset(&key->payload, 0xbd, sizeof(key->payload)); 992 memset(&key->payload, KEY_DESTROY, sizeof(key->payload));
992 } 993 }
993 } 994 }
994 995
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 329411cf8768..d9ca15c109cc 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -183,7 +183,7 @@ asmlinkage long sys_request_key(const char __user *_type,
183 } 183 }
184 184
185 /* do the search */ 185 /* do the search */
186 key = request_key_and_link(ktype, description, callout_info, 186 key = request_key_and_link(ktype, description, callout_info, NULL,
187 key_ref_to_ptr(dest_ref), 187 key_ref_to_ptr(dest_ref),
188 KEY_ALLOC_IN_QUOTA); 188 KEY_ALLOC_IN_QUOTA);
189 if (IS_ERR(key)) { 189 if (IS_ERR(key)) {
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 58d1efd4fc2c..f573ac189a0a 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -1,6 +1,6 @@
1/* request_key.c: request a key from userspace 1/* request_key.c: request a key from userspace
2 * 2 *
3 * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2004-6 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -33,7 +33,8 @@ DECLARE_WAIT_QUEUE_HEAD(request_key_conswq);
33 */ 33 */
34static int call_sbin_request_key(struct key *key, 34static int call_sbin_request_key(struct key *key,
35 struct key *authkey, 35 struct key *authkey,
36 const char *op) 36 const char *op,
37 void *aux)
37{ 38{
38 struct task_struct *tsk = current; 39 struct task_struct *tsk = current;
39 key_serial_t prkey, sskey; 40 key_serial_t prkey, sskey;
@@ -127,6 +128,7 @@ error_alloc:
127static struct key *__request_key_construction(struct key_type *type, 128static struct key *__request_key_construction(struct key_type *type,
128 const char *description, 129 const char *description,
129 const char *callout_info, 130 const char *callout_info,
131 void *aux,
130 unsigned long flags) 132 unsigned long flags)
131{ 133{
132 request_key_actor_t actor; 134 request_key_actor_t actor;
@@ -164,7 +166,7 @@ static struct key *__request_key_construction(struct key_type *type,
164 actor = call_sbin_request_key; 166 actor = call_sbin_request_key;
165 if (type->request_key) 167 if (type->request_key)
166 actor = type->request_key; 168 actor = type->request_key;
167 ret = actor(key, authkey, "create"); 169 ret = actor(key, authkey, "create", aux);
168 if (ret < 0) 170 if (ret < 0)
169 goto request_failed; 171 goto request_failed;
170 172
@@ -258,8 +260,9 @@ alloc_failed:
258 */ 260 */
259static struct key *request_key_construction(struct key_type *type, 261static struct key *request_key_construction(struct key_type *type,
260 const char *description, 262 const char *description,
261 struct key_user *user,
262 const char *callout_info, 263 const char *callout_info,
264 void *aux,
265 struct key_user *user,
263 unsigned long flags) 266 unsigned long flags)
264{ 267{
265 struct key_construction *pcons; 268 struct key_construction *pcons;
@@ -284,7 +287,7 @@ static struct key *request_key_construction(struct key_type *type,
284 } 287 }
285 288
286 /* see about getting userspace to construct the key */ 289 /* see about getting userspace to construct the key */
287 key = __request_key_construction(type, description, callout_info, 290 key = __request_key_construction(type, description, callout_info, aux,
288 flags); 291 flags);
289 error: 292 error:
290 kleave(" = %p", key); 293 kleave(" = %p", key);
@@ -392,6 +395,7 @@ static void request_key_link(struct key *key, struct key *dest_keyring)
392struct key *request_key_and_link(struct key_type *type, 395struct key *request_key_and_link(struct key_type *type,
393 const char *description, 396 const char *description,
394 const char *callout_info, 397 const char *callout_info,
398 void *aux,
395 struct key *dest_keyring, 399 struct key *dest_keyring,
396 unsigned long flags) 400 unsigned long flags)
397{ 401{
@@ -399,8 +403,9 @@ struct key *request_key_and_link(struct key_type *type,
399 struct key *key; 403 struct key *key;
400 key_ref_t key_ref; 404 key_ref_t key_ref;
401 405
402 kenter("%s,%s,%s,%p,%lx", 406 kenter("%s,%s,%s,%p,%p,%lx",
403 type->name, description, callout_info, dest_keyring, flags); 407 type->name, description, callout_info, aux,
408 dest_keyring, flags);
404 409
405 /* search all the process keyrings for a key */ 410 /* search all the process keyrings for a key */
406 key_ref = search_process_keyrings(type, description, type->match, 411 key_ref = search_process_keyrings(type, description, type->match,
@@ -433,8 +438,8 @@ struct key *request_key_and_link(struct key_type *type,
433 /* ask userspace (returns NULL if it waited on a key 438 /* ask userspace (returns NULL if it waited on a key
434 * being constructed) */ 439 * being constructed) */
435 key = request_key_construction(type, description, 440 key = request_key_construction(type, description,
436 user, callout_info, 441 callout_info, aux,
437 flags); 442 user, flags);
438 if (key) 443 if (key)
439 break; 444 break;
440 445
@@ -491,8 +496,27 @@ struct key *request_key(struct key_type *type,
491 const char *callout_info) 496 const char *callout_info)
492{ 497{
493 return request_key_and_link(type, description, callout_info, NULL, 498 return request_key_and_link(type, description, callout_info, NULL,
494 KEY_ALLOC_IN_QUOTA); 499 NULL, KEY_ALLOC_IN_QUOTA);
495 500
496} /* end request_key() */ 501} /* end request_key() */
497 502
498EXPORT_SYMBOL(request_key); 503EXPORT_SYMBOL(request_key);
504
505/*****************************************************************************/
506/*
507 * request a key with auxiliary data for the upcaller
508 * - search the process's keyrings
509 * - check the list of keys being created or updated
510 * - call out to userspace for a key if supplementary info was provided
511 */
512struct key *request_key_with_auxdata(struct key_type *type,
513 const char *description,
514 const char *callout_info,
515 void *aux)
516{
517 return request_key_and_link(type, description, callout_info, aux,
518 NULL, KEY_ALLOC_IN_QUOTA);
519
520} /* end request_key_with_auxdata() */
521
522EXPORT_SYMBOL(request_key_with_auxdata);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index ac7f2b2e3924..28832e689800 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1532,8 +1532,9 @@ static int selinux_bprm_set_security(struct linux_binprm *bprm)
1532 /* Default to the current task SID. */ 1532 /* Default to the current task SID. */
1533 bsec->sid = tsec->sid; 1533 bsec->sid = tsec->sid;
1534 1534
1535 /* Reset create and sockcreate SID on execve. */ 1535 /* Reset fs, key, and sock SIDs on execve. */
1536 tsec->create_sid = 0; 1536 tsec->create_sid = 0;
1537 tsec->keycreate_sid = 0;
1537 tsec->sockcreate_sid = 0; 1538 tsec->sockcreate_sid = 0;
1538 1539
1539 if (tsec->exec_sid) { 1540 if (tsec->exec_sid) {
@@ -2586,9 +2587,10 @@ static int selinux_task_alloc_security(struct task_struct *tsk)
2586 tsec2->osid = tsec1->osid; 2587 tsec2->osid = tsec1->osid;
2587 tsec2->sid = tsec1->sid; 2588 tsec2->sid = tsec1->sid;
2588 2589
2589 /* Retain the exec, create, and sock SIDs across fork */ 2590 /* Retain the exec, fs, key, and sock SIDs across fork */
2590 tsec2->exec_sid = tsec1->exec_sid; 2591 tsec2->exec_sid = tsec1->exec_sid;
2591 tsec2->create_sid = tsec1->create_sid; 2592 tsec2->create_sid = tsec1->create_sid;
2593 tsec2->keycreate_sid = tsec1->keycreate_sid;
2592 tsec2->sockcreate_sid = tsec1->sockcreate_sid; 2594 tsec2->sockcreate_sid = tsec1->sockcreate_sid;
2593 2595
2594 /* Retain ptracer SID across fork, if any. 2596 /* Retain ptracer SID across fork, if any.
diff --git a/sound/Makefile b/sound/Makefile
index a682ea30f0c9..1f60797afa8a 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -4,7 +4,8 @@
4obj-$(CONFIG_SOUND) += soundcore.o 4obj-$(CONFIG_SOUND) += soundcore.o
5obj-$(CONFIG_SOUND_PRIME) += oss/ 5obj-$(CONFIG_SOUND_PRIME) += oss/
6obj-$(CONFIG_DMASOUND) += oss/ 6obj-$(CONFIG_DMASOUND) += oss/
7obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ aoa/ 7obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/
8obj-$(CONFIG_SND_AOA) += aoa/
8 9
9ifeq ($(CONFIG_SND),y) 10ifeq ($(CONFIG_SND),y)
10 obj-y += last.o 11 obj-y += last.o
diff --git a/sound/aoa/Kconfig b/sound/aoa/Kconfig
index a85194fe0b06..2f4334d19ccd 100644
--- a/sound/aoa/Kconfig
+++ b/sound/aoa/Kconfig
@@ -3,7 +3,8 @@ menu "Apple Onboard Audio driver"
3 3
4config SND_AOA 4config SND_AOA
5 tristate "Apple Onboard Audio driver" 5 tristate "Apple Onboard Audio driver"
6 depends on SOUND && SND_PCM 6 depends on SND
7 select SND_PCM
7 ---help--- 8 ---help---
8 This option enables the new driver for the various 9 This option enables the new driver for the various
9 Apple Onboard Audio components. 10 Apple Onboard Audio components.
diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
index 2c6eb7784cc9..bab97547a052 100644
--- a/sound/aoa/core/snd-aoa-gpio-feature.c
+++ b/sound/aoa/core/snd-aoa-gpio-feature.c
@@ -207,6 +207,17 @@ static void ftr_handle_notify(void *data)
207 mutex_unlock(&notif->mutex); 207 mutex_unlock(&notif->mutex);
208} 208}
209 209
210static void gpio_enable_dual_edge(int gpio)
211{
212 int v;
213
214 if (gpio == -1)
215 return;
216 v = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio, 0);
217 v |= 0x80; /* enable dual edge */
218 pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio, v);
219}
220
210static void ftr_gpio_init(struct gpio_runtime *rt) 221static void ftr_gpio_init(struct gpio_runtime *rt)
211{ 222{
212 get_gpio("headphone-mute", NULL, 223 get_gpio("headphone-mute", NULL,
@@ -234,6 +245,10 @@ static void ftr_gpio_init(struct gpio_runtime *rt)
234 &linein_detect_gpio, 245 &linein_detect_gpio,
235 &linein_detect_gpio_activestate); 246 &linein_detect_gpio_activestate);
236 247
248 gpio_enable_dual_edge(headphone_detect_gpio);
249 gpio_enable_dual_edge(lineout_detect_gpio);
250 gpio_enable_dual_edge(linein_detect_gpio);
251
237 get_irq(headphone_detect_node, &headphone_detect_irq); 252 get_irq(headphone_detect_node, &headphone_detect_irq);
238 get_irq(lineout_detect_node, &lineout_detect_irq); 253 get_irq(lineout_detect_node, &lineout_detect_irq);
239 get_irq(linein_detect_node, &linein_detect_irq); 254 get_irq(linein_detect_node, &linein_detect_irq);
diff --git a/sound/aoa/fabrics/snd-aoa-fabric-layout.c b/sound/aoa/fabrics/snd-aoa-fabric-layout.c
index 04a7238e9494..cbc8a3b5cea4 100644
--- a/sound/aoa/fabrics/snd-aoa-fabric-layout.c
+++ b/sound/aoa/fabrics/snd-aoa-fabric-layout.c
@@ -94,6 +94,7 @@ MODULE_ALIAS("sound-layout-82");
94MODULE_ALIAS("sound-layout-84"); 94MODULE_ALIAS("sound-layout-84");
95MODULE_ALIAS("sound-layout-86"); 95MODULE_ALIAS("sound-layout-86");
96MODULE_ALIAS("sound-layout-92"); 96MODULE_ALIAS("sound-layout-92");
97MODULE_ALIAS("sound-layout-96");
97 98
98/* onyx with all but microphone connected */ 99/* onyx with all but microphone connected */
99static struct codec_connection onyx_connections_nomic[] = { 100static struct codec_connection onyx_connections_nomic[] = {
@@ -381,6 +382,13 @@ static struct layout layouts[] = {
381 .connections = toonie_connections, 382 .connections = toonie_connections,
382 }, 383 },
383 }, 384 },
385 {
386 .layout_id = 96,
387 .codecs[0] = {
388 .name = "onyx",
389 .connections = onyx_connections_noheadphones,
390 },
391 },
384 /* unknown, untested, but this comes from Apple */ 392 /* unknown, untested, but this comes from Apple */
385 { .layout_id = 41, 393 { .layout_id = 41,
386 .codecs[0] = { 394 .codecs[0] = {
@@ -479,12 +487,6 @@ static struct layout layouts[] = {
479 .connections = onyx_connections_noheadphones, 487 .connections = onyx_connections_noheadphones,
480 }, 488 },
481 }, 489 },
482 { .layout_id = 96,
483 .codecs[0] = {
484 .name = "onyx",
485 .connections = onyx_connections_noheadphones,
486 },
487 },
488 { .layout_id = 98, 490 { .layout_id = 98,
489 .codecs[0] = { 491 .codecs[0] = {
490 .name = "toonie", 492 .name = "toonie",
diff --git a/sound/aoa/soundbus/Kconfig b/sound/aoa/soundbus/Kconfig
index d532d27a9f54..7368b7ddfe0d 100644
--- a/sound/aoa/soundbus/Kconfig
+++ b/sound/aoa/soundbus/Kconfig
@@ -1,6 +1,7 @@
1config SND_AOA_SOUNDBUS 1config SND_AOA_SOUNDBUS
2 tristate "Apple Soundbus support" 2 tristate "Apple Soundbus support"
3 depends on SOUND && SND_PCM && EXPERIMENTAL 3 depends on SOUND
4 select SND_PCM
4 ---help--- 5 ---help---
5 This option enables the generic driver for the soundbus 6 This option enables the generic driver for the soundbus
6 support on Apple machines. 7 support on Apple machines.
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 5f22d70fefc0..6b18225672c7 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -779,8 +779,9 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
779 strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver)); 779 strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver));
780 strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname)); 780 strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname));
781 snprintf(card->longname, sizeof(card->longname), 781 snprintf(card->longname, sizeof(card->longname),
782 "%s at 0x%08lx, irq %d", 782 "%s at 0x%016llx, irq %d",
783 card->shortname, dev->res.start, dev->irq[0]); 783 card->shortname, (unsigned long long)dev->res.start,
784 dev->irq[0]);
784 785
785 aaci = card->private_data; 786 aaci = card->private_data;
786 mutex_init(&aaci->ac97_sem); 787 mutex_init(&aaci->ac97_sem);
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index 4262a1c87731..b2927523d79d 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -122,8 +122,8 @@ config SND_SEQ_RTCTIMER_DEFAULT
122 If in doubt, say Y. 122 If in doubt, say Y.
123 123
124config SND_DYNAMIC_MINORS 124config SND_DYNAMIC_MINORS
125 bool "Dynamic device file minor numbers (EXPERIMENTAL)" 125 bool "Dynamic device file minor numbers"
126 depends on SND && EXPERIMENTAL 126 depends on SND
127 help 127 help
128 If you say Y here, the minor numbers of ALSA device files in 128 If you say Y here, the minor numbers of ALSA device files in
129 /dev/snd/ are allocated dynamically. This allows you to have 129 /dev/snd/ are allocated dynamically. This allows you to have
diff --git a/sound/core/info.c b/sound/core/info.c
index 10c1772bf3ea..340332c6d973 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -29,7 +29,6 @@
29#include <sound/info.h> 29#include <sound/info.h>
30#include <sound/version.h> 30#include <sound/version.h>
31#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
32#include <linux/devfs_fs_kernel.h>
33#include <linux/mutex.h> 32#include <linux/mutex.h>
34#include <stdarg.h> 33#include <stdarg.h>
35 34
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 334579a9f268..d467b4f0ff2b 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -322,10 +322,8 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
322 mutex_lock(&client->ports_mutex); 322 mutex_lock(&client->ports_mutex);
323 write_lock_irqsave(&client->ports_lock, flags); 323 write_lock_irqsave(&client->ports_lock, flags);
324 if (! list_empty(&client->ports_list_head)) { 324 if (! list_empty(&client->ports_list_head)) {
325 __list_add(&deleted_list, 325 list_add(&deleted_list, &client->ports_list_head);
326 client->ports_list_head.prev, 326 list_del_init(&client->ports_list_head);
327 client->ports_list_head.next);
328 INIT_LIST_HEAD(&client->ports_list_head);
329 } else { 327 } else {
330 INIT_LIST_HEAD(&deleted_list); 328 INIT_LIST_HEAD(&deleted_list);
331 } 329 }
diff --git a/sound/core/sound.c b/sound/core/sound.c
index cd862728346c..264f2efd1af8 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -32,7 +32,6 @@
32#include <sound/control.h> 32#include <sound/control.h>
33#include <sound/initval.h> 33#include <sound/initval.h>
34#include <linux/kmod.h> 34#include <linux/kmod.h>
35#include <linux/devfs_fs_kernel.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
37 36
38#define SNDRV_OS_MINORS 256 37#define SNDRV_OS_MINORS 256
@@ -42,7 +41,6 @@ int snd_major;
42EXPORT_SYMBOL(snd_major); 41EXPORT_SYMBOL(snd_major);
43 42
44static int cards_limit = 1; 43static int cards_limit = 1;
45static int device_mode = S_IFCHR | S_IRUGO | S_IWUGO;
46 44
47MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 45MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
48MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards."); 46MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
@@ -51,10 +49,6 @@ module_param(major, int, 0444);
51MODULE_PARM_DESC(major, "Major # for sound driver."); 49MODULE_PARM_DESC(major, "Major # for sound driver.");
52module_param(cards_limit, int, 0444); 50module_param(cards_limit, int, 0444);
53MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards."); 51MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards.");
54#ifdef CONFIG_DEVFS_FS
55module_param(device_mode, int, 0444);
56MODULE_PARM_DESC(device_mode, "Device file permission mask for devfs.");
57#endif
58MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR); 52MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
59 53
60/* this one holds the actual max. card number currently available. 54/* this one holds the actual max. card number currently available.
@@ -273,8 +267,6 @@ int snd_register_device(int type, struct snd_card *card, int dev,
273 return minor; 267 return minor;
274 } 268 }
275 snd_minors[minor] = preg; 269 snd_minors[minor] = preg;
276 if (type != SNDRV_DEVICE_TYPE_CONTROL || preg->card >= cards_limit)
277 devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
278 if (card) 270 if (card)
279 device = card->dev; 271 device = card->dev;
280 class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name); 272 class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);
@@ -314,9 +306,6 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
314 return -EINVAL; 306 return -EINVAL;
315 } 307 }
316 308
317 if (mptr->type != SNDRV_DEVICE_TYPE_CONTROL ||
318 mptr->card >= cards_limit) /* created in sound.c */
319 devfs_remove("snd/%s", mptr->name);
320 class_device_destroy(sound_class, MKDEV(major, minor)); 309 class_device_destroy(sound_class, MKDEV(major, minor));
321 310
322 snd_minors[minor] = NULL; 311 snd_minors[minor] = NULL;
@@ -411,24 +400,17 @@ int __exit snd_minor_info_done(void)
411 400
412static int __init alsa_sound_init(void) 401static int __init alsa_sound_init(void)
413{ 402{
414 short controlnum;
415
416 snd_major = major; 403 snd_major = major;
417 snd_ecards_limit = cards_limit; 404 snd_ecards_limit = cards_limit;
418 devfs_mk_dir("snd");
419 if (register_chrdev(major, "alsa", &snd_fops)) { 405 if (register_chrdev(major, "alsa", &snd_fops)) {
420 snd_printk(KERN_ERR "unable to register native major device number %d\n", major); 406 snd_printk(KERN_ERR "unable to register native major device number %d\n", major);
421 devfs_remove("snd");
422 return -EIO; 407 return -EIO;
423 } 408 }
424 if (snd_info_init() < 0) { 409 if (snd_info_init() < 0) {
425 unregister_chrdev(major, "alsa"); 410 unregister_chrdev(major, "alsa");
426 devfs_remove("snd");
427 return -ENOMEM; 411 return -ENOMEM;
428 } 412 }
429 snd_info_minor_register(); 413 snd_info_minor_register();
430 for (controlnum = 0; controlnum < cards_limit; controlnum++)
431 devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum);
432#ifndef MODULE 414#ifndef MODULE
433 printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n"); 415 printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n");
434#endif 416#endif
@@ -437,16 +419,10 @@ static int __init alsa_sound_init(void)
437 419
438static void __exit alsa_sound_exit(void) 420static void __exit alsa_sound_exit(void)
439{ 421{
440 short controlnum;
441
442 for (controlnum = 0; controlnum < cards_limit; controlnum++)
443 devfs_remove("snd/controlC%d", controlnum);
444
445 snd_info_minor_unregister(); 422 snd_info_minor_unregister();
446 snd_info_done(); 423 snd_info_done();
447 if (unregister_chrdev(major, "alsa") != 0) 424 if (unregister_chrdev(major, "alsa") != 0)
448 snd_printk(KERN_ERR "unable to unregister major device number %d\n", major); 425 snd_printk(KERN_ERR "unable to unregister major device number %d\n", major);
449 devfs_remove("snd");
450} 426}
451 427
452module_init(alsa_sound_init) 428module_init(alsa_sound_init)
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index d3cbbb047582..8b80024968be 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -160,8 +160,9 @@ static int __devinit snd_mpu401_pnp(int dev, struct pnp_dev *device,
160 return -ENODEV; 160 return -ENODEV;
161 } 161 }
162 if (pnp_port_len(device, 0) < IO_EXTENT) { 162 if (pnp_port_len(device, 0) < IO_EXTENT) {
163 snd_printk(KERN_ERR "PnP port length is %ld, expected %d\n", 163 snd_printk(KERN_ERR "PnP port length is %llu, expected %d\n",
164 pnp_port_len(device, 0), IO_EXTENT); 164 (unsigned long long)pnp_port_len(device, 0),
165 IO_EXTENT);
165 return -ENODEV; 166 return -ENODEV;
166 } 167 }
167 port[dev] = pnp_port_start(device, 0); 168 port[dev] = pnp_port_start(device, 0);
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c
index 045e32a311e0..dc7cc2001b74 100644
--- a/sound/i2c/other/ak4xxx-adda.c
+++ b/sound/i2c/other/ak4xxx-adda.c
@@ -34,7 +34,8 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Takashi Iwai <tiwai@suse.de>");
34MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters"); 34MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
37void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val) 37void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
38 unsigned char val)
38{ 39{
39 ak->ops.lock(ak, chip); 40 ak->ops.lock(ak, chip);
40 ak->ops.write(ak, chip, reg, val); 41 ak->ops.write(ak, chip, reg, val);
@@ -52,6 +53,67 @@ void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsi
52 ak->ops.unlock(ak, chip); 53 ak->ops.unlock(ak, chip);
53} 54}
54 55
56EXPORT_SYMBOL(snd_akm4xxx_write);
57
58/* reset procedure for AK4524 and AK4528 */
59static void ak4524_reset(struct snd_akm4xxx *ak, int state)
60{
61 unsigned int chip;
62 unsigned char reg, maxreg;
63
64 if (ak->type == SND_AK4528)
65 maxreg = 0x06;
66 else
67 maxreg = 0x08;
68 for (chip = 0; chip < ak->num_dacs/2; chip++) {
69 snd_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03);
70 if (state)
71 continue;
72 /* DAC volumes */
73 for (reg = 0x04; reg < maxreg; reg++)
74 snd_akm4xxx_write(ak, chip, reg,
75 snd_akm4xxx_get(ak, chip, reg));
76 if (ak->type == SND_AK4528)
77 continue;
78 /* IPGA */
79 for (reg = 0x04; reg < 0x06; reg++)
80 snd_akm4xxx_write(ak, chip, reg,
81 snd_akm4xxx_get_ipga(ak, chip, reg));
82 }
83}
84
85/* reset procedure for AK4355 and AK4358 */
86static void ak4355_reset(struct snd_akm4xxx *ak, int state)
87{
88 unsigned char reg;
89
90 if (state) {
91 snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */
92 return;
93 }
94 for (reg = 0x00; reg < 0x0b; reg++)
95 if (reg != 0x01)
96 snd_akm4xxx_write(ak, 0, reg,
97 snd_akm4xxx_get(ak, 0, reg));
98 snd_akm4xxx_write(ak, 0, 0x01, 0x01); /* un-reset, unmute */
99}
100
101/* reset procedure for AK4381 */
102static void ak4381_reset(struct snd_akm4xxx *ak, int state)
103{
104 unsigned int chip;
105 unsigned char reg;
106
107 for (chip = 0; chip < ak->num_dacs/2; chip++) {
108 snd_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f);
109 if (state)
110 continue;
111 for (reg = 0x01; reg < 0x05; reg++)
112 snd_akm4xxx_write(ak, chip, reg,
113 snd_akm4xxx_get(ak, chip, reg));
114 }
115}
116
55/* 117/*
56 * reset the AKM codecs 118 * reset the AKM codecs
57 * @state: 1 = reset codec, 0 = restore the registers 119 * @state: 1 = reset codec, 0 = restore the registers
@@ -60,52 +122,26 @@ void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsi
60 */ 122 */
61void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state) 123void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state)
62{ 124{
63 unsigned int chip;
64 unsigned char reg;
65
66 switch (ak->type) { 125 switch (ak->type) {
67 case SND_AK4524: 126 case SND_AK4524:
68 case SND_AK4528: 127 case SND_AK4528:
69 for (chip = 0; chip < ak->num_dacs/2; chip++) { 128 ak4524_reset(ak, state);
70 snd_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03);
71 if (state)
72 continue;
73 /* DAC volumes */
74 for (reg = 0x04; reg < (ak->type == SND_AK4528 ? 0x06 : 0x08); reg++)
75 snd_akm4xxx_write(ak, chip, reg, snd_akm4xxx_get(ak, chip, reg));
76 if (ak->type == SND_AK4528)
77 continue;
78 /* IPGA */
79 for (reg = 0x04; reg < 0x06; reg++)
80 snd_akm4xxx_write(ak, chip, reg, snd_akm4xxx_get_ipga(ak, chip, reg));
81 }
82 break; 129 break;
83 case SND_AK4529: 130 case SND_AK4529:
84 /* FIXME: needed for ak4529? */ 131 /* FIXME: needed for ak4529? */
85 break; 132 break;
86 case SND_AK4355: 133 case SND_AK4355:
87 case SND_AK4358: 134 case SND_AK4358:
88 if (state) { 135 ak4355_reset(ak, state);
89 snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */
90 return;
91 }
92 for (reg = 0x00; reg < 0x0b; reg++)
93 if (reg != 0x01)
94 snd_akm4xxx_write(ak, 0, reg, snd_akm4xxx_get(ak, 0, reg));
95 snd_akm4xxx_write(ak, 0, 0x01, 0x01); /* un-reset, unmute */
96 break; 136 break;
97 case SND_AK4381: 137 case SND_AK4381:
98 for (chip = 0; chip < ak->num_dacs/2; chip++) { 138 ak4381_reset(ak, state);
99 snd_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f);
100 if (state)
101 continue;
102 for (reg = 0x01; reg < 0x05; reg++)
103 snd_akm4xxx_write(ak, chip, reg, snd_akm4xxx_get(ak, chip, reg));
104 }
105 break; 139 break;
106 } 140 }
107} 141}
108 142
143EXPORT_SYMBOL(snd_akm4xxx_reset);
144
109/* 145/*
110 * initialize all the ak4xxx chips 146 * initialize all the ak4xxx chips
111 */ 147 */
@@ -153,7 +189,8 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
153 }; 189 };
154 static unsigned char inits_ak4355[] = { 190 static unsigned char inits_ak4355[] = {
155 0x01, 0x02, /* 1: reset and soft-mute */ 191 0x01, 0x02, /* 1: reset and soft-mute */
156 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect, disable DZF, sharp roll-off, RSTN#=0 */ 192 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect,
193 * disable DZF, sharp roll-off, RSTN#=0 */
157 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */ 194 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */
158 // 0x02, 0x2e, /* quad speed */ 195 // 0x02, 0x2e, /* quad speed */
159 0x03, 0x01, /* 3: de-emphasis off */ 196 0x03, 0x01, /* 3: de-emphasis off */
@@ -169,7 +206,8 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
169 }; 206 };
170 static unsigned char inits_ak4358[] = { 207 static unsigned char inits_ak4358[] = {
171 0x01, 0x02, /* 1: reset and soft-mute */ 208 0x01, 0x02, /* 1: reset and soft-mute */
172 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect, disable DZF, sharp roll-off, RSTN#=0 */ 209 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect,
210 * disable DZF, sharp roll-off, RSTN#=0 */
173 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */ 211 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */
174 // 0x02, 0x2e, /* quad speed */ 212 // 0x02, 0x2e, /* quad speed */
175 0x03, 0x01, /* 3: de-emphasis off */ 213 0x03, 0x01, /* 3: de-emphasis off */
@@ -187,7 +225,8 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
187 }; 225 };
188 static unsigned char inits_ak4381[] = { 226 static unsigned char inits_ak4381[] = {
189 0x00, 0x0c, /* 0: mode3(i2s), disable auto-clock detect */ 227 0x00, 0x0c, /* 0: mode3(i2s), disable auto-clock detect */
190 0x01, 0x02, /* 1: de-emphasis off, normal speed, sharp roll-off, DZF off */ 228 0x01, 0x02, /* 1: de-emphasis off, normal speed,
229 * sharp roll-off, DZF off */
191 // 0x01, 0x12, /* quad speed */ 230 // 0x01, 0x12, /* quad speed */
192 0x02, 0x00, /* 2: DZF disabled */ 231 0x02, 0x00, /* 2: DZF disabled */
193 0x03, 0x00, /* 3: LATT 0 */ 232 0x03, 0x00, /* 3: LATT 0 */
@@ -239,12 +278,15 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
239 } 278 }
240} 279}
241 280
281EXPORT_SYMBOL(snd_akm4xxx_init);
282
242#define AK_GET_CHIP(val) (((val) >> 8) & 0xff) 283#define AK_GET_CHIP(val) (((val) >> 8) & 0xff)
243#define AK_GET_ADDR(val) ((val) & 0xff) 284#define AK_GET_ADDR(val) ((val) & 0xff)
244#define AK_GET_SHIFT(val) (((val) >> 16) & 0x7f) 285#define AK_GET_SHIFT(val) (((val) >> 16) & 0x7f)
245#define AK_GET_INVERT(val) (((val) >> 23) & 1) 286#define AK_GET_INVERT(val) (((val) >> 23) & 1)
246#define AK_GET_MASK(val) (((val) >> 24) & 0xff) 287#define AK_GET_MASK(val) (((val) >> 24) & 0xff)
247#define AK_COMPOSE(chip,addr,shift,mask) (((chip) << 8) | (addr) | ((shift) << 16) | ((mask) << 24)) 288#define AK_COMPOSE(chip,addr,shift,mask) \
289 (((chip) << 8) | (addr) | ((shift) << 16) | ((mask) << 24))
248#define AK_INVERT (1<<23) 290#define AK_INVERT (1<<23)
249 291
250static int snd_akm4xxx_volume_info(struct snd_kcontrol *kcontrol, 292static int snd_akm4xxx_volume_info(struct snd_kcontrol *kcontrol,
@@ -292,6 +334,64 @@ static int snd_akm4xxx_volume_put(struct snd_kcontrol *kcontrol,
292 return change; 334 return change;
293} 335}
294 336
337static int snd_akm4xxx_stereo_volume_info(struct snd_kcontrol *kcontrol,
338 struct snd_ctl_elem_info *uinfo)
339{
340 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
341
342 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
343 uinfo->count = 2;
344 uinfo->value.integer.min = 0;
345 uinfo->value.integer.max = mask;
346 return 0;
347}
348
349static int snd_akm4xxx_stereo_volume_get(struct snd_kcontrol *kcontrol,
350 struct snd_ctl_elem_value *ucontrol)
351{
352 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
353 int chip = AK_GET_CHIP(kcontrol->private_value);
354 int addr = AK_GET_ADDR(kcontrol->private_value);
355 int invert = AK_GET_INVERT(kcontrol->private_value);
356 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
357 unsigned char val = snd_akm4xxx_get(ak, chip, addr);
358
359 ucontrol->value.integer.value[0] = invert ? mask - val : val;
360
361 val = snd_akm4xxx_get(ak, chip, addr+1);
362 ucontrol->value.integer.value[1] = invert ? mask - val : val;
363
364 return 0;
365}
366
367static int snd_akm4xxx_stereo_volume_put(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_value *ucontrol)
369{
370 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
371 int chip = AK_GET_CHIP(kcontrol->private_value);
372 int addr = AK_GET_ADDR(kcontrol->private_value);
373 int invert = AK_GET_INVERT(kcontrol->private_value);
374 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
375 unsigned char nval = ucontrol->value.integer.value[0] % (mask+1);
376 int change0, change1;
377
378 if (invert)
379 nval = mask - nval;
380 change0 = snd_akm4xxx_get(ak, chip, addr) != nval;
381 if (change0)
382 snd_akm4xxx_write(ak, chip, addr, nval);
383
384 nval = ucontrol->value.integer.value[1] % (mask+1);
385 if (invert)
386 nval = mask - nval;
387 change1 = snd_akm4xxx_get(ak, chip, addr+1) != nval;
388 if (change1)
389 snd_akm4xxx_write(ak, chip, addr+1, nval);
390
391
392 return change0 || change1;
393}
394
295static int snd_akm4xxx_ipga_gain_info(struct snd_kcontrol *kcontrol, 395static int snd_akm4xxx_ipga_gain_info(struct snd_kcontrol *kcontrol,
296 struct snd_ctl_elem_info *uinfo) 396 struct snd_ctl_elem_info *uinfo)
297{ 397{
@@ -308,7 +408,8 @@ static int snd_akm4xxx_ipga_gain_get(struct snd_kcontrol *kcontrol,
308 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); 408 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
309 int chip = AK_GET_CHIP(kcontrol->private_value); 409 int chip = AK_GET_CHIP(kcontrol->private_value);
310 int addr = AK_GET_ADDR(kcontrol->private_value); 410 int addr = AK_GET_ADDR(kcontrol->private_value);
311 ucontrol->value.integer.value[0] = snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f; 411 ucontrol->value.integer.value[0] =
412 snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f;
312 return 0; 413 return 0;
313} 414}
314 415
@@ -336,7 +437,8 @@ static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol,
336 uinfo->value.enumerated.items = 4; 437 uinfo->value.enumerated.items = 4;
337 if (uinfo->value.enumerated.item >= 4) 438 if (uinfo->value.enumerated.item >= 4)
338 uinfo->value.enumerated.item = 3; 439 uinfo->value.enumerated.item = 3;
339 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 440 strcpy(uinfo->value.enumerated.name,
441 texts[uinfo->value.enumerated.item]);
340 return 0; 442 return 0;
341} 443}
342 444
@@ -347,7 +449,8 @@ static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol,
347 int chip = AK_GET_CHIP(kcontrol->private_value); 449 int chip = AK_GET_CHIP(kcontrol->private_value);
348 int addr = AK_GET_ADDR(kcontrol->private_value); 450 int addr = AK_GET_ADDR(kcontrol->private_value);
349 int shift = AK_GET_SHIFT(kcontrol->private_value); 451 int shift = AK_GET_SHIFT(kcontrol->private_value);
350 ucontrol->value.enumerated.item[0] = (snd_akm4xxx_get(ak, chip, addr) >> shift) & 3; 452 ucontrol->value.enumerated.item[0] =
453 (snd_akm4xxx_get(ak, chip, addr) >> shift) & 3;
351 return 0; 454 return 0;
352} 455}
353 456
@@ -361,7 +464,8 @@ static int snd_akm4xxx_deemphasis_put(struct snd_kcontrol *kcontrol,
361 unsigned char nval = ucontrol->value.enumerated.item[0] & 3; 464 unsigned char nval = ucontrol->value.enumerated.item[0] & 3;
362 int change; 465 int change;
363 466
364 nval = (nval << shift) | (snd_akm4xxx_get(ak, chip, addr) & ~(3 << shift)); 467 nval = (nval << shift) |
468 (snd_akm4xxx_get(ak, chip, addr) & ~(3 << shift));
365 change = snd_akm4xxx_get(ak, chip, addr) != nval; 469 change = snd_akm4xxx_get(ak, chip, addr) != nval;
366 if (change) 470 if (change)
367 snd_akm4xxx_write(ak, chip, addr, nval); 471 snd_akm4xxx_write(ak, chip, addr, nval);
@@ -377,51 +481,86 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
377 unsigned int idx, num_emphs; 481 unsigned int idx, num_emphs;
378 struct snd_kcontrol *ctl; 482 struct snd_kcontrol *ctl;
379 int err; 483 int err;
484 int mixer_ch = 0;
485 int num_stereo;
380 486
381 ctl = kmalloc(sizeof(*ctl), GFP_KERNEL); 487 ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);
382 if (! ctl) 488 if (! ctl)
383 return -ENOMEM; 489 return -ENOMEM;
384 490
385 for (idx = 0; idx < ak->num_dacs; ++idx) { 491 for (idx = 0; idx < ak->num_dacs; ) {
386 memset(ctl, 0, sizeof(*ctl)); 492 memset(ctl, 0, sizeof(*ctl));
387 strcpy(ctl->id.name, "DAC Volume"); 493 if (ak->channel_names == NULL) {
388 ctl->id.index = idx + ak->idx_offset * 2; 494 strcpy(ctl->id.name, "DAC Volume");
495 num_stereo = 1;
496 ctl->id.index = mixer_ch + ak->idx_offset * 2;
497 } else {
498 strcpy(ctl->id.name, ak->channel_names[mixer_ch]);
499 num_stereo = ak->num_stereo[mixer_ch];
500 ctl->id.index = 0;
501 }
389 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 502 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
390 ctl->count = 1; 503 ctl->count = 1;
391 ctl->info = snd_akm4xxx_volume_info; 504 if (num_stereo == 2) {
392 ctl->get = snd_akm4xxx_volume_get; 505 ctl->info = snd_akm4xxx_stereo_volume_info;
393 ctl->put = snd_akm4xxx_volume_put; 506 ctl->get = snd_akm4xxx_stereo_volume_get;
507 ctl->put = snd_akm4xxx_stereo_volume_put;
508 } else {
509 ctl->info = snd_akm4xxx_volume_info;
510 ctl->get = snd_akm4xxx_volume_get;
511 ctl->put = snd_akm4xxx_volume_put;
512 }
394 switch (ak->type) { 513 switch (ak->type) {
395 case SND_AK4524: 514 case SND_AK4524:
396 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127); /* register 6 & 7 */ 515 /* register 6 & 7 */
516 ctl->private_value =
517 AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127);
397 break; 518 break;
398 case SND_AK4528: 519 case SND_AK4528:
399 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */ 520 /* register 4 & 5 */
521 ctl->private_value =
522 AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127);
400 break; 523 break;
401 case SND_AK4529: { 524 case SND_AK4529: {
402 int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb; /* registers 2-7 and b,c */ 525 /* registers 2-7 and b,c */
403 ctl->private_value = AK_COMPOSE(0, val, 0, 255) | AK_INVERT; 526 int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb;
527 ctl->private_value =
528 AK_COMPOSE(0, val, 0, 255) | AK_INVERT;
404 break; 529 break;
405 } 530 }
406 case SND_AK4355: 531 case SND_AK4355:
407 ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */ 532 /* register 4-9, chip #0 only */
533 ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255);
408 break; 534 break;
409 case SND_AK4358: 535 case SND_AK4358:
410 if (idx >= 6) 536 if (idx >= 6)
411 ctl->private_value = AK_COMPOSE(0, idx + 5, 0, 255); /* register 4-9, chip #0 only */ 537 /* register 4-9, chip #0 only */
538 ctl->private_value =
539 AK_COMPOSE(0, idx + 5, 0, 255);
412 else 540 else
413 ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */ 541 /* register 4-9, chip #0 only */
542 ctl->private_value =
543 AK_COMPOSE(0, idx + 4, 0, 255);
414 break; 544 break;
415 case SND_AK4381: 545 case SND_AK4381:
416 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); /* register 3 & 4 */ 546 /* register 3 & 4 */
547 ctl->private_value =
548 AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255);
417 break; 549 break;
418 default: 550 default:
419 err = -EINVAL; 551 err = -EINVAL;
420 goto __error; 552 goto __error;
421 } 553 }
554
422 ctl->private_data = ak; 555 ctl->private_data = ak;
423 if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0) 556 err = snd_ctl_add(ak->card,
557 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
558 SNDRV_CTL_ELEM_ACCESS_WRITE));
559 if (err < 0)
424 goto __error; 560 goto __error;
561
562 idx += num_stereo;
563 mixer_ch++;
425 } 564 }
426 for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) { 565 for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) {
427 memset(ctl, 0, sizeof(*ctl)); 566 memset(ctl, 0, sizeof(*ctl));
@@ -432,9 +571,14 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
432 ctl->info = snd_akm4xxx_volume_info; 571 ctl->info = snd_akm4xxx_volume_info;
433 ctl->get = snd_akm4xxx_volume_get; 572 ctl->get = snd_akm4xxx_volume_get;
434 ctl->put = snd_akm4xxx_volume_put; 573 ctl->put = snd_akm4xxx_volume_put;
435 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */ 574 /* register 4 & 5 */
575 ctl->private_value =
576 AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127);
436 ctl->private_data = ak; 577 ctl->private_data = ak;
437 if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0) 578 err = snd_ctl_add(ak->card,
579 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
580 SNDRV_CTL_ELEM_ACCESS_WRITE));
581 if (err < 0)
438 goto __error; 582 goto __error;
439 583
440 memset(ctl, 0, sizeof(*ctl)); 584 memset(ctl, 0, sizeof(*ctl));
@@ -445,9 +589,13 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
445 ctl->info = snd_akm4xxx_ipga_gain_info; 589 ctl->info = snd_akm4xxx_ipga_gain_info;
446 ctl->get = snd_akm4xxx_ipga_gain_get; 590 ctl->get = snd_akm4xxx_ipga_gain_get;
447 ctl->put = snd_akm4xxx_ipga_gain_put; 591 ctl->put = snd_akm4xxx_ipga_gain_put;
448 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0); /* register 4 & 5 */ 592 /* register 4 & 5 */
593 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0);
449 ctl->private_data = ak; 594 ctl->private_data = ak;
450 if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0) 595 err = snd_ctl_add(ak->card,
596 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
597 SNDRV_CTL_ELEM_ACCESS_WRITE));
598 if (err < 0)
451 goto __error; 599 goto __error;
452 } 600 }
453 if (ak->type == SND_AK4355 || ak->type == SND_AK4358) 601 if (ak->type == SND_AK4355 || ak->type == SND_AK4358)
@@ -466,11 +614,13 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
466 switch (ak->type) { 614 switch (ak->type) {
467 case SND_AK4524: 615 case SND_AK4524:
468 case SND_AK4528: 616 case SND_AK4528:
469 ctl->private_value = AK_COMPOSE(idx, 3, 0, 0); /* register 3 */ 617 /* register 3 */
618 ctl->private_value = AK_COMPOSE(idx, 3, 0, 0);
470 break; 619 break;
471 case SND_AK4529: { 620 case SND_AK4529: {
472 int shift = idx == 3 ? 6 : (2 - idx) * 2; 621 int shift = idx == 3 ? 6 : (2 - idx) * 2;
473 ctl->private_value = AK_COMPOSE(0, 8, shift, 0); /* register 8 with shift */ 622 /* register 8 with shift */
623 ctl->private_value = AK_COMPOSE(0, 8, shift, 0);
474 break; 624 break;
475 } 625 }
476 case SND_AK4355: 626 case SND_AK4355:
@@ -482,7 +632,10 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
482 break; 632 break;
483 } 633 }
484 ctl->private_data = ak; 634 ctl->private_data = ak;
485 if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0) 635 err = snd_ctl_add(ak->card,
636 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
637 SNDRV_CTL_ELEM_ACCESS_WRITE));
638 if (err < 0)
486 goto __error; 639 goto __error;
487 } 640 }
488 err = 0; 641 err = 0;
@@ -492,6 +645,8 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
492 return err; 645 return err;
493} 646}
494 647
648EXPORT_SYMBOL(snd_akm4xxx_build_controls);
649
495static int __init alsa_akm4xxx_module_init(void) 650static int __init alsa_akm4xxx_module_init(void)
496{ 651{
497 return 0; 652 return 0;
@@ -503,8 +658,3 @@ static void __exit alsa_akm4xxx_module_exit(void)
503 658
504module_init(alsa_akm4xxx_module_init) 659module_init(alsa_akm4xxx_module_init)
505module_exit(alsa_akm4xxx_module_exit) 660module_exit(alsa_akm4xxx_module_exit)
506
507EXPORT_SYMBOL(snd_akm4xxx_write);
508EXPORT_SYMBOL(snd_akm4xxx_reset);
509EXPORT_SYMBOL(snd_akm4xxx_init);
510EXPORT_SYMBOL(snd_akm4xxx_build_controls);
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index e6945db8ed1b..af60b0bc8115 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -2088,7 +2088,8 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard,
2088 kfree(cfg); 2088 kfree(cfg);
2089 return -EAGAIN; 2089 return -EAGAIN;
2090 } 2090 }
2091 snd_printdd("pnp: port=0x%lx\n", pnp_port_start(acard->devc, 0)); 2091 snd_printdd("pnp: port=0x%llx\n",
2092 (unsigned long long)pnp_port_start(acard->devc, 0));
2092 /* PnP initialization */ 2093 /* PnP initialization */
2093 pdev = acard->dev; 2094 pdev = acard->dev;
2094 pnp_init_resource_table(cfg); 2095 pnp_init_resource_table(cfg);
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 866300f2acbb..c1c86e0fa56d 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -611,10 +611,10 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard,
611 if (dma2[dev] >= 0) 611 if (dma2[dev] >= 0)
612 dma2[dev] = pnp_dma(pdev, 1); 612 dma2[dev] = pnp_dma(pdev, 1);
613 irq[dev] = pnp_irq(pdev, 0); 613 irq[dev] = pnp_irq(pdev, 0);
614 snd_printdd("isapnp IW: sb port=0x%lx, gf1 port=0x%lx, codec port=0x%lx\n", 614 snd_printdd("isapnp IW: sb port=0x%llx, gf1 port=0x%llx, codec port=0x%llx\n",
615 pnp_port_start(pdev, 0), 615 (unsigned long long)pnp_port_start(pdev, 0),
616 pnp_port_start(pdev, 1), 616 (unsigned long long)pnp_port_start(pdev, 1),
617 pnp_port_start(pdev, 2)); 617 (unsigned long long)pnp_port_start(pdev, 2));
618 snd_printdd("isapnp IW: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]); 618 snd_printdd("isapnp IW: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]);
619#ifdef SNDRV_STB 619#ifdef SNDRV_STB
620 /* Tone Control initialization */ 620 /* Tone Control initialization */
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 7f7f05fa518a..d64e67f2bafa 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -327,7 +327,8 @@ static int __devinit snd_card_sb16_pnp(int dev, struct snd_card_sb16 *acard,
327 goto __wt_error; 327 goto __wt_error;
328 } 328 }
329 awe_port[dev] = pnp_port_start(pdev, 0); 329 awe_port[dev] = pnp_port_start(pdev, 0);
330 snd_printdd("pnp SB16: wavetable port=0x%lx\n", pnp_port_start(pdev, 0)); 330 snd_printdd("pnp SB16: wavetable port=0x%llx\n",
331 (unsigned long long)pnp_port_start(pdev, 0));
331 } else { 332 } else {
332__wt_error: 333__wt_error:
333 if (pdev) { 334 if (pdev) {
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index 3b8cdbca2636..f4980ca5c05c 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -493,6 +493,19 @@ config SOUND_CS4232
493 See <file:Documentation/sound/oss/CS4232> for more information on 493 See <file:Documentation/sound/oss/CS4232> for more information on
494 configuring this card. 494 configuring this card.
495 495
496config SOUND_SSCAPE
497 tristate "Ensoniq SoundScape support"
498 depends on SOUND_OSS
499 help
500 Answer Y if you have a sound card based on the Ensoniq SoundScape
501 chipset. Such cards are being manufactured at least by Ensoniq, Spea
502 and Reveal (Reveal makes also other cards).
503
504 If you compile the driver into the kernel, you have to add
505 "sscape=<io>,<irq>,<dma>,<mpuio>,<mpuirq>" to the kernel command
506 line.
507
508
496config SOUND_VMIDI 509config SOUND_VMIDI
497 tristate "Loopback MIDI device support" 510 tristate "Loopback MIDI device support"
498 depends on SOUND_OSS 511 depends on SOUND_OSS
diff --git a/sound/oss/cs4232.c b/sound/oss/cs4232.c
index c7f86f09c28d..80f6c08e26e7 100644
--- a/sound/oss/cs4232.c
+++ b/sound/oss/cs4232.c
@@ -405,7 +405,7 @@ static const struct pnp_device_id cs4232_pnp_table[] = {
405 405
406MODULE_DEVICE_TABLE(pnp, cs4232_pnp_table); 406MODULE_DEVICE_TABLE(pnp, cs4232_pnp_table);
407 407
408static int cs4232_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) 408static int __init cs4232_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
409{ 409{
410 struct address_info *isapnpcfg; 410 struct address_info *isapnpcfg;
411 411
diff --git a/sound/oss/forte.c b/sound/oss/forte.c
index 0294eec8ad90..44e578098d76 100644
--- a/sound/oss/forte.c
+++ b/sound/oss/forte.c
@@ -2035,8 +2035,9 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
2035 2035
2036 pci_set_drvdata (pci_dev, chip); 2036 pci_set_drvdata (pci_dev, chip);
2037 2037
2038 printk (KERN_INFO PFX "FM801 chip found at 0x%04lX-0x%04lX IRQ %u\n", 2038 printk (KERN_INFO PFX "FM801 chip found at 0x%04lX-0x%16llX IRQ %u\n",
2039 chip->iobase, pci_resource_end (pci_dev, 0), chip->irq); 2039 chip->iobase, (unsigned long long)pci_resource_end (pci_dev, 0),
2040 chip->irq);
2040 2041
2041 /* Power it up */ 2042 /* Power it up */
2042 if ((ret = forte_chip_init (chip)) == 0) 2043 if ((ret = forte_chip_init (chip)) == 0)
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index d33bb464f70e..a33289948902 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -38,7 +38,6 @@
38#include <linux/wait.h> 38#include <linux/wait.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/ioport.h> 40#include <linux/ioport.h>
41#include <linux/devfs_fs_kernel.h>
42#include <linux/major.h> 41#include <linux/major.h>
43#include <linux/delay.h> 42#include <linux/delay.h>
44#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
@@ -564,9 +563,6 @@ static int __init oss_init(void)
564 sound_dmap_flag = (dmabuf > 0 ? 1 : 0); 563 sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
565 564
566 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { 565 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
567 devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
568 S_IFCHR | dev_list[i].mode,
569 "sound/%s", dev_list[i].name);
570 class_device_create(sound_class, NULL, 566 class_device_create(sound_class, NULL,
571 MKDEV(SOUND_MAJOR, dev_list[i].minor), 567 MKDEV(SOUND_MAJOR, dev_list[i].minor),
572 NULL, "%s", dev_list[i].name); 568 NULL, "%s", dev_list[i].name);
@@ -574,15 +570,10 @@ static int __init oss_init(void)
574 if (!dev_list[i].num) 570 if (!dev_list[i].num)
575 continue; 571 continue;
576 572
577 for (j = 1; j < *dev_list[i].num; j++) { 573 for (j = 1; j < *dev_list[i].num; j++)
578 devfs_mk_cdev(MKDEV(SOUND_MAJOR,
579 dev_list[i].minor + (j*0x10)),
580 S_IFCHR | dev_list[i].mode,
581 "sound/%s%d", dev_list[i].name, j);
582 class_device_create(sound_class, NULL, 574 class_device_create(sound_class, NULL,
583 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), 575 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
584 NULL, "%s%d", dev_list[i].name, j); 576 NULL, "%s%d", dev_list[i].name, j);
585 }
586 } 577 }
587 578
588 if (sound_nblocks >= 1024) 579 if (sound_nblocks >= 1024)
@@ -596,14 +587,11 @@ static void __exit oss_cleanup(void)
596 int i, j; 587 int i, j;
597 588
598 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { 589 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
599 devfs_remove("sound/%s", dev_list[i].name);
600 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor)); 590 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor));
601 if (!dev_list[i].num) 591 if (!dev_list[i].num)
602 continue; 592 continue;
603 for (j = 1; j < *dev_list[i].num; j++) { 593 for (j = 1; j < *dev_list[i].num; j++)
604 devfs_remove("sound/%s%d", dev_list[i].name, j);
605 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); 594 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
606 }
607 } 595 }
608 596
609 unregister_sound_special(1); 597 unregister_sound_special(1);
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
index 1a921ee71aba..29a6e0cff79f 100644
--- a/sound/oss/via82cxxx_audio.c
+++ b/sound/oss/via82cxxx_audio.c
@@ -24,6 +24,7 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/poison.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/interrupt.h> 29#include <linux/interrupt.h>
29#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
@@ -308,7 +309,7 @@ struct via_info {
308 unsigned sixchannel: 1; /* 8233/35 with 6 channel support */ 309 unsigned sixchannel: 1; /* 8233/35 with 6 channel support */
309 unsigned volume: 1; 310 unsigned volume: 1;
310 311
311 int locked_rate : 1; 312 unsigned locked_rate : 1;
312 313
313 int mixer_vol; /* 8233/35 volume - not yet implemented */ 314 int mixer_vol; /* 8233/35 volume - not yet implemented */
314 315
@@ -3522,7 +3523,7 @@ err_out_have_mixer:
3522 3523
3523err_out_kfree: 3524err_out_kfree:
3524#ifndef VIA_NDEBUG 3525#ifndef VIA_NDEBUG
3525 memset (card, 0xAB, sizeof (*card)); /* poison memory */ 3526 memset (card, OSS_POISON_FREE, sizeof (*card)); /* poison memory */
3526#endif 3527#endif
3527 kfree (card); 3528 kfree (card);
3528 3529
@@ -3559,7 +3560,7 @@ static void __devexit via_remove_one (struct pci_dev *pdev)
3559 via_ac97_cleanup (card); 3560 via_ac97_cleanup (card);
3560 3561
3561#ifndef VIA_NDEBUG 3562#ifndef VIA_NDEBUG
3562 memset (card, 0xAB, sizeof (*card)); /* poison memory */ 3563 memset (card, OSS_POISON_FREE, sizeof (*card)); /* poison memory */
3563#endif 3564#endif
3564 kfree (card); 3565 kfree (card);
3565 3566
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index d37346b12dc0..23e54cedfd4a 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -233,6 +233,143 @@ config SND_CS5535AUDIO
233 To compile this driver as a module, choose M here: the module 233 To compile this driver as a module, choose M here: the module
234 will be called snd-cs5535audio. 234 will be called snd-cs5535audio.
235 235
236config SND_DARLA20
237 tristate "(Echoaudio) Darla20"
238 depends on SND
239 depends on FW_LOADER
240 select SND_PCM
241 help
242 Say 'Y' or 'M' to include support for Echoaudio Darla.
243
244 To compile this driver as a module, choose M here: the module
245 will be called snd-darla20
246
247config SND_GINA20
248 tristate "(Echoaudio) Gina20"
249 depends on SND
250 depends on FW_LOADER
251 select SND_PCM
252 help
253 Say 'Y' or 'M' to include support for Echoaudio Gina.
254
255 To compile this driver as a module, choose M here: the module
256 will be called snd-gina20
257
258config SND_LAYLA20
259 tristate "(Echoaudio) Layla20"
260 depends on SND
261 depends on FW_LOADER
262 select SND_RAWMIDI
263 select SND_PCM
264 help
265 Say 'Y' or 'M' to include support for Echoaudio Layla.
266
267 To compile this driver as a module, choose M here: the module
268 will be called snd-layla20
269
270config SND_DARLA24
271 tristate "(Echoaudio) Darla24"
272 depends on SND
273 depends on FW_LOADER
274 select SND_PCM
275 help
276 Say 'Y' or 'M' to include support for Echoaudio Darla24.
277
278 To compile this driver as a module, choose M here: the module
279 will be called snd-darla24
280
281config SND_GINA24
282 tristate "(Echoaudio) Gina24"
283 depends on SND
284 depends on FW_LOADER
285 select SND_PCM
286 help
287 Say 'Y' or 'M' to include support for Echoaudio Gina24.
288
289 To compile this driver as a module, choose M here: the module
290 will be called snd-gina24
291
292config SND_LAYLA24
293 tristate "(Echoaudio) Layla24"
294 depends on SND
295 depends on FW_LOADER
296 select SND_RAWMIDI
297 select SND_PCM
298 help
299 Say 'Y' or 'M' to include support for Echoaudio Layla24.
300
301 To compile this driver as a module, choose M here: the module
302 will be called snd-layla24
303
304config SND_MONA
305 tristate "(Echoaudio) Mona"
306 depends on SND
307 depends on FW_LOADER
308 select SND_RAWMIDI
309 select SND_PCM
310 help
311 Say 'Y' or 'M' to include support for Echoaudio Mona.
312
313 To compile this driver as a module, choose M here: the module
314 will be called snd-mona
315
316config SND_MIA
317 tristate "(Echoaudio) Mia"
318 depends on SND
319 depends on FW_LOADER
320 select SND_RAWMIDI
321 select SND_PCM
322 help
323 Say 'Y' or 'M' to include support for Echoaudio Mia and Mia-midi.
324
325 To compile this driver as a module, choose M here: the module
326 will be called snd-mia
327
328config SND_ECHO3G
329 tristate "(Echoaudio) 3G cards"
330 depends on SND
331 depends on FW_LOADER
332 select SND_RAWMIDI
333 select SND_PCM
334 help
335 Say 'Y' or 'M' to include support for Echoaudio Gina3G and Layla3G.
336
337 To compile this driver as a module, choose M here: the module
338 will be called snd-echo3g
339
340config SND_INDIGO
341 tristate "(Echoaudio) Indigo"
342 depends on SND
343 depends on FW_LOADER
344 select SND_PCM
345 help
346 Say 'Y' or 'M' to include support for Echoaudio Indigo.
347
348 To compile this driver as a module, choose M here: the module
349 will be called snd-indigo
350
351config SND_INDIGOIO
352 tristate "(Echoaudio) Indigo IO"
353 depends on SND
354 depends on FW_LOADER
355 select SND_PCM
356 help
357 Say 'Y' or 'M' to include support for Echoaudio Indigo IO.
358
359 To compile this driver as a module, choose M here: the module
360 will be called snd-indigoio
361
362config SND_INDIGODJ
363 tristate "(Echoaudio) Indigo DJ"
364 depends on SND
365 depends on FW_LOADER
366 select SND_PCM
367 help
368 Say 'Y' or 'M' to include support for Echoaudio Indigo DJ.
369
370 To compile this driver as a module, choose M here: the module
371 will be called snd-indigodj
372
236config SND_EMU10K1 373config SND_EMU10K1
237 tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)" 374 tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)"
238 depends on SND 375 depends on SND
@@ -420,8 +557,8 @@ config SND_INTEL8X0
420 will be called snd-intel8x0. 557 will be called snd-intel8x0.
421 558
422config SND_INTEL8X0M 559config SND_INTEL8X0M
423 tristate "Intel/SiS/nVidia/AMD MC97 Modem (EXPERIMENTAL)" 560 tristate "Intel/SiS/nVidia/AMD MC97 Modem"
424 depends on SND && EXPERIMENTAL 561 depends on SND
425 select SND_AC97_CODEC 562 select SND_AC97_CODEC
426 help 563 help
427 Say Y here to include support for the integrated MC97 modem on 564 Say Y here to include support for the integrated MC97 modem on
diff --git a/sound/pci/Makefile b/sound/pci/Makefile
index cba5105aafea..e06736da9ef1 100644
--- a/sound/pci/Makefile
+++ b/sound/pci/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_SND) += \
57 ca0106/ \ 57 ca0106/ \
58 cs46xx/ \ 58 cs46xx/ \
59 cs5535audio/ \ 59 cs5535audio/ \
60 echoaudio/ \
60 emu10k1/ \ 61 emu10k1/ \
61 hda/ \ 62 hda/ \
62 ice1712/ \ 63 ice1712/ \
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 7f197c780816..094cfc1f3a19 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -1824,6 +1824,8 @@ static const struct snd_kcontrol_new snd_ac97_ad1888_controls[] = {
1824 .get = snd_ac97_ad1888_lohpsel_get, 1824 .get = snd_ac97_ad1888_lohpsel_get,
1825 .put = snd_ac97_ad1888_lohpsel_put 1825 .put = snd_ac97_ad1888_lohpsel_put
1826 }, 1826 },
1827 AC97_SINGLE("V_REFOUT Enable", AC97_AD_MISC, 2, 1, 1),
1828 AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1),
1827 AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0), 1829 AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0),
1828 { 1830 {
1829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index c33642d8d9a1..497ed6b20060 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -888,8 +888,9 @@ static int __devinit snd_bt87x_probe(struct pci_dev *pci,
888 888
889 strcpy(card->driver, "Bt87x"); 889 strcpy(card->driver, "Bt87x");
890 sprintf(card->shortname, "Brooktree Bt%x", pci->device); 890 sprintf(card->shortname, "Brooktree Bt%x", pci->device);
891 sprintf(card->longname, "%s at %#lx, irq %i", 891 sprintf(card->longname, "%s at %#llx, irq %i",
892 card->shortname, pci_resource_start(pci, 0), chip->irq); 892 card->shortname, (unsigned long long)pci_resource_start(pci, 0),
893 chip->irq);
893 strcpy(card->mixername, "Bt87x"); 894 strcpy(card->mixername, "Bt87x");
894 895
895 err = snd_card_register(card); 896 err = snd_card_register(card);
diff --git a/sound/pci/echoaudio/Makefile b/sound/pci/echoaudio/Makefile
new file mode 100644
index 000000000000..7b576aeb3f8d
--- /dev/null
+++ b/sound/pci/echoaudio/Makefile
@@ -0,0 +1,30 @@
1#
2# Makefile for ALSA Echoaudio soundcard drivers
3# Copyright (c) 2003 by Giuliano Pochini <pochini@shiny.it>
4#
5
6snd-darla20-objs := darla20.o
7snd-gina20-objs := gina20.o
8snd-layla20-objs := layla20.o
9snd-darla24-objs := darla24.o
10snd-gina24-objs := gina24.o
11snd-layla24-objs := layla24.o
12snd-mona-objs := mona.o
13snd-mia-objs := mia.o
14snd-echo3g-objs := echo3g.o
15snd-indigo-objs := indigo.o
16snd-indigoio-objs := indigoio.o
17snd-indigodj-objs := indigodj.o
18
19obj-$(CONFIG_SND_DARLA20) += snd-darla20.o
20obj-$(CONFIG_SND_GINA20) += snd-gina20.o
21obj-$(CONFIG_SND_LAYLA20) += snd-layla20.o
22obj-$(CONFIG_SND_DARLA24) += snd-darla24.o
23obj-$(CONFIG_SND_GINA24) += snd-gina24.o
24obj-$(CONFIG_SND_LAYLA24) += snd-layla24.o
25obj-$(CONFIG_SND_MONA) += snd-mona.o
26obj-$(CONFIG_SND_MIA) += snd-mia.o
27obj-$(CONFIG_SND_ECHO3G) += snd-echo3g.o
28obj-$(CONFIG_SND_INDIGO) += snd-indigo.o
29obj-$(CONFIG_SND_INDIGOIO) += snd-indigoio.o
30obj-$(CONFIG_SND_INDIGODJ) += snd-indigodj.o
diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c
new file mode 100644
index 000000000000..b7108e29a668
--- /dev/null
+++ b/sound/pci/echoaudio/darla20.c
@@ -0,0 +1,99 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHOGALS_FAMILY
20#define ECHOCARD_DARLA20
21#define ECHOCARD_NAME "Darla20"
22#define ECHOCARD_HAS_MONITOR
23
24/* Pipe indexes */
25#define PX_ANALOG_OUT 0 /* 8 */
26#define PX_DIGITAL_OUT 8 /* 0 */
27#define PX_ANALOG_IN 8 /* 2 */
28#define PX_DIGITAL_IN 10 /* 0 */
29#define PX_NUM 10
30
31/* Bus indexes */
32#define BX_ANALOG_OUT 0 /* 8 */
33#define BX_DIGITAL_OUT 8 /* 0 */
34#define BX_ANALOG_IN 8 /* 2 */
35#define BX_DIGITAL_IN 10 /* 0 */
36#define BX_NUM 10
37
38
39#include <sound/driver.h>
40#include <linux/delay.h>
41#include <linux/init.h>
42#include <linux/interrupt.h>
43#include <linux/pci.h>
44#include <linux/slab.h>
45#include <linux/moduleparam.h>
46#include <linux/firmware.h>
47#include <sound/core.h>
48#include <sound/info.h>
49#include <sound/control.h>
50#include <sound/pcm.h>
51#include <sound/pcm_params.h>
52#include <sound/asoundef.h>
53#include <sound/initval.h>
54#include <asm/io.h>
55#include <asm/atomic.h>
56#include "echoaudio.h"
57
58#define FW_DARLA20_DSP 0
59
60static const struct firmware card_fw[] = {
61 {0, "darla20_dsp.fw"}
62};
63
64static struct pci_device_id snd_echo_ids[] = {
65 {0x1057, 0x1801, 0xECC0, 0x0010, 0, 0, 0}, /* DSP 56301 Darla20 rev.0 */
66 {0,}
67};
68
69static struct snd_pcm_hardware pcm_hardware_skel = {
70 .info = SNDRV_PCM_INFO_MMAP |
71 SNDRV_PCM_INFO_INTERLEAVED |
72 SNDRV_PCM_INFO_BLOCK_TRANSFER |
73 SNDRV_PCM_INFO_MMAP_VALID |
74 SNDRV_PCM_INFO_PAUSE |
75 SNDRV_PCM_INFO_SYNC_START,
76 .formats = SNDRV_PCM_FMTBIT_U8 |
77 SNDRV_PCM_FMTBIT_S16_LE |
78 SNDRV_PCM_FMTBIT_S24_3LE |
79 SNDRV_PCM_FMTBIT_S32_LE |
80 SNDRV_PCM_FMTBIT_S32_BE,
81 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
82 .rate_min = 44100,
83 .rate_max = 48000,
84 .channels_min = 1,
85 .channels_max = 2,
86 .buffer_bytes_max = 262144,
87 .period_bytes_min = 32,
88 .period_bytes_max = 131072,
89 .periods_min = 2,
90 .periods_max = 220,
91 /* One page (4k) contains 512 instructions. I don't know if the hw
92 supports lists longer than this. In this case periods_max=220 is a
93 safe limit to make sure the list never exceeds 512 instructions. */
94};
95
96
97#include "darla20_dsp.c"
98#include "echoaudio_dsp.c"
99#include "echoaudio.c"
diff --git a/sound/pci/echoaudio/darla20_dsp.c b/sound/pci/echoaudio/darla20_dsp.c
new file mode 100644
index 000000000000..4159e3bc186f
--- /dev/null
+++ b/sound/pci/echoaudio/darla20_dsp.c
@@ -0,0 +1,125 @@
1/***************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
33{
34 int err;
35
36 DE_INIT(("init_hw() - Darla20\n"));
37 snd_assert((subdevice_id & 0xfff0) == DARLA20, return -ENODEV);
38
39 if ((err = init_dsp_comm_page(chip))) {
40 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
41 return err;
42 }
43
44 chip->device_id = device_id;
45 chip->subdevice_id = subdevice_id;
46 chip->bad_board = TRUE;
47 chip->dsp_code_to_load = &card_fw[FW_DARLA20_DSP];
48 chip->spdif_status = GD_SPDIF_STATUS_UNDEF;
49 chip->clock_state = GD_CLOCK_UNDEF;
50 /* Since this card has no ASIC, mark it as loaded so everything
51 works OK */
52 chip->asic_loaded = TRUE;
53 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
54
55 if ((err = load_firmware(chip)) < 0)
56 return err;
57 chip->bad_board = FALSE;
58
59 if ((err = init_line_levels(chip)) < 0)
60 return err;
61
62 DE_INIT(("init_hw done\n"));
63 return err;
64}
65
66
67
68/* The Darla20 has no external clock sources */
69static u32 detect_input_clocks(const struct echoaudio *chip)
70{
71 return ECHO_CLOCK_BIT_INTERNAL;
72}
73
74
75
76/* The Darla20 has no ASIC. Just do nothing */
77static int load_asic(struct echoaudio *chip)
78{
79 return 0;
80}
81
82
83
84static int set_sample_rate(struct echoaudio *chip, u32 rate)
85{
86 u8 clock_state, spdif_status;
87
88 if (wait_handshake(chip))
89 return -EIO;
90
91 switch (rate) {
92 case 44100:
93 clock_state = GD_CLOCK_44;
94 spdif_status = GD_SPDIF_STATUS_44;
95 break;
96 case 48000:
97 clock_state = GD_CLOCK_48;
98 spdif_status = GD_SPDIF_STATUS_48;
99 break;
100 default:
101 clock_state = GD_CLOCK_NOCHANGE;
102 spdif_status = GD_SPDIF_STATUS_NOCHANGE;
103 break;
104 }
105
106 if (chip->clock_state == clock_state)
107 clock_state = GD_CLOCK_NOCHANGE;
108 if (spdif_status == chip->spdif_status)
109 spdif_status = GD_SPDIF_STATUS_NOCHANGE;
110
111 chip->comm_page->sample_rate = cpu_to_le32(rate);
112 chip->comm_page->gd_clock_state = clock_state;
113 chip->comm_page->gd_spdif_status = spdif_status;
114 chip->comm_page->gd_resampler_state = 3; /* magic number - should always be 3 */
115
116 /* Save the new audio state if it changed */
117 if (clock_state != GD_CLOCK_NOCHANGE)
118 chip->clock_state = clock_state;
119 if (spdif_status != GD_SPDIF_STATUS_NOCHANGE)
120 chip->spdif_status = spdif_status;
121 chip->sample_rate = rate;
122
123 clear_handshake(chip);
124 return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
125}
diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c
new file mode 100644
index 000000000000..e59a982ee361
--- /dev/null
+++ b/sound/pci/echoaudio/darla24.c
@@ -0,0 +1,106 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHOGALS_FAMILY
20#define ECHOCARD_DARLA24
21#define ECHOCARD_NAME "Darla24"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
24#define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
25#define ECHOCARD_HAS_EXTERNAL_CLOCK
26#define ECHOCARD_HAS_SUPER_INTERLEAVE
27
28/* Pipe indexes */
29#define PX_ANALOG_OUT 0 /* 8 */
30#define PX_DIGITAL_OUT 8 /* 0 */
31#define PX_ANALOG_IN 8 /* 2 */
32#define PX_DIGITAL_IN 10 /* 0 */
33#define PX_NUM 10
34
35/* Bus indexes */
36#define BX_ANALOG_OUT 0 /* 8 */
37#define BX_DIGITAL_OUT 8 /* 0 */
38#define BX_ANALOG_IN 8 /* 2 */
39#define BX_DIGITAL_IN 10 /* 0 */
40#define BX_NUM 10
41
42
43#include <sound/driver.h>
44#include <linux/delay.h>
45#include <linux/init.h>
46#include <linux/interrupt.h>
47#include <linux/pci.h>
48#include <linux/slab.h>
49#include <linux/moduleparam.h>
50#include <linux/firmware.h>
51#include <sound/core.h>
52#include <sound/info.h>
53#include <sound/control.h>
54#include <sound/pcm.h>
55#include <sound/pcm_params.h>
56#include <sound/asoundef.h>
57#include <sound/initval.h>
58#include <asm/io.h>
59#include <asm/atomic.h>
60#include "echoaudio.h"
61
62#define FW_DARLA24_DSP 0
63
64static const struct firmware card_fw[] = {
65 {0, "darla24_dsp.fw"}
66};
67
68static struct pci_device_id snd_echo_ids[] = {
69 {0x1057, 0x1801, 0xECC0, 0x0040, 0, 0, 0}, /* DSP 56301 Darla24 rev.0 */
70 {0x1057, 0x1801, 0xECC0, 0x0041, 0, 0, 0}, /* DSP 56301 Darla24 rev.1 */
71 {0,}
72};
73
74static struct snd_pcm_hardware pcm_hardware_skel = {
75 .info = SNDRV_PCM_INFO_MMAP |
76 SNDRV_PCM_INFO_INTERLEAVED |
77 SNDRV_PCM_INFO_BLOCK_TRANSFER |
78 SNDRV_PCM_INFO_MMAP_VALID |
79 SNDRV_PCM_INFO_PAUSE |
80 SNDRV_PCM_INFO_SYNC_START,
81 .formats = SNDRV_PCM_FMTBIT_U8 |
82 SNDRV_PCM_FMTBIT_S16_LE |
83 SNDRV_PCM_FMTBIT_S24_3LE |
84 SNDRV_PCM_FMTBIT_S32_LE |
85 SNDRV_PCM_FMTBIT_S32_BE,
86 .rates = SNDRV_PCM_RATE_8000_48000 |
87 SNDRV_PCM_RATE_88200 |
88 SNDRV_PCM_RATE_96000,
89 .rate_min = 8000,
90 .rate_max = 96000,
91 .channels_min = 1,
92 .channels_max = 8,
93 .buffer_bytes_max = 262144,
94 .period_bytes_min = 32,
95 .period_bytes_max = 131072,
96 .periods_min = 2,
97 .periods_max = 220,
98 /* One page (4k) contains 512 instructions. I don't know if the hw
99 supports lists longer than this. In this case periods_max=220 is a
100 safe limit to make sure the list never exceeds 512 instructions. */
101};
102
103
104#include "darla24_dsp.c"
105#include "echoaudio_dsp.c"
106#include "echoaudio.c"
diff --git a/sound/pci/echoaudio/darla24_dsp.c b/sound/pci/echoaudio/darla24_dsp.c
new file mode 100644
index 000000000000..79938eed7e9c
--- /dev/null
+++ b/sound/pci/echoaudio/darla24_dsp.c
@@ -0,0 +1,156 @@
1/***************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
33{
34 int err;
35
36 DE_INIT(("init_hw() - Darla24\n"));
37 snd_assert((subdevice_id & 0xfff0) == DARLA24, return -ENODEV);
38
39 if ((err = init_dsp_comm_page(chip))) {
40 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
41 return err;
42 }
43
44 chip->device_id = device_id;
45 chip->subdevice_id = subdevice_id;
46 chip->bad_board = TRUE;
47 chip->dsp_code_to_load = &card_fw[FW_DARLA24_DSP];
48 /* Since this card has no ASIC, mark it as loaded so everything
49 works OK */
50 chip->asic_loaded = TRUE;
51 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
52 ECHO_CLOCK_BIT_ESYNC;
53
54 if ((err = load_firmware(chip)) < 0)
55 return err;
56 chip->bad_board = FALSE;
57
58 if ((err = init_line_levels(chip)) < 0)
59 return err;
60
61 DE_INIT(("init_hw done\n"));
62 return err;
63}
64
65
66
67static u32 detect_input_clocks(const struct echoaudio *chip)
68{
69 u32 clocks_from_dsp, clock_bits;
70
71 /* Map the DSP clock detect bits to the generic driver clock
72 detect bits */
73 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
74
75 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
76
77 if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_ESYNC)
78 clock_bits |= ECHO_CLOCK_BIT_ESYNC;
79
80 return clock_bits;
81}
82
83
84
85/* The Darla24 has no ASIC. Just do nothing */
86static int load_asic(struct echoaudio *chip)
87{
88 return 0;
89}
90
91
92
93static int set_sample_rate(struct echoaudio *chip, u32 rate)
94{
95 u8 clock;
96
97 switch (rate) {
98 case 96000:
99 clock = GD24_96000;
100 break;
101 case 88200:
102 clock = GD24_88200;
103 break;
104 case 48000:
105 clock = GD24_48000;
106 break;
107 case 44100:
108 clock = GD24_44100;
109 break;
110 case 32000:
111 clock = GD24_32000;
112 break;
113 case 22050:
114 clock = GD24_22050;
115 break;
116 case 16000:
117 clock = GD24_16000;
118 break;
119 case 11025:
120 clock = GD24_11025;
121 break;
122 case 8000:
123 clock = GD24_8000;
124 break;
125 default:
126 DE_ACT(("set_sample_rate: Error, invalid sample rate %d\n",
127 rate));
128 return -EINVAL;
129 }
130
131 if (wait_handshake(chip))
132 return -EIO;
133
134 DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));
135 chip->sample_rate = rate;
136
137 /* Override the sample rate if this card is set to Echo sync. */
138 if (chip->input_clock == ECHO_CLOCK_ESYNC)
139 clock = GD24_EXT_SYNC;
140
141 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP ? */
142 chip->comm_page->gd_clock_state = clock;
143 clear_handshake(chip);
144 return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
145}
146
147
148
149static int set_input_clock(struct echoaudio *chip, u16 clock)
150{
151 snd_assert(clock == ECHO_CLOCK_INTERNAL ||
152 clock == ECHO_CLOCK_ESYNC, return -EINVAL);
153 chip->input_clock = clock;
154 return set_sample_rate(chip, chip->sample_rate);
155}
156
diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c
new file mode 100644
index 000000000000..12099fe1547d
--- /dev/null
+++ b/sound/pci/echoaudio/echo3g.c
@@ -0,0 +1,118 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHO3G_FAMILY
20#define ECHOCARD_ECHO3G
21#define ECHOCARD_NAME "Echo3G"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_ASIC
24#define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
25#define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
26#define ECHOCARD_HAS_SUPER_INTERLEAVE
27#define ECHOCARD_HAS_DIGITAL_IO
28#define ECHOCARD_HAS_DIGITAL_MODE_SWITCH
29#define ECHOCARD_HAS_ADAT 6
30#define ECHOCARD_HAS_EXTERNAL_CLOCK
31#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
32#define ECHOCARD_HAS_MIDI
33#define ECHOCARD_HAS_PHANTOM_POWER
34
35/* Pipe indexes */
36#define PX_ANALOG_OUT 0
37#define PX_DIGITAL_OUT chip->px_digital_out
38#define PX_ANALOG_IN chip->px_analog_in
39#define PX_DIGITAL_IN chip->px_digital_in
40#define PX_NUM chip->px_num
41
42/* Bus indexes */
43#define BX_ANALOG_OUT 0
44#define BX_DIGITAL_OUT chip->bx_digital_out
45#define BX_ANALOG_IN chip->bx_analog_in
46#define BX_DIGITAL_IN chip->bx_digital_in
47#define BX_NUM chip->bx_num
48
49
50#include <sound/driver.h>
51#include <linux/delay.h>
52#include <linux/init.h>
53#include <linux/interrupt.h>
54#include <linux/pci.h>
55#include <linux/slab.h>
56#include <linux/moduleparam.h>
57#include <linux/firmware.h>
58#include <sound/core.h>
59#include <sound/info.h>
60#include <sound/control.h>
61#include <sound/pcm.h>
62#include <sound/pcm_params.h>
63#include <sound/asoundef.h>
64#include <sound/initval.h>
65#include <sound/rawmidi.h>
66#include <asm/io.h>
67#include <asm/atomic.h>
68#include "echoaudio.h"
69
70#define FW_361_LOADER 0
71#define FW_ECHO3G_DSP 1
72#define FW_3G_ASIC 2
73
74static const struct firmware card_fw[] = {
75 {0, "loader_dsp.fw"},
76 {0, "echo3g_dsp.fw"},
77 {0, "3g_asic.fw"}
78};
79
80static struct pci_device_id snd_echo_ids[] = {
81 {0x1057, 0x3410, 0xECC0, 0x0100, 0, 0, 0}, /* Echo 3G */
82 {0,}
83};
84
85static struct snd_pcm_hardware pcm_hardware_skel = {
86 .info = SNDRV_PCM_INFO_MMAP |
87 SNDRV_PCM_INFO_INTERLEAVED |
88 SNDRV_PCM_INFO_BLOCK_TRANSFER |
89 SNDRV_PCM_INFO_MMAP_VALID |
90 SNDRV_PCM_INFO_PAUSE |
91 SNDRV_PCM_INFO_SYNC_START,
92 .formats = SNDRV_PCM_FMTBIT_U8 |
93 SNDRV_PCM_FMTBIT_S16_LE |
94 SNDRV_PCM_FMTBIT_S24_3LE |
95 SNDRV_PCM_FMTBIT_S32_LE |
96 SNDRV_PCM_FMTBIT_S32_BE,
97 .rates = SNDRV_PCM_RATE_32000 |
98 SNDRV_PCM_RATE_44100 |
99 SNDRV_PCM_RATE_48000 |
100 SNDRV_PCM_RATE_88200 |
101 SNDRV_PCM_RATE_96000 |
102 SNDRV_PCM_RATE_CONTINUOUS,
103 .rate_min = 32000,
104 .rate_max = 100000,
105 .channels_min = 1,
106 .channels_max = 8,
107 .buffer_bytes_max = 262144,
108 .period_bytes_min = 32,
109 .period_bytes_max = 131072,
110 .periods_min = 2,
111 .periods_max = 220,
112};
113
114#include "echo3g_dsp.c"
115#include "echoaudio_dsp.c"
116#include "echoaudio_3g.c"
117#include "echoaudio.c"
118#include "midi.c"
diff --git a/sound/pci/echoaudio/echo3g_dsp.c b/sound/pci/echoaudio/echo3g_dsp.c
new file mode 100644
index 000000000000..d26a1d1f3ed1
--- /dev/null
+++ b/sound/pci/echoaudio/echo3g_dsp.c
@@ -0,0 +1,131 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31static int load_asic(struct echoaudio *chip);
32static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode);
33static int set_digital_mode(struct echoaudio *chip, u8 mode);
34static int check_asic_status(struct echoaudio *chip);
35static int set_sample_rate(struct echoaudio *chip, u32 rate);
36static int set_input_clock(struct echoaudio *chip, u16 clock);
37static int set_professional_spdif(struct echoaudio *chip, char prof);
38static int set_phantom_power(struct echoaudio *chip, char on);
39static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq,
40 char force);
41
42#include <linux/irq.h>
43
44static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
45{
46 int err;
47
48 local_irq_enable();
49 DE_INIT(("init_hw() - Echo3G\n"));
50 snd_assert((subdevice_id & 0xfff0) == ECHO3G, return -ENODEV);
51
52 if ((err = init_dsp_comm_page(chip))) {
53 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
54 return err;
55 }
56
57 chip->comm_page->e3g_frq_register =
58 __constant_cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2);
59 chip->device_id = device_id;
60 chip->subdevice_id = subdevice_id;
61 chip->bad_board = TRUE;
62 chip->has_midi = TRUE;
63 chip->dsp_code_to_load = &card_fw[FW_ECHO3G_DSP];
64
65 /* Load the DSP code and the ASIC on the PCI card and get
66 what type of external box is attached */
67 err = load_firmware(chip);
68
69 if (err < 0) {
70 return err;
71 } else if (err == E3G_GINA3G_BOX_TYPE) {
72 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
73 ECHO_CLOCK_BIT_SPDIF |
74 ECHO_CLOCK_BIT_ADAT;
75 chip->card_name = "Gina3G";
76 chip->px_digital_out = chip->bx_digital_out = 6;
77 chip->px_analog_in = chip->bx_analog_in = 14;
78 chip->px_digital_in = chip->bx_digital_in = 16;
79 chip->px_num = chip->bx_num = 24;
80 chip->has_phantom_power = TRUE;
81 chip->hasnt_input_nominal_level = TRUE;
82 } else if (err == E3G_LAYLA3G_BOX_TYPE) {
83 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
84 ECHO_CLOCK_BIT_SPDIF |
85 ECHO_CLOCK_BIT_ADAT |
86 ECHO_CLOCK_BIT_WORD;
87 chip->card_name = "Layla3G";
88 chip->px_digital_out = chip->bx_digital_out = 8;
89 chip->px_analog_in = chip->bx_analog_in = 16;
90 chip->px_digital_in = chip->bx_digital_in = 24;
91 chip->px_num = chip->bx_num = 32;
92 } else {
93 return -ENODEV;
94 }
95
96 chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
97 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
98 ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
99 chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
100 chip->professional_spdif = FALSE;
101 chip->non_audio_spdif = FALSE;
102 chip->bad_board = FALSE;
103
104 if ((err = init_line_levels(chip)) < 0)
105 return err;
106 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
107 snd_assert(err >= 0, return err);
108 err = set_phantom_power(chip, 0);
109 snd_assert(err >= 0, return err);
110 err = set_professional_spdif(chip, TRUE);
111
112 DE_INIT(("init_hw done\n"));
113 return err;
114}
115
116
117
118static int set_phantom_power(struct echoaudio *chip, char on)
119{
120 u32 control_reg = le32_to_cpu(chip->comm_page->control_register);
121
122 if (on)
123 control_reg |= E3G_PHANTOM_POWER;
124 else
125 control_reg &= ~E3G_PHANTOM_POWER;
126
127 chip->phantom_power = on;
128 return write_control_reg(chip, control_reg,
129 le32_to_cpu(chip->comm_page->e3g_frq_register),
130 0);
131}
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
new file mode 100644
index 000000000000..43b408ada1da
--- /dev/null
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -0,0 +1,2196 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19MODULE_AUTHOR("Giuliano Pochini <pochini@shiny.it>");
20MODULE_LICENSE("GPL v2");
21MODULE_DESCRIPTION("Echoaudio " ECHOCARD_NAME " soundcards driver");
22MODULE_SUPPORTED_DEVICE("{{Echoaudio," ECHOCARD_NAME "}}");
23MODULE_DEVICE_TABLE(pci, snd_echo_ids);
24
25static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
26static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
27static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
28
29module_param_array(index, int, NULL, 0444);
30MODULE_PARM_DESC(index, "Index value for " ECHOCARD_NAME " soundcard.");
31module_param_array(id, charp, NULL, 0444);
32MODULE_PARM_DESC(id, "ID string for " ECHOCARD_NAME " soundcard.");
33module_param_array(enable, bool, NULL, 0444);
34MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard.");
35
36static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
37
38static int get_firmware(const struct firmware **fw_entry,
39 const struct firmware *frm, struct echoaudio *chip)
40{
41 int err;
42 char name[30];
43 DE_ACT(("firmware requested: %s\n", frm->data));
44 snprintf(name, sizeof(name), "ea/%s", frm->data);
45 if ((err = request_firmware(fw_entry, name, pci_device(chip))) < 0)
46 snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err);
47 return err;
48}
49
50static void free_firmware(const struct firmware *fw_entry)
51{
52 release_firmware(fw_entry);
53 DE_ACT(("firmware released\n"));
54}
55
56
57
58/******************************************************************************
59 PCM interface
60******************************************************************************/
61
62static void audiopipe_free(struct snd_pcm_runtime *runtime)
63{
64 struct audiopipe *pipe = runtime->private_data;
65
66 if (pipe->sgpage.area)
67 snd_dma_free_pages(&pipe->sgpage);
68 kfree(pipe);
69}
70
71
72
73static int hw_rule_capture_format_by_channels(struct snd_pcm_hw_params *params,
74 struct snd_pcm_hw_rule *rule)
75{
76 struct snd_interval *c = hw_param_interval(params,
77 SNDRV_PCM_HW_PARAM_CHANNELS);
78 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
79 struct snd_mask fmt;
80
81 snd_mask_any(&fmt);
82
83#ifndef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
84 /* >=2 channels cannot be S32_BE */
85 if (c->min == 2) {
86 fmt.bits[0] &= ~SNDRV_PCM_FMTBIT_S32_BE;
87 return snd_mask_refine(f, &fmt);
88 }
89#endif
90 /* > 2 channels cannot be U8 and S32_BE */
91 if (c->min > 2) {
92 fmt.bits[0] &= ~(SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_BE);
93 return snd_mask_refine(f, &fmt);
94 }
95 /* Mono is ok with any format */
96 return 0;
97}
98
99
100
101static int hw_rule_capture_channels_by_format(struct snd_pcm_hw_params *params,
102 struct snd_pcm_hw_rule *rule)
103{
104 struct snd_interval *c = hw_param_interval(params,
105 SNDRV_PCM_HW_PARAM_CHANNELS);
106 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
107 struct snd_interval ch;
108
109 snd_interval_any(&ch);
110
111 /* S32_BE is mono (and stereo) only */
112 if (f->bits[0] == SNDRV_PCM_FMTBIT_S32_BE) {
113 ch.min = 1;
114#ifdef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
115 ch.max = 2;
116#else
117 ch.max = 1;
118#endif
119 ch.integer = 1;
120 return snd_interval_refine(c, &ch);
121 }
122 /* U8 can be only mono or stereo */
123 if (f->bits[0] == SNDRV_PCM_FMTBIT_U8) {
124 ch.min = 1;
125 ch.max = 2;
126 ch.integer = 1;
127 return snd_interval_refine(c, &ch);
128 }
129 /* S16_LE, S24_3LE and S32_LE support any number of channels. */
130 return 0;
131}
132
133
134
135static int hw_rule_playback_format_by_channels(struct snd_pcm_hw_params *params,
136 struct snd_pcm_hw_rule *rule)
137{
138 struct snd_interval *c = hw_param_interval(params,
139 SNDRV_PCM_HW_PARAM_CHANNELS);
140 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
141 struct snd_mask fmt;
142 u64 fmask;
143 snd_mask_any(&fmt);
144
145 fmask = fmt.bits[0] + ((u64)fmt.bits[1] << 32);
146
147 /* >2 channels must be S16_LE, S24_3LE or S32_LE */
148 if (c->min > 2) {
149 fmask &= SNDRV_PCM_FMTBIT_S16_LE |
150 SNDRV_PCM_FMTBIT_S24_3LE |
151 SNDRV_PCM_FMTBIT_S32_LE;
152 /* 1 channel must be S32_BE or S32_LE */
153 } else if (c->max == 1)
154 fmask &= SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE;
155#ifndef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
156 /* 2 channels cannot be S32_BE */
157 else if (c->min == 2 && c->max == 2)
158 fmask &= ~SNDRV_PCM_FMTBIT_S32_BE;
159#endif
160 else
161 return 0;
162
163 fmt.bits[0] &= (u32)fmask;
164 fmt.bits[1] &= (u32)(fmask >> 32);
165 return snd_mask_refine(f, &fmt);
166}
167
168
169
170static int hw_rule_playback_channels_by_format(struct snd_pcm_hw_params *params,
171 struct snd_pcm_hw_rule *rule)
172{
173 struct snd_interval *c = hw_param_interval(params,
174 SNDRV_PCM_HW_PARAM_CHANNELS);
175 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
176 struct snd_interval ch;
177 u64 fmask;
178
179 snd_interval_any(&ch);
180 ch.integer = 1;
181 fmask = f->bits[0] + ((u64)f->bits[1] << 32);
182
183 /* S32_BE is mono (and stereo) only */
184 if (fmask == SNDRV_PCM_FMTBIT_S32_BE) {
185 ch.min = 1;
186#ifdef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
187 ch.max = 2;
188#else
189 ch.max = 1;
190#endif
191 /* U8 is stereo only */
192 } else if (fmask == SNDRV_PCM_FMTBIT_U8)
193 ch.min = ch.max = 2;
194 /* S16_LE and S24_3LE must be at least stereo */
195 else if (!(fmask & ~(SNDRV_PCM_FMTBIT_S16_LE |
196 SNDRV_PCM_FMTBIT_S24_3LE)))
197 ch.min = 2;
198 else
199 return 0;
200
201 return snd_interval_refine(c, &ch);
202}
203
204
205
206/* Since the sample rate is a global setting, do allow the user to change the
207sample rate only if there is only one pcm device open. */
208static int hw_rule_sample_rate(struct snd_pcm_hw_params *params,
209 struct snd_pcm_hw_rule *rule)
210{
211 struct snd_interval *rate = hw_param_interval(params,
212 SNDRV_PCM_HW_PARAM_RATE);
213 struct echoaudio *chip = rule->private;
214 struct snd_interval fixed;
215
216 if (!chip->can_set_rate) {
217 snd_interval_any(&fixed);
218 fixed.min = fixed.max = chip->sample_rate;
219 return snd_interval_refine(rate, &fixed);
220 }
221 return 0;
222}
223
224
225static int pcm_open(struct snd_pcm_substream *substream,
226 signed char max_channels)
227{
228 struct echoaudio *chip;
229 struct snd_pcm_runtime *runtime;
230 struct audiopipe *pipe;
231 int err, i;
232
233 if (max_channels <= 0)
234 return -EAGAIN;
235
236 chip = snd_pcm_substream_chip(substream);
237 runtime = substream->runtime;
238
239 if (!(pipe = kmalloc(sizeof(struct audiopipe), GFP_KERNEL)))
240 return -ENOMEM;
241 memset(pipe, 0, sizeof(struct audiopipe));
242 pipe->index = -1; /* Not configured yet */
243
244 /* Set up hw capabilities and contraints */
245 memcpy(&pipe->hw, &pcm_hardware_skel, sizeof(struct snd_pcm_hardware));
246 DE_HWP(("max_channels=%d\n", max_channels));
247 pipe->constr.list = channels_list;
248 pipe->constr.mask = 0;
249 for (i = 0; channels_list[i] <= max_channels; i++);
250 pipe->constr.count = i;
251 if (pipe->hw.channels_max > max_channels)
252 pipe->hw.channels_max = max_channels;
253 if (chip->digital_mode == DIGITAL_MODE_ADAT) {
254 pipe->hw.rate_max = 48000;
255 pipe->hw.rates &= SNDRV_PCM_RATE_8000_48000;
256 }
257
258 runtime->hw = pipe->hw;
259 runtime->private_data = pipe;
260 runtime->private_free = audiopipe_free;
261 snd_pcm_set_sync(substream);
262
263 /* Only mono and any even number of channels are allowed */
264 if ((err = snd_pcm_hw_constraint_list(runtime, 0,
265 SNDRV_PCM_HW_PARAM_CHANNELS,
266 &pipe->constr)) < 0)
267 return err;
268
269 /* All periods should have the same size */
270 if ((err = snd_pcm_hw_constraint_integer(runtime,
271 SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
272 return err;
273
274 /* The hw accesses memory in chunks 32 frames long and they should be
275 32-bytes-aligned. It's not a requirement, but it seems that IRQs are
276 generated with a resolution of 32 frames. Thus we need the following */
277 if ((err = snd_pcm_hw_constraint_step(runtime, 0,
278 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
279 32)) < 0)
280 return err;
281 if ((err = snd_pcm_hw_constraint_step(runtime, 0,
282 SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
283 32)) < 0)
284 return err;
285
286 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
287 SNDRV_PCM_HW_PARAM_RATE,
288 hw_rule_sample_rate, chip,
289 SNDRV_PCM_HW_PARAM_RATE, -1)) < 0)
290 return err;
291
292 /* Finally allocate a page for the scatter-gather list */
293 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
294 snd_dma_pci_data(chip->pci),
295 PAGE_SIZE, &pipe->sgpage)) < 0) {
296 DE_HWP(("s-g list allocation failed\n"));
297 return err;
298 }
299
300 return 0;
301}
302
303
304
305static int pcm_analog_in_open(struct snd_pcm_substream *substream)
306{
307 struct echoaudio *chip = snd_pcm_substream_chip(substream);
308 int err;
309
310 DE_ACT(("pcm_analog_in_open\n"));
311 if ((err = pcm_open(substream, num_analog_busses_in(chip) -
312 substream->number)) < 0)
313 return err;
314 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
315 SNDRV_PCM_HW_PARAM_CHANNELS,
316 hw_rule_capture_channels_by_format, NULL,
317 SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0)
318 return err;
319 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
320 SNDRV_PCM_HW_PARAM_FORMAT,
321 hw_rule_capture_format_by_channels, NULL,
322 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
323 return err;
324 atomic_inc(&chip->opencount);
325 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
326 chip->can_set_rate=0;
327 DE_HWP(("pcm_analog_in_open cs=%d oc=%d r=%d\n",
328 chip->can_set_rate, atomic_read(&chip->opencount),
329 chip->sample_rate));
330 return 0;
331}
332
333
334
335static int pcm_analog_out_open(struct snd_pcm_substream *substream)
336{
337 struct echoaudio *chip = snd_pcm_substream_chip(substream);
338 int max_channels, err;
339
340#ifdef ECHOCARD_HAS_VMIXER
341 max_channels = num_pipes_out(chip);
342#else
343 max_channels = num_analog_busses_out(chip);
344#endif
345 DE_ACT(("pcm_analog_out_open\n"));
346 if ((err = pcm_open(substream, max_channels - substream->number)) < 0)
347 return err;
348 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
349 SNDRV_PCM_HW_PARAM_CHANNELS,
350 hw_rule_playback_channels_by_format,
351 NULL,
352 SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0)
353 return err;
354 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
355 SNDRV_PCM_HW_PARAM_FORMAT,
356 hw_rule_playback_format_by_channels,
357 NULL,
358 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
359 return err;
360 atomic_inc(&chip->opencount);
361 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
362 chip->can_set_rate=0;
363 DE_HWP(("pcm_analog_out_open cs=%d oc=%d r=%d\n",
364 chip->can_set_rate, atomic_read(&chip->opencount),
365 chip->sample_rate));
366 return 0;
367}
368
369
370
371#ifdef ECHOCARD_HAS_DIGITAL_IO
372
373static int pcm_digital_in_open(struct snd_pcm_substream *substream)
374{
375 struct echoaudio *chip = snd_pcm_substream_chip(substream);
376 int err, max_channels;
377
378 DE_ACT(("pcm_digital_in_open\n"));
379 max_channels = num_digital_busses_in(chip) - substream->number;
380 down(&chip->mode_mutex);
381 if (chip->digital_mode == DIGITAL_MODE_ADAT)
382 err = pcm_open(substream, max_channels);
383 else /* If the card has ADAT, subtract the 6 channels
384 * that S/PDIF doesn't have
385 */
386 err = pcm_open(substream, max_channels - ECHOCARD_HAS_ADAT);
387
388 if (err < 0)
389 goto din_exit;
390
391 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
392 SNDRV_PCM_HW_PARAM_CHANNELS,
393 hw_rule_capture_channels_by_format, NULL,
394 SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0)
395 goto din_exit;
396 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
397 SNDRV_PCM_HW_PARAM_FORMAT,
398 hw_rule_capture_format_by_channels, NULL,
399 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
400 goto din_exit;
401
402 atomic_inc(&chip->opencount);
403 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
404 chip->can_set_rate=0;
405
406din_exit:
407 up(&chip->mode_mutex);
408 return err;
409}
410
411
412
413#ifndef ECHOCARD_HAS_VMIXER /* See the note in snd_echo_new_pcm() */
414
415static int pcm_digital_out_open(struct snd_pcm_substream *substream)
416{
417 struct echoaudio *chip = snd_pcm_substream_chip(substream);
418 int err, max_channels;
419
420 DE_ACT(("pcm_digital_out_open\n"));
421 max_channels = num_digital_busses_out(chip) - substream->number;
422 down(&chip->mode_mutex);
423 if (chip->digital_mode == DIGITAL_MODE_ADAT)
424 err = pcm_open(substream, max_channels);
425 else /* If the card has ADAT, subtract the 6 channels
426 * that S/PDIF doesn't have
427 */
428 err = pcm_open(substream, max_channels - ECHOCARD_HAS_ADAT);
429
430 if (err < 0)
431 goto dout_exit;
432
433 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
434 SNDRV_PCM_HW_PARAM_CHANNELS,
435 hw_rule_playback_channels_by_format,
436 NULL, SNDRV_PCM_HW_PARAM_FORMAT,
437 -1)) < 0)
438 goto dout_exit;
439 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
440 SNDRV_PCM_HW_PARAM_FORMAT,
441 hw_rule_playback_format_by_channels,
442 NULL, SNDRV_PCM_HW_PARAM_CHANNELS,
443 -1)) < 0)
444 goto dout_exit;
445 atomic_inc(&chip->opencount);
446 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
447 chip->can_set_rate=0;
448dout_exit:
449 up(&chip->mode_mutex);
450 return err;
451}
452
453#endif /* !ECHOCARD_HAS_VMIXER */
454
455#endif /* ECHOCARD_HAS_DIGITAL_IO */
456
457
458
459static int pcm_close(struct snd_pcm_substream *substream)
460{
461 struct echoaudio *chip = snd_pcm_substream_chip(substream);
462 int oc;
463
464 /* Nothing to do here. Audio is already off and pipe will be
465 * freed by its callback
466 */
467 DE_ACT(("pcm_close\n"));
468
469 atomic_dec(&chip->opencount);
470 oc = atomic_read(&chip->opencount);
471 DE_ACT(("pcm_close oc=%d cs=%d rs=%d\n", oc,
472 chip->can_set_rate, chip->rate_set));
473 if (oc < 2)
474 chip->can_set_rate = 1;
475 if (oc == 0)
476 chip->rate_set = 0;
477 DE_ACT(("pcm_close2 oc=%d cs=%d rs=%d\n", oc,
478 chip->can_set_rate,chip->rate_set));
479
480 return 0;
481}
482
483
484
485/* Channel allocation and scatter-gather list setup */
486static int init_engine(struct snd_pcm_substream *substream,
487 struct snd_pcm_hw_params *hw_params,
488 int pipe_index, int interleave)
489{
490 struct echoaudio *chip;
491 int err, per, rest, page, edge, offs;
492 struct snd_sg_buf *sgbuf;
493 struct audiopipe *pipe;
494
495 chip = snd_pcm_substream_chip(substream);
496 pipe = (struct audiopipe *) substream->runtime->private_data;
497
498 /* Sets up che hardware. If it's already initialized, reset and
499 * redo with the new parameters
500 */
501 spin_lock_irq(&chip->lock);
502 if (pipe->index >= 0) {
503 DE_HWP(("hwp_ie free(%d)\n", pipe->index));
504 err = free_pipes(chip, pipe);
505 snd_assert(!err);
506 chip->substream[pipe->index] = NULL;
507 }
508
509 err = allocate_pipes(chip, pipe, pipe_index, interleave);
510 if (err < 0) {
511 spin_unlock_irq(&chip->lock);
512 DE_ACT((KERN_NOTICE "allocate_pipes(%d) err=%d\n",
513 pipe_index, err));
514 return err;
515 }
516 spin_unlock_irq(&chip->lock);
517 DE_ACT((KERN_NOTICE "allocate_pipes()=%d\n", pipe_index));
518
519 DE_HWP(("pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n",
520 params_buffer_bytes(hw_params), params_periods(hw_params),
521 params_period_bytes(hw_params)));
522 err = snd_pcm_lib_malloc_pages(substream,
523 params_buffer_bytes(hw_params));
524 if (err < 0) {
525 snd_printk(KERN_ERR "malloc_pages err=%d\n", err);
526 spin_lock_irq(&chip->lock);
527 free_pipes(chip, pipe);
528 spin_unlock_irq(&chip->lock);
529 pipe->index = -1;
530 return err;
531 }
532
533 sgbuf = snd_pcm_substream_sgbuf(substream);
534
535 DE_HWP(("pcm_hw_params table size=%d pages=%d\n",
536 sgbuf->size, sgbuf->pages));
537 sglist_init(chip, pipe);
538 edge = PAGE_SIZE;
539 for (offs = page = per = 0; offs < params_buffer_bytes(hw_params);
540 per++) {
541 rest = params_period_bytes(hw_params);
542 if (offs + rest > params_buffer_bytes(hw_params))
543 rest = params_buffer_bytes(hw_params) - offs;
544 while (rest) {
545 if (rest <= edge - offs) {
546 sglist_add_mapping(chip, pipe,
547 snd_sgbuf_get_addr(sgbuf, offs),
548 rest);
549 sglist_add_irq(chip, pipe);
550 offs += rest;
551 rest = 0;
552 } else {
553 sglist_add_mapping(chip, pipe,
554 snd_sgbuf_get_addr(sgbuf, offs),
555 edge - offs);
556 rest -= edge - offs;
557 offs = edge;
558 }
559 if (offs == edge) {
560 edge += PAGE_SIZE;
561 page++;
562 }
563 }
564 }
565
566 /* Close the ring buffer */
567 sglist_wrap(chip, pipe);
568
569 /* This stuff is used by the irq handler, so it must be
570 * initialized before chip->substream
571 */
572 chip->last_period[pipe_index] = 0;
573 pipe->last_counter = 0;
574 pipe->position = 0;
575 smp_wmb();
576 chip->substream[pipe_index] = substream;
577 chip->rate_set = 1;
578 spin_lock_irq(&chip->lock);
579 set_sample_rate(chip, hw_params->rate_num / hw_params->rate_den);
580 spin_unlock_irq(&chip->lock);
581 DE_HWP(("pcm_hw_params ok\n"));
582 return 0;
583}
584
585
586
587static int pcm_analog_in_hw_params(struct snd_pcm_substream *substream,
588 struct snd_pcm_hw_params *hw_params)
589{
590 struct echoaudio *chip = snd_pcm_substream_chip(substream);
591
592 return init_engine(substream, hw_params, px_analog_in(chip) +
593 substream->number, params_channels(hw_params));
594}
595
596
597
598static int pcm_analog_out_hw_params(struct snd_pcm_substream *substream,
599 struct snd_pcm_hw_params *hw_params)
600{
601 return init_engine(substream, hw_params, substream->number,
602 params_channels(hw_params));
603}
604
605
606
607#ifdef ECHOCARD_HAS_DIGITAL_IO
608
609static int pcm_digital_in_hw_params(struct snd_pcm_substream *substream,
610 struct snd_pcm_hw_params *hw_params)
611{
612 struct echoaudio *chip = snd_pcm_substream_chip(substream);
613
614 return init_engine(substream, hw_params, px_digital_in(chip) +
615 substream->number, params_channels(hw_params));
616}
617
618
619
620#ifndef ECHOCARD_HAS_VMIXER /* See the note in snd_echo_new_pcm() */
621static int pcm_digital_out_hw_params(struct snd_pcm_substream *substream,
622 struct snd_pcm_hw_params *hw_params)
623{
624 struct echoaudio *chip = snd_pcm_substream_chip(substream);
625
626 return init_engine(substream, hw_params, px_digital_out(chip) +
627 substream->number, params_channels(hw_params));
628}
629#endif /* !ECHOCARD_HAS_VMIXER */
630
631#endif /* ECHOCARD_HAS_DIGITAL_IO */
632
633
634
635static int pcm_hw_free(struct snd_pcm_substream *substream)
636{
637 struct echoaudio *chip;
638 struct audiopipe *pipe;
639
640 chip = snd_pcm_substream_chip(substream);
641 pipe = (struct audiopipe *) substream->runtime->private_data;
642
643 spin_lock_irq(&chip->lock);
644 if (pipe->index >= 0) {
645 DE_HWP(("pcm_hw_free(%d)\n", pipe->index));
646 free_pipes(chip, pipe);
647 chip->substream[pipe->index] = NULL;
648 pipe->index = -1;
649 }
650 spin_unlock_irq(&chip->lock);
651
652 DE_HWP(("pcm_hw_freed\n"));
653 snd_pcm_lib_free_pages(substream);
654 return 0;
655}
656
657
658
659static int pcm_prepare(struct snd_pcm_substream *substream)
660{
661 struct echoaudio *chip = snd_pcm_substream_chip(substream);
662 struct snd_pcm_runtime *runtime = substream->runtime;
663 struct audioformat format;
664 int pipe_index = ((struct audiopipe *)runtime->private_data)->index;
665
666 DE_HWP(("Prepare rate=%d format=%d channels=%d\n",
667 runtime->rate, runtime->format, runtime->channels));
668 format.interleave = runtime->channels;
669 format.data_are_bigendian = 0;
670 format.mono_to_stereo = 0;
671 switch (runtime->format) {
672 case SNDRV_PCM_FORMAT_U8:
673 format.bits_per_sample = 8;
674 break;
675 case SNDRV_PCM_FORMAT_S16_LE:
676 format.bits_per_sample = 16;
677 break;
678 case SNDRV_PCM_FORMAT_S24_3LE:
679 format.bits_per_sample = 24;
680 break;
681 case SNDRV_PCM_FORMAT_S32_BE:
682 format.data_are_bigendian = 1;
683 case SNDRV_PCM_FORMAT_S32_LE:
684 format.bits_per_sample = 32;
685 break;
686 default:
687 DE_HWP(("Prepare error: unsupported format %d\n",
688 runtime->format));
689 return -EINVAL;
690 }
691
692 snd_assert(pipe_index < px_num(chip), return -EINVAL);
693 snd_assert(is_pipe_allocated(chip, pipe_index), return -EINVAL);
694 set_audio_format(chip, pipe_index, &format);
695 return 0;
696}
697
698
699
700static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
701{
702 struct echoaudio *chip = snd_pcm_substream_chip(substream);
703 struct snd_pcm_runtime *runtime = substream->runtime;
704 struct audiopipe *pipe = runtime->private_data;
705 int i, err;
706 u32 channelmask = 0;
707 struct list_head *pos;
708 struct snd_pcm_substream *s;
709
710 snd_pcm_group_for_each(pos, substream) {
711 s = snd_pcm_group_substream_entry(pos);
712 for (i = 0; i < DSP_MAXPIPES; i++) {
713 if (s == chip->substream[i]) {
714 channelmask |= 1 << i;
715 snd_pcm_trigger_done(s, substream);
716 }
717 }
718 }
719
720 spin_lock(&chip->lock);
721 switch (cmd) {
722 case SNDRV_PCM_TRIGGER_START:
723 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
724 DE_ACT(("pcm_trigger start\n"));
725 for (i = 0; i < DSP_MAXPIPES; i++) {
726 if (channelmask & (1 << i)) {
727 pipe = chip->substream[i]->runtime->private_data;
728 switch (pipe->state) {
729 case PIPE_STATE_STOPPED:
730 chip->last_period[i] = 0;
731 pipe->last_counter = 0;
732 pipe->position = 0;
733 *pipe->dma_counter = 0;
734 case PIPE_STATE_PAUSED:
735 pipe->state = PIPE_STATE_STARTED;
736 break;
737 case PIPE_STATE_STARTED:
738 break;
739 }
740 }
741 }
742 err = start_transport(chip, channelmask,
743 chip->pipe_cyclic_mask);
744 break;
745 case SNDRV_PCM_TRIGGER_STOP:
746 DE_ACT(("pcm_trigger stop\n"));
747 for (i = 0; i < DSP_MAXPIPES; i++) {
748 if (channelmask & (1 << i)) {
749 pipe = chip->substream[i]->runtime->private_data;
750 pipe->state = PIPE_STATE_STOPPED;
751 }
752 }
753 err = stop_transport(chip, channelmask);
754 break;
755 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
756 DE_ACT(("pcm_trigger pause\n"));
757 for (i = 0; i < DSP_MAXPIPES; i++) {
758 if (channelmask & (1 << i)) {
759 pipe = chip->substream[i]->runtime->private_data;
760 pipe->state = PIPE_STATE_PAUSED;
761 }
762 }
763 err = pause_transport(chip, channelmask);
764 break;
765 default:
766 err = -EINVAL;
767 }
768 spin_unlock(&chip->lock);
769 return err;
770}
771
772
773
774static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream)
775{
776 struct snd_pcm_runtime *runtime = substream->runtime;
777 struct audiopipe *pipe = runtime->private_data;
778 size_t cnt, bufsize, pos;
779
780 cnt = le32_to_cpu(*pipe->dma_counter);
781 pipe->position += cnt - pipe->last_counter;
782 pipe->last_counter = cnt;
783 bufsize = substream->runtime->buffer_size;
784 pos = bytes_to_frames(substream->runtime, pipe->position);
785
786 while (pos >= bufsize) {
787 pipe->position -= frames_to_bytes(substream->runtime, bufsize);
788 pos -= bufsize;
789 }
790 return pos;
791}
792
793
794
795/* pcm *_ops structures */
796static struct snd_pcm_ops analog_playback_ops = {
797 .open = pcm_analog_out_open,
798 .close = pcm_close,
799 .ioctl = snd_pcm_lib_ioctl,
800 .hw_params = pcm_analog_out_hw_params,
801 .hw_free = pcm_hw_free,
802 .prepare = pcm_prepare,
803 .trigger = pcm_trigger,
804 .pointer = pcm_pointer,
805 .page = snd_pcm_sgbuf_ops_page,
806};
807static struct snd_pcm_ops analog_capture_ops = {
808 .open = pcm_analog_in_open,
809 .close = pcm_close,
810 .ioctl = snd_pcm_lib_ioctl,
811 .hw_params = pcm_analog_in_hw_params,
812 .hw_free = pcm_hw_free,
813 .prepare = pcm_prepare,
814 .trigger = pcm_trigger,
815 .pointer = pcm_pointer,
816 .page = snd_pcm_sgbuf_ops_page,
817};
818#ifdef ECHOCARD_HAS_DIGITAL_IO
819#ifndef ECHOCARD_HAS_VMIXER
820static struct snd_pcm_ops digital_playback_ops = {
821 .open = pcm_digital_out_open,
822 .close = pcm_close,
823 .ioctl = snd_pcm_lib_ioctl,
824 .hw_params = pcm_digital_out_hw_params,
825 .hw_free = pcm_hw_free,
826 .prepare = pcm_prepare,
827 .trigger = pcm_trigger,
828 .pointer = pcm_pointer,
829 .page = snd_pcm_sgbuf_ops_page,
830};
831#endif /* !ECHOCARD_HAS_VMIXER */
832static struct snd_pcm_ops digital_capture_ops = {
833 .open = pcm_digital_in_open,
834 .close = pcm_close,
835 .ioctl = snd_pcm_lib_ioctl,
836 .hw_params = pcm_digital_in_hw_params,
837 .hw_free = pcm_hw_free,
838 .prepare = pcm_prepare,
839 .trigger = pcm_trigger,
840 .pointer = pcm_pointer,
841 .page = snd_pcm_sgbuf_ops_page,
842};
843#endif /* ECHOCARD_HAS_DIGITAL_IO */
844
845
846
847/* Preallocate memory only for the first substream because it's the most
848 * used one
849 */
850static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
851{
852 struct snd_pcm_substream *ss;
853 int stream, err;
854
855 for (stream = 0; stream < 2; stream++)
856 for (ss = pcm->streams[stream].substream; ss; ss = ss->next) {
857 err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
858 dev,
859 ss->number ? 0 : 128<<10,
860 256<<10);
861 if (err < 0)
862 return err;
863 }
864 return 0;
865}
866
867
868
869/*<--snd_echo_probe() */
870static int __devinit snd_echo_new_pcm(struct echoaudio *chip)
871{
872 struct snd_pcm *pcm;
873 int err;
874
875#ifdef ECHOCARD_HAS_VMIXER
876 /* This card has a Vmixer, that is there is no direct mapping from PCM
877 streams to physical outputs. The user can mix the streams as he wishes
878 via control interface and it's possible to send any stream to any
879 output, thus it makes no sense to keep analog and digital outputs
880 separated */
881
882 /* PCM#0 Virtual outputs and analog inputs */
883 if ((err = snd_pcm_new(chip->card, "PCM", 0, num_pipes_out(chip),
884 num_analog_busses_in(chip), &pcm)) < 0)
885 return err;
886 pcm->private_data = chip;
887 chip->analog_pcm = pcm;
888 strcpy(pcm->name, chip->card->shortname);
889 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
890 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
891 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
892 return err;
893 DE_INIT(("Analog PCM ok\n"));
894
895#ifdef ECHOCARD_HAS_DIGITAL_IO
896 /* PCM#1 Digital inputs, no outputs */
897 if ((err = snd_pcm_new(chip->card, "Digital PCM", 1, 0,
898 num_digital_busses_in(chip), &pcm)) < 0)
899 return err;
900 pcm->private_data = chip;
901 chip->digital_pcm = pcm;
902 strcpy(pcm->name, chip->card->shortname);
903 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
904 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
905 return err;
906 DE_INIT(("Digital PCM ok\n"));
907#endif /* ECHOCARD_HAS_DIGITAL_IO */
908
909#else /* ECHOCARD_HAS_VMIXER */
910
911 /* The card can manage substreams formed by analog and digital channels
912 at the same time, but I prefer to keep analog and digital channels
913 separated, because that mixed thing is confusing and useless. So we
914 register two PCM devices: */
915
916 /* PCM#0 Analog i/o */
917 if ((err = snd_pcm_new(chip->card, "Analog PCM", 0,
918 num_analog_busses_out(chip),
919 num_analog_busses_in(chip), &pcm)) < 0)
920 return err;
921 pcm->private_data = chip;
922 chip->analog_pcm = pcm;
923 strcpy(pcm->name, chip->card->shortname);
924 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
925 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
926 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
927 return err;
928 DE_INIT(("Analog PCM ok\n"));
929
930#ifdef ECHOCARD_HAS_DIGITAL_IO
931 /* PCM#1 Digital i/o */
932 if ((err = snd_pcm_new(chip->card, "Digital PCM", 1,
933 num_digital_busses_out(chip),
934 num_digital_busses_in(chip), &pcm)) < 0)
935 return err;
936 pcm->private_data = chip;
937 chip->digital_pcm = pcm;
938 strcpy(pcm->name, chip->card->shortname);
939 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &digital_playback_ops);
940 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
941 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
942 return err;
943 DE_INIT(("Digital PCM ok\n"));
944#endif /* ECHOCARD_HAS_DIGITAL_IO */
945
946#endif /* ECHOCARD_HAS_VMIXER */
947
948 return 0;
949}
950
951
952
953
954/******************************************************************************
955 Control interface
956******************************************************************************/
957
958/******************* PCM output volume *******************/
959static int snd_echo_output_gain_info(struct snd_kcontrol *kcontrol,
960 struct snd_ctl_elem_info *uinfo)
961{
962 struct echoaudio *chip;
963
964 chip = snd_kcontrol_chip(kcontrol);
965 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
966 uinfo->count = num_busses_out(chip);
967 uinfo->value.integer.min = ECHOGAIN_MINOUT;
968 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
969 return 0;
970}
971
972static int snd_echo_output_gain_get(struct snd_kcontrol *kcontrol,
973 struct snd_ctl_elem_value *ucontrol)
974{
975 struct echoaudio *chip;
976 int c;
977
978 chip = snd_kcontrol_chip(kcontrol);
979 for (c = 0; c < num_busses_out(chip); c++)
980 ucontrol->value.integer.value[c] = chip->output_gain[c];
981 return 0;
982}
983
984static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
985 struct snd_ctl_elem_value *ucontrol)
986{
987 struct echoaudio *chip;
988 int c, changed, gain;
989
990 changed = 0;
991 chip = snd_kcontrol_chip(kcontrol);
992 spin_lock_irq(&chip->lock);
993 for (c = 0; c < num_busses_out(chip); c++) {
994 gain = ucontrol->value.integer.value[c];
995 /* Ignore out of range values */
996 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
997 continue;
998 if (chip->output_gain[c] != gain) {
999 set_output_gain(chip, c, gain);
1000 changed = 1;
1001 }
1002 }
1003 if (changed)
1004 update_output_line_level(chip);
1005 spin_unlock_irq(&chip->lock);
1006 return changed;
1007}
1008
1009#ifdef ECHOCARD_HAS_VMIXER
1010/* On Vmixer cards this one controls the line-out volume */
1011static struct snd_kcontrol_new snd_echo_line_output_gain __devinitdata = {
1012 .name = "Line Playback Volume",
1013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1014 .info = snd_echo_output_gain_info,
1015 .get = snd_echo_output_gain_get,
1016 .put = snd_echo_output_gain_put,
1017};
1018#else
1019static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = {
1020 .name = "PCM Playback Volume",
1021 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1022 .info = snd_echo_output_gain_info,
1023 .get = snd_echo_output_gain_get,
1024 .put = snd_echo_output_gain_put,
1025};
1026#endif
1027
1028
1029
1030#ifdef ECHOCARD_HAS_INPUT_GAIN
1031
1032/******************* Analog input volume *******************/
1033static int snd_echo_input_gain_info(struct snd_kcontrol *kcontrol,
1034 struct snd_ctl_elem_info *uinfo)
1035{
1036 struct echoaudio *chip;
1037
1038 chip = snd_kcontrol_chip(kcontrol);
1039 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1040 uinfo->count = num_analog_busses_in(chip);
1041 uinfo->value.integer.min = ECHOGAIN_MININP;
1042 uinfo->value.integer.max = ECHOGAIN_MAXINP;
1043 return 0;
1044}
1045
1046static int snd_echo_input_gain_get(struct snd_kcontrol *kcontrol,
1047 struct snd_ctl_elem_value *ucontrol)
1048{
1049 struct echoaudio *chip;
1050 int c;
1051
1052 chip = snd_kcontrol_chip(kcontrol);
1053 for (c = 0; c < num_analog_busses_in(chip); c++)
1054 ucontrol->value.integer.value[c] = chip->input_gain[c];
1055 return 0;
1056}
1057
1058static int snd_echo_input_gain_put(struct snd_kcontrol *kcontrol,
1059 struct snd_ctl_elem_value *ucontrol)
1060{
1061 struct echoaudio *chip;
1062 int c, gain, changed;
1063
1064 changed = 0;
1065 chip = snd_kcontrol_chip(kcontrol);
1066 spin_lock_irq(&chip->lock);
1067 for (c = 0; c < num_analog_busses_in(chip); c++) {
1068 gain = ucontrol->value.integer.value[c];
1069 /* Ignore out of range values */
1070 if (gain < ECHOGAIN_MININP || gain > ECHOGAIN_MAXINP)
1071 continue;
1072 if (chip->input_gain[c] != gain) {
1073 set_input_gain(chip, c, gain);
1074 changed = 1;
1075 }
1076 }
1077 if (changed)
1078 update_input_line_level(chip);
1079 spin_unlock_irq(&chip->lock);
1080 return changed;
1081}
1082
1083static struct snd_kcontrol_new snd_echo_line_input_gain __devinitdata = {
1084 .name = "Line Capture Volume",
1085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1086 .info = snd_echo_input_gain_info,
1087 .get = snd_echo_input_gain_get,
1088 .put = snd_echo_input_gain_put,
1089};
1090
1091#endif /* ECHOCARD_HAS_INPUT_GAIN */
1092
1093
1094
1095#ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
1096
1097/************ Analog output nominal level (+4dBu / -10dBV) ***************/
1098static int snd_echo_output_nominal_info (struct snd_kcontrol *kcontrol,
1099 struct snd_ctl_elem_info *uinfo)
1100{
1101 struct echoaudio *chip;
1102
1103 chip = snd_kcontrol_chip(kcontrol);
1104 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1105 uinfo->count = num_analog_busses_out(chip);
1106 uinfo->value.integer.min = 0;
1107 uinfo->value.integer.max = 1;
1108 return 0;
1109}
1110
1111static int snd_echo_output_nominal_get(struct snd_kcontrol *kcontrol,
1112 struct snd_ctl_elem_value *ucontrol)
1113{
1114 struct echoaudio *chip;
1115 int c;
1116
1117 chip = snd_kcontrol_chip(kcontrol);
1118 for (c = 0; c < num_analog_busses_out(chip); c++)
1119 ucontrol->value.integer.value[c] = chip->nominal_level[c];
1120 return 0;
1121}
1122
1123static int snd_echo_output_nominal_put(struct snd_kcontrol *kcontrol,
1124 struct snd_ctl_elem_value *ucontrol)
1125{
1126 struct echoaudio *chip;
1127 int c, changed;
1128
1129 changed = 0;
1130 chip = snd_kcontrol_chip(kcontrol);
1131 spin_lock_irq(&chip->lock);
1132 for (c = 0; c < num_analog_busses_out(chip); c++) {
1133 if (chip->nominal_level[c] != ucontrol->value.integer.value[c]) {
1134 set_nominal_level(chip, c,
1135 ucontrol->value.integer.value[c]);
1136 changed = 1;
1137 }
1138 }
1139 if (changed)
1140 update_output_line_level(chip);
1141 spin_unlock_irq(&chip->lock);
1142 return changed;
1143}
1144
1145static struct snd_kcontrol_new snd_echo_output_nominal_level __devinitdata = {
1146 .name = "Line Playback Switch (-10dBV)",
1147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1148 .info = snd_echo_output_nominal_info,
1149 .get = snd_echo_output_nominal_get,
1150 .put = snd_echo_output_nominal_put,
1151};
1152
1153#endif /* ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL */
1154
1155
1156
1157#ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
1158
1159/*************** Analog input nominal level (+4dBu / -10dBV) ***************/
1160static int snd_echo_input_nominal_info(struct snd_kcontrol *kcontrol,
1161 struct snd_ctl_elem_info *uinfo)
1162{
1163 struct echoaudio *chip;
1164
1165 chip = snd_kcontrol_chip(kcontrol);
1166 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1167 uinfo->count = num_analog_busses_in(chip);
1168 uinfo->value.integer.min = 0;
1169 uinfo->value.integer.max = 1;
1170 return 0;
1171}
1172
1173static int snd_echo_input_nominal_get(struct snd_kcontrol *kcontrol,
1174 struct snd_ctl_elem_value *ucontrol)
1175{
1176 struct echoaudio *chip;
1177 int c;
1178
1179 chip = snd_kcontrol_chip(kcontrol);
1180 for (c = 0; c < num_analog_busses_in(chip); c++)
1181 ucontrol->value.integer.value[c] =
1182 chip->nominal_level[bx_analog_in(chip) + c];
1183 return 0;
1184}
1185
1186static int snd_echo_input_nominal_put(struct snd_kcontrol *kcontrol,
1187 struct snd_ctl_elem_value *ucontrol)
1188{
1189 struct echoaudio *chip;
1190 int c, changed;
1191
1192 changed = 0;
1193 chip = snd_kcontrol_chip(kcontrol);
1194 spin_lock_irq(&chip->lock);
1195 for (c = 0; c < num_analog_busses_in(chip); c++) {
1196 if (chip->nominal_level[bx_analog_in(chip) + c] !=
1197 ucontrol->value.integer.value[c]) {
1198 set_nominal_level(chip, bx_analog_in(chip) + c,
1199 ucontrol->value.integer.value[c]);
1200 changed = 1;
1201 }
1202 }
1203 if (changed)
1204 update_output_line_level(chip); /* "Output" is not a mistake
1205 * here.
1206 */
1207 spin_unlock_irq(&chip->lock);
1208 return changed;
1209}
1210
1211static struct snd_kcontrol_new snd_echo_intput_nominal_level __devinitdata = {
1212 .name = "Line Capture Switch (-10dBV)",
1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1214 .info = snd_echo_input_nominal_info,
1215 .get = snd_echo_input_nominal_get,
1216 .put = snd_echo_input_nominal_put,
1217};
1218
1219#endif /* ECHOCARD_HAS_INPUT_NOMINAL_LEVEL */
1220
1221
1222
1223#ifdef ECHOCARD_HAS_MONITOR
1224
1225/******************* Monitor mixer *******************/
1226static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol,
1227 struct snd_ctl_elem_info *uinfo)
1228{
1229 struct echoaudio *chip;
1230
1231 chip = snd_kcontrol_chip(kcontrol);
1232 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1233 uinfo->count = 1;
1234 uinfo->value.integer.min = ECHOGAIN_MINOUT;
1235 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
1236 uinfo->dimen.d[0] = num_busses_out(chip);
1237 uinfo->dimen.d[1] = num_busses_in(chip);
1238 return 0;
1239}
1240
1241static int snd_echo_mixer_get(struct snd_kcontrol *kcontrol,
1242 struct snd_ctl_elem_value *ucontrol)
1243{
1244 struct echoaudio *chip;
1245
1246 chip = snd_kcontrol_chip(kcontrol);
1247 ucontrol->value.integer.value[0] =
1248 chip->monitor_gain[ucontrol->id.index / num_busses_in(chip)]
1249 [ucontrol->id.index % num_busses_in(chip)];
1250 return 0;
1251}
1252
1253static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
1254 struct snd_ctl_elem_value *ucontrol)
1255{
1256 struct echoaudio *chip;
1257 int changed, gain;
1258 short out, in;
1259
1260 changed = 0;
1261 chip = snd_kcontrol_chip(kcontrol);
1262 out = ucontrol->id.index / num_busses_in(chip);
1263 in = ucontrol->id.index % num_busses_in(chip);
1264 gain = ucontrol->value.integer.value[0];
1265 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
1266 return -EINVAL;
1267 if (chip->monitor_gain[out][in] != gain) {
1268 spin_lock_irq(&chip->lock);
1269 set_monitor_gain(chip, out, in, gain);
1270 update_output_line_level(chip);
1271 spin_unlock_irq(&chip->lock);
1272 changed = 1;
1273 }
1274 return changed;
1275}
1276
1277static struct snd_kcontrol_new snd_echo_monitor_mixer __devinitdata = {
1278 .name = "Monitor Mixer Volume",
1279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1280 .info = snd_echo_mixer_info,
1281 .get = snd_echo_mixer_get,
1282 .put = snd_echo_mixer_put,
1283};
1284
1285#endif /* ECHOCARD_HAS_MONITOR */
1286
1287
1288
1289#ifdef ECHOCARD_HAS_VMIXER
1290
1291/******************* Vmixer *******************/
1292static int snd_echo_vmixer_info(struct snd_kcontrol *kcontrol,
1293 struct snd_ctl_elem_info *uinfo)
1294{
1295 struct echoaudio *chip;
1296
1297 chip = snd_kcontrol_chip(kcontrol);
1298 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1299 uinfo->count = 1;
1300 uinfo->value.integer.min = ECHOGAIN_MINOUT;
1301 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
1302 uinfo->dimen.d[0] = num_busses_out(chip);
1303 uinfo->dimen.d[1] = num_pipes_out(chip);
1304 return 0;
1305}
1306
1307static int snd_echo_vmixer_get(struct snd_kcontrol *kcontrol,
1308 struct snd_ctl_elem_value *ucontrol)
1309{
1310 struct echoaudio *chip;
1311
1312 chip = snd_kcontrol_chip(kcontrol);
1313 ucontrol->value.integer.value[0] =
1314 chip->vmixer_gain[ucontrol->id.index / num_pipes_out(chip)]
1315 [ucontrol->id.index % num_pipes_out(chip)];
1316 return 0;
1317}
1318
1319static int snd_echo_vmixer_put(struct snd_kcontrol *kcontrol,
1320 struct snd_ctl_elem_value *ucontrol)
1321{
1322 struct echoaudio *chip;
1323 int gain, changed;
1324 short vch, out;
1325
1326 changed = 0;
1327 chip = snd_kcontrol_chip(kcontrol);
1328 out = ucontrol->id.index / num_pipes_out(chip);
1329 vch = ucontrol->id.index % num_pipes_out(chip);
1330 gain = ucontrol->value.integer.value[0];
1331 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
1332 return -EINVAL;
1333 if (chip->vmixer_gain[out][vch] != ucontrol->value.integer.value[0]) {
1334 spin_lock_irq(&chip->lock);
1335 set_vmixer_gain(chip, out, vch, ucontrol->value.integer.value[0]);
1336 update_vmixer_level(chip);
1337 spin_unlock_irq(&chip->lock);
1338 changed = 1;
1339 }
1340 return changed;
1341}
1342
1343static struct snd_kcontrol_new snd_echo_vmixer __devinitdata = {
1344 .name = "VMixer Volume",
1345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1346 .info = snd_echo_vmixer_info,
1347 .get = snd_echo_vmixer_get,
1348 .put = snd_echo_vmixer_put,
1349};
1350
1351#endif /* ECHOCARD_HAS_VMIXER */
1352
1353
1354
1355#ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH
1356
1357/******************* Digital mode switch *******************/
1358static int snd_echo_digital_mode_info(struct snd_kcontrol *kcontrol,
1359 struct snd_ctl_elem_info *uinfo)
1360{
1361 static char *names[4] = {
1362 "S/PDIF Coaxial", "S/PDIF Optical", "ADAT Optical",
1363 "S/PDIF Cdrom"
1364 };
1365 struct echoaudio *chip;
1366
1367 chip = snd_kcontrol_chip(kcontrol);
1368 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1369 uinfo->value.enumerated.items = chip->num_digital_modes;
1370 uinfo->count = 1;
1371 if (uinfo->value.enumerated.item >= chip->num_digital_modes)
1372 uinfo->value.enumerated.item = chip->num_digital_modes - 1;
1373 strcpy(uinfo->value.enumerated.name, names[
1374 chip->digital_mode_list[uinfo->value.enumerated.item]]);
1375 return 0;
1376}
1377
1378static int snd_echo_digital_mode_get(struct snd_kcontrol *kcontrol,
1379 struct snd_ctl_elem_value *ucontrol)
1380{
1381 struct echoaudio *chip;
1382 int i, mode;
1383
1384 chip = snd_kcontrol_chip(kcontrol);
1385 mode = chip->digital_mode;
1386 for (i = chip->num_digital_modes - 1; i >= 0; i--)
1387 if (mode == chip->digital_mode_list[i]) {
1388 ucontrol->value.enumerated.item[0] = i;
1389 break;
1390 }
1391 return 0;
1392}
1393
1394static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol,
1395 struct snd_ctl_elem_value *ucontrol)
1396{
1397 struct echoaudio *chip;
1398 int changed;
1399 unsigned short emode, dmode;
1400
1401 changed = 0;
1402 chip = snd_kcontrol_chip(kcontrol);
1403
1404 emode = ucontrol->value.enumerated.item[0];
1405 if (emode >= chip->num_digital_modes)
1406 return -EINVAL;
1407 dmode = chip->digital_mode_list[emode];
1408
1409 if (dmode != chip->digital_mode) {
1410 /* mode_mutex is required to make this operation atomic wrt
1411 pcm_digital_*_open() and set_input_clock() functions. */
1412 down(&chip->mode_mutex);
1413
1414 /* Do not allow the user to change the digital mode when a pcm
1415 device is open because it also changes the number of channels
1416 and the allowed sample rates */
1417 if (atomic_read(&chip->opencount)) {
1418 changed = -EAGAIN;
1419 } else {
1420 changed = set_digital_mode(chip, dmode);
1421 /* If we had to change the clock source, report it */
1422 if (changed > 0 && chip->clock_src_ctl) {
1423 snd_ctl_notify(chip->card,
1424 SNDRV_CTL_EVENT_MASK_VALUE,
1425 &chip->clock_src_ctl->id);
1426 DE_ACT(("SDM() =%d\n", changed));
1427 }
1428 if (changed >= 0)
1429 changed = 1; /* No errors */
1430 }
1431 up(&chip->mode_mutex);
1432 }
1433 return changed;
1434}
1435
1436static struct snd_kcontrol_new snd_echo_digital_mode_switch __devinitdata = {
1437 .name = "Digital mode Switch",
1438 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1439 .info = snd_echo_digital_mode_info,
1440 .get = snd_echo_digital_mode_get,
1441 .put = snd_echo_digital_mode_put,
1442};
1443
1444#endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */
1445
1446
1447
1448#ifdef ECHOCARD_HAS_DIGITAL_IO
1449
1450/******************* S/PDIF mode switch *******************/
1451static int snd_echo_spdif_mode_info(struct snd_kcontrol *kcontrol,
1452 struct snd_ctl_elem_info *uinfo)
1453{
1454 static char *names[2] = {"Consumer", "Professional"};
1455
1456 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1457 uinfo->value.enumerated.items = 2;
1458 uinfo->count = 1;
1459 if (uinfo->value.enumerated.item)
1460 uinfo->value.enumerated.item = 1;
1461 strcpy(uinfo->value.enumerated.name,
1462 names[uinfo->value.enumerated.item]);
1463 return 0;
1464}
1465
1466static int snd_echo_spdif_mode_get(struct snd_kcontrol *kcontrol,
1467 struct snd_ctl_elem_value *ucontrol)
1468{
1469 struct echoaudio *chip;
1470
1471 chip = snd_kcontrol_chip(kcontrol);
1472 ucontrol->value.enumerated.item[0] = !!chip->professional_spdif;
1473 return 0;
1474}
1475
1476static int snd_echo_spdif_mode_put(struct snd_kcontrol *kcontrol,
1477 struct snd_ctl_elem_value *ucontrol)
1478{
1479 struct echoaudio *chip;
1480 int mode;
1481
1482 chip = snd_kcontrol_chip(kcontrol);
1483 mode = !!ucontrol->value.enumerated.item[0];
1484 if (mode != chip->professional_spdif) {
1485 spin_lock_irq(&chip->lock);
1486 set_professional_spdif(chip, mode);
1487 spin_unlock_irq(&chip->lock);
1488 return 1;
1489 }
1490 return 0;
1491}
1492
1493static struct snd_kcontrol_new snd_echo_spdif_mode_switch __devinitdata = {
1494 .name = "S/PDIF mode Switch",
1495 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1496 .info = snd_echo_spdif_mode_info,
1497 .get = snd_echo_spdif_mode_get,
1498 .put = snd_echo_spdif_mode_put,
1499};
1500
1501#endif /* ECHOCARD_HAS_DIGITAL_IO */
1502
1503
1504
1505#ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
1506
1507/******************* Select input clock source *******************/
1508static int snd_echo_clock_source_info(struct snd_kcontrol *kcontrol,
1509 struct snd_ctl_elem_info *uinfo)
1510{
1511 static char *names[8] = {
1512 "Internal", "Word", "Super", "S/PDIF", "ADAT", "ESync",
1513 "ESync96", "MTC"
1514 };
1515 struct echoaudio *chip;
1516
1517 chip = snd_kcontrol_chip(kcontrol);
1518 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1519 uinfo->value.enumerated.items = chip->num_clock_sources;
1520 uinfo->count = 1;
1521 if (uinfo->value.enumerated.item >= chip->num_clock_sources)
1522 uinfo->value.enumerated.item = chip->num_clock_sources - 1;
1523 strcpy(uinfo->value.enumerated.name, names[
1524 chip->clock_source_list[uinfo->value.enumerated.item]]);
1525 return 0;
1526}
1527
1528static int snd_echo_clock_source_get(struct snd_kcontrol *kcontrol,
1529 struct snd_ctl_elem_value *ucontrol)
1530{
1531 struct echoaudio *chip;
1532 int i, clock;
1533
1534 chip = snd_kcontrol_chip(kcontrol);
1535 clock = chip->input_clock;
1536
1537 for (i = 0; i < chip->num_clock_sources; i++)
1538 if (clock == chip->clock_source_list[i])
1539 ucontrol->value.enumerated.item[0] = i;
1540
1541 return 0;
1542}
1543
1544static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol,
1545 struct snd_ctl_elem_value *ucontrol)
1546{
1547 struct echoaudio *chip;
1548 int changed;
1549 unsigned int eclock, dclock;
1550
1551 changed = 0;
1552 chip = snd_kcontrol_chip(kcontrol);
1553 eclock = ucontrol->value.enumerated.item[0];
1554 if (eclock >= chip->input_clock_types)
1555 return -EINVAL;
1556 dclock = chip->clock_source_list[eclock];
1557 if (chip->input_clock != dclock) {
1558 down(&chip->mode_mutex);
1559 spin_lock_irq(&chip->lock);
1560 if ((changed = set_input_clock(chip, dclock)) == 0)
1561 changed = 1; /* no errors */
1562 spin_unlock_irq(&chip->lock);
1563 up(&chip->mode_mutex);
1564 }
1565
1566 if (changed < 0)
1567 DE_ACT(("seticlk val%d err 0x%x\n", dclock, changed));
1568
1569 return changed;
1570}
1571
1572static struct snd_kcontrol_new snd_echo_clock_source_switch __devinitdata = {
1573 .name = "Sample Clock Source",
1574 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1575 .info = snd_echo_clock_source_info,
1576 .get = snd_echo_clock_source_get,
1577 .put = snd_echo_clock_source_put,
1578};
1579
1580#endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */
1581
1582
1583
1584#ifdef ECHOCARD_HAS_PHANTOM_POWER
1585
1586/******************* Phantom power switch *******************/
1587static int snd_echo_phantom_power_info(struct snd_kcontrol *kcontrol,
1588 struct snd_ctl_elem_info *uinfo)
1589{
1590 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1591 uinfo->count = 1;
1592 uinfo->value.integer.min = 0;
1593 uinfo->value.integer.max = 1;
1594 return 0;
1595}
1596
1597static int snd_echo_phantom_power_get(struct snd_kcontrol *kcontrol,
1598 struct snd_ctl_elem_value *ucontrol)
1599{
1600 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1601
1602 ucontrol->value.integer.value[0] = chip->phantom_power;
1603 return 0;
1604}
1605
1606static int snd_echo_phantom_power_put(struct snd_kcontrol *kcontrol,
1607 struct snd_ctl_elem_value *ucontrol)
1608{
1609 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1610 int power, changed = 0;
1611
1612 power = !!ucontrol->value.integer.value[0];
1613 if (chip->phantom_power != power) {
1614 spin_lock_irq(&chip->lock);
1615 changed = set_phantom_power(chip, power);
1616 spin_unlock_irq(&chip->lock);
1617 if (changed == 0)
1618 changed = 1; /* no errors */
1619 }
1620 return changed;
1621}
1622
1623static struct snd_kcontrol_new snd_echo_phantom_power_switch __devinitdata = {
1624 .name = "Phantom power Switch",
1625 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1626 .info = snd_echo_phantom_power_info,
1627 .get = snd_echo_phantom_power_get,
1628 .put = snd_echo_phantom_power_put,
1629};
1630
1631#endif /* ECHOCARD_HAS_PHANTOM_POWER */
1632
1633
1634
1635#ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
1636
1637/******************* Digital input automute switch *******************/
1638static int snd_echo_automute_info(struct snd_kcontrol *kcontrol,
1639 struct snd_ctl_elem_info *uinfo)
1640{
1641 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1642 uinfo->count = 1;
1643 uinfo->value.integer.min = 0;
1644 uinfo->value.integer.max = 1;
1645 return 0;
1646}
1647
1648static int snd_echo_automute_get(struct snd_kcontrol *kcontrol,
1649 struct snd_ctl_elem_value *ucontrol)
1650{
1651 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1652
1653 ucontrol->value.integer.value[0] = chip->digital_in_automute;
1654 return 0;
1655}
1656
1657static int snd_echo_automute_put(struct snd_kcontrol *kcontrol,
1658 struct snd_ctl_elem_value *ucontrol)
1659{
1660 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1661 int automute, changed = 0;
1662
1663 automute = !!ucontrol->value.integer.value[0];
1664 if (chip->digital_in_automute != automute) {
1665 spin_lock_irq(&chip->lock);
1666 changed = set_input_auto_mute(chip, automute);
1667 spin_unlock_irq(&chip->lock);
1668 if (changed == 0)
1669 changed = 1; /* no errors */
1670 }
1671 return changed;
1672}
1673
1674static struct snd_kcontrol_new snd_echo_automute_switch __devinitdata = {
1675 .name = "Digital Capture Switch (automute)",
1676 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1677 .info = snd_echo_automute_info,
1678 .get = snd_echo_automute_get,
1679 .put = snd_echo_automute_put,
1680};
1681
1682#endif /* ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE */
1683
1684
1685
1686/******************* VU-meters switch *******************/
1687static int snd_echo_vumeters_switch_info(struct snd_kcontrol *kcontrol,
1688 struct snd_ctl_elem_info *uinfo)
1689{
1690 struct echoaudio *chip;
1691
1692 chip = snd_kcontrol_chip(kcontrol);
1693 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1694 uinfo->count = 1;
1695 uinfo->value.integer.min = 0;
1696 uinfo->value.integer.max = 1;
1697 return 0;
1698}
1699
1700static int snd_echo_vumeters_switch_put(struct snd_kcontrol *kcontrol,
1701 struct snd_ctl_elem_value *ucontrol)
1702{
1703 struct echoaudio *chip;
1704
1705 chip = snd_kcontrol_chip(kcontrol);
1706 spin_lock_irq(&chip->lock);
1707 set_meters_on(chip, ucontrol->value.integer.value[0]);
1708 spin_unlock_irq(&chip->lock);
1709 return 1;
1710}
1711
1712static struct snd_kcontrol_new snd_echo_vumeters_switch __devinitdata = {
1713 .name = "VU-meters Switch",
1714 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1715 .access = SNDRV_CTL_ELEM_ACCESS_WRITE,
1716 .info = snd_echo_vumeters_switch_info,
1717 .put = snd_echo_vumeters_switch_put,
1718};
1719
1720
1721
1722/***** Read VU-meters (input, output, analog and digital together) *****/
1723static int snd_echo_vumeters_info(struct snd_kcontrol *kcontrol,
1724 struct snd_ctl_elem_info *uinfo)
1725{
1726 struct echoaudio *chip;
1727
1728 chip = snd_kcontrol_chip(kcontrol);
1729 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1730 uinfo->count = 96;
1731 uinfo->value.integer.min = ECHOGAIN_MINOUT;
1732 uinfo->value.integer.max = 0;
1733#ifdef ECHOCARD_HAS_VMIXER
1734 uinfo->dimen.d[0] = 3; /* Out, In, Virt */
1735#else
1736 uinfo->dimen.d[0] = 2; /* Out, In */
1737#endif
1738 uinfo->dimen.d[1] = 16; /* 16 channels */
1739 uinfo->dimen.d[2] = 2; /* 0=level, 1=peak */
1740 return 0;
1741}
1742
1743static int snd_echo_vumeters_get(struct snd_kcontrol *kcontrol,
1744 struct snd_ctl_elem_value *ucontrol)
1745{
1746 struct echoaudio *chip;
1747
1748 chip = snd_kcontrol_chip(kcontrol);
1749 get_audio_meters(chip, ucontrol->value.integer.value);
1750 return 0;
1751}
1752
1753static struct snd_kcontrol_new snd_echo_vumeters __devinitdata = {
1754 .name = "VU-meters",
1755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1756 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
1757 .info = snd_echo_vumeters_info,
1758 .get = snd_echo_vumeters_get,
1759};
1760
1761
1762
1763/*** Channels info - it exports informations about the number of channels ***/
1764static int snd_echo_channels_info_info(struct snd_kcontrol *kcontrol,
1765 struct snd_ctl_elem_info *uinfo)
1766{
1767 struct echoaudio *chip;
1768
1769 chip = snd_kcontrol_chip(kcontrol);
1770 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1771 uinfo->count = 6;
1772 uinfo->value.integer.min = 0;
1773 uinfo->value.integer.max = 1 << ECHO_CLOCK_NUMBER;
1774 return 0;
1775}
1776
1777static int snd_echo_channels_info_get(struct snd_kcontrol *kcontrol,
1778 struct snd_ctl_elem_value *ucontrol)
1779{
1780 struct echoaudio *chip;
1781 int detected, clocks, bit, src;
1782
1783 chip = snd_kcontrol_chip(kcontrol);
1784 ucontrol->value.integer.value[0] = num_busses_in(chip);
1785 ucontrol->value.integer.value[1] = num_analog_busses_in(chip);
1786 ucontrol->value.integer.value[2] = num_busses_out(chip);
1787 ucontrol->value.integer.value[3] = num_analog_busses_out(chip);
1788 ucontrol->value.integer.value[4] = num_pipes_out(chip);
1789
1790 /* Compute the bitmask of the currently valid input clocks */
1791 detected = detect_input_clocks(chip);
1792 clocks = 0;
1793 src = chip->num_clock_sources - 1;
1794 for (bit = ECHO_CLOCK_NUMBER - 1; bit >= 0; bit--)
1795 if (detected & (1 << bit))
1796 for (; src >= 0; src--)
1797 if (bit == chip->clock_source_list[src]) {
1798 clocks |= 1 << src;
1799 break;
1800 }
1801 ucontrol->value.integer.value[5] = clocks;
1802
1803 return 0;
1804}
1805
1806static struct snd_kcontrol_new snd_echo_channels_info __devinitdata = {
1807 .name = "Channels info",
1808 .iface = SNDRV_CTL_ELEM_IFACE_HWDEP,
1809 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
1810 .info = snd_echo_channels_info_info,
1811 .get = snd_echo_channels_info_get,
1812};
1813
1814
1815
1816
1817/******************************************************************************
1818 IRQ Handler
1819******************************************************************************/
1820
1821static irqreturn_t snd_echo_interrupt(int irq, void *dev_id,
1822 struct pt_regs *regs)
1823{
1824 struct echoaudio *chip = dev_id;
1825 struct snd_pcm_substream *substream;
1826 int period, ss, st;
1827
1828 spin_lock(&chip->lock);
1829 st = service_irq(chip);
1830 if (st < 0) {
1831 spin_unlock(&chip->lock);
1832 return IRQ_NONE;
1833 }
1834 /* The hardware doesn't tell us which substream caused the irq,
1835 thus we have to check all running substreams. */
1836 for (ss = 0; ss < DSP_MAXPIPES; ss++) {
1837 if ((substream = chip->substream[ss])) {
1838 period = pcm_pointer(substream) /
1839 substream->runtime->period_size;
1840 if (period != chip->last_period[ss]) {
1841 chip->last_period[ss] = period;
1842 spin_unlock(&chip->lock);
1843 snd_pcm_period_elapsed(substream);
1844 spin_lock(&chip->lock);
1845 }
1846 }
1847 }
1848 spin_unlock(&chip->lock);
1849
1850#ifdef ECHOCARD_HAS_MIDI
1851 if (st > 0 && chip->midi_in) {
1852 snd_rawmidi_receive(chip->midi_in, chip->midi_buffer, st);
1853 DE_MID(("rawmidi_iread=%d\n", st));
1854 }
1855#endif
1856 return IRQ_HANDLED;
1857}
1858
1859
1860
1861
1862/******************************************************************************
1863 Module construction / destruction
1864******************************************************************************/
1865
1866static int snd_echo_free(struct echoaudio *chip)
1867{
1868 DE_INIT(("Stop DSP...\n"));
1869 if (chip->comm_page) {
1870 rest_in_peace(chip);
1871 snd_dma_free_pages(&chip->commpage_dma_buf);
1872 }
1873 DE_INIT(("Stopped.\n"));
1874
1875 if (chip->irq >= 0)
1876 free_irq(chip->irq, (void *)chip);
1877
1878 if (chip->dsp_registers)
1879 iounmap(chip->dsp_registers);
1880
1881 if (chip->iores)
1882 release_and_free_resource(chip->iores);
1883
1884 DE_INIT(("MMIO freed.\n"));
1885
1886 pci_disable_device(chip->pci);
1887
1888 /* release chip data */
1889 kfree(chip);
1890 DE_INIT(("Chip freed.\n"));
1891 return 0;
1892}
1893
1894
1895
1896static int snd_echo_dev_free(struct snd_device *device)
1897{
1898 struct echoaudio *chip = device->device_data;
1899
1900 DE_INIT(("snd_echo_dev_free()...\n"));
1901 return snd_echo_free(chip);
1902}
1903
1904
1905
1906/* <--snd_echo_probe() */
1907static __devinit int snd_echo_create(struct snd_card *card,
1908 struct pci_dev *pci,
1909 struct echoaudio **rchip)
1910{
1911 struct echoaudio *chip;
1912 int err;
1913 size_t sz;
1914 static struct snd_device_ops ops = {
1915 .dev_free = snd_echo_dev_free,
1916 };
1917
1918 *rchip = NULL;
1919
1920 pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0xC0);
1921
1922 if ((err = pci_enable_device(pci)) < 0)
1923 return err;
1924 pci_set_master(pci);
1925
1926 /* allocate a chip-specific data */
1927 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1928 if (!chip) {
1929 pci_disable_device(pci);
1930 return -ENOMEM;
1931 }
1932 DE_INIT(("chip=%p\n", chip));
1933
1934 spin_lock_init(&chip->lock);
1935 chip->card = card;
1936 chip->pci = pci;
1937 chip->irq = -1;
1938
1939 /* PCI resource allocation */
1940 chip->dsp_registers_phys = pci_resource_start(pci, 0);
1941 sz = pci_resource_len(pci, 0);
1942 if (sz > PAGE_SIZE)
1943 sz = PAGE_SIZE; /* We map only the required part */
1944
1945 if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz,
1946 ECHOCARD_NAME)) == NULL) {
1947 snd_echo_free(chip);
1948 snd_printk(KERN_ERR "cannot get memory region\n");
1949 return -EBUSY;
1950 }
1951 chip->dsp_registers = (volatile u32 __iomem *)
1952 ioremap_nocache(chip->dsp_registers_phys, sz);
1953
1954 if (request_irq(pci->irq, snd_echo_interrupt, SA_INTERRUPT | SA_SHIRQ,
1955 ECHOCARD_NAME, (void *)chip)) {
1956 snd_echo_free(chip);
1957 snd_printk(KERN_ERR "cannot grab irq\n");
1958 return -EBUSY;
1959 }
1960 chip->irq = pci->irq;
1961 DE_INIT(("pci=%p irq=%d subdev=%04x Init hardware...\n",
1962 chip->pci, chip->irq, chip->pci->subsystem_device));
1963
1964 /* Create the DSP comm page - this is the area of memory used for most
1965 of the communication with the DSP, which accesses it via bus mastering */
1966 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1967 sizeof(struct comm_page),
1968 &chip->commpage_dma_buf) < 0) {
1969 snd_echo_free(chip);
1970 snd_printk(KERN_ERR "cannot allocate the comm page\n");
1971 return -ENOMEM;
1972 }
1973 chip->comm_page_phys = chip->commpage_dma_buf.addr;
1974 chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area;
1975
1976 err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device);
1977 if (err) {
1978 DE_INIT(("init_hw err=%d\n", err));
1979 snd_echo_free(chip);
1980 return err;
1981 }
1982 DE_INIT(("Card init OK\n"));
1983
1984 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
1985 snd_echo_free(chip);
1986 return err;
1987 }
1988 atomic_set(&chip->opencount, 0);
1989 init_MUTEX(&chip->mode_mutex);
1990 chip->can_set_rate = 1;
1991 *rchip = chip;
1992 /* Init done ! */
1993 return 0;
1994}
1995
1996
1997
1998/* constructor */
1999static int __devinit snd_echo_probe(struct pci_dev *pci,
2000 const struct pci_device_id *pci_id)
2001{
2002 static int dev;
2003 struct snd_card *card;
2004 struct echoaudio *chip;
2005 char *dsp;
2006 int i, err;
2007
2008 if (dev >= SNDRV_CARDS)
2009 return -ENODEV;
2010 if (!enable[dev]) {
2011 dev++;
2012 return -ENOENT;
2013 }
2014
2015 DE_INIT(("Echoaudio driver starting...\n"));
2016 i = 0;
2017 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
2018 if (card == NULL)
2019 return -ENOMEM;
2020
2021 if ((err = snd_echo_create(card, pci, &chip)) < 0) {
2022 snd_card_free(card);
2023 return err;
2024 }
2025
2026 strcpy(card->driver, "Echo_" ECHOCARD_NAME);
2027 strcpy(card->shortname, chip->card_name);
2028
2029 dsp = "56301";
2030 if (pci_id->device == 0x3410)
2031 dsp = "56361";
2032
2033 sprintf(card->longname, "%s rev.%d (DSP%s) at 0x%lx irq %i",
2034 card->shortname, pci_id->subdevice & 0x000f, dsp,
2035 chip->dsp_registers_phys, chip->irq);
2036
2037 if ((err = snd_echo_new_pcm(chip)) < 0) {
2038 snd_printk(KERN_ERR "new pcm error %d\n", err);
2039 snd_card_free(card);
2040 return err;
2041 }
2042
2043#ifdef ECHOCARD_HAS_MIDI
2044 if (chip->has_midi) { /* Some Mia's do not have midi */
2045 if ((err = snd_echo_midi_create(card, chip)) < 0) {
2046 snd_printk(KERN_ERR "new midi error %d\n", err);
2047 snd_card_free(card);
2048 return err;
2049 }
2050 }
2051#endif
2052
2053#ifdef ECHOCARD_HAS_VMIXER
2054 snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip);
2055 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_output_gain, chip))) < 0)
2056 goto ctl_error;
2057 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip))) < 0)
2058 goto ctl_error;
2059#else
2060 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_pcm_output_gain, chip))) < 0)
2061 goto ctl_error;
2062#endif
2063
2064#ifdef ECHOCARD_HAS_INPUT_GAIN
2065 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_input_gain, chip))) < 0)
2066 goto ctl_error;
2067#endif
2068
2069#ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
2070 if (!chip->hasnt_input_nominal_level)
2071 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_intput_nominal_level, chip))) < 0)
2072 goto ctl_error;
2073#endif
2074
2075#ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
2076 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_output_nominal_level, chip))) < 0)
2077 goto ctl_error;
2078#endif
2079
2080 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters_switch, chip))) < 0)
2081 goto ctl_error;
2082
2083 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters, chip))) < 0)
2084 goto ctl_error;
2085
2086#ifdef ECHOCARD_HAS_MONITOR
2087 snd_echo_monitor_mixer.count = num_busses_in(chip) * num_busses_out(chip);
2088 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_monitor_mixer, chip))) < 0)
2089 goto ctl_error;
2090#endif
2091
2092#ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
2093 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_automute_switch, chip))) < 0)
2094 goto ctl_error;
2095#endif
2096
2097 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_channels_info, chip))) < 0)
2098 goto ctl_error;
2099
2100#ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH
2101 /* Creates a list of available digital modes */
2102 chip->num_digital_modes = 0;
2103 for (i = 0; i < 6; i++)
2104 if (chip->digital_modes & (1 << i))
2105 chip->digital_mode_list[chip->num_digital_modes++] = i;
2106
2107 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_digital_mode_switch, chip))) < 0)
2108 goto ctl_error;
2109#endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */
2110
2111#ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
2112 /* Creates a list of available clock sources */
2113 chip->num_clock_sources = 0;
2114 for (i = 0; i < 10; i++)
2115 if (chip->input_clock_types & (1 << i))
2116 chip->clock_source_list[chip->num_clock_sources++] = i;
2117
2118 if (chip->num_clock_sources > 1) {
2119 chip->clock_src_ctl = snd_ctl_new1(&snd_echo_clock_source_switch, chip);
2120 if ((err = snd_ctl_add(chip->card, chip->clock_src_ctl)) < 0)
2121 goto ctl_error;
2122 }
2123#endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */
2124
2125#ifdef ECHOCARD_HAS_DIGITAL_IO
2126 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_spdif_mode_switch, chip))) < 0)
2127 goto ctl_error;
2128#endif
2129
2130#ifdef ECHOCARD_HAS_PHANTOM_POWER
2131 if (chip->has_phantom_power)
2132 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_phantom_power_switch, chip))) < 0)
2133 goto ctl_error;
2134#endif
2135
2136 if ((err = snd_card_register(card)) < 0) {
2137 snd_card_free(card);
2138 goto ctl_error;
2139 }
2140 snd_printk(KERN_INFO "Card registered: %s\n", card->longname);
2141
2142 pci_set_drvdata(pci, chip);
2143 dev++;
2144 return 0;
2145
2146ctl_error:
2147 snd_printk(KERN_ERR "new control error %d\n", err);
2148 snd_card_free(card);
2149 return err;
2150}
2151
2152
2153
2154static void __devexit snd_echo_remove(struct pci_dev *pci)
2155{
2156 struct echoaudio *chip;
2157
2158 chip = pci_get_drvdata(pci);
2159 if (chip)
2160 snd_card_free(chip->card);
2161 pci_set_drvdata(pci, NULL);
2162}
2163
2164
2165
2166/******************************************************************************
2167 Everything starts and ends here
2168******************************************************************************/
2169
2170/* pci_driver definition */
2171static struct pci_driver driver = {
2172 .name = "Echoaudio " ECHOCARD_NAME,
2173 .id_table = snd_echo_ids,
2174 .probe = snd_echo_probe,
2175 .remove = __devexit_p(snd_echo_remove),
2176};
2177
2178
2179
2180/* initialization of the module */
2181static int __init alsa_card_echo_init(void)
2182{
2183 return pci_register_driver(&driver);
2184}
2185
2186
2187
2188/* clean up the module */
2189static void __exit alsa_card_echo_exit(void)
2190{
2191 pci_unregister_driver(&driver);
2192}
2193
2194
2195module_init(alsa_card_echo_init)
2196module_exit(alsa_card_echo_exit)
diff --git a/sound/pci/echoaudio/echoaudio.h b/sound/pci/echoaudio/echoaudio.h
new file mode 100644
index 000000000000..7e88c968e22f
--- /dev/null
+++ b/sound/pci/echoaudio/echoaudio.h
@@ -0,0 +1,590 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 ****************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29 ****************************************************************************
30
31
32 Here's a block diagram of how most of the cards work:
33
34 +-----------+
35 record | |<-------------------- Inputs
36 <-------| | |
37 PCI | Transport | |
38 bus | engine | \|/
39 ------->| | +-------+
40 play | |--->|monitor|-------> Outputs
41 +-----------+ | mixer |
42 +-------+
43
44 The lines going to and from the PCI bus represent "pipes". A pipe performs
45 audio transport - moving audio data to and from buffers on the host via
46 bus mastering.
47
48 The inputs and outputs on the right represent input and output "busses."
49 A bus is a physical, real connection to the outside world. An example
50 of a bus would be the 1/4" analog connectors on the back of Layla or
51 an RCA S/PDIF connector.
52
53 For most cards, there is a one-to-one correspondence between outputs
54 and busses; that is, each individual pipe is hard-wired to a single bus.
55
56 Cards that work this way are Darla20, Gina20, Layla20, Darla24, Gina24,
57 Layla24, Mona, and Indigo.
58
59
60 Mia has a feature called "virtual outputs."
61
62
63 +-----------+
64 record | |<----------------------------- Inputs
65 <-------| | |
66 PCI | Transport | |
67 bus | engine | \|/
68 ------->| | +------+ +-------+
69 play | |-->|vmixer|-->|monitor|-------> Outputs
70 +-----------+ +------+ | mixer |
71 +-------+
72
73
74 Obviously, the difference here is the box labeled "vmixer." Vmixer is
75 short for "virtual output mixer." For Mia, pipes are *not* hard-wired
76 to a single bus; the vmixer lets you mix any pipe to any bus in any
77 combination.
78
79 Note, however, that the left-hand side of the diagram is unchanged.
80 Transport works exactly the same way - the difference is in the mixer stage.
81
82
83 Pipes and busses are numbered starting at zero.
84
85
86
87 Pipe index
88 ==========
89
90 A number of calls in CEchoGals refer to a "pipe index". A pipe index is
91 a unique number for a pipe that unambiguously refers to a playback or record
92 pipe. Pipe indices are numbered starting with analog outputs, followed by
93 digital outputs, then analog inputs, then digital inputs.
94
95 Take Gina24 as an example:
96
97 Pipe index
98
99 0-7 Analog outputs (0 .. FirstDigitalBusOut-1)
100 8-15 Digital outputs (FirstDigitalBusOut .. NumBussesOut-1)
101 16-17 Analog inputs
102 18-25 Digital inputs
103
104
105 You get the pipe index by calling CEchoGals::OpenAudio; the other transport
106 functions take the pipe index as a parameter. If you need a pipe index for
107 some other reason, use the handy Makepipe_index method.
108
109
110 Some calls take a CChannelMask parameter; CChannelMask is a handy way to
111 group pipe indices.
112
113
114
115 Digital mode switch
116 ===================
117
118 Some cards (right now, Gina24, Layla24, and Mona) have a Digital Mode Switch
119 or DMS. Cards with a DMS can be set to one of three mutually exclusive
120 digital modes: S/PDIF RCA, S/PDIF optical, or ADAT optical.
121
122 This may create some confusion since ADAT optical is 8 channels wide and
123 S/PDIF is only two channels wide. Gina24, Layla24, and Mona handle this
124 by acting as if they always have 8 digital outs and ins. If you are in
125 either S/PDIF mode, the last 6 channels don't do anything - data sent
126 out these channels is thrown away and you will always record zeros.
127
128 Note that with Gina24, Layla24, and Mona, sample rates above 50 kHz are
129 only available if you have the card configured for S/PDIF optical or S/PDIF
130 RCA.
131
132
133
134 Double speed mode
135 =================
136
137 Some of the cards support 88.2 kHz and 96 kHz sampling (Darla24, Gina24,
138 Layla24, Mona, Mia, and Indigo). For these cards, the driver sometimes has
139 to worry about "double speed mode"; double speed mode applies whenever the
140 sampling rate is above 50 kHz.
141
142 For instance, Mona and Layla24 support word clock sync. However, they
143 actually support two different word clock modes - single speed (below
144 50 kHz) and double speed (above 50 kHz). The hardware detects if a single
145 or double speed word clock signal is present; the generic code uses that
146 information to determine which mode to use.
147
148 The generic code takes care of all this for you.
149*/
150
151
152#ifndef _ECHOAUDIO_H_
153#define _ECHOAUDIO_H_
154
155
156#define TRUE 1
157#define FALSE 0
158
159#include "echoaudio_dsp.h"
160
161
162
163/***********************************************************************
164
165 PCI configuration space
166
167***********************************************************************/
168
169/*
170 * PCI vendor ID and device IDs for the hardware
171 */
172#define VENDOR_ID 0x1057
173#define DEVICE_ID_56301 0x1801
174#define DEVICE_ID_56361 0x3410
175#define SUBVENDOR_ID 0xECC0
176
177
178/*
179 * Valid Echo PCI subsystem card IDs
180 */
181#define DARLA20 0x0010
182#define GINA20 0x0020
183#define LAYLA20 0x0030
184#define DARLA24 0x0040
185#define GINA24 0x0050
186#define LAYLA24 0x0060
187#define MONA 0x0070
188#define MIA 0x0080
189#define INDIGO 0x0090
190#define INDIGO_IO 0x00a0
191#define INDIGO_DJ 0x00b0
192#define ECHO3G 0x0100
193
194
195/************************************************************************
196
197 Array sizes and so forth
198
199***********************************************************************/
200
201/*
202 * Sizes
203 */
204#define ECHO_MAXAUDIOINPUTS 32 /* Max audio input channels */
205#define ECHO_MAXAUDIOOUTPUTS 32 /* Max audio output channels */
206#define ECHO_MAXAUDIOPIPES 32 /* Max number of input and output
207 * pipes */
208#define E3G_MAX_OUTPUTS 16
209#define ECHO_MAXMIDIJACKS 1 /* Max MIDI ports */
210#define ECHO_MIDI_QUEUE_SZ 512 /* Max MIDI input queue entries */
211#define ECHO_MTC_QUEUE_SZ 32 /* Max MIDI time code input queue
212 * entries */
213
214/*
215 * MIDI activity indicator timeout
216 */
217#define MIDI_ACTIVITY_TIMEOUT_USEC 200000
218
219
220/****************************************************************************
221
222 Clocks
223
224*****************************************************************************/
225
226/*
227 * Clock numbers
228 */
229#define ECHO_CLOCK_INTERNAL 0
230#define ECHO_CLOCK_WORD 1
231#define ECHO_CLOCK_SUPER 2
232#define ECHO_CLOCK_SPDIF 3
233#define ECHO_CLOCK_ADAT 4
234#define ECHO_CLOCK_ESYNC 5
235#define ECHO_CLOCK_ESYNC96 6
236#define ECHO_CLOCK_MTC 7
237#define ECHO_CLOCK_NUMBER 8
238#define ECHO_CLOCKS 0xffff
239
240/*
241 * Clock bit numbers - used to report capabilities and whatever clocks
242 * are being detected dynamically.
243 */
244#define ECHO_CLOCK_BIT_INTERNAL (1 << ECHO_CLOCK_INTERNAL)
245#define ECHO_CLOCK_BIT_WORD (1 << ECHO_CLOCK_WORD)
246#define ECHO_CLOCK_BIT_SUPER (1 << ECHO_CLOCK_SUPER)
247#define ECHO_CLOCK_BIT_SPDIF (1 << ECHO_CLOCK_SPDIF)
248#define ECHO_CLOCK_BIT_ADAT (1 << ECHO_CLOCK_ADAT)
249#define ECHO_CLOCK_BIT_ESYNC (1 << ECHO_CLOCK_ESYNC)
250#define ECHO_CLOCK_BIT_ESYNC96 (1 << ECHO_CLOCK_ESYNC96)
251#define ECHO_CLOCK_BIT_MTC (1<<ECHO_CLOCK_MTC)
252
253
254/***************************************************************************
255
256 Digital modes
257
258****************************************************************************/
259
260/*
261 * Digital modes for Mona, Layla24, and Gina24
262 */
263#define DIGITAL_MODE_NONE 0xFF
264#define DIGITAL_MODE_SPDIF_RCA 0
265#define DIGITAL_MODE_SPDIF_OPTICAL 1
266#define DIGITAL_MODE_ADAT 2
267#define DIGITAL_MODE_SPDIF_CDROM 3
268#define DIGITAL_MODES 4
269
270/*
271 * Digital mode capability masks
272 */
273#define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA (1 << DIGITAL_MODE_SPDIF_RCA)
274#define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL (1 << DIGITAL_MODE_SPDIF_OPTICAL)
275#define ECHOCAPS_HAS_DIGITAL_MODE_ADAT (1 << DIGITAL_MODE_ADAT)
276#define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM (1 << DIGITAL_MODE_SPDIF_CDROM)
277
278
279#define EXT_3GBOX_NC 0x01 /* 3G box not connected */
280#define EXT_3GBOX_NOT_SET 0x02 /* 3G box not detected yet */
281
282
283#define ECHOGAIN_MUTED (-128) /* Minimum possible gain */
284#define ECHOGAIN_MINOUT (-128) /* Min output gain (dB) */
285#define ECHOGAIN_MAXOUT (6) /* Max output gain (dB) */
286#define ECHOGAIN_MININP (-50) /* Min input gain (0.5 dB) */
287#define ECHOGAIN_MAXINP (50) /* Max input gain (0.5 dB) */
288
289#define PIPE_STATE_STOPPED 0 /* Pipe has been reset */
290#define PIPE_STATE_PAUSED 1 /* Pipe has been stopped */
291#define PIPE_STATE_STARTED 2 /* Pipe has been started */
292#define PIPE_STATE_PENDING 3 /* Pipe has pending start */
293
294
295/* Debug initialization */
296#ifdef CONFIG_SND_DEBUG
297#define DE_INIT(x) snd_printk x
298#else
299#define DE_INIT(x)
300#endif
301
302/* Debug hw_params callbacks */
303#ifdef CONFIG_SND_DEBUG
304#define DE_HWP(x) snd_printk x
305#else
306#define DE_HWP(x)
307#endif
308
309/* Debug normal activity (open, start, stop...) */
310#ifdef CONFIG_SND_DEBUG
311#define DE_ACT(x) snd_printk x
312#else
313#define DE_ACT(x)
314#endif
315
316/* Debug midi activity */
317#ifdef CONFIG_SND_DEBUG
318#define DE_MID(x) snd_printk x
319#else
320#define DE_MID(x)
321#endif
322
323
324struct audiopipe {
325 volatile u32 *dma_counter; /* Commpage register that contains
326 * the current dma position
327 * (lower 32 bits only)
328 */
329 u32 last_counter; /* The last position, which is used
330 * to compute...
331 */
332 u32 position; /* ...the number of bytes tranferred
333 * by the DMA engine, modulo the
334 * buffer size
335 */
336 short index; /* Index of the first channel or <0
337 * if hw is not configured yet
338 */
339 short interleave;
340 struct snd_dma_buffer sgpage; /* Room for the scatter-gather list */
341 struct snd_pcm_hardware hw;
342 struct snd_pcm_hw_constraint_list constr;
343 short sglist_head;
344 char state; /* pipe state */
345};
346
347
348struct audioformat {
349 u8 interleave; /* How the data is arranged in memory:
350 * mono = 1, stereo = 2, ...
351 */
352 u8 bits_per_sample; /* 8, 16, 24, 32 (24 bits left aligned) */
353 char mono_to_stereo; /* Only used if interleave is 1 and
354 * if this is an output pipe.
355 */
356 char data_are_bigendian; /* 1 = big endian, 0 = little endian */
357};
358
359
360struct echoaudio {
361 spinlock_t lock;
362 struct snd_pcm_substream *substream[DSP_MAXPIPES];
363 int last_period[DSP_MAXPIPES];
364 struct semaphore mode_mutex;
365 u16 num_digital_modes, digital_mode_list[6];
366 u16 num_clock_sources, clock_source_list[10];
367 atomic_t opencount;
368 struct snd_kcontrol *clock_src_ctl;
369 struct snd_pcm *analog_pcm, *digital_pcm;
370 struct snd_card *card;
371 const char *card_name;
372 struct pci_dev *pci;
373 unsigned long dsp_registers_phys;
374 struct resource *iores;
375 struct snd_dma_buffer commpage_dma_buf;
376 int irq;
377#ifdef ECHOCARD_HAS_MIDI
378 struct snd_rawmidi *rmidi;
379 struct snd_rawmidi_substream *midi_in, *midi_out;
380#endif
381 struct timer_list timer;
382 char tinuse; /* Timer in use */
383 char midi_full; /* MIDI output buffer is full */
384 char can_set_rate;
385 char rate_set;
386
387 /* This stuff is used mainly by the lowlevel code */
388 struct comm_page *comm_page; /* Virtual address of the memory
389 * seen by DSP
390 */
391 u32 pipe_alloc_mask; /* Bitmask of allocated pipes */
392 u32 pipe_cyclic_mask; /* Bitmask of pipes with cyclic
393 * buffers
394 */
395 u32 sample_rate; /* Card sample rate in Hz */
396 u8 digital_mode; /* Current digital mode
397 * (see DIGITAL_MODE_*)
398 */
399 u8 spdif_status; /* Gina20, Darla20, Darla24 - only */
400 u8 clock_state; /* Gina20, Darla20, Darla24 - only */
401 u8 input_clock; /* Currently selected sample clock
402 * source
403 */
404 u8 output_clock; /* Layla20 only */
405 char meters_enabled; /* VU-meters status */
406 char asic_loaded; /* Set TRUE when ASIC loaded */
407 char bad_board; /* Set TRUE if DSP won't load */
408 char professional_spdif; /* 0 = consumer; 1 = professional */
409 char non_audio_spdif; /* 3G - only */
410 char digital_in_automute; /* Gina24, Layla24, Mona - only */
411 char has_phantom_power;
412 char hasnt_input_nominal_level; /* Gina3G */
413 char phantom_power; /* Gina3G - only */
414 char has_midi;
415 char midi_input_enabled;
416
417#ifdef ECHOCARD_ECHO3G
418 /* External module -dependent pipe and bus indexes */
419 char px_digital_out, px_analog_in, px_digital_in, px_num;
420 char bx_digital_out, bx_analog_in, bx_digital_in, bx_num;
421#endif
422
423 char nominal_level[ECHO_MAXAUDIOPIPES]; /* True == -10dBV
424 * False == +4dBu */
425 s8 input_gain[ECHO_MAXAUDIOINPUTS]; /* Input level -50..+50
426 * unit is 0.5dB */
427 s8 output_gain[ECHO_MAXAUDIOOUTPUTS]; /* Output level -128..+6 dB
428 * (-128=muted) */
429 s8 monitor_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOINPUTS];
430 /* -128..+6 dB */
431 s8 vmixer_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOOUTPUTS];
432 /* -128..+6 dB */
433
434 u16 digital_modes; /* Bitmask of supported modes
435 * (see ECHOCAPS_HAS_DIGITAL_MODE_*) */
436 u16 input_clock_types; /* Suppoted input clock types */
437 u16 output_clock_types; /* Suppoted output clock types -
438 * Layla20 only */
439 u16 device_id, subdevice_id;
440 u16 *dsp_code; /* Current DSP code loaded,
441 * NULL if nothing loaded */
442 const struct firmware *dsp_code_to_load;/* DSP code to load */
443 const struct firmware *asic_code; /* Current ASIC code */
444 u32 comm_page_phys; /* Physical address of the
445 * memory seen by DSP */
446 volatile u32 __iomem *dsp_registers; /* DSP's register base */
447 u32 active_mask; /* Chs. active mask or
448 * punks out */
449
450#ifdef ECHOCARD_HAS_MIDI
451 u16 mtc_state; /* State for MIDI input parsing state machine */
452 u8 midi_buffer[MIDI_IN_BUFFER_SIZE];
453#endif
454};
455
456
457static int init_dsp_comm_page(struct echoaudio *chip);
458static int init_line_levels(struct echoaudio *chip);
459static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe);
460static int load_firmware(struct echoaudio *chip);
461static int wait_handshake(struct echoaudio *chip);
462static int send_vector(struct echoaudio *chip, u32 command);
463static int get_firmware(const struct firmware **fw_entry,
464 const struct firmware *frm, struct echoaudio *chip);
465static void free_firmware(const struct firmware *fw_entry);
466
467#ifdef ECHOCARD_HAS_MIDI
468static int enable_midi_input(struct echoaudio *chip, char enable);
469static int midi_service_irq(struct echoaudio *chip);
470static int __devinit snd_echo_midi_create(struct snd_card *card,
471 struct echoaudio *chip);
472#endif
473
474
475static inline void clear_handshake(struct echoaudio *chip)
476{
477 chip->comm_page->handshake = 0;
478}
479
480static inline u32 get_dsp_register(struct echoaudio *chip, u32 index)
481{
482 return readl(&chip->dsp_registers[index]);
483}
484
485static inline void set_dsp_register(struct echoaudio *chip, u32 index,
486 u32 value)
487{
488 writel(value, &chip->dsp_registers[index]);
489}
490
491
492/* Pipe and bus indexes. PX_* and BX_* are defined as chip->px_* and chip->bx_*
493for 3G cards because they depend on the external box. They are integer
494constants for all other cards.
495Never use those defines directly, use the following functions instead. */
496
497static inline int px_digital_out(const struct echoaudio *chip)
498{
499 return PX_DIGITAL_OUT;
500}
501
502static inline int px_analog_in(const struct echoaudio *chip)
503{
504 return PX_ANALOG_IN;
505}
506
507static inline int px_digital_in(const struct echoaudio *chip)
508{
509 return PX_DIGITAL_IN;
510}
511
512static inline int px_num(const struct echoaudio *chip)
513{
514 return PX_NUM;
515}
516
517static inline int bx_digital_out(const struct echoaudio *chip)
518{
519 return BX_DIGITAL_OUT;
520}
521
522static inline int bx_analog_in(const struct echoaudio *chip)
523{
524 return BX_ANALOG_IN;
525}
526
527static inline int bx_digital_in(const struct echoaudio *chip)
528{
529 return BX_DIGITAL_IN;
530}
531
532static inline int bx_num(const struct echoaudio *chip)
533{
534 return BX_NUM;
535}
536
537static inline int num_pipes_out(const struct echoaudio *chip)
538{
539 return px_analog_in(chip);
540}
541
542static inline int num_pipes_in(const struct echoaudio *chip)
543{
544 return px_num(chip) - px_analog_in(chip);
545}
546
547static inline int num_busses_out(const struct echoaudio *chip)
548{
549 return bx_analog_in(chip);
550}
551
552static inline int num_busses_in(const struct echoaudio *chip)
553{
554 return bx_num(chip) - bx_analog_in(chip);
555}
556
557static inline int num_analog_busses_out(const struct echoaudio *chip)
558{
559 return bx_digital_out(chip);
560}
561
562static inline int num_analog_busses_in(const struct echoaudio *chip)
563{
564 return bx_digital_in(chip) - bx_analog_in(chip);
565}
566
567static inline int num_digital_busses_out(const struct echoaudio *chip)
568{
569 return num_busses_out(chip) - num_analog_busses_out(chip);
570}
571
572static inline int num_digital_busses_in(const struct echoaudio *chip)
573{
574 return num_busses_in(chip) - num_analog_busses_in(chip);
575}
576
577/* The monitor array is a one-dimensional array; compute the offset
578 * into the array */
579static inline int monitor_index(const struct echoaudio *chip, int out, int in)
580{
581 return out * num_busses_in(chip) + in;
582}
583
584
585#ifndef pci_device
586#define pci_device(chip) (&chip->pci->dev)
587#endif
588
589
590#endif /* _ECHOAUDIO_H_ */
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c
new file mode 100644
index 000000000000..9f439ea459f4
--- /dev/null
+++ b/sound/pci/echoaudio/echoaudio_3g.c
@@ -0,0 +1,431 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32
33/* These functions are common for all "3G" cards */
34
35
36static int check_asic_status(struct echoaudio *chip)
37{
38 u32 box_status;
39
40 if (wait_handshake(chip))
41 return -EIO;
42
43 chip->comm_page->ext_box_status =
44 __constant_cpu_to_le32(E3G_ASIC_NOT_LOADED);
45 chip->asic_loaded = FALSE;
46 clear_handshake(chip);
47 send_vector(chip, DSP_VC_TEST_ASIC);
48
49 if (wait_handshake(chip)) {
50 chip->dsp_code = NULL;
51 return -EIO;
52 }
53
54 box_status = le32_to_cpu(chip->comm_page->ext_box_status);
55 DE_INIT(("box_status=%x\n", box_status));
56 if (box_status == E3G_ASIC_NOT_LOADED)
57 return -ENODEV;
58
59 chip->asic_loaded = TRUE;
60 return box_status & E3G_BOX_TYPE_MASK;
61}
62
63
64
65static inline u32 get_frq_reg(struct echoaudio *chip)
66{
67 return le32_to_cpu(chip->comm_page->e3g_frq_register);
68}
69
70
71
72/* Most configuration of 3G cards is accomplished by writing the control
73register. write_control_reg sends the new control register value to the DSP. */
74static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq,
75 char force)
76{
77 if (wait_handshake(chip))
78 return -EIO;
79
80 DE_ACT(("WriteControlReg: Setting 0x%x, 0x%x\n", ctl, frq));
81
82 ctl = cpu_to_le32(ctl);
83 frq = cpu_to_le32(frq);
84
85 if (ctl != chip->comm_page->control_register ||
86 frq != chip->comm_page->e3g_frq_register || force) {
87 chip->comm_page->e3g_frq_register = frq;
88 chip->comm_page->control_register = ctl;
89 clear_handshake(chip);
90 return send_vector(chip, DSP_VC_WRITE_CONTROL_REG);
91 }
92
93 DE_ACT(("WriteControlReg: not written, no change\n"));
94 return 0;
95}
96
97
98
99/* Set the digital mode - currently for Gina24, Layla24, Mona, 3G */
100static int set_digital_mode(struct echoaudio *chip, u8 mode)
101{
102 u8 previous_mode;
103 int err, i, o;
104
105 /* All audio channels must be closed before changing the digital mode */
106 snd_assert(!chip->pipe_alloc_mask, return -EAGAIN);
107
108 snd_assert(chip->digital_modes & (1 << mode), return -EINVAL);
109
110 previous_mode = chip->digital_mode;
111 err = dsp_set_digital_mode(chip, mode);
112
113 /* If we successfully changed the digital mode from or to ADAT,
114 * then make sure all output, input and monitor levels are
115 * updated by the DSP comm object. */
116 if (err >= 0 && previous_mode != mode &&
117 (previous_mode == DIGITAL_MODE_ADAT || mode == DIGITAL_MODE_ADAT)) {
118 spin_lock_irq(&chip->lock);
119 for (o = 0; o < num_busses_out(chip); o++)
120 for (i = 0; i < num_busses_in(chip); i++)
121 set_monitor_gain(chip, o, i,
122 chip->monitor_gain[o][i]);
123
124#ifdef ECHOCARD_HAS_INPUT_GAIN
125 for (i = 0; i < num_busses_in(chip); i++)
126 set_input_gain(chip, i, chip->input_gain[i]);
127 update_input_line_level(chip);
128#endif
129
130 for (o = 0; o < num_busses_out(chip); o++)
131 set_output_gain(chip, o, chip->output_gain[o]);
132 update_output_line_level(chip);
133 spin_unlock_irq(&chip->lock);
134 }
135
136 return err;
137}
138
139
140
141static u32 set_spdif_bits(struct echoaudio *chip, u32 control_reg, u32 rate)
142{
143 control_reg &= E3G_SPDIF_FORMAT_CLEAR_MASK;
144
145 switch (rate) {
146 case 32000 :
147 control_reg |= E3G_SPDIF_SAMPLE_RATE0 | E3G_SPDIF_SAMPLE_RATE1;
148 break;
149 case 44100 :
150 if (chip->professional_spdif)
151 control_reg |= E3G_SPDIF_SAMPLE_RATE0;
152 break;
153 case 48000 :
154 control_reg |= E3G_SPDIF_SAMPLE_RATE1;
155 break;
156 }
157
158 if (chip->professional_spdif)
159 control_reg |= E3G_SPDIF_PRO_MODE;
160
161 if (chip->non_audio_spdif)
162 control_reg |= E3G_SPDIF_NOT_AUDIO;
163
164 control_reg |= E3G_SPDIF_24_BIT | E3G_SPDIF_TWO_CHANNEL |
165 E3G_SPDIF_COPY_PERMIT;
166
167 return control_reg;
168}
169
170
171
172/* Set the S/PDIF output format */
173static int set_professional_spdif(struct echoaudio *chip, char prof)
174{
175 u32 control_reg;
176
177 control_reg = le32_to_cpu(chip->comm_page->control_register);
178 chip->professional_spdif = prof;
179 control_reg = set_spdif_bits(chip, control_reg, chip->sample_rate);
180 return write_control_reg(chip, control_reg, get_frq_reg(chip), 0);
181}
182
183
184
185/* detect_input_clocks() returns a bitmask consisting of all the input clocks
186currently connected to the hardware; this changes as the user connects and
187disconnects clock inputs. You should use this information to determine which
188clocks the user is allowed to select. */
189static u32 detect_input_clocks(const struct echoaudio *chip)
190{
191 u32 clocks_from_dsp, clock_bits;
192
193 /* Map the DSP clock detect bits to the generic driver clock
194 * detect bits */
195 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
196
197 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
198
199 if (clocks_from_dsp & E3G_CLOCK_DETECT_BIT_WORD)
200 clock_bits |= ECHO_CLOCK_BIT_WORD;
201
202 switch(chip->digital_mode) {
203 case DIGITAL_MODE_SPDIF_RCA:
204 case DIGITAL_MODE_SPDIF_OPTICAL:
205 if (clocks_from_dsp & E3G_CLOCK_DETECT_BIT_SPDIF)
206 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
207 break;
208 case DIGITAL_MODE_ADAT:
209 if (clocks_from_dsp & E3G_CLOCK_DETECT_BIT_ADAT)
210 clock_bits |= ECHO_CLOCK_BIT_ADAT;
211 break;
212 }
213
214 return clock_bits;
215}
216
217
218
219static int load_asic(struct echoaudio *chip)
220{
221 int box_type, err;
222
223 if (chip->asic_loaded)
224 return 0;
225
226 /* Give the DSP a few milliseconds to settle down */
227 mdelay(2);
228
229 err = load_asic_generic(chip, DSP_FNC_LOAD_3G_ASIC,
230 &card_fw[FW_3G_ASIC]);
231 if (err < 0)
232 return err;
233
234 chip->asic_code = &card_fw[FW_3G_ASIC];
235
236 /* Now give the new ASIC a little time to set up */
237 mdelay(2);
238 /* See if it worked */
239 box_type = check_asic_status(chip);
240
241 /* Set up the control register if the load succeeded -
242 * 48 kHz, internal clock, S/PDIF RCA mode */
243 if (box_type >= 0) {
244 err = write_control_reg(chip, E3G_48KHZ,
245 E3G_FREQ_REG_DEFAULT, TRUE);
246 if (err < 0)
247 return err;
248 }
249
250 return box_type;
251}
252
253
254
255static int set_sample_rate(struct echoaudio *chip, u32 rate)
256{
257 u32 control_reg, clock, base_rate, frq_reg;
258
259 /* Only set the clock for internal mode. */
260 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
261 DE_ACT(("set_sample_rate: Cannot set sample rate - "
262 "clock not set to CLK_CLOCKININTERNAL\n"));
263 /* Save the rate anyhow */
264 chip->comm_page->sample_rate = cpu_to_le32(rate);
265 chip->sample_rate = rate;
266 set_input_clock(chip, chip->input_clock);
267 return 0;
268 }
269
270 snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT,
271 return -EINVAL);
272
273 clock = 0;
274 control_reg = le32_to_cpu(chip->comm_page->control_register);
275 control_reg &= E3G_CLOCK_CLEAR_MASK;
276
277 switch (rate) {
278 case 96000:
279 clock = E3G_96KHZ;
280 break;
281 case 88200:
282 clock = E3G_88KHZ;
283 break;
284 case 48000:
285 clock = E3G_48KHZ;
286 break;
287 case 44100:
288 clock = E3G_44KHZ;
289 break;
290 case 32000:
291 clock = E3G_32KHZ;
292 break;
293 default:
294 clock = E3G_CONTINUOUS_CLOCK;
295 if (rate > 50000)
296 clock |= E3G_DOUBLE_SPEED_MODE;
297 break;
298 }
299
300 control_reg |= clock;
301 control_reg = set_spdif_bits(chip, control_reg, rate);
302
303 base_rate = rate;
304 if (base_rate > 50000)
305 base_rate /= 2;
306 if (base_rate < 32000)
307 base_rate = 32000;
308
309 frq_reg = E3G_MAGIC_NUMBER / base_rate - 2;
310 if (frq_reg > E3G_FREQ_REG_MAX)
311 frq_reg = E3G_FREQ_REG_MAX;
312
313 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */
314 chip->sample_rate = rate;
315 DE_ACT(("SetSampleRate: %d clock %x\n", rate, control_reg));
316
317 /* Tell the DSP about it - DSP reads both control reg & freq reg */
318 return write_control_reg(chip, control_reg, frq_reg, 0);
319}
320
321
322
323/* Set the sample clock source to internal, S/PDIF, ADAT */
324static int set_input_clock(struct echoaudio *chip, u16 clock)
325{
326 u32 control_reg, clocks_from_dsp;
327
328 DE_ACT(("set_input_clock:\n"));
329
330 /* Mask off the clock select bits */
331 control_reg = le32_to_cpu(chip->comm_page->control_register) &
332 E3G_CLOCK_CLEAR_MASK;
333 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
334
335 switch (clock) {
336 case ECHO_CLOCK_INTERNAL:
337 DE_ACT(("Set Echo3G clock to INTERNAL\n"));
338 chip->input_clock = ECHO_CLOCK_INTERNAL;
339 return set_sample_rate(chip, chip->sample_rate);
340 case ECHO_CLOCK_SPDIF:
341 if (chip->digital_mode == DIGITAL_MODE_ADAT)
342 return -EAGAIN;
343 DE_ACT(("Set Echo3G clock to SPDIF\n"));
344 control_reg |= E3G_SPDIF_CLOCK;
345 if (clocks_from_dsp & E3G_CLOCK_DETECT_BIT_SPDIF96)
346 control_reg |= E3G_DOUBLE_SPEED_MODE;
347 else
348 control_reg &= ~E3G_DOUBLE_SPEED_MODE;
349 break;
350 case ECHO_CLOCK_ADAT:
351 if (chip->digital_mode != DIGITAL_MODE_ADAT)
352 return -EAGAIN;
353 DE_ACT(("Set Echo3G clock to ADAT\n"));
354 control_reg |= E3G_ADAT_CLOCK;
355 control_reg &= ~E3G_DOUBLE_SPEED_MODE;
356 break;
357 case ECHO_CLOCK_WORD:
358 DE_ACT(("Set Echo3G clock to WORD\n"));
359 control_reg |= E3G_WORD_CLOCK;
360 if (clocks_from_dsp & E3G_CLOCK_DETECT_BIT_WORD96)
361 control_reg |= E3G_DOUBLE_SPEED_MODE;
362 else
363 control_reg &= ~E3G_DOUBLE_SPEED_MODE;
364 break;
365 default:
366 DE_ACT(("Input clock 0x%x not supported for Echo3G\n", clock));
367 return -EINVAL;
368 }
369
370 chip->input_clock = clock;
371 return write_control_reg(chip, control_reg, get_frq_reg(chip), 1);
372}
373
374
375
376static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
377{
378 u32 control_reg;
379 int err, incompatible_clock;
380
381 /* Set clock to "internal" if it's not compatible with the new mode */
382 incompatible_clock = FALSE;
383 switch (mode) {
384 case DIGITAL_MODE_SPDIF_OPTICAL:
385 case DIGITAL_MODE_SPDIF_RCA:
386 if (chip->input_clock == ECHO_CLOCK_ADAT)
387 incompatible_clock = TRUE;
388 break;
389 case DIGITAL_MODE_ADAT:
390 if (chip->input_clock == ECHO_CLOCK_SPDIF)
391 incompatible_clock = TRUE;
392 break;
393 default:
394 DE_ACT(("Digital mode not supported: %d\n", mode));
395 return -EINVAL;
396 }
397
398 spin_lock_irq(&chip->lock);
399
400 if (incompatible_clock) {
401 chip->sample_rate = 48000;
402 set_input_clock(chip, ECHO_CLOCK_INTERNAL);
403 }
404
405 /* Clear the current digital mode */
406 control_reg = le32_to_cpu(chip->comm_page->control_register);
407 control_reg &= E3G_DIGITAL_MODE_CLEAR_MASK;
408
409 /* Tweak the control reg */
410 switch (mode) {
411 case DIGITAL_MODE_SPDIF_OPTICAL:
412 control_reg |= E3G_SPDIF_OPTICAL_MODE;
413 break;
414 case DIGITAL_MODE_SPDIF_RCA:
415 /* E3G_SPDIF_OPTICAL_MODE bit cleared */
416 break;
417 case DIGITAL_MODE_ADAT:
418 control_reg |= E3G_ADAT_MODE;
419 control_reg &= ~E3G_DOUBLE_SPEED_MODE; /* @@ useless */
420 break;
421 }
422
423 err = write_control_reg(chip, control_reg, get_frq_reg(chip), 1);
424 spin_unlock_irq(&chip->lock);
425 if (err < 0)
426 return err;
427 chip->digital_mode = mode;
428
429 DE_ACT(("set_digital_mode(%d)\n", chip->digital_mode));
430 return incompatible_clock;
431}
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
new file mode 100644
index 000000000000..42afa837d9b4
--- /dev/null
+++ b/sound/pci/echoaudio/echoaudio_dsp.c
@@ -0,0 +1,1125 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31#if PAGE_SIZE < 4096
32#error PAGE_SIZE is < 4k
33#endif
34
35static int restore_dsp_rettings(struct echoaudio *chip);
36
37
38/* Some vector commands involve the DSP reading or writing data to and from the
39comm page; if you send one of these commands to the DSP, it will complete the
40command and then write a non-zero value to the Handshake field in the
41comm page. This function waits for the handshake to show up. */
42static int wait_handshake(struct echoaudio *chip)
43{
44 int i;
45
46 /* Wait up to 10ms for the handshake from the DSP */
47 for (i = 0; i < HANDSHAKE_TIMEOUT; i++) {
48 /* Look for the handshake value */
49 if (chip->comm_page->handshake) {
50 /*if (i) DE_ACT(("Handshake time: %d\n", i));*/
51 return 0;
52 }
53 udelay(1);
54 }
55
56 snd_printk(KERN_ERR "wait_handshake(): Timeout waiting for DSP\n");
57 return -EBUSY;
58}
59
60
61
62/* Much of the interaction between the DSP and the driver is done via vector
63commands; send_vector writes a vector command to the DSP. Typically, this
64causes the DSP to read or write fields in the comm page.
65PCI posting is not required thanks to the handshake logic. */
66static int send_vector(struct echoaudio *chip, u32 command)
67{
68 int i;
69
70 wmb(); /* Flush all pending writes before sending the command */
71
72 /* Wait up to 100ms for the "vector busy" bit to be off */
73 for (i = 0; i < VECTOR_BUSY_TIMEOUT; i++) {
74 if (!(get_dsp_register(chip, CHI32_VECTOR_REG) &
75 CHI32_VECTOR_BUSY)) {
76 set_dsp_register(chip, CHI32_VECTOR_REG, command);
77 /*if (i) DE_ACT(("send_vector time: %d\n", i));*/
78 return 0;
79 }
80 udelay(1);
81 }
82
83 DE_ACT((KERN_ERR "timeout on send_vector\n"));
84 return -EBUSY;
85}
86
87
88
89/* write_dsp writes a 32-bit value to the DSP; this is used almost
90exclusively for loading the DSP. */
91static int write_dsp(struct echoaudio *chip, u32 data)
92{
93 u32 status, i;
94
95 for (i = 0; i < 10000000; i++) { /* timeout = 10s */
96 status = get_dsp_register(chip, CHI32_STATUS_REG);
97 if ((status & CHI32_STATUS_HOST_WRITE_EMPTY) != 0) {
98 set_dsp_register(chip, CHI32_DATA_REG, data);
99 wmb(); /* write it immediately */
100 return 0;
101 }
102 udelay(1);
103 cond_resched();
104 }
105
106 chip->bad_board = TRUE; /* Set TRUE until DSP re-loaded */
107 DE_ACT((KERN_ERR "write_dsp: Set bad_board to TRUE\n"));
108 return -EIO;
109}
110
111
112
113/* read_dsp reads a 32-bit value from the DSP; this is used almost
114exclusively for loading the DSP and checking the status of the ASIC. */
115static int read_dsp(struct echoaudio *chip, u32 *data)
116{
117 u32 status, i;
118
119 for (i = 0; i < READ_DSP_TIMEOUT; i++) {
120 status = get_dsp_register(chip, CHI32_STATUS_REG);
121 if ((status & CHI32_STATUS_HOST_READ_FULL) != 0) {
122 *data = get_dsp_register(chip, CHI32_DATA_REG);
123 return 0;
124 }
125 udelay(1);
126 cond_resched();
127 }
128
129 chip->bad_board = TRUE; /* Set TRUE until DSP re-loaded */
130 DE_INIT((KERN_ERR "read_dsp: Set bad_board to TRUE\n"));
131 return -EIO;
132}
133
134
135
136/****************************************************************************
137 Firmware loading functions
138 ****************************************************************************/
139
140/* This function is used to read back the serial number from the DSP;
141this is triggered by the SET_COMMPAGE_ADDR command.
142Only some early Echogals products have serial numbers in the ROM;
143the serial number is not used, but you still need to do this as
144part of the DSP load process. */
145static int read_sn(struct echoaudio *chip)
146{
147 int i;
148 u32 sn[6];
149
150 for (i = 0; i < 5; i++) {
151 if (read_dsp(chip, &sn[i])) {
152 snd_printk(KERN_ERR "Failed to read serial number\n");
153 return -EIO;
154 }
155 }
156 DE_INIT(("Read serial number %08x %08x %08x %08x %08x\n",
157 sn[0], sn[1], sn[2], sn[3], sn[4]));
158 return 0;
159}
160
161
162
163#ifndef ECHOCARD_HAS_ASIC
164/* This card has no ASIC, just return ok */
165static inline int check_asic_status(struct echoaudio *chip)
166{
167 chip->asic_loaded = TRUE;
168 return 0;
169}
170
171#endif /* !ECHOCARD_HAS_ASIC */
172
173
174
175#ifdef ECHOCARD_HAS_ASIC
176
177/* Load ASIC code - done after the DSP is loaded */
178static int load_asic_generic(struct echoaudio *chip, u32 cmd,
179 const struct firmware *asic)
180{
181 const struct firmware *fw;
182 int err;
183 u32 i, size;
184 u8 *code;
185
186 if ((err = get_firmware(&fw, asic, chip)) < 0) {
187 snd_printk(KERN_WARNING "Firmware not found !\n");
188 return err;
189 }
190
191 code = (u8 *)fw->data;
192 size = fw->size;
193
194 /* Send the "Here comes the ASIC" command */
195 if (write_dsp(chip, cmd) < 0)
196 goto la_error;
197
198 /* Write length of ASIC file in bytes */
199 if (write_dsp(chip, size) < 0)
200 goto la_error;
201
202 for (i = 0; i < size; i++) {
203 if (write_dsp(chip, code[i]) < 0)
204 goto la_error;
205 }
206
207 DE_INIT(("ASIC loaded\n"));
208 free_firmware(fw);
209 return 0;
210
211la_error:
212 DE_INIT(("failed on write_dsp\n"));
213 free_firmware(fw);
214 return -EIO;
215}
216
217#endif /* ECHOCARD_HAS_ASIC */
218
219
220
221#ifdef DSP_56361
222
223/* Install the resident loader for 56361 DSPs; The resident loader is on
224the EPROM on the board for 56301 DSP. The resident loader is a tiny little
225program that is used to load the real DSP code. */
226static int install_resident_loader(struct echoaudio *chip)
227{
228 u32 address;
229 int index, words, i;
230 u16 *code;
231 u32 status;
232 const struct firmware *fw;
233
234 /* 56361 cards only! This check is required by the old 56301-based
235 Mona and Gina24 */
236 if (chip->device_id != DEVICE_ID_56361)
237 return 0;
238
239 /* Look to see if the resident loader is present. If the resident
240 loader is already installed, host flag 5 will be on. */
241 status = get_dsp_register(chip, CHI32_STATUS_REG);
242 if (status & CHI32_STATUS_REG_HF5) {
243 DE_INIT(("Resident loader already installed; status is 0x%x\n",
244 status));
245 return 0;
246 }
247
248 if ((i = get_firmware(&fw, &card_fw[FW_361_LOADER], chip)) < 0) {
249 snd_printk(KERN_WARNING "Firmware not found !\n");
250 return i;
251 }
252
253 /* The DSP code is an array of 16 bit words. The array is divided up
254 into sections. The first word of each section is the size in words,
255 followed by the section type.
256 Since DSP addresses and data are 24 bits wide, they each take up two
257 16 bit words in the array.
258 This is a lot like the other loader loop, but it's not a loop, you
259 don't write the memory type, and you don't write a zero at the end. */
260
261 /* Set DSP format bits for 24 bit mode */
262 set_dsp_register(chip, CHI32_CONTROL_REG,
263 get_dsp_register(chip, CHI32_CONTROL_REG) | 0x900);
264
265 code = (u16 *)fw->data;
266
267 /* Skip the header section; the first word in the array is the size
268 of the first section, so the first real section of code is pointed
269 to by Code[0]. */
270 index = code[0];
271
272 /* Skip the section size, LRS block type, and DSP memory type */
273 index += 3;
274
275 /* Get the number of DSP words to write */
276 words = code[index++];
277
278 /* Get the DSP address for this block; 24 bits, so build from two words */
279 address = ((u32)code[index] << 16) + code[index + 1];
280 index += 2;
281
282 /* Write the count to the DSP */
283 if (write_dsp(chip, words)) {
284 DE_INIT(("install_resident_loader: Failed to write word count!\n"));
285 goto irl_error;
286 }
287 /* Write the DSP address */
288 if (write_dsp(chip, address)) {
289 DE_INIT(("install_resident_loader: Failed to write DSP address!\n"));
290 goto irl_error;
291 }
292 /* Write out this block of code to the DSP */
293 for (i = 0; i < words; i++) {
294 u32 data;
295
296 data = ((u32)code[index] << 16) + code[index + 1];
297 if (write_dsp(chip, data)) {
298 DE_INIT(("install_resident_loader: Failed to write DSP code\n"));
299 goto irl_error;
300 }
301 index += 2;
302 }
303
304 /* Wait for flag 5 to come up */
305 for (i = 0; i < 200; i++) { /* Timeout is 50us * 200 = 10ms */
306 udelay(50);
307 status = get_dsp_register(chip, CHI32_STATUS_REG);
308 if (status & CHI32_STATUS_REG_HF5)
309 break;
310 }
311
312 if (i == 200) {
313 DE_INIT(("Resident loader failed to set HF5\n"));
314 goto irl_error;
315 }
316
317 DE_INIT(("Resident loader successfully installed\n"));
318 free_firmware(fw);
319 return 0;
320
321irl_error:
322 free_firmware(fw);
323 return -EIO;
324}
325
326#endif /* DSP_56361 */
327
328
329static int load_dsp(struct echoaudio *chip, u16 *code)
330{
331 u32 address, data;
332 int index, words, i;
333
334 if (chip->dsp_code == code) {
335 DE_INIT(("DSP is already loaded!\n"));
336 return 0;
337 }
338 chip->bad_board = TRUE; /* Set TRUE until DSP loaded */
339 chip->dsp_code = NULL; /* Current DSP code not loaded */
340 chip->asic_loaded = FALSE; /* Loading the DSP code will reset the ASIC */
341
342 DE_INIT(("load_dsp: Set bad_board to TRUE\n"));
343
344 /* If this board requires a resident loader, install it. */
345#ifdef DSP_56361
346 if ((i = install_resident_loader(chip)) < 0)
347 return i;
348#endif
349
350 /* Send software reset command */
351 if (send_vector(chip, DSP_VC_RESET) < 0) {
352 DE_INIT(("LoadDsp: send_vector DSP_VC_RESET failed, Critical Failure\n"));
353 return -EIO;
354 }
355 /* Delay 10us */
356 udelay(10);
357
358 /* Wait 10ms for HF3 to indicate that software reset is complete */
359 for (i = 0; i < 1000; i++) { /* Timeout is 10us * 1000 = 10ms */
360 if (get_dsp_register(chip, CHI32_STATUS_REG) &
361 CHI32_STATUS_REG_HF3)
362 break;
363 udelay(10);
364 }
365
366 if (i == 1000) {
367 DE_INIT(("load_dsp: Timeout waiting for CHI32_STATUS_REG_HF3\n"));
368 return -EIO;
369 }
370
371 /* Set DSP format bits for 24 bit mode now that soft reset is done */
372 set_dsp_register(chip, CHI32_CONTROL_REG,
373 get_dsp_register(chip, CHI32_CONTROL_REG) | 0x900);
374
375 /* Main loader loop */
376
377 index = code[0];
378 for (;;) {
379 int block_type, mem_type;
380
381 /* Total Block Size */
382 index++;
383
384 /* Block Type */
385 block_type = code[index];
386 if (block_type == 4) /* We're finished */
387 break;
388
389 index++;
390
391 /* Memory Type P=0,X=1,Y=2 */
392 mem_type = code[index++];
393
394 /* Block Code Size */
395 words = code[index++];
396 if (words == 0) /* We're finished */
397 break;
398
399 /* Start Address */
400 address = ((u32)code[index] << 16) + code[index + 1];
401 index += 2;
402
403 if (write_dsp(chip, words) < 0) {
404 DE_INIT(("load_dsp: failed to write number of DSP words\n"));
405 return -EIO;
406 }
407 if (write_dsp(chip, address) < 0) {
408 DE_INIT(("load_dsp: failed to write DSP address\n"));
409 return -EIO;
410 }
411 if (write_dsp(chip, mem_type) < 0) {
412 DE_INIT(("load_dsp: failed to write DSP memory type\n"));
413 return -EIO;
414 }
415 /* Code */
416 for (i = 0; i < words; i++, index+=2) {
417 data = ((u32)code[index] << 16) + code[index + 1];
418 if (write_dsp(chip, data) < 0) {
419 DE_INIT(("load_dsp: failed to write DSP data\n"));
420 return -EIO;
421 }
422 }
423 }
424
425 if (write_dsp(chip, 0) < 0) { /* We're done!!! */
426 DE_INIT(("load_dsp: Failed to write final zero\n"));
427 return -EIO;
428 }
429 udelay(10);
430
431 for (i = 0; i < 5000; i++) { /* Timeout is 100us * 5000 = 500ms */
432 /* Wait for flag 4 - indicates that the DSP loaded OK */
433 if (get_dsp_register(chip, CHI32_STATUS_REG) &
434 CHI32_STATUS_REG_HF4) {
435 set_dsp_register(chip, CHI32_CONTROL_REG,
436 get_dsp_register(chip, CHI32_CONTROL_REG) & ~0x1b00);
437
438 if (write_dsp(chip, DSP_FNC_SET_COMMPAGE_ADDR) < 0) {
439 DE_INIT(("load_dsp: Failed to write DSP_FNC_SET_COMMPAGE_ADDR\n"));
440 return -EIO;
441 }
442
443 if (write_dsp(chip, chip->comm_page_phys) < 0) {
444 DE_INIT(("load_dsp: Failed to write comm page address\n"));
445 return -EIO;
446 }
447
448 /* Get the serial number via slave mode.
449 This is triggered by the SET_COMMPAGE_ADDR command.
450 We don't actually use the serial number but we have to
451 get it as part of the DSP init voodoo. */
452 if (read_sn(chip) < 0) {
453 DE_INIT(("load_dsp: Failed to read serial number\n"));
454 return -EIO;
455 }
456
457 chip->dsp_code = code; /* Show which DSP code loaded */
458 chip->bad_board = FALSE; /* DSP OK */
459 DE_INIT(("load_dsp: OK!\n"));
460 return 0;
461 }
462 udelay(100);
463 }
464
465 DE_INIT(("load_dsp: DSP load timed out waiting for HF4\n"));
466 return -EIO;
467}
468
469
470
471/* load_firmware takes care of loading the DSP and any ASIC code. */
472static int load_firmware(struct echoaudio *chip)
473{
474 const struct firmware *fw;
475 int box_type, err;
476
477 snd_assert(chip->dsp_code_to_load && chip->comm_page, return -EPERM);
478
479 /* See if the ASIC is present and working - only if the DSP is already loaded */
480 if (chip->dsp_code) {
481 if ((box_type = check_asic_status(chip)) >= 0)
482 return box_type;
483 /* ASIC check failed; force the DSP to reload */
484 chip->dsp_code = NULL;
485 }
486
487 if ((err = get_firmware(&fw, chip->dsp_code_to_load, chip)) < 0)
488 return err;
489 err = load_dsp(chip, (u16 *)fw->data);
490 free_firmware(fw);
491 if (err < 0)
492 return err;
493
494 if ((box_type = load_asic(chip)) < 0)
495 return box_type; /* error */
496
497 if ((err = restore_dsp_rettings(chip)) < 0)
498 return err;
499
500 return box_type;
501}
502
503
504
505/****************************************************************************
506 Mixer functions
507 ****************************************************************************/
508
509#if defined(ECHOCARD_HAS_INPUT_NOMINAL_LEVEL) || \
510 defined(ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL)
511
512/* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */
513static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer)
514{
515 snd_assert(index < num_busses_out(chip) + num_busses_in(chip),
516 return -EINVAL);
517
518 /* Wait for the handshake (OK even if ASIC is not loaded) */
519 if (wait_handshake(chip))
520 return -EIO;
521
522 chip->nominal_level[index] = consumer;
523
524 if (consumer)
525 chip->comm_page->nominal_level_mask |= cpu_to_le32(1 << index);
526 else
527 chip->comm_page->nominal_level_mask &= ~cpu_to_le32(1 << index);
528
529 return 0;
530}
531
532#endif /* ECHOCARD_HAS_*_NOMINAL_LEVEL */
533
534
535
536/* Set the gain for a single physical output channel (dB). */
537static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain)
538{
539 snd_assert(channel < num_busses_out(chip), return -EINVAL);
540
541 if (wait_handshake(chip))
542 return -EIO;
543
544 /* Save the new value */
545 chip->output_gain[channel] = gain;
546 chip->comm_page->line_out_level[channel] = gain;
547 return 0;
548}
549
550
551
552#ifdef ECHOCARD_HAS_MONITOR
553/* Set the monitor level from an input bus to an output bus. */
554static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input,
555 s8 gain)
556{
557 snd_assert(output < num_busses_out(chip) &&
558 input < num_busses_in(chip), return -EINVAL);
559
560 if (wait_handshake(chip))
561 return -EIO;
562
563 chip->monitor_gain[output][input] = gain;
564 chip->comm_page->monitors[monitor_index(chip, output, input)] = gain;
565 return 0;
566}
567#endif /* ECHOCARD_HAS_MONITOR */
568
569
570/* Tell the DSP to read and update output, nominal & monitor levels in comm page. */
571static int update_output_line_level(struct echoaudio *chip)
572{
573 if (wait_handshake(chip))
574 return -EIO;
575 clear_handshake(chip);
576 return send_vector(chip, DSP_VC_UPDATE_OUTVOL);
577}
578
579
580
581/* Tell the DSP to read and update input levels in comm page */
582static int update_input_line_level(struct echoaudio *chip)
583{
584 if (wait_handshake(chip))
585 return -EIO;
586 clear_handshake(chip);
587 return send_vector(chip, DSP_VC_UPDATE_INGAIN);
588}
589
590
591
592/* set_meters_on turns the meters on or off. If meters are turned on, the DSP
593will write the meter and clock detect values to the comm page at about 30Hz */
594static void set_meters_on(struct echoaudio *chip, char on)
595{
596 if (on && !chip->meters_enabled) {
597 send_vector(chip, DSP_VC_METERS_ON);
598 chip->meters_enabled = 1;
599 } else if (!on && chip->meters_enabled) {
600 send_vector(chip, DSP_VC_METERS_OFF);
601 chip->meters_enabled = 0;
602 memset((s8 *)chip->comm_page->vu_meter, ECHOGAIN_MUTED,
603 DSP_MAXPIPES);
604 memset((s8 *)chip->comm_page->peak_meter, ECHOGAIN_MUTED,
605 DSP_MAXPIPES);
606 }
607}
608
609
610
611/* Fill out an the given array using the current values in the comm page.
612Meters are written in the comm page by the DSP in this order:
613 Output busses
614 Input busses
615 Output pipes (vmixer cards only)
616
617This function assumes there are no more than 16 in/out busses or pipes
618Meters is an array [3][16][2] of long. */
619static void get_audio_meters(struct echoaudio *chip, long *meters)
620{
621 int i, m, n;
622
623 m = 0;
624 n = 0;
625 for (i = 0; i < num_busses_out(chip); i++, m++) {
626 meters[n++] = chip->comm_page->vu_meter[m];
627 meters[n++] = chip->comm_page->peak_meter[m];
628 }
629 for (; n < 32; n++)
630 meters[n] = 0;
631
632#ifdef ECHOCARD_ECHO3G
633 m = E3G_MAX_OUTPUTS; /* Skip unused meters */
634#endif
635
636 for (i = 0; i < num_busses_in(chip); i++, m++) {
637 meters[n++] = chip->comm_page->vu_meter[m];
638 meters[n++] = chip->comm_page->peak_meter[m];
639 }
640 for (; n < 64; n++)
641 meters[n] = 0;
642
643#ifdef ECHOCARD_HAS_VMIXER
644 for (i = 0; i < num_pipes_out(chip); i++, m++) {
645 meters[n++] = chip->comm_page->vu_meter[m];
646 meters[n++] = chip->comm_page->peak_meter[m];
647 }
648#endif
649 for (; n < 96; n++)
650 meters[n] = 0;
651}
652
653
654
655static int restore_dsp_rettings(struct echoaudio *chip)
656{
657 int err;
658 DE_INIT(("restore_dsp_settings\n"));
659
660 if ((err = check_asic_status(chip)) < 0)
661 return err;
662
663 /* @ Gina20/Darla20 only. Should be harmless for other cards. */
664 chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF;
665 chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF;
666 chip->comm_page->handshake = 0xffffffff;
667
668 if ((err = set_sample_rate(chip, chip->sample_rate)) < 0)
669 return err;
670
671 if (chip->meters_enabled)
672 if (send_vector(chip, DSP_VC_METERS_ON) < 0)
673 return -EIO;
674
675#ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
676 if (set_input_clock(chip, chip->input_clock) < 0)
677 return -EIO;
678#endif
679
680#ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH
681 if (set_output_clock(chip, chip->output_clock) < 0)
682 return -EIO;
683#endif
684
685 if (update_output_line_level(chip) < 0)
686 return -EIO;
687
688 if (update_input_line_level(chip) < 0)
689 return -EIO;
690
691#ifdef ECHOCARD_HAS_VMIXER
692 if (update_vmixer_level(chip) < 0)
693 return -EIO;
694#endif
695
696 if (wait_handshake(chip) < 0)
697 return -EIO;
698 clear_handshake(chip);
699
700 DE_INIT(("restore_dsp_rettings done\n"));
701 return send_vector(chip, DSP_VC_UPDATE_FLAGS);
702}
703
704
705
706/****************************************************************************
707 Transport functions
708 ****************************************************************************/
709
710/* set_audio_format() sets the format of the audio data in host memory for
711this pipe. Note that _MS_ (mono-to-stereo) playback modes are not used by ALSA
712but they are here because they are just mono while capturing */
713static void set_audio_format(struct echoaudio *chip, u16 pipe_index,
714 const struct audioformat *format)
715{
716 u16 dsp_format;
717
718 dsp_format = DSP_AUDIOFORM_SS_16LE;
719
720 /* Look for super-interleave (no big-endian and 8 bits) */
721 if (format->interleave > 2) {
722 switch (format->bits_per_sample) {
723 case 16:
724 dsp_format = DSP_AUDIOFORM_SUPER_INTERLEAVE_16LE;
725 break;
726 case 24:
727 dsp_format = DSP_AUDIOFORM_SUPER_INTERLEAVE_24LE;
728 break;
729 case 32:
730 dsp_format = DSP_AUDIOFORM_SUPER_INTERLEAVE_32LE;
731 break;
732 }
733 dsp_format |= format->interleave;
734 } else if (format->data_are_bigendian) {
735 /* For big-endian data, only 32 bit samples are supported */
736 switch (format->interleave) {
737 case 1:
738 dsp_format = DSP_AUDIOFORM_MM_32BE;
739 break;
740#ifdef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
741 case 2:
742 dsp_format = DSP_AUDIOFORM_SS_32BE;
743 break;
744#endif
745 }
746 } else if (format->interleave == 1 &&
747 format->bits_per_sample == 32 && !format->mono_to_stereo) {
748 /* 32 bit little-endian mono->mono case */
749 dsp_format = DSP_AUDIOFORM_MM_32LE;
750 } else {
751 /* Handle the other little-endian formats */
752 switch (format->bits_per_sample) {
753 case 8:
754 if (format->interleave == 2)
755 dsp_format = DSP_AUDIOFORM_SS_8;
756 else
757 dsp_format = DSP_AUDIOFORM_MS_8;
758 break;
759 default:
760 case 16:
761 if (format->interleave == 2)
762 dsp_format = DSP_AUDIOFORM_SS_16LE;
763 else
764 dsp_format = DSP_AUDIOFORM_MS_16LE;
765 break;
766 case 24:
767 if (format->interleave == 2)
768 dsp_format = DSP_AUDIOFORM_SS_24LE;
769 else
770 dsp_format = DSP_AUDIOFORM_MS_24LE;
771 break;
772 case 32:
773 if (format->interleave == 2)
774 dsp_format = DSP_AUDIOFORM_SS_32LE;
775 else
776 dsp_format = DSP_AUDIOFORM_MS_32LE;
777 break;
778 }
779 }
780 DE_ACT(("set_audio_format[%d] = %x\n", pipe_index, dsp_format));
781 chip->comm_page->audio_format[pipe_index] = cpu_to_le16(dsp_format);
782}
783
784
785
786/* start_transport starts transport for a set of pipes.
787The bits 1 in channel_mask specify what pipes to start. Only the bit of the
788first channel must be set, regardless its interleave.
789Same thing for pause_ and stop_ -trasport below. */
790static int start_transport(struct echoaudio *chip, u32 channel_mask,
791 u32 cyclic_mask)
792{
793 DE_ACT(("start_transport %x\n", channel_mask));
794
795 if (wait_handshake(chip))
796 return -EIO;
797
798 chip->comm_page->cmd_start |= cpu_to_le32(channel_mask);
799
800 if (chip->comm_page->cmd_start) {
801 clear_handshake(chip);
802 send_vector(chip, DSP_VC_START_TRANSFER);
803 if (wait_handshake(chip))
804 return -EIO;
805 /* Keep track of which pipes are transporting */
806 chip->active_mask |= channel_mask;
807 chip->comm_page->cmd_start = 0;
808 return 0;
809 }
810
811 DE_ACT(("start_transport: No pipes to start!\n"));
812 return -EINVAL;
813}
814
815
816
817static int pause_transport(struct echoaudio *chip, u32 channel_mask)
818{
819 DE_ACT(("pause_transport %x\n", channel_mask));
820
821 if (wait_handshake(chip))
822 return -EIO;
823
824 chip->comm_page->cmd_stop |= cpu_to_le32(channel_mask);
825 chip->comm_page->cmd_reset = 0;
826 if (chip->comm_page->cmd_stop) {
827 clear_handshake(chip);
828 send_vector(chip, DSP_VC_STOP_TRANSFER);
829 if (wait_handshake(chip))
830 return -EIO;
831 /* Keep track of which pipes are transporting */
832 chip->active_mask &= ~channel_mask;
833 chip->comm_page->cmd_stop = 0;
834 chip->comm_page->cmd_reset = 0;
835 return 0;
836 }
837
838 DE_ACT(("pause_transport: No pipes to stop!\n"));
839 return 0;
840}
841
842
843
844static int stop_transport(struct echoaudio *chip, u32 channel_mask)
845{
846 DE_ACT(("stop_transport %x\n", channel_mask));
847
848 if (wait_handshake(chip))
849 return -EIO;
850
851 chip->comm_page->cmd_stop |= cpu_to_le32(channel_mask);
852 chip->comm_page->cmd_reset |= cpu_to_le32(channel_mask);
853 if (chip->comm_page->cmd_reset) {
854 clear_handshake(chip);
855 send_vector(chip, DSP_VC_STOP_TRANSFER);
856 if (wait_handshake(chip))
857 return -EIO;
858 /* Keep track of which pipes are transporting */
859 chip->active_mask &= ~channel_mask;
860 chip->comm_page->cmd_stop = 0;
861 chip->comm_page->cmd_reset = 0;
862 return 0;
863 }
864
865 DE_ACT(("stop_transport: No pipes to stop!\n"));
866 return 0;
867}
868
869
870
871static inline int is_pipe_allocated(struct echoaudio *chip, u16 pipe_index)
872{
873 return (chip->pipe_alloc_mask & (1 << pipe_index));
874}
875
876
877
878/* Stops everything and turns off the DSP. All pipes should be already
879stopped and unallocated. */
880static int rest_in_peace(struct echoaudio *chip)
881{
882 DE_ACT(("rest_in_peace() open=%x\n", chip->pipe_alloc_mask));
883
884 /* Stops all active pipes (just to be sure) */
885 stop_transport(chip, chip->active_mask);
886
887 set_meters_on(chip, FALSE);
888
889#ifdef ECHOCARD_HAS_MIDI
890 enable_midi_input(chip, FALSE);
891#endif
892
893 /* Go to sleep */
894 if (chip->dsp_code) {
895 /* Make load_firmware do a complete reload */
896 chip->dsp_code = NULL;
897 /* Put the DSP to sleep */
898 return send_vector(chip, DSP_VC_GO_COMATOSE);
899 }
900 return 0;
901}
902
903
904
905/* Fills the comm page with default values */
906static int init_dsp_comm_page(struct echoaudio *chip)
907{
908 /* Check if the compiler added extra padding inside the structure */
909 if (offsetof(struct comm_page, midi_output) != 0xbe0) {
910 DE_INIT(("init_dsp_comm_page() - Invalid struct comm_page structure\n"));
911 return -EPERM;
912 }
913
914 /* Init all the basic stuff */
915 chip->card_name = ECHOCARD_NAME;
916 chip->bad_board = TRUE; /* Set TRUE until DSP loaded */
917 chip->dsp_code = NULL; /* Current DSP code not loaded */
918 chip->digital_mode = DIGITAL_MODE_NONE;
919 chip->input_clock = ECHO_CLOCK_INTERNAL;
920 chip->output_clock = ECHO_CLOCK_WORD;
921 chip->asic_loaded = FALSE;
922 memset(chip->comm_page, 0, sizeof(struct comm_page));
923
924 /* Init the comm page */
925 chip->comm_page->comm_size =
926 __constant_cpu_to_le32(sizeof(struct comm_page));
927 chip->comm_page->handshake = 0xffffffff;
928 chip->comm_page->midi_out_free_count =
929 __constant_cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE);
930 chip->comm_page->sample_rate = __constant_cpu_to_le32(44100);
931 chip->sample_rate = 44100;
932
933 /* Set line levels so we don't blast any inputs on startup */
934 memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE);
935 memset(chip->comm_page->vmixer, ECHOGAIN_MUTED, VMIXER_ARRAY_SIZE);
936
937 return 0;
938}
939
940
941
942/* This function initializes the several volume controls for busses and pipes.
943This MUST be called after the DSP is up and running ! */
944static int init_line_levels(struct echoaudio *chip)
945{
946 int st, i, o;
947
948 DE_INIT(("init_line_levels\n"));
949
950 /* Mute output busses */
951 for (i = 0; i < num_busses_out(chip); i++)
952 if ((st = set_output_gain(chip, i, ECHOGAIN_MUTED)))
953 return st;
954 if ((st = update_output_line_level(chip)))
955 return st;
956
957#ifdef ECHOCARD_HAS_VMIXER
958 /* Mute the Vmixer */
959 for (i = 0; i < num_pipes_out(chip); i++)
960 for (o = 0; o < num_busses_out(chip); o++)
961 if ((st = set_vmixer_gain(chip, o, i, ECHOGAIN_MUTED)))
962 return st;
963 if ((st = update_vmixer_level(chip)))
964 return st;
965#endif /* ECHOCARD_HAS_VMIXER */
966
967#ifdef ECHOCARD_HAS_MONITOR
968 /* Mute the monitor mixer */
969 for (o = 0; o < num_busses_out(chip); o++)
970 for (i = 0; i < num_busses_in(chip); i++)
971 if ((st = set_monitor_gain(chip, o, i, ECHOGAIN_MUTED)))
972 return st;
973 if ((st = update_output_line_level(chip)))
974 return st;
975#endif /* ECHOCARD_HAS_MONITOR */
976
977#ifdef ECHOCARD_HAS_INPUT_GAIN
978 for (i = 0; i < num_busses_in(chip); i++)
979 if ((st = set_input_gain(chip, i, ECHOGAIN_MUTED)))
980 return st;
981 if ((st = update_input_line_level(chip)))
982 return st;
983#endif /* ECHOCARD_HAS_INPUT_GAIN */
984
985 return 0;
986}
987
988
989
990/* This is low level part of the interrupt handler.
991It returns -1 if the IRQ is not ours, or N>=0 if it is, where N is the number
992of midi data in the input queue. */
993static int service_irq(struct echoaudio *chip)
994{
995 int st;
996
997 /* Read the DSP status register and see if this DSP generated this interrupt */
998 if (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_IRQ) {
999 st = 0;
1000#ifdef ECHOCARD_HAS_MIDI
1001 /* Get and parse midi data if present */
1002 if (chip->comm_page->midi_input[0]) /* The count is at index 0 */
1003 st = midi_service_irq(chip); /* Returns how many midi bytes we received */
1004#endif
1005 /* Clear the hardware interrupt */
1006 chip->comm_page->midi_input[0] = 0;
1007 send_vector(chip, DSP_VC_ACK_INT);
1008 return st;
1009 }
1010 return -1;
1011}
1012
1013
1014
1015
1016/******************************************************************************
1017 Functions for opening and closing pipes
1018 ******************************************************************************/
1019
1020/* allocate_pipes is used to reserve audio pipes for your exclusive use.
1021The call will fail if some pipes are already allocated. */
1022static int allocate_pipes(struct echoaudio *chip, struct audiopipe *pipe,
1023 int pipe_index, int interleave)
1024{
1025 int i;
1026 u32 channel_mask;
1027 char is_cyclic;
1028
1029 DE_ACT(("allocate_pipes: ch=%d int=%d\n", pipe_index, interleave));
1030
1031 if (chip->bad_board)
1032 return -EIO;
1033
1034 is_cyclic = 1; /* This driver uses cyclic buffers only */
1035
1036 for (channel_mask = i = 0; i < interleave; i++)
1037 channel_mask |= 1 << (pipe_index + i);
1038 if (chip->pipe_alloc_mask & channel_mask) {
1039 DE_ACT(("allocate_pipes: channel already open\n"));
1040 return -EAGAIN;
1041 }
1042
1043 chip->comm_page->position[pipe_index] = 0;
1044 chip->pipe_alloc_mask |= channel_mask;
1045 if (is_cyclic)
1046 chip->pipe_cyclic_mask |= channel_mask;
1047 pipe->index = pipe_index;
1048 pipe->interleave = interleave;
1049 pipe->state = PIPE_STATE_STOPPED;
1050
1051 /* The counter register is where the DSP writes the 32 bit DMA
1052 position for a pipe. The DSP is constantly updating this value as
1053 it moves data. The DMA counter is in units of bytes, not samples. */
1054 pipe->dma_counter = &chip->comm_page->position[pipe_index];
1055 *pipe->dma_counter = 0;
1056 DE_ACT(("allocate_pipes: ok\n"));
1057 return pipe_index;
1058}
1059
1060
1061
1062static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe)
1063{
1064 u32 channel_mask;
1065 int i;
1066
1067 DE_ACT(("free_pipes: Pipe %d\n", pipe->index));
1068 snd_assert(is_pipe_allocated(chip, pipe->index), return -EINVAL);
1069 snd_assert(pipe->state == PIPE_STATE_STOPPED, return -EINVAL);
1070
1071 for (channel_mask = i = 0; i < pipe->interleave; i++)
1072 channel_mask |= 1 << (pipe->index + i);
1073
1074 chip->pipe_alloc_mask &= ~channel_mask;
1075 chip->pipe_cyclic_mask &= ~channel_mask;
1076 return 0;
1077}
1078
1079
1080
1081/******************************************************************************
1082 Functions for managing the scatter-gather list
1083******************************************************************************/
1084
1085static int sglist_init(struct echoaudio *chip, struct audiopipe *pipe)
1086{
1087 pipe->sglist_head = 0;
1088 memset(pipe->sgpage.area, 0, PAGE_SIZE);
1089 chip->comm_page->sglist_addr[pipe->index].addr =
1090 cpu_to_le32(pipe->sgpage.addr);
1091 return 0;
1092}
1093
1094
1095
1096static int sglist_add_mapping(struct echoaudio *chip, struct audiopipe *pipe,
1097 dma_addr_t address, size_t length)
1098{
1099 int head = pipe->sglist_head;
1100 struct sg_entry *list = (struct sg_entry *)pipe->sgpage.area;
1101
1102 if (head < MAX_SGLIST_ENTRIES - 1) {
1103 list[head].addr = cpu_to_le32(address);
1104 list[head].size = cpu_to_le32(length);
1105 pipe->sglist_head++;
1106 } else {
1107 DE_ACT(("SGlist: too many fragments\n"));
1108 return -ENOMEM;
1109 }
1110 return 0;
1111}
1112
1113
1114
1115static inline int sglist_add_irq(struct echoaudio *chip, struct audiopipe *pipe)
1116{
1117 return sglist_add_mapping(chip, pipe, 0, 0);
1118}
1119
1120
1121
1122static inline int sglist_wrap(struct echoaudio *chip, struct audiopipe *pipe)
1123{
1124 return sglist_add_mapping(chip, pipe, pipe->sgpage.addr, 0);
1125}
diff --git a/sound/pci/echoaudio/echoaudio_dsp.h b/sound/pci/echoaudio/echoaudio_dsp.h
new file mode 100644
index 000000000000..e55ee00991ac
--- /dev/null
+++ b/sound/pci/echoaudio/echoaudio_dsp.h
@@ -0,0 +1,694 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31#ifndef _ECHO_DSP_
32#define _ECHO_DSP_
33
34
35/**** Echogals: Darla20, Gina20, Layla20, and Darla24 ****/
36#if defined(ECHOGALS_FAMILY)
37
38#define NUM_ASIC_TESTS 5
39#define READ_DSP_TIMEOUT 1000000L /* one second */
40
41/**** Echo24: Gina24, Layla24, Mona, Mia, Mia-midi ****/
42#elif defined(ECHO24_FAMILY)
43
44#define DSP_56361 /* Some Echo24 cards use the 56361 DSP */
45#define READ_DSP_TIMEOUT 100000L /* .1 second */
46
47/**** 3G: Gina3G, Layla3G ****/
48#elif defined(ECHO3G_FAMILY)
49
50#define DSP_56361
51#define READ_DSP_TIMEOUT 100000L /* .1 second */
52#define MIN_MTC_1X_RATE 32000
53
54/**** Indigo: Indigo, Indigo IO, Indigo DJ ****/
55#elif defined(INDIGO_FAMILY)
56
57#define DSP_56361
58#define READ_DSP_TIMEOUT 100000L /* .1 second */
59
60#else
61
62#error No family is defined
63
64#endif
65
66
67
68/*
69 *
70 * Max inputs and outputs
71 *
72 */
73
74#define DSP_MAXAUDIOINPUTS 16 /* Max audio input channels */
75#define DSP_MAXAUDIOOUTPUTS 16 /* Max audio output channels */
76#define DSP_MAXPIPES 32 /* Max total pipes (input + output) */
77
78
79/*
80 *
81 * These are the offsets for the memory-mapped DSP registers; the DSP base
82 * address is treated as the start of a u32 array.
83 */
84
85#define CHI32_CONTROL_REG 4
86#define CHI32_STATUS_REG 5
87#define CHI32_VECTOR_REG 6
88#define CHI32_DATA_REG 7
89
90
91/*
92 *
93 * Interesting bits within the DSP registers
94 *
95 */
96
97#define CHI32_VECTOR_BUSY 0x00000001
98#define CHI32_STATUS_REG_HF3 0x00000008
99#define CHI32_STATUS_REG_HF4 0x00000010
100#define CHI32_STATUS_REG_HF5 0x00000020
101#define CHI32_STATUS_HOST_READ_FULL 0x00000004
102#define CHI32_STATUS_HOST_WRITE_EMPTY 0x00000002
103#define CHI32_STATUS_IRQ 0x00000040
104
105
106/*
107 *
108 * DSP commands sent via slave mode; these are sent to the DSP by write_dsp()
109 *
110 */
111
112#define DSP_FNC_SET_COMMPAGE_ADDR 0x02
113#define DSP_FNC_LOAD_LAYLA_ASIC 0xa0
114#define DSP_FNC_LOAD_GINA24_ASIC 0xa0
115#define DSP_FNC_LOAD_MONA_PCI_CARD_ASIC 0xa0
116#define DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC 0xa0
117#define DSP_FNC_LOAD_MONA_EXTERNAL_ASIC 0xa1
118#define DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC 0xa1
119#define DSP_FNC_LOAD_3G_ASIC 0xa0
120
121
122/*
123 *
124 * Defines to handle the MIDI input state engine; these are used to properly
125 * extract MIDI time code bytes and their timestamps from the MIDI input stream.
126 *
127 */
128
129#define MIDI_IN_STATE_NORMAL 0
130#define MIDI_IN_STATE_TS_HIGH 1
131#define MIDI_IN_STATE_TS_LOW 2
132#define MIDI_IN_STATE_F1_DATA 3
133#define MIDI_IN_SKIP_DATA (-1)
134
135
136/*----------------------------------------------------------------------------
137
138Setting the sample rates on Layla24 is somewhat schizophrenic.
139
140For standard rates, it works exactly like Mona and Gina24. That is, for
1418, 11.025, 16, 22.05, 32, 44.1, 48, 88.2, and 96 kHz, you just set the
142appropriate bits in the control register and write the control register.
143
144In order to support MIDI time code sync (and possibly SMPTE LTC sync in
145the future), Layla24 also has "continuous sample rate mode". In this mode,
146Layla24 can generate any sample rate between 25 and 50 kHz inclusive, or
14750 to 100 kHz inclusive for double speed mode.
148
149To use continuous mode:
150
151-Set the clock select bits in the control register to 0xe (see the #define
152 below)
153
154-Set double-speed mode if you want to use sample rates above 50 kHz
155
156-Write the control register as you would normally
157
158-Now, you need to set the frequency register. First, you need to determine the
159 value for the frequency register. This is given by the following formula:
160
161frequency_reg = (LAYLA24_MAGIC_NUMBER / sample_rate) - 2
162
163Note the #define below for the magic number
164
165-Wait for the DSP handshake
166-Write the frequency_reg value to the .SampleRate field of the comm page
167-Send the vector command SET_LAYLA24_FREQUENCY_REG (see vmonkey.h)
168
169Once you have set the control register up for continuous mode, you can just
170write the frequency register to change the sample rate. This could be
171used for MIDI time code sync. For MTC sync, the control register is set for
172continuous mode. The driver then just keeps writing the
173SET_LAYLA24_FREQUENCY_REG command.
174
175-----------------------------------------------------------------------------*/
176
177#define LAYLA24_MAGIC_NUMBER 677376000
178#define LAYLA24_CONTINUOUS_CLOCK 0x000e
179
180
181/*
182 *
183 * DSP vector commands
184 *
185 */
186
187#define DSP_VC_RESET 0x80ff
188
189#ifndef DSP_56361
190
191#define DSP_VC_ACK_INT 0x8073
192#define DSP_VC_SET_VMIXER_GAIN 0x0000 /* Not used, only for compile */
193#define DSP_VC_START_TRANSFER 0x0075 /* Handshke rqd. */
194#define DSP_VC_METERS_ON 0x0079
195#define DSP_VC_METERS_OFF 0x007b
196#define DSP_VC_UPDATE_OUTVOL 0x007d /* Handshke rqd. */
197#define DSP_VC_UPDATE_INGAIN 0x007f /* Handshke rqd. */
198#define DSP_VC_ADD_AUDIO_BUFFER 0x0081 /* Handshke rqd. */
199#define DSP_VC_TEST_ASIC 0x00eb
200#define DSP_VC_UPDATE_CLOCKS 0x00ef /* Handshke rqd. */
201#define DSP_VC_SET_LAYLA_SAMPLE_RATE 0x00f1 /* Handshke rqd. */
202#define DSP_VC_SET_GD_AUDIO_STATE 0x00f1 /* Handshke rqd. */
203#define DSP_VC_WRITE_CONTROL_REG 0x00f1 /* Handshke rqd. */
204#define DSP_VC_MIDI_WRITE 0x00f5 /* Handshke rqd. */
205#define DSP_VC_STOP_TRANSFER 0x00f7 /* Handshke rqd. */
206#define DSP_VC_UPDATE_FLAGS 0x00fd /* Handshke rqd. */
207#define DSP_VC_GO_COMATOSE 0x00f9
208
209#else /* !DSP_56361 */
210
211/* Vector commands for families that use either the 56301 or 56361 */
212#define DSP_VC_ACK_INT 0x80F5
213#define DSP_VC_SET_VMIXER_GAIN 0x00DB /* Handshke rqd. */
214#define DSP_VC_START_TRANSFER 0x00DD /* Handshke rqd. */
215#define DSP_VC_METERS_ON 0x00EF
216#define DSP_VC_METERS_OFF 0x00F1
217#define DSP_VC_UPDATE_OUTVOL 0x00E3 /* Handshke rqd. */
218#define DSP_VC_UPDATE_INGAIN 0x00E5 /* Handshke rqd. */
219#define DSP_VC_ADD_AUDIO_BUFFER 0x00E1 /* Handshke rqd. */
220#define DSP_VC_TEST_ASIC 0x00ED
221#define DSP_VC_UPDATE_CLOCKS 0x00E9 /* Handshke rqd. */
222#define DSP_VC_SET_LAYLA24_FREQUENCY_REG 0x00E9 /* Handshke rqd. */
223#define DSP_VC_SET_LAYLA_SAMPLE_RATE 0x00EB /* Handshke rqd. */
224#define DSP_VC_SET_GD_AUDIO_STATE 0x00EB /* Handshke rqd. */
225#define DSP_VC_WRITE_CONTROL_REG 0x00EB /* Handshke rqd. */
226#define DSP_VC_MIDI_WRITE 0x00E7 /* Handshke rqd. */
227#define DSP_VC_STOP_TRANSFER 0x00DF /* Handshke rqd. */
228#define DSP_VC_UPDATE_FLAGS 0x00FB /* Handshke rqd. */
229#define DSP_VC_GO_COMATOSE 0x00d9
230
231#endif /* !DSP_56361 */
232
233
234/*
235 *
236 * Timeouts
237 *
238 */
239
240#define HANDSHAKE_TIMEOUT 20000 /* send_vector command timeout (20ms) */
241#define VECTOR_BUSY_TIMEOUT 100000 /* 100ms */
242#define MIDI_OUT_DELAY_USEC 2000 /* How long to wait after MIDI fills up */
243
244
245/*
246 *
247 * Flags for .Flags field in the comm page
248 *
249 */
250
251#define DSP_FLAG_MIDI_INPUT 0x0001 /* Enable MIDI input */
252#define DSP_FLAG_SPDIF_NONAUDIO 0x0002 /* Sets the "non-audio" bit
253 * in the S/PDIF out status
254 * bits. Clear this flag for
255 * audio data;
256 * set it for AC3 or WMA or
257 * some such */
258#define DSP_FLAG_PROFESSIONAL_SPDIF 0x0008 /* 1 Professional, 0 Consumer */
259
260
261/*
262 *
263 * Clock detect bits reported by the DSP for Gina20, Layla20, Darla24, and Mia
264 *
265 */
266
267#define GLDM_CLOCK_DETECT_BIT_WORD 0x0002
268#define GLDM_CLOCK_DETECT_BIT_SUPER 0x0004
269#define GLDM_CLOCK_DETECT_BIT_SPDIF 0x0008
270#define GLDM_CLOCK_DETECT_BIT_ESYNC 0x0010
271
272
273/*
274 *
275 * Clock detect bits reported by the DSP for Gina24, Mona, and Layla24
276 *
277 */
278
279#define GML_CLOCK_DETECT_BIT_WORD96 0x0002
280#define GML_CLOCK_DETECT_BIT_WORD48 0x0004
281#define GML_CLOCK_DETECT_BIT_SPDIF48 0x0008
282#define GML_CLOCK_DETECT_BIT_SPDIF96 0x0010
283#define GML_CLOCK_DETECT_BIT_WORD (GML_CLOCK_DETECT_BIT_WORD96 | GML_CLOCK_DETECT_BIT_WORD48)
284#define GML_CLOCK_DETECT_BIT_SPDIF (GML_CLOCK_DETECT_BIT_SPDIF48 | GML_CLOCK_DETECT_BIT_SPDIF96)
285#define GML_CLOCK_DETECT_BIT_ESYNC 0x0020
286#define GML_CLOCK_DETECT_BIT_ADAT 0x0040
287
288
289/*
290 *
291 * Layla clock numbers to send to DSP
292 *
293 */
294
295#define LAYLA20_CLOCK_INTERNAL 0
296#define LAYLA20_CLOCK_SPDIF 1
297#define LAYLA20_CLOCK_WORD 2
298#define LAYLA20_CLOCK_SUPER 3
299
300
301/*
302 *
303 * Gina/Darla clock states
304 *
305 */
306
307#define GD_CLOCK_NOCHANGE 0
308#define GD_CLOCK_44 1
309#define GD_CLOCK_48 2
310#define GD_CLOCK_SPDIFIN 3
311#define GD_CLOCK_UNDEF 0xff
312
313
314/*
315 *
316 * Gina/Darla S/PDIF status bits
317 *
318 */
319
320#define GD_SPDIF_STATUS_NOCHANGE 0
321#define GD_SPDIF_STATUS_44 1
322#define GD_SPDIF_STATUS_48 2
323#define GD_SPDIF_STATUS_UNDEF 0xff
324
325
326/*
327 *
328 * Layla20 output clocks
329 *
330 */
331
332#define LAYLA20_OUTPUT_CLOCK_SUPER 0
333#define LAYLA20_OUTPUT_CLOCK_WORD 1
334
335
336/****************************************************************************
337
338 Magic constants for the Darla24 hardware
339
340 ****************************************************************************/
341
342#define GD24_96000 0x0
343#define GD24_48000 0x1
344#define GD24_44100 0x2
345#define GD24_32000 0x3
346#define GD24_22050 0x4
347#define GD24_16000 0x5
348#define GD24_11025 0x6
349#define GD24_8000 0x7
350#define GD24_88200 0x8
351#define GD24_EXT_SYNC 0x9
352
353
354/*
355 *
356 * Return values from the DSP when ASIC is loaded
357 *
358 */
359
360#define ASIC_ALREADY_LOADED 0x1
361#define ASIC_NOT_LOADED 0x0
362
363
364/*
365 *
366 * DSP Audio formats
367 *
368 * These are the audio formats that the DSP can transfer
369 * via input and output pipes. LE means little-endian,
370 * BE means big-endian.
371 *
372 * DSP_AUDIOFORM_MS_8
373 *
374 * 8-bit mono unsigned samples. For playback,
375 * mono data is duplicated out the left and right channels
376 * of the output bus. The "MS" part of the name
377 * means mono->stereo.
378 *
379 * DSP_AUDIOFORM_MS_16LE
380 *
381 * 16-bit signed little-endian mono samples. Playback works
382 * like the previous code.
383 *
384 * DSP_AUDIOFORM_MS_24LE
385 *
386 * 24-bit signed little-endian mono samples. Data is packed
387 * three bytes per sample; if you had two samples 0x112233 and 0x445566
388 * they would be stored in memory like this: 33 22 11 66 55 44.
389 *
390 * DSP_AUDIOFORM_MS_32LE
391 *
392 * 24-bit signed little-endian mono samples in a 32-bit
393 * container. In other words, each sample is a 32-bit signed
394 * integer, where the actual audio data is left-justified
395 * in the 32 bits and only the 24 most significant bits are valid.
396 *
397 * DSP_AUDIOFORM_SS_8
398 * DSP_AUDIOFORM_SS_16LE
399 * DSP_AUDIOFORM_SS_24LE
400 * DSP_AUDIOFORM_SS_32LE
401 *
402 * Like the previous ones, except now with stereo interleaved
403 * data. "SS" means stereo->stereo.
404 *
405 * DSP_AUDIOFORM_MM_32LE
406 *
407 * Similar to DSP_AUDIOFORM_MS_32LE, except that the mono
408 * data is not duplicated out both the left and right outputs.
409 * This mode is used by the ASIO driver. Here, "MM" means
410 * mono->mono.
411 *
412 * DSP_AUDIOFORM_MM_32BE
413 *
414 * Just like DSP_AUDIOFORM_MM_32LE, but now the data is
415 * in big-endian format.
416 *
417 */
418
419#define DSP_AUDIOFORM_MS_8 0 /* 8 bit mono */
420#define DSP_AUDIOFORM_MS_16LE 1 /* 16 bit mono */
421#define DSP_AUDIOFORM_MS_24LE 2 /* 24 bit mono */
422#define DSP_AUDIOFORM_MS_32LE 3 /* 32 bit mono */
423#define DSP_AUDIOFORM_SS_8 4 /* 8 bit stereo */
424#define DSP_AUDIOFORM_SS_16LE 5 /* 16 bit stereo */
425#define DSP_AUDIOFORM_SS_24LE 6 /* 24 bit stereo */
426#define DSP_AUDIOFORM_SS_32LE 7 /* 32 bit stereo */
427#define DSP_AUDIOFORM_MM_32LE 8 /* 32 bit mono->mono little-endian */
428#define DSP_AUDIOFORM_MM_32BE 9 /* 32 bit mono->mono big-endian */
429#define DSP_AUDIOFORM_SS_32BE 10 /* 32 bit stereo big endian */
430#define DSP_AUDIOFORM_INVALID 0xFF /* Invalid audio format */
431
432
433/*
434 *
435 * Super-interleave is defined as interleaving by 4 or more. Darla20 and Gina20
436 * do not support super interleave.
437 *
438 * 16 bit, 24 bit, and 32 bit little endian samples are supported for super
439 * interleave. The interleave factor must be even. 16 - way interleave is the
440 * current maximum, so you can interleave by 4, 6, 8, 10, 12, 14, and 16.
441 *
442 * The actual format code is derived by taking the define below and or-ing with
443 * the interleave factor. So, 32 bit interleave by 6 is 0x86 and
444 * 16 bit interleave by 16 is (0x40 | 0x10) = 0x50.
445 *
446 */
447
448#define DSP_AUDIOFORM_SUPER_INTERLEAVE_16LE 0x40
449#define DSP_AUDIOFORM_SUPER_INTERLEAVE_24LE 0xc0
450#define DSP_AUDIOFORM_SUPER_INTERLEAVE_32LE 0x80
451
452
453/*
454 *
455 * Gina24, Mona, and Layla24 control register defines
456 *
457 */
458
459#define GML_CONVERTER_ENABLE 0x0010
460#define GML_SPDIF_PRO_MODE 0x0020 /* Professional S/PDIF == 1,
461 consumer == 0 */
462#define GML_SPDIF_SAMPLE_RATE0 0x0040
463#define GML_SPDIF_SAMPLE_RATE1 0x0080
464#define GML_SPDIF_TWO_CHANNEL 0x0100 /* 1 == two channels,
465 0 == one channel */
466#define GML_SPDIF_NOT_AUDIO 0x0200
467#define GML_SPDIF_COPY_PERMIT 0x0400
468#define GML_SPDIF_24_BIT 0x0800 /* 1 == 24 bit, 0 == 20 bit */
469#define GML_ADAT_MODE 0x1000 /* 1 == ADAT mode, 0 == S/PDIF mode */
470#define GML_SPDIF_OPTICAL_MODE 0x2000 /* 1 == optical mode, 0 == RCA mode */
471#define GML_SPDIF_CDROM_MODE 0x3000 /* 1 == CDROM mode,
472 * 0 == RCA or optical mode */
473#define GML_DOUBLE_SPEED_MODE 0x4000 /* 1 == double speed,
474 0 == single speed */
475
476#define GML_DIGITAL_IN_AUTO_MUTE 0x800000
477
478#define GML_96KHZ (0x0 | GML_DOUBLE_SPEED_MODE)
479#define GML_88KHZ (0x1 | GML_DOUBLE_SPEED_MODE)
480#define GML_48KHZ 0x2
481#define GML_44KHZ 0x3
482#define GML_32KHZ 0x4
483#define GML_22KHZ 0x5
484#define GML_16KHZ 0x6
485#define GML_11KHZ 0x7
486#define GML_8KHZ 0x8
487#define GML_SPDIF_CLOCK 0x9
488#define GML_ADAT_CLOCK 0xA
489#define GML_WORD_CLOCK 0xB
490#define GML_ESYNC_CLOCK 0xC
491#define GML_ESYNCx2_CLOCK 0xD
492
493#define GML_CLOCK_CLEAR_MASK 0xffffbff0
494#define GML_SPDIF_RATE_CLEAR_MASK (~(GML_SPDIF_SAMPLE_RATE0|GML_SPDIF_SAMPLE_RATE1))
495#define GML_DIGITAL_MODE_CLEAR_MASK 0xffffcfff
496#define GML_SPDIF_FORMAT_CLEAR_MASK 0xfffff01f
497
498
499/*
500 *
501 * Mia sample rate and clock setting constants
502 *
503 */
504
505#define MIA_32000 0x0040
506#define MIA_44100 0x0042
507#define MIA_48000 0x0041
508#define MIA_88200 0x0142
509#define MIA_96000 0x0141
510
511#define MIA_SPDIF 0x00000044
512#define MIA_SPDIF96 0x00000144
513
514#define MIA_MIDI_REV 1 /* Must be Mia rev 1 for MIDI support */
515
516
517/*
518 *
519 * 3G register bits
520 *
521 */
522
523#define E3G_CONVERTER_ENABLE 0x0010
524#define E3G_SPDIF_PRO_MODE 0x0020 /* Professional S/PDIF == 1,
525 consumer == 0 */
526#define E3G_SPDIF_SAMPLE_RATE0 0x0040
527#define E3G_SPDIF_SAMPLE_RATE1 0x0080
528#define E3G_SPDIF_TWO_CHANNEL 0x0100 /* 1 == two channels,
529 0 == one channel */
530#define E3G_SPDIF_NOT_AUDIO 0x0200
531#define E3G_SPDIF_COPY_PERMIT 0x0400
532#define E3G_SPDIF_24_BIT 0x0800 /* 1 == 24 bit, 0 == 20 bit */
533#define E3G_DOUBLE_SPEED_MODE 0x4000 /* 1 == double speed,
534 0 == single speed */
535#define E3G_PHANTOM_POWER 0x8000 /* 1 == phantom power on,
536 0 == phantom power off */
537
538#define E3G_96KHZ (0x0 | E3G_DOUBLE_SPEED_MODE)
539#define E3G_88KHZ (0x1 | E3G_DOUBLE_SPEED_MODE)
540#define E3G_48KHZ 0x2
541#define E3G_44KHZ 0x3
542#define E3G_32KHZ 0x4
543#define E3G_22KHZ 0x5
544#define E3G_16KHZ 0x6
545#define E3G_11KHZ 0x7
546#define E3G_8KHZ 0x8
547#define E3G_SPDIF_CLOCK 0x9
548#define E3G_ADAT_CLOCK 0xA
549#define E3G_WORD_CLOCK 0xB
550#define E3G_CONTINUOUS_CLOCK 0xE
551
552#define E3G_ADAT_MODE 0x1000
553#define E3G_SPDIF_OPTICAL_MODE 0x2000
554
555#define E3G_CLOCK_CLEAR_MASK 0xbfffbff0
556#define E3G_DIGITAL_MODE_CLEAR_MASK 0xffffcfff
557#define E3G_SPDIF_FORMAT_CLEAR_MASK 0xfffff01f
558
559/* Clock detect bits reported by the DSP */
560#define E3G_CLOCK_DETECT_BIT_WORD96 0x0001
561#define E3G_CLOCK_DETECT_BIT_WORD48 0x0002
562#define E3G_CLOCK_DETECT_BIT_SPDIF48 0x0004
563#define E3G_CLOCK_DETECT_BIT_ADAT 0x0004
564#define E3G_CLOCK_DETECT_BIT_SPDIF96 0x0008
565#define E3G_CLOCK_DETECT_BIT_WORD (E3G_CLOCK_DETECT_BIT_WORD96|E3G_CLOCK_DETECT_BIT_WORD48)
566#define E3G_CLOCK_DETECT_BIT_SPDIF (E3G_CLOCK_DETECT_BIT_SPDIF48|E3G_CLOCK_DETECT_BIT_SPDIF96)
567
568/* Frequency control register */
569#define E3G_MAGIC_NUMBER 677376000
570#define E3G_FREQ_REG_DEFAULT (E3G_MAGIC_NUMBER / 48000 - 2)
571#define E3G_FREQ_REG_MAX 0xffff
572
573/* 3G external box types */
574#define E3G_GINA3G_BOX_TYPE 0x00
575#define E3G_LAYLA3G_BOX_TYPE 0x10
576#define E3G_ASIC_NOT_LOADED 0xffff
577#define E3G_BOX_TYPE_MASK 0xf0
578
579#define EXT_3GBOX_NC 0x01
580#define EXT_3GBOX_NOT_SET 0x02
581
582
583/*
584 *
585 * Gina20 & Layla20 have input gain controls for the analog inputs;
586 * this is the magic number for the hardware that gives you 0 dB at -10.
587 *
588 */
589
590#define GL20_INPUT_GAIN_MAGIC_NUMBER 0xC8
591
592
593/*
594 *
595 * Defines how much time must pass between DSP load attempts
596 *
597 */
598
599#define DSP_LOAD_ATTEMPT_PERIOD 1000000L /* One second */
600
601
602/*
603 *
604 * Size of arrays for the comm page. MAX_PLAY_TAPS and MAX_REC_TAPS are
605 * no longer used, but the sizes must still be right for the DSP to see
606 * the comm page correctly.
607 *
608 */
609
610#define MONITOR_ARRAY_SIZE 0x180
611#define VMIXER_ARRAY_SIZE 0x40
612#define MIDI_OUT_BUFFER_SIZE 32
613#define MIDI_IN_BUFFER_SIZE 256
614#define MAX_PLAY_TAPS 168
615#define MAX_REC_TAPS 192
616#define DSP_MIDI_OUT_FIFO_SIZE 64
617
618
619/* sg_entry is a single entry for the scatter-gather list. The array of struct
620sg_entry struct is read by the DSP, so all values must be little-endian. */
621
622#define MAX_SGLIST_ENTRIES 512
623
624struct sg_entry {
625 u32 addr;
626 u32 size;
627};
628
629
630/****************************************************************************
631
632 The comm page. This structure is read and written by the DSP; the
633 DSP code is a firm believer in the byte offsets written in the comments
634 at the end of each line. This structure should not be changed.
635
636 Any reads from or writes to this structure should be in little-endian format.
637
638 ****************************************************************************/
639
640struct comm_page { /* Base Length*/
641 u32 comm_size; /* size of this object 0x000 4 */
642 u32 flags; /* See Appendix A below 0x004 4 */
643 u32 unused; /* Unused entry 0x008 4 */
644 u32 sample_rate; /* Card sample rate in Hz 0x00c 4 */
645 volatile u32 handshake; /* DSP command handshake 0x010 4 */
646 u32 cmd_start; /* Chs. to start mask 0x014 4 */
647 u32 cmd_stop; /* Chs. to stop mask 0x018 4 */
648 u32 cmd_reset; /* Chs. to reset mask 0x01c 4 */
649 u16 audio_format[DSP_MAXPIPES]; /* Chs. audio format 0x020 32*2 */
650 struct sg_entry sglist_addr[DSP_MAXPIPES];
651 /* Chs. Physical sglist addrs 0x060 32*8 */
652 volatile u32 position[DSP_MAXPIPES];
653 /* Positions for ea. ch. 0x160 32*4 */
654 volatile s8 vu_meter[DSP_MAXPIPES];
655 /* VU meters 0x1e0 32*1 */
656 volatile s8 peak_meter[DSP_MAXPIPES];
657 /* Peak meters 0x200 32*1 */
658 s8 line_out_level[DSP_MAXAUDIOOUTPUTS];
659 /* Output gain 0x220 16*1 */
660 s8 line_in_level[DSP_MAXAUDIOINPUTS];
661 /* Input gain 0x230 16*1 */
662 s8 monitors[MONITOR_ARRAY_SIZE];
663 /* Monitor map 0x240 0x180 */
664 u32 play_coeff[MAX_PLAY_TAPS];
665 /* Gina/Darla play filters - obsolete 0x3c0 168*4 */
666 u32 rec_coeff[MAX_REC_TAPS];
667 /* Gina/Darla record filters - obsolete 0x660 192*4 */
668 volatile u16 midi_input[MIDI_IN_BUFFER_SIZE];
669 /* MIDI input data transfer buffer 0x960 256*2 */
670 u8 gd_clock_state; /* Chg Gina/Darla clock state 0xb60 1 */
671 u8 gd_spdif_status; /* Chg. Gina/Darla S/PDIF state 0xb61 1 */
672 u8 gd_resampler_state; /* Should always be 3 0xb62 1 */
673 u8 filler2; /* 0xb63 1 */
674 u32 nominal_level_mask; /* -10 level enable mask 0xb64 4 */
675 u16 input_clock; /* Chg. Input clock state 0xb68 2 */
676 u16 output_clock; /* Chg. Output clock state 0xb6a 2 */
677 volatile u32 status_clocks;
678 /* Current Input clock state 0xb6c 4 */
679 u32 ext_box_status; /* External box status 0xb70 4 */
680 u32 cmd_add_buffer; /* Pipes to add (obsolete) 0xb74 4 */
681 volatile u32 midi_out_free_count;
682 /* # of bytes free in MIDI output FIFO 0xb78 4 */
683 u32 unused2; /* Cyclic pipes 0xb7c 4 */
684 u32 control_register;
685 /* Mona, Gina24, Layla24, 3G ctrl reg 0xb80 4 */
686 u32 e3g_frq_register; /* 3G frequency register 0xb84 4 */
687 u8 filler[24]; /* filler 0xb88 24*1 */
688 s8 vmixer[VMIXER_ARRAY_SIZE];
689 /* Vmixer levels 0xba0 64*1 */
690 u8 midi_output[MIDI_OUT_BUFFER_SIZE];
691 /* MIDI output data 0xbe0 32*1 */
692};
693
694#endif /* _ECHO_DSP_ */
diff --git a/sound/pci/echoaudio/echoaudio_gml.c b/sound/pci/echoaudio/echoaudio_gml.c
new file mode 100644
index 000000000000..3aa37e76ebab
--- /dev/null
+++ b/sound/pci/echoaudio/echoaudio_gml.c
@@ -0,0 +1,198 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32/* These functions are common for Gina24, Layla24 and Mona cards */
33
34
35/* ASIC status check - some cards have one or two ASICs that need to be
36loaded. Once that load is complete, this function is called to see if
37the load was successful.
38If this load fails, it does not necessarily mean that the hardware is
39defective - the external box may be disconnected or turned off. */
40static int check_asic_status(struct echoaudio *chip)
41{
42 u32 asic_status;
43
44 send_vector(chip, DSP_VC_TEST_ASIC);
45
46 /* The DSP will return a value to indicate whether or not the
47 ASIC is currently loaded */
48 if (read_dsp(chip, &asic_status) < 0) {
49 DE_INIT(("check_asic_status: failed on read_dsp\n"));
50 chip->asic_loaded = FALSE;
51 return -EIO;
52 }
53
54 chip->asic_loaded = (asic_status == ASIC_ALREADY_LOADED);
55 return chip->asic_loaded ? 0 : -EIO;
56}
57
58
59
60/* Most configuration of Gina24, Layla24, or Mona is accomplished by writing
61the control register. write_control_reg sends the new control register
62value to the DSP. */
63static int write_control_reg(struct echoaudio *chip, u32 value, char force)
64{
65 /* Handle the digital input auto-mute */
66 if (chip->digital_in_automute)
67 value |= GML_DIGITAL_IN_AUTO_MUTE;
68 else
69 value &= ~GML_DIGITAL_IN_AUTO_MUTE;
70
71 DE_ACT(("write_control_reg: 0x%x\n", value));
72
73 /* Write the control register */
74 value = cpu_to_le32(value);
75 if (value != chip->comm_page->control_register || force) {
76 if (wait_handshake(chip))
77 return -EIO;
78 chip->comm_page->control_register = value;
79 clear_handshake(chip);
80 return send_vector(chip, DSP_VC_WRITE_CONTROL_REG);
81 }
82 return 0;
83}
84
85
86
87/* Gina24, Layla24, and Mona support digital input auto-mute. If the digital
88input auto-mute is enabled, the DSP will only enable the digital inputs if
89the card is syncing to a valid clock on the ADAT or S/PDIF inputs.
90If the auto-mute is disabled, the digital inputs are enabled regardless of
91what the input clock is set or what is connected. */
92static int set_input_auto_mute(struct echoaudio *chip, int automute)
93{
94 DE_ACT(("set_input_auto_mute %d\n", automute));
95
96 chip->digital_in_automute = automute;
97
98 /* Re-set the input clock to the current value - indirectly causes
99 the auto-mute flag to be sent to the DSP */
100 return set_input_clock(chip, chip->input_clock);
101}
102
103
104
105/* S/PDIF coax / S/PDIF optical / ADAT - switch */
106static int set_digital_mode(struct echoaudio *chip, u8 mode)
107{
108 u8 previous_mode;
109 int err, i, o;
110
111 if (chip->bad_board)
112 return -EIO;
113
114 /* All audio channels must be closed before changing the digital mode */
115 snd_assert(!chip->pipe_alloc_mask, return -EAGAIN);
116
117 snd_assert(chip->digital_modes & (1 << mode), return -EINVAL);
118
119 previous_mode = chip->digital_mode;
120 err = dsp_set_digital_mode(chip, mode);
121
122 /* If we successfully changed the digital mode from or to ADAT,
123 then make sure all output, input and monitor levels are
124 updated by the DSP comm object. */
125 if (err >= 0 && previous_mode != mode &&
126 (previous_mode == DIGITAL_MODE_ADAT || mode == DIGITAL_MODE_ADAT)) {
127 spin_lock_irq(&chip->lock);
128 for (o = 0; o < num_busses_out(chip); o++)
129 for (i = 0; i < num_busses_in(chip); i++)
130 set_monitor_gain(chip, o, i,
131 chip->monitor_gain[o][i]);
132
133#ifdef ECHOCARD_HAS_INPUT_GAIN
134 for (i = 0; i < num_busses_in(chip); i++)
135 set_input_gain(chip, i, chip->input_gain[i]);
136 update_input_line_level(chip);
137#endif
138
139 for (o = 0; o < num_busses_out(chip); o++)
140 set_output_gain(chip, o, chip->output_gain[o]);
141 update_output_line_level(chip);
142 spin_unlock_irq(&chip->lock);
143 }
144
145 return err;
146}
147
148
149
150/* Set the S/PDIF output format */
151static int set_professional_spdif(struct echoaudio *chip, char prof)
152{
153 u32 control_reg;
154 int err;
155
156 /* Clear the current S/PDIF flags */
157 control_reg = le32_to_cpu(chip->comm_page->control_register);
158 control_reg &= GML_SPDIF_FORMAT_CLEAR_MASK;
159
160 /* Set the new S/PDIF flags depending on the mode */
161 control_reg |= GML_SPDIF_TWO_CHANNEL | GML_SPDIF_24_BIT |
162 GML_SPDIF_COPY_PERMIT;
163 if (prof) {
164 /* Professional mode */
165 control_reg |= GML_SPDIF_PRO_MODE;
166
167 switch (chip->sample_rate) {
168 case 32000:
169 control_reg |= GML_SPDIF_SAMPLE_RATE0 |
170 GML_SPDIF_SAMPLE_RATE1;
171 break;
172 case 44100:
173 control_reg |= GML_SPDIF_SAMPLE_RATE0;
174 break;
175 case 48000:
176 control_reg |= GML_SPDIF_SAMPLE_RATE1;
177 break;
178 }
179 } else {
180 /* Consumer mode */
181 switch (chip->sample_rate) {
182 case 32000:
183 control_reg |= GML_SPDIF_SAMPLE_RATE0 |
184 GML_SPDIF_SAMPLE_RATE1;
185 break;
186 case 48000:
187 control_reg |= GML_SPDIF_SAMPLE_RATE1;
188 break;
189 }
190 }
191
192 if ((err = write_control_reg(chip, control_reg, FALSE)))
193 return err;
194 chip->professional_spdif = prof;
195 DE_ACT(("set_professional_spdif to %s\n",
196 prof ? "Professional" : "Consumer"));
197 return 0;
198}
diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c
new file mode 100644
index 000000000000..29d6d12f80ca
--- /dev/null
+++ b/sound/pci/echoaudio/gina20.c
@@ -0,0 +1,103 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHOGALS_FAMILY
20#define ECHOCARD_GINA20
21#define ECHOCARD_NAME "Gina20"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_INPUT_GAIN
24#define ECHOCARD_HAS_DIGITAL_IO
25#define ECHOCARD_HAS_EXTERNAL_CLOCK
26#define ECHOCARD_HAS_ADAT FALSE
27
28/* Pipe indexes */
29#define PX_ANALOG_OUT 0 /* 8 */
30#define PX_DIGITAL_OUT 8 /* 2 */
31#define PX_ANALOG_IN 10 /* 2 */
32#define PX_DIGITAL_IN 12 /* 2 */
33#define PX_NUM 14
34
35/* Bus indexes */
36#define BX_ANALOG_OUT 0 /* 8 */
37#define BX_DIGITAL_OUT 8 /* 2 */
38#define BX_ANALOG_IN 10 /* 2 */
39#define BX_DIGITAL_IN 12 /* 2 */
40#define BX_NUM 14
41
42
43#include <sound/driver.h>
44#include <linux/delay.h>
45#include <linux/init.h>
46#include <linux/interrupt.h>
47#include <linux/pci.h>
48#include <linux/slab.h>
49#include <linux/moduleparam.h>
50#include <linux/firmware.h>
51#include <sound/core.h>
52#include <sound/info.h>
53#include <sound/control.h>
54#include <sound/pcm.h>
55#include <sound/pcm_params.h>
56#include <sound/asoundef.h>
57#include <sound/initval.h>
58#include <asm/io.h>
59#include <asm/atomic.h>
60#include "echoaudio.h"
61
62#define FW_GINA20_DSP 0
63
64static const struct firmware card_fw[] = {
65 {0, "gina20_dsp.fw"}
66};
67
68static struct pci_device_id snd_echo_ids[] = {
69 {0x1057, 0x1801, 0xECC0, 0x0020, 0, 0, 0}, /* DSP 56301 Gina20 rev.0 */
70 {0,}
71};
72
73static struct snd_pcm_hardware pcm_hardware_skel = {
74 .info = SNDRV_PCM_INFO_MMAP |
75 SNDRV_PCM_INFO_INTERLEAVED |
76 SNDRV_PCM_INFO_BLOCK_TRANSFER |
77 SNDRV_PCM_INFO_MMAP_VALID |
78 SNDRV_PCM_INFO_PAUSE |
79 SNDRV_PCM_INFO_SYNC_START,
80 .formats = SNDRV_PCM_FMTBIT_U8 |
81 SNDRV_PCM_FMTBIT_S16_LE |
82 SNDRV_PCM_FMTBIT_S24_3LE |
83 SNDRV_PCM_FMTBIT_S32_LE |
84 SNDRV_PCM_FMTBIT_S32_BE,
85 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
86 .rate_min = 44100,
87 .rate_max = 48000,
88 .channels_min = 1,
89 .channels_max = 2,
90 .buffer_bytes_max = 262144,
91 .period_bytes_min = 32,
92 .period_bytes_max = 131072,
93 .periods_min = 2,
94 .periods_max = 220,
95 /* One page (4k) contains 512 instructions. I don't know if the hw
96 supports lists longer than this. In this case periods_max=220 is a
97 safe limit to make sure the list never exceeds 512 instructions. */
98};
99
100
101#include "gina20_dsp.c"
102#include "echoaudio_dsp.c"
103#include "echoaudio.c"
diff --git a/sound/pci/echoaudio/gina20_dsp.c b/sound/pci/echoaudio/gina20_dsp.c
new file mode 100644
index 000000000000..2757c8960843
--- /dev/null
+++ b/sound/pci/echoaudio/gina20_dsp.c
@@ -0,0 +1,215 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int set_professional_spdif(struct echoaudio *chip, char prof);
33static int update_flags(struct echoaudio *chip);
34
35
36static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
37{
38 int err;
39
40 DE_INIT(("init_hw() - Gina20\n"));
41 snd_assert((subdevice_id & 0xfff0) == GINA20, return -ENODEV);
42
43 if ((err = init_dsp_comm_page(chip))) {
44 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
45 return err;
46 }
47
48 chip->device_id = device_id;
49 chip->subdevice_id = subdevice_id;
50 chip->bad_board = TRUE;
51 chip->dsp_code_to_load = &card_fw[FW_GINA20_DSP];
52 chip->spdif_status = GD_SPDIF_STATUS_UNDEF;
53 chip->clock_state = GD_CLOCK_UNDEF;
54 /* Since this card has no ASIC, mark it as loaded so everything
55 works OK */
56 chip->asic_loaded = TRUE;
57 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
58 ECHO_CLOCK_BIT_SPDIF;
59
60 if ((err = load_firmware(chip)) < 0)
61 return err;
62 chip->bad_board = FALSE;
63
64 if ((err = init_line_levels(chip)) < 0)
65 return err;
66
67 err = set_professional_spdif(chip, TRUE);
68
69 DE_INIT(("init_hw done\n"));
70 return err;
71}
72
73
74
75static u32 detect_input_clocks(const struct echoaudio *chip)
76{
77 u32 clocks_from_dsp, clock_bits;
78
79 /* Map the DSP clock detect bits to the generic driver clock
80 detect bits */
81 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
82
83 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
84
85 if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_SPDIF)
86 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
87
88 return clock_bits;
89}
90
91
92
93/* The Gina20 has no ASIC. Just do nothing */
94static int load_asic(struct echoaudio *chip)
95{
96 return 0;
97}
98
99
100
101static int set_sample_rate(struct echoaudio *chip, u32 rate)
102{
103 u8 clock_state, spdif_status;
104
105 if (wait_handshake(chip))
106 return -EIO;
107
108 switch (rate) {
109 case 44100:
110 clock_state = GD_CLOCK_44;
111 spdif_status = GD_SPDIF_STATUS_44;
112 break;
113 case 48000:
114 clock_state = GD_CLOCK_48;
115 spdif_status = GD_SPDIF_STATUS_48;
116 break;
117 default:
118 clock_state = GD_CLOCK_NOCHANGE;
119 spdif_status = GD_SPDIF_STATUS_NOCHANGE;
120 break;
121 }
122
123 if (chip->clock_state == clock_state)
124 clock_state = GD_CLOCK_NOCHANGE;
125 if (spdif_status == chip->spdif_status)
126 spdif_status = GD_SPDIF_STATUS_NOCHANGE;
127
128 chip->comm_page->sample_rate = cpu_to_le32(rate);
129 chip->comm_page->gd_clock_state = clock_state;
130 chip->comm_page->gd_spdif_status = spdif_status;
131 chip->comm_page->gd_resampler_state = 3; /* magic number - should always be 3 */
132
133 /* Save the new audio state if it changed */
134 if (clock_state != GD_CLOCK_NOCHANGE)
135 chip->clock_state = clock_state;
136 if (spdif_status != GD_SPDIF_STATUS_NOCHANGE)
137 chip->spdif_status = spdif_status;
138 chip->sample_rate = rate;
139
140 clear_handshake(chip);
141 return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
142}
143
144
145
146static int set_input_clock(struct echoaudio *chip, u16 clock)
147{
148 DE_ACT(("set_input_clock:\n"));
149
150 switch (clock) {
151 case ECHO_CLOCK_INTERNAL:
152 /* Reset the audio state to unknown (just in case) */
153 chip->clock_state = GD_CLOCK_UNDEF;
154 chip->spdif_status = GD_SPDIF_STATUS_UNDEF;
155 set_sample_rate(chip, chip->sample_rate);
156 chip->input_clock = clock;
157 DE_ACT(("Set Gina clock to INTERNAL\n"));
158 break;
159 case ECHO_CLOCK_SPDIF:
160 chip->comm_page->gd_clock_state = GD_CLOCK_SPDIFIN;
161 chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_NOCHANGE;
162 clear_handshake(chip);
163 send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
164 chip->clock_state = GD_CLOCK_SPDIFIN;
165 DE_ACT(("Set Gina20 clock to SPDIF\n"));
166 chip->input_clock = clock;
167 break;
168 default:
169 return -EINVAL;
170 }
171
172 return 0;
173}
174
175
176
177/* Set input bus gain (one unit is 0.5dB !) */
178static int set_input_gain(struct echoaudio *chip, u16 input, int gain)
179{
180 snd_assert(input < num_busses_in(chip), return -EINVAL);
181
182 if (wait_handshake(chip))
183 return -EIO;
184
185 chip->input_gain[input] = gain;
186 gain += GL20_INPUT_GAIN_MAGIC_NUMBER;
187 chip->comm_page->line_in_level[input] = gain;
188 return 0;
189}
190
191
192
193/* Tell the DSP to reread the flags from the comm page */
194static int update_flags(struct echoaudio *chip)
195{
196 if (wait_handshake(chip))
197 return -EIO;
198 clear_handshake(chip);
199 return send_vector(chip, DSP_VC_UPDATE_FLAGS);
200}
201
202
203
204static int set_professional_spdif(struct echoaudio *chip, char prof)
205{
206 DE_ACT(("set_professional_spdif %d\n", prof));
207 if (prof)
208 chip->comm_page->flags |=
209 __constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
210 else
211 chip->comm_page->flags &=
212 ~__constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
213 chip->professional_spdif = prof;
214 return update_flags(chip);
215}
diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c
new file mode 100644
index 000000000000..e464d720d0bd
--- /dev/null
+++ b/sound/pci/echoaudio/gina24.c
@@ -0,0 +1,123 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHO24_FAMILY
20#define ECHOCARD_GINA24
21#define ECHOCARD_NAME "Gina24"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_ASIC
24#define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
25#define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
26#define ECHOCARD_HAS_SUPER_INTERLEAVE
27#define ECHOCARD_HAS_DIGITAL_IO
28#define ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
29#define ECHOCARD_HAS_DIGITAL_MODE_SWITCH
30#define ECHOCARD_HAS_EXTERNAL_CLOCK
31#define ECHOCARD_HAS_ADAT 6
32#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
33
34/* Pipe indexes */
35#define PX_ANALOG_OUT 0 /* 8 */
36#define PX_DIGITAL_OUT 8 /* 8 */
37#define PX_ANALOG_IN 16 /* 2 */
38#define PX_DIGITAL_IN 18 /* 8 */
39#define PX_NUM 26
40
41/* Bus indexes */
42#define BX_ANALOG_OUT 0 /* 8 */
43#define BX_DIGITAL_OUT 8 /* 8 */
44#define BX_ANALOG_IN 16 /* 2 */
45#define BX_DIGITAL_IN 18 /* 8 */
46#define BX_NUM 26
47
48
49#include <sound/driver.h>
50#include <linux/delay.h>
51#include <linux/init.h>
52#include <linux/interrupt.h>
53#include <linux/pci.h>
54#include <linux/slab.h>
55#include <linux/moduleparam.h>
56#include <linux/firmware.h>
57#include <sound/core.h>
58#include <sound/info.h>
59#include <sound/control.h>
60#include <sound/pcm.h>
61#include <sound/pcm_params.h>
62#include <sound/asoundef.h>
63#include <sound/initval.h>
64#include <asm/io.h>
65#include <asm/atomic.h>
66#include "echoaudio.h"
67
68#define FW_361_LOADER 0
69#define FW_GINA24_301_DSP 1
70#define FW_GINA24_361_DSP 2
71#define FW_GINA24_301_ASIC 3
72#define FW_GINA24_361_ASIC 4
73
74static const struct firmware card_fw[] = {
75 {0, "loader_dsp.fw"},
76 {0, "gina24_301_dsp.fw"},
77 {0, "gina24_361_dsp.fw"},
78 {0, "gina24_301_asic.fw"},
79 {0, "gina24_361_asic.fw"}
80};
81
82static struct pci_device_id snd_echo_ids[] = {
83 {0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56301 Gina24 rev.0 */
84 {0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0}, /* DSP 56301 Gina24 rev.1 */
85 {0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56361 Gina24 rev.0 */
86 {0x1057, 0x3410, 0xECC0, 0x0051, 0, 0, 0}, /* DSP 56361 Gina24 rev.1 */
87 {0,}
88};
89
90static struct snd_pcm_hardware pcm_hardware_skel = {
91 .info = SNDRV_PCM_INFO_MMAP |
92 SNDRV_PCM_INFO_INTERLEAVED |
93 SNDRV_PCM_INFO_BLOCK_TRANSFER |
94 SNDRV_PCM_INFO_MMAP_VALID |
95 SNDRV_PCM_INFO_PAUSE |
96 SNDRV_PCM_INFO_SYNC_START,
97 .formats = SNDRV_PCM_FMTBIT_U8 |
98 SNDRV_PCM_FMTBIT_S16_LE |
99 SNDRV_PCM_FMTBIT_S24_3LE |
100 SNDRV_PCM_FMTBIT_S32_LE |
101 SNDRV_PCM_FMTBIT_S32_BE,
102 .rates = SNDRV_PCM_RATE_8000_48000 |
103 SNDRV_PCM_RATE_88200 |
104 SNDRV_PCM_RATE_96000,
105 .rate_min = 8000,
106 .rate_max = 96000,
107 .channels_min = 1,
108 .channels_max = 8,
109 .buffer_bytes_max = 262144,
110 .period_bytes_min = 32,
111 .period_bytes_max = 131072,
112 .periods_min = 2,
113 .periods_max = 220,
114 /* One page (4k) contains 512 instructions. I don't know if the hw
115 supports lists longer than this. In this case periods_max=220 is a
116 safe limit to make sure the list never exceeds 512 instructions.
117 220 ~= (512 - 1 - (BUFFER_BYTES_MAX / PAGE_SIZE)) / 2 */
118};
119
120#include "gina24_dsp.c"
121#include "echoaudio_dsp.c"
122#include "echoaudio_gml.c"
123#include "echoaudio.c"
diff --git a/sound/pci/echoaudio/gina24_dsp.c b/sound/pci/echoaudio/gina24_dsp.c
new file mode 100644
index 000000000000..144fc567becf
--- /dev/null
+++ b/sound/pci/echoaudio/gina24_dsp.c
@@ -0,0 +1,346 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int write_control_reg(struct echoaudio *chip, u32 value, char force);
33static int set_input_clock(struct echoaudio *chip, u16 clock);
34static int set_professional_spdif(struct echoaudio *chip, char prof);
35static int set_digital_mode(struct echoaudio *chip, u8 mode);
36static int load_asic_generic(struct echoaudio *chip, u32 cmd,
37 const struct firmware *asic);
38static int check_asic_status(struct echoaudio *chip);
39
40
41static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
42{
43 int err;
44
45 DE_INIT(("init_hw() - Gina24\n"));
46 snd_assert((subdevice_id & 0xfff0) == GINA24, return -ENODEV);
47
48 if ((err = init_dsp_comm_page(chip))) {
49 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
50 return err;
51 }
52
53 chip->device_id = device_id;
54 chip->subdevice_id = subdevice_id;
55 chip->bad_board = TRUE;
56 chip->input_clock_types =
57 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF |
58 ECHO_CLOCK_BIT_ESYNC | ECHO_CLOCK_BIT_ESYNC96 |
59 ECHO_CLOCK_BIT_ADAT;
60 chip->professional_spdif = FALSE;
61 chip->digital_in_automute = TRUE;
62 chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
63
64 /* Gina24 comes in both '301 and '361 flavors */
65 if (chip->device_id == DEVICE_ID_56361) {
66 chip->dsp_code_to_load = &card_fw[FW_GINA24_361_DSP];
67 chip->digital_modes =
68 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
69 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
70 ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
71 } else {
72 chip->dsp_code_to_load = &card_fw[FW_GINA24_301_DSP];
73 chip->digital_modes =
74 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
75 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
76 ECHOCAPS_HAS_DIGITAL_MODE_ADAT |
77 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM;
78 }
79
80 if ((err = load_firmware(chip)) < 0)
81 return err;
82 chip->bad_board = FALSE;
83
84 if ((err = init_line_levels(chip)) < 0)
85 return err;
86 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
87 snd_assert(err >= 0, return err);
88 err = set_professional_spdif(chip, TRUE);
89
90 DE_INIT(("init_hw done\n"));
91 return err;
92}
93
94
95
96static u32 detect_input_clocks(const struct echoaudio *chip)
97{
98 u32 clocks_from_dsp, clock_bits;
99
100 /* Map the DSP clock detect bits to the generic driver clock
101 detect bits */
102 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
103
104 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
105
106 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_SPDIF)
107 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
108
109 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_ADAT)
110 clock_bits |= ECHO_CLOCK_BIT_ADAT;
111
112 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_ESYNC)
113 clock_bits |= ECHO_CLOCK_BIT_ESYNC | ECHO_CLOCK_BIT_ESYNC96;
114
115 return clock_bits;
116}
117
118
119
120/* Gina24 has an ASIC on the PCI card which must be loaded for anything
121interesting to happen. */
122static int load_asic(struct echoaudio *chip)
123{
124 u32 control_reg;
125 int err;
126 const struct firmware *fw;
127
128 if (chip->asic_loaded)
129 return 1;
130
131 /* Give the DSP a few milliseconds to settle down */
132 mdelay(10);
133
134 /* Pick the correct ASIC for '301 or '361 Gina24 */
135 if (chip->device_id == DEVICE_ID_56361)
136 fw = &card_fw[FW_GINA24_361_ASIC];
137 else
138 fw = &card_fw[FW_GINA24_301_ASIC];
139
140 if ((err = load_asic_generic(chip, DSP_FNC_LOAD_GINA24_ASIC, fw)) < 0)
141 return err;
142
143 chip->asic_code = fw;
144
145 /* Now give the new ASIC a little time to set up */
146 mdelay(10);
147 /* See if it worked */
148 err = check_asic_status(chip);
149
150 /* Set up the control register if the load succeeded -
151 48 kHz, internal clock, S/PDIF RCA mode */
152 if (!err) {
153 control_reg = GML_CONVERTER_ENABLE | GML_48KHZ;
154 err = write_control_reg(chip, control_reg, TRUE);
155 }
156 DE_INIT(("load_asic() done\n"));
157 return err;
158}
159
160
161
162static int set_sample_rate(struct echoaudio *chip, u32 rate)
163{
164 u32 control_reg, clock;
165
166 snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT,
167 return -EINVAL);
168
169 /* Only set the clock for internal mode. */
170 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
171 DE_ACT(("set_sample_rate: Cannot set sample rate - "
172 "clock not set to CLK_CLOCKININTERNAL\n"));
173 /* Save the rate anyhow */
174 chip->comm_page->sample_rate = cpu_to_le32(rate);
175 chip->sample_rate = rate;
176 return 0;
177 }
178
179 clock = 0;
180
181 control_reg = le32_to_cpu(chip->comm_page->control_register);
182 control_reg &= GML_CLOCK_CLEAR_MASK & GML_SPDIF_RATE_CLEAR_MASK;
183
184 switch (rate) {
185 case 96000:
186 clock = GML_96KHZ;
187 break;
188 case 88200:
189 clock = GML_88KHZ;
190 break;
191 case 48000:
192 clock = GML_48KHZ | GML_SPDIF_SAMPLE_RATE1;
193 break;
194 case 44100:
195 clock = GML_44KHZ;
196 /* Professional mode ? */
197 if (control_reg & GML_SPDIF_PRO_MODE)
198 clock |= GML_SPDIF_SAMPLE_RATE0;
199 break;
200 case 32000:
201 clock = GML_32KHZ | GML_SPDIF_SAMPLE_RATE0 |
202 GML_SPDIF_SAMPLE_RATE1;
203 break;
204 case 22050:
205 clock = GML_22KHZ;
206 break;
207 case 16000:
208 clock = GML_16KHZ;
209 break;
210 case 11025:
211 clock = GML_11KHZ;
212 break;
213 case 8000:
214 clock = GML_8KHZ;
215 break;
216 default:
217 DE_ACT(("set_sample_rate: %d invalid!\n", rate));
218 return -EINVAL;
219 }
220
221 control_reg |= clock;
222
223 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */
224 chip->sample_rate = rate;
225 DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));
226
227 return write_control_reg(chip, control_reg, FALSE);
228}
229
230
231
232static int set_input_clock(struct echoaudio *chip, u16 clock)
233{
234 u32 control_reg, clocks_from_dsp;
235
236 DE_ACT(("set_input_clock:\n"));
237
238 /* Mask off the clock select bits */
239 control_reg = le32_to_cpu(chip->comm_page->control_register) &
240 GML_CLOCK_CLEAR_MASK;
241 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
242
243 switch (clock) {
244 case ECHO_CLOCK_INTERNAL:
245 DE_ACT(("Set Gina24 clock to INTERNAL\n"));
246 chip->input_clock = ECHO_CLOCK_INTERNAL;
247 return set_sample_rate(chip, chip->sample_rate);
248 case ECHO_CLOCK_SPDIF:
249 if (chip->digital_mode == DIGITAL_MODE_ADAT)
250 return -EAGAIN;
251 DE_ACT(("Set Gina24 clock to SPDIF\n"));
252 control_reg |= GML_SPDIF_CLOCK;
253 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_SPDIF96)
254 control_reg |= GML_DOUBLE_SPEED_MODE;
255 else
256 control_reg &= ~GML_DOUBLE_SPEED_MODE;
257 break;
258 case ECHO_CLOCK_ADAT:
259 if (chip->digital_mode != DIGITAL_MODE_ADAT)
260 return -EAGAIN;
261 DE_ACT(("Set Gina24 clock to ADAT\n"));
262 control_reg |= GML_ADAT_CLOCK;
263 control_reg &= ~GML_DOUBLE_SPEED_MODE;
264 break;
265 case ECHO_CLOCK_ESYNC:
266 DE_ACT(("Set Gina24 clock to ESYNC\n"));
267 control_reg |= GML_ESYNC_CLOCK;
268 control_reg &= ~GML_DOUBLE_SPEED_MODE;
269 break;
270 case ECHO_CLOCK_ESYNC96:
271 DE_ACT(("Set Gina24 clock to ESYNC96\n"));
272 control_reg |= GML_ESYNC_CLOCK | GML_DOUBLE_SPEED_MODE;
273 break;
274 default:
275 DE_ACT(("Input clock 0x%x not supported for Gina24\n", clock));
276 return -EINVAL;
277 }
278
279 chip->input_clock = clock;
280 return write_control_reg(chip, control_reg, TRUE);
281}
282
283
284
285static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
286{
287 u32 control_reg;
288 int err, incompatible_clock;
289
290 /* Set clock to "internal" if it's not compatible with the new mode */
291 incompatible_clock = FALSE;
292 switch (mode) {
293 case DIGITAL_MODE_SPDIF_OPTICAL:
294 case DIGITAL_MODE_SPDIF_CDROM:
295 case DIGITAL_MODE_SPDIF_RCA:
296 if (chip->input_clock == ECHO_CLOCK_ADAT)
297 incompatible_clock = TRUE;
298 break;
299 case DIGITAL_MODE_ADAT:
300 if (chip->input_clock == ECHO_CLOCK_SPDIF)
301 incompatible_clock = TRUE;
302 break;
303 default:
304 DE_ACT(("Digital mode not supported: %d\n", mode));
305 return -EINVAL;
306 }
307
308 spin_lock_irq(&chip->lock);
309
310 if (incompatible_clock) { /* Switch to 48KHz, internal */
311 chip->sample_rate = 48000;
312 set_input_clock(chip, ECHO_CLOCK_INTERNAL);
313 }
314
315 /* Clear the current digital mode */
316 control_reg = le32_to_cpu(chip->comm_page->control_register);
317 control_reg &= GML_DIGITAL_MODE_CLEAR_MASK;
318
319 /* Tweak the control reg */
320 switch (mode) {
321 case DIGITAL_MODE_SPDIF_OPTICAL:
322 control_reg |= GML_SPDIF_OPTICAL_MODE;
323 break;
324 case DIGITAL_MODE_SPDIF_CDROM:
325 /* '361 Gina24 cards do not have the S/PDIF CD-ROM mode */
326 if (chip->device_id == DEVICE_ID_56301)
327 control_reg |= GML_SPDIF_CDROM_MODE;
328 break;
329 case DIGITAL_MODE_SPDIF_RCA:
330 /* GML_SPDIF_OPTICAL_MODE bit cleared */
331 break;
332 case DIGITAL_MODE_ADAT:
333 control_reg |= GML_ADAT_MODE;
334 control_reg &= ~GML_DOUBLE_SPEED_MODE;
335 break;
336 }
337
338 err = write_control_reg(chip, control_reg, TRUE);
339 spin_unlock_irq(&chip->lock);
340 if (err < 0)
341 return err;
342 chip->digital_mode = mode;
343
344 DE_ACT(("set_digital_mode to %d\n", chip->digital_mode));
345 return incompatible_clock;
346}
diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c
new file mode 100644
index 000000000000..bfd2467099ac
--- /dev/null
+++ b/sound/pci/echoaudio/indigo.c
@@ -0,0 +1,104 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define INDIGO_FAMILY
20#define ECHOCARD_INDIGO
21#define ECHOCARD_NAME "Indigo"
22#define ECHOCARD_HAS_SUPER_INTERLEAVE
23#define ECHOCARD_HAS_VMIXER
24#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
25
26/* Pipe indexes */
27#define PX_ANALOG_OUT 0 /* 8 */
28#define PX_DIGITAL_OUT 8 /* 0 */
29#define PX_ANALOG_IN 8 /* 0 */
30#define PX_DIGITAL_IN 8 /* 0 */
31#define PX_NUM 8
32
33/* Bus indexes */
34#define BX_ANALOG_OUT 0 /* 2 */
35#define BX_DIGITAL_OUT 2 /* 0 */
36#define BX_ANALOG_IN 2 /* 0 */
37#define BX_DIGITAL_IN 2 /* 0 */
38#define BX_NUM 2
39
40
41#include <sound/driver.h>
42#include <linux/delay.h>
43#include <linux/init.h>
44#include <linux/interrupt.h>
45#include <linux/pci.h>
46#include <linux/slab.h>
47#include <linux/moduleparam.h>
48#include <linux/firmware.h>
49#include <sound/core.h>
50#include <sound/info.h>
51#include <sound/control.h>
52#include <sound/pcm.h>
53#include <sound/pcm_params.h>
54#include <sound/asoundef.h>
55#include <sound/initval.h>
56#include <asm/io.h>
57#include <asm/atomic.h>
58#include "echoaudio.h"
59
60#define FW_361_LOADER 0
61#define FW_INDIGO_DSP 1
62
63static const struct firmware card_fw[] = {
64 {0, "loader_dsp.fw"},
65 {0, "indigo_dsp.fw"}
66};
67
68static struct pci_device_id snd_echo_ids[] = {
69 {0x1057, 0x3410, 0xECC0, 0x0090, 0, 0, 0}, /* Indigo */
70 {0,}
71};
72
73static struct snd_pcm_hardware pcm_hardware_skel = {
74 .info = SNDRV_PCM_INFO_MMAP |
75 SNDRV_PCM_INFO_INTERLEAVED |
76 SNDRV_PCM_INFO_BLOCK_TRANSFER |
77 SNDRV_PCM_INFO_MMAP_VALID |
78 SNDRV_PCM_INFO_PAUSE |
79 SNDRV_PCM_INFO_SYNC_START,
80 .formats = SNDRV_PCM_FMTBIT_U8 |
81 SNDRV_PCM_FMTBIT_S16_LE |
82 SNDRV_PCM_FMTBIT_S24_3LE |
83 SNDRV_PCM_FMTBIT_S32_LE |
84 SNDRV_PCM_FMTBIT_S32_BE,
85 .rates = SNDRV_PCM_RATE_32000 |
86 SNDRV_PCM_RATE_44100 |
87 SNDRV_PCM_RATE_48000 |
88 SNDRV_PCM_RATE_88200 |
89 SNDRV_PCM_RATE_96000,
90 .rate_min = 32000,
91 .rate_max = 96000,
92 .channels_min = 1,
93 .channels_max = 8,
94 .buffer_bytes_max = 262144,
95 .period_bytes_min = 32,
96 .period_bytes_max = 131072,
97 .periods_min = 2,
98 .periods_max = 220,
99};
100
101#include "indigo_dsp.c"
102#include "echoaudio_dsp.c"
103#include "echoaudio.c"
104
diff --git a/sound/pci/echoaudio/indigo_dsp.c b/sound/pci/echoaudio/indigo_dsp.c
new file mode 100644
index 000000000000..d6ac7734609e
--- /dev/null
+++ b/sound/pci/echoaudio/indigo_dsp.c
@@ -0,0 +1,170 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
33 int gain);
34static int update_vmixer_level(struct echoaudio *chip);
35
36
37static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
38{
39 int err;
40
41 DE_INIT(("init_hw() - Indigo\n"));
42 snd_assert((subdevice_id & 0xfff0) == INDIGO, return -ENODEV);
43
44 if ((err = init_dsp_comm_page(chip))) {
45 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
46 return err;
47 }
48
49 chip->device_id = device_id;
50 chip->subdevice_id = subdevice_id;
51 chip->bad_board = TRUE;
52 chip->dsp_code_to_load = &card_fw[FW_INDIGO_DSP];
53 /* Since this card has no ASIC, mark it as loaded so everything
54 works OK */
55 chip->asic_loaded = TRUE;
56 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
57
58 if ((err = load_firmware(chip)) < 0)
59 return err;
60 chip->bad_board = FALSE;
61
62 if ((err = init_line_levels(chip)) < 0)
63 return err;
64
65 /* Default routing of the virtual channels: all vchannels are routed
66 to the stereo output */
67 set_vmixer_gain(chip, 0, 0, 0);
68 set_vmixer_gain(chip, 1, 1, 0);
69 set_vmixer_gain(chip, 0, 2, 0);
70 set_vmixer_gain(chip, 1, 3, 0);
71 set_vmixer_gain(chip, 0, 4, 0);
72 set_vmixer_gain(chip, 1, 5, 0);
73 set_vmixer_gain(chip, 0, 6, 0);
74 set_vmixer_gain(chip, 1, 7, 0);
75 err = update_vmixer_level(chip);
76
77 DE_INIT(("init_hw done\n"));
78 return err;
79}
80
81
82
83static u32 detect_input_clocks(const struct echoaudio *chip)
84{
85 return ECHO_CLOCK_BIT_INTERNAL;
86}
87
88
89
90/* The Indigo has no ASIC. Just do nothing */
91static int load_asic(struct echoaudio *chip)
92{
93 return 0;
94}
95
96
97
98static int set_sample_rate(struct echoaudio *chip, u32 rate)
99{
100 u32 control_reg;
101
102 switch (rate) {
103 case 96000:
104 control_reg = MIA_96000;
105 break;
106 case 88200:
107 control_reg = MIA_88200;
108 break;
109 case 48000:
110 control_reg = MIA_48000;
111 break;
112 case 44100:
113 control_reg = MIA_44100;
114 break;
115 case 32000:
116 control_reg = MIA_32000;
117 break;
118 default:
119 DE_ACT(("set_sample_rate: %d invalid!\n", rate));
120 return -EINVAL;
121 }
122
123 /* Set the control register if it has changed */
124 if (control_reg != le32_to_cpu(chip->comm_page->control_register)) {
125 if (wait_handshake(chip))
126 return -EIO;
127
128 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */
129 chip->comm_page->control_register = cpu_to_le32(control_reg);
130 chip->sample_rate = rate;
131
132 clear_handshake(chip);
133 return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
134 }
135 return 0;
136}
137
138
139
140/* This function routes the sound from a virtual channel to a real output */
141static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
142 int gain)
143{
144 int index;
145
146 snd_assert(pipe < num_pipes_out(chip) &&
147 output < num_busses_out(chip), return -EINVAL);
148
149 if (wait_handshake(chip))
150 return -EIO;
151
152 chip->vmixer_gain[output][pipe] = gain;
153 index = output * num_pipes_out(chip) + pipe;
154 chip->comm_page->vmixer[index] = gain;
155
156 DE_ACT(("set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain));
157 return 0;
158}
159
160
161
162/* Tell the DSP to read and update virtual mixer levels in comm page. */
163static int update_vmixer_level(struct echoaudio *chip)
164{
165 if (wait_handshake(chip))
166 return -EIO;
167 clear_handshake(chip);
168 return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
169}
170
diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c
new file mode 100644
index 000000000000..8ed7ff1fd875
--- /dev/null
+++ b/sound/pci/echoaudio/indigodj.c
@@ -0,0 +1,104 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define INDIGO_FAMILY
20#define ECHOCARD_INDIGO_DJ
21#define ECHOCARD_NAME "Indigo DJ"
22#define ECHOCARD_HAS_SUPER_INTERLEAVE
23#define ECHOCARD_HAS_VMIXER
24#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
25
26/* Pipe indexes */
27#define PX_ANALOG_OUT 0 /* 8 */
28#define PX_DIGITAL_OUT 8 /* 0 */
29#define PX_ANALOG_IN 8 /* 0 */
30#define PX_DIGITAL_IN 8 /* 0 */
31#define PX_NUM 8
32
33/* Bus indexes */
34#define BX_ANALOG_OUT 0 /* 4 */
35#define BX_DIGITAL_OUT 4 /* 0 */
36#define BX_ANALOG_IN 4 /* 0 */
37#define BX_DIGITAL_IN 4 /* 0 */
38#define BX_NUM 4
39
40
41#include <sound/driver.h>
42#include <linux/delay.h>
43#include <linux/init.h>
44#include <linux/interrupt.h>
45#include <linux/pci.h>
46#include <linux/slab.h>
47#include <linux/moduleparam.h>
48#include <linux/firmware.h>
49#include <sound/core.h>
50#include <sound/info.h>
51#include <sound/control.h>
52#include <sound/pcm.h>
53#include <sound/pcm_params.h>
54#include <sound/asoundef.h>
55#include <sound/initval.h>
56#include <asm/io.h>
57#include <asm/atomic.h>
58#include "echoaudio.h"
59
60#define FW_361_LOADER 0
61#define FW_INDIGO_DJ_DSP 1
62
63static const struct firmware card_fw[] = {
64 {0, "loader_dsp.fw"},
65 {0, "indigo_dj_dsp.fw"}
66};
67
68static struct pci_device_id snd_echo_ids[] = {
69 {0x1057, 0x3410, 0xECC0, 0x00B0, 0, 0, 0}, /* Indigo DJ*/
70 {0,}
71};
72
73static struct snd_pcm_hardware pcm_hardware_skel = {
74 .info = SNDRV_PCM_INFO_MMAP |
75 SNDRV_PCM_INFO_INTERLEAVED |
76 SNDRV_PCM_INFO_BLOCK_TRANSFER |
77 SNDRV_PCM_INFO_MMAP_VALID |
78 SNDRV_PCM_INFO_PAUSE |
79 SNDRV_PCM_INFO_SYNC_START,
80 .formats = SNDRV_PCM_FMTBIT_U8 |
81 SNDRV_PCM_FMTBIT_S16_LE |
82 SNDRV_PCM_FMTBIT_S24_3LE |
83 SNDRV_PCM_FMTBIT_S32_LE |
84 SNDRV_PCM_FMTBIT_S32_BE,
85 .rates = SNDRV_PCM_RATE_32000 |
86 SNDRV_PCM_RATE_44100 |
87 SNDRV_PCM_RATE_48000 |
88 SNDRV_PCM_RATE_88200 |
89 SNDRV_PCM_RATE_96000,
90 .rate_min = 32000,
91 .rate_max = 96000,
92 .channels_min = 1,
93 .channels_max = 4,
94 .buffer_bytes_max = 262144,
95 .period_bytes_min = 32,
96 .period_bytes_max = 131072,
97 .periods_min = 2,
98 .periods_max = 220,
99};
100
101#include "indigodj_dsp.c"
102#include "echoaudio_dsp.c"
103#include "echoaudio.c"
104
diff --git a/sound/pci/echoaudio/indigodj_dsp.c b/sound/pci/echoaudio/indigodj_dsp.c
new file mode 100644
index 000000000000..500e150b49fc
--- /dev/null
+++ b/sound/pci/echoaudio/indigodj_dsp.c
@@ -0,0 +1,170 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
33 int gain);
34static int update_vmixer_level(struct echoaudio *chip);
35
36
37static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
38{
39 int err;
40
41 DE_INIT(("init_hw() - Indigo DJ\n"));
42 snd_assert((subdevice_id & 0xfff0) == INDIGO_DJ, return -ENODEV);
43
44 if ((err = init_dsp_comm_page(chip))) {
45 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
46 return err;
47 }
48
49 chip->device_id = device_id;
50 chip->subdevice_id = subdevice_id;
51 chip->bad_board = TRUE;
52 chip->dsp_code_to_load = &card_fw[FW_INDIGO_DJ_DSP];
53 /* Since this card has no ASIC, mark it as loaded so everything
54 works OK */
55 chip->asic_loaded = TRUE;
56 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
57
58 if ((err = load_firmware(chip)) < 0)
59 return err;
60 chip->bad_board = FALSE;
61
62 if ((err = init_line_levels(chip)) < 0)
63 return err;
64
65 /* Default routing of the virtual channels: vchannels 0-3 and
66 vchannels 4-7 are routed to real channels 0-4 */
67 set_vmixer_gain(chip, 0, 0, 0);
68 set_vmixer_gain(chip, 1, 1, 0);
69 set_vmixer_gain(chip, 2, 2, 0);
70 set_vmixer_gain(chip, 3, 3, 0);
71 set_vmixer_gain(chip, 0, 4, 0);
72 set_vmixer_gain(chip, 1, 5, 0);
73 set_vmixer_gain(chip, 2, 6, 0);
74 set_vmixer_gain(chip, 3, 7, 0);
75 err = update_vmixer_level(chip);
76
77 DE_INIT(("init_hw done\n"));
78 return err;
79}
80
81
82
83static u32 detect_input_clocks(const struct echoaudio *chip)
84{
85 return ECHO_CLOCK_BIT_INTERNAL;
86}
87
88
89
90/* The IndigoDJ has no ASIC. Just do nothing */
91static int load_asic(struct echoaudio *chip)
92{
93 return 0;
94}
95
96
97
98static int set_sample_rate(struct echoaudio *chip, u32 rate)
99{
100 u32 control_reg;
101
102 switch (rate) {
103 case 96000:
104 control_reg = MIA_96000;
105 break;
106 case 88200:
107 control_reg = MIA_88200;
108 break;
109 case 48000:
110 control_reg = MIA_48000;
111 break;
112 case 44100:
113 control_reg = MIA_44100;
114 break;
115 case 32000:
116 control_reg = MIA_32000;
117 break;
118 default:
119 DE_ACT(("set_sample_rate: %d invalid!\n", rate));
120 return -EINVAL;
121 }
122
123 /* Set the control register if it has changed */
124 if (control_reg != le32_to_cpu(chip->comm_page->control_register)) {
125 if (wait_handshake(chip))
126 return -EIO;
127
128 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */
129 chip->comm_page->control_register = cpu_to_le32(control_reg);
130 chip->sample_rate = rate;
131
132 clear_handshake(chip);
133 return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
134 }
135 return 0;
136}
137
138
139
140/* This function routes the sound from a virtual channel to a real output */
141static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
142 int gain)
143{
144 int index;
145
146 snd_assert(pipe < num_pipes_out(chip) &&
147 output < num_busses_out(chip), return -EINVAL);
148
149 if (wait_handshake(chip))
150 return -EIO;
151
152 chip->vmixer_gain[output][pipe] = gain;
153 index = output * num_pipes_out(chip) + pipe;
154 chip->comm_page->vmixer[index] = gain;
155
156 DE_ACT(("set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain));
157 return 0;
158}
159
160
161
162/* Tell the DSP to read and update virtual mixer levels in comm page. */
163static int update_vmixer_level(struct echoaudio *chip)
164{
165 if (wait_handshake(chip))
166 return -EIO;
167 clear_handshake(chip);
168 return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
169}
170
diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c
new file mode 100644
index 000000000000..a8788e959171
--- /dev/null
+++ b/sound/pci/echoaudio/indigoio.c
@@ -0,0 +1,105 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define INDIGO_FAMILY
20#define ECHOCARD_INDIGO_IO
21#define ECHOCARD_NAME "Indigo IO"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_SUPER_INTERLEAVE
24#define ECHOCARD_HAS_VMIXER
25#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
26
27/* Pipe indexes */
28#define PX_ANALOG_OUT 0 /* 8 */
29#define PX_DIGITAL_OUT 8 /* 0 */
30#define PX_ANALOG_IN 8 /* 2 */
31#define PX_DIGITAL_IN 10 /* 0 */
32#define PX_NUM 10
33
34/* Bus indexes */
35#define BX_ANALOG_OUT 0 /* 2 */
36#define BX_DIGITAL_OUT 2 /* 0 */
37#define BX_ANALOG_IN 2 /* 2 */
38#define BX_DIGITAL_IN 4 /* 0 */
39#define BX_NUM 4
40
41
42#include <sound/driver.h>
43#include <linux/delay.h>
44#include <linux/init.h>
45#include <linux/interrupt.h>
46#include <linux/pci.h>
47#include <linux/slab.h>
48#include <linux/moduleparam.h>
49#include <linux/firmware.h>
50#include <sound/core.h>
51#include <sound/info.h>
52#include <sound/control.h>
53#include <sound/pcm.h>
54#include <sound/pcm_params.h>
55#include <sound/asoundef.h>
56#include <sound/initval.h>
57#include <asm/io.h>
58#include <asm/atomic.h>
59#include "echoaudio.h"
60
61#define FW_361_LOADER 0
62#define FW_INDIGO_IO_DSP 1
63
64static const struct firmware card_fw[] = {
65 {0, "loader_dsp.fw"},
66 {0, "indigo_io_dsp.fw"}
67};
68
69static struct pci_device_id snd_echo_ids[] = {
70 {0x1057, 0x3410, 0xECC0, 0x00A0, 0, 0, 0}, /* Indigo IO*/
71 {0,}
72};
73
74static struct snd_pcm_hardware pcm_hardware_skel = {
75 .info = SNDRV_PCM_INFO_MMAP |
76 SNDRV_PCM_INFO_INTERLEAVED |
77 SNDRV_PCM_INFO_BLOCK_TRANSFER |
78 SNDRV_PCM_INFO_MMAP_VALID |
79 SNDRV_PCM_INFO_PAUSE |
80 SNDRV_PCM_INFO_SYNC_START,
81 .formats = SNDRV_PCM_FMTBIT_U8 |
82 SNDRV_PCM_FMTBIT_S16_LE |
83 SNDRV_PCM_FMTBIT_S24_3LE |
84 SNDRV_PCM_FMTBIT_S32_LE |
85 SNDRV_PCM_FMTBIT_S32_BE,
86 .rates = SNDRV_PCM_RATE_32000 |
87 SNDRV_PCM_RATE_44100 |
88 SNDRV_PCM_RATE_48000 |
89 SNDRV_PCM_RATE_88200 |
90 SNDRV_PCM_RATE_96000,
91 .rate_min = 32000,
92 .rate_max = 96000,
93 .channels_min = 1,
94 .channels_max = 8,
95 .buffer_bytes_max = 262144,
96 .period_bytes_min = 32,
97 .period_bytes_max = 131072,
98 .periods_min = 2,
99 .periods_max = 220,
100};
101
102#include "indigoio_dsp.c"
103#include "echoaudio_dsp.c"
104#include "echoaudio.c"
105
diff --git a/sound/pci/echoaudio/indigoio_dsp.c b/sound/pci/echoaudio/indigoio_dsp.c
new file mode 100644
index 000000000000..f3ad13d06be0
--- /dev/null
+++ b/sound/pci/echoaudio/indigoio_dsp.c
@@ -0,0 +1,141 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
33 int gain);
34static int update_vmixer_level(struct echoaudio *chip);
35
36
37static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
38{
39 int err;
40
41 DE_INIT(("init_hw() - Indigo IO\n"));
42 snd_assert((subdevice_id & 0xfff0) == INDIGO_IO, return -ENODEV);
43
44 if ((err = init_dsp_comm_page(chip))) {
45 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
46 return err;
47 }
48
49 chip->device_id = device_id;
50 chip->subdevice_id = subdevice_id;
51 chip->bad_board = TRUE;
52 chip->dsp_code_to_load = &card_fw[FW_INDIGO_IO_DSP];
53 /* Since this card has no ASIC, mark it as loaded so everything
54 works OK */
55 chip->asic_loaded = TRUE;
56 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
57
58 if ((err = load_firmware(chip)) < 0)
59 return err;
60 chip->bad_board = FALSE;
61
62 if ((err = init_line_levels(chip)) < 0)
63 return err;
64
65 /* Default routing of the virtual channels: all vchannels are routed
66 to the stereo output */
67 set_vmixer_gain(chip, 0, 0, 0);
68 set_vmixer_gain(chip, 1, 1, 0);
69 set_vmixer_gain(chip, 0, 2, 0);
70 set_vmixer_gain(chip, 1, 3, 0);
71 set_vmixer_gain(chip, 0, 4, 0);
72 set_vmixer_gain(chip, 1, 5, 0);
73 set_vmixer_gain(chip, 0, 6, 0);
74 set_vmixer_gain(chip, 1, 7, 0);
75 err = update_vmixer_level(chip);
76
77 DE_INIT(("init_hw done\n"));
78 return err;
79}
80
81
82
83static u32 detect_input_clocks(const struct echoaudio *chip)
84{
85 return ECHO_CLOCK_BIT_INTERNAL;
86}
87
88
89
90/* The IndigoIO has no ASIC. Just do nothing */
91static int load_asic(struct echoaudio *chip)
92{
93 return 0;
94}
95
96
97
98static int set_sample_rate(struct echoaudio *chip, u32 rate)
99{
100 if (wait_handshake(chip))
101 return -EIO;
102
103 chip->sample_rate = rate;
104 chip->comm_page->sample_rate = cpu_to_le32(rate);
105 clear_handshake(chip);
106 return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
107}
108
109
110
111/* This function routes the sound from a virtual channel to a real output */
112static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
113 int gain)
114{
115 int index;
116
117 snd_assert(pipe < num_pipes_out(chip) &&
118 output < num_busses_out(chip), return -EINVAL);
119
120 if (wait_handshake(chip))
121 return -EIO;
122
123 chip->vmixer_gain[output][pipe] = gain;
124 index = output * num_pipes_out(chip) + pipe;
125 chip->comm_page->vmixer[index] = gain;
126
127 DE_ACT(("set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain));
128 return 0;
129}
130
131
132
133/* Tell the DSP to read and update virtual mixer levels in comm page. */
134static int update_vmixer_level(struct echoaudio *chip)
135{
136 if (wait_handshake(chip))
137 return -EIO;
138 clear_handshake(chip);
139 return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
140}
141
diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c
new file mode 100644
index 000000000000..e503d74b3ba9
--- /dev/null
+++ b/sound/pci/echoaudio/layla20.c
@@ -0,0 +1,112 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHOGALS_FAMILY
20#define ECHOCARD_LAYLA20
21#define ECHOCARD_NAME "Layla20"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_ASIC
24#define ECHOCARD_HAS_INPUT_GAIN
25#define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
26#define ECHOCARD_HAS_SUPER_INTERLEAVE
27#define ECHOCARD_HAS_DIGITAL_IO
28#define ECHOCARD_HAS_EXTERNAL_CLOCK
29#define ECHOCARD_HAS_ADAT FALSE
30#define ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH
31#define ECHOCARD_HAS_MIDI
32
33/* Pipe indexes */
34#define PX_ANALOG_OUT 0 /* 10 */
35#define PX_DIGITAL_OUT 10 /* 2 */
36#define PX_ANALOG_IN 12 /* 8 */
37#define PX_DIGITAL_IN 20 /* 2 */
38#define PX_NUM 22
39
40/* Bus indexes */
41#define BX_ANALOG_OUT 0 /* 10 */
42#define BX_DIGITAL_OUT 10 /* 2 */
43#define BX_ANALOG_IN 12 /* 8 */
44#define BX_DIGITAL_IN 20 /* 2 */
45#define BX_NUM 22
46
47
48#include <sound/driver.h>
49#include <linux/delay.h>
50#include <linux/init.h>
51#include <linux/interrupt.h>
52#include <linux/pci.h>
53#include <linux/slab.h>
54#include <linux/moduleparam.h>
55#include <linux/firmware.h>
56#include <sound/core.h>
57#include <sound/info.h>
58#include <sound/control.h>
59#include <sound/pcm.h>
60#include <sound/pcm_params.h>
61#include <sound/asoundef.h>
62#include <sound/initval.h>
63#include <sound/rawmidi.h>
64#include <asm/io.h>
65#include <asm/atomic.h>
66#include "echoaudio.h"
67
68#define FW_LAYLA20_DSP 0
69#define FW_LAYLA20_ASIC 1
70
71static const struct firmware card_fw[] = {
72 {0, "layla20_dsp.fw"},
73 {0, "layla20_asic.fw"}
74};
75
76static struct pci_device_id snd_echo_ids[] = {
77 {0x1057, 0x1801, 0xECC0, 0x0030, 0, 0, 0}, /* DSP 56301 Layla20 rev.0 */
78 {0x1057, 0x1801, 0xECC0, 0x0031, 0, 0, 0}, /* DSP 56301 Layla20 rev.1 */
79 {0,}
80};
81
82static struct snd_pcm_hardware pcm_hardware_skel = {
83 .info = SNDRV_PCM_INFO_MMAP |
84 SNDRV_PCM_INFO_INTERLEAVED |
85 SNDRV_PCM_INFO_BLOCK_TRANSFER |
86 SNDRV_PCM_INFO_MMAP_VALID |
87 SNDRV_PCM_INFO_PAUSE |
88 SNDRV_PCM_INFO_SYNC_START,
89 .formats = SNDRV_PCM_FMTBIT_U8 |
90 SNDRV_PCM_FMTBIT_S16_LE |
91 SNDRV_PCM_FMTBIT_S24_3LE |
92 SNDRV_PCM_FMTBIT_S32_LE |
93 SNDRV_PCM_FMTBIT_S32_BE,
94 .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_CONTINUOUS,
95 .rate_min = 8000,
96 .rate_max = 50000,
97 .channels_min = 1,
98 .channels_max = 10,
99 .buffer_bytes_max = 262144,
100 .period_bytes_min = 32,
101 .period_bytes_max = 131072,
102 .periods_min = 2,
103 .periods_max = 220,
104 /* One page (4k) contains 512 instructions. I don't know if the hw
105 supports lists longer than this. In this case periods_max=220 is a
106 safe limit to make sure the list never exceeds 512 instructions. */
107};
108
109#include "layla20_dsp.c"
110#include "echoaudio_dsp.c"
111#include "echoaudio.c"
112#include "midi.c"
diff --git a/sound/pci/echoaudio/layla20_dsp.c b/sound/pci/echoaudio/layla20_dsp.c
new file mode 100644
index 000000000000..990c9a60a0a8
--- /dev/null
+++ b/sound/pci/echoaudio/layla20_dsp.c
@@ -0,0 +1,290 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int read_dsp(struct echoaudio *chip, u32 *data);
33static int set_professional_spdif(struct echoaudio *chip, char prof);
34static int load_asic_generic(struct echoaudio *chip, u32 cmd,
35 const struct firmware *asic);
36static int check_asic_status(struct echoaudio *chip);
37static int update_flags(struct echoaudio *chip);
38
39
40static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
41{
42 int err;
43
44 DE_INIT(("init_hw() - Layla20\n"));
45 snd_assert((subdevice_id & 0xfff0) == LAYLA20, return -ENODEV);
46
47 if ((err = init_dsp_comm_page(chip))) {
48 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
49 return err;
50 }
51
52 chip->device_id = device_id;
53 chip->subdevice_id = subdevice_id;
54 chip->bad_board = TRUE;
55 chip->has_midi = TRUE;
56 chip->dsp_code_to_load = &card_fw[FW_LAYLA20_DSP];
57 chip->input_clock_types =
58 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF |
59 ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER;
60 chip->output_clock_types =
61 ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER;
62
63 if ((err = load_firmware(chip)) < 0)
64 return err;
65 chip->bad_board = FALSE;
66
67 if ((err = init_line_levels(chip)) < 0)
68 return err;
69
70 err = set_professional_spdif(chip, TRUE);
71
72 DE_INIT(("init_hw done\n"));
73 return err;
74}
75
76
77
78static u32 detect_input_clocks(const struct echoaudio *chip)
79{
80 u32 clocks_from_dsp, clock_bits;
81
82 /* Map the DSP clock detect bits to the generic driver clock detect bits */
83 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
84
85 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
86
87 if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_SPDIF)
88 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
89
90 if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_WORD) {
91 if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_SUPER)
92 clock_bits |= ECHO_CLOCK_BIT_SUPER;
93 else
94 clock_bits |= ECHO_CLOCK_BIT_WORD;
95 }
96
97 return clock_bits;
98}
99
100
101
102/* ASIC status check - some cards have one or two ASICs that need to be
103loaded. Once that load is complete, this function is called to see if
104the load was successful.
105If this load fails, it does not necessarily mean that the hardware is
106defective - the external box may be disconnected or turned off.
107This routine sometimes fails for Layla20; for Layla20, the loop runs
1085 times and succeeds if it wins on three of the loops. */
109static int check_asic_status(struct echoaudio *chip)
110{
111 u32 asic_status;
112 int goodcnt, i;
113
114 chip->asic_loaded = FALSE;
115 for (i = goodcnt = 0; i < 5; i++) {
116 send_vector(chip, DSP_VC_TEST_ASIC);
117
118 /* The DSP will return a value to indicate whether or not
119 the ASIC is currently loaded */
120 if (read_dsp(chip, &asic_status) < 0) {
121 DE_ACT(("check_asic_status: failed on read_dsp\n"));
122 return -EIO;
123 }
124
125 if (asic_status == ASIC_ALREADY_LOADED) {
126 if (++goodcnt == 3) {
127 chip->asic_loaded = TRUE;
128 return 0;
129 }
130 }
131 }
132 return -EIO;
133}
134
135
136
137/* Layla20 has an ASIC in the external box */
138static int load_asic(struct echoaudio *chip)
139{
140 int err;
141
142 if (chip->asic_loaded)
143 return 0;
144
145 err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA_ASIC,
146 &card_fw[FW_LAYLA20_ASIC]);
147 if (err < 0)
148 return err;
149
150 /* Check if ASIC is alive and well. */
151 return check_asic_status(chip);
152}
153
154
155
156static int set_sample_rate(struct echoaudio *chip, u32 rate)
157{
158 snd_assert(rate >= 8000 && rate <= 50000, return -EINVAL);
159
160 /* Only set the clock for internal mode. Do not return failure,
161 simply treat it as a non-event. */
162 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
163 DE_ACT(("set_sample_rate: Cannot set sample rate - "
164 "clock not set to CLK_CLOCKININTERNAL\n"));
165 chip->comm_page->sample_rate = cpu_to_le32(rate);
166 chip->sample_rate = rate;
167 return 0;
168 }
169
170 if (wait_handshake(chip))
171 return -EIO;
172
173 DE_ACT(("set_sample_rate(%d)\n", rate));
174 chip->sample_rate = rate;
175 chip->comm_page->sample_rate = cpu_to_le32(rate);
176 clear_handshake(chip);
177 return send_vector(chip, DSP_VC_SET_LAYLA_SAMPLE_RATE);
178}
179
180
181
182static int set_input_clock(struct echoaudio *chip, u16 clock_source)
183{
184 u16 clock;
185 u32 rate;
186
187 DE_ACT(("set_input_clock:\n"));
188 rate = 0;
189 switch (clock_source) {
190 case ECHO_CLOCK_INTERNAL:
191 DE_ACT(("Set Layla20 clock to INTERNAL\n"));
192 rate = chip->sample_rate;
193 clock = LAYLA20_CLOCK_INTERNAL;
194 break;
195 case ECHO_CLOCK_SPDIF:
196 DE_ACT(("Set Layla20 clock to SPDIF\n"));
197 clock = LAYLA20_CLOCK_SPDIF;
198 break;
199 case ECHO_CLOCK_WORD:
200 DE_ACT(("Set Layla20 clock to WORD\n"));
201 clock = LAYLA20_CLOCK_WORD;
202 break;
203 case ECHO_CLOCK_SUPER:
204 DE_ACT(("Set Layla20 clock to SUPER\n"));
205 clock = LAYLA20_CLOCK_SUPER;
206 break;
207 default:
208 DE_ACT(("Input clock 0x%x not supported for Layla24\n",
209 clock_source));
210 return -EINVAL;
211 }
212 chip->input_clock = clock_source;
213
214 chip->comm_page->input_clock = cpu_to_le16(clock);
215 clear_handshake(chip);
216 send_vector(chip, DSP_VC_UPDATE_CLOCKS);
217
218 if (rate)
219 set_sample_rate(chip, rate);
220
221 return 0;
222}
223
224
225
226static int set_output_clock(struct echoaudio *chip, u16 clock)
227{
228 DE_ACT(("set_output_clock: %d\n", clock));
229 switch (clock) {
230 case ECHO_CLOCK_SUPER:
231 clock = LAYLA20_OUTPUT_CLOCK_SUPER;
232 break;
233 case ECHO_CLOCK_WORD:
234 clock = LAYLA20_OUTPUT_CLOCK_WORD;
235 break;
236 default:
237 DE_ACT(("set_output_clock wrong clock\n"));
238 return -EINVAL;
239 }
240
241 if (wait_handshake(chip))
242 return -EIO;
243
244 chip->comm_page->output_clock = cpu_to_le16(clock);
245 chip->output_clock = clock;
246 clear_handshake(chip);
247 return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
248}
249
250
251
252/* Set input bus gain (one unit is 0.5dB !) */
253static int set_input_gain(struct echoaudio *chip, u16 input, int gain)
254{
255 snd_assert(input < num_busses_in(chip), return -EINVAL);
256
257 if (wait_handshake(chip))
258 return -EIO;
259
260 chip->input_gain[input] = gain;
261 gain += GL20_INPUT_GAIN_MAGIC_NUMBER;
262 chip->comm_page->line_in_level[input] = gain;
263 return 0;
264}
265
266
267
268/* Tell the DSP to reread the flags from the comm page */
269static int update_flags(struct echoaudio *chip)
270{
271 if (wait_handshake(chip))
272 return -EIO;
273 clear_handshake(chip);
274 return send_vector(chip, DSP_VC_UPDATE_FLAGS);
275}
276
277
278
279static int set_professional_spdif(struct echoaudio *chip, char prof)
280{
281 DE_ACT(("set_professional_spdif %d\n", prof));
282 if (prof)
283 chip->comm_page->flags |=
284 __constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
285 else
286 chip->comm_page->flags &=
287 ~__constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
288 chip->professional_spdif = prof;
289 return update_flags(chip);
290}
diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c
new file mode 100644
index 000000000000..d4581fdc841c
--- /dev/null
+++ b/sound/pci/echoaudio/layla24.c
@@ -0,0 +1,121 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHO24_FAMILY
20#define ECHOCARD_LAYLA24
21#define ECHOCARD_NAME "Layla24"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_ASIC
24#define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
25#define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
26#define ECHOCARD_HAS_SUPER_INTERLEAVE
27#define ECHOCARD_HAS_DIGITAL_IO
28#define ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
29#define ECHOCARD_HAS_DIGITAL_MODE_SWITCH
30#define ECHOCARD_HAS_EXTERNAL_CLOCK
31#define ECHOCARD_HAS_ADAT 6
32#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
33#define ECHOCARD_HAS_MIDI
34
35/* Pipe indexes */
36#define PX_ANALOG_OUT 0 /* 8 */
37#define PX_DIGITAL_OUT 8 /* 8 */
38#define PX_ANALOG_IN 16 /* 8 */
39#define PX_DIGITAL_IN 24 /* 8 */
40#define PX_NUM 32
41
42/* Bus indexes */
43#define BX_ANALOG_OUT 0 /* 8 */
44#define BX_DIGITAL_OUT 8 /* 8 */
45#define BX_ANALOG_IN 16 /* 8 */
46#define BX_DIGITAL_IN 24 /* 8 */
47#define BX_NUM 32
48
49
50#include <sound/driver.h>
51#include <linux/delay.h>
52#include <linux/init.h>
53#include <linux/interrupt.h>
54#include <linux/pci.h>
55#include <linux/slab.h>
56#include <linux/moduleparam.h>
57#include <linux/firmware.h>
58#include <sound/core.h>
59#include <sound/info.h>
60#include <sound/control.h>
61#include <sound/pcm.h>
62#include <sound/pcm_params.h>
63#include <sound/asoundef.h>
64#include <sound/initval.h>
65#include <sound/rawmidi.h>
66#include <asm/io.h>
67#include <asm/atomic.h>
68#include "echoaudio.h"
69
70#define FW_361_LOADER 0
71#define FW_LAYLA24_DSP 1
72#define FW_LAYLA24_1_ASIC 2
73#define FW_LAYLA24_2A_ASIC 3
74#define FW_LAYLA24_2S_ASIC 4
75
76static const struct firmware card_fw[] = {
77 {0, "loader_dsp.fw"},
78 {0, "layla24_dsp.fw"},
79 {0, "layla24_1_asic.fw"},
80 {0, "layla24_2A_asic.fw"},
81 {0, "layla24_2S_asic.fw"}
82};
83
84static struct pci_device_id snd_echo_ids[] = {
85 {0x1057, 0x3410, 0xECC0, 0x0060, 0, 0, 0}, /* DSP 56361 Layla24 rev.0 */
86 {0,}
87};
88
89static struct snd_pcm_hardware pcm_hardware_skel = {
90 .info = SNDRV_PCM_INFO_MMAP |
91 SNDRV_PCM_INFO_INTERLEAVED |
92 SNDRV_PCM_INFO_BLOCK_TRANSFER |
93 SNDRV_PCM_INFO_MMAP_VALID |
94 SNDRV_PCM_INFO_PAUSE |
95 SNDRV_PCM_INFO_SYNC_START,
96 .formats = SNDRV_PCM_FMTBIT_U8 |
97 SNDRV_PCM_FMTBIT_S16_LE |
98 SNDRV_PCM_FMTBIT_S24_3LE |
99 SNDRV_PCM_FMTBIT_S32_LE |
100 SNDRV_PCM_FMTBIT_S32_BE,
101 .rates = SNDRV_PCM_RATE_8000_96000,
102 .rate_min = 8000,
103 .rate_max = 100000,
104 .channels_min = 1,
105 .channels_max = 8,
106 .buffer_bytes_max = 262144,
107 .period_bytes_min = 32,
108 .period_bytes_max = 131072,
109 .periods_min = 2,
110 .periods_max = 220,
111 /* One page (4k) contains 512 instructions. I don't know if the hw
112 supports lists longer than this. In this case periods_max=220 is a
113 safe limit to make sure the list never exceeds 512 instructions. */
114};
115
116
117#include "layla24_dsp.c"
118#include "echoaudio_dsp.c"
119#include "echoaudio_gml.c"
120#include "echoaudio.c"
121#include "midi.c"
diff --git a/sound/pci/echoaudio/layla24_dsp.c b/sound/pci/echoaudio/layla24_dsp.c
new file mode 100644
index 000000000000..7ec5b63d0dce
--- /dev/null
+++ b/sound/pci/echoaudio/layla24_dsp.c
@@ -0,0 +1,394 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software Foundation.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA.
22
23 *************************************************************************
24
25 Translation from C++ and adaptation for use in ALSA-Driver
26 were made by Giuliano Pochini <pochini@shiny.it>
27
28****************************************************************************/
29
30
31static int write_control_reg(struct echoaudio *chip, u32 value, char force);
32static int set_input_clock(struct echoaudio *chip, u16 clock);
33static int set_professional_spdif(struct echoaudio *chip, char prof);
34static int set_digital_mode(struct echoaudio *chip, u8 mode);
35static int load_asic_generic(struct echoaudio *chip, u32 cmd,
36 const struct firmware *asic);
37static int check_asic_status(struct echoaudio *chip);
38
39
40static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
41{
42 int err;
43
44 DE_INIT(("init_hw() - Layla24\n"));
45 snd_assert((subdevice_id & 0xfff0) == LAYLA24, return -ENODEV);
46
47 if ((err = init_dsp_comm_page(chip))) {
48 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
49 return err;
50 }
51
52 chip->device_id = device_id;
53 chip->subdevice_id = subdevice_id;
54 chip->bad_board = TRUE;
55 chip->has_midi = TRUE;
56 chip->dsp_code_to_load = &card_fw[FW_LAYLA24_DSP];
57 chip->input_clock_types =
58 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF |
59 ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_ADAT;
60 chip->digital_modes =
61 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
62 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
63 ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
64 chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
65 chip->professional_spdif = FALSE;
66 chip->digital_in_automute = TRUE;
67
68 if ((err = load_firmware(chip)) < 0)
69 return err;
70 chip->bad_board = FALSE;
71
72 if ((err = init_line_levels(chip)) < 0)
73 return err;
74
75 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
76 snd_assert(err >= 0, return err);
77 err = set_professional_spdif(chip, TRUE);
78
79 DE_INIT(("init_hw done\n"));
80 return err;
81}
82
83
84
85static u32 detect_input_clocks(const struct echoaudio *chip)
86{
87 u32 clocks_from_dsp, clock_bits;
88
89 /* Map the DSP clock detect bits to the generic driver clock detect bits */
90 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
91
92 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
93
94 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_SPDIF)
95 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
96
97 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_ADAT)
98 clock_bits |= ECHO_CLOCK_BIT_ADAT;
99
100 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_WORD)
101 clock_bits |= ECHO_CLOCK_BIT_WORD;
102
103 return clock_bits;
104}
105
106
107
108/* Layla24 has an ASIC on the PCI card and another ASIC in the external box;
109both need to be loaded. */
110static int load_asic(struct echoaudio *chip)
111{
112 int err;
113
114 if (chip->asic_loaded)
115 return 1;
116
117 DE_INIT(("load_asic\n"));
118
119 /* Give the DSP a few milliseconds to settle down */
120 mdelay(10);
121
122 /* Load the ASIC for the PCI card */
123 err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC,
124 &card_fw[FW_LAYLA24_1_ASIC]);
125 if (err < 0)
126 return err;
127
128 chip->asic_code = &card_fw[FW_LAYLA24_2S_ASIC];
129
130 /* Now give the new ASIC a little time to set up */
131 mdelay(10);
132
133 /* Do the external one */
134 err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC,
135 &card_fw[FW_LAYLA24_2S_ASIC]);
136 if (err < 0)
137 return FALSE;
138
139 /* Now give the external ASIC a little time to set up */
140 mdelay(10);
141
142 /* See if it worked */
143 err = check_asic_status(chip);
144
145 /* Set up the control register if the load succeeded -
146 48 kHz, internal clock, S/PDIF RCA mode */
147 if (!err)
148 err = write_control_reg(chip, GML_CONVERTER_ENABLE | GML_48KHZ,
149 TRUE);
150
151 DE_INIT(("load_asic() done\n"));
152 return err;
153}
154
155
156
157static int set_sample_rate(struct echoaudio *chip, u32 rate)
158{
159 u32 control_reg, clock, base_rate;
160
161 snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT,
162 return -EINVAL);
163
164 /* Only set the clock for internal mode. */
165 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
166 DE_ACT(("set_sample_rate: Cannot set sample rate - "
167 "clock not set to CLK_CLOCKININTERNAL\n"));
168 /* Save the rate anyhow */
169 chip->comm_page->sample_rate = cpu_to_le32(rate);
170 chip->sample_rate = rate;
171 return 0;
172 }
173
174 /* Get the control register & clear the appropriate bits */
175 control_reg = le32_to_cpu(chip->comm_page->control_register);
176 control_reg &= GML_CLOCK_CLEAR_MASK & GML_SPDIF_RATE_CLEAR_MASK;
177
178 clock = 0;
179
180 switch (rate) {
181 case 96000:
182 clock = GML_96KHZ;
183 break;
184 case 88200:
185 clock = GML_88KHZ;
186 break;
187 case 48000:
188 clock = GML_48KHZ | GML_SPDIF_SAMPLE_RATE1;
189 break;
190 case 44100:
191 clock = GML_44KHZ;
192 /* Professional mode */
193 if (control_reg & GML_SPDIF_PRO_MODE)
194 clock |= GML_SPDIF_SAMPLE_RATE0;
195 break;
196 case 32000:
197 clock = GML_32KHZ | GML_SPDIF_SAMPLE_RATE0 |
198 GML_SPDIF_SAMPLE_RATE1;
199 break;
200 case 22050:
201 clock = GML_22KHZ;
202 break;
203 case 16000:
204 clock = GML_16KHZ;
205 break;
206 case 11025:
207 clock = GML_11KHZ;
208 break;
209 case 8000:
210 clock = GML_8KHZ;
211 break;
212 default:
213 /* If this is a non-standard rate, then the driver needs to
214 use Layla24's special "continuous frequency" mode */
215 clock = LAYLA24_CONTINUOUS_CLOCK;
216 if (rate > 50000) {
217 base_rate = rate >> 1;
218 control_reg |= GML_DOUBLE_SPEED_MODE;
219 } else {
220 base_rate = rate;
221 }
222
223 if (base_rate < 25000)
224 base_rate = 25000;
225
226 if (wait_handshake(chip))
227 return -EIO;
228
229 chip->comm_page->sample_rate =
230 cpu_to_le32(LAYLA24_MAGIC_NUMBER / base_rate - 2);
231
232 clear_handshake(chip);
233 send_vector(chip, DSP_VC_SET_LAYLA24_FREQUENCY_REG);
234 }
235
236 control_reg |= clock;
237
238 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP ? */
239 chip->sample_rate = rate;
240 DE_ACT(("set_sample_rate: %d clock %d\n", rate, control_reg));
241
242 return write_control_reg(chip, control_reg, FALSE);
243}
244
245
246
247static int set_input_clock(struct echoaudio *chip, u16 clock)
248{
249 u32 control_reg, clocks_from_dsp;
250
251 /* Mask off the clock select bits */
252 control_reg = le32_to_cpu(chip->comm_page->control_register) &
253 GML_CLOCK_CLEAR_MASK;
254 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
255
256 /* Pick the new clock */
257 switch (clock) {
258 case ECHO_CLOCK_INTERNAL:
259 DE_ACT(("Set Layla24 clock to INTERNAL\n"));
260 chip->input_clock = ECHO_CLOCK_INTERNAL;
261 return set_sample_rate(chip, chip->sample_rate);
262 case ECHO_CLOCK_SPDIF:
263 if (chip->digital_mode == DIGITAL_MODE_ADAT)
264 return -EAGAIN;
265 control_reg |= GML_SPDIF_CLOCK;
266 /* Layla24 doesn't support 96KHz S/PDIF */
267 control_reg &= ~GML_DOUBLE_SPEED_MODE;
268 DE_ACT(("Set Layla24 clock to SPDIF\n"));
269 break;
270 case ECHO_CLOCK_WORD:
271 control_reg |= GML_WORD_CLOCK;
272 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_WORD96)
273 control_reg |= GML_DOUBLE_SPEED_MODE;
274 else
275 control_reg &= ~GML_DOUBLE_SPEED_MODE;
276 DE_ACT(("Set Layla24 clock to WORD\n"));
277 break;
278 case ECHO_CLOCK_ADAT:
279 if (chip->digital_mode != DIGITAL_MODE_ADAT)
280 return -EAGAIN;
281 control_reg |= GML_ADAT_CLOCK;
282 control_reg &= ~GML_DOUBLE_SPEED_MODE;
283 DE_ACT(("Set Layla24 clock to ADAT\n"));
284 break;
285 default:
286 DE_ACT(("Input clock 0x%x not supported for Layla24\n", clock));
287 return -EINVAL;
288 }
289
290 chip->input_clock = clock;
291 return write_control_reg(chip, control_reg, TRUE);
292}
293
294
295
296/* Depending on what digital mode you want, Layla24 needs different ASICs
297loaded. This function checks the ASIC needed for the new mode and sees
298if it matches the one already loaded. */
299static int switch_asic(struct echoaudio *chip, const struct firmware *asic)
300{
301 s8 *monitors;
302
303 /* Check to see if this is already loaded */
304 if (asic != chip->asic_code) {
305 monitors = kmalloc(MONITOR_ARRAY_SIZE, GFP_KERNEL);
306 if (! monitors)
307 return -ENOMEM;
308
309 memcpy(monitors, chip->comm_page->monitors, MONITOR_ARRAY_SIZE);
310 memset(chip->comm_page->monitors, ECHOGAIN_MUTED,
311 MONITOR_ARRAY_SIZE);
312
313 /* Load the desired ASIC */
314 if (load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC,
315 asic) < 0) {
316 memcpy(chip->comm_page->monitors, monitors,
317 MONITOR_ARRAY_SIZE);
318 kfree(monitors);
319 return -EIO;
320 }
321 chip->asic_code = asic;
322 memcpy(chip->comm_page->monitors, monitors, MONITOR_ARRAY_SIZE);
323 kfree(monitors);
324 }
325
326 return 0;
327}
328
329
330
331static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
332{
333 u32 control_reg;
334 int err, incompatible_clock;
335 const struct firmware *asic;
336
337 /* Set clock to "internal" if it's not compatible with the new mode */
338 incompatible_clock = FALSE;
339 switch (mode) {
340 case DIGITAL_MODE_SPDIF_OPTICAL:
341 case DIGITAL_MODE_SPDIF_RCA:
342 if (chip->input_clock == ECHO_CLOCK_ADAT)
343 incompatible_clock = TRUE;
344 asic = &card_fw[FW_LAYLA24_2S_ASIC];
345 break;
346 case DIGITAL_MODE_ADAT:
347 if (chip->input_clock == ECHO_CLOCK_SPDIF)
348 incompatible_clock = TRUE;
349 asic = &card_fw[FW_LAYLA24_2A_ASIC];
350 break;
351 default:
352 DE_ACT(("Digital mode not supported: %d\n", mode));
353 return -EINVAL;
354 }
355
356 if (incompatible_clock) { /* Switch to 48KHz, internal */
357 chip->sample_rate = 48000;
358 spin_lock_irq(&chip->lock);
359 set_input_clock(chip, ECHO_CLOCK_INTERNAL);
360 spin_unlock_irq(&chip->lock);
361 }
362
363 /* switch_asic() can sleep */
364 if (switch_asic(chip, asic) < 0)
365 return -EIO;
366
367 spin_lock_irq(&chip->lock);
368
369 /* Tweak the control register */
370 control_reg = le32_to_cpu(chip->comm_page->control_register);
371 control_reg &= GML_DIGITAL_MODE_CLEAR_MASK;
372
373 switch (mode) {
374 case DIGITAL_MODE_SPDIF_OPTICAL:
375 control_reg |= GML_SPDIF_OPTICAL_MODE;
376 break;
377 case DIGITAL_MODE_SPDIF_RCA:
378 /* GML_SPDIF_OPTICAL_MODE bit cleared */
379 break;
380 case DIGITAL_MODE_ADAT:
381 control_reg |= GML_ADAT_MODE;
382 control_reg &= ~GML_DOUBLE_SPEED_MODE;
383 break;
384 }
385
386 err = write_control_reg(chip, control_reg, TRUE);
387 spin_unlock_irq(&chip->lock);
388 if (err < 0)
389 return err;
390 chip->digital_mode = mode;
391
392 DE_ACT(("set_digital_mode to %d\n", mode));
393 return incompatible_clock;
394}
diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c
new file mode 100644
index 000000000000..be40c64263d2
--- /dev/null
+++ b/sound/pci/echoaudio/mia.c
@@ -0,0 +1,117 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHO24_FAMILY
20#define ECHOCARD_MIA
21#define ECHOCARD_NAME "Mia"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
24#define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
25#define ECHOCARD_HAS_SUPER_INTERLEAVE
26#define ECHOCARD_HAS_VMIXER
27#define ECHOCARD_HAS_DIGITAL_IO
28#define ECHOCARD_HAS_EXTERNAL_CLOCK
29#define ECHOCARD_HAS_ADAT FALSE
30#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
31#define ECHOCARD_HAS_MIDI
32
33/* Pipe indexes */
34#define PX_ANALOG_OUT 0 /* 8 */
35#define PX_DIGITAL_OUT 8 /* 0 */
36#define PX_ANALOG_IN 8 /* 2 */
37#define PX_DIGITAL_IN 10 /* 2 */
38#define PX_NUM 12
39
40/* Bus indexes */
41#define BX_ANALOG_OUT 0 /* 2 */
42#define BX_DIGITAL_OUT 2 /* 2 */
43#define BX_ANALOG_IN 4 /* 2 */
44#define BX_DIGITAL_IN 6 /* 2 */
45#define BX_NUM 8
46
47
48#include <sound/driver.h>
49#include <linux/delay.h>
50#include <linux/init.h>
51#include <linux/interrupt.h>
52#include <linux/pci.h>
53#include <linux/slab.h>
54#include <linux/moduleparam.h>
55#include <linux/firmware.h>
56#include <sound/core.h>
57#include <sound/info.h>
58#include <sound/control.h>
59#include <sound/pcm.h>
60#include <sound/pcm_params.h>
61#include <sound/asoundef.h>
62#include <sound/initval.h>
63#include <sound/rawmidi.h>
64#include <asm/io.h>
65#include <asm/atomic.h>
66#include "echoaudio.h"
67
68#define FW_361_LOADER 0
69#define FW_MIA_DSP 1
70
71static const struct firmware card_fw[] = {
72 {0, "loader_dsp.fw"},
73 {0, "mia_dsp.fw"}
74};
75
76static struct pci_device_id snd_echo_ids[] = {
77 {0x1057, 0x3410, 0xECC0, 0x0080, 0, 0, 0}, /* DSP 56361 Mia rev.0 */
78 {0x1057, 0x3410, 0xECC0, 0x0081, 0, 0, 0}, /* DSP 56361 Mia rev.1 */
79 {0,}
80};
81
82static struct snd_pcm_hardware pcm_hardware_skel = {
83 .info = SNDRV_PCM_INFO_MMAP |
84 SNDRV_PCM_INFO_INTERLEAVED |
85 SNDRV_PCM_INFO_BLOCK_TRANSFER |
86 SNDRV_PCM_INFO_MMAP_VALID |
87 SNDRV_PCM_INFO_PAUSE |
88 SNDRV_PCM_INFO_SYNC_START,
89 .formats = SNDRV_PCM_FMTBIT_U8 |
90 SNDRV_PCM_FMTBIT_S16_LE |
91 SNDRV_PCM_FMTBIT_S24_3LE |
92 SNDRV_PCM_FMTBIT_S32_LE |
93 SNDRV_PCM_FMTBIT_S32_BE,
94 .rates = SNDRV_PCM_RATE_32000 |
95 SNDRV_PCM_RATE_44100 |
96 SNDRV_PCM_RATE_48000 |
97 SNDRV_PCM_RATE_88200 |
98 SNDRV_PCM_RATE_96000,
99 .rate_min = 8000,
100 .rate_max = 96000,
101 .channels_min = 1,
102 .channels_max = 8,
103 .buffer_bytes_max = 262144,
104 .period_bytes_min = 32,
105 .period_bytes_max = 131072,
106 .periods_min = 2,
107 .periods_max = 220,
108 /* One page (4k) contains 512 instructions. I don't know if the hw
109 supports lists longer than this. In this case periods_max=220 is a
110 safe limit to make sure the list never exceeds 512 instructions. */
111};
112
113
114#include "mia_dsp.c"
115#include "echoaudio_dsp.c"
116#include "echoaudio.c"
117#include "midi.c"
diff --git a/sound/pci/echoaudio/mia_dsp.c b/sound/pci/echoaudio/mia_dsp.c
new file mode 100644
index 000000000000..891c70519096
--- /dev/null
+++ b/sound/pci/echoaudio/mia_dsp.c
@@ -0,0 +1,229 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int set_input_clock(struct echoaudio *chip, u16 clock);
33static int set_professional_spdif(struct echoaudio *chip, char prof);
34static int update_flags(struct echoaudio *chip);
35static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
36 int gain);
37static int update_vmixer_level(struct echoaudio *chip);
38
39
40static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
41{
42 int err;
43
44 DE_INIT(("init_hw() - Mia\n"));
45 snd_assert((subdevice_id & 0xfff0) == MIA, return -ENODEV);
46
47 if ((err = init_dsp_comm_page(chip))) {
48 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
49 return err;
50 }
51
52 chip->device_id = device_id;
53 chip->subdevice_id = subdevice_id;
54 chip->bad_board = TRUE;
55 chip->dsp_code_to_load = &card_fw[FW_MIA_DSP];
56 /* Since this card has no ASIC, mark it as loaded so everything
57 works OK */
58 chip->asic_loaded = TRUE;
59 if ((subdevice_id & 0x0000f) == MIA_MIDI_REV)
60 chip->has_midi = TRUE;
61 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
62 ECHO_CLOCK_BIT_SPDIF;
63
64 if ((err = load_firmware(chip)) < 0)
65 return err;
66 chip->bad_board = FALSE;
67
68 if ((err = init_line_levels(chip)))
69 return err;
70
71 /* Default routing of the virtual channels: vchannels 0-3 go to analog
72 outputs and vchannels 4-7 go to S/PDIF outputs */
73 set_vmixer_gain(chip, 0, 0, 0);
74 set_vmixer_gain(chip, 1, 1, 0);
75 set_vmixer_gain(chip, 0, 2, 0);
76 set_vmixer_gain(chip, 1, 3, 0);
77 set_vmixer_gain(chip, 2, 4, 0);
78 set_vmixer_gain(chip, 3, 5, 0);
79 set_vmixer_gain(chip, 2, 6, 0);
80 set_vmixer_gain(chip, 3, 7, 0);
81 err = update_vmixer_level(chip);
82
83 DE_INIT(("init_hw done\n"));
84 return err;
85}
86
87
88
89static u32 detect_input_clocks(const struct echoaudio *chip)
90{
91 u32 clocks_from_dsp, clock_bits;
92
93 /* Map the DSP clock detect bits to the generic driver clock
94 detect bits */
95 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
96
97 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
98
99 if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_SPDIF)
100 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
101
102 return clock_bits;
103}
104
105
106
107/* The Mia has no ASIC. Just do nothing */
108static int load_asic(struct echoaudio *chip)
109{
110 return 0;
111}
112
113
114
115static int set_sample_rate(struct echoaudio *chip, u32 rate)
116{
117 u32 control_reg;
118
119 switch (rate) {
120 case 96000:
121 control_reg = MIA_96000;
122 break;
123 case 88200:
124 control_reg = MIA_88200;
125 break;
126 case 48000:
127 control_reg = MIA_48000;
128 break;
129 case 44100:
130 control_reg = MIA_44100;
131 break;
132 case 32000:
133 control_reg = MIA_32000;
134 break;
135 default:
136 DE_ACT(("set_sample_rate: %d invalid!\n", rate));
137 return -EINVAL;
138 }
139
140 /* Override the clock setting if this Mia is set to S/PDIF clock */
141 if (chip->input_clock == ECHO_CLOCK_SPDIF)
142 control_reg |= MIA_SPDIF;
143
144 /* Set the control register if it has changed */
145 if (control_reg != le32_to_cpu(chip->comm_page->control_register)) {
146 if (wait_handshake(chip))
147 return -EIO;
148
149 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */
150 chip->comm_page->control_register = cpu_to_le32(control_reg);
151 chip->sample_rate = rate;
152
153 clear_handshake(chip);
154 return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
155 }
156 return 0;
157}
158
159
160
161static int set_input_clock(struct echoaudio *chip, u16 clock)
162{
163 DE_ACT(("set_input_clock(%d)\n", clock));
164 snd_assert(clock == ECHO_CLOCK_INTERNAL || clock == ECHO_CLOCK_SPDIF,
165 return -EINVAL);
166
167 chip->input_clock = clock;
168 return set_sample_rate(chip, chip->sample_rate);
169}
170
171
172
173/* This function routes the sound from a virtual channel to a real output */
174static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
175 int gain)
176{
177 int index;
178
179 snd_assert(pipe < num_pipes_out(chip) &&
180 output < num_busses_out(chip), return -EINVAL);
181
182 if (wait_handshake(chip))
183 return -EIO;
184
185 chip->vmixer_gain[output][pipe] = gain;
186 index = output * num_pipes_out(chip) + pipe;
187 chip->comm_page->vmixer[index] = gain;
188
189 DE_ACT(("set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain));
190 return 0;
191}
192
193
194
195/* Tell the DSP to read and update virtual mixer levels in comm page. */
196static int update_vmixer_level(struct echoaudio *chip)
197{
198 if (wait_handshake(chip))
199 return -EIO;
200 clear_handshake(chip);
201 return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
202}
203
204
205
206/* Tell the DSP to reread the flags from the comm page */
207static int update_flags(struct echoaudio *chip)
208{
209 if (wait_handshake(chip))
210 return -EIO;
211 clear_handshake(chip);
212 return send_vector(chip, DSP_VC_UPDATE_FLAGS);
213}
214
215
216
217static int set_professional_spdif(struct echoaudio *chip, char prof)
218{
219 DE_ACT(("set_professional_spdif %d\n", prof));
220 if (prof)
221 chip->comm_page->flags |=
222 __constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
223 else
224 chip->comm_page->flags &=
225 ~__constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
226 chip->professional_spdif = prof;
227 return update_flags(chip);
228}
229
diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c
new file mode 100644
index 000000000000..e31f0f11e3a8
--- /dev/null
+++ b/sound/pci/echoaudio/midi.c
@@ -0,0 +1,327 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32/******************************************************************************
33 MIDI lowlevel code
34******************************************************************************/
35
36/* Start and stop Midi input */
37static int enable_midi_input(struct echoaudio *chip, char enable)
38{
39 DE_MID(("enable_midi_input(%d)\n", enable));
40
41 if (wait_handshake(chip))
42 return -EIO;
43
44 if (enable) {
45 chip->mtc_state = MIDI_IN_STATE_NORMAL;
46 chip->comm_page->flags |=
47 __constant_cpu_to_le32(DSP_FLAG_MIDI_INPUT);
48 } else
49 chip->comm_page->flags &=
50 ~__constant_cpu_to_le32(DSP_FLAG_MIDI_INPUT);
51
52 clear_handshake(chip);
53 return send_vector(chip, DSP_VC_UPDATE_FLAGS);
54}
55
56
57
58/* Send a buffer full of MIDI data to the DSP
59Returns how many actually written or < 0 on error */
60static int write_midi(struct echoaudio *chip, u8 *data, int bytes)
61{
62 snd_assert(bytes > 0 && bytes < MIDI_OUT_BUFFER_SIZE, return -EINVAL);
63
64 if (wait_handshake(chip))
65 return -EIO;
66
67 /* HF4 indicates that it is safe to write MIDI output data */
68 if (! (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_REG_HF4))
69 return 0;
70
71 chip->comm_page->midi_output[0] = bytes;
72 memcpy(&chip->comm_page->midi_output[1], data, bytes);
73 chip->comm_page->midi_out_free_count = 0;
74 clear_handshake(chip);
75 send_vector(chip, DSP_VC_MIDI_WRITE);
76 DE_MID(("write_midi: %d\n", bytes));
77 return bytes;
78}
79
80
81
82/* Run the state machine for MIDI input data
83MIDI time code sync isn't supported by this code right now, but you still need
84this state machine to parse the incoming MIDI data stream. Every time the DSP
85sees a 0xF1 byte come in, it adds the DSP sample position to the MIDI data
86stream. The DSP sample position is represented as a 32 bit unsigned value,
87with the high 16 bits first, followed by the low 16 bits. Since these aren't
88real MIDI bytes, the following logic is needed to skip them. */
89static inline int mtc_process_data(struct echoaudio *chip, short midi_byte)
90{
91 switch (chip->mtc_state) {
92 case MIDI_IN_STATE_NORMAL:
93 if (midi_byte == 0xF1)
94 chip->mtc_state = MIDI_IN_STATE_TS_HIGH;
95 break;
96 case MIDI_IN_STATE_TS_HIGH:
97 chip->mtc_state = MIDI_IN_STATE_TS_LOW;
98 return MIDI_IN_SKIP_DATA;
99 break;
100 case MIDI_IN_STATE_TS_LOW:
101 chip->mtc_state = MIDI_IN_STATE_F1_DATA;
102 return MIDI_IN_SKIP_DATA;
103 break;
104 case MIDI_IN_STATE_F1_DATA:
105 chip->mtc_state = MIDI_IN_STATE_NORMAL;
106 break;
107 }
108 return 0;
109}
110
111
112
113/* This function is called from the IRQ handler and it reads the midi data
114from the DSP's buffer. It returns the number of bytes received. */
115static int midi_service_irq(struct echoaudio *chip)
116{
117 short int count, midi_byte, i, received;
118
119 /* The count is at index 0, followed by actual data */
120 count = le16_to_cpu(chip->comm_page->midi_input[0]);
121
122 snd_assert(count < MIDI_IN_BUFFER_SIZE, return 0);
123
124 /* Get the MIDI data from the comm page */
125 i = 1;
126 received = 0;
127 for (i = 1; i <= count; i++) {
128 /* Get the MIDI byte */
129 midi_byte = le16_to_cpu(chip->comm_page->midi_input[i]);
130
131 /* Parse the incoming MIDI stream. The incoming MIDI data
132 consists of MIDI bytes and timestamps for the MIDI time code
133 0xF1 bytes. mtc_process_data() is a little state machine that
134 parses the stream. If you get MIDI_IN_SKIP_DATA back, then
135 this is a timestamp byte, not a MIDI byte, so don't store it
136 in the MIDI input buffer. */
137 if (mtc_process_data(chip, midi_byte) == MIDI_IN_SKIP_DATA)
138 continue;
139
140 chip->midi_buffer[received++] = (u8)midi_byte;
141 }
142
143 return received;
144}
145
146
147
148
149/******************************************************************************
150 MIDI interface
151******************************************************************************/
152
153static int snd_echo_midi_input_open(struct snd_rawmidi_substream *substream)
154{
155 struct echoaudio *chip = substream->rmidi->private_data;
156
157 chip->midi_in = substream;
158 DE_MID(("rawmidi_iopen\n"));
159 return 0;
160}
161
162
163
164static void snd_echo_midi_input_trigger(struct snd_rawmidi_substream *substream,
165 int up)
166{
167 struct echoaudio *chip = substream->rmidi->private_data;
168
169 if (up != chip->midi_input_enabled) {
170 spin_lock_irq(&chip->lock);
171 enable_midi_input(chip, up);
172 spin_unlock_irq(&chip->lock);
173 chip->midi_input_enabled = up;
174 }
175}
176
177
178
179static int snd_echo_midi_input_close(struct snd_rawmidi_substream *substream)
180{
181 struct echoaudio *chip = substream->rmidi->private_data;
182
183 chip->midi_in = NULL;
184 DE_MID(("rawmidi_iclose\n"));
185 return 0;
186}
187
188
189
190static int snd_echo_midi_output_open(struct snd_rawmidi_substream *substream)
191{
192 struct echoaudio *chip = substream->rmidi->private_data;
193
194 chip->tinuse = 0;
195 chip->midi_full = 0;
196 chip->midi_out = substream;
197 DE_MID(("rawmidi_oopen\n"));
198 return 0;
199}
200
201
202
203static void snd_echo_midi_output_write(unsigned long data)
204{
205 struct echoaudio *chip = (struct echoaudio *)data;
206 unsigned long flags;
207 int bytes, sent, time;
208 unsigned char buf[MIDI_OUT_BUFFER_SIZE - 1];
209
210 DE_MID(("snd_echo_midi_output_write\n"));
211 /* No interrupts are involved: we have to check at regular intervals
212 if the card's output buffer has room for new data. */
213 sent = bytes = 0;
214 spin_lock_irqsave(&chip->lock, flags);
215 chip->midi_full = 0;
216 if (chip->midi_out && !snd_rawmidi_transmit_empty(chip->midi_out)) {
217 bytes = snd_rawmidi_transmit_peek(chip->midi_out, buf,
218 MIDI_OUT_BUFFER_SIZE - 1);
219 DE_MID(("Try to send %d bytes...\n", bytes));
220 sent = write_midi(chip, buf, bytes);
221 if (sent < 0) {
222 snd_printk(KERN_ERR "write_midi() error %d\n", sent);
223 /* retry later */
224 sent = 9000;
225 chip->midi_full = 1;
226 } else if (sent > 0) {
227 DE_MID(("%d bytes sent\n", sent));
228 snd_rawmidi_transmit_ack(chip->midi_out, sent);
229 } else {
230 /* Buffer is full. DSP's internal buffer is 64 (128 ?)
231 bytes long. Let's wait until half of them are sent */
232 DE_MID(("Full\n"));
233 sent = 32;
234 chip->midi_full = 1;
235 }
236 }
237
238 /* We restart the timer only if there is some data left to send */
239 if (!snd_rawmidi_transmit_empty(chip->midi_out) && chip->tinuse) {
240 /* The timer will expire slightly after the data has been
241 sent */
242 time = (sent << 3) / 25 + 1; /* 8/25=0.32ms to send a byte */
243 mod_timer(&chip->timer, jiffies + (time * HZ + 999) / 1000);
244 DE_MID(("Timer armed(%d)\n", ((time * HZ + 999) / 1000)));
245 }
246 spin_unlock_irqrestore(&chip->lock, flags);
247}
248
249
250
251static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream,
252 int up)
253{
254 struct echoaudio *chip = substream->rmidi->private_data;
255
256 DE_MID(("snd_echo_midi_output_trigger(%d)\n", up));
257 spin_lock_irq(&chip->lock);
258 if (up) {
259 if (!chip->tinuse) {
260 init_timer(&chip->timer);
261 chip->timer.function = snd_echo_midi_output_write;
262 chip->timer.data = (unsigned long)chip;
263 chip->tinuse = 1;
264 }
265 } else {
266 if (chip->tinuse) {
267 del_timer(&chip->timer);
268 chip->tinuse = 0;
269 DE_MID(("Timer removed\n"));
270 }
271 }
272 spin_unlock_irq(&chip->lock);
273
274 if (up && !chip->midi_full)
275 snd_echo_midi_output_write((unsigned long)chip);
276}
277
278
279
280static int snd_echo_midi_output_close(struct snd_rawmidi_substream *substream)
281{
282 struct echoaudio *chip = substream->rmidi->private_data;
283
284 chip->midi_out = NULL;
285 DE_MID(("rawmidi_oclose\n"));
286 return 0;
287}
288
289
290
291static struct snd_rawmidi_ops snd_echo_midi_input = {
292 .open = snd_echo_midi_input_open,
293 .close = snd_echo_midi_input_close,
294 .trigger = snd_echo_midi_input_trigger,
295};
296
297static struct snd_rawmidi_ops snd_echo_midi_output = {
298 .open = snd_echo_midi_output_open,
299 .close = snd_echo_midi_output_close,
300 .trigger = snd_echo_midi_output_trigger,
301};
302
303
304
305/* <--snd_echo_probe() */
306static int __devinit snd_echo_midi_create(struct snd_card *card,
307 struct echoaudio *chip)
308{
309 int err;
310
311 if ((err = snd_rawmidi_new(card, card->shortname, 0, 1, 1,
312 &chip->rmidi)) < 0)
313 return err;
314
315 strcpy(chip->rmidi->name, card->shortname);
316 chip->rmidi->private_data = chip;
317
318 snd_rawmidi_set_ops(chip->rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
319 &snd_echo_midi_input);
320 snd_rawmidi_set_ops(chip->rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
321 &snd_echo_midi_output);
322
323 chip->rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
324 SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX;
325 DE_INIT(("MIDI ok\n"));
326 return 0;
327}
diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c
new file mode 100644
index 000000000000..5dc512add372
--- /dev/null
+++ b/sound/pci/echoaudio/mona.c
@@ -0,0 +1,129 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4 *
5 * 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
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define ECHO24_FAMILY
20#define ECHOCARD_MONA
21#define ECHOCARD_NAME "Mona"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_ASIC
24#define ECHOCARD_HAS_SUPER_INTERLEAVE
25#define ECHOCARD_HAS_DIGITAL_IO
26#define ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
27#define ECHOCARD_HAS_DIGITAL_MODE_SWITCH
28#define ECHOCARD_HAS_EXTERNAL_CLOCK
29#define ECHOCARD_HAS_ADAT 6
30#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
31
32/* Pipe indexes */
33#define PX_ANALOG_OUT 0 /* 6 */
34#define PX_DIGITAL_OUT 6 /* 8 */
35#define PX_ANALOG_IN 14 /* 4 */
36#define PX_DIGITAL_IN 18 /* 8 */
37#define PX_NUM 26
38
39/* Bus indexes */
40#define BX_ANALOG_OUT 0 /* 6 */
41#define BX_DIGITAL_OUT 6 /* 8 */
42#define BX_ANALOG_IN 14 /* 4 */
43#define BX_DIGITAL_IN 18 /* 8 */
44#define BX_NUM 26
45
46
47#include <sound/driver.h>
48#include <linux/delay.h>
49#include <linux/init.h>
50#include <linux/interrupt.h>
51#include <linux/pci.h>
52#include <linux/slab.h>
53#include <linux/moduleparam.h>
54#include <linux/firmware.h>
55#include <sound/core.h>
56#include <sound/info.h>
57#include <sound/control.h>
58#include <sound/pcm.h>
59#include <sound/pcm_params.h>
60#include <sound/asoundef.h>
61#include <sound/initval.h>
62#include <asm/io.h>
63#include <asm/atomic.h>
64#include "echoaudio.h"
65
66#define FW_361_LOADER 0
67#define FW_MONA_301_DSP 1
68#define FW_MONA_361_DSP 2
69#define FW_MONA_301_1_ASIC48 3
70#define FW_MONA_301_1_ASIC96 4
71#define FW_MONA_361_1_ASIC48 5
72#define FW_MONA_361_1_ASIC96 6
73#define FW_MONA_2_ASIC 7
74
75static const struct firmware card_fw[] = {
76 {0, "loader_dsp.fw"},
77 {0, "mona_301_dsp.fw"},
78 {0, "mona_361_dsp.fw"},
79 {0, "mona_301_1_asic_48.fw"},
80 {0, "mona_301_1_asic_96.fw"},
81 {0, "mona_361_1_asic_48.fw"},
82 {0, "mona_361_1_asic_96.fw"},
83 {0, "mona_2_asic.fw"}
84};
85
86static struct pci_device_id snd_echo_ids[] = {
87 {0x1057, 0x1801, 0xECC0, 0x0070, 0, 0, 0}, /* DSP 56301 Mona rev.0 */
88 {0x1057, 0x1801, 0xECC0, 0x0071, 0, 0, 0}, /* DSP 56301 Mona rev.1 */
89 {0x1057, 0x1801, 0xECC0, 0x0072, 0, 0, 0}, /* DSP 56301 Mona rev.2 */
90 {0x1057, 0x3410, 0xECC0, 0x0070, 0, 0, 0}, /* DSP 56361 Mona rev.0 */
91 {0x1057, 0x3410, 0xECC0, 0x0071, 0, 0, 0}, /* DSP 56361 Mona rev.1 */
92 {0x1057, 0x3410, 0xECC0, 0x0072, 0, 0, 0}, /* DSP 56361 Mona rev.2 */
93 {0,}
94};
95
96static struct snd_pcm_hardware pcm_hardware_skel = {
97 .info = SNDRV_PCM_INFO_MMAP |
98 SNDRV_PCM_INFO_INTERLEAVED |
99 SNDRV_PCM_INFO_BLOCK_TRANSFER |
100 SNDRV_PCM_INFO_MMAP_VALID |
101 SNDRV_PCM_INFO_PAUSE |
102 SNDRV_PCM_INFO_SYNC_START,
103 .formats = SNDRV_PCM_FMTBIT_U8 |
104 SNDRV_PCM_FMTBIT_S16_LE |
105 SNDRV_PCM_FMTBIT_S24_3LE |
106 SNDRV_PCM_FMTBIT_S32_LE |
107 SNDRV_PCM_FMTBIT_S32_BE,
108 .rates = SNDRV_PCM_RATE_8000_48000 |
109 SNDRV_PCM_RATE_88200 |
110 SNDRV_PCM_RATE_96000,
111 .rate_min = 8000,
112 .rate_max = 96000,
113 .channels_min = 1,
114 .channels_max = 8,
115 .buffer_bytes_max = 262144,
116 .period_bytes_min = 32,
117 .period_bytes_max = 131072,
118 .periods_min = 2,
119 .periods_max = 220,
120 /* One page (4k) contains 512 instructions. I don't know if the hw
121 supports lists longer than this. In this case periods_max=220 is a
122 safe limit to make sure the list never exceeds 512 instructions. */
123};
124
125
126#include "mona_dsp.c"
127#include "echoaudio_dsp.c"
128#include "echoaudio_gml.c"
129#include "echoaudio.c"
diff --git a/sound/pci/echoaudio/mona_dsp.c b/sound/pci/echoaudio/mona_dsp.c
new file mode 100644
index 000000000000..c0b4bf0be7d1
--- /dev/null
+++ b/sound/pci/echoaudio/mona_dsp.c
@@ -0,0 +1,428 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31
32static int write_control_reg(struct echoaudio *chip, u32 value, char force);
33static int set_input_clock(struct echoaudio *chip, u16 clock);
34static int set_professional_spdif(struct echoaudio *chip, char prof);
35static int set_digital_mode(struct echoaudio *chip, u8 mode);
36static int load_asic_generic(struct echoaudio *chip, u32 cmd,
37 const struct firmware *asic);
38static int check_asic_status(struct echoaudio *chip);
39
40
41static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
42{
43 int err;
44
45 DE_INIT(("init_hw() - Mona\n"));
46 snd_assert((subdevice_id & 0xfff0) == MONA, return -ENODEV);
47
48 if ((err = init_dsp_comm_page(chip))) {
49 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
50 return err;
51 }
52
53 chip->device_id = device_id;
54 chip->subdevice_id = subdevice_id;
55 chip->bad_board = TRUE;
56 chip->input_clock_types =
57 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF |
58 ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_ADAT;
59 chip->digital_modes =
60 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
61 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
62 ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
63
64 /* Mona comes in both '301 and '361 flavors */
65 if (chip->device_id == DEVICE_ID_56361)
66 chip->dsp_code_to_load = &card_fw[FW_MONA_361_DSP];
67 else
68 chip->dsp_code_to_load = &card_fw[FW_MONA_301_DSP];
69
70 chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
71 chip->professional_spdif = FALSE;
72 chip->digital_in_automute = TRUE;
73
74 if ((err = load_firmware(chip)) < 0)
75 return err;
76 chip->bad_board = FALSE;
77
78 if ((err = init_line_levels(chip)) < 0)
79 return err;
80
81 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
82 snd_assert(err >= 0, return err);
83 err = set_professional_spdif(chip, TRUE);
84
85 DE_INIT(("init_hw done\n"));
86 return err;
87}
88
89
90
91static u32 detect_input_clocks(const struct echoaudio *chip)
92{
93 u32 clocks_from_dsp, clock_bits;
94
95 /* Map the DSP clock detect bits to the generic driver clock
96 detect bits */
97 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
98
99 clock_bits = ECHO_CLOCK_BIT_INTERNAL;
100
101 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_SPDIF)
102 clock_bits |= ECHO_CLOCK_BIT_SPDIF;
103
104 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_ADAT)
105 clock_bits |= ECHO_CLOCK_BIT_ADAT;
106
107 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_WORD)
108 clock_bits |= ECHO_CLOCK_BIT_WORD;
109
110 return clock_bits;
111}
112
113
114
115/* Mona has an ASIC on the PCI card and another ASIC in the external box;
116both need to be loaded. */
117static int load_asic(struct echoaudio *chip)
118{
119 u32 control_reg;
120 int err;
121 const struct firmware *asic;
122
123 if (chip->asic_loaded)
124 return 0;
125
126 mdelay(10);
127
128 if (chip->device_id == DEVICE_ID_56361)
129 asic = &card_fw[FW_MONA_361_1_ASIC48];
130 else
131 asic = &card_fw[FW_MONA_301_1_ASIC48];
132
133 err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_PCI_CARD_ASIC, asic);
134 if (err < 0)
135 return err;
136
137 chip->asic_code = asic;
138 mdelay(10);
139
140 /* Do the external one */
141 err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_EXTERNAL_ASIC,
142 &card_fw[FW_MONA_2_ASIC]);
143 if (err < 0)
144 return err;
145
146 mdelay(10);
147 err = check_asic_status(chip);
148
149 /* Set up the control register if the load succeeded -
150 48 kHz, internal clock, S/PDIF RCA mode */
151 if (!err) {
152 control_reg = GML_CONVERTER_ENABLE | GML_48KHZ;
153 err = write_control_reg(chip, control_reg, TRUE);
154 }
155
156 return err;
157}
158
159
160
161/* Depending on what digital mode you want, Mona needs different ASICs
162loaded. This function checks the ASIC needed for the new mode and sees
163if it matches the one already loaded. */
164static int switch_asic(struct echoaudio *chip, char double_speed)
165{
166 const struct firmware *asic;
167 int err;
168
169 /* Check the clock detect bits to see if this is
170 a single-speed clock or a double-speed clock; load
171 a new ASIC if necessary. */
172 if (chip->device_id == DEVICE_ID_56361) {
173 if (double_speed)
174 asic = &card_fw[FW_MONA_361_1_ASIC96];
175 else
176 asic = &card_fw[FW_MONA_361_1_ASIC48];
177 } else {
178 if (double_speed)
179 asic = &card_fw[FW_MONA_301_1_ASIC96];
180 else
181 asic = &card_fw[FW_MONA_301_1_ASIC48];
182 }
183
184 if (asic != chip->asic_code) {
185 /* Load the desired ASIC */
186 err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_PCI_CARD_ASIC,
187 asic);
188 if (err < 0)
189 return err;
190 chip->asic_code = asic;
191 }
192
193 return 0;
194}
195
196
197
198static int set_sample_rate(struct echoaudio *chip, u32 rate)
199{
200 u32 control_reg, clock;
201 const struct firmware *asic;
202 char force_write;
203
204 /* Only set the clock for internal mode. */
205 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
206 DE_ACT(("set_sample_rate: Cannot set sample rate - "
207 "clock not set to CLK_CLOCKININTERNAL\n"));
208 /* Save the rate anyhow */
209 chip->comm_page->sample_rate = cpu_to_le32(rate);
210 chip->sample_rate = rate;
211 return 0;
212 }
213
214 /* Now, check to see if the required ASIC is loaded */
215 if (rate >= 88200) {
216 if (chip->digital_mode == DIGITAL_MODE_ADAT)
217 return -EINVAL;
218 if (chip->device_id == DEVICE_ID_56361)
219 asic = &card_fw[FW_MONA_361_1_ASIC96];
220 else
221 asic = &card_fw[FW_MONA_301_1_ASIC96];
222 } else {
223 if (chip->device_id == DEVICE_ID_56361)
224 asic = &card_fw[FW_MONA_361_1_ASIC48];
225 else
226 asic = &card_fw[FW_MONA_301_1_ASIC48];
227 }
228
229 force_write = 0;
230 if (asic != chip->asic_code) {
231 int err;
232 /* Load the desired ASIC (load_asic_generic() can sleep) */
233 spin_unlock_irq(&chip->lock);
234 err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_PCI_CARD_ASIC,
235 asic);
236 spin_lock_irq(&chip->lock);
237
238 if (err < 0)
239 return err;
240 chip->asic_code = asic;
241 force_write = 1;
242 }
243
244 /* Compute the new control register value */
245 clock = 0;
246 control_reg = le32_to_cpu(chip->comm_page->control_register);
247 control_reg &= GML_CLOCK_CLEAR_MASK;
248 control_reg &= GML_SPDIF_RATE_CLEAR_MASK;
249
250 switch (rate) {
251 case 96000:
252 clock = GML_96KHZ;
253 break;
254 case 88200:
255 clock = GML_88KHZ;
256 break;
257 case 48000:
258 clock = GML_48KHZ | GML_SPDIF_SAMPLE_RATE1;
259 break;
260 case 44100:
261 clock = GML_44KHZ;
262 /* Professional mode */
263 if (control_reg & GML_SPDIF_PRO_MODE)
264 clock |= GML_SPDIF_SAMPLE_RATE0;
265 break;
266 case 32000:
267 clock = GML_32KHZ | GML_SPDIF_SAMPLE_RATE0 |
268 GML_SPDIF_SAMPLE_RATE1;
269 break;
270 case 22050:
271 clock = GML_22KHZ;
272 break;
273 case 16000:
274 clock = GML_16KHZ;
275 break;
276 case 11025:
277 clock = GML_11KHZ;
278 break;
279 case 8000:
280 clock = GML_8KHZ;
281 break;
282 default:
283 DE_ACT(("set_sample_rate: %d invalid!\n", rate));
284 return -EINVAL;
285 }
286
287 control_reg |= clock;
288
289 chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */
290 chip->sample_rate = rate;
291 DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));
292
293 return write_control_reg(chip, control_reg, force_write);
294}
295
296
297
298static int set_input_clock(struct echoaudio *chip, u16 clock)
299{
300 u32 control_reg, clocks_from_dsp;
301 int err;
302
303 DE_ACT(("set_input_clock:\n"));
304
305 /* Prevent two simultaneous calls to switch_asic() */
306 if (atomic_read(&chip->opencount))
307 return -EAGAIN;
308
309 /* Mask off the clock select bits */
310 control_reg = le32_to_cpu(chip->comm_page->control_register) &
311 GML_CLOCK_CLEAR_MASK;
312 clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);
313
314 switch (clock) {
315 case ECHO_CLOCK_INTERNAL:
316 DE_ACT(("Set Mona clock to INTERNAL\n"));
317 chip->input_clock = ECHO_CLOCK_INTERNAL;
318 return set_sample_rate(chip, chip->sample_rate);
319 case ECHO_CLOCK_SPDIF:
320 if (chip->digital_mode == DIGITAL_MODE_ADAT)
321 return -EAGAIN;
322 spin_unlock_irq(&chip->lock);
323 err = switch_asic(chip, clocks_from_dsp &
324 GML_CLOCK_DETECT_BIT_SPDIF96);
325 spin_lock_irq(&chip->lock);
326 if (err < 0)
327 return err;
328 DE_ACT(("Set Mona clock to SPDIF\n"));
329 control_reg |= GML_SPDIF_CLOCK;
330 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_SPDIF96)
331 control_reg |= GML_DOUBLE_SPEED_MODE;
332 else
333 control_reg &= ~GML_DOUBLE_SPEED_MODE;
334 break;
335 case ECHO_CLOCK_WORD:
336 DE_ACT(("Set Mona clock to WORD\n"));
337 spin_unlock_irq(&chip->lock);
338 err = switch_asic(chip, clocks_from_dsp &
339 GML_CLOCK_DETECT_BIT_WORD96);
340 spin_lock_irq(&chip->lock);
341 if (err < 0)
342 return err;
343 control_reg |= GML_WORD_CLOCK;
344 if (clocks_from_dsp & GML_CLOCK_DETECT_BIT_WORD96)
345 control_reg |= GML_DOUBLE_SPEED_MODE;
346 else
347 control_reg &= ~GML_DOUBLE_SPEED_MODE;
348 break;
349 case ECHO_CLOCK_ADAT:
350 DE_ACT(("Set Mona clock to ADAT\n"));
351 if (chip->digital_mode != DIGITAL_MODE_ADAT)
352 return -EAGAIN;
353 control_reg |= GML_ADAT_CLOCK;
354 control_reg &= ~GML_DOUBLE_SPEED_MODE;
355 break;
356 default:
357 DE_ACT(("Input clock 0x%x not supported for Mona\n", clock));
358 return -EINVAL;
359 }
360
361 chip->input_clock = clock;
362 return write_control_reg(chip, control_reg, TRUE);
363}
364
365
366
367static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
368{
369 u32 control_reg;
370 int err, incompatible_clock;
371
372 /* Set clock to "internal" if it's not compatible with the new mode */
373 incompatible_clock = FALSE;
374 switch (mode) {
375 case DIGITAL_MODE_SPDIF_OPTICAL:
376 case DIGITAL_MODE_SPDIF_RCA:
377 if (chip->input_clock == ECHO_CLOCK_ADAT)
378 incompatible_clock = TRUE;
379 break;
380 case DIGITAL_MODE_ADAT:
381 if (chip->input_clock == ECHO_CLOCK_SPDIF)
382 incompatible_clock = TRUE;
383 break;
384 default:
385 DE_ACT(("Digital mode not supported: %d\n", mode));
386 return -EINVAL;
387 }
388
389 spin_lock_irq(&chip->lock);
390
391 if (incompatible_clock) { /* Switch to 48KHz, internal */
392 chip->sample_rate = 48000;
393 set_input_clock(chip, ECHO_CLOCK_INTERNAL);
394 }
395
396 /* Clear the current digital mode */
397 control_reg = le32_to_cpu(chip->comm_page->control_register);
398 control_reg &= GML_DIGITAL_MODE_CLEAR_MASK;
399
400 /* Tweak the control reg */
401 switch (mode) {
402 case DIGITAL_MODE_SPDIF_OPTICAL:
403 control_reg |= GML_SPDIF_OPTICAL_MODE;
404 break;
405 case DIGITAL_MODE_SPDIF_RCA:
406 /* GML_SPDIF_OPTICAL_MODE bit cleared */
407 break;
408 case DIGITAL_MODE_ADAT:
409 /* If the current ASIC is the 96KHz ASIC, switch the ASIC
410 and set to 48 KHz */
411 if (chip->asic_code == &card_fw[FW_MONA_361_1_ASIC96] ||
412 chip->asic_code == &card_fw[FW_MONA_301_1_ASIC96]) {
413 set_sample_rate(chip, 48000);
414 }
415 control_reg |= GML_ADAT_MODE;
416 control_reg &= ~GML_DOUBLE_SPEED_MODE;
417 break;
418 }
419
420 err = write_control_reg(chip, control_reg, FALSE);
421 spin_unlock_irq(&chip->lock);
422 if (err < 0)
423 return err;
424 chip->digital_mode = mode;
425
426 DE_ACT(("set_digital_mode to %d\n", mode));
427 return incompatible_clock;
428}
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 8c2a8174ece1..23201f3eeb12 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -408,7 +408,9 @@ static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec)
408 u32 mask = preset->mask; 408 u32 mask = preset->mask;
409 if (! mask) 409 if (! mask)
410 mask = ~0; 410 mask = ~0;
411 if (preset->id == (codec->vendor_id & mask)) 411 if (preset->id == (codec->vendor_id & mask) &&
412 (! preset->rev ||
413 preset->rev == codec->revision_id))
412 return preset; 414 return preset;
413 } 415 }
414 } 416 }
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index dd4e00a82b55..33b7d5806469 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -799,6 +799,8 @@ static struct hda_board_config ad1986a_cfg_tbl[] = {
799 { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f, 799 { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f,
800 .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */ 800 .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */
801 { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD }, 801 { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD },
802 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc023,
803 .config = AD1986A_LAPTOP_EAPD }, /* Samsung X60 Chane */
802 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024, 804 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024,
803 .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */ 805 .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */
804 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1153, 806 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1153,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 98b9f16c26ff..18d105263fea 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -78,6 +78,7 @@ enum {
78enum { 78enum {
79 ALC262_BASIC, 79 ALC262_BASIC,
80 ALC262_FUJITSU, 80 ALC262_FUJITSU,
81 ALC262_HP_BPC,
81 ALC262_AUTO, 82 ALC262_AUTO,
82 ALC262_MODEL_LAST /* last tag */ 83 ALC262_MODEL_LAST /* last tag */
83}; 84};
@@ -85,6 +86,7 @@ enum {
85/* ALC861 models */ 86/* ALC861 models */
86enum { 87enum {
87 ALC861_3ST, 88 ALC861_3ST,
89 ALC660_3ST,
88 ALC861_3ST_DIG, 90 ALC861_3ST_DIG,
89 ALC861_6ST_DIG, 91 ALC861_6ST_DIG,
90 ALC861_AUTO, 92 ALC861_AUTO,
@@ -99,6 +101,17 @@ enum {
99 ALC882_MODEL_LAST, 101 ALC882_MODEL_LAST,
100}; 102};
101 103
104/* ALC883 models */
105enum {
106 ALC883_3ST_2ch_DIG,
107 ALC883_3ST_6ch_DIG,
108 ALC883_3ST_6ch,
109 ALC883_6ST_DIG,
110 ALC888_DEMO_BOARD,
111 ALC883_AUTO,
112 ALC883_MODEL_LAST,
113};
114
102/* for GPIO Poll */ 115/* for GPIO Poll */
103#define GPIO_MASK 0x03 116#define GPIO_MASK 0x03
104 117
@@ -108,7 +121,8 @@ struct alc_spec {
108 unsigned int num_mixers; 121 unsigned int num_mixers;
109 122
110 const struct hda_verb *init_verbs[5]; /* initialization verbs 123 const struct hda_verb *init_verbs[5]; /* initialization verbs
111 * don't forget NULL termination! 124 * don't forget NULL
125 * termination!
112 */ 126 */
113 unsigned int num_init_verbs; 127 unsigned int num_init_verbs;
114 128
@@ -163,7 +177,9 @@ struct alc_spec {
163 * configuration template - to be copied to the spec instance 177 * configuration template - to be copied to the spec instance
164 */ 178 */
165struct alc_config_preset { 179struct alc_config_preset {
166 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */ 180 struct snd_kcontrol_new *mixers[5]; /* should be identical size
181 * with spec
182 */
167 const struct hda_verb *init_verbs[5]; 183 const struct hda_verb *init_verbs[5];
168 unsigned int num_dacs; 184 unsigned int num_dacs;
169 hda_nid_t *dac_nids; 185 hda_nid_t *dac_nids;
@@ -184,7 +200,8 @@ struct alc_config_preset {
184/* 200/*
185 * input MUX handling 201 * input MUX handling
186 */ 202 */
187static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 203static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
204 struct snd_ctl_elem_info *uinfo)
188{ 205{
189 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 206 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
190 struct alc_spec *spec = codec->spec; 207 struct alc_spec *spec = codec->spec;
@@ -194,7 +211,8 @@ static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
194 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); 211 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
195} 212}
196 213
197static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 214static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
215 struct snd_ctl_elem_value *ucontrol)
198{ 216{
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 217 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec; 218 struct alc_spec *spec = codec->spec;
@@ -204,21 +222,24 @@ static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
204 return 0; 222 return 0;
205} 223}
206 224
207static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 225static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_value *ucontrol)
208{ 227{
209 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
210 struct alc_spec *spec = codec->spec; 229 struct alc_spec *spec = codec->spec;
211 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 230 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
212 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 231 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
213 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, 232 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
214 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); 233 spec->adc_nids[adc_idx],
234 &spec->cur_mux[adc_idx]);
215} 235}
216 236
217 237
218/* 238/*
219 * channel mode setting 239 * channel mode setting
220 */ 240 */
221static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 241static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
242 struct snd_ctl_elem_info *uinfo)
222{ 243{
223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
224 struct alc_spec *spec = codec->spec; 245 struct alc_spec *spec = codec->spec;
@@ -226,20 +247,24 @@ static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_i
226 spec->num_channel_mode); 247 spec->num_channel_mode);
227} 248}
228 249
229static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 250static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
251 struct snd_ctl_elem_value *ucontrol)
230{ 252{
231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
232 struct alc_spec *spec = codec->spec; 254 struct alc_spec *spec = codec->spec;
233 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 255 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
234 spec->num_channel_mode, spec->multiout.max_channels); 256 spec->num_channel_mode,
257 spec->multiout.max_channels);
235} 258}
236 259
237static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 260static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
261 struct snd_ctl_elem_value *ucontrol)
238{ 262{
239 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
240 struct alc_spec *spec = codec->spec; 264 struct alc_spec *spec = codec->spec;
241 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 265 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
242 spec->num_channel_mode, &spec->multiout.max_channels); 266 spec->num_channel_mode,
267 &spec->multiout.max_channels);
243} 268}
244 269
245/* 270/*
@@ -290,7 +315,8 @@ static signed char alc_pin_mode_dir_info[5][2] = {
290#define alc_pin_mode_n_items(_dir) \ 315#define alc_pin_mode_n_items(_dir) \
291 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) 316 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
292 317
293static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 318static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
319 struct snd_ctl_elem_info *uinfo)
294{ 320{
295 unsigned int item_num = uinfo->value.enumerated.item; 321 unsigned int item_num = uinfo->value.enumerated.item;
296 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 322 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
@@ -305,40 +331,46 @@ static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
305 return 0; 331 return 0;
306} 332}
307 333
308static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 334static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
335 struct snd_ctl_elem_value *ucontrol)
309{ 336{
310 unsigned int i; 337 unsigned int i;
311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
312 hda_nid_t nid = kcontrol->private_value & 0xffff; 339 hda_nid_t nid = kcontrol->private_value & 0xffff;
313 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 340 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
314 long *valp = ucontrol->value.integer.value; 341 long *valp = ucontrol->value.integer.value;
315 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); 342 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
343 AC_VERB_GET_PIN_WIDGET_CONTROL,
344 0x00);
316 345
317 /* Find enumerated value for current pinctl setting */ 346 /* Find enumerated value for current pinctl setting */
318 i = alc_pin_mode_min(dir); 347 i = alc_pin_mode_min(dir);
319 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir)) 348 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
320 i++; 349 i++;
321 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir); 350 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
322 return 0; 351 return 0;
323} 352}
324 353
325static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 354static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
355 struct snd_ctl_elem_value *ucontrol)
326{ 356{
327 signed int change; 357 signed int change;
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
329 hda_nid_t nid = kcontrol->private_value & 0xffff; 359 hda_nid_t nid = kcontrol->private_value & 0xffff;
330 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 360 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
331 long val = *ucontrol->value.integer.value; 361 long val = *ucontrol->value.integer.value;
332 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); 362 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
363 AC_VERB_GET_PIN_WIDGET_CONTROL,
364 0x00);
333 365
334 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir)) 366 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
335 val = alc_pin_mode_min(dir); 367 val = alc_pin_mode_min(dir);
336 368
337 change = pinctl != alc_pin_mode_values[val]; 369 change = pinctl != alc_pin_mode_values[val];
338 if (change) { 370 if (change) {
339 /* Set pin mode to that requested */ 371 /* Set pin mode to that requested */
340 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, 372 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
341 alc_pin_mode_values[val]); 373 alc_pin_mode_values[val]);
342 374
343 /* Also enable the retasking pin's input/output as required 375 /* Also enable the retasking pin's input/output as required
344 * for the requested pin mode. Enum values of 2 or less are 376 * for the requested pin mode. Enum values of 2 or less are
@@ -351,15 +383,19 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
351 * this turns out to be necessary in the future. 383 * this turns out to be necessary in the future.
352 */ 384 */
353 if (val <= 2) { 385 if (val <= 2) {
354 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 386 snd_hda_codec_write(codec, nid, 0,
355 AMP_OUT_MUTE); 387 AC_VERB_SET_AMP_GAIN_MUTE,
356 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 388 AMP_OUT_MUTE);
357 AMP_IN_UNMUTE(0)); 389 snd_hda_codec_write(codec, nid, 0,
390 AC_VERB_SET_AMP_GAIN_MUTE,
391 AMP_IN_UNMUTE(0));
358 } else { 392 } else {
359 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 393 snd_hda_codec_write(codec, nid, 0,
360 AMP_IN_MUTE(0)); 394 AC_VERB_SET_AMP_GAIN_MUTE,
361 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 395 AMP_IN_MUTE(0));
362 AMP_OUT_UNMUTE); 396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
398 AMP_OUT_UNMUTE);
363 } 399 }
364 } 400 }
365 return change; 401 return change;
@@ -378,7 +414,8 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
378 * needed for any "production" models. 414 * needed for any "production" models.
379 */ 415 */
380#ifdef CONFIG_SND_DEBUG 416#ifdef CONFIG_SND_DEBUG
381static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 417static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_info *uinfo)
382{ 419{
383 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 420 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
384 uinfo->count = 1; 421 uinfo->count = 1;
@@ -386,33 +423,38 @@ static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
386 uinfo->value.integer.max = 1; 423 uinfo->value.integer.max = 1;
387 return 0; 424 return 0;
388} 425}
389static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 426static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_value *ucontrol)
390{ 428{
391 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 429 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
392 hda_nid_t nid = kcontrol->private_value & 0xffff; 430 hda_nid_t nid = kcontrol->private_value & 0xffff;
393 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 431 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
394 long *valp = ucontrol->value.integer.value; 432 long *valp = ucontrol->value.integer.value;
395 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); 433 unsigned int val = snd_hda_codec_read(codec, nid, 0,
434 AC_VERB_GET_GPIO_DATA, 0x00);
396 435
397 *valp = (val & mask) != 0; 436 *valp = (val & mask) != 0;
398 return 0; 437 return 0;
399} 438}
400static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 439static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
401{ 441{
402 signed int change; 442 signed int change;
403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
404 hda_nid_t nid = kcontrol->private_value & 0xffff; 444 hda_nid_t nid = kcontrol->private_value & 0xffff;
405 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 445 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
406 long val = *ucontrol->value.integer.value; 446 long val = *ucontrol->value.integer.value;
407 unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); 447 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
448 AC_VERB_GET_GPIO_DATA,
449 0x00);
408 450
409 /* Set/unset the masked GPIO bit(s) as needed */ 451 /* Set/unset the masked GPIO bit(s) as needed */
410 change = (val==0?0:mask) != (gpio_data & mask); 452 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
411 if (val==0) 453 if (val == 0)
412 gpio_data &= ~mask; 454 gpio_data &= ~mask;
413 else 455 else
414 gpio_data |= mask; 456 gpio_data |= mask;
415 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data); 457 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
416 458
417 return change; 459 return change;
418} 460}
@@ -432,7 +474,8 @@ static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
432 * necessary. 474 * necessary.
433 */ 475 */
434#ifdef CONFIG_SND_DEBUG 476#ifdef CONFIG_SND_DEBUG
435static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 477static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_info *uinfo)
436{ 479{
437 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 480 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
438 uinfo->count = 1; 481 uinfo->count = 1;
@@ -440,33 +483,39 @@ static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
440 uinfo->value.integer.max = 1; 483 uinfo->value.integer.max = 1;
441 return 0; 484 return 0;
442} 485}
443static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 486static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
444{ 488{
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 hda_nid_t nid = kcontrol->private_value & 0xffff; 490 hda_nid_t nid = kcontrol->private_value & 0xffff;
447 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 491 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
448 long *valp = ucontrol->value.integer.value; 492 long *valp = ucontrol->value.integer.value;
449 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); 493 unsigned int val = snd_hda_codec_read(codec, nid, 0,
494 AC_VERB_GET_DIGI_CONVERT, 0x00);
450 495
451 *valp = (val & mask) != 0; 496 *valp = (val & mask) != 0;
452 return 0; 497 return 0;
453} 498}
454static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 499static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
455{ 501{
456 signed int change; 502 signed int change;
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 hda_nid_t nid = kcontrol->private_value & 0xffff; 504 hda_nid_t nid = kcontrol->private_value & 0xffff;
459 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 505 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
460 long val = *ucontrol->value.integer.value; 506 long val = *ucontrol->value.integer.value;
461 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); 507 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
508 AC_VERB_GET_DIGI_CONVERT,
509 0x00);
462 510
463 /* Set/unset the masked control bit(s) as needed */ 511 /* Set/unset the masked control bit(s) as needed */
464 change = (val==0?0:mask) != (ctrl_data & mask); 512 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
465 if (val==0) 513 if (val==0)
466 ctrl_data &= ~mask; 514 ctrl_data &= ~mask;
467 else 515 else
468 ctrl_data |= mask; 516 ctrl_data |= mask;
469 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data); 517 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
518 ctrl_data);
470 519
471 return change; 520 return change;
472} 521}
@@ -481,14 +530,17 @@ static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
481/* 530/*
482 * set up from the preset table 531 * set up from the preset table
483 */ 532 */
484static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset) 533static void setup_preset(struct alc_spec *spec,
534 const struct alc_config_preset *preset)
485{ 535{
486 int i; 536 int i;
487 537
488 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 538 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
489 spec->mixers[spec->num_mixers++] = preset->mixers[i]; 539 spec->mixers[spec->num_mixers++] = preset->mixers[i];
490 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) 540 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
491 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; 541 i++)
542 spec->init_verbs[spec->num_init_verbs++] =
543 preset->init_verbs[i];
492 544
493 spec->channel_mode = preset->channel_mode; 545 spec->channel_mode = preset->channel_mode;
494 spec->num_channel_mode = preset->num_channel_mode; 546 spec->num_channel_mode = preset->num_channel_mode;
@@ -517,8 +569,8 @@ static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *
517 * ALC880 3-stack model 569 * ALC880 3-stack model
518 * 570 *
519 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) 571 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
520 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b 572 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
521 * HP = 0x19 573 * F-Mic = 0x1b, HP = 0x19
522 */ 574 */
523 575
524static hda_nid_t alc880_dac_nids[4] = { 576static hda_nid_t alc880_dac_nids[4] = {
@@ -662,7 +714,8 @@ static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
662/* 714/*
663 * ALC880 5-stack model 715 * ALC880 5-stack model
664 * 716 *
665 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd) 717 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
718 * Side = 0x02 (0xd)
666 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 719 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
667 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 720 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
668 */ 721 */
@@ -700,7 +753,8 @@ static struct hda_channel_mode alc880_fivestack_modes[2] = {
700/* 753/*
701 * ALC880 6-stack model 754 * ALC880 6-stack model
702 * 755 *
703 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f) 756 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
757 * Side = 0x05 (0x0f)
704 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, 758 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
705 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b 759 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
706 */ 760 */
@@ -811,7 +865,8 @@ static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
811 * Z710V model 865 * Z710V model
812 * 866 *
813 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) 867 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
814 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a 868 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
869 * Line = 0x1a
815 */ 870 */
816 871
817static hda_nid_t alc880_z71v_dac_nids[1] = { 872static hda_nid_t alc880_z71v_dac_nids[1] = {
@@ -966,7 +1021,8 @@ static int alc_build_controls(struct hda_codec *codec)
966 } 1021 }
967 1022
968 if (spec->multiout.dig_out_nid) { 1023 if (spec->multiout.dig_out_nid) {
969 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 1024 err = snd_hda_create_spdif_out_ctls(codec,
1025 spec->multiout.dig_out_nid);
970 if (err < 0) 1026 if (err < 0)
971 return err; 1027 return err;
972 } 1028 }
@@ -999,8 +1055,8 @@ static struct hda_verb alc880_volume_init_verbs[] = {
999 1055
1000 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 1056 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1001 * mixer widget 1057 * mixer widget
1002 * Note: PASD motherboards uses the Line In 2 as the input for front panel 1058 * Note: PASD motherboards uses the Line In 2 as the input for front
1003 * mic (mic 2) 1059 * panel mic (mic 2)
1004 */ 1060 */
1005 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 1061 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -1154,8 +1210,8 @@ static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1154 1210
1155/* 1211/*
1156 * 6-stack pin configuration: 1212 * 6-stack pin configuration:
1157 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19, 1213 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1158 * line = 0x1a, HP = 0x1b 1214 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1159 */ 1215 */
1160static struct hda_verb alc880_pin_6stack_init_verbs[] = { 1216static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1161 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1217 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
@@ -1587,8 +1643,8 @@ static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1587 struct snd_pcm_substream *substream) 1643 struct snd_pcm_substream *substream)
1588{ 1644{
1589 struct alc_spec *spec = codec->spec; 1645 struct alc_spec *spec = codec->spec;
1590 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, 1646 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1591 format, substream); 1647 stream_tag, format, substream);
1592} 1648}
1593 1649
1594static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 1650static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
@@ -1640,7 +1696,8 @@ static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1640{ 1696{
1641 struct alc_spec *spec = codec->spec; 1697 struct alc_spec *spec = codec->spec;
1642 1698
1643 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 1699 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1700 0, 0, 0);
1644 return 0; 1701 return 0;
1645} 1702}
1646 1703
@@ -1822,7 +1879,8 @@ static struct hda_channel_mode alc880_test_modes[4] = {
1822 { 8, NULL }, 1879 { 8, NULL },
1823}; 1880};
1824 1881
1825static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1882static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1883 struct snd_ctl_elem_info *uinfo)
1826{ 1884{
1827 static char *texts[] = { 1885 static char *texts[] = {
1828 "N/A", "Line Out", "HP Out", 1886 "N/A", "Line Out", "HP Out",
@@ -1837,7 +1895,8 @@ static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1837 return 0; 1895 return 0;
1838} 1896}
1839 1897
1840static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1898static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1899 struct snd_ctl_elem_value *ucontrol)
1841{ 1900{
1842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1901 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1843 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1902 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
@@ -1863,7 +1922,8 @@ static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_el
1863 return 0; 1922 return 0;
1864} 1923}
1865 1924
1866static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1925static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1926 struct snd_ctl_elem_value *ucontrol)
1867{ 1927{
1868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1869 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1929 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
@@ -1881,15 +1941,18 @@ static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
1881 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1941 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1882 new_ctl = ctls[ucontrol->value.enumerated.item[0]]; 1942 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1883 if (old_ctl != new_ctl) { 1943 if (old_ctl != new_ctl) {
1884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); 1944 snd_hda_codec_write(codec, nid, 0,
1945 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1885 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1946 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1886 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); 1947 (ucontrol->value.enumerated.item[0] >= 3 ?
1948 0xb080 : 0xb000));
1887 return 1; 1949 return 1;
1888 } 1950 }
1889 return 0; 1951 return 0;
1890} 1952}
1891 1953
1892static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1954static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1955 struct snd_ctl_elem_info *uinfo)
1893{ 1956{
1894 static char *texts[] = { 1957 static char *texts[] = {
1895 "Front", "Surround", "CLFE", "Side" 1958 "Front", "Surround", "CLFE", "Side"
@@ -1903,7 +1966,8 @@ static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1903 return 0; 1966 return 0;
1904} 1967}
1905 1968
1906static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1969static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1970 struct snd_ctl_elem_value *ucontrol)
1907{ 1971{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1972 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1973 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
@@ -1914,7 +1978,8 @@ static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_el
1914 return 0; 1978 return 0;
1915} 1979}
1916 1980
1917static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1981static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1918{ 1983{
1919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1985 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
@@ -2739,7 +2804,8 @@ static int patch_alc880(struct hda_codec *codec)
2739 2804
2740 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); 2805 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2741 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { 2806 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2742 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); 2807 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2808 "trying auto-probe from BIOS...\n");
2743 board_config = ALC880_AUTO; 2809 board_config = ALC880_AUTO;
2744 } 2810 }
2745 2811
@@ -2750,7 +2816,9 @@ static int patch_alc880(struct hda_codec *codec)
2750 alc_free(codec); 2816 alc_free(codec);
2751 return err; 2817 return err;
2752 } else if (! err) { 2818 } else if (! err) {
2753 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n"); 2819 printk(KERN_INFO
2820 "hda_codec: Cannot set up configuration "
2821 "from BIOS. Using 3-stack mode...\n");
2754 board_config = ALC880_3ST; 2822 board_config = ALC880_3ST;
2755 } 2823 }
2756 } 2824 }
@@ -3947,7 +4015,8 @@ static int patch_alc260(struct hda_codec *codec)
3947 4015
3948 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); 4016 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3949 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { 4017 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3950 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); 4018 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4019 "trying auto-probe from BIOS...\n");
3951 board_config = ALC260_AUTO; 4020 board_config = ALC260_AUTO;
3952 } 4021 }
3953 4022
@@ -3958,7 +4027,9 @@ static int patch_alc260(struct hda_codec *codec)
3958 alc_free(codec); 4027 alc_free(codec);
3959 return err; 4028 return err;
3960 } else if (! err) { 4029 } else if (! err) {
3961 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 4030 printk(KERN_INFO
4031 "hda_codec: Cannot set up configuration "
4032 "from BIOS. Using base mode...\n");
3962 board_config = ALC260_BASIC; 4033 board_config = ALC260_BASIC;
3963 } 4034 }
3964 } 4035 }
@@ -4320,9 +4391,12 @@ static struct snd_kcontrol_new alc882_capture_mixer[] = {
4320static struct hda_board_config alc882_cfg_tbl[] = { 4391static struct hda_board_config alc882_cfg_tbl[] = {
4321 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG }, 4392 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4322 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG }, 4393 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4323 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ 4394 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4324 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ 4395 .config = ALC882_6ST_DIG }, /* MSI */
4325 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ 4396 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4397 .config = ALC882_6ST_DIG }, /* Foxconn */
4398 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4399 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4326 { .modelname = "auto", .config = ALC882_AUTO }, 4400 { .modelname = "auto", .config = ALC882_AUTO },
4327 {} 4401 {}
4328}; 4402};
@@ -4439,10 +4513,6 @@ static void alc882_auto_init(struct hda_codec *codec)
4439 alc882_auto_init_analog_input(codec); 4513 alc882_auto_init_analog_input(codec);
4440} 4514}
4441 4515
4442/*
4443 * ALC882 Headphone poll in 3.5.1a or 3.5.2
4444 */
4445
4446static int patch_alc882(struct hda_codec *codec) 4516static int patch_alc882(struct hda_codec *codec)
4447{ 4517{
4448 struct alc_spec *spec; 4518 struct alc_spec *spec;
@@ -4457,7 +4527,8 @@ static int patch_alc882(struct hda_codec *codec)
4457 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); 4527 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4458 4528
4459 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { 4529 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4460 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n"); 4530 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4531 "trying auto-probe from BIOS...\n");
4461 board_config = ALC882_AUTO; 4532 board_config = ALC882_AUTO;
4462 } 4533 }
4463 4534
@@ -4468,7 +4539,9 @@ static int patch_alc882(struct hda_codec *codec)
4468 alc_free(codec); 4539 alc_free(codec);
4469 return err; 4540 return err;
4470 } else if (! err) { 4541 } else if (! err) {
4471 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 4542 printk(KERN_INFO
4543 "hda_codec: Cannot set up configuration "
4544 "from BIOS. Using base mode...\n");
4472 board_config = ALC882_3ST_DIG; 4545 board_config = ALC882_3ST_DIG;
4473 } 4546 }
4474 } 4547 }
@@ -4509,6 +4582,652 @@ static int patch_alc882(struct hda_codec *codec)
4509} 4582}
4510 4583
4511/* 4584/*
4585 * ALC883 support
4586 *
4587 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4588 * configuration. Each pin widget can choose any input DACs and a mixer.
4589 * Each ADC is connected from a mixer of all inputs. This makes possible
4590 * 6-channel independent captures.
4591 *
4592 * In addition, an independent DAC for the multi-playback (not used in this
4593 * driver yet).
4594 */
4595#define ALC883_DIGOUT_NID 0x06
4596#define ALC883_DIGIN_NID 0x0a
4597
4598static hda_nid_t alc883_dac_nids[4] = {
4599 /* front, rear, clfe, rear_surr */
4600 0x02, 0x04, 0x03, 0x05
4601};
4602
4603static hda_nid_t alc883_adc_nids[2] = {
4604 /* ADC1-2 */
4605 0x08, 0x09,
4606};
4607/* input MUX */
4608/* FIXME: should be a matrix-type input source selection */
4609
4610static struct hda_input_mux alc883_capture_source = {
4611 .num_items = 4,
4612 .items = {
4613 { "Mic", 0x0 },
4614 { "Front Mic", 0x1 },
4615 { "Line", 0x2 },
4616 { "CD", 0x4 },
4617 },
4618};
4619#define alc883_mux_enum_info alc_mux_enum_info
4620#define alc883_mux_enum_get alc_mux_enum_get
4621
4622static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4623 struct snd_ctl_elem_value *ucontrol)
4624{
4625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4626 struct alc_spec *spec = codec->spec;
4627 const struct hda_input_mux *imux = spec->input_mux;
4628 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4629 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4630 hda_nid_t nid = capture_mixers[adc_idx];
4631 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4632 unsigned int i, idx;
4633
4634 idx = ucontrol->value.enumerated.item[0];
4635 if (idx >= imux->num_items)
4636 idx = imux->num_items - 1;
4637 if (*cur_val == idx && ! codec->in_resume)
4638 return 0;
4639 for (i = 0; i < imux->num_items; i++) {
4640 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4641 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4642 v | (imux->items[i].index << 8));
4643 }
4644 *cur_val = idx;
4645 return 1;
4646}
4647/*
4648 * 2ch mode
4649 */
4650static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4651 { 2, NULL }
4652};
4653
4654/*
4655 * 2ch mode
4656 */
4657static struct hda_verb alc883_3ST_ch2_init[] = {
4658 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4660 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4661 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4662 { } /* end */
4663};
4664
4665/*
4666 * 6ch mode
4667 */
4668static struct hda_verb alc883_3ST_ch6_init[] = {
4669 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4670 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4671 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4672 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4673 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4674 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4675 { } /* end */
4676};
4677
4678static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4679 { 2, alc883_3ST_ch2_init },
4680 { 6, alc883_3ST_ch6_init },
4681};
4682
4683/*
4684 * 6ch mode
4685 */
4686static struct hda_verb alc883_sixstack_ch6_init[] = {
4687 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4688 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4689 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4690 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4691 { } /* end */
4692};
4693
4694/*
4695 * 8ch mode
4696 */
4697static struct hda_verb alc883_sixstack_ch8_init[] = {
4698 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4699 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4700 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4701 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4702 { } /* end */
4703};
4704
4705static struct hda_channel_mode alc883_sixstack_modes[2] = {
4706 { 6, alc883_sixstack_ch6_init },
4707 { 8, alc883_sixstack_ch8_init },
4708};
4709
4710/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4711 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4712 */
4713
4714static struct snd_kcontrol_new alc883_base_mixer[] = {
4715 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4716 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4717 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4718 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4719 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4720 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4721 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4722 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4723 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4724 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4726 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4727 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4732 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4733 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4734 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4735 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4736 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4737 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4738 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4739 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4740 {
4741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4742 /* .name = "Capture Source", */
4743 .name = "Input Source",
4744 .count = 2,
4745 .info = alc883_mux_enum_info,
4746 .get = alc883_mux_enum_get,
4747 .put = alc883_mux_enum_put,
4748 },
4749 { } /* end */
4750};
4751
4752static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4762 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4764 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4765 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4766 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4767 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4768 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4769 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4770 {
4771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4772 /* .name = "Capture Source", */
4773 .name = "Input Source",
4774 .count = 2,
4775 .info = alc883_mux_enum_info,
4776 .get = alc883_mux_enum_get,
4777 .put = alc883_mux_enum_put,
4778 },
4779 { } /* end */
4780};
4781
4782static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4786 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4788 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4800 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4801 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4802 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4803 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4804 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4805 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4806 {
4807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4808 /* .name = "Capture Source", */
4809 .name = "Input Source",
4810 .count = 2,
4811 .info = alc883_mux_enum_info,
4812 .get = alc883_mux_enum_get,
4813 .put = alc883_mux_enum_put,
4814 },
4815 { } /* end */
4816};
4817
4818static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4819 {
4820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4821 .name = "Channel Mode",
4822 .info = alc_ch_mode_info,
4823 .get = alc_ch_mode_get,
4824 .put = alc_ch_mode_put,
4825 },
4826 { } /* end */
4827};
4828
4829static struct hda_verb alc883_init_verbs[] = {
4830 /* ADC1: mute amp left and right */
4831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4832 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4833 /* ADC2: mute amp left and right */
4834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4835 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4836 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4840 /* Rear mixer */
4841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4843 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4844 /* CLFE mixer */
4845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4848 /* Side mixer */
4849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4852
4853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4858
4859 /* Front Pin: output 0 (0x0c) */
4860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4862 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4863 /* Rear Pin: output 1 (0x0d) */
4864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4867 /* CLFE Pin: output 2 (0x0e) */
4868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4870 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4871 /* Side Pin: output 3 (0x0f) */
4872 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4874 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4875 /* Mic (rear) pin: input vref at 80% */
4876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4878 /* Front Mic pin: input vref at 80% */
4879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4881 /* Line In pin: input */
4882 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4884 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4886 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4887 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4888 /* CD pin widget for input */
4889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4890
4891 /* FIXME: use matrix-type input source selection */
4892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4893 /* Input mixer2 */
4894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4898 /* Input mixer3 */
4899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4903 { }
4904};
4905
4906/*
4907 * generic initialization of ADC, input mixers and output mixers
4908 */
4909static struct hda_verb alc883_auto_init_verbs[] = {
4910 /*
4911 * Unmute ADC0-2 and set the default input to mic-in
4912 */
4913 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4914 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4915 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4917
4918 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4919 * mixer widget
4920 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4921 * mic (mic 2)
4922 */
4923 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4929
4930 /*
4931 * Set up output mixers (0x0c - 0x0f)
4932 */
4933 /* set vol=0 to output mixers */
4934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4938 /* set up input amps for analog loopback */
4939 /* Amp Indices: DAC = 0, mixer = 1 */
4940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4948 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4949 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4950
4951 /* FIXME: use matrix-type input source selection */
4952 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4953 /* Input mixer1 */
4954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4957 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4958 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4959 /* Input mixer2 */
4960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4963 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4965
4966 { }
4967};
4968
4969/* capture mixer elements */
4970static struct snd_kcontrol_new alc883_capture_mixer[] = {
4971 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4972 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4973 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4974 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4975 {
4976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4977 /* The multiple "Capture Source" controls confuse alsamixer
4978 * So call somewhat different..
4979 * FIXME: the controls appear in the "playback" view!
4980 */
4981 /* .name = "Capture Source", */
4982 .name = "Input Source",
4983 .count = 2,
4984 .info = alc882_mux_enum_info,
4985 .get = alc882_mux_enum_get,
4986 .put = alc882_mux_enum_put,
4987 },
4988 { } /* end */
4989};
4990
4991/* pcm configuration: identiacal with ALC880 */
4992#define alc883_pcm_analog_playback alc880_pcm_analog_playback
4993#define alc883_pcm_analog_capture alc880_pcm_analog_capture
4994#define alc883_pcm_digital_playback alc880_pcm_digital_playback
4995#define alc883_pcm_digital_capture alc880_pcm_digital_capture
4996
4997/*
4998 * configuration and preset
4999 */
5000static struct hda_board_config alc883_cfg_tbl[] = {
5001 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5002 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5003 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5004 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5005 .config = ALC883_6ST_DIG }, /* MSI */
5006 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5007 .config = ALC883_6ST_DIG }, /* Foxconn */
5008 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5009 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5010 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5011 .config = ALC883_3ST_6ch },
5012 { .modelname = "auto", .config = ALC883_AUTO },
5013 {}
5014};
5015
5016static struct alc_config_preset alc883_presets[] = {
5017 [ALC883_3ST_2ch_DIG] = {
5018 .mixers = { alc883_3ST_2ch_mixer },
5019 .init_verbs = { alc883_init_verbs },
5020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5021 .dac_nids = alc883_dac_nids,
5022 .dig_out_nid = ALC883_DIGOUT_NID,
5023 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5024 .adc_nids = alc883_adc_nids,
5025 .dig_in_nid = ALC883_DIGIN_NID,
5026 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5027 .channel_mode = alc883_3ST_2ch_modes,
5028 .input_mux = &alc883_capture_source,
5029 },
5030 [ALC883_3ST_6ch_DIG] = {
5031 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5032 .init_verbs = { alc883_init_verbs },
5033 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5034 .dac_nids = alc883_dac_nids,
5035 .dig_out_nid = ALC883_DIGOUT_NID,
5036 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5037 .adc_nids = alc883_adc_nids,
5038 .dig_in_nid = ALC883_DIGIN_NID,
5039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5040 .channel_mode = alc883_3ST_6ch_modes,
5041 .input_mux = &alc883_capture_source,
5042 },
5043 [ALC883_3ST_6ch] = {
5044 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5045 .init_verbs = { alc883_init_verbs },
5046 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5047 .dac_nids = alc883_dac_nids,
5048 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5049 .adc_nids = alc883_adc_nids,
5050 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5051 .channel_mode = alc883_3ST_6ch_modes,
5052 .input_mux = &alc883_capture_source,
5053 },
5054 [ALC883_6ST_DIG] = {
5055 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5056 .init_verbs = { alc883_init_verbs },
5057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5058 .dac_nids = alc883_dac_nids,
5059 .dig_out_nid = ALC883_DIGOUT_NID,
5060 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5061 .adc_nids = alc883_adc_nids,
5062 .dig_in_nid = ALC883_DIGIN_NID,
5063 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5064 .channel_mode = alc883_sixstack_modes,
5065 .input_mux = &alc883_capture_source,
5066 },
5067 [ALC888_DEMO_BOARD] = {
5068 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5069 .init_verbs = { alc883_init_verbs },
5070 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5071 .dac_nids = alc883_dac_nids,
5072 .dig_out_nid = ALC883_DIGOUT_NID,
5073 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5074 .adc_nids = alc883_adc_nids,
5075 .dig_in_nid = ALC883_DIGIN_NID,
5076 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5077 .channel_mode = alc883_sixstack_modes,
5078 .input_mux = &alc883_capture_source,
5079 },
5080};
5081
5082
5083/*
5084 * BIOS auto configuration
5085 */
5086static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5087 hda_nid_t nid, int pin_type,
5088 int dac_idx)
5089{
5090 /* set as output */
5091 struct alc_spec *spec = codec->spec;
5092 int idx;
5093
5094 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5095 idx = 4;
5096 else
5097 idx = spec->multiout.dac_nids[dac_idx] - 2;
5098
5099 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5100 pin_type);
5101 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5102 AMP_OUT_UNMUTE);
5103 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5104
5105}
5106
5107static void alc883_auto_init_multi_out(struct hda_codec *codec)
5108{
5109 struct alc_spec *spec = codec->spec;
5110 int i;
5111
5112 for (i = 0; i <= HDA_SIDE; i++) {
5113 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5114 if (nid)
5115 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5116 }
5117}
5118
5119static void alc883_auto_init_hp_out(struct hda_codec *codec)
5120{
5121 struct alc_spec *spec = codec->spec;
5122 hda_nid_t pin;
5123
5124 pin = spec->autocfg.hp_pin;
5125 if (pin) /* connect to front */
5126 /* use dac 0 */
5127 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5128}
5129
5130#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5131#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5132
5133static void alc883_auto_init_analog_input(struct hda_codec *codec)
5134{
5135 struct alc_spec *spec = codec->spec;
5136 int i;
5137
5138 for (i = 0; i < AUTO_PIN_LAST; i++) {
5139 hda_nid_t nid = spec->autocfg.input_pins[i];
5140 if (alc883_is_input_pin(nid)) {
5141 snd_hda_codec_write(codec, nid, 0,
5142 AC_VERB_SET_PIN_WIDGET_CONTROL,
5143 (i <= AUTO_PIN_FRONT_MIC ?
5144 PIN_VREF80 : PIN_IN));
5145 if (nid != ALC883_PIN_CD_NID)
5146 snd_hda_codec_write(codec, nid, 0,
5147 AC_VERB_SET_AMP_GAIN_MUTE,
5148 AMP_OUT_MUTE);
5149 }
5150 }
5151}
5152
5153/* almost identical with ALC880 parser... */
5154static int alc883_parse_auto_config(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
5157 int err = alc880_parse_auto_config(codec);
5158
5159 if (err < 0)
5160 return err;
5161 else if (err > 0)
5162 /* hack - override the init verbs */
5163 spec->init_verbs[0] = alc883_auto_init_verbs;
5164 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5165 spec->num_mixers++;
5166 return err;
5167}
5168
5169/* additional initialization for auto-configuration model */
5170static void alc883_auto_init(struct hda_codec *codec)
5171{
5172 alc883_auto_init_multi_out(codec);
5173 alc883_auto_init_hp_out(codec);
5174 alc883_auto_init_analog_input(codec);
5175}
5176
5177static int patch_alc883(struct hda_codec *codec)
5178{
5179 struct alc_spec *spec;
5180 int err, board_config;
5181
5182 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5183 if (spec == NULL)
5184 return -ENOMEM;
5185
5186 codec->spec = spec;
5187
5188 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5189 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5190 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5191 "trying auto-probe from BIOS...\n");
5192 board_config = ALC883_AUTO;
5193 }
5194
5195 if (board_config == ALC883_AUTO) {
5196 /* automatic parse from the BIOS config */
5197 err = alc883_parse_auto_config(codec);
5198 if (err < 0) {
5199 alc_free(codec);
5200 return err;
5201 } else if (! err) {
5202 printk(KERN_INFO
5203 "hda_codec: Cannot set up configuration "
5204 "from BIOS. Using base mode...\n");
5205 board_config = ALC883_3ST_2ch_DIG;
5206 }
5207 }
5208
5209 if (board_config != ALC883_AUTO)
5210 setup_preset(spec, &alc883_presets[board_config]);
5211
5212 spec->stream_name_analog = "ALC883 Analog";
5213 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5214 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5215
5216 spec->stream_name_digital = "ALC883 Digital";
5217 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5218 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5219
5220 spec->adc_nids = alc883_adc_nids;
5221 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5222
5223 codec->patch_ops = alc_patch_ops;
5224 if (board_config == ALC883_AUTO)
5225 spec->init_hook = alc883_auto_init;
5226
5227 return 0;
5228}
5229
5230/*
4512 * ALC262 support 5231 * ALC262 support
4513 */ 5232 */
4514 5233
@@ -4542,6 +5261,28 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
4542 { } /* end */ 5261 { } /* end */
4543}; 5262};
4544 5263
5264static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5265 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5266 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5268 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5269 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5270
5271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5276 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5277 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5278 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5279 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5280 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5281 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5282 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5283 { } /* end */
5284};
5285
4545#define alc262_capture_mixer alc882_capture_mixer 5286#define alc262_capture_mixer alc882_capture_mixer
4546#define alc262_capture_alt_mixer alc882_capture_alt_mixer 5287#define alc262_capture_alt_mixer alc882_capture_alt_mixer
4547 5288
@@ -4645,6 +5386,17 @@ static struct hda_input_mux alc262_fujitsu_capture_source = {
4645 }, 5386 },
4646}; 5387};
4647 5388
5389static struct hda_input_mux alc262_HP_capture_source = {
5390 .num_items = 5,
5391 .items = {
5392 { "Mic", 0x0 },
5393 { "Front Mic", 0x3 },
5394 { "Line", 0x2 },
5395 { "CD", 0x4 },
5396 { "AUX IN", 0x6 },
5397 },
5398};
5399
4648/* mute/unmute internal speaker according to the hp jack and mute state */ 5400/* mute/unmute internal speaker according to the hp jack and mute state */
4649static void alc262_fujitsu_automute(struct hda_codec *codec, int force) 5401static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
4650{ 5402{
@@ -4868,6 +5620,93 @@ static struct hda_verb alc262_volume_init_verbs[] = {
4868 { } 5620 { }
4869}; 5621};
4870 5622
5623static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5624 /*
5625 * Unmute ADC0-2 and set the default input to mic-in
5626 */
5627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5633
5634 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5635 * mixer widget
5636 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5637 * mic (mic 2)
5638 */
5639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5647
5648 /*
5649 * Set up output mixers (0x0c - 0x0e)
5650 */
5651 /* set vol=0 to output mixers */
5652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655
5656 /* set up input amps for analog loopback */
5657 /* Amp Indices: DAC = 0, mixer = 1 */
5658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5664
5665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5668
5669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5671
5672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5674
5675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5679 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5680
5681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5684 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5685 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5686 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5687
5688
5689 /* FIXME: use matrix-type input source selection */
5690 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5691 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5696 /* Input mixer2 */
5697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5701 /* Input mixer3 */
5702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5706
5707 { }
5708};
5709
4871/* pcm configuration: identiacal with ALC880 */ 5710/* pcm configuration: identiacal with ALC880 */
4872#define alc262_pcm_analog_playback alc880_pcm_analog_playback 5711#define alc262_pcm_analog_playback alc880_pcm_analog_playback
4873#define alc262_pcm_analog_capture alc880_pcm_analog_capture 5712#define alc262_pcm_analog_capture alc880_pcm_analog_capture
@@ -4928,7 +5767,16 @@ static void alc262_auto_init(struct hda_codec *codec)
4928static struct hda_board_config alc262_cfg_tbl[] = { 5767static struct hda_board_config alc262_cfg_tbl[] = {
4929 { .modelname = "basic", .config = ALC262_BASIC }, 5768 { .modelname = "basic", .config = ALC262_BASIC },
4930 { .modelname = "fujitsu", .config = ALC262_FUJITSU }, 5769 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
4931 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU }, 5770 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5771 .config = ALC262_FUJITSU },
5772 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5773 .config = ALC262_HP_BPC }, /* xw4400 */
5774 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5775 .config = ALC262_HP_BPC }, /* xw6400 */
5776 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5777 .config = ALC262_HP_BPC }, /* xw8400 */
5778 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5779 .config = ALC262_HP_BPC }, /* xw9400 */
4932 { .modelname = "auto", .config = ALC262_AUTO }, 5780 { .modelname = "auto", .config = ALC262_AUTO },
4933 {} 5781 {}
4934}; 5782};
@@ -4956,6 +5804,16 @@ static struct alc_config_preset alc262_presets[] = {
4956 .input_mux = &alc262_fujitsu_capture_source, 5804 .input_mux = &alc262_fujitsu_capture_source,
4957 .unsol_event = alc262_fujitsu_unsol_event, 5805 .unsol_event = alc262_fujitsu_unsol_event,
4958 }, 5806 },
5807 [ALC262_HP_BPC] = {
5808 .mixers = { alc262_HP_BPC_mixer },
5809 .init_verbs = { alc262_HP_BPC_init_verbs },
5810 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5811 .dac_nids = alc262_dac_nids,
5812 .hp_nid = 0x03,
5813 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5814 .channel_mode = alc262_modes,
5815 .input_mux = &alc262_HP_capture_source,
5816 },
4959}; 5817};
4960 5818
4961static int patch_alc262(struct hda_codec *codec) 5819static int patch_alc262(struct hda_codec *codec)
@@ -4981,8 +5839,10 @@ static int patch_alc262(struct hda_codec *codec)
4981#endif 5839#endif
4982 5840
4983 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); 5841 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
5842
4984 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { 5843 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4985 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n"); 5844 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5845 "trying auto-probe from BIOS...\n");
4986 board_config = ALC262_AUTO; 5846 board_config = ALC262_AUTO;
4987 } 5847 }
4988 5848
@@ -4993,7 +5853,9 @@ static int patch_alc262(struct hda_codec *codec)
4993 alc_free(codec); 5853 alc_free(codec);
4994 return err; 5854 return err;
4995 } else if (! err) { 5855 } else if (! err) {
4996 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 5856 printk(KERN_INFO
5857 "hda_codec: Cannot set up configuration "
5858 "from BIOS. Using base mode...\n");
4997 board_config = ALC262_BASIC; 5859 board_config = ALC262_BASIC;
4998 } 5860 }
4999 } 5861 }
@@ -5034,7 +5896,6 @@ static int patch_alc262(struct hda_codec *codec)
5034 return 0; 5896 return 0;
5035} 5897}
5036 5898
5037
5038/* 5899/*
5039 * ALC861 channel source setting (2/6 channel selection for 3-stack) 5900 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5040 */ 5901 */
@@ -5049,9 +5910,11 @@ static struct hda_verb alc861_threestack_ch2_init[] = {
5049 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 5910 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5050 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 5911 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5051 5912
5052 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 5913 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5053 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic 5914#if 0
5054 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in 5915 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5916 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
5917#endif
5055 { } /* end */ 5918 { } /* end */
5056}; 5919};
5057/* 5920/*
@@ -5065,11 +5928,13 @@ static struct hda_verb alc861_threestack_ch6_init[] = {
5065 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 5928 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5066 5929
5067 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, 5930 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
5068 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, 5931 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
5069 5932
5070 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 5933 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
5071 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic 5934#if 0
5072 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in 5935 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
5936 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
5937#endif
5073 { } /* end */ 5938 { } /* end */
5074}; 5939};
5075 5940
@@ -5353,6 +6218,11 @@ static hda_nid_t alc861_dac_nids[4] = {
5353 0x03, 0x06, 0x05, 0x04 6218 0x03, 0x06, 0x05, 0x04
5354}; 6219};
5355 6220
6221static hda_nid_t alc660_dac_nids[3] = {
6222 /* front, clfe, surround */
6223 0x03, 0x05, 0x06
6224};
6225
5356static hda_nid_t alc861_adc_nids[1] = { 6226static hda_nid_t alc861_adc_nids[1] = {
5357 /* ADC0-2 */ 6227 /* ADC0-2 */
5358 0x08, 6228 0x08,
@@ -5605,7 +6475,10 @@ static void alc861_auto_init(struct hda_codec *codec)
5605 */ 6475 */
5606static struct hda_board_config alc861_cfg_tbl[] = { 6476static struct hda_board_config alc861_cfg_tbl[] = {
5607 { .modelname = "3stack", .config = ALC861_3ST }, 6477 { .modelname = "3stack", .config = ALC861_3ST },
5608 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST }, 6478 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6479 .config = ALC861_3ST },
6480 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6481 .config = ALC660_3ST },
5609 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, 6482 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
5610 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, 6483 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
5611 { .modelname = "auto", .config = ALC861_AUTO }, 6484 { .modelname = "auto", .config = ALC861_AUTO },
@@ -5648,6 +6521,17 @@ static struct alc_config_preset alc861_presets[] = {
5648 .adc_nids = alc861_adc_nids, 6521 .adc_nids = alc861_adc_nids,
5649 .input_mux = &alc861_capture_source, 6522 .input_mux = &alc861_capture_source,
5650 }, 6523 },
6524 [ALC660_3ST] = {
6525 .mixers = { alc861_3ST_mixer },
6526 .init_verbs = { alc861_threestack_init_verbs },
6527 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6528 .dac_nids = alc660_dac_nids,
6529 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6530 .channel_mode = alc861_threestack_modes,
6531 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6532 .adc_nids = alc861_adc_nids,
6533 .input_mux = &alc861_capture_source,
6534 },
5651}; 6535};
5652 6536
5653 6537
@@ -5664,8 +6548,10 @@ static int patch_alc861(struct hda_codec *codec)
5664 codec->spec = spec; 6548 codec->spec = spec;
5665 6549
5666 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); 6550 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
6551
5667 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { 6552 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
5668 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n"); 6553 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6554 "trying auto-probe from BIOS...\n");
5669 board_config = ALC861_AUTO; 6555 board_config = ALC861_AUTO;
5670 } 6556 }
5671 6557
@@ -5676,7 +6562,9 @@ static int patch_alc861(struct hda_codec *codec)
5676 alc_free(codec); 6562 alc_free(codec);
5677 return err; 6563 return err;
5678 } else if (! err) { 6564 } else if (! err) {
5679 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 6565 printk(KERN_INFO
6566 "hda_codec: Cannot set up configuration "
6567 "from BIOS. Using base mode...\n");
5680 board_config = ALC861_3ST_DIG; 6568 board_config = ALC861_3ST_DIG;
5681 } 6569 }
5682 } 6570 }
@@ -5707,8 +6595,12 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
5707 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 6595 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
5708 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 6596 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
5709 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 6597 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
5710 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, 6598 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
5711 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 6599 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5712 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 6600 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6601 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6602 .patch = patch_alc861 },
6603 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6604 .patch = patch_alc861 },
5713 {} /* terminator */ 6605 {} /* terminator */
5714}; 6606};
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 36f199442fdc..fb4bed0759d1 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -42,6 +42,9 @@
42#define STAC_D945GTP3 1 42#define STAC_D945GTP3 1
43#define STAC_D945GTP5 2 43#define STAC_D945GTP5 2
44#define STAC_MACMINI 3 44#define STAC_MACMINI 3
45#define STAC_D965_2112 4
46#define STAC_D965_284B 5
47#define STAC_922X_MODELS 6 /* number of 922x models */
45 48
46struct sigmatel_spec { 49struct sigmatel_spec {
47 struct snd_kcontrol_new *mixers[4]; 50 struct snd_kcontrol_new *mixers[4];
@@ -107,10 +110,24 @@ static hda_nid_t stac922x_adc_nids[2] = {
107 0x06, 0x07, 110 0x06, 0x07,
108}; 111};
109 112
113static hda_nid_t stac9227_adc_nids[2] = {
114 0x07, 0x08,
115};
116
117#if 0
118static hda_nid_t d965_2112_dac_nids[3] = {
119 0x02, 0x03, 0x05,
120};
121#endif
122
110static hda_nid_t stac922x_mux_nids[2] = { 123static hda_nid_t stac922x_mux_nids[2] = {
111 0x12, 0x13, 124 0x12, 0x13,
112}; 125};
113 126
127static hda_nid_t stac9227_mux_nids[2] = {
128 0x15, 0x16,
129};
130
114static hda_nid_t stac927x_adc_nids[3] = { 131static hda_nid_t stac927x_adc_nids[3] = {
115 0x07, 0x08, 0x09 132 0x07, 0x08, 0x09
116}; 133};
@@ -173,6 +190,24 @@ static struct hda_verb stac922x_core_init[] = {
173 {} 190 {}
174}; 191};
175 192
193static struct hda_verb stac9227_core_init[] = {
194 /* set master volume and direct control */
195 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
196 /* unmute node 0x1b */
197 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
198 {}
199};
200
201static struct hda_verb d965_2112_core_init[] = {
202 /* set master volume and direct control */
203 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
204 /* unmute node 0x1b */
205 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
206 /* select node 0x03 as DAC */
207 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
208 {}
209};
210
176static struct hda_verb stac927x_core_init[] = { 211static struct hda_verb stac927x_core_init[] = {
177 /* set master volume and direct control */ 212 /* set master volume and direct control */
178 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 213 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -212,6 +247,21 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
212 { } /* end */ 247 { } /* end */
213}; 248};
214 249
250/* This needs to be generated dynamically based on sequence */
251static struct snd_kcontrol_new stac9227_mixer[] = {
252 {
253 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
254 .name = "Input Source",
255 .count = 1,
256 .info = stac92xx_mux_enum_info,
257 .get = stac92xx_mux_enum_get,
258 .put = stac92xx_mux_enum_put,
259 },
260 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
261 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
262 { } /* end */
263};
264
215static snd_kcontrol_new_t stac927x_mixer[] = { 265static snd_kcontrol_new_t stac927x_mixer[] = {
216 { 266 {
217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -291,11 +341,17 @@ static unsigned int d945gtp5_pin_configs[10] = {
291 0x02a19320, 0x40000100, 341 0x02a19320, 0x40000100,
292}; 342};
293 343
294static unsigned int *stac922x_brd_tbl[] = { 344static unsigned int d965_2112_pin_configs[10] = {
295 ref922x_pin_configs, 345 0x0221401f, 0x40000100, 0x40000100, 0x01014011,
296 d945gtp3_pin_configs, 346 0x01a19021, 0x01813024, 0x01452130, 0x40000100,
297 d945gtp5_pin_configs, 347 0x02a19320, 0x40000100,
298 NULL, /* STAC_MACMINI */ 348};
349
350static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
351 [STAC_REF] = ref922x_pin_configs,
352 [STAC_D945GTP3] = d945gtp3_pin_configs,
353 [STAC_D945GTP5] = d945gtp5_pin_configs,
354 [STAC_D965_2112] = d965_2112_pin_configs,
299}; 355};
300 356
301static struct hda_board_config stac922x_cfg_tbl[] = { 357static struct hda_board_config stac922x_cfg_tbl[] = {
@@ -330,6 +386,12 @@ static struct hda_board_config stac922x_cfg_tbl[] = {
330 { .pci_subvendor = 0x8384, 386 { .pci_subvendor = 0x8384,
331 .pci_subdevice = 0x7680, 387 .pci_subdevice = 0x7680,
332 .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */ 388 .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */
389 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
390 .pci_subdevice = 0x2112,
391 .config = STAC_D965_2112 },
392 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
393 .pci_subdevice = 0x284b,
394 .config = STAC_D965_284B },
333 {} /* terminator */ 395 {} /* terminator */
334}; 396};
335 397
@@ -713,7 +775,8 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
713 * A and B is not supported. 775 * A and B is not supported.
714 */ 776 */
715/* fill in the dac_nids table from the parsed pin configuration */ 777/* fill in the dac_nids table from the parsed pin configuration */
716static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 778static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
779 const struct auto_pin_cfg *cfg)
717{ 780{
718 struct sigmatel_spec *spec = codec->spec; 781 struct sigmatel_spec *spec = codec->spec;
719 hda_nid_t nid; 782 hda_nid_t nid;
@@ -732,10 +795,13 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct aut
732} 795}
733 796
734/* add playback controls from the parsed DAC table */ 797/* add playback controls from the parsed DAC table */
735static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg) 798static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
799 const struct auto_pin_cfg *cfg)
736{ 800{
737 char name[32]; 801 char name[32];
738 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 802 static const char *chname[4] = {
803 "Front", "Surround", NULL /*CLFE*/, "Side"
804 };
739 hda_nid_t nid; 805 hda_nid_t nid;
740 int i, err; 806 int i, err;
741 807
@@ -893,10 +959,12 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
893 return err; 959 return err;
894 if (! spec->autocfg.line_outs) 960 if (! spec->autocfg.line_outs)
895 return 0; /* can't find valid pin config */ 961 return 0; /* can't find valid pin config */
962
896 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) 963 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
897 return err; 964 return err;
898 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) 965 if (spec->multiout.num_dacs == 0)
899 return err; 966 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
967 return err;
900 968
901 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 969 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
902 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || 970 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
@@ -1194,7 +1262,8 @@ static int patch_stac922x(struct hda_codec *codec)
1194 codec->spec = spec; 1262 codec->spec = spec;
1195 spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl); 1263 spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
1196 if (spec->board_config < 0) 1264 if (spec->board_config < 0)
1197 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n"); 1265 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
1266 "using BIOS defaults\n");
1198 else if (stac922x_brd_tbl[spec->board_config] != NULL) { 1267 else if (stac922x_brd_tbl[spec->board_config] != NULL) {
1199 spec->num_pins = 10; 1268 spec->num_pins = 10;
1200 spec->pin_nids = stac922x_pin_nids; 1269 spec->pin_nids = stac922x_pin_nids;
@@ -1210,6 +1279,25 @@ static int patch_stac922x(struct hda_codec *codec)
1210 spec->mixer = stac922x_mixer; 1279 spec->mixer = stac922x_mixer;
1211 1280
1212 spec->multiout.dac_nids = spec->dac_nids; 1281 spec->multiout.dac_nids = spec->dac_nids;
1282
1283 switch (spec->board_config) {
1284 case STAC_D965_2112:
1285 spec->adc_nids = stac9227_adc_nids;
1286 spec->mux_nids = stac9227_mux_nids;
1287#if 0
1288 spec->multiout.dac_nids = d965_2112_dac_nids;
1289 spec->multiout.num_dacs = ARRAY_SIZE(d965_2112_dac_nids);
1290#endif
1291 spec->init = d965_2112_core_init;
1292 spec->mixer = stac9227_mixer;
1293 break;
1294 case STAC_D965_284B:
1295 spec->adc_nids = stac9227_adc_nids;
1296 spec->mux_nids = stac9227_mux_nids;
1297 spec->init = stac9227_core_init;
1298 spec->mixer = stac9227_mixer;
1299 break;
1300 }
1213 1301
1214 err = stac92xx_parse_auto_config(codec, 0x08, 0x09); 1302 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
1215 if (err < 0) { 1303 if (err < 0) {
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index b5754b32b802..fec9440cb310 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -87,12 +87,25 @@ static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
87 * initialize the chips on M-Audio Revolution cards 87 * initialize the chips on M-Audio Revolution cards
88 */ 88 */
89 89
90static unsigned int revo71_num_stereo_front[] = {2};
91static char *revo71_channel_names_front[] = {"PCM Playback Volume"};
92
93static unsigned int revo71_num_stereo_surround[] = {1, 1, 2, 2};
94static char *revo71_channel_names_surround[] = {"PCM Center Playback Volume", "PCM LFE Playback Volume",
95 "PCM Side Playback Volume", "PCM Rear Playback Volume"};
96
97static unsigned int revo51_num_stereo[] = {2, 1, 1, 2};
98static char *revo51_channel_names[] = {"PCM Playback Volume", "PCM Center Playback Volume",
99 "PCM LFE Playback Volume", "PCM Rear Playback Volume"};
100
90static struct snd_akm4xxx akm_revo_front __devinitdata = { 101static struct snd_akm4xxx akm_revo_front __devinitdata = {
91 .type = SND_AK4381, 102 .type = SND_AK4381,
92 .num_dacs = 2, 103 .num_dacs = 2,
93 .ops = { 104 .ops = {
94 .set_rate_val = revo_set_rate_val 105 .set_rate_val = revo_set_rate_val
95 } 106 },
107 .num_stereo = revo71_num_stereo_front,
108 .channel_names = revo71_channel_names_front
96}; 109};
97 110
98static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 111static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
@@ -113,7 +126,9 @@ static struct snd_akm4xxx akm_revo_surround __devinitdata = {
113 .num_dacs = 6, 126 .num_dacs = 6,
114 .ops = { 127 .ops = {
115 .set_rate_val = revo_set_rate_val 128 .set_rate_val = revo_set_rate_val
116 } 129 },
130 .num_stereo = revo71_num_stereo_surround,
131 .channel_names = revo71_channel_names_surround
117}; 132};
118 133
119static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 134static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
@@ -133,7 +148,9 @@ static struct snd_akm4xxx akm_revo51 __devinitdata = {
133 .num_dacs = 6, 148 .num_dacs = 6,
134 .ops = { 149 .ops = {
135 .set_rate_val = revo_set_rate_val 150 .set_rate_val = revo_set_rate_val
136 } 151 },
152 .num_stereo = revo51_num_stereo,
153 .channel_names = revo51_channel_names
137}; 154};
138 155
139static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { 156static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index dcf402948347..e5511606af04 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1441,10 +1441,10 @@ static int __devinit snd_sonic_probe(struct pci_dev *pci,
1441 1441
1442 strcpy(card->driver, "SonicVibes"); 1442 strcpy(card->driver, "SonicVibes");
1443 strcpy(card->shortname, "S3 SonicVibes"); 1443 strcpy(card->shortname, "S3 SonicVibes");
1444 sprintf(card->longname, "%s rev %i at 0x%lx, irq %i", 1444 sprintf(card->longname, "%s rev %i at 0x%llx, irq %i",
1445 card->shortname, 1445 card->shortname,
1446 sonic->revision, 1446 sonic->revision,
1447 pci_resource_start(pci, 1), 1447 (unsigned long long)pci_resource_start(pci, 1),
1448 sonic->irq); 1448 sonic->irq);
1449 1449
1450 if ((err = snd_sonicvibes_pcm(sonic, 0, NULL)) < 0) { 1450 if ((err = snd_sonicvibes_pcm(sonic, 0, NULL)) < 0) {
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index b678814975c9..be98f6377339 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1170,9 +1170,10 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1170 chip->rsrc[i].start + 1, 1170 chip->rsrc[i].start + 1,
1171 rnames[i]) == NULL) { 1171 rnames[i]) == NULL) {
1172 printk(KERN_ERR "snd: can't request rsrc " 1172 printk(KERN_ERR "snd: can't request rsrc "
1173 " %d (%s: 0x%08lx:%08lx)\n", 1173 " %d (%s: 0x%016lx:%016lx)\n",
1174 i, rnames[i], chip->rsrc[i].start, 1174 i, rnames[i],
1175 chip->rsrc[i].end); 1175 (unsigned long long)chip->rsrc[i].start,
1176 (unsigned long long)chip->rsrc[i].end);
1176 err = -ENODEV; 1177 err = -ENODEV;
1177 goto __error; 1178 goto __error;
1178 } 1179 }
@@ -1201,9 +1202,10 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1201 chip->rsrc[i].start + 1, 1202 chip->rsrc[i].start + 1,
1202 rnames[i]) == NULL) { 1203 rnames[i]) == NULL) {
1203 printk(KERN_ERR "snd: can't request rsrc " 1204 printk(KERN_ERR "snd: can't request rsrc "
1204 " %d (%s: 0x%08lx:%08lx)\n", 1205 " %d (%s: 0x%016llx:%016llx)\n",
1205 i, rnames[i], chip->rsrc[i].start, 1206 i, rnames[i],
1206 chip->rsrc[i].end); 1207 (unsigned long long)chip->rsrc[i].start,
1208 (unsigned long long)chip->rsrc[i].end);
1207 err = -ENODEV; 1209 err = -ENODEV;
1208 goto __error; 1210 goto __error;
1209 } 1211 }
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/sound/ppc/toonie.c
+++ /dev/null
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 6f849720aef3..7535ec821dcf 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -44,7 +44,6 @@
44#include <linux/sound.h> 44#include <linux/sound.h>
45#include <linux/major.h> 45#include <linux/major.h>
46#include <linux/kmod.h> 46#include <linux/kmod.h>
47#include <linux/devfs_fs_kernel.h>
48#include <linux/device.h> 47#include <linux/device.h>
49 48
50#define SOUND_STEP 16 49#define SOUND_STEP 16
@@ -172,8 +171,6 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
172 else 171 else
173 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); 172 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
174 173
175 devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
176 S_IFCHR | mode, s->name);
177 class_device_create(sound_class, NULL, MKDEV(SOUND_MAJOR, s->unit_minor), 174 class_device_create(sound_class, NULL, MKDEV(SOUND_MAJOR, s->unit_minor),
178 dev, s->name+6); 175 dev, s->name+6);
179 return r; 176 return r;
@@ -197,7 +194,6 @@ static void sound_remove_unit(struct sound_unit **list, int unit)
197 p = __sound_remove_unit(list, unit); 194 p = __sound_remove_unit(list, unit);
198 spin_unlock(&sound_loader_lock); 195 spin_unlock(&sound_loader_lock);
199 if (p) { 196 if (p) {
200 devfs_remove(p->name);
201 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); 197 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor));
202 kfree(p); 198 kfree(p);
203 } 199 }
@@ -570,7 +566,6 @@ static void __exit cleanup_soundcore(void)
570 /* We have nothing to really do here - we know the lists must be 566 /* We have nothing to really do here - we know the lists must be
571 empty */ 567 empty */
572 unregister_chrdev(SOUND_MAJOR, "sound"); 568 unregister_chrdev(SOUND_MAJOR, "sound");
573 devfs_remove("sound");
574 class_destroy(sound_class); 569 class_destroy(sound_class);
575} 570}
576 571
@@ -580,7 +575,6 @@ static int __init init_soundcore(void)
580 printk(KERN_ERR "soundcore: sound device already in use.\n"); 575 printk(KERN_ERR "soundcore: sound device already in use.\n");
581 return -EBUSY; 576 return -EBUSY;
582 } 577 }
583 devfs_mk_dir ("sound");
584 sound_class = class_create(THIS_MODULE, "sound"); 578 sound_class = class_create(THIS_MODULE, "sound");
585 if (IS_ERR(sound_class)) 579 if (IS_ERR(sound_class))
586 return PTR_ERR(sound_class); 580 return PTR_ERR(sound_class);
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index da54d04a3e3a..d9d14c2707db 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -2037,10 +2037,10 @@ static int __init cs4231_sbus_attach(struct sbus_dev *sdev)
2037 if (err) 2037 if (err)
2038 return err; 2038 return err;
2039 2039
2040 sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %d", 2040 sprintf(card->longname, "%s at 0x%02lx:0x%016lx, irq %d",
2041 card->shortname, 2041 card->shortname,
2042 rp->flags & 0xffL, 2042 rp->flags & 0xffL,
2043 rp->start, 2043 (unsigned long long)rp->start,
2044 sdev->irqs[0]); 2044 sdev->irqs[0]);
2045 2045
2046 if ((err = snd_cs4231_sbus_create(card, sdev, dev, &cp)) < 0) { 2046 if ((err = snd_cs4231_sbus_create(card, sdev, dev, &cp)) < 0) {
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 5eecdd09a79d..a7489a3dd75a 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -2645,9 +2645,9 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev)
2645 strcpy(card->driver, "DBRI"); 2645 strcpy(card->driver, "DBRI");
2646 strcpy(card->shortname, "Sun DBRI"); 2646 strcpy(card->shortname, "Sun DBRI");
2647 rp = &sdev->resource[0]; 2647 rp = &sdev->resource[0];
2648 sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %d", 2648 sprintf(card->longname, "%s at 0x%02lx:0x%016lx, irq %d",
2649 card->shortname, 2649 card->shortname,
2650 rp->flags & 0xffL, rp->start, irq.pri); 2650 rp->flags & 0xffL, (unsigned long long)rp->start, irq.pri);
2651 2651
2652 if ((err = snd_dbri_create(card, sdev, &irq, dev)) < 0) { 2652 if ((err = snd_dbri_create(card, sdev, &irq, dev)) < 0) {
2653 snd_card_free(card); 2653 snd_card_free(card);
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 627de9525a32..d32d83d970cc 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -3096,6 +3096,32 @@ static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev)
3096} 3096}
3097 3097
3098/* 3098/*
3099 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely
3100 * documented in the device's data sheet.
3101 */
3102static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value)
3103{
3104 u8 buf[4];
3105 buf[0] = 0x20;
3106 buf[1] = value & 0xff;
3107 buf[2] = (value >> 8) & 0xff;
3108 buf[3] = reg;
3109 return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION,
3110 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
3111 0, 0, &buf, 4, 1000);
3112}
3113
3114static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
3115{
3116 /*
3117 * Enable line-out driver mode, set headphone source to front
3118 * channels, enable stereo mic.
3119 */
3120 return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
3121}
3122
3123
3124/*
3099 * Setup quirks 3125 * Setup quirks
3100 */ 3126 */
3101#define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */ 3127#define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */
@@ -3365,6 +3391,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
3365 goto __err_val; 3391 goto __err_val;
3366 } 3392 }
3367 3393
3394 /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
3395 if (id == USB_ID(0x10f5, 0x0200)) {
3396 if (snd_usb_cm106_boot_quirk(dev) < 0)
3397 goto __err_val;
3398 }
3399
3368 /* 3400 /*
3369 * found a config. now register to ALSA 3401 * found a config. now register to ALSA
3370 */ 3402 */